]> git.ipfire.org Git - thirdparty/u-boot.git/blame - arch/openrisc/include/asm/io.h
Add GPL-2.0+ SPDX-License-Identifier to source files
[thirdparty/u-boot.git] / arch / openrisc / include / asm / io.h
CommitLineData
ca9d3ab5
SK
1/*
2 * (C) Copyright 2011, Julius Baxter <julius@opencores.org>
3 *
1a459660 4 * SPDX-License-Identifier: GPL-2.0+
ca9d3ab5
SK
5 */
6
7#ifndef __ASM_OPENRISC_IO_H
8#define __ASM_OPENRISC_IO_H
9
10/*
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".
14 */
15#define MAP_NOCACHE (0)
16#define MAP_WRCOMBINE (0)
17#define MAP_WRBACK (0)
18#define MAP_WRTHROUGH (0)
19
20static inline void *
21map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
22{
23 return (void *)paddr;
24}
25
26/*
27 * Take down a mapping set up by map_physmem().
28 */
29static inline void unmap_physmem(void *vaddr, unsigned long flags)
30{
31
32}
33
34/*
35 * Change virtual addresses to physical addresses
36 */
37static inline phys_addr_t virt_to_phys(void *vaddr)
38{
39 return (phys_addr_t)(vaddr);
40}
41
42
43/*
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.
48 */
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
55
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
62
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))
66
67/*
68 * Again, OpenRISC does not require mem IO specific function.
69 */
70
71
72#define IO_BASE 0x0
73#define IO_SPACE_LIMIT 0xffffffff
74
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))
79
80/*
81 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
82 * access
83 */
84#define xlate_dev_mem_ptr(p) __va(p)
85
86/*
87 * Convert a virtual cached pointer to an uncached pointer
88 */
89#define xlate_dev_kmem_ptr(p) p
90
91#define ioread8(addr) readb(addr)
92#define ioread16(addr) readw(addr)
93#define ioread32(addr) readl(addr)
94
95#define iowrite8(v, addr) writeb((v), (addr))
96#define iowrite16(v, addr) writew((v), (addr))
97#define iowrite32(v, addr) writel((v), (addr))
98
99#endif