blob: 74fed0b4e2c2b58a84bd0bbc699d7bca74f422de [file] [log] [blame]
Chris Zankel9a8fd552005-06-23 22:01:26 -07001/*
Chris Zankel173d6682006-12-10 02:18:48 -08002 * include/asm-xtensa/io.h
Chris Zankel9a8fd552005-06-23 22:01:26 -07003 *
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 Zankel9a8fd552005-06-23 22:01:26 -070015#include <asm/byteorder.h>
Adrian Bunkc51aea82007-07-23 18:43:54 -070016#include <asm/page.h>
Baruch Siach4809bb42013-11-17 08:14:54 +020017#include <asm/vectors.h>
Paul Gortmakerbfae8ee2012-04-18 16:20:38 -040018#include <linux/bug.h>
Chris Zankel66569202007-08-22 10:14:51 -070019#include <linux/kernel.h>
Chris Zankel9a8fd552005-06-23 22:01:26 -070020
21#include <linux/types.h>
Chris Zankel9a8fd552005-06-23 22:01:26 -070022
Chris Zankel00c81d22008-10-21 09:08:31 -070023#define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x))
Max Filippovd38efc12012-09-17 05:44:40 +040024#define IO_SPACE_LIMIT ~0
Chris Zankel9a8fd552005-06-23 22:01:26 -070025
Max Filippovd38efc12012-09-17 05:44:40 +040026#ifdef CONFIG_MMU
Baruch Siach6cb97112013-12-29 11:03:30 +020027
Chris Zankel9a8fd552005-06-23 22:01:26 -070028/*
Max Filippovd38efc12012-09-17 05:44:40 +040029 * Return the virtual address for the specified bus memory.
Chris Zankel173d6682006-12-10 02:18:48 -080030 * Note that we currently don't support any address outside the KIO segment.
Chris Zankel9a8fd552005-06-23 22:01:26 -070031 */
Max Filippov02f37742012-09-17 05:44:39 +040032static inline void __iomem *ioremap_nocache(unsigned long offset,
33 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070034{
Chris Zankel173d6682006-12-10 02:18:48 -080035 if (offset >= XCHAL_KIO_PADDR
Max Filippov02f37742012-09-17 05:44:39 +040036 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
Chris Zankel173d6682006-12-10 02:18:48 -080037 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
Chris Zankel173d6682006-12-10 02:18:48 -080038 else
39 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070040}
41
Max Filippov02f37742012-09-17 05:44:39 +040042static inline void __iomem *ioremap_cache(unsigned long offset,
43 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070044{
Chris Zankel173d6682006-12-10 02:18:48 -080045 if (offset >= XCHAL_KIO_PADDR
Max Filippov02f37742012-09-17 05:44:39 +040046 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
Chris Zankel173d6682006-12-10 02:18:48 -080047 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
48 else
49 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070050}
Dan Williams92281dee2015-08-10 23:07:06 -040051#define ioremap_cache ioremap_cache
Chris Zankel9a8fd552005-06-23 22:01:26 -070052
Max Filippov02f37742012-09-17 05:44:39 +040053#define ioremap_wc ioremap_nocache
Toshi Kani556269c2015-06-04 18:55:16 +020054#define ioremap_wt ioremap_nocache
Max Filippov02f37742012-09-17 05:44:39 +040055
56static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
57{
58 return ioremap_nocache(offset, size);
59}
60
61static inline void iounmap(volatile void __iomem *addr)
Chris Zankel9a8fd552005-06-23 22:01:26 -070062{
63}
Chris Zankelcddfcbc2012-10-23 20:25:37 -070064
65#define virt_to_bus virt_to_phys
66#define bus_to_virt phys_to_virt
67
Max Filippovd38efc12012-09-17 05:44:40 +040068#endif /* CONFIG_MMU */
Chris Zankel9a8fd552005-06-23 22:01:26 -070069
Chris Zankel9a8fd552005-06-23 22:01:26 -070070#endif /* __KERNEL__ */
71
Max Filippovd38efc12012-09-17 05:44:40 +040072#include <asm-generic/io.h>
73
Chris Zankel9a8fd552005-06-23 22:01:26 -070074#endif /* _XTENSA_IO_H */