xref: /openbmc/u-boot/arch/powerpc/include/asm/pci_io.h (revision fd0bc623)
1 /* 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) : \
12 		  "r" (addr), "m" (*addr));
13 
14 #define pci_write_le16(addr, val) \
15     __asm__ __volatile__("sthbrx %1,0,%2" : "=m" (*addr) : \
16 		  "r" (val), "r" (addr));
17 
18 
19 #define pci_read_le32(addr, dest) \
20     __asm__ __volatile__("lwbrx %0,0,%1" : "=r" (dest) : \
21 		 "r" (addr), "m" (*addr));
22 
23 #define pci_write_le32(addr, val) \
24 __asm__ __volatile__("stwbrx %1,0,%2" : "=m" (*addr) : \
25 		 "r" (val), "r" (addr));
26 
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_ */
44