blob: 4076cb5d1581cdbcce73bac0e2c9cc5974064db2 [file] [log] [blame]
David S. Miller64d329e2007-10-27 00:17:01 -07001/* ide.h: SPARC PCI specific IDE glue.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
David S. Miller64d329e2007-10-27 00:17:01 -07003 * Copyright (C) 1997 David S. Miller (davem@davemloft.net)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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 Torvalds1da177e2005-04-16 15:20:36 -070013#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 Torvalds1da177e2005-04-16 15:20:36 -070020#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
21
22#define __ide_insl(data_reg, buffer, wcount) \
23 __ide_insw(data_reg, buffer, (wcount)<<1)
24#define __ide_outsl(data_reg, buffer, wcount) \
25 __ide_outsw(data_reg, buffer, (wcount)<<1)
26
27/* On sparc, I/O ports and MMIO registers are accessed identically. */
28#define __ide_mm_insw __ide_insw
29#define __ide_mm_insl __ide_insl
30#define __ide_mm_outsw __ide_outsw
31#define __ide_mm_outsl __ide_outsl
32
David S. Miller64d329e2007-10-27 00:17:01 -070033static inline void __ide_insw(unsigned long port,
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 void *dst,
35 unsigned long count)
36{
37 volatile unsigned short *data_port;
38 /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
39 u16 *ps = dst;
40 u32 *pi;
41
42 data_port = (volatile unsigned short *)port;
43
44 if(((unsigned long)ps) & 0x2) {
45 *ps++ = *data_port;
46 count--;
47 }
48 pi = (u32 *)ps;
49 while(count >= 2) {
50 u32 w;
51
52 w = (*data_port) << 16;
53 w |= (*data_port);
54 *pi++ = w;
55 count -= 2;
56 }
57 ps = (u16 *)pi;
58 if(count)
59 *ps++ = *data_port;
60
61 /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
62}
63
David S. Miller64d329e2007-10-27 00:17:01 -070064static inline void __ide_outsw(unsigned long port,
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 const void *src,
66 unsigned long count)
67{
68 volatile unsigned short *data_port;
69 /* unsigned long end = (unsigned long)src + (count << 1); */
70 const u16 *ps = src;
71 const u32 *pi;
72
73 data_port = (volatile unsigned short *)port;
74
75 if(((unsigned long)src) & 0x2) {
76 *data_port = *ps++;
77 count--;
78 }
79 pi = (const u32 *)ps;
80 while(count >= 2) {
81 u32 w;
82
83 w = *pi++;
84 *data_port = (w >> 16);
85 *data_port = w;
86 count -= 2;
87 }
88 ps = (const u16 *)pi;
89 if(count)
90 *data_port = *ps;
91
92 /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
93}
94
95#endif /* __KERNEL__ */
96
97#endif /* _SPARC_IDE_H */