Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 1 | /* |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 2 | * include/asm-xtensa/io.h |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file "COPYING" in the main directory of this archive |
| 6 | * for more details. |
| 7 | * |
| 8 | * Copyright (C) 2001 - 2005 Tensilica Inc. |
| 9 | */ |
| 10 | |
| 11 | #ifndef _XTENSA_IO_H |
| 12 | #define _XTENSA_IO_H |
| 13 | |
| 14 | #ifdef __KERNEL__ |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 15 | #include <asm/byteorder.h> |
Adrian Bunk | c51aea8 | 2007-07-23 18:43:54 -0700 | [diff] [blame] | 16 | #include <asm/page.h> |
Baruch Siach | 4809bb4 | 2013-11-17 08:14:54 +0200 | [diff] [blame] | 17 | #include <asm/vectors.h> |
Paul Gortmaker | bfae8ee | 2012-04-18 16:20:38 -0400 | [diff] [blame] | 18 | #include <linux/bug.h> |
Chris Zankel | 6656920 | 2007-08-22 10:14:51 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 20 | |
| 21 | #include <linux/types.h> |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 22 | |
Chris Zankel | 00c81d2 | 2008-10-21 09:08:31 -0700 | [diff] [blame] | 23 | #define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x)) |
Max Filippov | d38efc1 | 2012-09-17 05:44:40 +0400 | [diff] [blame] | 24 | #define IO_SPACE_LIMIT ~0 |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 25 | |
Max Filippov | d38efc1 | 2012-09-17 05:44:40 +0400 | [diff] [blame] | 26 | #ifdef CONFIG_MMU |
Baruch Siach | 6cb9711 | 2013-12-29 11:03:30 +0200 | [diff] [blame] | 27 | |
Max Filippov | 5bb8def | 2015-12-10 17:05:27 -0800 | [diff] [blame] | 28 | void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size); |
| 29 | void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size); |
| 30 | void xtensa_iounmap(volatile void __iomem *addr); |
| 31 | |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 32 | /* |
Max Filippov | d38efc1 | 2012-09-17 05:44:40 +0400 | [diff] [blame] | 33 | * Return the virtual address for the specified bus memory. |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 34 | */ |
Max Filippov | 02f3774 | 2012-09-17 05:44:39 +0400 | [diff] [blame] | 35 | static inline void __iomem *ioremap_nocache(unsigned long offset, |
| 36 | unsigned long size) |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 37 | { |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 38 | if (offset >= XCHAL_KIO_PADDR |
Max Filippov | 02f3774 | 2012-09-17 05:44:39 +0400 | [diff] [blame] | 39 | && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 40 | return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR); |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 41 | else |
Max Filippov | 5bb8def | 2015-12-10 17:05:27 -0800 | [diff] [blame] | 42 | return xtensa_ioremap_nocache(offset, size); |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Max Filippov | 02f3774 | 2012-09-17 05:44:39 +0400 | [diff] [blame] | 45 | static inline void __iomem *ioremap_cache(unsigned long offset, |
| 46 | unsigned long size) |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 47 | { |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 48 | if (offset >= XCHAL_KIO_PADDR |
Max Filippov | 02f3774 | 2012-09-17 05:44:39 +0400 | [diff] [blame] | 49 | && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 50 | return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR); |
| 51 | else |
Max Filippov | 5bb8def | 2015-12-10 17:05:27 -0800 | [diff] [blame] | 52 | return xtensa_ioremap_cache(offset, size); |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 53 | } |
Dan Williams | 92281dee | 2015-08-10 23:07:06 -0400 | [diff] [blame] | 54 | #define ioremap_cache ioremap_cache |
Greentime Hu | 94bc61e | 2018-02-21 14:21:23 +0800 | [diff] [blame] | 55 | #define ioremap_nocache ioremap_nocache |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 56 | |
Max Filippov | 02f3774 | 2012-09-17 05:44:39 +0400 | [diff] [blame] | 57 | #define ioremap_wc ioremap_nocache |
Toshi Kani | 556269c | 2015-06-04 18:55:16 +0200 | [diff] [blame] | 58 | #define ioremap_wt ioremap_nocache |
Max Filippov | 02f3774 | 2012-09-17 05:44:39 +0400 | [diff] [blame] | 59 | |
| 60 | static inline void __iomem *ioremap(unsigned long offset, unsigned long size) |
| 61 | { |
| 62 | return ioremap_nocache(offset, size); |
| 63 | } |
| 64 | |
| 65 | static inline void iounmap(volatile void __iomem *addr) |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 66 | { |
Max Filippov | 5bb8def | 2015-12-10 17:05:27 -0800 | [diff] [blame] | 67 | unsigned long va = (unsigned long) addr; |
| 68 | |
| 69 | if (!(va >= XCHAL_KIO_CACHED_VADDR && |
| 70 | va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) && |
| 71 | !(va >= XCHAL_KIO_BYPASS_VADDR && |
| 72 | va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) |
| 73 | xtensa_iounmap(addr); |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 74 | } |
Chris Zankel | cddfcbc | 2012-10-23 20:25:37 -0700 | [diff] [blame] | 75 | |
| 76 | #define virt_to_bus virt_to_phys |
| 77 | #define bus_to_virt phys_to_virt |
| 78 | |
Max Filippov | d38efc1 | 2012-09-17 05:44:40 +0400 | [diff] [blame] | 79 | #endif /* CONFIG_MMU */ |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 80 | |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 81 | #endif /* __KERNEL__ */ |
| 82 | |
Max Filippov | d38efc1 | 2012-09-17 05:44:40 +0400 | [diff] [blame] | 83 | #include <asm-generic/io.h> |
| 84 | |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 85 | #endif /* _XTENSA_IO_H */ |