blob: 8e6be0ae267f47c930437884dd01c2a9bac832b4 [file] [log] [blame]
Shreenidhi Shediffced402018-07-15 02:34:35 +05301/* SPDX-License-Identifier: GPL-2.0+ */
wdenk12490652004-04-18 21:13:41 +00002/*
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 Simek403d6192008-07-11 10:10:31 +020020#include <asm/types.h>
21
wdenk12490652004-04-18 21:13:41 +000022#define IO_SPACE_LIMIT 0xFFFFFFFF
23
24#define readb(addr) \
Shreenidhi Shediffced402018-07-15 02:34:35 +053025 ({ unsigned char __v = (*(volatile unsigned char *)(addr)); __v; })
26
wdenk12490652004-04-18 21:13:41 +000027#define readw(addr) \
Shreenidhi Shediffced402018-07-15 02:34:35 +053028 ({ unsigned short __v = (*(volatile unsigned short *)(addr)); __v; })
29
wdenk12490652004-04-18 21:13:41 +000030#define readl(addr) \
Shreenidhi Shediffced402018-07-15 02:34:35 +053031 ({ unsigned int __v = (*(volatile unsigned int *)(addr)); __v; })
wdenk12490652004-04-18 21:13:41 +000032
33#define writeb(b, addr) \
Shreenidhi Shediffced402018-07-15 02:34:35 +053034 (void)((*(volatile unsigned char *)(addr)) = (b))
35
wdenk12490652004-04-18 21:13:41 +000036#define writew(b, addr) \
Shreenidhi Shediffced402018-07-15 02:34:35 +053037 (void)((*(volatile unsigned short *)(addr)) = (b))
38
wdenk12490652004-04-18 21:13:41 +000039#define writel(b, addr) \
Shreenidhi Shediffced402018-07-15 02:34:35 +053040 (void)((*(volatile unsigned int *)(addr)) = (b))
wdenk12490652004-04-18 21:13:41 +000041
Shreenidhi Shediffced402018-07-15 02:34:35 +053042#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))
wdenk12490652004-04-18 21:13:41 +000045
Shreenidhi Shediffced402018-07-15 02:34:35 +053046#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))
wdenk12490652004-04-18 21:13:41 +000052
53/* Some #definitions to keep strange Xilinx code happy */
Shreenidhi Shediffced402018-07-15 02:34:35 +053054#define in_8(addr) readb(addr)
55#define in_be16(addr) readw(addr)
56#define in_be32(addr) readl(addr)
wdenk12490652004-04-18 21:13:41 +000057
Shreenidhi Shediffced402018-07-15 02:34:35 +053058#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)
wdenk12490652004-04-18 21:13:41 +000061
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 Shediffced402018-07-15 02:34:35 +053078static inline void io_insb(unsigned long port, void *dst, unsigned long count)
wdenk12490652004-04-18 21:13:41 +000079{
80 unsigned char *p = dst;
Shreenidhi Shediffced402018-07-15 02:34:35 +053081
wdenk12490652004-04-18 21:13:41 +000082 while (count--)
Shreenidhi Shediffced402018-07-15 02:34:35 +053083 *p++ = inb(port);
wdenk12490652004-04-18 21:13:41 +000084}
Shreenidhi Shediffced402018-07-15 02:34:35 +053085
86static inline void io_insw(unsigned long port, void *dst, unsigned long count)
wdenk12490652004-04-18 21:13:41 +000087{
88 unsigned short *p = dst;
Shreenidhi Shediffced402018-07-15 02:34:35 +053089
wdenk12490652004-04-18 21:13:41 +000090 while (count--)
Shreenidhi Shediffced402018-07-15 02:34:35 +053091 *p++ = inw(port);
wdenk12490652004-04-18 21:13:41 +000092}
Shreenidhi Shediffced402018-07-15 02:34:35 +053093
94static inline void io_insl(unsigned long port, void *dst, unsigned long count)
wdenk12490652004-04-18 21:13:41 +000095{
96 unsigned long *p = dst;
Shreenidhi Shediffced402018-07-15 02:34:35 +053097
wdenk12490652004-04-18 21:13:41 +000098 while (count--)
Shreenidhi Shediffced402018-07-15 02:34:35 +053099 *p++ = inl(port);
wdenk12490652004-04-18 21:13:41 +0000100}
101
102static inline void
Shreenidhi Shediffced402018-07-15 02:34:35 +0530103io_outsb(unsigned long port, const void *src, unsigned long count)
wdenk12490652004-04-18 21:13:41 +0000104{
105 const unsigned char *p = src;
Shreenidhi Shediffced402018-07-15 02:34:35 +0530106
wdenk12490652004-04-18 21:13:41 +0000107 while (count--)
Shreenidhi Shediffced402018-07-15 02:34:35 +0530108 outb(*p++, port);
wdenk12490652004-04-18 21:13:41 +0000109}
Shreenidhi Shediffced402018-07-15 02:34:35 +0530110
wdenk12490652004-04-18 21:13:41 +0000111static inline void
Shreenidhi Shediffced402018-07-15 02:34:35 +0530112io_outsw(unsigned long port, const void *src, unsigned long count)
wdenk12490652004-04-18 21:13:41 +0000113{
114 const unsigned short *p = src;
Shreenidhi Shediffced402018-07-15 02:34:35 +0530115
wdenk12490652004-04-18 21:13:41 +0000116 while (count--)
Shreenidhi Shediffced402018-07-15 02:34:35 +0530117 outw(*p++, port);
wdenk12490652004-04-18 21:13:41 +0000118}
Shreenidhi Shediffced402018-07-15 02:34:35 +0530119
wdenk12490652004-04-18 21:13:41 +0000120static inline void
Shreenidhi Shediffced402018-07-15 02:34:35 +0530121io_outsl(unsigned long port, const void *src, unsigned long count)
wdenk12490652004-04-18 21:13:41 +0000122{
123 const unsigned long *p = src;
Shreenidhi Shediffced402018-07-15 02:34:35 +0530124
wdenk12490652004-04-18 21:13:41 +0000125 while (count--)
Shreenidhi Shediffced402018-07-15 02:34:35 +0530126 outl(*p++, port);
wdenk12490652004-04-18 21:13:41 +0000127}
128
Shreenidhi Shediffced402018-07-15 02:34:35 +0530129#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)
wdenk12490652004-04-18 21:13:41 +0000132
Shreenidhi Shediffced402018-07-15 02:34:35 +0530133#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)
wdenk12490652004-04-18 21:13:41 +0000136
wdenk12490652004-04-18 21:13:41 +0000137#define ioremap_nocache(physaddr, size) (physaddr)
138#define ioremap_writethrough(physaddr, size) (physaddr)
139#define ioremap_fullcache(physaddr, size) (physaddr)
140
Haiying Wangc123a382007-02-21 16:52:31 +0100141static inline void sync(void)
142{
143}
144
Paul Burtona974ec62017-09-14 15:05:05 -0700145#include <asm-generic/io.h>
Kumar Gala9364a672008-12-13 17:20:27 -0600146
wdenk12490652004-04-18 21:13:41 +0000147#endif /* __MICROBLAZE_IO_H__ */