diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-02 13:56:40 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-02 13:56:40 -0500 |
commit | 1f2cf8b0014fdfa3141449b508aca25e78c078a7 (patch) | |
tree | 2bbed83a1c7f5fc037cd64c2af108f081aff4c65 | |
parent | 807b90d0be23b8d088d4369b02539dada70f03f4 (diff) |
ide: add ->port_init_devs method to ide_hwif_t
* Add ->port_init_devs method to ide_hwif_t for a host specific
initialization of devices on a port. Call the new method from
ide_port_init_devices().
* Convert ht6560b, qd65xx and opti621 host drivers to use the new
->port_init_devs method.
There should be no functionality changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-probe.c | 3 | ||||
-rw-r--r-- | drivers/ide/legacy/ht6560b.c | 26 | ||||
-rw-r--r-- | drivers/ide/legacy/qd65xx.c | 44 | ||||
-rw-r--r-- | drivers/ide/pci/opti621.c | 10 | ||||
-rw-r--r-- | include/linux/ide.h | 2 |
5 files changed, 59 insertions, 26 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index fee898c4a773..174c81d8793c 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1305,6 +1305,9 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1305 | if ((hwif->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0) | 1305 | if ((hwif->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0) |
1306 | drive->autotune = 1; | 1306 | drive->autotune = 1; |
1307 | } | 1307 | } |
1308 | |||
1309 | if (hwif->port_init_devs) | ||
1310 | hwif->port_init_devs(hwif); | ||
1308 | } | 1311 | } |
1309 | 1312 | ||
1310 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | 1313 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index a89cd80d8124..02d12c74764a 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -300,6 +300,18 @@ static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
300 | #endif | 300 | #endif |
301 | } | 301 | } |
302 | 302 | ||
303 | static void __init ht6560b_port_init_devs(ide_hwif_t *hwif) | ||
304 | { | ||
305 | /* Setting default configurations for drives. */ | ||
306 | int t = (HT_CONFIG_DEFAULT << 8) | HT_TIMING_DEFAULT; | ||
307 | |||
308 | if (hwif->channel) | ||
309 | t |= (HT_SECONDARY_IF << 8); | ||
310 | |||
311 | hwif->drives[0].drive_data = t; | ||
312 | hwif->drives[1].drive_data = t; | ||
313 | } | ||
314 | |||
303 | int probe_ht6560b = 0; | 315 | int probe_ht6560b = 0; |
304 | 316 | ||
305 | module_param_named(probe, probe_ht6560b, bool, 0); | 317 | module_param_named(probe, probe_ht6560b, bool, 0); |
@@ -318,7 +330,6 @@ static int __init ht6560b_init(void) | |||
318 | { | 330 | { |
319 | ide_hwif_t *hwif, *mate; | 331 | ide_hwif_t *hwif, *mate; |
320 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | 332 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; |
321 | int t; | ||
322 | 333 | ||
323 | if (probe_ht6560b == 0) | 334 | if (probe_ht6560b == 0) |
324 | return -ENODEV; | 335 | return -ENODEV; |
@@ -343,17 +354,8 @@ static int __init ht6560b_init(void) | |||
343 | mate->selectproc = &ht6560b_selectproc; | 354 | mate->selectproc = &ht6560b_selectproc; |
344 | mate->set_pio_mode = &ht6560b_set_pio_mode; | 355 | mate->set_pio_mode = &ht6560b_set_pio_mode; |
345 | 356 | ||
346 | /* | 357 | hwif->port_init_devs = ht6560b_port_init_devs; |
347 | * Setting default configurations for drives | 358 | mate->port_init_devs = ht6560b_port_init_devs; |
348 | */ | ||
349 | t = (HT_CONFIG_DEFAULT << 8); | ||
350 | t |= HT_TIMING_DEFAULT; | ||
351 | hwif->drives[0].drive_data = t; | ||
352 | hwif->drives[1].drive_data = t; | ||
353 | |||
354 | t |= (HT_SECONDARY_IF << 8); | ||
355 | mate->drives[0].drive_data = t; | ||
356 | mate->drives[1].drive_data = t; | ||
357 | 359 | ||
358 | ide_device_add(idx, &ht6560b_port_info); | 360 | ide_device_add(idx, &ht6560b_port_info); |
359 | 361 | ||
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 60a6ed1088df..bba29df5f21d 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -305,13 +305,33 @@ static int __init qd_testreg(int port) | |||
305 | * called to setup an ata channel : adjusts attributes & links for tuning | 305 | * called to setup an ata channel : adjusts attributes & links for tuning |
306 | */ | 306 | */ |
307 | 307 | ||
308 | static void __init qd_setup(ide_hwif_t *hwif, int base, int config, | 308 | static void __init qd_setup(ide_hwif_t *hwif, int base, int config) |
309 | unsigned int data0, unsigned int data1) | ||
310 | { | 309 | { |
311 | hwif->select_data = base; | 310 | hwif->select_data = base; |
312 | hwif->config_data = config; | 311 | hwif->config_data = config; |
313 | hwif->drives[0].drive_data = data0; | 312 | } |
314 | hwif->drives[1].drive_data = data1; | 313 | |
314 | static void __init qd6500_port_init_devs(ide_hwif_t *hwif) | ||
315 | { | ||
316 | u8 base = hwif->select_data, config = QD_CONFIG(hwif); | ||
317 | |||
318 | hwif->drives[0].drive_data = QD6500_DEF_DATA; | ||
319 | hwif->drives[1].drive_data = QD6500_DEF_DATA; | ||
320 | } | ||
321 | |||
322 | static void __init qd6580_port_init_devs(ide_hwif_t *hwif) | ||
323 | { | ||
324 | u16 t1, t2; | ||
325 | u8 base = hwif->select_data, config = QD_CONFIG(hwif); | ||
326 | |||
327 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { | ||
328 | t1 = QD6580_DEF_DATA; | ||
329 | t2 = QD6580_DEF_DATA2; | ||
330 | } else | ||
331 | t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA; | ||
332 | |||
333 | hwif->drives[0].drive_data = t1; | ||
334 | hwif->drives[1].drive_data = t2; | ||
315 | } | 335 | } |
316 | 336 | ||
317 | /* | 337 | /* |
@@ -396,8 +416,9 @@ static int __init qd_probe(int base) | |||
396 | return 1; | 416 | return 1; |
397 | } | 417 | } |
398 | 418 | ||
399 | qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA); | 419 | qd_setup(hwif, base, config); |
400 | 420 | ||
421 | hwif->port_init_devs = qd6500_port_init_devs; | ||
401 | hwif->set_pio_mode = &qd6500_set_pio_mode; | 422 | hwif->set_pio_mode = &qd6500_set_pio_mode; |
402 | 423 | ||
403 | idx[unit] = unit; | 424 | idx[unit] = unit; |
@@ -429,9 +450,10 @@ static int __init qd_probe(int base) | |||
429 | hwif = &ide_hwifs[unit]; | 450 | hwif = &ide_hwifs[unit]; |
430 | printk(KERN_INFO "%s: qd6580: single IDE board\n", | 451 | printk(KERN_INFO "%s: qd6580: single IDE board\n", |
431 | hwif->name); | 452 | hwif->name); |
432 | qd_setup(hwif, base, config | (control << 8), | ||
433 | QD6580_DEF_DATA, QD6580_DEF_DATA2); | ||
434 | 453 | ||
454 | qd_setup(hwif, base, config | (control << 8)); | ||
455 | |||
456 | hwif->port_init_devs = qd6580_port_init_devs; | ||
435 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 457 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
436 | 458 | ||
437 | idx[unit] = unit; | 459 | idx[unit] = unit; |
@@ -450,14 +472,14 @@ static int __init qd_probe(int base) | |||
450 | printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", | 472 | printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", |
451 | hwif->name, mate->name); | 473 | hwif->name, mate->name); |
452 | 474 | ||
453 | qd_setup(hwif, base, config | (control << 8), | 475 | qd_setup(hwif, base, config | (control << 8)); |
454 | QD6580_DEF_DATA, QD6580_DEF_DATA); | ||
455 | 476 | ||
477 | hwif->port_init_devs = qd6580_port_init_devs; | ||
456 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 478 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
457 | 479 | ||
458 | qd_setup(mate, base, config | (control << 8), | 480 | qd_setup(mate, base, config | (control << 8)); |
459 | QD6580_DEF_DATA2, QD6580_DEF_DATA2); | ||
460 | 481 | ||
482 | mate->port_init_devs = qd6580_port_init_devs; | ||
461 | mate->set_pio_mode = &qd6580_set_pio_mode; | 483 | mate->set_pio_mode = &qd6580_set_pio_mode; |
462 | 484 | ||
463 | idx[0] = 0; | 485 | idx[0] = 0; |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 1e532c9a97f7..46e8748f507e 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
@@ -315,14 +315,18 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
315 | spin_unlock_irqrestore(&opti621_lock, flags); | 315 | spin_unlock_irqrestore(&opti621_lock, flags); |
316 | } | 316 | } |
317 | 317 | ||
318 | static void __devinit opti621_port_init_devs(ide_hwif_t *hwif) | ||
319 | { | ||
320 | hwif->drives[0].drive_data = PIO_DONT_KNOW; | ||
321 | hwif->drives[1].drive_data = PIO_DONT_KNOW; | ||
322 | } | ||
323 | |||
318 | /* | 324 | /* |
319 | * init_hwif_opti621() is called once for each hwif found at boot. | 325 | * init_hwif_opti621() is called once for each hwif found at boot. |
320 | */ | 326 | */ |
321 | static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) | 327 | static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) |
322 | { | 328 | { |
323 | hwif->drives[0].drive_data = PIO_DONT_KNOW; | 329 | hwif->port_init_devs = opti621_port_init_devs; |
324 | hwif->drives[1].drive_data = PIO_DONT_KNOW; | ||
325 | |||
326 | hwif->set_pio_mode = &opti621_set_pio_mode; | 330 | hwif->set_pio_mode = &opti621_set_pio_mode; |
327 | } | 331 | } |
328 | 332 | ||
diff --git a/include/linux/ide.h b/include/linux/ide.h index 7b24358a6f8a..9f195078ff99 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -514,6 +514,8 @@ typedef struct hwif_s { | |||
514 | #if 0 | 514 | #if 0 |
515 | ide_hwif_ops_t *hwifops; | 515 | ide_hwif_ops_t *hwifops; |
516 | #else | 516 | #else |
517 | /* host specific initialization of devices on a port */ | ||
518 | void (*port_init_devs)(struct hwif_s *); | ||
517 | /* routine to program host for PIO mode */ | 519 | /* routine to program host for PIO mode */ |
518 | void (*set_pio_mode)(ide_drive_t *, const u8); | 520 | void (*set_pio_mode)(ide_drive_t *, const u8); |
519 | /* routine to program host for DMA mode */ | 521 | /* routine to program host for DMA mode */ |