David S. Miller | 64d329e | 2007-10-27 00:17:01 -0700 | [diff] [blame] | 1 | /* ide.h: SPARC PCI specific IDE glue. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
David S. Miller | 64d329e | 2007-10-27 00:17:01 -0700 | [diff] [blame] | 3 | * Copyright (C) 1997 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) |
| 5 | * Adaptation from sparc64 version to sparc by Pete Zaitcev. |
| 6 | */ |
| 7 | |
| 8 | #ifndef _SPARC_IDE_H |
| 9 | #define _SPARC_IDE_H |
| 10 | |
| 11 | #ifdef __KERNEL__ |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/pgtable.h> |
| 14 | #include <asm/io.h> |
| 15 | #include <asm/psr.h> |
| 16 | |
| 17 | #undef MAX_HWIFS |
| 18 | #define MAX_HWIFS 2 |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #define __ide_insl(data_reg, buffer, wcount) \ |
| 21 | __ide_insw(data_reg, buffer, (wcount)<<1) |
| 22 | #define __ide_outsl(data_reg, buffer, wcount) \ |
| 23 | __ide_outsw(data_reg, buffer, (wcount)<<1) |
| 24 | |
| 25 | /* On sparc, I/O ports and MMIO registers are accessed identically. */ |
| 26 | #define __ide_mm_insw __ide_insw |
| 27 | #define __ide_mm_insl __ide_insl |
| 28 | #define __ide_mm_outsw __ide_outsw |
| 29 | #define __ide_mm_outsl __ide_outsl |
| 30 | |
David S. Miller | 64d329e | 2007-10-27 00:17:01 -0700 | [diff] [blame] | 31 | static inline void __ide_insw(unsigned long port, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | void *dst, |
| 33 | unsigned long count) |
| 34 | { |
| 35 | volatile unsigned short *data_port; |
| 36 | /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */ |
| 37 | u16 *ps = dst; |
| 38 | u32 *pi; |
| 39 | |
| 40 | data_port = (volatile unsigned short *)port; |
| 41 | |
| 42 | if(((unsigned long)ps) & 0x2) { |
| 43 | *ps++ = *data_port; |
| 44 | count--; |
| 45 | } |
| 46 | pi = (u32 *)ps; |
| 47 | while(count >= 2) { |
| 48 | u32 w; |
| 49 | |
| 50 | w = (*data_port) << 16; |
| 51 | w |= (*data_port); |
| 52 | *pi++ = w; |
| 53 | count -= 2; |
| 54 | } |
| 55 | ps = (u16 *)pi; |
| 56 | if(count) |
| 57 | *ps++ = *data_port; |
| 58 | |
| 59 | /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */ |
| 60 | } |
| 61 | |
David S. Miller | 64d329e | 2007-10-27 00:17:01 -0700 | [diff] [blame] | 62 | static inline void __ide_outsw(unsigned long port, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | const void *src, |
| 64 | unsigned long count) |
| 65 | { |
| 66 | volatile unsigned short *data_port; |
| 67 | /* unsigned long end = (unsigned long)src + (count << 1); */ |
| 68 | const u16 *ps = src; |
| 69 | const u32 *pi; |
| 70 | |
| 71 | data_port = (volatile unsigned short *)port; |
| 72 | |
| 73 | if(((unsigned long)src) & 0x2) { |
| 74 | *data_port = *ps++; |
| 75 | count--; |
| 76 | } |
| 77 | pi = (const u32 *)ps; |
| 78 | while(count >= 2) { |
| 79 | u32 w; |
| 80 | |
| 81 | w = *pi++; |
| 82 | *data_port = (w >> 16); |
| 83 | *data_port = w; |
| 84 | count -= 2; |
| 85 | } |
| 86 | ps = (const u16 *)pi; |
| 87 | if(count) |
| 88 | *data_port = *ps; |
| 89 | |
| 90 | /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */ |
| 91 | } |
| 92 | |
| 93 | #endif /* __KERNEL__ */ |
| 94 | |
| 95 | #endif /* _SPARC_IDE_H */ |