1 /* $Id: ide.h,v 1.6 2000/05/27 00:49:37 davem Exp $
2 * ide.h: SPARC PCI specific IDE glue.
3 *
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 * Adaptation from sparc64 version to sparc by Pete Zaitcev.
7 */
8
9 #ifndef _SPARC_IDE_H
10 #define _SPARC_IDE_H
11
12 #ifdef __KERNEL__
13
14 #include <linux/config.h>
15 #include <asm/pgtable.h>
16 #include <asm/io.h>
17 #include <asm/hdreg.h>
18 #include <asm/psr.h>
19
20 #undef MAX_HWIFS
21 #define MAX_HWIFS 2
22
ide_default_irq(ide_ioreg_t base)23 static __inline__ int ide_default_irq(ide_ioreg_t base)
24 {
25 return 0;
26 }
27
ide_default_io_base(int index)28 static __inline__ ide_ioreg_t ide_default_io_base(int index)
29 {
30 return 0;
31 }
32
33 /*
34 * Doing any sort of ioremap() here does not work
35 * because this function may be called with null aguments.
36 */
ide_init_hwif_ports(hw_regs_t * hw,ide_ioreg_t data_port,ide_ioreg_t ctrl_port,int * irq)37 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
38 {
39 ide_ioreg_t reg = data_port;
40 int i;
41
42 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
43 hw->io_ports[i] = reg;
44 reg += 1;
45 }
46 if (ctrl_port) {
47 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
48 } else {
49 hw->io_ports[IDE_CONTROL_OFFSET] = 0;
50 }
51 if (irq != NULL)
52 *irq = 0;
53 hw->io_ports[IDE_IRQ_OFFSET] = 0;
54 }
55
56 /*
57 * This registers the standard ports for this architecture with the IDE
58 * driver.
59 */
ide_init_default_hwifs(void)60 static __inline__ void ide_init_default_hwifs(void)
61 {
62 #ifndef CONFIG_BLK_DEV_IDEPCI
63 hw_regs_t hw;
64 int index;
65
66 for (index = 0; index < MAX_HWIFS; index++) {
67 ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
68 hw.irq = ide_default_irq(ide_default_io_base(index));
69 ide_register_hw(&hw, NULL);
70 }
71 #endif /* CONFIG_BLK_DEV_IDEPCI */
72 }
73
74 #undef SUPPORT_SLOW_DATA_PORTS
75 #define SUPPORT_SLOW_DATA_PORTS 0
76
77 #undef SUPPORT_VLB_SYNC
78 #define SUPPORT_VLB_SYNC 0
79
80 #undef HD_DATA
81 #define HD_DATA ((ide_ioreg_t)0)
82
83 /* From m68k code... */
84
85 #ifdef insl
86 #undef insl
87 #endif
88 #ifdef outsl
89 #undef outsl
90 #endif
91 #ifdef insw
92 #undef insw
93 #endif
94 #ifdef outsw
95 #undef outsw
96 #endif
97
98 #define insl(data_reg, buffer, wcount) insw(data_reg, buffer, (wcount)<<1)
99 #define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, (wcount)<<1)
100
101 #define insw(port, buf, nr) ide_insw((port), (buf), (nr))
102 #define outsw(port, buf, nr) ide_outsw((port), (buf), (nr))
103
ide_insw(unsigned long port,void * dst,unsigned long count)104 static __inline__ void ide_insw(unsigned long port,
105 void *dst,
106 unsigned long count)
107 {
108 volatile unsigned short *data_port;
109 /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
110 u16 *ps = dst;
111 u32 *pi;
112
113 data_port = (volatile unsigned short *)port;
114
115 if(((unsigned long)ps) & 0x2) {
116 *ps++ = *data_port;
117 count--;
118 }
119 pi = (u32 *)ps;
120 while(count >= 2) {
121 u32 w;
122
123 w = (*data_port) << 16;
124 w |= (*data_port);
125 *pi++ = w;
126 count -= 2;
127 }
128 ps = (u16 *)pi;
129 if(count)
130 *ps++ = *data_port;
131
132 /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
133 }
134
ide_outsw(unsigned long port,const void * src,unsigned long count)135 static __inline__ void ide_outsw(unsigned long port,
136 const void *src,
137 unsigned long count)
138 {
139 volatile unsigned short *data_port;
140 /* unsigned long end = (unsigned long)src + (count << 1); */
141 const u16 *ps = src;
142 const u32 *pi;
143
144 data_port = (volatile unsigned short *)port;
145
146 if(((unsigned long)src) & 0x2) {
147 *data_port = *ps++;
148 count--;
149 }
150 pi = (const u32 *)ps;
151 while(count >= 2) {
152 u32 w;
153
154 w = *pi++;
155 *data_port = (w >> 16);
156 *data_port = w;
157 count -= 2;
158 }
159 ps = (const u16 *)pi;
160 if(count)
161 *data_port = *ps;
162
163 /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
164 }
165
166 #endif /* __KERNEL__ */
167
168 #endif /* _SPARC_IDE_H */
169