aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2011-10-11 14:13:53 -0400
committerJeff Garzik <jgarzik@redhat.com>2011-10-14 13:16:35 -0400
commitd912be2f3b335353ee442262e010a225c94e6ef4 (patch)
tree09509b47f05075febaf148aa5f19c93bde44906d /drivers/ata
parente69a70d951787013e5fe65e843edd5711571546c (diff)
pata_serverworks: add serverworks_fixup()
Factor out common code from serverworks_[re]init_one() to serverworks_fixup(). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/pata_serverworks.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index 27d9802fb974..71eaf385e970 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -349,6 +349,31 @@ static void serverworks_fixup_ht1000(struct pci_dev *pdev)
349 pci_write_config_byte(pdev, 0x5A, btr); 349 pci_write_config_byte(pdev, 0x5A, btr);
350} 350}
351 351
352static int serverworks_fixup(struct pci_dev *pdev)
353{
354 int rc = 0;
355
356 /* Force master latency timer to 64 PCI clocks */
357 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
358
359 switch (pdev->device) {
360 case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
361 rc = serverworks_fixup_osb4(pdev);
362 break;
363 case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
364 ata_pci_bmdma_clear_simplex(pdev);
365 /* fall through */
366 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
367 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
368 rc = serverworks_fixup_csb(pdev);
369 break;
370 case PCI_DEVICE_ID_SERVERWORKS_HT1000IDE:
371 serverworks_fixup_ht1000(pdev);
372 break;
373 }
374
375 return rc;
376}
352 377
353static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 378static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
354{ 379{
@@ -386,13 +411,12 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
386 if (rc) 411 if (rc)
387 return rc; 412 return rc;
388 413
389 /* Force master latency timer to 64 PCI clocks */ 414 rc = serverworks_fixup(pdev);
390 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
391 415
392 /* OSB4 : South Bridge and IDE */ 416 /* OSB4 : South Bridge and IDE */
393 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { 417 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
394 /* Select non UDMA capable OSB4 if we can't do fixups */ 418 /* Select non UDMA capable OSB4 if we can't do fixups */
395 if ( serverworks_fixup_osb4(pdev) < 0) 419 if (rc < 0)
396 ppi[0] = &info[1]; 420 ppi[0] = &info[1];
397 } 421 }
398 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ 422 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */
@@ -402,19 +426,13 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
402 426
403 /* If the returned btr is the newer revision then 427 /* If the returned btr is the newer revision then
404 select the right info block */ 428 select the right info block */
405 if (serverworks_fixup_csb(pdev) == 3) 429 if (rc == 3)
406 ppi[0] = &info[3]; 430 ppi[0] = &info[3];
407 431
408 /* Is this the 3rd channel CSB6 IDE ? */ 432 /* Is this the 3rd channel CSB6 IDE ? */
409 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) 433 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)
410 ppi[1] = &ata_dummy_port_info; 434 ppi[1] = &ata_dummy_port_info;
411 } 435 }
412 /* setup HT1000E */
413 else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE)
414 serverworks_fixup_ht1000(pdev);
415
416 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
417 ata_pci_bmdma_clear_simplex(pdev);
418 436
419 return ata_pci_bmdma_init_one(pdev, ppi, &serverworks_sht, NULL, 0); 437 return ata_pci_bmdma_init_one(pdev, ppi, &serverworks_sht, NULL, 0);
420} 438}
@@ -429,24 +447,7 @@ static int serverworks_reinit_one(struct pci_dev *pdev)
429 if (rc) 447 if (rc)
430 return rc; 448 return rc;
431 449
432 /* Force master latency timer to 64 PCI clocks */ 450 (void)serverworks_fixup(pdev);
433 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
434
435 switch (pdev->device) {
436 case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
437 serverworks_fixup_osb4(pdev);
438 break;
439 case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
440 ata_pci_bmdma_clear_simplex(pdev);
441 /* fall through */
442 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
443 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
444 serverworks_fixup_csb(pdev);
445 break;
446 case PCI_DEVICE_ID_SERVERWORKS_HT1000IDE:
447 serverworks_fixup_ht1000(pdev);
448 break;
449 }
450 451
451 ata_host_resume(host); 452 ata_host_resume(host);
452 return 0; 453 return 0;