1 /* $Id: ide.h,v 1.19 2000/05/27 00:49:37 davem Exp $
2 * ide.h: Ultra/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)
13 #include <linux/config.h>
14 #include <asm/pgalloc.h>
16 #include <asm/hdreg.h>
21 #define ide__sti() __sti()
23 static __inline__
int ide_default_irq(ide_ioreg_t base
)
28 static __inline__ ide_ioreg_t
ide_default_io_base(int index
)
33 static __inline__
void ide_init_hwif_ports(hw_regs_t
*hw
, ide_ioreg_t data_port
, ide_ioreg_t ctrl_port
, int *irq
)
35 ide_ioreg_t reg
= data_port
;
38 for (i
= IDE_DATA_OFFSET
; i
<= IDE_STATUS_OFFSET
; i
++) {
39 hw
->io_ports
[i
] = reg
;
43 hw
->io_ports
[IDE_CONTROL_OFFSET
] = ctrl_port
;
45 hw
->io_ports
[IDE_CONTROL_OFFSET
] = 0;
49 hw
->io_ports
[IDE_IRQ_OFFSET
] = 0;
53 * This registers the standard ports for this architecture with the IDE
56 static __inline__
void ide_init_default_hwifs(void)
58 #ifndef CONFIG_BLK_DEV_IDEPCI
62 for (index
= 0; index
< MAX_HWIFS
; index
++) {
63 ide_init_hwif_ports(&hw
, ide_default_io_base(index
), 0, NULL
);
64 hw
.irq
= ide_default_irq(ide_default_io_base(index
));
65 ide_register_hw(&hw
, NULL
);
67 #endif /* CONFIG_BLK_DEV_IDEPCI */
71 unsigned int all
: 8; /* all of the bits together */
73 unsigned int bit7
: 1;
75 unsigned int bit5
: 1;
76 unsigned int unit
: 1;
77 unsigned int head
: 4;
81 static __inline__
int ide_request_irq(unsigned int irq
,
82 void (*handler
)(int, void *, struct pt_regs
*),
83 unsigned long flags
, const char *name
, void *devid
)
85 return request_irq(irq
, handler
, SA_SHIRQ
, name
, devid
);
88 static __inline__
void ide_free_irq(unsigned int irq
, void *dev_id
)
90 free_irq(irq
, dev_id
);
93 static __inline__
int ide_check_region(ide_ioreg_t base
, unsigned int size
)
95 return check_region(base
, size
);
98 static __inline__
void ide_request_region(ide_ioreg_t base
, unsigned int size
,
101 request_region(base
, size
, name
);
104 static __inline__
void ide_release_region(ide_ioreg_t base
, unsigned int size
)
106 release_region(base
, size
);
109 #undef SUPPORT_SLOW_DATA_PORTS
110 #define SUPPORT_SLOW_DATA_PORTS 0
112 #undef SUPPORT_VLB_SYNC
113 #define SUPPORT_VLB_SYNC 0
116 #define HD_DATA ((ide_ioreg_t)0)
118 /* From m68k code... */
133 #define insl(data_reg, buffer, wcount) insw(data_reg, buffer, (wcount)<<1)
134 #define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, (wcount)<<1)
136 #define insw(port, buf, nr) ide_insw((port), (buf), (nr))
137 #define outsw(port, buf, nr) ide_outsw((port), (buf), (nr))
139 static __inline__
unsigned int inw_be(unsigned long addr
)
143 __asm__
__volatile__("lduha [%1] %2, %0"
145 : "r" (addr
), "i" (ASI_PHYS_BYPASS_EC_E
));
150 static __inline__
void ide_insw(unsigned long port
,
154 unsigned long end
= (unsigned long)dst
+ (count
<< 1);
158 if(((u64
)ps
) & 0x2) {
159 *ps
++ = inw_be(port
);
166 w
= inw_be(port
) << 16;
173 *ps
++ = inw_be(port
);
175 __flush_dcache_range((unsigned long)dst
, end
);
178 static __inline__
void outw_be(unsigned short w
, unsigned long addr
)
180 __asm__
__volatile__("stha %0, [%1] %2"
182 : "r" (w
), "r" (addr
), "i" (ASI_PHYS_BYPASS_EC_E
));
185 static __inline__
void ide_outsw(unsigned long port
,
189 unsigned long end
= (unsigned long)src
+ (count
<< 1);
193 if(((u64
)src
) & 0x2) {
194 outw_be(*ps
++, port
);
197 pi
= (const u32
*)ps
;
202 outw_be((w
>> 16), port
);
206 ps
= (const u16
*)pi
;
210 __flush_dcache_range((unsigned long)src
, end
);
213 #define T_CHAR (0x0000) /* char: don't touch */
214 #define T_SHORT (0x4000) /* short: 12 -> 21 */
215 #define T_INT (0x8000) /* int: 1234 -> 4321 */
216 #define T_TEXT (0xc000) /* text: 12 -> 21 */
218 #define T_MASK_TYPE (0xc000)
219 #define T_MASK_COUNT (0x3fff)
221 #define D_CHAR(cnt) (T_CHAR | (cnt))
222 #define D_SHORT(cnt) (T_SHORT | (cnt))
223 #define D_INT(cnt) (T_INT | (cnt))
224 #define D_TEXT(cnt) (T_TEXT | (cnt))
226 static u_short driveid_types
[] = {
227 D_SHORT(10), /* config - vendor2 */
228 D_TEXT(20), /* serial_no */
229 D_SHORT(3), /* buf_type - ecc_bytes */
230 D_TEXT(48), /* fw_rev - model */
231 D_CHAR(2), /* max_multsect - vendor3 */
232 D_SHORT(1), /* dword_io */
233 D_CHAR(2), /* vendor4 - capability */
234 D_SHORT(1), /* reserved50 */
235 D_CHAR(4), /* vendor5 - tDMA */
236 D_SHORT(4), /* field_valid - cur_sectors */
237 D_INT(1), /* cur_capacity */
238 D_CHAR(2), /* multsect - multsect_valid */
239 D_INT(1), /* lba_capacity */
240 D_SHORT(194) /* dma_1word - reservedyy */
243 #define num_driveid_types (sizeof(driveid_types)/sizeof(*driveid_types))
245 static __inline__
void ide_fix_driveid(struct hd_driveid
*id
)
247 u_char
*p
= (u_char
*)id
;
251 for (i
= 0; i
< num_driveid_types
; i
++) {
252 cnt
= driveid_types
[i
] & T_MASK_COUNT
;
253 switch (driveid_types
[i
] & T_MASK_TYPE
) {
258 for (j
= 0; j
< cnt
; j
++) {
266 for (j
= 0; j
< cnt
; j
++) {
277 for (j
= 0; j
< cnt
; j
+= 2) {
289 * The following are not needed for the non-m68k ports
291 #define ide_ack_intr(hwif) (1)
292 #define ide_release_lock(lock) do {} while (0)
293 #define ide_get_lock(lock, hdlr, data) do {} while (0)
295 #endif /* __KERNEL__ */
297 #endif /* _SPARC64_IDE_H */