18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (C) 2014 Altera Corporation
38c2ecf20Sopenharmony_ci * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
48c2ecf20Sopenharmony_ci * Copyright (C) 2004 Microtronix Datacom Ltd.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
78c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive
88c2ecf20Sopenharmony_ci * for more details.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef _ASM_NIOS2_IO_H
128c2ecf20Sopenharmony_ci#define _ASM_NIOS2_IO_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/types.h>
158c2ecf20Sopenharmony_ci#include <asm/pgtable-bits.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* PCI is not supported in nios2, set this to 0. */
188c2ecf20Sopenharmony_ci#define IO_SPACE_LIMIT 0
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define readb_relaxed(addr)	readb(addr)
218c2ecf20Sopenharmony_ci#define readw_relaxed(addr)	readw(addr)
228c2ecf20Sopenharmony_ci#define readl_relaxed(addr)	readl(addr)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define writeb_relaxed(x, addr)	writeb(x, addr)
258c2ecf20Sopenharmony_ci#define writew_relaxed(x, addr)	writew(x, addr)
268c2ecf20Sopenharmony_ci#define writel_relaxed(x, addr)	writel(x, addr)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_civoid __iomem *ioremap(unsigned long physaddr, unsigned long size);
298c2ecf20Sopenharmony_civoid iounmap(void __iomem *addr);
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/* Pages to physical address... */
328c2ecf20Sopenharmony_ci#define page_to_phys(page)	virt_to_phys(page_to_virt(page))
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* Macros used for converting between virtual and physical mappings. */
358c2ecf20Sopenharmony_ci#define phys_to_virt(vaddr)	\
368c2ecf20Sopenharmony_ci	((void *)((unsigned long)(vaddr) | CONFIG_NIOS2_KERNEL_REGION_BASE))
378c2ecf20Sopenharmony_ci/* Clear top 3 bits */
388c2ecf20Sopenharmony_ci#define virt_to_phys(vaddr)	\
398c2ecf20Sopenharmony_ci	((unsigned long)((unsigned long)(vaddr) & ~0xE0000000))
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#include <asm-generic/io.h>
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#endif /* _ASM_NIOS2_IO_H */
44