Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-s390/io.h |
| 3 | * |
| 4 | * S390 version |
| 5 | * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation |
| 6 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) |
| 7 | * |
| 8 | * Derived from "include/asm-i386/io.h" |
| 9 | */ |
| 10 | |
| 11 | #ifndef _S390_IO_H |
| 12 | #define _S390_IO_H |
| 13 | |
| 14 | #ifdef __KERNEL__ |
| 15 | |
| 16 | #include <linux/vmalloc.h> |
| 17 | #include <asm/page.h> |
| 18 | |
| 19 | #define IO_SPACE_LIMIT 0xffffffff |
| 20 | |
| 21 | #define __io_virt(x) ((void *)(PAGE_OFFSET | (unsigned long)(x))) |
| 22 | |
| 23 | /* |
| 24 | * Change virtual addresses to physical addresses and vv. |
| 25 | * These are pretty trivial |
| 26 | */ |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 27 | static inline unsigned long virt_to_phys(volatile void * address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | { |
| 29 | unsigned long real_address; |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 30 | asm volatile( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #ifndef __s390x__ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 32 | " lra %0,0(%1)\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #else /* __s390x__ */ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 34 | " lrag %0,0(%1)\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #endif /* __s390x__ */ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 36 | " jz 0f\n" |
| 37 | " la %0,0\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | "0:" |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 39 | : "=a" (real_address) : "a" (address) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | return real_address; |
| 41 | } |
| 42 | |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 43 | static inline void * phys_to_virt(unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | { |
| 45 | return __io_virt(address); |
| 46 | } |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags); |
| 49 | |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 50 | static inline void * ioremap (unsigned long offset, unsigned long size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
| 52 | return __ioremap(offset, size, 0); |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | * This one maps high address device memory and turns off caching for that area. |
| 57 | * it's useful if some control registers are in such an area and write combining |
| 58 | * or read caching is not desirable: |
| 59 | */ |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 60 | static inline void * ioremap_nocache (unsigned long offset, unsigned long size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | { |
| 62 | return __ioremap(offset, size, 0); |
| 63 | } |
| 64 | |
| 65 | extern void iounmap(void *addr); |
| 66 | |
| 67 | /* |
| 68 | * IO bus memory addresses are also 1:1 with the physical address |
| 69 | */ |
| 70 | #define virt_to_bus virt_to_phys |
| 71 | #define bus_to_virt phys_to_virt |
| 72 | |
| 73 | /* |
| 74 | * readX/writeX() are used to access memory mapped devices. On some |
| 75 | * architectures the memory mapped IO stuff needs to be accessed |
| 76 | * differently. |
| 77 | */ |
| 78 | |
| 79 | #define readb(addr) (*(volatile unsigned char *) __io_virt(addr)) |
| 80 | #define readw(addr) (*(volatile unsigned short *) __io_virt(addr)) |
| 81 | #define readl(addr) (*(volatile unsigned int *) __io_virt(addr)) |
Cedric Le Goater | 2eec0e0 | 2006-06-19 21:10:44 -0700 | [diff] [blame] | 82 | #define readq(addr) (*(volatile unsigned long long *) __io_virt(addr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
| 84 | #define readb_relaxed(addr) readb(addr) |
| 85 | #define readw_relaxed(addr) readw(addr) |
| 86 | #define readl_relaxed(addr) readl(addr) |
Cedric Le Goater | 2eec0e0 | 2006-06-19 21:10:44 -0700 | [diff] [blame] | 87 | #define readq_relaxed(addr) readq(addr) |
Heiko Carstens | 6ff290a | 2006-02-03 03:03:51 -0800 | [diff] [blame] | 88 | #define __raw_readb readb |
| 89 | #define __raw_readw readw |
| 90 | #define __raw_readl readl |
Cedric Le Goater | 2eec0e0 | 2006-06-19 21:10:44 -0700 | [diff] [blame] | 91 | #define __raw_readq readq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
| 93 | #define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b)) |
| 94 | #define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b)) |
| 95 | #define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b)) |
Cedric Le Goater | 2eec0e0 | 2006-06-19 21:10:44 -0700 | [diff] [blame] | 96 | #define writeq(b,addr) (*(volatile unsigned long long *) __io_virt(addr) = (b)) |
Heiko Carstens | 6ff290a | 2006-02-03 03:03:51 -0800 | [diff] [blame] | 97 | #define __raw_writeb writeb |
| 98 | #define __raw_writew writew |
| 99 | #define __raw_writel writel |
Cedric Le Goater | 2eec0e0 | 2006-06-19 21:10:44 -0700 | [diff] [blame] | 100 | #define __raw_writeq writeq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
| 102 | #define memset_io(a,b,c) memset(__io_virt(a),(b),(c)) |
| 103 | #define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c)) |
| 104 | #define memcpy_toio(a,b,c) memcpy(__io_virt(a),(b),(c)) |
| 105 | |
| 106 | #define inb_p(addr) readb(addr) |
| 107 | #define inb(addr) readb(addr) |
| 108 | |
| 109 | #define outb(x,addr) ((void) writeb(x,addr)) |
| 110 | #define outb_p(x,addr) outb(x,addr) |
| 111 | |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 112 | #define mmiowb() do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | /* |
| 115 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem |
| 116 | * access |
| 117 | */ |
| 118 | #define xlate_dev_mem_ptr(p) __va(p) |
| 119 | |
| 120 | /* |
| 121 | * Convert a virtual cached pointer to an uncached pointer |
| 122 | */ |
| 123 | #define xlate_dev_kmem_ptr(p) p |
| 124 | |
| 125 | #endif /* __KERNEL__ */ |
| 126 | |
| 127 | #endif |