io_mm.h 9.9 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9
/*
 * linux/include/asm-m68k/io.h
 *
 * 4/1/00 RZ: - rewritten to avoid clashes between ISA/PCI and other
 *              IO access
 *            - added Q40 support
 *            - added skeleton for GG-II and Amiga PCMCIA
 * 2/3/01 RZ: - moved a few more defs into raw_io.h
 *
A
Adrian Bunk 已提交
10 11
 * inX/outX should not be used by any driver unless it does
 * ISA access. Other drivers should use function defined in raw_io.h
L
Linus Torvalds 已提交
12 13
 * or define its own macros on top of these.
 *
A
Adrian Bunk 已提交
14
 *    inX(),outX()              are for ISA I/O
L
Linus Torvalds 已提交
15 16 17 18 19 20 21 22
 *    isa_readX(),isa_writeX()  are for ISA memory
 */

#ifndef _IO_H
#define _IO_H

#ifdef __KERNEL__

A
Al Viro 已提交
23
#include <linux/compiler.h>
L
Linus Torvalds 已提交
24 25 26
#include <asm/raw_io.h>
#include <asm/virtconvert.h>

27
#include <asm-generic/iomap.h>
L
Linus Torvalds 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

#ifdef CONFIG_ATARI
#include <asm/atarihw.h>
#endif


/*
 * IO/MEM definitions for various ISA bridges
 */


#ifdef CONFIG_Q40

#define q40_isa_io_base  0xff400000
#define q40_isa_mem_base 0xff800000

#define Q40_ISA_IO_B(ioaddr) (q40_isa_io_base+1+4*((unsigned long)(ioaddr)))
#define Q40_ISA_IO_W(ioaddr) (q40_isa_io_base+  4*((unsigned long)(ioaddr)))
#define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
#define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))

#define MULTI_ISA 0
#endif /* Q40 */

/* GG-II Zorro to ISA bridge */
#ifdef CONFIG_GG2

extern unsigned long gg2_isa_base;
#define GG2_ISA_IO_B(ioaddr) (gg2_isa_base+1+((unsigned long)(ioaddr)*4))
#define GG2_ISA_IO_W(ioaddr) (gg2_isa_base+  ((unsigned long)(ioaddr)*4))
#define GG2_ISA_MEM_B(madr)  (gg2_isa_base+1+(((unsigned long)(madr)*4) & 0xfffff))
#define GG2_ISA_MEM_W(madr)  (gg2_isa_base+  (((unsigned long)(madr)*4) & 0xfffff))

#ifndef MULTI_ISA
#define MULTI_ISA 0
#else
#undef MULTI_ISA
#define MULTI_ISA 1
#endif
#endif /* GG2 */

#ifdef CONFIG_AMIGA_PCMCIA
#include <asm/amigayle.h>

#define AG_ISA_IO_B(ioaddr) ( GAYLE_IO+(ioaddr)+(((ioaddr)&1)*GAYLE_ODD) )
#define AG_ISA_IO_W(ioaddr) ( GAYLE_IO+(ioaddr) )

#ifndef MULTI_ISA
#define MULTI_ISA 0
#else
#undef MULTI_ISA
#define MULTI_ISA 1
#endif
#endif /* AMIGA_PCMCIA */



#ifdef CONFIG_ISA

#if MULTI_ISA == 0
#undef MULTI_ISA
#endif

91 92 93
#define ISA_TYPE_Q40 (1)
#define ISA_TYPE_GG2 (2)
#define ISA_TYPE_AG  (3)
L
Linus Torvalds 已提交
94 95

#if defined(CONFIG_Q40) && !defined(MULTI_ISA)
96
#define ISA_TYPE ISA_TYPE_Q40
L
Linus Torvalds 已提交
97 98 99
#define ISA_SEX  0
#endif
#if defined(CONFIG_AMIGA_PCMCIA) && !defined(MULTI_ISA)
100
#define ISA_TYPE ISA_TYPE_AG
L
Linus Torvalds 已提交
101 102 103
#define ISA_SEX  1
#endif
#if defined(CONFIG_GG2) && !defined(MULTI_ISA)
104
#define ISA_TYPE ISA_TYPE_GG2
L
Linus Torvalds 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#define ISA_SEX  0
#endif

#ifdef MULTI_ISA
extern int isa_type;
extern int isa_sex;

#define ISA_TYPE isa_type
#define ISA_SEX  isa_sex
#endif

/*
 * define inline addr translation functions. Normally only one variant will
 * be compiled in so the case statement will be optimised away
 */

A
Al Viro 已提交
121
static inline u8 __iomem *isa_itb(unsigned long addr)
L
Linus Torvalds 已提交
122 123 124 125
{
  switch(ISA_TYPE)
    {
#ifdef CONFIG_Q40
126
    case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
L
Linus Torvalds 已提交
127 128
#endif
#ifdef CONFIG_GG2
129
    case ISA_TYPE_GG2: return (u8 __iomem *)GG2_ISA_IO_B(addr);
L
Linus Torvalds 已提交
130 131
#endif
#ifdef CONFIG_AMIGA_PCMCIA
132
    case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
L
Linus Torvalds 已提交
133
#endif
A
Al Viro 已提交
134
    default: return NULL; /* avoid warnings, just in case */
L
Linus Torvalds 已提交
135 136
    }
}
A
Al Viro 已提交
137
static inline u16 __iomem *isa_itw(unsigned long addr)
L
Linus Torvalds 已提交
138 139 140 141
{
  switch(ISA_TYPE)
    {
#ifdef CONFIG_Q40
142
    case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
L
Linus Torvalds 已提交
143 144
#endif
#ifdef CONFIG_GG2
145
    case ISA_TYPE_GG2: return (u16 __iomem *)GG2_ISA_IO_W(addr);
L
Linus Torvalds 已提交
146 147
#endif
#ifdef CONFIG_AMIGA_PCMCIA
148
    case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
L
Linus Torvalds 已提交
149
#endif
A
Al Viro 已提交
150
    default: return NULL; /* avoid warnings, just in case */
L
Linus Torvalds 已提交
151 152
    }
}
153 154 155 156 157
static inline u32 __iomem *isa_itl(unsigned long addr)
{
  switch(ISA_TYPE)
    {
#ifdef CONFIG_AMIGA_PCMCIA
158
    case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
159 160 161 162
#endif
    default: return 0; /* avoid warnings, just in case */
    }
}
A
Al Viro 已提交
163
static inline u8 __iomem *isa_mtb(unsigned long addr)
L
Linus Torvalds 已提交
164 165 166 167
{
  switch(ISA_TYPE)
    {
#ifdef CONFIG_Q40
168
    case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
L
Linus Torvalds 已提交
169 170
#endif
#ifdef CONFIG_GG2
171
    case ISA_TYPE_GG2: return (u8 __iomem *)GG2_ISA_MEM_B(addr);
L
Linus Torvalds 已提交
172 173
#endif
#ifdef CONFIG_AMIGA_PCMCIA
174
    case ISA_TYPE_AG: return (u8 __iomem *)addr;
L
Linus Torvalds 已提交
175
#endif
A
Al Viro 已提交
176
    default: return NULL; /* avoid warnings, just in case */
L
Linus Torvalds 已提交
177 178
    }
}
A
Al Viro 已提交
179
static inline u16 __iomem *isa_mtw(unsigned long addr)
L
Linus Torvalds 已提交
180 181 182 183
{
  switch(ISA_TYPE)
    {
#ifdef CONFIG_Q40
184
    case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
L
Linus Torvalds 已提交
185 186
#endif
#ifdef CONFIG_GG2
187
    case ISA_TYPE_GG2: return (u16 __iomem *)GG2_ISA_MEM_W(addr);
L
Linus Torvalds 已提交
188 189
#endif
#ifdef CONFIG_AMIGA_PCMCIA
190
    case ISA_TYPE_AG: return (u16 __iomem *)addr;
L
Linus Torvalds 已提交
191
#endif
A
Al Viro 已提交
192
    default: return NULL; /* avoid warnings, just in case */
L
Linus Torvalds 已提交
193 194 195 196 197 198
    }
}


#define isa_inb(port)      in_8(isa_itb(port))
#define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
199
#define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
L
Linus Torvalds 已提交
200 201
#define isa_outb(val,port) out_8(isa_itb(port),(val))
#define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
202
#define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
L
Linus Torvalds 已提交
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217

#define isa_readb(p)       in_8(isa_mtb((unsigned long)(p)))
#define isa_readw(p)       \
	(ISA_SEX ? in_be16(isa_mtw((unsigned long)(p)))	\
		 : in_le16(isa_mtw((unsigned long)(p))))
#define isa_writeb(val,p)  out_8(isa_mtb((unsigned long)(p)),(val))
#define isa_writew(val,p)  \
	(ISA_SEX ? out_be16(isa_mtw((unsigned long)(p)),(val))	\
		 : out_le16(isa_mtw((unsigned long)(p)),(val)))

static inline void isa_delay(void)
{
  switch(ISA_TYPE)
    {
#ifdef CONFIG_Q40
218
    case ISA_TYPE_Q40: isa_outb(0,0x80); break;
L
Linus Torvalds 已提交
219 220
#endif
#ifdef CONFIG_GG2
221
    case ISA_TYPE_GG2: break;
L
Linus Torvalds 已提交
222 223
#endif
#ifdef CONFIG_AMIGA_PCMCIA
224
    case ISA_TYPE_AG: break;
L
Linus Torvalds 已提交
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
#endif
    default: break; /* avoid warnings */
    }
}

#define isa_inb_p(p)      ({u8 v=isa_inb(p);isa_delay();v;})
#define isa_outb_p(v,p)   ({isa_outb((v),(p));isa_delay();})
#define isa_inw_p(p)      ({u16 v=isa_inw(p);isa_delay();v;})
#define isa_outw_p(v,p)   ({isa_outw((v),(p));isa_delay();})
#define isa_inl_p(p)      ({u32 v=isa_inl(p);isa_delay();v;})
#define isa_outl_p(v,p)   ({isa_outl((v),(p));isa_delay();})

#define isa_insb(port, buf, nr) raw_insb(isa_itb(port), (u8 *)(buf), (nr))
#define isa_outsb(port, buf, nr) raw_outsb(isa_itb(port), (u8 *)(buf), (nr))

#define isa_insw(port, buf, nr)     \
       (ISA_SEX ? raw_insw(isa_itw(port), (u16 *)(buf), (nr)) :    \
                  raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))

#define isa_outsw(port, buf, nr)    \
       (ISA_SEX ? raw_outsw(isa_itw(port), (u16 *)(buf), (nr)) :  \
                  raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
247 248 249 250 251 252 253 254 255

#define isa_insl(port, buf, nr)     \
       (ISA_SEX ? raw_insl(isa_itl(port), (u32 *)(buf), (nr)) :    \
                  raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))

#define isa_outsl(port, buf, nr)    \
       (ISA_SEX ? raw_outsl(isa_itl(port), (u32 *)(buf), (nr)) :  \
                  raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))

L
Linus Torvalds 已提交
256 257 258 259 260 261 262 263 264

#define inb     isa_inb
#define inb_p   isa_inb_p
#define outb    isa_outb
#define outb_p  isa_outb_p
#define inw     isa_inw
#define inw_p   isa_inw_p
#define outw    isa_outw
#define outw_p  isa_outw_p
265 266 267 268
#define inl     isa_inl
#define inl_p   isa_inl_p
#define outl    isa_outl
#define outl_p  isa_outl_p
L
Linus Torvalds 已提交
269 270
#define insb    isa_insb
#define insw    isa_insw
271
#define insl    isa_insl
L
Linus Torvalds 已提交
272 273
#define outsb   isa_outsb
#define outsw   isa_outsw
274
#define outsl   isa_outsl
L
Linus Torvalds 已提交
275 276 277 278 279
#define readb   isa_readb
#define readw   isa_readw
#define writeb  isa_writeb
#define writew  isa_writew

A
Adrian Bunk 已提交
280
#else  /* CONFIG_ISA */
L
Linus Torvalds 已提交
281 282

/*
283
 * We need to define dummy functions for GENERIC_IOMAP support.
L
Linus Torvalds 已提交
284
 */
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
#define inb(port)          0xff
#define inb_p(port)        0xff
#define outb(val,port)     ((void)0)
#define outb_p(val,port)   ((void)0)
#define inw(port)          0xffff
#define outw(val,port)     ((void)0)
#define inl(port)          0xffffffffUL
#define outl(val,port)     ((void)0)

#define insb(port,buf,nr)  ((void)0)
#define outsb(port,buf,nr) ((void)0)
#define insw(port,buf,nr)  ((void)0)
#define outsw(port,buf,nr) ((void)0)
#define insl(port,buf,nr)  ((void)0)
#define outsl(port,buf,nr) ((void)0)
L
Linus Torvalds 已提交
300 301 302 303 304 305

/*
 * These should be valid on any ioremap()ed region
 */
#define readb(addr)      in_8(addr)
#define writeb(val,addr) out_8((addr),(val))
306 307
#define readw(addr)      in_le16(addr)
#define writew(val,addr) out_le16((addr),(val))
A
Adrian Bunk 已提交
308 309 310

#endif /* CONFIG_ISA */

L
Linus Torvalds 已提交
311 312 313 314 315
#define readl(addr)      in_le32(addr)
#define writel(val,addr) out_le32((addr),(val))

#define mmiowb()

A
Al Viro 已提交
316
static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
L
Linus Torvalds 已提交
317 318 319
{
	return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
}
A
Al Viro 已提交
320
static inline void __iomem *ioremap_nocache(unsigned long physaddr, unsigned long size)
L
Linus Torvalds 已提交
321 322 323
{
	return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
}
A
Al Viro 已提交
324
static inline void __iomem *ioremap_writethrough(unsigned long physaddr,
L
Linus Torvalds 已提交
325 326 327 328
					 unsigned long size)
{
	return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
}
A
Al Viro 已提交
329
static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
L
Linus Torvalds 已提交
330 331 332 333 334
				      unsigned long size)
{
	return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
}

335 336 337 338 339 340 341 342 343 344 345 346
static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
{
	__builtin_memset((void __force *) addr, val, count);
}
static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
{
	__builtin_memcpy(dst, (void __force *) src, count);
}
static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
{
	__builtin_memcpy((void __force *) dst, src, count);
}
L
Linus Torvalds 已提交
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369

#ifndef CONFIG_SUN3
#define IO_SPACE_LIMIT 0xffff
#else
#define IO_SPACE_LIMIT 0x0fffffff
#endif

#endif /* __KERNEL__ */

#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED		1

/*
 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
 * access
 */
#define xlate_dev_mem_ptr(p)	__va(p)

/*
 * Convert a virtual cached pointer to an uncached pointer
 */
#define xlate_dev_kmem_ptr(p)	p

#endif /* _IO_H */