Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 2 | /* |
| 3 | * include/asm-microblaze/io.h -- Misc I/O operations |
| 4 | * |
| 5 | * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au> |
| 6 | * Copyright (C) 2001,02 NEC Corporation |
| 7 | * Copyright (C) 2001,02 Miles Bader <miles@gnu.org> |
| 8 | * |
| 9 | * This file is subject to the terms and conditions of the GNU General |
| 10 | * Public License. See the file COPYING in the main directory of this |
| 11 | * archive for more details. |
| 12 | * |
| 13 | * Written by Miles Bader <miles@gnu.org> |
| 14 | * Microblaze port by John Williams |
| 15 | */ |
| 16 | |
| 17 | #ifndef __MICROBLAZE_IO_H__ |
| 18 | #define __MICROBLAZE_IO_H__ |
| 19 | |
Michal Simek | 403d619 | 2008-07-11 10:10:31 +0200 | [diff] [blame] | 20 | #include <asm/types.h> |
| 21 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 22 | #define IO_SPACE_LIMIT 0xFFFFFFFF |
| 23 | |
| 24 | #define readb(addr) \ |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 25 | ({ unsigned char __v = (*(volatile unsigned char *)(addr)); __v; }) |
| 26 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 27 | #define readw(addr) \ |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 28 | ({ unsigned short __v = (*(volatile unsigned short *)(addr)); __v; }) |
| 29 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 30 | #define readl(addr) \ |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 31 | ({ unsigned int __v = (*(volatile unsigned int *)(addr)); __v; }) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 32 | |
| 33 | #define writeb(b, addr) \ |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 34 | (void)((*(volatile unsigned char *)(addr)) = (b)) |
| 35 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 36 | #define writew(b, addr) \ |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 37 | (void)((*(volatile unsigned short *)(addr)) = (b)) |
| 38 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 39 | #define writel(b, addr) \ |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 40 | (void)((*(volatile unsigned int *)(addr)) = (b)) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 41 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 42 | #define memset_io(a, b, c) memset((void *)(a), (b), (c)) |
| 43 | #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c)) |
| 44 | #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c)) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 45 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 46 | #define inb(addr) readb(addr) |
| 47 | #define inw(addr) readw(addr) |
| 48 | #define inl(addr) readl(addr) |
| 49 | #define outb(x, addr) ((void)writeb(x, addr)) |
| 50 | #define outw(x, addr) ((void)writew(x, addr)) |
| 51 | #define outl(x, addr) ((void)writel(x, addr)) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 52 | |
| 53 | /* Some #definitions to keep strange Xilinx code happy */ |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 54 | #define in_8(addr) readb(addr) |
| 55 | #define in_be16(addr) readw(addr) |
| 56 | #define in_be32(addr) readl(addr) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 57 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 58 | #define out_8(addr, x) outb(x, addr) |
| 59 | #define out_be16(addr, x) outw(x, addr) |
| 60 | #define out_be32(addr, x) outl(x, addr) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 61 | |
| 62 | #define inb_p(port) inb((port)) |
| 63 | #define outb_p(val, port) outb((val), (port)) |
| 64 | #define inw_p(port) inw((port)) |
| 65 | #define outw_p(val, port) outw((val), (port)) |
| 66 | #define inl_p(port) inl((port)) |
| 67 | #define outl_p(val, port) outl((val), (port)) |
| 68 | |
| 69 | /* Some defines to keep the MTD flash drivers happy */ |
| 70 | |
| 71 | #define __raw_readb readb |
| 72 | #define __raw_readw readw |
| 73 | #define __raw_readl readl |
| 74 | #define __raw_writeb writeb |
| 75 | #define __raw_writew writew |
| 76 | #define __raw_writel writel |
| 77 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 78 | static inline void io_insb(unsigned long port, void *dst, unsigned long count) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 79 | { |
| 80 | unsigned char *p = dst; |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 81 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 82 | while (count--) |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 83 | *p++ = inb(port); |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 84 | } |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 85 | |
| 86 | static inline void io_insw(unsigned long port, void *dst, unsigned long count) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 87 | { |
| 88 | unsigned short *p = dst; |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 89 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 90 | while (count--) |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 91 | *p++ = inw(port); |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 92 | } |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 93 | |
| 94 | static inline void io_insl(unsigned long port, void *dst, unsigned long count) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 95 | { |
| 96 | unsigned long *p = dst; |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 97 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 98 | while (count--) |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 99 | *p++ = inl(port); |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | static inline void |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 103 | io_outsb(unsigned long port, const void *src, unsigned long count) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 104 | { |
| 105 | const unsigned char *p = src; |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 106 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 107 | while (count--) |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 108 | outb(*p++, port); |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 109 | } |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 110 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 111 | static inline void |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 112 | io_outsw(unsigned long port, const void *src, unsigned long count) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 113 | { |
| 114 | const unsigned short *p = src; |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 115 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 116 | while (count--) |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 117 | outw(*p++, port); |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 118 | } |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 119 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 120 | static inline void |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 121 | io_outsl(unsigned long port, const void *src, unsigned long count) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 122 | { |
| 123 | const unsigned long *p = src; |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 124 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 125 | while (count--) |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 126 | outl(*p++, port); |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 129 | #define outsb(a, b, l) io_outsb(a, b, l) |
| 130 | #define outsw(a, b, l) io_outsw(a, b, l) |
| 131 | #define outsl(a, b, l) io_outsl(a, b, l) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 132 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 133 | #define insb(a, b, l) io_insb(a, b, l) |
| 134 | #define insw(a, b, l) io_insw(a, b, l) |
| 135 | #define insl(a, b, l) io_insl(a, b, l) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 136 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 137 | #define ioremap_nocache(physaddr, size) (physaddr) |
| 138 | #define ioremap_writethrough(physaddr, size) (physaddr) |
| 139 | #define ioremap_fullcache(physaddr, size) (physaddr) |
| 140 | |
Haiying Wang | c123a38 | 2007-02-21 16:52:31 +0100 | [diff] [blame] | 141 | static inline void sync(void) |
| 142 | { |
| 143 | } |
| 144 | |
Paul Burton | a974ec6 | 2017-09-14 15:05:05 -0700 | [diff] [blame] | 145 | #include <asm-generic/io.h> |
Kumar Gala | 9364a67 | 2008-12-13 17:20:27 -0600 | [diff] [blame] | 146 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 147 | #endif /* __MICROBLAZE_IO_H__ */ |