Loading...
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * ppc64 "iomap" interface implementation.
4 *
5 * (C) Copyright 2004 Linus Torvalds
6 */
7#include <linux/pci.h>
8#include <linux/mm.h>
9#include <linux/export.h>
10#include <asm/io.h>
11#include <asm/pci-bridge.h>
12#include <asm/isa-bridge.h>
13
14void __iomem *ioport_map(unsigned long port, unsigned int len)
15{
16 return (void __iomem *) (port + _IO_BASE);
17}
18EXPORT_SYMBOL(ioport_map);
19
20#ifdef CONFIG_PCI
21void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
22{
23 if (isa_vaddr_is_ioport(addr))
24 return;
25 if (pcibios_vaddr_is_ioport(addr))
26 return;
27 iounmap(addr);
28}
29
30EXPORT_SYMBOL(pci_iounmap);
31#endif /* CONFIG_PCI */
1/*
2 * ppc64 "iomap" interface implementation.
3 *
4 * (C) Copyright 2004 Linus Torvalds
5 */
6#include <linux/pci.h>
7#include <linux/mm.h>
8#include <linux/export.h>
9#include <asm/io.h>
10#include <asm/pci-bridge.h>
11
12/*
13 * Here comes the ppc64 implementation of the IOMAP
14 * interfaces.
15 */
16unsigned int ioread8(void __iomem *addr)
17{
18 return readb(addr);
19}
20unsigned int ioread16(void __iomem *addr)
21{
22 return readw(addr);
23}
24unsigned int ioread16be(void __iomem *addr)
25{
26 return in_be16(addr);
27}
28unsigned int ioread32(void __iomem *addr)
29{
30 return readl(addr);
31}
32unsigned int ioread32be(void __iomem *addr)
33{
34 return in_be32(addr);
35}
36EXPORT_SYMBOL(ioread8);
37EXPORT_SYMBOL(ioread16);
38EXPORT_SYMBOL(ioread16be);
39EXPORT_SYMBOL(ioread32);
40EXPORT_SYMBOL(ioread32be);
41
42void iowrite8(u8 val, void __iomem *addr)
43{
44 writeb(val, addr);
45}
46void iowrite16(u16 val, void __iomem *addr)
47{
48 writew(val, addr);
49}
50void iowrite16be(u16 val, void __iomem *addr)
51{
52 out_be16(addr, val);
53}
54void iowrite32(u32 val, void __iomem *addr)
55{
56 writel(val, addr);
57}
58void iowrite32be(u32 val, void __iomem *addr)
59{
60 out_be32(addr, val);
61}
62EXPORT_SYMBOL(iowrite8);
63EXPORT_SYMBOL(iowrite16);
64EXPORT_SYMBOL(iowrite16be);
65EXPORT_SYMBOL(iowrite32);
66EXPORT_SYMBOL(iowrite32be);
67
68/*
69 * These are the "repeat read/write" functions. Note the
70 * non-CPU byte order. We do things in "IO byteorder"
71 * here.
72 *
73 * FIXME! We could make these do EEH handling if we really
74 * wanted. Not clear if we do.
75 */
76void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
77{
78 _insb((u8 __iomem *) addr, dst, count);
79}
80void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
81{
82 _insw_ns((u16 __iomem *) addr, dst, count);
83}
84void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
85{
86 _insl_ns((u32 __iomem *) addr, dst, count);
87}
88EXPORT_SYMBOL(ioread8_rep);
89EXPORT_SYMBOL(ioread16_rep);
90EXPORT_SYMBOL(ioread32_rep);
91
92void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
93{
94 _outsb((u8 __iomem *) addr, src, count);
95}
96void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
97{
98 _outsw_ns((u16 __iomem *) addr, src, count);
99}
100void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
101{
102 _outsl_ns((u32 __iomem *) addr, src, count);
103}
104EXPORT_SYMBOL(iowrite8_rep);
105EXPORT_SYMBOL(iowrite16_rep);
106EXPORT_SYMBOL(iowrite32_rep);
107
108void __iomem *ioport_map(unsigned long port, unsigned int len)
109{
110 return (void __iomem *) (port + _IO_BASE);
111}
112
113void ioport_unmap(void __iomem *addr)
114{
115 /* Nothing to do */
116}
117EXPORT_SYMBOL(ioport_map);
118EXPORT_SYMBOL(ioport_unmap);
119
120#ifdef CONFIG_PCI
121void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
122{
123 if (isa_vaddr_is_ioport(addr))
124 return;
125 if (pcibios_vaddr_is_ioport(addr))
126 return;
127 iounmap(addr);
128}
129
130EXPORT_SYMBOL(pci_iounmap);
131#endif /* CONFIG_PCI */