Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __GENERIC_IO_H |
| 2 | #define __GENERIC_IO_H |
| 3 | |
| 4 | #include <linux/linkage.h> |
James Bottomley | dae409a | 2005-04-16 15:25:54 -0700 | [diff] [blame] | 5 | #include <asm/byteorder.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
| 7 | /* |
| 8 | * These are the "generic" interfaces for doing new-style |
| 9 | * memory-mapped or PIO accesses. Architectures may do |
| 10 | * their own arch-optimized versions, these just act as |
| 11 | * wrappers around the old-style IO register access functions: |
| 12 | * read[bwl]/write[bwl]/in[bwl]/out[bwl] |
| 13 | * |
| 14 | * Don't include this directly, include it from <asm/io.h>. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * Read/write from/to an (offsettable) iomem cookie. It might be a PIO |
| 19 | * access or a MMIO access, these functions don't care. The info is |
| 20 | * encoded in the hardware mapping set up by the mapping functions |
| 21 | * (or the cookie itself, depending on implementation and hw). |
| 22 | * |
| 23 | * The generic routines just encode the PIO/MMIO as part of the |
| 24 | * cookie, and coldly assume that the MMIO IO mappings are not |
| 25 | * in the low address range. Architectures for which this is not |
| 26 | * true can't use this generic implementation. |
| 27 | */ |
Harvey Harrison | 144b2a9 | 2008-02-08 04:19:56 -0800 | [diff] [blame] | 28 | extern unsigned int ioread8(void __iomem *); |
| 29 | extern unsigned int ioread16(void __iomem *); |
| 30 | extern unsigned int ioread16be(void __iomem *); |
| 31 | extern unsigned int ioread32(void __iomem *); |
| 32 | extern unsigned int ioread32be(void __iomem *); |
Horia Geantă | 9e44fb1 | 2016-05-19 18:10:56 +0300 | [diff] [blame] | 33 | #ifdef CONFIG_64BIT |
| 34 | extern u64 ioread64(void __iomem *); |
| 35 | extern u64 ioread64be(void __iomem *); |
| 36 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Harvey Harrison | 144b2a9 | 2008-02-08 04:19:56 -0800 | [diff] [blame] | 38 | extern void iowrite8(u8, void __iomem *); |
| 39 | extern void iowrite16(u16, void __iomem *); |
| 40 | extern void iowrite16be(u16, void __iomem *); |
| 41 | extern void iowrite32(u32, void __iomem *); |
| 42 | extern void iowrite32be(u32, void __iomem *); |
Horia Geantă | 9e44fb1 | 2016-05-19 18:10:56 +0300 | [diff] [blame] | 43 | #ifdef CONFIG_64BIT |
| 44 | extern void iowrite64(u64, void __iomem *); |
| 45 | extern void iowrite64be(u64, void __iomem *); |
| 46 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | * "string" versions of the above. Note that they |
| 50 | * use native byte ordering for the accesses (on |
| 51 | * the assumption that IO and memory agree on a |
| 52 | * byte order, and CPU byteorder is irrelevant). |
| 53 | * |
| 54 | * They do _not_ update the port address. If you |
| 55 | * want MMIO that copies stuff laid out in MMIO |
| 56 | * memory across multiple ports, use "memcpy_toio()" |
| 57 | * and friends. |
| 58 | */ |
Harvey Harrison | 144b2a9 | 2008-02-08 04:19:56 -0800 | [diff] [blame] | 59 | extern void ioread8_rep(void __iomem *port, void *buf, unsigned long count); |
| 60 | extern void ioread16_rep(void __iomem *port, void *buf, unsigned long count); |
| 61 | extern void ioread32_rep(void __iomem *port, void *buf, unsigned long count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Harvey Harrison | 144b2a9 | 2008-02-08 04:19:56 -0800 | [diff] [blame] | 63 | extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count); |
| 64 | extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count); |
| 65 | extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Uwe Kleine-König | ce816fa | 2014-04-07 15:39:19 -0700 | [diff] [blame] | 67 | #ifdef CONFIG_HAS_IOPORT_MAP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | /* Create a virtual mapping cookie for an IO port range */ |
| 69 | extern void __iomem *ioport_map(unsigned long port, unsigned int nr); |
| 70 | extern void ioport_unmap(void __iomem *); |
Jonas Bonn | 82ed223 | 2011-07-02 17:23:29 +0200 | [diff] [blame] | 71 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
venkatesh.pallipadi@intel.com | 1526a75 | 2008-03-18 17:00:24 -0700 | [diff] [blame] | 73 | #ifndef ARCH_HAS_IOREMAP_WC |
| 74 | #define ioremap_wc ioremap_nocache |
| 75 | #endif |
| 76 | |
Toshi Kani | d838270 | 2015-06-04 18:55:15 +0200 | [diff] [blame] | 77 | #ifndef ARCH_HAS_IOREMAP_WT |
| 78 | #define ioremap_wt ioremap_nocache |
| 79 | #endif |
| 80 | |
Jonas Bonn | 82ed223 | 2011-07-02 17:23:29 +0200 | [diff] [blame] | 81 | #ifdef CONFIG_PCI |
Michael S. Tsirkin | 66eab4d | 2011-11-24 20:45:20 +0200 | [diff] [blame] | 82 | /* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | struct pci_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | extern void pci_iounmap(struct pci_dev *dev, void __iomem *); |
James Bottomley | 97a29d5 | 2012-01-30 10:40:47 -0600 | [diff] [blame] | 85 | #elif defined(CONFIG_GENERIC_IOMAP) |
Randy Dunlap | fea8031 | 2011-07-24 11:39:14 -0700 | [diff] [blame] | 86 | struct pci_dev; |
Randy Dunlap | fea8031 | 2011-07-24 11:39:14 -0700 | [diff] [blame] | 87 | static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) |
| 88 | { } |
Jonas Bonn | 82ed223 | 2011-07-02 17:23:29 +0200 | [diff] [blame] | 89 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
Michael S. Tsirkin | 66eab4d | 2011-11-24 20:45:20 +0200 | [diff] [blame] | 91 | #include <asm-generic/pci_iomap.h> |
| 92 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | #endif |