2019-06-04 08:11:33 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2011-01-15 10:23:09 +00:00
|
|
|
/*
|
|
|
|
* linux/arch/unicore32/include/asm/io.h
|
|
|
|
*
|
|
|
|
* Code specific to PKUnity SoC and UniCore ISA
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001-2010 GUAN Xue-tao
|
|
|
|
*/
|
|
|
|
#ifndef __UNICORE_IO_H__
|
|
|
|
#define __UNICORE_IO_H__
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
#include <asm/memory.h>
|
|
|
|
|
2011-03-04 10:07:48 +00:00
|
|
|
#define PCI_IOBASE PKUNITY_PCILIO_BASE
|
2011-01-15 10:23:09 +00:00
|
|
|
#include <asm-generic/io.h>
|
|
|
|
|
|
|
|
/*
|
2019-08-11 12:03:29 +00:00
|
|
|
* __uc32_ioremap takes CPU physical address.
|
2011-01-15 10:23:09 +00:00
|
|
|
*/
|
|
|
|
extern void __iomem *__uc32_ioremap(unsigned long, size_t);
|
|
|
|
extern void __uc32_iounmap(volatile void __iomem *addr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ioremap and friends.
|
|
|
|
*
|
|
|
|
* ioremap takes a PCI memory address, as specified in
|
2020-03-11 11:51:17 +00:00
|
|
|
* Documentation/driver-api/io-mapping.rst.
|
2011-01-15 10:23:09 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define ioremap(cookie, size) __uc32_ioremap(cookie, size)
|
|
|
|
#define iounmap(cookie) __uc32_iounmap(cookie)
|
|
|
|
|
2014-05-03 01:06:28 +00:00
|
|
|
#define readb_relaxed readb
|
|
|
|
#define readw_relaxed readw
|
|
|
|
#define readl_relaxed readl
|
|
|
|
|
2011-02-27 04:46:06 +00:00
|
|
|
#define HAVE_ARCH_PIO_SIZE
|
|
|
|
#define PIO_OFFSET (unsigned int)(PCI_IOBASE)
|
|
|
|
#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT)
|
|
|
|
#define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1)
|
|
|
|
|
2014-04-15 01:21:30 +00:00
|
|
|
#ifdef CONFIG_STRICT_DEVMEM
|
|
|
|
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* devmem_is_allowed() checks to see if /dev/mem access to a certain
|
|
|
|
* address is valid. The argument is a physical page number.
|
|
|
|
* We mimic x86 here by disallowing access to system RAM as well as
|
|
|
|
* device-exclusive MMIO regions. This effectively disable read()/write()
|
|
|
|
* on /dev/mem.
|
|
|
|
*/
|
|
|
|
static inline int devmem_is_allowed(unsigned long pfn)
|
|
|
|
{
|
|
|
|
if (iomem_is_exclusive(pfn << PAGE_SHIFT))
|
|
|
|
return 0;
|
|
|
|
if (!page_is_ram(pfn))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_STRICT_DEVMEM */
|
|
|
|
|
2011-01-15 10:23:09 +00:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* __UNICORE_IO_H__ */
|