Import 2.3.18pre1
[davej-history.git] / include / asm-ppc / ide.h
blobfffe270cb7fea95a32abd3f5ebe8aeac4f4c30e4
1 /*
2 * linux/include/asm-ppc/ide.h
4 * Copyright (C) 1994-1996 Linus Torvalds & authors */
6 /*
7 * This file contains the ppc architecture specific IDE code.
8 */
10 #ifndef __ASMPPC_IDE_H
11 #define __ASMPPC_IDE_H
13 #include <linux/sched.h>
14 #include <asm/processor.h>
16 #ifndef MAX_HWIFS
17 #define MAX_HWIFS 4
18 #endif
20 #include <asm/hdreg.h>
22 #ifdef __KERNEL__
24 #include <linux/config.h>
25 #include <linux/hdreg.h>
26 #include <linux/ioport.h>
27 #include <asm/io.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,
47 unsigned int extent,
48 const char *name);
49 void (*ide_release_region)(ide_ioreg_t from,
50 unsigned int extent);
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,
55 int *irq);
57 int io_base;
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);
66 #undef insw
67 #define insw(port, buf, ns) do { \
68 ppc_ide_md.insw((port), (buf), (ns)); \
69 } while (0)
71 #undef outsw
72 #define outsw(port, buf, ns) do { \
73 ppc_ide_md.outsw((port), (buf), (ns)); \
74 } while (0)
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);
87 else
88 return -1;
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);
95 else
96 return -1;
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
110 hw_regs_t hw;
111 int index;
112 ide_ioreg_t base;
114 for (index = 0; index < MAX_HWIFS; index++) {
115 base = ide_default_io_base(index);
116 if (base == 0)
117 continue;
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);
129 else
130 return -1;
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 */
152 #undef inb
153 #define inb(port) in_8((unsigned char *)((port) + ppc_ide_md.io_base))
154 #undef inb_p
155 #define inb_p(port) inb(port)
157 #undef outb
158 #define outb(val, port) \
159 out_8((unsigned char *)((port) + ppc_ide_md.io_base), (val) )
160 #undef outb_p
161 #define outb_p(val, port) outb(val, port)
162 #endif
164 typedef union {
165 unsigned all : 8; /* all of the bits together */
166 struct {
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 */
172 } b;
173 } select_t;
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
181 #define ide_ack_intr(hwif) (1)
182 #define ide_release_lock(lock) do {} while (0)
183 #define ide_get_lock(lock, hdlr, data) do {} while (0)
185 #endif /* __KERNEL__ */
187 #endif /* __ASMPPC_IDE_H */