diff options
Diffstat (limited to 'drivers/ata/pata_ali.c')
-rw-r--r-- | drivers/ata/pata_ali.c | 140 |
1 files changed, 85 insertions, 55 deletions
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index 64eed99f6814..c5d61d1911a5 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/dmi.h> | 34 | #include <linux/dmi.h> |
35 | 35 | ||
36 | #define DRV_NAME "pata_ali" | 36 | #define DRV_NAME "pata_ali" |
37 | #define DRV_VERSION "0.6.6" | 37 | #define DRV_VERSION "0.7.2" |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * Cable special cases | 40 | * Cable special cases |
@@ -78,7 +78,7 @@ static int ali_c2_cable_detect(struct ata_port *ap) | |||
78 | implement the detect logic */ | 78 | implement the detect logic */ |
79 | 79 | ||
80 | if (ali_cable_override(pdev)) | 80 | if (ali_cable_override(pdev)) |
81 | return ATA_CBL_PATA80; | 81 | return ATA_CBL_PATA40_SHORT; |
82 | 82 | ||
83 | /* Host view cable detect 0x4A bit 0 primary bit 1 secondary | 83 | /* Host view cable detect 0x4A bit 0 primary bit 1 secondary |
84 | Bit set for 40 pin */ | 84 | Bit set for 40 pin */ |
@@ -337,9 +337,6 @@ static struct scsi_host_template ali_sht = { | |||
337 | .can_queue = ATA_DEF_QUEUE, | 337 | .can_queue = ATA_DEF_QUEUE, |
338 | .this_id = ATA_SHT_THIS_ID, | 338 | .this_id = ATA_SHT_THIS_ID, |
339 | .sg_tablesize = LIBATA_MAX_PRD, | 339 | .sg_tablesize = LIBATA_MAX_PRD, |
340 | /* Keep LBA28 counts so large I/O's don't turn LBA48 and PIO | ||
341 | with older controllers. Not locked so will grow on C5 or later */ | ||
342 | .max_sectors = 255, | ||
343 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 340 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
344 | .emulated = ATA_SHT_EMULATED, | 341 | .emulated = ATA_SHT_EMULATED, |
345 | .use_clustering = ATA_SHT_USE_CLUSTERING, | 342 | .use_clustering = ATA_SHT_USE_CLUSTERING, |
@@ -348,6 +345,8 @@ static struct scsi_host_template ali_sht = { | |||
348 | .slave_configure = ata_scsi_slave_config, | 345 | .slave_configure = ata_scsi_slave_config, |
349 | .slave_destroy = ata_scsi_slave_destroy, | 346 | .slave_destroy = ata_scsi_slave_destroy, |
350 | .bios_param = ata_std_bios_param, | 347 | .bios_param = ata_std_bios_param, |
348 | .resume = ata_scsi_device_resume, | ||
349 | .suspend = ata_scsi_device_suspend, | ||
351 | }; | 350 | }; |
352 | 351 | ||
353 | /* | 352 | /* |
@@ -497,6 +496,69 @@ static struct ata_port_operations ali_c5_port_ops = { | |||
497 | .host_stop = ata_host_stop | 496 | .host_stop = ata_host_stop |
498 | }; | 497 | }; |
499 | 498 | ||
499 | |||
500 | /** | ||
501 | * ali_init_chipset - chip setup function | ||
502 | * @pdev: PCI device of ATA controller | ||
503 | * | ||
504 | * Perform the setup on the device that must be done both at boot | ||
505 | * and at resume time. | ||
506 | */ | ||
507 | |||
508 | static void ali_init_chipset(struct pci_dev *pdev) | ||
509 | { | ||
510 | u8 rev, tmp; | ||
511 | struct pci_dev *north, *isa_bridge; | ||
512 | |||
513 | pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); | ||
514 | |||
515 | /* | ||
516 | * The chipset revision selects the driver operations and | ||
517 | * mode data. | ||
518 | */ | ||
519 | |||
520 | if (rev >= 0x20 && rev < 0xC2) { | ||
521 | /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */ | ||
522 | pci_read_config_byte(pdev, 0x4B, &tmp); | ||
523 | /* Clear CD-ROM DMA write bit */ | ||
524 | tmp &= 0x7F; | ||
525 | pci_write_config_byte(pdev, 0x4B, tmp); | ||
526 | } else if (rev >= 0xC2) { | ||
527 | /* Enable cable detection logic */ | ||
528 | pci_read_config_byte(pdev, 0x4B, &tmp); | ||
529 | pci_write_config_byte(pdev, 0x4B, tmp | 0x08); | ||
530 | } | ||
531 | north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); | ||
532 | isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); | ||
533 | |||
534 | if (north && north->vendor == PCI_VENDOR_ID_AL && isa_bridge) { | ||
535 | /* Configure the ALi bridge logic. For non ALi rely on BIOS. | ||
536 | Set the south bridge enable bit */ | ||
537 | pci_read_config_byte(isa_bridge, 0x79, &tmp); | ||
538 | if (rev == 0xC2) | ||
539 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04); | ||
540 | else if (rev > 0xC2 && rev < 0xC5) | ||
541 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02); | ||
542 | } | ||
543 | if (rev >= 0x20) { | ||
544 | /* | ||
545 | * CD_ROM DMA on (0x53 bit 0). Enable this even if we want | ||
546 | * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control | ||
547 | * via 0x54/55. | ||
548 | */ | ||
549 | pci_read_config_byte(pdev, 0x53, &tmp); | ||
550 | if (rev <= 0x20) | ||
551 | tmp &= ~0x02; | ||
552 | if (rev >= 0xc7) | ||
553 | tmp |= 0x03; | ||
554 | else | ||
555 | tmp |= 0x01; /* CD_ROM enable for DMA */ | ||
556 | pci_write_config_byte(pdev, 0x53, tmp); | ||
557 | } | ||
558 | pci_dev_put(isa_bridge); | ||
559 | pci_dev_put(north); | ||
560 | ata_pci_clear_simplex(pdev); | ||
561 | } | ||
500 | /** | 562 | /** |
501 | * ali_init_one - discovery callback | 563 | * ali_init_one - discovery callback |
502 | * @pdev: PCI device ID | 564 | * @pdev: PCI device ID |
@@ -570,7 +632,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
570 | 632 | ||
571 | static struct ata_port_info *port_info[2]; | 633 | static struct ata_port_info *port_info[2]; |
572 | u8 rev, tmp; | 634 | u8 rev, tmp; |
573 | struct pci_dev *north, *isa_bridge; | 635 | struct pci_dev *isa_bridge; |
574 | 636 | ||
575 | pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); | 637 | pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); |
576 | 638 | ||
@@ -582,11 +644,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
582 | if (rev < 0x20) { | 644 | if (rev < 0x20) { |
583 | port_info[0] = port_info[1] = &info_early; | 645 | port_info[0] = port_info[1] = &info_early; |
584 | } else if (rev < 0xC2) { | 646 | } else if (rev < 0xC2) { |
585 | /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */ | ||
586 | pci_read_config_byte(pdev, 0x4B, &tmp); | ||
587 | /* Clear CD-ROM DMA write bit */ | ||
588 | tmp &= 0x7F; | ||
589 | pci_write_config_byte(pdev, 0x4B, tmp); | ||
590 | port_info[0] = port_info[1] = &info_20; | 647 | port_info[0] = port_info[1] = &info_20; |
591 | } else if (rev == 0xC2) { | 648 | } else if (rev == 0xC2) { |
592 | port_info[0] = port_info[1] = &info_c2; | 649 | port_info[0] = port_info[1] = &info_c2; |
@@ -597,54 +654,25 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
597 | } else | 654 | } else |
598 | port_info[0] = port_info[1] = &info_c5; | 655 | port_info[0] = port_info[1] = &info_c5; |
599 | 656 | ||
600 | if (rev >= 0xC2) { | 657 | ali_init_chipset(pdev); |
601 | /* Enable cable detection logic */ | 658 | |
602 | pci_read_config_byte(pdev, 0x4B, &tmp); | ||
603 | pci_write_config_byte(pdev, 0x4B, tmp | 0x08); | ||
604 | } | ||
605 | |||
606 | north = pci_get_slot(pdev->bus, PCI_DEVFN(0,0)); | ||
607 | isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); | 659 | isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); |
608 | 660 | if (isa_bridge && rev >= 0x20 && rev < 0xC2) { | |
609 | if (north && north->vendor == PCI_VENDOR_ID_AL) { | 661 | /* Are we paired with a UDMA capable chip */ |
610 | /* Configure the ALi bridge logic. For non ALi rely on BIOS. | 662 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); |
611 | Set the south bridge enable bit */ | 663 | if ((tmp & 0x1E) == 0x12) |
612 | pci_read_config_byte(isa_bridge, 0x79, &tmp); | 664 | port_info[0] = port_info[1] = &info_20_udma; |
613 | if (rev == 0xC2) | 665 | pci_dev_put(isa_bridge); |
614 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04); | ||
615 | else if (rev > 0xC2) | ||
616 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02); | ||
617 | } | ||
618 | |||
619 | if (rev >= 0x20) { | ||
620 | if (rev < 0xC2) { | ||
621 | /* Are we paired with a UDMA capable chip */ | ||
622 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); | ||
623 | if ((tmp & 0x1E) == 0x12) | ||
624 | port_info[0] = port_info[1] = &info_20_udma; | ||
625 | } | ||
626 | /* | ||
627 | * CD_ROM DMA on (0x53 bit 0). Enable this even if we want | ||
628 | * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control | ||
629 | * via 0x54/55. | ||
630 | */ | ||
631 | pci_read_config_byte(pdev, 0x53, &tmp); | ||
632 | if (rev <= 0x20) | ||
633 | tmp &= ~0x02; | ||
634 | if (rev >= 0xc7) | ||
635 | tmp |= 0x03; | ||
636 | else | ||
637 | tmp |= 0x01; /* CD_ROM enable for DMA */ | ||
638 | pci_write_config_byte(pdev, 0x53, tmp); | ||
639 | } | 666 | } |
640 | |||
641 | pci_dev_put(isa_bridge); | ||
642 | pci_dev_put(north); | ||
643 | |||
644 | ata_pci_clear_simplex(pdev); | ||
645 | return ata_pci_init_one(pdev, port_info, 2); | 667 | return ata_pci_init_one(pdev, port_info, 2); |
646 | } | 668 | } |
647 | 669 | ||
670 | static int ali_reinit_one(struct pci_dev *pdev) | ||
671 | { | ||
672 | ali_init_chipset(pdev); | ||
673 | return ata_pci_device_resume(pdev); | ||
674 | } | ||
675 | |||
648 | static const struct pci_device_id ali[] = { | 676 | static const struct pci_device_id ali[] = { |
649 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), }, | 677 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), }, |
650 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), }, | 678 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), }, |
@@ -656,7 +684,9 @@ static struct pci_driver ali_pci_driver = { | |||
656 | .name = DRV_NAME, | 684 | .name = DRV_NAME, |
657 | .id_table = ali, | 685 | .id_table = ali, |
658 | .probe = ali_init_one, | 686 | .probe = ali_init_one, |
659 | .remove = ata_pci_remove_one | 687 | .remove = ata_pci_remove_one, |
688 | .suspend = ata_pci_device_suspend, | ||
689 | .resume = ali_reinit_one, | ||
660 | }; | 690 | }; |
661 | 691 | ||
662 | static int __init ali_init(void) | 692 | static int __init ali_init(void) |