linux/arch/m32r/include/asm/io.h
<<
>>
Prefs
   1#ifndef _ASM_M32R_IO_H
   2#define _ASM_M32R_IO_H
   3
   4#include <linux/string.h>
   5#include <linux/compiler.h>
   6#include <asm/page.h>  /* __va */
   7
   8#ifdef __KERNEL__
   9
  10#define IO_SPACE_LIMIT  0xFFFFFFFF
  11
  12/**
  13 *      virt_to_phys    -       map virtual addresses to physical
  14 *      @address: address to remap
  15 *
  16 *      The returned physical address is the physical (CPU) mapping for
  17 *      the memory address given. It is only valid to use this function on
  18 *      addresses directly mapped or allocated via kmalloc.
  19 *
  20 *      This function does not give bus mappings for DMA transfers. In
  21 *      almost all conceivable cases a device driver should not be using
  22 *      this function
  23 */
  24
  25static inline unsigned long virt_to_phys(volatile void * address)
  26{
  27        return __pa(address);
  28}
  29
  30/**
  31 *      phys_to_virt    -       map physical address to virtual
  32 *      @address: address to remap
  33 *
  34 *      The returned virtual address is a current CPU mapping for
  35 *      the memory address given. It is only valid to use this function on
  36 *      addresses that have a kernel mapping
  37 *
  38 *      This function does not handle bus mappings for DMA transfers. In
  39 *      almost all conceivable cases a device driver should not be using
  40 *      this function
  41 */
  42
  43static inline void *phys_to_virt(unsigned long address)
  44{
  45        return __va(address);
  46}
  47
  48extern void __iomem *
  49__ioremap(unsigned long offset, unsigned long size, unsigned long flags);
  50
  51/**
  52 *      ioremap         -       map bus memory into CPU space
  53 *      @offset:        bus address of the memory
  54 *      @size:          size of the resource to map
  55 *
  56 *      ioremap performs a platform specific sequence of operations to
  57 *      make bus memory CPU accessible via the readb/readw/readl/writeb/
  58 *      writew/writel functions and the other mmio helpers. The returned
  59 *      address is not guaranteed to be usable directly as a virtual
  60 *      address.
  61 */
  62
  63static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
  64{
  65        return __ioremap(offset, size, 0);
  66}
  67
  68extern void iounmap(volatile void __iomem *addr);
  69#define ioremap_nocache(off,size) ioremap(off,size)
  70#define ioremap_wc ioremap_nocache
  71
  72/*
  73 * IO bus memory addresses are also 1:1 with the physical address
  74 */
  75#define page_to_phys(page)      (page_to_pfn(page) << PAGE_SHIFT)
  76#define page_to_bus     page_to_phys
  77#define virt_to_bus     virt_to_phys
  78
  79extern unsigned char _inb(unsigned long);
  80extern unsigned short _inw(unsigned long);
  81extern unsigned long _inl(unsigned long);
  82extern unsigned char _inb_p(unsigned long);
  83extern unsigned short _inw_p(unsigned long);
  84extern unsigned long _inl_p(unsigned long);
  85extern void _outb(unsigned char, unsigned long);
  86extern void _outw(unsigned short, unsigned long);
  87extern void _outl(unsigned long, unsigned long);
  88extern void _outb_p(unsigned char, unsigned long);
  89extern void _outw_p(unsigned short, unsigned long);
  90extern void _outl_p(unsigned long, unsigned long);
  91extern void _insb(unsigned int, void *, unsigned long);
  92extern void _insw(unsigned int, void *, unsigned long);
  93extern void _insl(unsigned int, void *, unsigned long);
  94extern void _outsb(unsigned int, const void *, unsigned long);
  95extern void _outsw(unsigned int, const void *, unsigned long);
  96extern void _outsl(unsigned int, const void *, unsigned long);
  97
  98static inline unsigned char _readb(unsigned long addr)
  99{
 100        return *(volatile unsigned char __force *)addr;
 101}
 102
 103static inline unsigned short _readw(unsigned long addr)
 104{
 105        return *(volatile unsigned short __force *)addr;
 106}
 107
 108static inline unsigned long _readl(unsigned long addr)
 109{
 110        return *(volatile unsigned long __force *)addr;
 111}
 112
 113static inline void _writeb(unsigned char b, unsigned long addr)
 114{
 115        *(volatile unsigned char __force *)addr = b;
 116}
 117
 118static inline void _writew(unsigned short w, unsigned long addr)
 119{
 120        *(volatile unsigned short __force *)addr = w;
 121}
 122
 123static inline void _writel(unsigned long l, unsigned long addr)
 124{
 125        *(volatile unsigned long __force *)addr = l;
 126}
 127
 128#define inb     _inb
 129#define inw     _inw
 130#define inl     _inl
 131#define outb    _outb
 132#define outw    _outw
 133#define outl    _outl
 134
 135#define inb_p   _inb_p
 136#define inw_p   _inw_p
 137#define inl_p   _inl_p
 138#define outb_p  _outb_p
 139#define outw_p  _outw_p
 140#define outl_p  _outl_p
 141
 142#define insb    _insb
 143#define insw    _insw
 144#define insl    _insl
 145#define outsb   _outsb
 146#define outsw   _outsw
 147#define outsl   _outsl
 148
 149#define readb(addr)   _readb((unsigned long)(addr))
 150#define readw(addr)   _readw((unsigned long)(addr))
 151#define readl(addr)   _readl((unsigned long)(addr))
 152#define __raw_readb readb
 153#define __raw_readw readw
 154#define __raw_readl readl
 155#define readb_relaxed readb
 156#define readw_relaxed readw
 157#define readl_relaxed readl
 158
 159#define writeb(val, addr)  _writeb((val), (unsigned long)(addr))
 160#define writew(val, addr)  _writew((val), (unsigned long)(addr))
 161#define writel(val, addr)  _writel((val), (unsigned long)(addr))
 162#define __raw_writeb writeb
 163#define __raw_writew writew
 164#define __raw_writel writel
 165#define writeb_relaxed writeb
 166#define writew_relaxed writew
 167#define writel_relaxed writel
 168
 169#define ioread8 read
 170#define ioread16 readw
 171#define ioread32 readl
 172#define iowrite8 writeb
 173#define iowrite16 writew
 174#define iowrite32 writel
 175
 176#define mmiowb()
 177
 178#define flush_write_buffers() do { } while (0)  /* M32R_FIXME */
 179
 180static inline void
 181memset_io(volatile void __iomem *addr, unsigned char val, int count)
 182{
 183        memset((void __force *) addr, val, count);
 184}
 185
 186static inline void
 187memcpy_fromio(void *dst, volatile void __iomem *src, int count)
 188{
 189        memcpy(dst, (void __force *) src, count);
 190}
 191
 192static inline void
 193memcpy_toio(volatile void __iomem *dst, const void *src, int count)
 194{
 195        memcpy((void __force *) dst, src, count);
 196}
 197
 198/*
 199 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
 200 * access
 201 */
 202#define xlate_dev_mem_ptr(p)    __va(p)
 203
 204/*
 205 * Convert a virtual cached pointer to an uncached pointer
 206 */
 207#define xlate_dev_kmem_ptr(p)   p
 208
 209#endif  /* __KERNEL__ */
 210
 211#endif  /* _ASM_M32R_IO_H */
 212