2 * (C) Copyright 2011, Julius Baxter <julius@opencores.org>
4 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef __ASM_OPENRISC_IO_H
8 #define __ASM_OPENRISC_IO_H
11 * Given a physical address and a length, return a virtual address
12 * that can be used to access the memory range with the caching
13 * properties specified by "flags".
15 #define MAP_NOCACHE (0)
16 #define MAP_WRCOMBINE (0)
17 #define MAP_WRBACK (0)
18 #define MAP_WRTHROUGH (0)
21 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
27 * Take down a mapping set up by map_physmem().
29 static inline void unmap_physmem(void *vaddr, unsigned long flags)
35 * Change virtual addresses to physical addresses
37 static inline phys_addr_t virt_to_phys(void *vaddr)
39 return (phys_addr_t)(vaddr);
44 * readX/writeX() are used to access memory mapped devices. On some
45 * architectures the memory mapped IO stuff needs to be accessed
46 * differently. On the openrisc architecture, we just read/write the
47 * memory location directly.
49 #define readb(addr) (*(volatile unsigned char *) (addr))
50 #define readw(addr) (*(volatile unsigned short *) (addr))
51 #define readl(addr) (*(volatile unsigned int *) (addr))
52 #define __raw_readb readb
53 #define __raw_readw readw
54 #define __raw_readl readl
56 #define writeb(b, addr) ((*(volatile unsigned char *) (addr)) = (b))
57 #define writew(b, addr) ((*(volatile unsigned short *) (addr)) = (b))
58 #define writel(b, addr) ((*(volatile unsigned int *) (addr)) = (b))
59 #define __raw_writeb writeb
60 #define __raw_writew writew
61 #define __raw_writel writel
63 #define memset_io(a, b, c) memset((void *)(a), (b), (c))
64 #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
65 #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
68 * Again, OpenRISC does not require mem IO specific function.
73 #define IO_SPACE_LIMIT 0xffffffff
75 #define inb(port) readb((port + IO_BASE))
76 #define outb(value, port) writeb((value), (port + IO_BASE))
77 #define inb_p(port) inb((port))
78 #define outb_p(value, port) outb((value), (port))
81 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
84 #define xlate_dev_mem_ptr(p) __va(p)
87 * Convert a virtual cached pointer to an uncached pointer
89 #define xlate_dev_kmem_ptr(p) p
91 #define ioread8(addr) readb(addr)
92 #define ioread16(addr) readw(addr)
93 #define ioread32(addr) readl(addr)
95 #define iowrite8(v, addr) writeb((v), (addr))
96 #define iowrite16(v, addr) writew((v), (addr))
97 #define iowrite32(v, addr) writel((v), (addr))