1 /* $Id: ide.h,v 1.2 2000/01/21 04:56:27 zaitcev Exp $
2 * ide.h: SPARC PCI specific IDE glue.
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.
14 #include <asm/pgtable.h>
16 #include <asm/hdreg.h>
22 #define ide__sti() __sti()
24 static __inline__
int ide_default_irq(ide_ioreg_t base
)
29 static __inline__ ide_ioreg_t
ide_default_io_base(int index
)
35 * Doing any sort of ioremap() here does not work
36 * because this function may be called with null aguments.
38 static __inline__
void ide_init_hwif_ports(hw_regs_t
*hw
, ide_ioreg_t data_port
, ide_ioreg_t ctrl_port
, int *irq
)
40 ide_ioreg_t reg
= data_port
;
43 for (i
= IDE_DATA_OFFSET
; i
<= IDE_STATUS_OFFSET
; i
++) {
44 hw
->io_ports
[i
] = reg
;
48 hw
->io_ports
[IDE_CONTROL_OFFSET
] = ctrl_port
;
50 hw
->io_ports
[IDE_CONTROL_OFFSET
] = 0;
57 * This registers the standard ports for this architecture with the IDE
60 static __inline__
void ide_init_default_hwifs(void)
62 #ifdef __DO_I_NEED_THIS
66 for (index
= 0; index
< MAX_HWIFS
; index
++) {
67 ide_init_hwif_ports(&hw
, ide_default_io_base(index
), 0, 0);
68 hw
.irq
= ide_default_irq(ide_default_io_base(index
));
69 ide_register_hw(&hw
, NULL
);
71 #endif /* __DO_I_NEED_THIS */
75 unsigned int all
: 8; /* all of the bits together */
77 unsigned int bit7
: 1;
79 unsigned int bit5
: 1;
80 unsigned int unit
: 1;
81 unsigned int head
: 4;
85 static __inline__
int ide_request_irq(unsigned int irq
,
86 void (*handler
)(int, void *, struct pt_regs
*),
87 unsigned long flags
, const char *name
, void *devid
)
89 return request_irq(irq
, handler
, SA_SHIRQ
, name
, devid
);
92 static __inline__
void ide_free_irq(unsigned int irq
, void *dev_id
)
94 free_irq(irq
, dev_id
);
97 static __inline__
int ide_check_region(ide_ioreg_t base
, unsigned int size
)
99 /* We leave these empty because pcic.c calls sparc_alloc_io() */
103 static __inline__
void ide_request_region(ide_ioreg_t base
, unsigned int size
,
108 static __inline__
void ide_release_region(ide_ioreg_t base
, unsigned int size
)
112 #undef SUPPORT_SLOW_DATA_PORTS
113 #define SUPPORT_SLOW_DATA_PORTS 0
115 #undef SUPPORT_VLB_SYNC
116 #define SUPPORT_VLB_SYNC 0
119 #define HD_DATA ((ide_ioreg_t)0)
121 /* From m68k code... */
136 #define insl(data_reg, buffer, wcount) insw(data_reg, buffer, (wcount)<<1)
137 #define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, (wcount)<<1)
139 #define insw(port, buf, nr) ide_insw((port), (buf), (nr))
140 #define outsw(port, buf, nr) ide_outsw((port), (buf), (nr))
142 static __inline__
void ide_insw(unsigned long port
,
146 volatile unsigned short *data_port
;
147 /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
151 data_port
= (volatile unsigned short *)port
;
153 if(((unsigned long)ps
) & 0x2) {
161 w
= (*data_port
) << 16;
170 /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
173 static __inline__
void ide_outsw(unsigned long port
,
177 volatile unsigned short *data_port
;
178 /* unsigned long end = (unsigned long)src + (count << 1); */
182 data_port
= (volatile unsigned short *)port
;
184 if(((unsigned long)src
) & 0x2) {
188 pi
= (const u32
*)ps
;
193 *data_port
= (w
>> 16);
197 ps
= (const u16
*)pi
;
201 /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
204 #define T_CHAR (0x0000) /* char: don't touch */
205 #define T_SHORT (0x4000) /* short: 12 -> 21 */
206 #define T_INT (0x8000) /* int: 1234 -> 4321 */
207 #define T_TEXT (0xc000) /* text: 12 -> 21 */
209 #define T_MASK_TYPE (0xc000)
210 #define T_MASK_COUNT (0x3fff)
212 #define D_CHAR(cnt) (T_CHAR | (cnt))
213 #define D_SHORT(cnt) (T_SHORT | (cnt))
214 #define D_INT(cnt) (T_INT | (cnt))
215 #define D_TEXT(cnt) (T_TEXT | (cnt))
217 static u_short driveid_types
[] = {
218 D_SHORT(10), /* config - vendor2 */
219 D_TEXT(20), /* serial_no */
220 D_SHORT(3), /* buf_type - ecc_bytes */
221 D_TEXT(48), /* fw_rev - model */
222 D_CHAR(2), /* max_multsect - vendor3 */
223 D_SHORT(1), /* dword_io */
224 D_CHAR(2), /* vendor4 - capability */
225 D_SHORT(1), /* reserved50 */
226 D_CHAR(4), /* vendor5 - tDMA */
227 D_SHORT(4), /* field_valid - cur_sectors */
228 D_INT(1), /* cur_capacity */
229 D_CHAR(2), /* multsect - multsect_valid */
230 D_INT(1), /* lba_capacity */
231 D_SHORT(194) /* dma_1word - reservedyy */
234 #define num_driveid_types (sizeof(driveid_types)/sizeof(*driveid_types))
236 static __inline__
void ide_fix_driveid(struct hd_driveid
*id
)
238 u_char
*p
= (u_char
*)id
;
242 for (i
= 0; i
< num_driveid_types
; i
++) {
243 cnt
= driveid_types
[i
] & T_MASK_COUNT
;
244 switch (driveid_types
[i
] & T_MASK_TYPE
) {
249 for (j
= 0; j
< cnt
; j
++) {
257 for (j
= 0; j
< cnt
; j
++) {
268 for (j
= 0; j
< cnt
; j
+= 2) {
280 * The following are not needed for the non-m68k ports
282 #define ide_ack_intr(hwif) (1)
283 /* #define ide_ack_intr(hwif) ((hwif)->hw.ack_intr ? (hwif)->hw.ack_intr(hwif) : 1) */
284 #define ide_release_lock(lock) do {} while (0)
285 #define ide_get_lock(lock, hdlr, data) do {} while (0)
287 #endif /* __KERNEL__ */
289 #endif /* _SPARC_IDE_H */