blob: 9b738c383f7d83ac782b289fe50c6879f3de10b1 [file] [log] [blame]
wdenk4248acf2000-11-20 17:21:10 +00001/* originally from linux source (asm-ppc/io.h).
2 * Sanity added by Rob Taylor, Flying Pig Systems, 2000
3 */
4#ifndef _PCI_IO_H_
5#define _PCI_IO_H_
6
7#include "io.h"
8
9
10#define pci_read_le16(addr, dest) \
11 __asm__ __volatile__("lhbrx %0,0,%1" : "=r" (dest) : \
wdenk8bde7f72003-06-27 21:31:46 +000012 "r" (addr), "m" (*addr));
wdenk4248acf2000-11-20 17:21:10 +000013
14#define pci_write_le16(addr, val) \
15 __asm__ __volatile__("sthbrx %1,0,%2" : "=m" (*addr) : \
wdenk8bde7f72003-06-27 21:31:46 +000016 "r" (val), "r" (addr));
wdenk4248acf2000-11-20 17:21:10 +000017
18
19#define pci_read_le32(addr, dest) \
20 __asm__ __volatile__("lwbrx %0,0,%1" : "=r" (dest) : \
wdenk8bde7f72003-06-27 21:31:46 +000021 "r" (addr), "m" (*addr));
wdenk4248acf2000-11-20 17:21:10 +000022
23#define pci_write_le32(addr, val) \
24__asm__ __volatile__("stwbrx %1,0,%2" : "=m" (*addr) : \
wdenk8bde7f72003-06-27 21:31:46 +000025 "r" (val), "r" (addr));
wdenk4248acf2000-11-20 17:21:10 +000026
27#define pci_readb(addr,b) ((b) = *(volatile u8 *) (addr))
28#define pci_writeb(b,addr) ((*(volatile u8 *) (addr)) = (b))
29
30#if !defined(__BIG_ENDIAN)
31#define pci_readw(addr,b) ((b) = *(volatile u16 *) (addr))
32#define pci_readl(addr,b) ((b) = *(volatile u32 *) (addr))
33#define pci_writew(b,addr) ((*(volatile u16 *) (addr)) = (b))
34#define pci_writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
35#else
36#define pci_readw(addr,b) pci_read_le16((volatile u16 *)(addr),(b))
37#define pci_readl(addr,b) pci_read_le32((volatile u32 *)(addr),(b))
38#define pci_writew(b,addr) pci_write_le16((volatile u16 *)(addr),(b))
39#define pci_writel(b,addr) pci_write_le32((volatile u32 *)(addr),(b))
40#endif
41
42
43#endif /* _PCI_IO_H_ */