Stephen Rothwell | 5adcaf5 | 2006-09-19 22:17:49 +1000 | [diff] [blame^] | 1 | /* |
| 2 | * I/O string operations |
| 3 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
| 4 | * Copyright (C) 2006 IBM Corporation |
| 5 | * |
| 6 | * Largely rewritten by Cort Dougan (cort@cs.nmt.edu) |
| 7 | * and Paul Mackerras. |
| 8 | * |
| 9 | * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com) |
| 10 | * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com) |
| 11 | * |
| 12 | * Rewritten in C by Stephen Rothwell. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * as published by the Free Software Foundation; either version |
| 17 | * 2 of the License, or (at your option) any later version. |
| 18 | */ |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/compiler.h> |
| 22 | #include <linux/module.h> |
| 23 | |
| 24 | #include <asm/io.h> |
| 25 | |
| 26 | void _insb(volatile u8 __iomem *port, void *buf, long count) |
| 27 | { |
| 28 | u8 *tbuf = buf; |
| 29 | u8 tmp; |
| 30 | |
| 31 | if (unlikely(count <= 0)) |
| 32 | return; |
| 33 | asm volatile("sync"); |
| 34 | do { |
| 35 | tmp = *port; |
| 36 | asm volatile("eieio"); |
| 37 | *tbuf++ = tmp; |
| 38 | } while (--count != 0); |
| 39 | asm volatile("twi 0,%0,0; isync" : : "r" (tmp)); |
| 40 | } |
| 41 | EXPORT_SYMBOL(_insb); |
| 42 | |
| 43 | void _outsb(volatile u8 __iomem *port, const void *buf, long count) |
| 44 | { |
| 45 | const u8 *tbuf = buf; |
| 46 | |
| 47 | if (unlikely(count <= 0)) |
| 48 | return; |
| 49 | asm volatile("sync"); |
| 50 | do { |
| 51 | *port = *tbuf++; |
| 52 | } while (--count != 0); |
| 53 | asm volatile("sync"); |
| 54 | } |
| 55 | EXPORT_SYMBOL(_outsb); |
| 56 | |
| 57 | void _insw_ns(volatile u16 __iomem *port, void *buf, long count) |
| 58 | { |
| 59 | u16 *tbuf = buf; |
| 60 | u16 tmp; |
| 61 | |
| 62 | if (unlikely(count <= 0)) |
| 63 | return; |
| 64 | asm volatile("sync"); |
| 65 | do { |
| 66 | tmp = *port; |
| 67 | asm volatile("eieio"); |
| 68 | *tbuf++ = tmp; |
| 69 | } while (--count != 0); |
| 70 | asm volatile("twi 0,%0,0; isync" : : "r" (tmp)); |
| 71 | } |
| 72 | EXPORT_SYMBOL(_insw_ns); |
| 73 | |
| 74 | void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count) |
| 75 | { |
| 76 | const u16 *tbuf = buf; |
| 77 | |
| 78 | if (unlikely(count <= 0)) |
| 79 | return; |
| 80 | asm volatile("sync"); |
| 81 | do { |
| 82 | *port = *tbuf++; |
| 83 | } while (--count != 0); |
| 84 | asm volatile("sync"); |
| 85 | } |
| 86 | EXPORT_SYMBOL(_outsw_ns); |
| 87 | |
| 88 | void _insl_ns(volatile u32 __iomem *port, void *buf, long count) |
| 89 | { |
| 90 | u32 *tbuf = buf; |
| 91 | u32 tmp; |
| 92 | |
| 93 | if (unlikely(count <= 0)) |
| 94 | return; |
| 95 | asm volatile("sync"); |
| 96 | do { |
| 97 | tmp = *port; |
| 98 | asm volatile("eieio"); |
| 99 | *tbuf++ = tmp; |
| 100 | } while (--count != 0); |
| 101 | asm volatile("twi 0,%0,0; isync" : : "r" (tmp)); |
| 102 | } |
| 103 | EXPORT_SYMBOL(_insl_ns); |
| 104 | |
| 105 | void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count) |
| 106 | { |
| 107 | const u32 *tbuf = buf; |
| 108 | |
| 109 | if (unlikely(count <= 0)) |
| 110 | return; |
| 111 | asm volatile("sync"); |
| 112 | do { |
| 113 | *port = *tbuf++; |
| 114 | } while (--count != 0); |
| 115 | asm volatile("sync"); |
| 116 | } |
| 117 | EXPORT_SYMBOL(_outsl_ns); |