blob: 6e24d7cceb0c1407db80f7354e662f11b5f7d339 [file] [log] [blame]
Ley Foon Tan6b8baec2014-11-06 15:19:42 +08001/*
2 * Copyright (C) 2014 Altera Corporation
3 * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
4 * Copyright (C) 2004 Microtronix Datacom Ltd.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _ASM_NIOS2_IO_H
12#define _ASM_NIOS2_IO_H
13
Ley Foon Tan61810322014-11-20 19:01:43 +080014#include <linux/types.h>
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080015#include <asm/pgtable-bits.h>
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080016
17/* PCI is not supported in nios2, set this to 0. */
18#define IO_SPACE_LIMIT 0
19
20#define readb_relaxed(addr) readb(addr)
21#define readw_relaxed(addr) readw(addr)
22#define readl_relaxed(addr) readl(addr)
23
24#define writeb_relaxed(x, addr) writeb(x, addr)
25#define writew_relaxed(x, addr) writew(x, addr)
26#define writel_relaxed(x, addr) writel(x, addr)
27
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080028extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size,
29 unsigned long cacheflag);
30extern void __iounmap(void __iomem *addr);
31
32static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
33{
34 return __ioremap(physaddr, size, 0);
35}
36
37static inline void __iomem *ioremap_nocache(unsigned long physaddr,
38 unsigned long size)
39{
40 return __ioremap(physaddr, size, 0);
41}
42
43static inline void iounmap(void __iomem *addr)
44{
45 __iounmap(addr);
46}
47
Guenter Roeck76367a52014-12-11 10:36:42 +080048#define ioremap_wc ioremap_nocache
49
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080050/* Pages to physical address... */
Ley Foon Tan568f6ba2014-11-20 18:44:56 +080051#define page_to_phys(page) virt_to_phys(page_to_virt(page))
52#define page_to_bus(page) page_to_virt(page)
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080053
54/* Macros used for converting between virtual and physical mappings. */
Ley Foon Tan568f6ba2014-11-20 18:44:56 +080055#define phys_to_virt(vaddr) \
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080056 ((void *)((unsigned long)(vaddr) | CONFIG_NIOS2_KERNEL_REGION_BASE))
57/* Clear top 3 bits */
Ley Foon Tan568f6ba2014-11-20 18:44:56 +080058#define virt_to_phys(vaddr) \
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080059 ((unsigned long)((unsigned long)(vaddr) & ~0xE0000000))
60
Ley Foon Tan065a1132014-11-20 19:04:41 +080061#include <asm-generic/io.h>
62
Ley Foon Tan6b8baec2014-11-06 15:19:42 +080063#endif /* _ASM_NIOS2_IO_H */