2 * linux/include/asm-ppc/ide.h
4 * Copyright (C) 1994-1996 Linus Torvalds & authors */
7 * This file contains the ppc architecture specific IDE code.
10 #ifndef __ASMPPC_IDE_H
11 #define __ASMPPC_IDE_H
13 #include <linux/sched.h>
14 #include <asm/processor.h>
20 #include <asm/hdreg.h>
24 #include <linux/config.h>
25 #include <linux/hdreg.h>
26 #include <linux/ioport.h>
29 extern int pmac_ide_ports_known
;
30 extern ide_ioreg_t pmac_ide_regbase
[MAX_HWIFS
];
31 extern int pmac_ide_irq
[MAX_HWIFS
];
32 extern void pmac_ide_probe(void);
34 extern int chrp_ide_ports_known
;
35 extern ide_ioreg_t chrp_ide_regbase
[MAX_HWIFS
];
36 extern ide_ioreg_t chrp_idedma_regbase
; /* one for both channels */
37 extern unsigned int chrp_ide_irq
;
38 extern void chrp_ide_probe(void);
40 struct ide_machdep_calls
{
41 void (*insw
)(ide_ioreg_t port
, void *buf
, int ns
);
42 void (*outsw
)(ide_ioreg_t port
, void *buf
, int ns
);
43 int (*default_irq
)(ide_ioreg_t base
);
44 ide_ioreg_t (*default_io_base
)(int index
);
45 int (*ide_check_region
)(ide_ioreg_t from
, unsigned int extent
);
46 void (*ide_request_region
)(ide_ioreg_t from
,
49 void (*ide_release_region
)(ide_ioreg_t from
,
51 void (*fix_driveid
)(struct hd_driveid
*id
);
52 void (*ide_init_hwif
)(hw_regs_t
*hw
,
53 ide_ioreg_t data_port
,
54 ide_ioreg_t ctrl_port
,
60 extern struct ide_machdep_calls ppc_ide_md
;
62 void ide_insw(ide_ioreg_t port
, void *buf
, int ns
);
63 void ide_outsw(ide_ioreg_t port
, void *buf
, int ns
);
64 void ppc_generic_ide_fix_driveid(struct hd_driveid
*id
);
67 #define insw(port, buf, ns) do { \
68 ppc_ide_md.insw((port), (buf), (ns)); \
72 #define outsw(port, buf, ns) do { \
73 ppc_ide_md.outsw((port), (buf), (ns)); \
76 #undef SUPPORT_SLOW_DATA_PORTS
77 #define SUPPORT_SLOW_DATA_PORTS 0
78 #undef SUPPORT_VLB_SYNC
79 #define SUPPORT_VLB_SYNC 0
81 #define ide__sti() __sti()
83 static __inline__
int ide_default_irq(ide_ioreg_t base
)
85 if ( ppc_ide_md
.default_irq
)
86 return ppc_ide_md
.default_irq(base
);
91 static __inline__ ide_ioreg_t
ide_default_io_base(int index
)
93 if ( ppc_ide_md
.default_io_base
)
94 return ppc_ide_md
.default_io_base(index
);
99 static __inline__
void ide_init_hwif_ports(hw_regs_t
*hw
,
100 ide_ioreg_t data_port
,
101 ide_ioreg_t ctrl_port
, int *irq
)
103 if (ppc_ide_md
.ide_init_hwif
!= NULL
)
104 ppc_ide_md
.ide_init_hwif(hw
, data_port
, ctrl_port
, irq
);
107 static __inline__
void ide_init_default_hwifs(void)
109 #ifndef CONFIG_BLK_DEV_IDEPCI
114 for (index
= 0; index
< MAX_HWIFS
; index
++) {
115 base
= ide_default_io_base(index
);
118 ide_init_hwif_ports(&hw
, base
, 0, NULL
);
119 hw
.irq
= ide_default_irq(base
);
120 ide_register_hw(&hw
, NULL
);
122 #endif /* CONFIG_BLK_DEV_IDEPCI */
125 static __inline__
int ide_check_region (ide_ioreg_t from
, unsigned int extent
)
127 if ( ppc_ide_md
.ide_check_region
)
128 return ppc_ide_md
.ide_check_region(from
, extent
);
133 static __inline__
void ide_request_region (ide_ioreg_t from
, unsigned int extent
, const char *name
)
135 if ( ppc_ide_md
.ide_request_region
)
136 ppc_ide_md
.ide_request_region(from
, extent
, name
);
139 static __inline__
void ide_release_region (ide_ioreg_t from
, unsigned int extent
)
141 if ( ppc_ide_md
.ide_release_region
)
142 ppc_ide_md
.ide_release_region(from
, extent
);
145 static __inline__
void ide_fix_driveid (struct hd_driveid
*id
)
147 if ( ppc_ide_md
.fix_driveid
)
148 ppc_ide_md
.fix_driveid(id
);
151 #if 0 /* inb/outb from io.h is OK now -- paulus */
153 #define inb(port) in_8((unsigned char *)((port) + ppc_ide_md.io_base))
155 #define inb_p(port) inb(port)
158 #define outb(val, port) \
159 out_8((unsigned char *)((port) + ppc_ide_md.io_base), (val) )
161 #define outb_p(val, port) outb(val, port)
165 unsigned all
: 8; /* all of the bits together */
167 unsigned bit7
: 1; /* always 1 */
168 unsigned lba
: 1; /* using LBA instead of CHS */
169 unsigned bit5
: 1; /* always 1 */
170 unsigned unit
: 1; /* drive select number, 0/1 */
171 unsigned head
: 4; /* always zeros here */
175 #define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id))
176 #define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id))
179 * The following are not needed for the non-m68k ports
182 #define ide_ack_intr(hwif) (hwif->hw.ack_intr ? hwif->hw.ack_intr(hwif) : 1)
184 #define ide_ack_intr(hwif) (1)
186 #define ide_release_lock(lock) do {} while (0)
187 #define ide_get_lock(lock, hdlr, data) do {} while (0)
189 #endif /* __KERNEL__ */
191 #endif /* __ASMPPC_IDE_H */