1 /* SPARC I/O definitions
4 * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
6 * SPDX-License-Identifier: GPL-2.0+
12 /* Nothing to sync, total store ordering (TSO)... */
15 /* Forces a cache miss on read/load.
16 * On some architectures we need to bypass the cache when reading
17 * I/O registers so that we are not reading the same status word
18 * over and over again resulting in a hang (until an IRQ if lucky)
21 #ifndef CONFIG_SYS_HAS_NO_CACHE
22 #define READ_BYTE(var) SPARC_NOCACHE_READ_BYTE((unsigned int)(var))
23 #define READ_HWORD(var) SPARC_NOCACHE_READ_HWORD((unsigned int)(var))
24 #define READ_WORD(var) SPARC_NOCACHE_READ((unsigned int)(var))
25 #define READ_DWORD(var) SPARC_NOCACHE_READ_DWORD((unsigned int)(var))
27 #define READ_BYTE(var) (var)
28 #define READ_HWORD(var) (var)
29 #define READ_WORD(var) (var)
30 #define READ_DWORD(var) (var)
34 * Generic virtual read/write.
36 #define __arch_getb(a) (READ_BYTE(a))
37 #define __arch_getw(a) (READ_HWORD(a))
38 #define __arch_getl(a) (READ_WORD(a))
39 #define __arch_getq(a) (READ_DWORD(a))
41 #define __arch_putb(v,a) (*(volatile unsigned char *)(a) = (v))
42 #define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
43 #define __arch_putl(v,a) (*(volatile unsigned int *)(a) = (v))
45 #define __raw_writeb(v,a) __arch_putb(v,a)
46 #define __raw_writew(v,a) __arch_putw(v,a)
47 #define __raw_writel(v,a) __arch_putl(v,a)
49 #define __raw_readb(a) __arch_getb(a)
50 #define __raw_readw(a) __arch_getw(a)
51 #define __raw_readl(a) __arch_getl(a)
52 #define __raw_readq(a) __arch_getq(a)
55 * Given a physical address and a length, return a virtual address
56 * that can be used to access the memory range with the caching
57 * properties specified by "flags".
60 #define MAP_NOCACHE (0)
61 #define MAP_WRCOMBINE (0)
62 #define MAP_WRBACK (0)
63 #define MAP_WRTHROUGH (0)
65 static inline void *map_physmem(phys_addr_t paddr, unsigned long len,
72 * Take down a mapping set up by map_physmem().
74 static inline void unmap_physmem(void *vaddr, unsigned long flags)
79 static inline phys_addr_t virt_to_phys(void * vaddr)
81 return (phys_addr_t)(vaddr);