/* SPDX-License-Identifier: GPL-2.0-only */ /* * arch/arm/include/asm/io.h * * Copyright (C) 1996-2000 Russell King * * Modifications: * 16-Sep-1996 RMK Inlined the inx/outx functions & optimised for both * constant addresses and variable addresses. * 04-Dec-1997 RMK Moved a lot of this stuff to the new architecture * specific IO header files. * 27-Mar-1999 PJB Second parameter of memcpy_toio is const.. * 04-Apr-1999 PJB Added check_signature. * 12-Dec-1999 RMK More cleanups * 18-Jun-2000 RMK Removed virt_to_* and friends definitions * 05-Oct-2004 BJD Moved memory string functions to use void __iomem
*/ #ifndef __ASM_ARM_IO_H #define __ASM_ARM_IO_H
/* * Generic IO read/write. These perform native-endian accesses. Note * that some architectures will want to re-define __raw_{read,write}w.
*/ void __raw_writesb(volatilevoid __iomem *addr, constvoid *data, int bytelen); void __raw_writesw(volatilevoid __iomem *addr, constvoid *data, int wordlen); void __raw_writesl(volatilevoid __iomem *addr, constvoid *data, int longlen);
void __raw_readsb(constvolatilevoid __iomem *addr, void *data, int bytelen); void __raw_readsw(constvolatilevoid __iomem *addr, void *data, int wordlen); void __raw_readsl(constvolatilevoid __iomem *addr, void *data, int longlen);
#if __LINUX_ARM_ARCH__ < 6 /* * Half-word accesses are problematic with RiscPC due to limitations of * the bus. Rather than special-case the machine, just let the compiler * generate the access for CPUs prior to ARMv6.
*/ #define __raw_readw(a) (__chk_io_ptr(a), *(volatileunsignedshort __force *)(a)) #define __raw_writew(v,a) ((void)(__chk_io_ptr(a), *(volatileunsignedshort __force *)(a) = (v))) #else /* * When running under a hypervisor, we want to avoid I/O accesses with * writeback addressing modes as these incur a significant performance * overhead (the address generation must be emulated in software).
*/ #define __raw_writew __raw_writew staticinlinevoid __raw_writew(u16 val, volatilevoid __iomem *addr)
{ asmvolatile("strh %1, %0"
: : "Q" (*(volatile u16 __force *)addr), "r" (val));
}
/* * Architecture ioremap implementation.
*/ #define MT_DEVICE 0 #define MT_DEVICE_NONSHARED 1 #define MT_DEVICE_CACHED 2 #define MT_DEVICE_WC 3 /* * types 4 onwards can be found in asm/mach/map.h and are undefined * for ioremap
*/
/* * __arm_ioremap takes CPU physical address. * __arm_ioremap_pfn takes a Page Frame Number and an offset into that page * The _caller variety takes a __builtin_return_address(0) value for * /proc/vmalloc to use - and should only be used in non-inline functions.
*/ externvoid __iomem *__arm_ioremap_caller(phys_addr_t, size_t, unsignedint, void *); externvoid __iomem *__arm_ioremap_pfn(unsignedlong, unsignedlong, size_t, unsignedint); externvoid __iomem *__arm_ioremap_exec(phys_addr_t, size_t, bool cached); void __arm_iomem_set_ro(void __iomem *ptr, size_t size);
#define pci_remap_iospace pci_remap_iospace int pci_remap_iospace(conststruct resource *res, phys_addr_t phys_addr);
/* * PCI configuration space mapping function. * * The PCI specification does not allow configuration write * transactions to be posted. Add an arch specific * pci_remap_cfgspace() definition that is implemented * through strongly ordered memory mappings.
*/ #define pci_remap_cfgspace pci_remap_cfgspace void __iomem *pci_remap_cfgspace(resource_size_t res_cookie, size_t size); /* * Now, pick up the machine-defined IO definitions
*/ #ifdef CONFIG_NEED_MACH_IO_H #include <mach/io.h> #else #if IS_ENABLED(CONFIG_PCMCIA) || defined(CONFIG_PCI) #define IO_SPACE_LIMIT ((resource_size_t)0xfffff) #else #define IO_SPACE_LIMIT ((resource_size_t)0) #endif #define __io(a) __typesafe_io(PCI_IO_VIRT_BASE + ((a) & IO_SPACE_LIMIT)) #endif
/* * IO port access primitives * ------------------------- * * The ARM doesn't have special IO access instructions; all IO is memory * mapped. Note that these are defined to perform little endian accesses * only. Their primary purpose is to access PCI and ISA peripherals. * * Note that for a big endian machine, this implies that the following * big endian mode connectivity is in place, as described by numerous * ARM documents: * * PCI: D0-D7 D8-D15 D16-D23 D24-D31 * ARM: D24-D31 D16-D23 D8-D15 D0-D7 * * The machine specific io.h include defines __io to translate an "IO" * address to a memory address. * * Note that we prevent GCC re-ordering or caching values in expressions * by introducing sequence points into the in*() definitions. Note that * __raw_* do not guarantee this behaviour. * * The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space.
*/ #ifdef __io #define outb(v,p) ({ __iowmb(); __raw_writeb(v,__io(p)); }) #define outw(v,p) ({ __iowmb(); __raw_writew((__force __u16) \
cpu_to_le16(v),__io(p)); }) #define outl(v,p) ({ __iowmb(); __raw_writel((__force __u32) \
cpu_to_le32(v),__io(p)); })
/* * Memory access primitives * ------------------------ * * These perform PCI memory accesses via an ioremap region. They don't * take an address as such, but a cookie. * * Again, these are defined to perform little endian accesses. See the * IO port primitives for more information.
*/ #ifndef readl #define readb_relaxed(c) ({ u8 __r = __raw_readb(c); __r; }) #define readw_relaxed(c) ({ u16 __r = le16_to_cpu((__force __le16) \
__raw_readw(c)); __r; }) #define readl_relaxed(c) ({ u32 __r = le32_to_cpu((__force __le32) \
__raw_readl(c)); __r; })
/* * ioremap() and friends. * * ioremap() takes a resource address, and size. Due to the ARM memory * types, it is important to use the correct ioremap() function as each * mapping has specific properties. * * Function Memory type Cacheability Cache hint * ioremap() Device n/a n/a * ioremap_cache() Normal Writeback Read allocate * ioremap_wc() Normal Non-cacheable n/a * ioremap_wt() Normal Non-cacheable n/a * * All device mappings have the following properties: * - no access speculation * - no repetition (eg, on return from an exception) * - number, order and size of accesses are maintained * - unaligned accesses are "unpredictable" * - writes may be delayed before they hit the endpoint device * * All normal memory mappings have the following properties: * - reads can be repeated with no side effects * - repeated reads return the last value written * - reads can fetch additional locations without side effects * - writes can be repeated (in certain cases) with no side effects * - writes can be merged before accessing the target * - unaligned accesses can be supported * - ordering is not guaranteed without explicit dependencies or barrier * instructions * - writes may be delayed before they hit the endpoint memory * * The cache hint is only a performance hint: CPUs may alias these hints. * Eg, a CPU not implementing read allocate but implementing write allocate * will provide a write allocate mapping instead.
*/ void __iomem *ioremap(resource_size_t res_cookie, size_t size); #define ioremap ioremap
/* * Do not use ioremap_cache for mapping memory. Use memremap instead.
*/ void __iomem *ioremap_cache(resource_size_t res_cookie, size_t size); #define ioremap_cache ioremap_cache
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.