2005-06-24 13:01:26 +08:00
|
|
|
/*
|
2006-12-10 18:18:48 +08:00
|
|
|
* include/asm-xtensa/io.h
|
2005-06-24 13:01:26 +08:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 - 2005 Tensilica Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _XTENSA_IO_H
|
|
|
|
#define _XTENSA_IO_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
#include <asm/byteorder.h>
|
2007-07-24 09:43:54 +08:00
|
|
|
#include <asm/page.h>
|
2013-11-17 14:14:54 +08:00
|
|
|
#include <asm/vectors.h>
|
2012-04-19 04:20:38 +08:00
|
|
|
#include <linux/bug.h>
|
2007-08-23 01:14:51 +08:00
|
|
|
#include <linux/kernel.h>
|
2005-06-24 13:01:26 +08:00
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
2008-10-22 00:08:31 +08:00
|
|
|
#define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x))
|
2012-09-17 09:44:40 +08:00
|
|
|
#define IO_SPACE_LIMIT ~0
|
2005-06-24 13:01:26 +08:00
|
|
|
|
2012-09-17 09:44:40 +08:00
|
|
|
#ifdef CONFIG_MMU
|
2013-12-29 17:03:30 +08:00
|
|
|
|
2015-12-11 09:05:27 +08:00
|
|
|
void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size);
|
|
|
|
void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size);
|
|
|
|
void xtensa_iounmap(volatile void __iomem *addr);
|
|
|
|
|
2005-06-24 13:01:26 +08:00
|
|
|
/*
|
2012-09-17 09:44:40 +08:00
|
|
|
* Return the virtual address for the specified bus memory.
|
2005-06-24 13:01:26 +08:00
|
|
|
*/
|
2012-09-17 09:44:39 +08:00
|
|
|
static inline void __iomem *ioremap_nocache(unsigned long offset,
|
|
|
|
unsigned long size)
|
2005-06-24 13:01:26 +08:00
|
|
|
{
|
2006-12-10 18:18:48 +08:00
|
|
|
if (offset >= XCHAL_KIO_PADDR
|
2012-09-17 09:44:39 +08:00
|
|
|
&& offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
|
2006-12-10 18:18:48 +08:00
|
|
|
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
|
|
|
|
else
|
2015-12-11 09:05:27 +08:00
|
|
|
return xtensa_ioremap_nocache(offset, size);
|
2005-06-24 13:01:26 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 09:44:39 +08:00
|
|
|
static inline void __iomem *ioremap_cache(unsigned long offset,
|
|
|
|
unsigned long size)
|
2005-06-24 13:01:26 +08:00
|
|
|
{
|
2006-12-10 18:18:48 +08:00
|
|
|
if (offset >= XCHAL_KIO_PADDR
|
2012-09-17 09:44:39 +08:00
|
|
|
&& offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
|
2006-12-10 18:18:48 +08:00
|
|
|
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
|
|
|
|
else
|
2015-12-11 09:05:27 +08:00
|
|
|
return xtensa_ioremap_cache(offset, size);
|
2005-06-24 13:01:26 +08:00
|
|
|
}
|
2015-08-11 11:07:06 +08:00
|
|
|
#define ioremap_cache ioremap_cache
|
2005-06-24 13:01:26 +08:00
|
|
|
|
2012-09-17 09:44:39 +08:00
|
|
|
#define ioremap_wc ioremap_nocache
|
2015-06-05 00:55:16 +08:00
|
|
|
#define ioremap_wt ioremap_nocache
|
2012-09-17 09:44:39 +08:00
|
|
|
|
|
|
|
static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
|
|
|
|
{
|
|
|
|
return ioremap_nocache(offset, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void iounmap(volatile void __iomem *addr)
|
2005-06-24 13:01:26 +08:00
|
|
|
{
|
2015-12-11 09:05:27 +08:00
|
|
|
unsigned long va = (unsigned long) addr;
|
|
|
|
|
|
|
|
if (!(va >= XCHAL_KIO_CACHED_VADDR &&
|
|
|
|
va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) &&
|
|
|
|
!(va >= XCHAL_KIO_BYPASS_VADDR &&
|
|
|
|
va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
|
|
|
|
xtensa_iounmap(addr);
|
2005-06-24 13:01:26 +08:00
|
|
|
}
|
2012-10-24 11:25:37 +08:00
|
|
|
|
|
|
|
#define virt_to_bus virt_to_phys
|
|
|
|
#define bus_to_virt phys_to_virt
|
|
|
|
|
2012-09-17 09:44:40 +08:00
|
|
|
#endif /* CONFIG_MMU */
|
2005-06-24 13:01:26 +08:00
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
2012-09-17 09:44:40 +08:00
|
|
|
#include <asm-generic/io.h>
|
|
|
|
|
2005-06-24 13:01:26 +08:00
|
|
|
#endif /* _XTENSA_IO_H */
|