blob: 1482a363638120a30a00c0a050203a14dd5a9561 [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
Chris Zankel9a8fd552005-06-23 22:01:26 -070027/*
Max Filippovd38efc12012-09-17 05:44:40 +040028 * Return the virtual address for the specified bus memory.
Chris Zankel173d6682006-12-10 02:18:48 -080029 * Note that we currently don't support any address outside the KIO segment.
Chris Zankel9a8fd552005-06-23 22:01:26 -070030 */
Max Filippov02f37742012-09-17 05:44:39 +040031static inline void __iomem *ioremap_nocache(unsigned long offset,
32 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070033{
Chris Zankel173d6682006-12-10 02:18:48 -080034 if (offset >= XCHAL_KIO_PADDR
Max Filippov02f37742012-09-17 05:44:39 +040035 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
Chris Zankel173d6682006-12-10 02:18:48 -080036 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
Chris Zankel173d6682006-12-10 02:18:48 -080037 else
38 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070039}
40
Max Filippov02f37742012-09-17 05:44:39 +040041static inline void __iomem *ioremap_cache(unsigned long offset,
42 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070043{
Chris Zankel173d6682006-12-10 02:18:48 -080044 if (offset >= XCHAL_KIO_PADDR
Max Filippov02f37742012-09-17 05:44:39 +040045 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
Chris Zankel173d6682006-12-10 02:18:48 -080046 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
47 else
48 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070049}
50
Max Filippov02f37742012-09-17 05:44:39 +040051#define ioremap_wc ioremap_nocache
52
53static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
54{
55 return ioremap_nocache(offset, size);
56}
57
58static inline void iounmap(volatile void __iomem *addr)
Chris Zankel9a8fd552005-06-23 22:01:26 -070059{
60}
Chris Zankelcddfcbc2012-10-23 20:25:37 -070061
62#define virt_to_bus virt_to_phys
63#define bus_to_virt phys_to_virt
64
Max Filippovd38efc12012-09-17 05:44:40 +040065#endif /* CONFIG_MMU */
Chris Zankel9a8fd552005-06-23 22:01:26 -070066
67/*
68 * Generic I/O
69 */
Max Filippovd38efc12012-09-17 05:44:40 +040070#define readb_relaxed readb
71#define readw_relaxed readw
72#define readl_relaxed readl
Chris Zankel9a8fd552005-06-23 22:01:26 -070073
74#endif /* __KERNEL__ */
75
Max Filippovd38efc12012-09-17 05:44:40 +040076#include <asm-generic/io.h>
77
Chris Zankel9a8fd552005-06-23 22:01:26 -070078#endif /* _XTENSA_IO_H */