aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 11:36:36 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 11:36:36 -0400
commite277f91fef8a0ff7726ad33eb79c6f0d0c6229a8 (patch)
treed275b5e0c720c5db73efa446c86a2437fd93dca2 /drivers/ide
parentfe80b937c9917887e4fbfaaf52f498b5ac3a6999 (diff)
ide: use ide_find_port() in legacy VLB host drivers (take 2)
* Add IDE_HFLAG_QD_2ND_PORT host flag to indicate the need of skipping first ide_hwifs[] slot for the second port of QD65xx controller. * Handle this new host flag in ide_find_port_slot(). * Convert legacy VLB host drivers to use ide_find_port(). While at it: * Fix couple of printk()-s in qd65xx host driver to not use hwif->name. v2: * Fix qd65xx. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-probe.c4
-rw-r--r--drivers/ide/legacy/ali14xx.c19
-rw-r--r--drivers/ide/legacy/dtc2278.c22
-rw-r--r--drivers/ide/legacy/ht6560b.c31
-rw-r--r--drivers/ide/legacy/ide-4drives.c34
-rw-r--r--drivers/ide/legacy/qd65xx.c72
-rw-r--r--drivers/ide/legacy/umc8672.c19
7 files changed, 120 insertions, 81 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index f81793f3f247..875429728021 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1468,7 +1468,9 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d)
1468 * ports 0x1f0/0x170 (the ide0/ide1 defaults). 1468 * ports 0x1f0/0x170 (the ide0/ide1 defaults).
1469 */ 1469 */
1470 if (bootable) { 1470 if (bootable) {
1471 for (i = 0; i < MAX_HWIFS; i++) { 1471 i = (d && (d->host_flags & IDE_HFLAG_QD_2ND_PORT)) ? 1 : 0;
1472
1473 for (; i < MAX_HWIFS; i++) {
1472 hwif = &ide_hwifs[i]; 1474 hwif = &ide_hwifs[i];
1473 if (hwif->chipset == ide_unknown) 1475 if (hwif->chipset == ide_unknown)
1474 return hwif; 1476 return hwif;
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index bc8b1f8de614..c9536dd268cd 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -199,7 +199,8 @@ static const struct ide_port_info ali14xx_port_info = {
199 199
200static int __init ali14xx_probe(void) 200static int __init ali14xx_probe(void)
201{ 201{
202 static u8 idx[4] = { 0, 1, 0xff, 0xff }; 202 ide_hwif_t *hwif, *mate;
203 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
203 hw_regs_t hw[2]; 204 hw_regs_t hw[2];
204 205
205 printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", 206 printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
@@ -219,11 +220,19 @@ static int __init ali14xx_probe(void)
219 ide_std_init_ports(&hw[1], 0x170, 0x376); 220 ide_std_init_ports(&hw[1], 0x170, 0x376);
220 hw[1].irq = 15; 221 hw[1].irq = 15;
221 222
222 ide_init_port_hw(&ide_hwifs[0], &hw[0]); 223 hwif = ide_find_port();
223 ide_init_port_hw(&ide_hwifs[1], &hw[1]); 224 if (hwif) {
225 ide_init_port_hw(hwif, &hw[0]);
226 hwif->set_pio_mode = &ali14xx_set_pio_mode;
227 idx[0] = hwif->index;
228 }
224 229
225 ide_hwifs[0].set_pio_mode = &ali14xx_set_pio_mode; 230 mate = ide_find_port();
226 ide_hwifs[1].set_pio_mode = &ali14xx_set_pio_mode; 231 if (mate) {
232 ide_init_port_hw(mate, &hw[1]);
233 mate->set_pio_mode = &ali14xx_set_pio_mode;
234 idx[1] = mate->index;
235 }
227 236
228 ide_device_add(idx, &ali14xx_port_info); 237 ide_device_add(idx, &ali14xx_port_info);
229 238
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
index 5f69cd2ea6f7..9c6b3249a004 100644
--- a/drivers/ide/legacy/dtc2278.c
+++ b/drivers/ide/legacy/dtc2278.c
@@ -102,15 +102,9 @@ static int __init dtc2278_probe(void)
102{ 102{
103 unsigned long flags; 103 unsigned long flags;
104 ide_hwif_t *hwif, *mate; 104 ide_hwif_t *hwif, *mate;
105 static u8 idx[4] = { 0, 1, 0xff, 0xff }; 105 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
106 hw_regs_t hw[2]; 106 hw_regs_t hw[2];
107 107
108 hwif = &ide_hwifs[0];
109 mate = &ide_hwifs[1];
110
111 if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown)
112 return 1;
113
114 local_irq_save(flags); 108 local_irq_save(flags);
115 /* 109 /*
116 * This enables the second interface 110 * This enables the second interface
@@ -137,10 +131,18 @@ static int __init dtc2278_probe(void)
137 ide_std_init_ports(&hw[1], 0x170, 0x376); 131 ide_std_init_ports(&hw[1], 0x170, 0x376);
138 hw[1].irq = 15; 132 hw[1].irq = 15;
139 133
140 ide_init_port_hw(hwif, &hw[0]); 134 hwif = ide_find_port();
141 ide_init_port_hw(mate, &hw[1]); 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 }
142 140
143 hwif->set_pio_mode = &dtc2278_set_pio_mode; 141 mate = ide_find_port();
142 if (mate) {
143 ide_init_port_hw(mate, &hw[1]);
144 idx[1] = mate->index;
145 }
144 146
145 ide_device_add(idx, &dtc2278_port_info); 147 ide_device_add(idx, &dtc2278_port_info);
146 148
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index fd21209025e1..60f52f5158c9 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -340,15 +340,12 @@ static const struct ide_port_info ht6560b_port_info __initdata = {
340static int __init ht6560b_init(void) 340static int __init ht6560b_init(void)
341{ 341{
342 ide_hwif_t *hwif, *mate; 342 ide_hwif_t *hwif, *mate;
343 static u8 idx[4] = { 0, 1, 0xff, 0xff }; 343 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
344 hw_regs_t hw[2]; 344 hw_regs_t hw[2];
345 345
346 if (probe_ht6560b == 0) 346 if (probe_ht6560b == 0)
347 return -ENODEV; 347 return -ENODEV;
348 348
349 hwif = &ide_hwifs[0];
350 mate = &ide_hwifs[1];
351
352 if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { 349 if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) {
353 printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", 350 printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
354 __FUNCTION__); 351 __FUNCTION__);
@@ -368,17 +365,23 @@ static int __init ht6560b_init(void)
368 ide_std_init_ports(&hw[1], 0x170, 0x376); 365 ide_std_init_ports(&hw[1], 0x170, 0x376);
369 hw[1].irq = 15; 366 hw[1].irq = 15;
370 367
371 ide_init_port_hw(hwif, &hw[0]); 368 hwif = ide_find_port();
372 ide_init_port_hw(mate, &hw[1]); 369 if (hwif) {
373 370 ide_init_port_hw(hwif, &hw[0]);
374 hwif->selectproc = &ht6560b_selectproc; 371 hwif->selectproc = ht6560b_selectproc;
375 hwif->set_pio_mode = &ht6560b_set_pio_mode; 372 hwif->set_pio_mode = ht6560b_set_pio_mode;
376 373 hwif->port_init_devs = ht6560b_port_init_devs;
377 mate->selectproc = &ht6560b_selectproc; 374 idx[0] = hwif->index;
378 mate->set_pio_mode = &ht6560b_set_pio_mode; 375 }
379 376
380 hwif->port_init_devs = ht6560b_port_init_devs; 377 mate = ide_find_port();
381 mate->port_init_devs = ht6560b_port_init_devs; 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 }
382 385
383 ide_device_add(idx, &ht6560b_port_info); 386 ide_device_add(idx, &ht6560b_port_info);
384 387
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c
index ecd7f3553554..d7bc94f94a39 100644
--- a/drivers/ide/legacy/ide-4drives.c
+++ b/drivers/ide/legacy/ide-4drives.c
@@ -12,31 +12,37 @@ MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
12static int __init ide_4drives_init(void) 12static int __init ide_4drives_init(void)
13{ 13{
14 ide_hwif_t *hwif, *mate; 14 ide_hwif_t *hwif, *mate;
15 u8 idx[4] = { 0, 1, 0xff, 0xff }; 15 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
16 hw_regs_t hw; 16 hw_regs_t hw;
17 17
18 if (probe_4drives == 0) 18 if (probe_4drives == 0)
19 return -ENODEV; 19 return -ENODEV;
20 20
21 hwif = &ide_hwifs[0];
22 mate = &ide_hwifs[1];
23
24 memset(&hw, 0, sizeof(hw)); 21 memset(&hw, 0, sizeof(hw));
25 22
26 ide_std_init_ports(&hw, 0x1f0, 0x3f6); 23 ide_std_init_ports(&hw, 0x1f0, 0x3f6);
27 hw.irq = 14; 24 hw.irq = 14;
28 hw.chipset = ide_4drives; 25 hw.chipset = ide_4drives;
29 26
30 ide_init_port_hw(hwif, &hw); 27 hwif = ide_find_port();
31 ide_init_port_hw(mate, &hw); 28 if (hwif) {
32 29 ide_init_port_hw(hwif, &hw);
33 mate->drives[0].select.all ^= 0x20; 30 idx[0] = hwif->index;
34 mate->drives[1].select.all ^= 0x20; 31 }
35 32
36 hwif->mate = mate; 33 mate = ide_find_port();
37 mate->mate = hwif; 34 if (mate) {
38 35 ide_init_port_hw(mate, &hw);
39 hwif->serialized = mate->serialized = 1; 36 mate->drives[0].select.all ^= 0x20;
37 mate->drives[1].select.all ^= 0x20;
38 idx[1] = mate->index;
39
40 if (hwif) {
41 hwif->mate = mate;
42 mate->mate = hwif;
43 hwif->serialized = mate->serialized = 1;
44 }
45 }
40 46
41 ide_device_add(idx, NULL); 47 ide_device_add(idx, NULL);
42 48
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index 5c92fb6d81a1..b693a5f21a42 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -355,6 +355,7 @@ static int __init qd_probe(int base)
355 u8 config, unit; 355 u8 config, unit;
356 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 356 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
357 hw_regs_t hw[2]; 357 hw_regs_t hw[2];
358 struct ide_port_info d = qd65xx_port_info;
358 359
359 config = inb(QD_CONFIG_PORT); 360 config = inb(QD_CONFIG_PORT);
360 361
@@ -363,6 +364,9 @@ static int __init qd_probe(int base)
363 364
364 unit = ! (config & QD_CONFIG_IDE_BASEPORT); 365 unit = ! (config & QD_CONFIG_IDE_BASEPORT);
365 366
367 if (unit)
368 d.host_flags |= IDE_HFLAG_QD_2ND_PORT;
369
366 memset(&hw, 0, sizeof(hw)); 370 memset(&hw, 0, sizeof(hw));
367 371
368 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 372 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
@@ -378,16 +382,19 @@ static int __init qd_probe(int base)
378 382
379 /* qd6500 found */ 383 /* qd6500 found */
380 384
381 hwif = &ide_hwifs[unit];
382 printk(KERN_NOTICE "%s: qd6500 at %#x\n", hwif->name, base);
383 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
384 config, QD_ID3);
385
386 if (config & QD_CONFIG_DISABLED) { 385 if (config & QD_CONFIG_DISABLED) {
387 printk(KERN_WARNING "qd6500 is disabled !\n"); 386 printk(KERN_WARNING "qd6500 is disabled !\n");
388 return -ENODEV; 387 return -ENODEV;
389 } 388 }
390 389
390 printk(KERN_NOTICE "qd6500 at %#x\n", base);
391 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
392 config, QD_ID3);
393
394 hwif = ide_find_port_slot(&d);
395 if (hwif == NULL)
396 return -ENOENT;
397
391 ide_init_port_hw(hwif, &hw[unit]); 398 ide_init_port_hw(hwif, &hw[unit]);
392 399
393 qd_setup(hwif, base, config); 400 qd_setup(hwif, base, config);
@@ -395,9 +402,9 @@ static int __init qd_probe(int base)
395 hwif->port_init_devs = qd6500_port_init_devs; 402 hwif->port_init_devs = qd6500_port_init_devs;
396 hwif->set_pio_mode = &qd6500_set_pio_mode; 403 hwif->set_pio_mode = &qd6500_set_pio_mode;
397 404
398 idx[unit] = unit; 405 idx[unit] = hwif->index;
399 406
400 ide_device_add(idx, &qd65xx_port_info); 407 ide_device_add(idx, &d);
401 408
402 return 1; 409 return 1;
403 } 410 }
@@ -423,9 +430,11 @@ static int __init qd_probe(int base)
423 if (control & QD_CONTR_SEC_DISABLED) { 430 if (control & QD_CONTR_SEC_DISABLED) {
424 /* secondary disabled */ 431 /* secondary disabled */
425 432
426 hwif = &ide_hwifs[unit]; 433 printk(KERN_INFO "qd6580: single IDE board\n");
427 printk(KERN_INFO "%s: qd6580: single IDE board\n", 434
428 hwif->name); 435 hwif = ide_find_port_slot(&d);
436 if (hwif == NULL)
437 return -ENOENT;
429 438
430 ide_init_port_hw(hwif, &hw[unit]); 439 ide_init_port_hw(hwif, &hw[unit]);
431 440
@@ -434,35 +443,34 @@ static int __init qd_probe(int base)
434 hwif->port_init_devs = qd6580_port_init_devs; 443 hwif->port_init_devs = qd6580_port_init_devs;
435 hwif->set_pio_mode = &qd6580_set_pio_mode; 444 hwif->set_pio_mode = &qd6580_set_pio_mode;
436 445
437 idx[unit] = unit; 446 idx[unit] = hwif->index;
438 447
439 ide_device_add(idx, &qd65xx_port_info); 448 ide_device_add(idx, &d);
440 449
441 return 1; 450 return 1;
442 } else { 451 } else {
443 ide_hwif_t *mate; 452 ide_hwif_t *mate;
444 453
445 hwif = &ide_hwifs[0];
446 mate = &ide_hwifs[1];
447 /* secondary enabled */ 454 /* secondary enabled */
448 printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", 455 printk(KERN_INFO "qd6580: dual IDE board\n");
449 hwif->name, mate->name); 456
450 457 hwif = ide_find_port();
451 ide_init_port_hw(hwif, &hw[0]); 458 if (hwif) {
452 ide_init_port_hw(mate, &hw[1]); 459 ide_init_port_hw(hwif, &hw[0]);
453 460 qd_setup(hwif, base, config | (control << 8));
454 qd_setup(hwif, base, config | (control << 8)); 461 hwif->port_init_devs = qd6580_port_init_devs;
455 462 hwif->set_pio_mode = qd6580_set_pio_mode;
456 hwif->port_init_devs = qd6580_port_init_devs; 463 idx[0] = hwif->index;
457 hwif->set_pio_mode = &qd6580_set_pio_mode; 464 }
458 465
459 qd_setup(mate, base, config | (control << 8)); 466 mate = ide_find_port();
460 467 if (mate) {
461 mate->port_init_devs = qd6580_port_init_devs; 468 ide_init_port_hw(mate, &hw[1]);
462 mate->set_pio_mode = &qd6580_set_pio_mode; 469 qd_setup(mate, base, config | (control << 8));
463 470 mate->port_init_devs = qd6580_port_init_devs;
464 idx[0] = 0; 471 mate->set_pio_mode = qd6580_set_pio_mode;
465 idx[1] = 1; 472 idx[1] = mate->index;
473 }
466 474
467 ide_device_add(idx, &qd65xx_port_info); 475 ide_device_add(idx, &qd65xx_port_info);
468 476
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
index ef768a84be9e..43ee632a6dae 100644
--- a/drivers/ide/legacy/umc8672.c
+++ b/drivers/ide/legacy/umc8672.c
@@ -128,8 +128,9 @@ static const struct ide_port_info umc8672_port_info __initdata = {
128 128
129static int __init umc8672_probe(void) 129static int __init umc8672_probe(void)
130{ 130{
131 ide_hwif_t *hwif, *mate;
131 unsigned long flags; 132 unsigned long flags;
132 static u8 idx[4] = { 0, 1, 0xff, 0xff }; 133 static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
133 hw_regs_t hw[2]; 134 hw_regs_t hw[2];
134 135
135 if (!request_region(0x108, 2, "umc8672")) { 136 if (!request_region(0x108, 2, "umc8672")) {
@@ -157,11 +158,19 @@ static int __init umc8672_probe(void)
157 ide_std_init_ports(&hw[1], 0x170, 0x376); 158 ide_std_init_ports(&hw[1], 0x170, 0x376);
158 hw[1].irq = 15; 159 hw[1].irq = 15;
159 160
160 ide_init_port_hw(&ide_hwifs[0], &hw[0]); 161 hwif = ide_find_port();
161 ide_init_port_hw(&ide_hwifs[1], &hw[1]); 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 }
162 167
163 ide_hwifs[0].set_pio_mode = &umc_set_pio_mode; 168 mate = ide_find_port();
164 ide_hwifs[1].set_pio_mode = &umc_set_pio_mode; 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 }
165 174
166 ide_device_add(idx, &umc8672_port_info); 175 ide_device_add(idx, &umc8672_port_info);
167 176