Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/sh/kernel/io.c |
| 3 | * |
| 4 | * Copyright (C) 2000 Stuart Menefy |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 5 | * Copyright (C) 2005 Paul Mundt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * Provide real functions which expand to whatever the header file defined. |
| 8 | * Also definitions of machine independent IO functions. |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 9 | * |
| 10 | * This file is subject to the terms and conditions of the GNU General Public |
| 11 | * License. See the file "COPYING" in the main directory of this archive |
| 12 | * for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 15 | #include <asm/machvec.h> |
| 16 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * Copy data from IO memory space to "real" memory space. |
| 20 | * This needs to be optimized. |
| 21 | */ |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 22 | void memcpy_fromio(void *to, volatile void __iomem *from, unsigned long count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
| 24 | char *p = to; |
| 25 | while (count) { |
| 26 | count--; |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 27 | *p = readb((void __iomem *)from); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | p++; |
| 29 | from++; |
| 30 | } |
| 31 | } |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 32 | EXPORT_SYMBOL(memcpy_fromio); |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* |
| 35 | * Copy data from "real" memory space to IO memory space. |
| 36 | * This needs to be optimized. |
| 37 | */ |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 38 | void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | { |
| 40 | const char *p = from; |
| 41 | while (count) { |
| 42 | count--; |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 43 | writeb(*p, (void __iomem *)to); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | p++; |
| 45 | to++; |
| 46 | } |
| 47 | } |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 48 | EXPORT_SYMBOL(memcpy_toio); |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | /* |
| 51 | * "memset" on IO memory space. |
| 52 | * This needs to be optimized. |
| 53 | */ |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 54 | void memset_io(volatile void __iomem *dst, int c, unsigned long count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
| 56 | while (count) { |
| 57 | count--; |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 58 | writeb(c, (void __iomem *)dst); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | dst++; |
| 60 | } |
| 61 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | EXPORT_SYMBOL(memset_io); |
| 63 | |
Paul Mundt | b66c1a3 | 2006-01-16 22:14:15 -0800 | [diff] [blame] | 64 | void __iomem *ioport_map(unsigned long port, unsigned int nr) |
| 65 | { |
| 66 | return sh_mv.mv_ioport_map(port, nr); |
| 67 | } |
| 68 | EXPORT_SYMBOL(ioport_map); |
| 69 | |
| 70 | void ioport_unmap(void __iomem *addr) |
| 71 | { |
| 72 | sh_mv.mv_ioport_unmap(addr); |
| 73 | } |
| 74 | EXPORT_SYMBOL(ioport_unmap); |