blob: 74944207167eccfb0f6e122ad7418d5728d4a2b7 [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>
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
Max Filippov9848e492014-01-16 03:38:58 +040028#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && defined(CONFIG_OF)
Baruch Siach6cb97112013-12-29 11:03:30 +020029extern unsigned long xtensa_kio_paddr;
30
31static inline unsigned long xtensa_get_kio_paddr(void)
32{
33 return xtensa_kio_paddr;
34}
35#endif
36
Chris Zankel9a8fd552005-06-23 22:01:26 -070037/*
Max Filippovd38efc12012-09-17 05:44:40 +040038 * Return the virtual address for the specified bus memory.
Chris Zankel173d66812006-12-10 02:18:48 -080039 * Note that we currently don't support any address outside the KIO segment.
Chris Zankel9a8fd552005-06-23 22:01:26 -070040 */
Max Filippov02f37742012-09-17 05:44:39 +040041static inline void __iomem *ioremap_nocache(unsigned long offset,
42 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070043{
Chris Zankel173d66812006-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 Zankel173d66812006-12-10 02:18:48 -080046 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
Chris Zankel173d66812006-12-10 02:18:48 -080047 else
48 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070049}
50
Max Filippov02f37742012-09-17 05:44:39 +040051static inline void __iomem *ioremap_cache(unsigned long offset,
52 unsigned long size)
Chris Zankel9a8fd552005-06-23 22:01:26 -070053{
Chris Zankel173d66812006-12-10 02:18:48 -080054 if (offset >= XCHAL_KIO_PADDR
Max Filippov02f37742012-09-17 05:44:39 +040055 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
Chris Zankel173d66812006-12-10 02:18:48 -080056 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
57 else
58 BUG();
Chris Zankel9a8fd552005-06-23 22:01:26 -070059}
60
Max Filippov02f37742012-09-17 05:44:39 +040061#define ioremap_wc ioremap_nocache
62
63static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
64{
65 return ioremap_nocache(offset, size);
66}
67
68static inline void iounmap(volatile void __iomem *addr)
Chris Zankel9a8fd552005-06-23 22:01:26 -070069{
70}
Chris Zankelcddfcbc2012-10-23 20:25:37 -070071
72#define virt_to_bus virt_to_phys
73#define bus_to_virt phys_to_virt
74
Max Filippovd38efc12012-09-17 05:44:40 +040075#endif /* CONFIG_MMU */
Chris Zankel9a8fd552005-06-23 22:01:26 -070076
77/*
78 * Generic I/O
79 */
Max Filippovd38efc12012-09-17 05:44:40 +040080#define readb_relaxed readb
81#define readw_relaxed readw
82#define readl_relaxed readl
Chris Zankel9a8fd552005-06-23 22:01:26 -070083
84#endif /* __KERNEL__ */
85
Max Filippovd38efc12012-09-17 05:44:40 +040086#include <asm-generic/io.h>
87
Chris Zankel9a8fd552005-06-23 22:01:26 -070088#endif /* _XTENSA_IO_H */