aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/legacy
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-26 16:44:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-26 16:44:19 -0400
commita52b0d25a722e84da999005b75f972aa4824253c (patch)
tree4a3a48305f744e6bde2e3fd663a4473dd712049c /drivers/ide/legacy
parent539a5fe22620a1665cce504167953a71a43232ad (diff)
parentf37afdaca711838b50ecd89b9c15fc745270d77c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (46 commits) ide: constify struct ide_dma_ops ide: add struct ide_dma_ops (take 3) ide: add IDE_HFLAG_SERIALIZE_DMA host flag sl82c105: check bridge revision in sl82c105_init_one() au1xxx-ide: use ->init_dma method palm_bk3710: use ->init_dma method sgiioc4: use ->init_dma method icside: use ->init_dma method ide-pmac: use ->init_dma method ide: do complete DMA setup in ->init_dma method (take 2) au1xxx-ide: fix MWDMA support ide: cleanup ide_setup_dma() ide: factor out setting PCI bus-mastering from ide_hwif_setup_dma() ide: export ide_allocate_dma_engine() ide: move ide_setup_dma() call out from ->init_dma method alim15x3: skip DMA initialization completely on revs < 0x20 pdc202xx_old: remove init_dma_pdc202xx() ide: don't display "BIOS" settings in ide_setup_dma() ide: remove ->cds field from ide_hwif_t (take 2) ide: remove ide_dma_iobase() ...
Diffstat (limited to 'drivers/ide/legacy')
-rw-r--r--drivers/ide/legacy/ali14xx.c38
-rw-r--r--drivers/ide/legacy/buddha.c2
-rw-r--r--drivers/ide/legacy/dtc2278.c36
-rw-r--r--drivers/ide/legacy/falconide.c1
-rw-r--r--drivers/ide/legacy/gayle.c2
-rw-r--r--drivers/ide/legacy/ht6560b.c46
-rw-r--r--drivers/ide/legacy/ide-4drives.c18
-rw-r--r--drivers/ide/legacy/ide-cs.c76
-rw-r--r--drivers/ide/legacy/ide_platform.c1
-rw-r--r--drivers/ide/legacy/macide.c2
-rw-r--r--drivers/ide/legacy/q40ide.c1
-rw-r--r--drivers/ide/legacy/qd65xx.c130
-rw-r--r--drivers/ide/legacy/umc8672.c37
13 files changed, 143 insertions, 247 deletions
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index 33bb7b87be5d..6efbf947c6db 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -49,6 +49,8 @@
49 49
50#include <asm/io.h> 50#include <asm/io.h>
51 51
52#define DRV_NAME "ali14xx"
53
52/* port addresses for auto-detection */ 54/* port addresses for auto-detection */
53#define ALI_NUM_PORTS 4 55#define ALI_NUM_PORTS 4
54static const int ports[ALI_NUM_PORTS] __initdata = 56static const int ports[ALI_NUM_PORTS] __initdata =
@@ -192,18 +194,20 @@ static int __init initRegisters(void)
192 return t; 194 return t;
193} 195}
194 196
197static const struct ide_port_ops ali14xx_port_ops = {
198 .set_pio_mode = ali14xx_set_pio_mode,
199};
200
195static const struct ide_port_info ali14xx_port_info = { 201static const struct ide_port_info ali14xx_port_info = {
202 .name = DRV_NAME,
196 .chipset = ide_ali14xx, 203 .chipset = ide_ali14xx,
204 .port_ops = &ali14xx_port_ops,
197 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, 205 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE,
198 .pio_mask = ATA_PIO4, 206 .pio_mask = ATA_PIO4,
199}; 207};
200 208
201static int __init ali14xx_probe(void) 209static int __init ali14xx_probe(void)
202{ 210{
203 ide_hwif_t *hwif, *mate;
204 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
205 hw_regs_t hw[2];
206
207 printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", 211 printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
208 basePort, regOn); 212 basePort, regOn);
209 213
@@ -213,31 +217,7 @@ static int __init ali14xx_probe(void)
213 return 1; 217 return 1;
214 } 218 }
215 219
216 memset(&hw, 0, sizeof(hw)); 220 return ide_legacy_device_add(&ali14xx_port_info, 0);
217
218 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
219 hw[0].irq = 14;
220
221 ide_std_init_ports(&hw[1], 0x170, 0x376);
222 hw[1].irq = 15;
223
224 hwif = ide_find_port();
225 if (hwif) {
226 ide_init_port_hw(hwif, &hw[0]);
227 hwif->set_pio_mode = &ali14xx_set_pio_mode;
228 idx[0] = hwif->index;
229 }
230
231 mate = ide_find_port();
232 if (mate) {
233 ide_init_port_hw(mate, &hw[1]);
234 mate->set_pio_mode = &ali14xx_set_pio_mode;
235 idx[1] = mate->index;
236 }
237
238 ide_device_add(idx, &ali14xx_port_info);
239
240 return 0;
241} 221}
242 222
243int probe_ali14xx; 223int probe_ali14xx;
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c
index 6956eb8f2d5f..f51433bce8e4 100644
--- a/drivers/ide/legacy/buddha.c
+++ b/drivers/ide/legacy/buddha.c
@@ -228,8 +228,6 @@ fail_base2:
228 ide_init_port_data(hwif, index); 228 ide_init_port_data(hwif, index);
229 ide_init_port_hw(hwif, &hw); 229 ide_init_port_hw(hwif, &hw);
230 230
231 hwif->mmio = 1;
232
233 idx[i] = index; 231 idx[i] = index;
234 } 232 }
235 } 233 }
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
index 9c6b3249a004..f7c4ad1c57c0 100644
--- a/drivers/ide/legacy/dtc2278.c
+++ b/drivers/ide/legacy/dtc2278.c
@@ -16,6 +16,8 @@
16 16
17#include <asm/io.h> 17#include <asm/io.h>
18 18
19#define DRV_NAME "dtc2278"
20
19/* 21/*
20 * Changing this #undef to #define may solve start up problems in some systems. 22 * Changing this #undef to #define may solve start up problems in some systems.
21 */ 23 */
@@ -86,8 +88,14 @@ static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio)
86 } 88 }
87} 89}
88 90
91static const struct ide_port_ops dtc2278_port_ops = {
92 .set_pio_mode = dtc2278_set_pio_mode,
93};
94
89static const struct ide_port_info dtc2278_port_info __initdata = { 95static const struct ide_port_info dtc2278_port_info __initdata = {
96 .name = DRV_NAME,
90 .chipset = ide_dtc2278, 97 .chipset = ide_dtc2278,
98 .port_ops = &dtc2278_port_ops,
91 .host_flags = IDE_HFLAG_SERIALIZE | 99 .host_flags = IDE_HFLAG_SERIALIZE |
92 IDE_HFLAG_NO_UNMASK_IRQS | 100 IDE_HFLAG_NO_UNMASK_IRQS |
93 IDE_HFLAG_IO_32BIT | 101 IDE_HFLAG_IO_32BIT |
@@ -101,9 +109,6 @@ static const struct ide_port_info dtc2278_port_info __initdata = {
101static int __init dtc2278_probe(void) 109static int __init dtc2278_probe(void)
102{ 110{
103 unsigned long flags; 111 unsigned long flags;
104 ide_hwif_t *hwif, *mate;
105 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
106 hw_regs_t hw[2];
107 112
108 local_irq_save(flags); 113 local_irq_save(flags);
109 /* 114 /*
@@ -123,30 +128,7 @@ static int __init dtc2278_probe(void)
123#endif 128#endif
124 local_irq_restore(flags); 129 local_irq_restore(flags);
125 130
126 memset(&hw, 0, sizeof(hw)); 131 return ide_legacy_device_add(&dtc2278_port_info, 0);
127
128 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
129 hw[0].irq = 14;
130
131 ide_std_init_ports(&hw[1], 0x170, 0x376);
132 hw[1].irq = 15;
133
134 hwif = ide_find_port();
135 if (hwif) {
136 ide_init_port_hw(hwif, &hw[0]);
137 hwif->set_pio_mode = dtc2278_set_pio_mode;
138 idx[0] = hwif->index;
139 }
140
141 mate = ide_find_port();
142 if (mate) {
143 ide_init_port_hw(mate, &hw[1]);
144 idx[1] = mate->index;
145 }
146
147 ide_device_add(idx, &dtc2278_port_info);
148
149 return 0;
150} 132}
151 133
152int probe_dtc2278 = 0; 134int probe_dtc2278 = 0;
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index 8c9c9f7f54ca..5c19c422c5cc 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -89,7 +89,6 @@ static int __init falconide_init(void)
89 89
90 ide_init_port_data(hwif, index); 90 ide_init_port_data(hwif, index);
91 ide_init_port_hw(hwif, &hw); 91 ide_init_port_hw(hwif, &hw);
92 hwif->mmio = 1;
93 92
94 ide_get_lock(NULL, NULL); 93 ide_get_lock(NULL, NULL);
95 ide_device_add(idx, NULL); 94 ide_device_add(idx, NULL);
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index fcc8d52bf2a1..a0c9601bdaf0 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -182,8 +182,6 @@ found:
182 ide_init_port_data(hwif, index); 182 ide_init_port_data(hwif, index);
183 ide_init_port_hw(hwif, &hw); 183 ide_init_port_hw(hwif, &hw);
184 184
185 hwif->mmio = 1;
186
187 idx[i] = index; 185 idx[i] = index;
188 } else 186 } else
189 release_mem_region(res_start, res_n); 187 release_mem_region(res_start, res_n);
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index 60f52f5158c9..702d8deb5780 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -328,8 +328,16 @@ int probe_ht6560b = 0;
328module_param_named(probe, probe_ht6560b, bool, 0); 328module_param_named(probe, probe_ht6560b, bool, 0);
329MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); 329MODULE_PARM_DESC(probe, "probe for HT6560B chipset");
330 330
331static const struct ide_port_ops ht6560b_port_ops = {
332 .port_init_devs = ht6560b_port_init_devs,
333 .set_pio_mode = ht6560b_set_pio_mode,
334 .selectproc = ht6560b_selectproc,
335};
336
331static const struct ide_port_info ht6560b_port_info __initdata = { 337static const struct ide_port_info ht6560b_port_info __initdata = {
338 .name = DRV_NAME,
332 .chipset = ide_ht6560b, 339 .chipset = ide_ht6560b,
340 .port_ops = &ht6560b_port_ops,
333 .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ 341 .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */
334 IDE_HFLAG_NO_DMA | 342 IDE_HFLAG_NO_DMA |
335 IDE_HFLAG_NO_AUTOTUNE | 343 IDE_HFLAG_NO_AUTOTUNE |
@@ -339,53 +347,21 @@ static const struct ide_port_info ht6560b_port_info __initdata = {
339 347
340static int __init ht6560b_init(void) 348static int __init ht6560b_init(void)
341{ 349{
342 ide_hwif_t *hwif, *mate;
343 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
344 hw_regs_t hw[2];
345
346 if (probe_ht6560b == 0) 350 if (probe_ht6560b == 0)
347 return -ENODEV; 351 return -ENODEV;
348 352
349 if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { 353 if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) {
350 printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", 354 printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
351 __FUNCTION__); 355 __func__);
352 return -ENODEV; 356 return -ENODEV;
353 } 357 }
354 358
355 if (!try_to_init_ht6560b()) { 359 if (!try_to_init_ht6560b()) {
356 printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__); 360 printk(KERN_NOTICE "%s: HBA not found\n", __func__);
357 goto release_region; 361 goto release_region;
358 } 362 }
359 363
360 memset(&hw, 0, sizeof(hw)); 364 return ide_legacy_device_add(&ht6560b_port_info, 0);
361
362 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
363 hw[0].irq = 14;
364
365 ide_std_init_ports(&hw[1], 0x170, 0x376);
366 hw[1].irq = 15;
367
368 hwif = ide_find_port();
369 if (hwif) {
370 ide_init_port_hw(hwif, &hw[0]);
371 hwif->selectproc = ht6560b_selectproc;
372 hwif->set_pio_mode = ht6560b_set_pio_mode;
373 hwif->port_init_devs = ht6560b_port_init_devs;
374 idx[0] = hwif->index;
375 }
376
377 mate = ide_find_port();
378 if (mate) {
379 ide_init_port_hw(mate, &hw[1]);
380 mate->selectproc = ht6560b_selectproc;
381 mate->set_pio_mode = ht6560b_set_pio_mode;
382 mate->port_init_devs = ht6560b_port_init_devs;
383 idx[1] = mate->index;
384 }
385
386 ide_device_add(idx, &ht6560b_port_info);
387
388 return 0;
389 365
390release_region: 366release_region:
391 release_region(HT_CONFIG_PORT, 1); 367 release_region(HT_CONFIG_PORT, 1);
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c
index c352f12348af..17f94d0cb539 100644
--- a/drivers/ide/legacy/ide-4drives.c
+++ b/drivers/ide/legacy/ide-4drives.c
@@ -4,6 +4,8 @@
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/ide.h> 5#include <linux/ide.h>
6 6
7#define DRV_NAME "ide-4drives"
8
7int probe_4drives; 9int probe_4drives;
8 10
9module_param_named(probe, probe_4drives, bool, 0); 11module_param_named(probe, probe_4drives, bool, 0);
@@ -12,15 +14,29 @@ MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
12static int __init ide_4drives_init(void) 14static int __init ide_4drives_init(void)
13{ 15{
14 ide_hwif_t *hwif, *mate; 16 ide_hwif_t *hwif, *mate;
17 unsigned long base = 0x1f0, ctl = 0x3f6;
15 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 18 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
16 hw_regs_t hw; 19 hw_regs_t hw;
17 20
18 if (probe_4drives == 0) 21 if (probe_4drives == 0)
19 return -ENODEV; 22 return -ENODEV;
20 23
24 if (!request_region(base, 8, DRV_NAME)) {
25 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
26 DRV_NAME, base, base + 7);
27 return -EBUSY;
28 }
29
30 if (!request_region(ctl, 1, DRV_NAME)) {
31 printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
32 DRV_NAME, ctl);
33 release_region(base, 8);
34 return -EBUSY;
35 }
36
21 memset(&hw, 0, sizeof(hw)); 37 memset(&hw, 0, sizeof(hw));
22 38
23 ide_std_init_ports(&hw, 0x1f0, 0x3f6); 39 ide_std_init_ports(&hw, base, ctl);
24 hw.irq = 14; 40 hw.irq = 14;
25 hw.chipset = ide_4drives; 41 hw.chipset = ide_4drives;
26 42
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index b97b8d51b3eb..855e157b18d3 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -51,6 +51,8 @@
51#include <pcmcia/cisreg.h> 51#include <pcmcia/cisreg.h>
52#include <pcmcia/ciscode.h> 52#include <pcmcia/ciscode.h>
53 53
54#define DRV_NAME "ide-cs"
55
54/*====================================================================*/ 56/*====================================================================*/
55 57
56/* Module parameters */ 58/* Module parameters */
@@ -72,16 +74,11 @@ static char *version =
72 74
73/*====================================================================*/ 75/*====================================================================*/
74 76
75static const char ide_major[] = {
76 IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR,
77 IDE4_MAJOR, IDE5_MAJOR
78};
79
80typedef struct ide_info_t { 77typedef struct ide_info_t {
81 struct pcmcia_device *p_dev; 78 struct pcmcia_device *p_dev;
79 ide_hwif_t *hwif;
82 int ndev; 80 int ndev;
83 dev_node_t node; 81 dev_node_t node;
84 int hd;
85} ide_info_t; 82} ide_info_t;
86 83
87static void ide_release(struct pcmcia_device *); 84static void ide_release(struct pcmcia_device *);
@@ -136,20 +133,44 @@ static int ide_probe(struct pcmcia_device *link)
136 133
137static void ide_detach(struct pcmcia_device *link) 134static void ide_detach(struct pcmcia_device *link)
138{ 135{
136 ide_info_t *info = link->priv;
137 ide_hwif_t *hwif = info->hwif;
138
139 DEBUG(0, "ide_detach(0x%p)\n", link); 139 DEBUG(0, "ide_detach(0x%p)\n", link);
140 140
141 ide_release(link); 141 ide_release(link);
142 142
143 kfree(link->priv); 143 release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1);
144 release_region(hwif->io_ports[IDE_DATA_OFFSET], 8);
145
146 kfree(info);
144} /* ide_detach */ 147} /* ide_detach */
145 148
146static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) 149static const struct ide_port_ops idecs_port_ops = {
150 .quirkproc = ide_undecoded_slave,
151};
152
153static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl,
154 unsigned long irq, struct pcmcia_device *handle)
147{ 155{
148 ide_hwif_t *hwif; 156 ide_hwif_t *hwif;
149 hw_regs_t hw; 157 hw_regs_t hw;
150 int i; 158 int i;
151 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 159 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
152 160
161 if (!request_region(io, 8, DRV_NAME)) {
162 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
163 DRV_NAME, io, io + 7);
164 return NULL;
165 }
166
167 if (!request_region(ctl, 1, DRV_NAME)) {
168 printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
169 DRV_NAME, ctl);
170 release_region(io, 8);
171 return NULL;
172 }
173
153 memset(&hw, 0, sizeof(hw)); 174 memset(&hw, 0, sizeof(hw));
154 ide_std_init_ports(&hw, io, ctl); 175 ide_std_init_ports(&hw, io, ctl);
155 hw.irq = irq; 176 hw.irq = irq;
@@ -158,7 +179,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
158 179
159 hwif = ide_find_port(); 180 hwif = ide_find_port();
160 if (hwif == NULL) 181 if (hwif == NULL)
161 return -1; 182 goto out_release;
162 183
163 i = hwif->index; 184 i = hwif->index;
164 185
@@ -168,13 +189,19 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
168 ide_init_port_data(hwif, i); 189 ide_init_port_data(hwif, i);
169 190
170 ide_init_port_hw(hwif, &hw); 191 ide_init_port_hw(hwif, &hw);
171 hwif->quirkproc = &ide_undecoded_slave; 192 hwif->port_ops = &idecs_port_ops;
172 193
173 idx[0] = i; 194 idx[0] = i;
174 195
175 ide_device_add(idx, NULL); 196 ide_device_add(idx, NULL);
176 197
177 return hwif->present ? i : -1; 198 if (hwif->present)
199 return hwif;
200
201out_release:
202 release_region(ctl, 1);
203 release_region(io, 8);
204 return NULL;
178} 205}
179 206
180/*====================================================================== 207/*======================================================================
@@ -199,8 +226,9 @@ static int ide_config(struct pcmcia_device *link)
199 cistpl_cftable_entry_t dflt; 226 cistpl_cftable_entry_t dflt;
200 } *stk = NULL; 227 } *stk = NULL;
201 cistpl_cftable_entry_t *cfg; 228 cistpl_cftable_entry_t *cfg;
202 int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0; 229 int i, pass, last_ret = 0, last_fn = 0, is_kme = 0;
203 unsigned long io_base, ctl_base; 230 unsigned long io_base, ctl_base;
231 ide_hwif_t *hwif;
204 232
205 DEBUG(0, "ide_config(0x%p)\n", link); 233 DEBUG(0, "ide_config(0x%p)\n", link);
206 234
@@ -296,14 +324,15 @@ static int ide_config(struct pcmcia_device *link)
296 outb(0x81, ctl_base+1); 324 outb(0x81, ctl_base+1);
297 325
298 /* retry registration in case device is still spinning up */ 326 /* retry registration in case device is still spinning up */
299 for (hd = -1, i = 0; i < 10; i++) { 327 for (i = 0; i < 10; i++) {
300 hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); 328 hwif = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link);
301 if (hd >= 0) break; 329 if (hwif)
330 break;
302 if (link->io.NumPorts1 == 0x20) { 331 if (link->io.NumPorts1 == 0x20) {
303 outb(0x02, ctl_base + 0x10); 332 outb(0x02, ctl_base + 0x10);
304 hd = idecs_register(io_base + 0x10, ctl_base + 0x10, 333 hwif = idecs_register(io_base + 0x10, ctl_base + 0x10,
305 link->irq.AssignedIRQ, link); 334 link->irq.AssignedIRQ, link);
306 if (hd >= 0) { 335 if (hwif) {
307 io_base += 0x10; 336 io_base += 0x10;
308 ctl_base += 0x10; 337 ctl_base += 0x10;
309 break; 338 break;
@@ -312,7 +341,7 @@ static int ide_config(struct pcmcia_device *link)
312 msleep(100); 341 msleep(100);
313 } 342 }
314 343
315 if (hd < 0) { 344 if (hwif == NULL) {
316 printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx" 345 printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx"
317 ", irq %u failed\n", io_base, ctl_base, 346 ", irq %u failed\n", io_base, ctl_base,
318 link->irq.AssignedIRQ); 347 link->irq.AssignedIRQ);
@@ -320,10 +349,10 @@ static int ide_config(struct pcmcia_device *link)
320 } 349 }
321 350
322 info->ndev = 1; 351 info->ndev = 1;
323 sprintf(info->node.dev_name, "hd%c", 'a' + (hd * 2)); 352 sprintf(info->node.dev_name, "hd%c", 'a' + hwif->index * 2);
324 info->node.major = ide_major[hd]; 353 info->node.major = hwif->major;
325 info->node.minor = 0; 354 info->node.minor = 0;
326 info->hd = hd; 355 info->hwif = hwif;
327 link->dev_node = &info->node; 356 link->dev_node = &info->node;
328 printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", 357 printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n",
329 info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); 358 info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10);
@@ -354,13 +383,14 @@ failed:
354void ide_release(struct pcmcia_device *link) 383void ide_release(struct pcmcia_device *link)
355{ 384{
356 ide_info_t *info = link->priv; 385 ide_info_t *info = link->priv;
386 ide_hwif_t *hwif = info->hwif;
357 387
358 DEBUG(0, "ide_release(0x%p)\n", link); 388 DEBUG(0, "ide_release(0x%p)\n", link);
359 389
360 if (info->ndev) { 390 if (info->ndev) {
361 /* FIXME: if this fails we need to queue the cleanup somehow 391 /* FIXME: if this fails we need to queue the cleanup somehow
362 -- need to investigate the required PCMCIA magic */ 392 -- need to investigate the required PCMCIA magic */
363 ide_unregister(info->hd); 393 ide_unregister(hwif->index);
364 } 394 }
365 info->ndev = 0; 395 info->ndev = 0;
366 396
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c
index bf240775531e..822f48b05c70 100644
--- a/drivers/ide/legacy/ide_platform.c
+++ b/drivers/ide/legacy/ide_platform.c
@@ -100,7 +100,6 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
100 hw.dev = &pdev->dev; 100 hw.dev = &pdev->dev;
101 101
102 ide_init_port_hw(hwif, &hw); 102 ide_init_port_hw(hwif, &hw);
103 hwif->mmio = 1;
104 103
105 if (mmio) 104 if (mmio)
106 default_hwif_mmiops(hwif); 105 default_hwif_mmiops(hwif);
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
index 7429b80cb089..26546d0afc7f 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/legacy/macide.c
@@ -128,8 +128,6 @@ static int __init macide_init(void)
128 ide_init_port_data(hwif, index); 128 ide_init_port_data(hwif, index);
129 ide_init_port_hw(hwif, &hw); 129 ide_init_port_hw(hwif, &hw);
130 130
131 hwif->mmio = 1;
132
133 ide_device_add(idx, NULL); 131 ide_device_add(idx, NULL);
134 } 132 }
135 133
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index fcbff0eced1b..f23999dd3d46 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -141,7 +141,6 @@ static int __init q40ide_init(void)
141 if (hwif) { 141 if (hwif) {
142 ide_init_port_data(hwif, hwif->index); 142 ide_init_port_data(hwif, hwif->index);
143 ide_init_port_hw(hwif, &hw); 143 ide_init_port_hw(hwif, &hw);
144 hwif->mmio = 1;
145 144
146 idx[i] = hwif->index; 145 idx[i] = hwif->index;
147 } 146 }
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index 6e820c7c5c6b..15a99aae0cf9 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -37,6 +37,8 @@
37#include <asm/system.h> 37#include <asm/system.h>
38#include <asm/io.h> 38#include <asm/io.h>
39 39
40#define DRV_NAME "qd65xx"
41
40#include "qd65xx.h" 42#include "qd65xx.h"
41 43
42/* 44/*
@@ -304,7 +306,20 @@ static void __init qd6580_port_init_devs(ide_hwif_t *hwif)
304 hwif->drives[1].drive_data = t2; 306 hwif->drives[1].drive_data = t2;
305} 307}
306 308
309static const struct ide_port_ops qd6500_port_ops = {
310 .port_init_devs = qd6500_port_init_devs,
311 .set_pio_mode = qd6500_set_pio_mode,
312 .selectproc = qd65xx_select,
313};
314
315static const struct ide_port_ops qd6580_port_ops = {
316 .port_init_devs = qd6580_port_init_devs,
317 .set_pio_mode = qd6580_set_pio_mode,
318 .selectproc = qd65xx_select,
319};
320
307static const struct ide_port_info qd65xx_port_info __initdata = { 321static const struct ide_port_info qd65xx_port_info __initdata = {
322 .name = DRV_NAME,
308 .chipset = ide_qd65xx, 323 .chipset = ide_qd65xx,
309 .host_flags = IDE_HFLAG_IO_32BIT | 324 .host_flags = IDE_HFLAG_IO_32BIT |
310 IDE_HFLAG_NO_DMA | 325 IDE_HFLAG_NO_DMA |
@@ -321,10 +336,8 @@ static const struct ide_port_info qd65xx_port_info __initdata = {
321 336
322static int __init qd_probe(int base) 337static int __init qd_probe(int base)
323{ 338{
324 ide_hwif_t *hwif; 339 int rc;
325 u8 config, unit; 340 u8 config, unit, control;
326 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
327 hw_regs_t hw[2];
328 struct ide_port_info d = qd65xx_port_info; 341 struct ide_port_info d = qd65xx_port_info;
329 342
330 config = inb(QD_CONFIG_PORT); 343 config = inb(QD_CONFIG_PORT);
@@ -337,21 +350,11 @@ static int __init qd_probe(int base)
337 if (unit) 350 if (unit)
338 d.host_flags |= IDE_HFLAG_QD_2ND_PORT; 351 d.host_flags |= IDE_HFLAG_QD_2ND_PORT;
339 352
340 memset(&hw, 0, sizeof(hw)); 353 switch (config & 0xf0) {
341 354 case QD_CONFIG_QD6500:
342 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
343 hw[0].irq = 14;
344
345 ide_std_init_ports(&hw[1], 0x170, 0x376);
346 hw[1].irq = 15;
347
348 if ((config & 0xf0) == QD_CONFIG_QD6500) {
349
350 if (qd_testreg(base)) 355 if (qd_testreg(base))
351 return -ENODEV; /* bad register */ 356 return -ENODEV; /* bad register */
352 357
353 /* qd6500 found */
354
355 if (config & QD_CONFIG_DISABLED) { 358 if (config & QD_CONFIG_DISABLED) {
356 printk(KERN_WARNING "qd6500 is disabled !\n"); 359 printk(KERN_WARNING "qd6500 is disabled !\n");
357 return -ENODEV; 360 return -ENODEV;
@@ -361,37 +364,14 @@ static int __init qd_probe(int base)
361 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", 364 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
362 config, QD_ID3); 365 config, QD_ID3);
363 366
367 d.port_ops = &qd6500_port_ops;
364 d.host_flags |= IDE_HFLAG_SINGLE; 368 d.host_flags |= IDE_HFLAG_SINGLE;
365 369 break;
366 hwif = ide_find_port_slot(&d); 370 case QD_CONFIG_QD6580_A:
367 if (hwif == NULL) 371 case QD_CONFIG_QD6580_B:
368 return -ENOENT;
369
370 ide_init_port_hw(hwif, &hw[unit]);
371
372 hwif->config_data = (base << 8) | config;
373
374 hwif->port_init_devs = qd6500_port_init_devs;
375 hwif->set_pio_mode = qd6500_set_pio_mode;
376 hwif->selectproc = qd65xx_select;
377
378 idx[unit] = hwif->index;
379
380 ide_device_add(idx, &d);
381
382 return 1;
383 }
384
385 if (((config & 0xf0) == QD_CONFIG_QD6580_A) ||
386 ((config & 0xf0) == QD_CONFIG_QD6580_B)) {
387
388 u8 control;
389
390 if (qd_testreg(base) || qd_testreg(base + 0x02)) 372 if (qd_testreg(base) || qd_testreg(base + 0x02))
391 return -ENODEV; /* bad registers */ 373 return -ENODEV; /* bad registers */
392 374
393 /* qd6580 found */
394
395 control = inb(QD_CONTROL_PORT); 375 control = inb(QD_CONTROL_PORT);
396 376
397 printk(KERN_NOTICE "qd6580 at %#x\n", base); 377 printk(KERN_NOTICE "qd6580 at %#x\n", base);
@@ -400,63 +380,23 @@ static int __init qd_probe(int base)
400 380
401 outb(QD_DEF_CONTR, QD_CONTROL_PORT); 381 outb(QD_DEF_CONTR, QD_CONTROL_PORT);
402 382
403 if (control & QD_CONTR_SEC_DISABLED) { 383 d.port_ops = &qd6580_port_ops;
404 /* secondary disabled */ 384 if (control & QD_CONTR_SEC_DISABLED)
405
406 printk(KERN_INFO "qd6580: single IDE board\n");
407
408 d.host_flags |= IDE_HFLAG_SINGLE; 385 d.host_flags |= IDE_HFLAG_SINGLE;
409 386
410 hwif = ide_find_port_slot(&d); 387 printk(KERN_INFO "qd6580: %s IDE board\n",
411 if (hwif == NULL) 388 (control & QD_CONTR_SEC_DISABLED) ? "single" : "dual");
412 return -ENOENT; 389 break;
413 390 default:
414 ide_init_port_hw(hwif, &hw[unit]); 391 return -ENODEV;
415 392 }
416 hwif->config_data = (base << 8) | config;
417
418 hwif->port_init_devs = qd6580_port_init_devs;
419 hwif->set_pio_mode = qd6580_set_pio_mode;
420 hwif->selectproc = qd65xx_select;
421 393
422 idx[unit] = hwif->index; 394 rc = ide_legacy_device_add(&d, (base << 8) | config);
423 395
424 ide_device_add(idx, &d); 396 if (d.host_flags & IDE_HFLAG_SINGLE)
397 return (rc == 0) ? 1 : rc;
425 398
426 return 1; 399 return rc;
427 } else {
428 ide_hwif_t *mate;
429
430 /* secondary enabled */
431 printk(KERN_INFO "qd6580: dual IDE board\n");
432
433 hwif = ide_find_port();
434 if (hwif) {
435 ide_init_port_hw(hwif, &hw[0]);
436 hwif->config_data = (base << 8) | config;
437 hwif->port_init_devs = qd6580_port_init_devs;
438 hwif->set_pio_mode = qd6580_set_pio_mode;
439 hwif->selectproc = qd65xx_select;
440 idx[0] = hwif->index;
441 }
442
443 mate = ide_find_port();
444 if (mate) {
445 ide_init_port_hw(mate, &hw[1]);
446 mate->config_data = (base << 8) | config;
447 mate->port_init_devs = qd6580_port_init_devs;
448 mate->set_pio_mode = qd6580_set_pio_mode;
449 mate->selectproc = qd65xx_select;
450 idx[1] = mate->index;
451 }
452
453 ide_device_add(idx, &qd65xx_port_info);
454
455 return 0; /* no other qd65xx possible */
456 }
457 }
458 /* no qd65xx found */
459 return -ENODEV;
460} 400}
461 401
462int probe_qd65xx = 0; 402int probe_qd65xx = 0;
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
index 4d90badd2bda..17d515329fe0 100644
--- a/drivers/ide/legacy/umc8672.c
+++ b/drivers/ide/legacy/umc8672.c
@@ -51,6 +51,8 @@
51 51
52#include <asm/io.h> 52#include <asm/io.h>
53 53
54#define DRV_NAME "umc8672"
55
54/* 56/*
55 * Default speeds. These can be changed with "auto-tune" and/or hdparm. 57 * Default speeds. These can be changed with "auto-tune" and/or hdparm.
56 */ 58 */
@@ -120,18 +122,21 @@ static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio)
120 spin_unlock_irqrestore(&ide_lock, flags); 122 spin_unlock_irqrestore(&ide_lock, flags);
121} 123}
122 124
125static const struct ide_port_ops umc8672_port_ops = {
126 .set_pio_mode = umc_set_pio_mode,
127};
128
123static const struct ide_port_info umc8672_port_info __initdata = { 129static const struct ide_port_info umc8672_port_info __initdata = {
130 .name = DRV_NAME,
124 .chipset = ide_umc8672, 131 .chipset = ide_umc8672,
132 .port_ops = &umc8672_port_ops,
125 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, 133 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE,
126 .pio_mask = ATA_PIO4, 134 .pio_mask = ATA_PIO4,
127}; 135};
128 136
129static int __init umc8672_probe(void) 137static int __init umc8672_probe(void)
130{ 138{
131 ide_hwif_t *hwif, *mate;
132 unsigned long flags; 139 unsigned long flags;
133 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
134 hw_regs_t hw[2];
135 140
136 if (!request_region(0x108, 2, "umc8672")) { 141 if (!request_region(0x108, 2, "umc8672")) {
137 printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); 142 printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n");
@@ -150,31 +155,7 @@ static int __init umc8672_probe(void)
150 umc_set_speeds(current_speeds); 155 umc_set_speeds(current_speeds);
151 local_irq_restore(flags); 156 local_irq_restore(flags);
152 157
153 memset(&hw, 0, sizeof(hw)); 158 return ide_legacy_device_add(&umc8672_port_info, 0);
154
155 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
156 hw[0].irq = 14;
157
158 ide_std_init_ports(&hw[1], 0x170, 0x376);
159 hw[1].irq = 15;
160
161 hwif = ide_find_port();
162 if (hwif) {
163 ide_init_port_hw(hwif, &hw[0]);
164 hwif->set_pio_mode = umc_set_pio_mode;
165 idx[0] = hwif->index;
166 }
167
168 mate = ide_find_port();
169 if (mate) {
170 ide_init_port_hw(mate, &hw[1]);
171 mate->set_pio_mode = umc_set_pio_mode;
172 idx[1] = mate->index;
173 }
174
175 ide_device_add(idx, &umc8672_port_info);
176
177 return 0;
178} 159}
179 160
180int probe_umc8672; 161int probe_umc8672;