blob: 700c2e6f2d259d454f5f8f310b431d6b20ecbc1f [file] [log] [blame]
Chris Zankel9a8fd552005-06-23 22:01:26 -07001/*
Chris Zankel173d66812006-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>
Paul Gortmakerbfae8ee2012-04-18 16:20:38 -040017#include <linux/bug.h>
Chris Zankel66569202007-08-22 10:14:51 -070018#include <linux/kernel.h>
Chris Zankel9a8fd552005-06-23 22:01:26 -070019
20#include <linux/types.h>
Chris Zankel9a8fd552005-06-23 22:01:26 -070021
Chris Zankel00c81d22008-10-21 09:08:31 -070022#define XCHAL_KIO_CACHED_VADDR 0xe0000000
23#define XCHAL_KIO_BYPASS_VADDR 0xf0000000
Chris Zankel173d66812006-12-10 02:18:48 -080024#define XCHAL_KIO_PADDR 0xf0000000
Chris Zankel00c81d22008-10-21 09:08:31 -070025#define XCHAL_KIO_SIZE 0x10000000
26
27#define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x))
Max Filippovd38efc12012-09-17 05:44:40 +040028#define IO_SPACE_LIMIT ~0
Chris Zankel9a8fd552005-06-23 22:01:26 -070029
Max Filippovd38efc12012-09-17 05:44:40 +040030#ifdef CONFIG_MMU
Chris Zankel9a8fd552005-06-23 22:01:26 -070031/*
Max Filippovd38efc12012-09-17 05:44:40 +040032 * Return the virtual address for the specified bus memory.
Chris Zankel173d66812006-12-10 02:18:48 -080033 * Note that we currently don't support any address outside the KIO segment.
Chris Zankel9a8fd552005-06-23 22:01:26 -070034 */
Max Filippov02f37742012-09-17 05:44:39 +040035static inline void __iomem *ioremap_nocache(unsigned long offset,
36 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070037{
Chris Zankel173d66812006-12-10 02:18:48 -080038 if (offset >= XCHAL_KIO_PADDR
Max Filippov02f37742012-09-17 05:44:39 +040039 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
Chris Zankel173d66812006-12-10 02:18:48 -080040 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
Chris Zankel173d66812006-12-10 02:18:48 -080041 else
42 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070043}
44
Max Filippov02f37742012-09-17 05:44:39 +040045static inline void __iomem *ioremap_cache(unsigned long offset,
46 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070047{
Chris Zankel173d66812006-12-10 02:18:48 -080048 if (offset >= XCHAL_KIO_PADDR
Max Filippov02f37742012-09-17 05:44:39 +040049 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
Chris Zankel173d66812006-12-10 02:18:48 -080050 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
51 else
52 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070053}
54
Max Filippov02f37742012-09-17 05:44:39 +040055#define ioremap_wc ioremap_nocache
56
57static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
58{
59 return ioremap_nocache(offset, size);
60}
61
62static inline void iounmap(volatile void __iomem *addr)
Chris Zankel9a8fd552005-06-23 22:01:26 -070063{
64}
Chris Zankelcddfcbc2012-10-23 20:25:37 -070065
66#define virt_to_bus virt_to_phys
67#define bus_to_virt phys_to_virt
68
Max Filippovd38efc12012-09-17 05:44:40 +040069#endif /* CONFIG_MMU */
Chris Zankel9a8fd552005-06-23 22:01:26 -070070
71/*
72 * Generic I/O
73 */
Max Filippovd38efc12012-09-17 05:44:40 +040074#define readb_relaxed readb
75#define readw_relaxed readw
76#define readl_relaxed readl
Chris Zankel9a8fd552005-06-23 22:01:26 -070077
78#endif /* __KERNEL__ */
79
Max Filippovd38efc12012-09-17 05:44:40 +040080#include <asm-generic/io.h>
81
Chris Zankel9a8fd552005-06-23 22:01:26 -070082#endif /* _XTENSA_IO_H */