/* 32 bits uses slightly different variables for the various IO * bases. Most of this file only uses _IO_BASE though which we * define properly based on the platform
*/ #ifndef CONFIG_PCI #define _IO_BASE POISON_POINTER_DELTA #define _ISA_MEM_BASE 0 #define PCI_DRAM_OFFSET 0 #elifdefined(CONFIG_PPC32) #define _IO_BASE isa_io_base #define _ISA_MEM_BASE isa_mem_base #define PCI_DRAM_OFFSET pci_dram_offset #else #define _IO_BASE pci_io_base #define _ISA_MEM_BASE isa_mem_base #define PCI_DRAM_OFFSET 0 #endif
/* Boolean set by platform if PIO accesses are suppored while _IO_BASE * is not set or addresses cannot be translated to MMIO. This is typically * set when the platform supports "special" PIO accesses via a non memory * mapped mechanism, and allows things like the early udbg UART code to * function.
*/ externbool isa_io_special;
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC_INDIRECT_PIO #error CONFIG_PPC_INDIRECT_PIO is not yet supported on 32 bits #endif #endif
/* * * Low level MMIO accessors * * This provides the non-bus specific accessors to MMIO. Those are PowerPC * specific and thus shouldn't be used in generic code. The accessors * provided here are: * * in_8, in_le16, in_be16, in_le32, in_be32, in_le64, in_be64 * out_8, out_le16, out_be16, out_le32, out_be32, out_le64, out_be64 * _insb, _insw, _insl, _outsb, _outsw, _outsl * * Those operate directly on a kernel virtual address. Note that the prototype * for the out_* accessors has the arguments in opposite order from the usual * linux PCI accessors. Unlike those, they take the address first and the value * next.
*/
/* There is no asm instructions for 64 bits reverse loads and stores */ staticinline u64 in_le64(constvolatile u64 __iomem *addr)
{ return swab64(in_be64(addr));
}
/* There is no asm instructions for 64 bits reverse loads and stores */ staticinline u64 in_be64(constvolatile u64 __iomem *addr)
{ return swab64(in_le64(addr));
}
/* * * PCI and standard ISA accessors * * Those are globally defined linux accessors for devices on PCI or ISA * busses. They follow the Linux defined semantics. The current implementation * for PowerPC is as close as possible to the x86 version of these, and thus * provides fairly heavy weight barriers for the non-raw versions * * In addition, they support a hook mechanism when CONFIG_PPC_INDIRECT_PIO * is set allowing the platform to provide its own implementation of some * of the accessors.
*/
/* * Include the EEH definitions when EEH is enabled only so they don't get * in the way when building for 32 bits
*/ #ifdef CONFIG_EEH #include <asm/eeh.h> #endif
#ifdef __powerpc64__ /* * Real mode versions of raw accessors. Those instructions are only supposed * to be used in hypervisor real mode as per the architecture spec.
*/ staticinlinevoid __raw_rm_writeb(u8 val, volatilevoid __iomem *paddr)
{
__asm__ __volatile__(".machine push; \
.machine power6; \
stbcix %0,0,%1; \
.machine pop;"
: : "r" (val), "r" (paddr) : "memory");
}
/* * * PCI PIO and MMIO accessors. * * * On 32 bits, PIO operations have a recovery mechanism in case they trigger * machine checks (which they occasionally do when probing non existing * IO ports on some platforms, like PowerMac and 8xx). * I always found it to be of dubious reliability and I am tempted to get * rid of it one of these days. So if you think it's important to keep it, * please voice up asap. We never had it for 64 bits and I do not intend * to port it over
*/
/* The "__do_*" operations below provide the actual "base" implementation * for each of the defined accessors. Some of them use the out_* functions * directly, some of them still use EEH, though we might change that in the * future. Those macros below provide the necessary argument swapping and * handling of the IO base for PIO. * * They are themselves used by the macros that define the actual accessors * and can be used by the hooks if any. * * Note that PIO operations are always defined in terms of their corresonding * MMIO operations. That allows platforms like iSeries who want to modify the * behaviour of both to only hook on the MMIO version and get both. It's also * possible to hook directly at the toplevel PIO operation if they have to * be handled differently
*/
/* * We don't do relaxed operations yet, at least not with this semantic
*/ #define readb_relaxed(addr) readb(addr) #define readw_relaxed(addr) readw(addr) #define readl_relaxed(addr) readl(addr) #define readq_relaxed(addr) readq(addr) #define writeb_relaxed(v, addr) writeb(v, addr) #define writew_relaxed(v, addr) writew(v, addr) #define writel_relaxed(v, addr) writel(v, addr) #define writeq_relaxed(v, addr) writeq(v, addr)
#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces.
*/ staticinlineunsignedint ioread16be(constvoid __iomem *addr)
{ return readw_be(addr);
} #define ioread16be ioread16be
/* Enforce in-order execution of data I/O. * No distinction between read/write on PPC; use eieio for all three. * Those are fairly week though. They don't provide a barrier between * MMIO and cacheable storage nor do they provide a barrier vs. locks, * they only provide barriers between 2 __raw MMIO operations and * possibly break write combining.
*/ #define iobarrier_rw() eieio() #define iobarrier_r() eieio() #define iobarrier_w() eieio()
/* * output pause versions need a delay at least for the * w83c105 ide controller in a p610.
*/ #define inb_p(port) inb(port) #define outb_p(val, port) (udelay(1), outb((val), (port))) #define inw_p(port) inw(port) #define outw_p(val, port) (udelay(1), outw((val), (port))) #define inl_p(port) inl(port) #define outl_p(val, port) (udelay(1), outl((val), (port)))
#define IO_SPACE_LIMIT ~(0UL)
/** * ioremap - map bus memory into CPU space * @address: bus address of the memory * @size: size of the resource to map * * ioremap performs a platform specific sequence of operations to * make bus memory CPU accessible via the readb/readw/readl/writeb/ * writew/writel functions and the other mmio helpers. The returned * address is not guaranteed to be usable directly as a virtual * address. * * We provide a few variations of it: * * * ioremap is the standard one and provides non-cacheable guarded mappings * and can be hooked by the platform via ppc_md * * * ioremap_prot allows to specify the page flags as an argument and can * also be hooked by the platform via ppc_md. * * * ioremap_wc enables write combining * * * ioremap_wt enables write through * * * ioremap_coherent maps coherent cached memory * * * iounmap undoes such a mapping and can be hooked * * * __ioremap_caller is the same as above but takes an explicit caller * reference rather than using __builtin_return_address(0) *
*/ externvoid __iomem *ioremap(phys_addr_t address, unsignedlong size); #define ioremap ioremap #define ioremap_prot ioremap_prot externvoid __iomem *ioremap_wc(phys_addr_t address, unsignedlong size); #define ioremap_wc ioremap_wc
/* * When CONFIG_PPC_INDIRECT_PIO is set, we use the generic iomap implementation * which needs some additional definitions here. They basically allow PIO * space overall to be 1GB. This will work as long as we never try to use * iomap to map MMIO below 1GB which should be fine on ppc64
*/ #define HAVE_ARCH_PIO_SIZE 1 #define PIO_OFFSET 0x00000000UL #define PIO_MASK (FULL_IO_SIZE - 1) #define PIO_RESERVED (FULL_IO_SIZE)
/** * virt_to_phys - map virtual addresses to physical * @address: address to remap * * The returned physical address is the physical (CPU) mapping for * the memory address given. It is only valid to use this function on * addresses directly mapped or allocated via kmalloc. * * This function does not give bus mappings for DMA transfers. In * almost all conceivable cases a device driver should not be using * this function
*/ staticinlineunsignedlong virt_to_phys(constvolatilevoid * address)
{
WARN_ON(IS_ENABLED(CONFIG_DEBUG_VIRTUAL) && !virt_addr_valid(address));
/** * phys_to_virt - map physical address to virtual * @address: address to remap * * The returned virtual address is a current CPU mapping for * the memory address given. It is only valid to use this function on * addresses that have a kernel mapping * * This function does not handle bus mappings for DMA transfers. In * almost all conceivable cases a device driver should not be using * this function
*/ staticinlinevoid * phys_to_virt(unsignedlong address)
{ return (void *)__va(address);
} #define phys_to_virt phys_to_virt
/* * 32 bits still uses virt_to_bus() for its implementation of DMA * mappings se we have to keep it defined here. We also have some old * drivers (shame shame shame) that use bus_to_virt() and haven't been * fixed yet so I need to define it here.
*/ #ifdef CONFIG_PPC32
/* Clear and set bits in one shot. These macros can be used to clear and * set multiple bits in a register using a single read-modify-write. These * macros can also be used to set a multiple-bit bit pattern using a mask, * by specifying the mask in the 'clear' parameter and the new bit pattern * in the 'set' parameter.
*/
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.