treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / sparc / include / asm / io_32.h
blob9a52d9506f80b7d58cb14a60ee6784d377348229
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __SPARC_IO_H
3 #define __SPARC_IO_H
5 #include <linux/kernel.h>
6 #include <linux/ioport.h> /* struct resource */
8 #define IO_SPACE_LIMIT 0xffffffff
10 #define memset_io(d,c,sz) _memset_io(d,c,sz)
11 #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
12 #define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
14 #include <asm-generic/io.h>
16 static inline void _memset_io(volatile void __iomem *dst,
17 int c, __kernel_size_t n)
19 volatile void __iomem *d = dst;
21 while (n--) {
22 writeb(c, d);
23 d++;
27 static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src,
28 __kernel_size_t n)
30 char *d = dst;
32 while (n--) {
33 char tmp = readb(src);
34 *d++ = tmp;
35 src++;
39 static inline void _memcpy_toio(volatile void __iomem *dst, const void *src,
40 __kernel_size_t n)
42 const char *s = src;
43 volatile void __iomem *d = dst;
45 while (n--) {
46 char tmp = *s++;
47 writeb(tmp, d);
48 d++;
53 * SBus accessors.
55 * SBus has only one, memory mapped, I/O space.
56 * We do not need to flip bytes for SBus of course.
58 static inline u8 sbus_readb(const volatile void __iomem *addr)
60 return *(__force volatile u8 *)addr;
63 static inline u16 sbus_readw(const volatile void __iomem *addr)
65 return *(__force volatile u16 *)addr;
68 static inline u32 sbus_readl(const volatile void __iomem *addr)
70 return *(__force volatile u32 *)addr;
73 static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
75 *(__force volatile u8 *)addr = b;
78 static inline void sbus_writew(u16 w, volatile void __iomem *addr)
80 *(__force volatile u16 *)addr = w;
83 static inline void sbus_writel(u32 l, volatile void __iomem *addr)
85 *(__force volatile u32 *)addr = l;
88 static inline void sbus_memset_io(volatile void __iomem *__dst, int c,
89 __kernel_size_t n)
91 while(n--) {
92 sbus_writeb(c, __dst);
93 __dst++;
97 static inline void sbus_memcpy_fromio(void *dst,
98 const volatile void __iomem *src,
99 __kernel_size_t n)
101 char *d = dst;
103 while (n--) {
104 char tmp = sbus_readb(src);
105 *d++ = tmp;
106 src++;
110 static inline void sbus_memcpy_toio(volatile void __iomem *dst,
111 const void *src,
112 __kernel_size_t n)
114 const char *s = src;
115 volatile void __iomem *d = dst;
117 while (n--) {
118 char tmp = *s++;
119 sbus_writeb(tmp, d);
120 d++;
124 #ifdef __KERNEL__
127 * Bus number may be embedded in the higher bits of the physical address.
128 * This is why we have no bus number argument to ioremap().
130 void __iomem *ioremap(phys_addr_t offset, size_t size);
131 void iounmap(volatile void __iomem *addr);
132 /* Create a virtual mapping cookie for an IO port range */
133 void __iomem *ioport_map(unsigned long port, unsigned int nr);
134 void ioport_unmap(void __iomem *);
136 /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
137 struct pci_dev;
138 void pci_iounmap(struct pci_dev *dev, void __iomem *);
140 static inline int sbus_can_dma_64bit(void)
142 return 0; /* actually, sparc_cpu_model==sun4d */
144 static inline int sbus_can_burst64(void)
146 return 0; /* actually, sparc_cpu_model==sun4d */
148 struct device;
149 void sbus_set_sbus64(struct device *, int);
151 #endif
153 #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
156 #endif /* !(__SPARC_IO_H) */