linux-old/include/asm-parisc/io.h
<<
>>
Prefs
   1#ifndef _ASM_IO_H
   2#define _ASM_IO_H
   3
   4/* USE_HPPA_IOREMAP IS THE MAGIC FLAG TO ENABLE OR DISABLE REAL IOREMAP() FUNCTIONALITY */
   5/* FOR 712 or 715 MACHINES THIS SHOULD BE ENABLED, 
   6   NEWER MACHINES STILL HAVE SOME ISSUES IN THE SCSI AND/OR NETWORK DRIVERS AND 
   7   BECAUSE OF THAT I WILL LEAVE IT DISABLED FOR NOW <deller@gmx.de> */
   8/* WHEN THOSE ISSUES ARE SOLVED, USE_HPPA_IOREMAP WILL GO AWAY */
   9#define USE_HPPA_IOREMAP 0
  10
  11
  12#include <linux/config.h>
  13#include <linux/types.h>
  14#include <asm/pgtable.h>
  15
  16#define virt_to_phys(a) ((unsigned long)__pa(a))
  17#define phys_to_virt(a) __va(a)
  18#define virt_to_bus virt_to_phys
  19#define bus_to_virt phys_to_virt
  20
  21/* Memory mapped IO */
  22
  23extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
  24
  25extern inline void * ioremap(unsigned long offset, unsigned long size)
  26{
  27        return __ioremap(offset, size, 0);
  28}
  29
  30/*
  31 * This one maps high address device memory and turns off caching for that area.
  32 * it's useful if some control registers are in such an area and write combining
  33 * or read caching is not desirable:
  34 */
  35extern inline void * ioremap_nocache (unsigned long offset, unsigned long size)
  36{
  37        return __ioremap(offset, size, _PAGE_NO_CACHE /* _PAGE_PCD */);
  38}
  39
  40extern void iounmap(void *addr);
  41
  42/*
  43 * __raw_ variants have no defined meaning.  on hppa, it means `i was
  44 * too lazy to ioremap first'.  kind of like isa_, except that there's
  45 * no additional base address to add on.
  46 */
  47extern __inline__ unsigned char __raw_readb(unsigned long addr)
  48{
  49        long flags;
  50        unsigned char ret;
  51
  52        __asm__ __volatile__(
  53        "       rsm     2,%0\n"
  54        "       ldb,ma  0(%2),%1\n"
  55        "       mtsm    %0\n"
  56        : "=&r" (flags), "=r" (ret) : "r" (addr) );
  57
  58        return ret;
  59}
  60
  61extern __inline__ unsigned short __raw_readw(unsigned long addr)
  62{
  63        long flags;
  64        unsigned short ret;
  65
  66        __asm__ __volatile__(
  67        "       rsm     2,%0\n"
  68        "       ldh,ma  0(%2),%1\n"
  69        "       mtsm    %0\n"
  70        : "=&r" (flags), "=r" (ret) : "r" (addr) );
  71
  72        return ret;
  73}
  74
  75extern __inline__ unsigned int __raw_readl(unsigned long addr)
  76{
  77        u32 ret;
  78
  79        __asm__ __volatile__(
  80        "       ldwa,ma 0(%1),%0\n"
  81        : "=r" (ret) : "r" (addr) );
  82
  83        return ret;
  84}
  85
  86extern __inline__ unsigned long long __raw_readq(unsigned long addr)
  87{
  88        unsigned long long ret;
  89#ifdef __LP64__
  90        __asm__ __volatile__(
  91        "       ldda,ma 0(%1),%0\n"
  92        :  "=r" (ret) : "r" (addr) );
  93#else
  94        /* two reads may have side effects.. */
  95        ret = ((u64) __raw_readl(addr)) << 32;
  96        ret |= __raw_readl(addr+4);
  97#endif
  98        return ret;
  99}
 100
 101extern __inline__ void __raw_writeb(unsigned char val, unsigned long addr)
 102{
 103        long flags;
 104        __asm__ __volatile__(
 105        "       rsm     2,%0\n"
 106        "       stb,ma  %1,0(%2)\n"
 107        "       mtsm    %0\n"
 108        : "=&r" (flags) :  "r" (val), "r" (addr) );
 109}
 110
 111extern __inline__ void __raw_writew(unsigned short val, unsigned long addr)
 112{
 113        long flags;
 114        __asm__ __volatile__(
 115        "       rsm     2,%0\n"
 116        "       sth,ma  %1,0(%2)\n"
 117        "       mtsm    %0\n"
 118        : "=&r" (flags) :  "r" (val), "r" (addr) );
 119}
 120
 121extern __inline__ void __raw_writel(unsigned int val, unsigned long addr)
 122{
 123        __asm__ __volatile__(
 124        "       stwa,ma %0,0(%1)\n"
 125        : :  "r" (val), "r" (addr) );
 126}
 127
 128extern __inline__ void __raw_writeq(unsigned long long val, unsigned long addr)
 129{
 130#ifdef __LP64__
 131        __asm__ __volatile__(
 132        "       stda,ma %0,0(%1)\n"
 133        : :  "r" (val), "r" (addr) );
 134#else
 135        /* two writes may have side effects.. */
 136        __raw_writel(val >> 32, addr);
 137        __raw_writel(val, addr+4);
 138#endif
 139}
 140
 141#if USE_HPPA_IOREMAP
 142#define readb(addr) (*(volatile unsigned char *) (addr))
 143#define readw(addr) (*(volatile unsigned short *) (addr))
 144#define readl(addr) (*(volatile unsigned int *) (addr))
 145#define readq(addr) (*(volatile u64 *) (addr))
 146#define writeb(b,addr) (*(volatile unsigned char *) (addr) = (b))
 147#define writew(b,addr) (*(volatile unsigned short *) (addr) = (b))
 148#define writel(b,addr) (*(volatile unsigned int *) (addr) = (b))
 149#define writeq(b,addr) (*(volatile u64 *) (addr) = (b))
 150#else /* !USE_HPPA_IOREMAP */
 151#define readb(addr) __raw_readb((unsigned long)(addr))
 152#define readw(addr) le16_to_cpu(__raw_readw((unsigned long)(addr)))
 153#define readl(addr) le32_to_cpu(__raw_readl((unsigned long)(addr)))
 154#define readq(addr) le64_to_cpu(__raw_readq((unsigned long)(addr)))
 155#define writeb(b,addr) __raw_writeb(b,(unsigned long)(addr))
 156#define writew(b,addr) __raw_writew(cpu_to_le16(b),(unsigned long)(addr))
 157#define writel(b,addr) __raw_writel(cpu_to_le32(b),(unsigned long)(addr))
 158#define writeq(b,addr) __raw_writeq(cpu_to_le64(b),(unsigned long)(addr))
 159#endif /* !USE_HPPA_IOREMAP */
 160
 161extern void memcpy_fromio(void *dest, unsigned long src, int count);
 162extern void memcpy_toio(unsigned long dest, const void *src, int count);
 163extern void memset_io(unsigned long dest, char fill, int count);
 164
 165/* Support old drivers which don't ioremap.
 166 * NB this interface is scheduled to disappear in 2.5
 167 */
 168
 169#define EISA_BASE 0xfffffffffc000000UL
 170#define isa_readb(a) readb(EISA_BASE | (a))
 171#define isa_readw(a) readw(EISA_BASE | (a))
 172#define isa_readl(a) readl(EISA_BASE | (a))
 173#define isa_writeb(b,a) writeb((b), EISA_BASE | (a))
 174#define isa_writew(b,a) writew((b), EISA_BASE | (a))
 175#define isa_writel(b,a) writel((b), EISA_BASE | (a))
 176#define isa_memset_io(a,b,c) memset_io(EISA_BASE | (a), (b), (c))
 177#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a), EISA_BASE | (b), (c))
 178#define isa_memcpy_toio(a,b,c) memcpy_toio(EISA_BASE | (a), (b), (c))
 179
 180/*
 181 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 
 182 * just copy it. The net code will then do the checksum later. Presently 
 183 * only used by some shared memory 8390 Ethernet cards anyway.
 184 */
 185
 186#define eth_io_copy_and_sum(skb,src,len,unused) \
 187  memcpy_fromio((skb)->data,(src),(len))
 188#define isa_eth_io_copy_and_sum(skb,src,len,unused) \
 189  isa_memcpy_fromio((skb)->data,(src),(len))
 190
 191/* Port-space IO */
 192
 193#define inb_p inb
 194#define inw_p inw
 195#define inl_p inl
 196#define outb_p outb
 197#define outw_p outw
 198#define outl_p outl
 199
 200extern unsigned char eisa_in8(unsigned short port);
 201extern unsigned short eisa_in16(unsigned short port);
 202extern unsigned int eisa_in32(unsigned short port);
 203extern void eisa_out8(unsigned char data, unsigned short port);
 204extern void eisa_out16(unsigned short data, unsigned short port);
 205extern void eisa_out32(unsigned int data, unsigned short port);
 206
 207#if defined(CONFIG_PCI)
 208extern unsigned char inb(int addr);
 209extern unsigned short inw(int addr);
 210extern unsigned int inl(int addr);
 211
 212extern void outb(unsigned char b, int addr);
 213extern void outw(unsigned short b, int addr);
 214extern void outl(unsigned int b, int addr);
 215#elif defined(CONFIG_EISA)
 216#define inb eisa_in8
 217#define inw eisa_in16
 218#define inl eisa_in32
 219#define outb eisa_out8
 220#define outw eisa_out16
 221#define outl eisa_out32
 222#else
 223static inline char inb(unsigned long addr)
 224{
 225        BUG();
 226        return -1;
 227}
 228
 229static inline short inw(unsigned long addr)
 230{
 231        BUG();
 232        return -1;
 233}
 234
 235static inline int inl(unsigned long addr)
 236{
 237        BUG();
 238        return -1;
 239}
 240
 241#define outb(x, y)      BUG()
 242#define outw(x, y)      BUG()
 243#define outl(x, y)      BUG()
 244#endif
 245
 246/*
 247 * String versions of in/out ops:
 248 */
 249extern void insb (unsigned long port, void *dst, unsigned long count);
 250extern void insw (unsigned long port, void *dst, unsigned long count);
 251extern void insl (unsigned long port, void *dst, unsigned long count);
 252extern void outsb (unsigned long port, const void *src, unsigned long count);
 253extern void outsw (unsigned long port, const void *src, unsigned long count);
 254extern void outsl (unsigned long port, const void *src, unsigned long count);
 255
 256
 257/* IO Port space is :      BBiiii   where BB is HBA number. */
 258#define IO_SPACE_LIMIT 0x00ffffff
 259
 260
 261#define dma_cache_inv(_start,_size)             do { flush_kernel_dcache_range(_start,_size); } while(0)
 262#define dma_cache_wback(_start,_size)           do { flush_kernel_dcache_range(_start,_size); } while (0)
 263#define dma_cache_wback_inv(_start,_size)       do { flush_kernel_dcache_range(_start,_size); } while (0)
 264
 265#endif
 266
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.