aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_hpt37x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_hpt37x.c')
-rw-r--r--drivers/ata/pata_hpt37x.c245
1 files changed, 52 insertions, 193 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 9a10878b2ad8..42163998de9a 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -283,7 +283,7 @@ static unsigned long hpt370_filter(struct ata_device *adev, unsigned long mask)
283 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) 283 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
284 mask &= ~(0xE0 << ATA_SHIFT_UDMA); 284 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
285 } 285 }
286 return ata_pci_default_filter(adev, mask); 286 return ata_bmdma_mode_filter(adev, mask);
287} 287}
288 288
289/** 289/**
@@ -299,7 +299,7 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
299 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) 299 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
300 mask &= ~(0xE0 << ATA_SHIFT_UDMA); 300 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
301 } 301 }
302 return ata_pci_default_filter(adev, mask); 302 return ata_bmdma_mode_filter(adev, mask);
303} 303}
304 304
305/** 305/**
@@ -338,22 +338,10 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline)
338 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 338 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
339 udelay(100); 339 udelay(100);
340 340
341 return ata_std_prereset(link, deadline); 341 return ata_sff_prereset(link, deadline);
342} 342}
343 343
344/** 344static int hpt374_fn1_pre_reset(struct ata_link *link, unsigned long deadline)
345 * hpt37x_error_handler - reset the hpt374
346 * @ap: ATA port to reset
347 *
348 * Perform probe for HPT37x, except for HPT374 channel 2
349 */
350
351static void hpt37x_error_handler(struct ata_port *ap)
352{
353 ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
354}
355
356static int hpt374_pre_reset(struct ata_link *link, unsigned long deadline)
357{ 345{
358 static const struct pci_bits hpt37x_enable_bits[] = { 346 static const struct pci_bits hpt37x_enable_bits[] = {
359 { 0x50, 1, 0x04, 0x04 }, 347 { 0x50, 1, 0x04, 0x04 },
@@ -386,26 +374,7 @@ static int hpt374_pre_reset(struct ata_link *link, unsigned long deadline)
386 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 374 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
387 udelay(100); 375 udelay(100);
388 376
389 return ata_std_prereset(link, deadline); 377 return ata_sff_prereset(link, deadline);
390}
391
392/**
393 * hpt374_error_handler - reset the hpt374
394 * @classes:
395 *
396 * The 374 cable detect is a little different due to the extra
397 * channels. The function 0 channels work like usual but function 1
398 * is special
399 */
400
401static void hpt374_error_handler(struct ata_port *ap)
402{
403 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
404
405 if (!(PCI_FUNC(pdev->devfn) & 1))
406 hpt37x_error_handler(ap);
407 else
408 ata_bmdma_drive_eh(ap, hpt374_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
409} 378}
410 379
411/** 380/**
@@ -619,21 +588,7 @@ static void hpt37x_bmdma_stop(struct ata_queued_cmd *qc)
619 588
620 589
621static struct scsi_host_template hpt37x_sht = { 590static struct scsi_host_template hpt37x_sht = {
622 .module = THIS_MODULE, 591 ATA_BMDMA_SHT(DRV_NAME),
623 .name = DRV_NAME,
624 .ioctl = ata_scsi_ioctl,
625 .queuecommand = ata_scsi_queuecmd,
626 .can_queue = ATA_DEF_QUEUE,
627 .this_id = ATA_SHT_THIS_ID,
628 .sg_tablesize = LIBATA_MAX_PRD,
629 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
630 .emulated = ATA_SHT_EMULATED,
631 .use_clustering = ATA_SHT_USE_CLUSTERING,
632 .proc_name = DRV_NAME,
633 .dma_boundary = ATA_DMA_BOUNDARY,
634 .slave_configure = ata_scsi_slave_config,
635 .slave_destroy = ata_scsi_slave_destroy,
636 .bios_param = ata_std_bios_param,
637}; 592};
638 593
639/* 594/*
@@ -641,36 +596,15 @@ static struct scsi_host_template hpt37x_sht = {
641 */ 596 */
642 597
643static struct ata_port_operations hpt370_port_ops = { 598static struct ata_port_operations hpt370_port_ops = {
644 .set_piomode = hpt370_set_piomode, 599 .inherits = &ata_bmdma_port_ops,
645 .set_dmamode = hpt370_set_dmamode,
646 .mode_filter = hpt370_filter,
647
648 .tf_load = ata_tf_load,
649 .tf_read = ata_tf_read,
650 .check_status = ata_check_status,
651 .exec_command = ata_exec_command,
652 .dev_select = ata_std_dev_select,
653 600
654 .freeze = ata_bmdma_freeze,
655 .thaw = ata_bmdma_thaw,
656 .error_handler = hpt37x_error_handler,
657 .post_internal_cmd = ata_bmdma_post_internal_cmd,
658
659 .bmdma_setup = ata_bmdma_setup,
660 .bmdma_start = hpt370_bmdma_start, 601 .bmdma_start = hpt370_bmdma_start,
661 .bmdma_stop = hpt370_bmdma_stop, 602 .bmdma_stop = hpt370_bmdma_stop,
662 .bmdma_status = ata_bmdma_status,
663
664 .qc_prep = ata_qc_prep,
665 .qc_issue = ata_qc_issue_prot,
666
667 .data_xfer = ata_data_xfer,
668
669 .irq_handler = ata_interrupt,
670 .irq_clear = ata_bmdma_irq_clear,
671 .irq_on = ata_irq_on,
672 603
673 .port_start = ata_sff_port_start, 604 .mode_filter = hpt370_filter,
605 .set_piomode = hpt370_set_piomode,
606 .set_dmamode = hpt370_set_dmamode,
607 .prereset = hpt37x_pre_reset,
674}; 608};
675 609
676/* 610/*
@@ -678,36 +612,8 @@ static struct ata_port_operations hpt370_port_ops = {
678 */ 612 */
679 613
680static struct ata_port_operations hpt370a_port_ops = { 614static struct ata_port_operations hpt370a_port_ops = {
681 .set_piomode = hpt370_set_piomode, 615 .inherits = &hpt370_port_ops,
682 .set_dmamode = hpt370_set_dmamode,
683 .mode_filter = hpt370a_filter, 616 .mode_filter = hpt370a_filter,
684
685 .tf_load = ata_tf_load,
686 .tf_read = ata_tf_read,
687 .check_status = ata_check_status,
688 .exec_command = ata_exec_command,
689 .dev_select = ata_std_dev_select,
690
691 .freeze = ata_bmdma_freeze,
692 .thaw = ata_bmdma_thaw,
693 .error_handler = hpt37x_error_handler,
694 .post_internal_cmd = ata_bmdma_post_internal_cmd,
695
696 .bmdma_setup = ata_bmdma_setup,
697 .bmdma_start = hpt370_bmdma_start,
698 .bmdma_stop = hpt370_bmdma_stop,
699 .bmdma_status = ata_bmdma_status,
700
701 .qc_prep = ata_qc_prep,
702 .qc_issue = ata_qc_issue_prot,
703
704 .data_xfer = ata_data_xfer,
705
706 .irq_handler = ata_interrupt,
707 .irq_clear = ata_bmdma_irq_clear,
708 .irq_on = ata_irq_on,
709
710 .port_start = ata_sff_port_start,
711}; 617};
712 618
713/* 619/*
@@ -716,74 +622,23 @@ static struct ata_port_operations hpt370a_port_ops = {
716 */ 622 */
717 623
718static struct ata_port_operations hpt372_port_ops = { 624static struct ata_port_operations hpt372_port_ops = {
719 .set_piomode = hpt372_set_piomode, 625 .inherits = &ata_bmdma_port_ops,
720 .set_dmamode = hpt372_set_dmamode,
721 .mode_filter = ata_pci_default_filter,
722
723 .tf_load = ata_tf_load,
724 .tf_read = ata_tf_read,
725 .check_status = ata_check_status,
726 .exec_command = ata_exec_command,
727 .dev_select = ata_std_dev_select,
728 626
729 .freeze = ata_bmdma_freeze,
730 .thaw = ata_bmdma_thaw,
731 .error_handler = hpt37x_error_handler,
732 .post_internal_cmd = ata_bmdma_post_internal_cmd,
733
734 .bmdma_setup = ata_bmdma_setup,
735 .bmdma_start = ata_bmdma_start,
736 .bmdma_stop = hpt37x_bmdma_stop, 627 .bmdma_stop = hpt37x_bmdma_stop,
737 .bmdma_status = ata_bmdma_status,
738
739 .qc_prep = ata_qc_prep,
740 .qc_issue = ata_qc_issue_prot,
741
742 .data_xfer = ata_data_xfer,
743
744 .irq_handler = ata_interrupt,
745 .irq_clear = ata_bmdma_irq_clear,
746 .irq_on = ata_irq_on,
747 628
748 .port_start = ata_sff_port_start, 629 .set_piomode = hpt372_set_piomode,
630 .set_dmamode = hpt372_set_dmamode,
631 .prereset = hpt37x_pre_reset,
749}; 632};
750 633
751/* 634/*
752 * Configuration for HPT374. Mode setting works like 372 and friends 635 * Configuration for HPT374. Mode setting works like 372 and friends
753 * but we have a different cable detection procedure. 636 * but we have a different cable detection procedure for function 1.
754 */ 637 */
755 638
756static struct ata_port_operations hpt374_port_ops = { 639static struct ata_port_operations hpt374_fn1_port_ops = {
757 .set_piomode = hpt372_set_piomode, 640 .inherits = &hpt372_port_ops,
758 .set_dmamode = hpt372_set_dmamode, 641 .prereset = hpt374_fn1_pre_reset,
759 .mode_filter = ata_pci_default_filter,
760
761 .tf_load = ata_tf_load,
762 .tf_read = ata_tf_read,
763 .check_status = ata_check_status,
764 .exec_command = ata_exec_command,
765 .dev_select = ata_std_dev_select,
766
767 .freeze = ata_bmdma_freeze,
768 .thaw = ata_bmdma_thaw,
769 .error_handler = hpt374_error_handler,
770 .post_internal_cmd = ata_bmdma_post_internal_cmd,
771
772 .bmdma_setup = ata_bmdma_setup,
773 .bmdma_start = ata_bmdma_start,
774 .bmdma_stop = hpt37x_bmdma_stop,
775 .bmdma_status = ata_bmdma_status,
776
777 .qc_prep = ata_qc_prep,
778 .qc_issue = ata_qc_issue_prot,
779
780 .data_xfer = ata_data_xfer,
781
782 .irq_handler = ata_interrupt,
783 .irq_clear = ata_bmdma_irq_clear,
784 .irq_on = ata_irq_on,
785
786 .port_start = ata_sff_port_start,
787}; 642};
788 643
789/** 644/**
@@ -897,7 +752,6 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
897{ 752{
898 /* HPT370 - UDMA100 */ 753 /* HPT370 - UDMA100 */
899 static const struct ata_port_info info_hpt370 = { 754 static const struct ata_port_info info_hpt370 = {
900 .sht = &hpt37x_sht,
901 .flags = ATA_FLAG_SLAVE_POSS, 755 .flags = ATA_FLAG_SLAVE_POSS,
902 .pio_mask = 0x1f, 756 .pio_mask = 0x1f,
903 .mwdma_mask = 0x07, 757 .mwdma_mask = 0x07,
@@ -906,7 +760,6 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
906 }; 760 };
907 /* HPT370A - UDMA100 */ 761 /* HPT370A - UDMA100 */
908 static const struct ata_port_info info_hpt370a = { 762 static const struct ata_port_info info_hpt370a = {
909 .sht = &hpt37x_sht,
910 .flags = ATA_FLAG_SLAVE_POSS, 763 .flags = ATA_FLAG_SLAVE_POSS,
911 .pio_mask = 0x1f, 764 .pio_mask = 0x1f,
912 .mwdma_mask = 0x07, 765 .mwdma_mask = 0x07,
@@ -915,7 +768,6 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
915 }; 768 };
916 /* HPT370 - UDMA100 */ 769 /* HPT370 - UDMA100 */
917 static const struct ata_port_info info_hpt370_33 = { 770 static const struct ata_port_info info_hpt370_33 = {
918 .sht = &hpt37x_sht,
919 .flags = ATA_FLAG_SLAVE_POSS, 771 .flags = ATA_FLAG_SLAVE_POSS,
920 .pio_mask = 0x1f, 772 .pio_mask = 0x1f,
921 .mwdma_mask = 0x07, 773 .mwdma_mask = 0x07,
@@ -924,7 +776,6 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
924 }; 776 };
925 /* HPT370A - UDMA100 */ 777 /* HPT370A - UDMA100 */
926 static const struct ata_port_info info_hpt370a_33 = { 778 static const struct ata_port_info info_hpt370a_33 = {
927 .sht = &hpt37x_sht,
928 .flags = ATA_FLAG_SLAVE_POSS, 779 .flags = ATA_FLAG_SLAVE_POSS,
929 .pio_mask = 0x1f, 780 .pio_mask = 0x1f,
930 .mwdma_mask = 0x07, 781 .mwdma_mask = 0x07,
@@ -933,28 +784,31 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
933 }; 784 };
934 /* HPT371, 372 and friends - UDMA133 */ 785 /* HPT371, 372 and friends - UDMA133 */
935 static const struct ata_port_info info_hpt372 = { 786 static const struct ata_port_info info_hpt372 = {
936 .sht = &hpt37x_sht,
937 .flags = ATA_FLAG_SLAVE_POSS, 787 .flags = ATA_FLAG_SLAVE_POSS,
938 .pio_mask = 0x1f, 788 .pio_mask = 0x1f,
939 .mwdma_mask = 0x07, 789 .mwdma_mask = 0x07,
940 .udma_mask = ATA_UDMA6, 790 .udma_mask = ATA_UDMA6,
941 .port_ops = &hpt372_port_ops 791 .port_ops = &hpt372_port_ops
942 }; 792 };
943 /* HPT374 - UDMA100 */ 793 /* HPT374 - UDMA100, function 1 uses different prereset method */
944 static const struct ata_port_info info_hpt374 = { 794 static const struct ata_port_info info_hpt374_fn0 = {
945 .sht = &hpt37x_sht,
946 .flags = ATA_FLAG_SLAVE_POSS, 795 .flags = ATA_FLAG_SLAVE_POSS,
947 .pio_mask = 0x1f, 796 .pio_mask = 0x1f,
948 .mwdma_mask = 0x07, 797 .mwdma_mask = 0x07,
949 .udma_mask = ATA_UDMA5, 798 .udma_mask = ATA_UDMA5,
950 .port_ops = &hpt374_port_ops 799 .port_ops = &hpt372_port_ops
800 };
801 static const struct ata_port_info info_hpt374_fn1 = {
802 .flags = ATA_FLAG_SLAVE_POSS,
803 .pio_mask = 0x1f,
804 .mwdma_mask = 0x07,
805 .udma_mask = ATA_UDMA5,
806 .port_ops = &hpt374_fn1_port_ops
951 }; 807 };
952 808
953 static const int MHz[4] = { 33, 40, 50, 66 }; 809 static const int MHz[4] = { 33, 40, 50, 66 };
954 const struct ata_port_info *port;
955 void *private_data = NULL; 810 void *private_data = NULL;
956 struct ata_port_info port_info; 811 const struct ata_port_info *ppi[] = { NULL, NULL };
957 const struct ata_port_info *ppi[] = { &port_info, NULL };
958 812
959 u8 irqmask; 813 u8 irqmask;
960 u32 class_rev; 814 u32 class_rev;
@@ -966,6 +820,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
966 820
967 const struct hpt_chip *chip_table; 821 const struct hpt_chip *chip_table;
968 int clock_slot; 822 int clock_slot;
823 int rc;
824
825 rc = pcim_enable_device(dev);
826 if (rc)
827 return rc;
969 828
970 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 829 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
971 class_rev &= 0xFF; 830 class_rev &= 0xFF;
@@ -981,17 +840,17 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
981 840
982 switch(class_rev) { 841 switch(class_rev) {
983 case 3: 842 case 3:
984 port = &info_hpt370; 843 ppi[0] = &info_hpt370;
985 chip_table = &hpt370; 844 chip_table = &hpt370;
986 prefer_dpll = 0; 845 prefer_dpll = 0;
987 break; 846 break;
988 case 4: 847 case 4:
989 port = &info_hpt370a; 848 ppi[0] = &info_hpt370a;
990 chip_table = &hpt370a; 849 chip_table = &hpt370a;
991 prefer_dpll = 0; 850 prefer_dpll = 0;
992 break; 851 break;
993 case 5: 852 case 5:
994 port = &info_hpt372; 853 ppi[0] = &info_hpt372;
995 chip_table = &hpt372; 854 chip_table = &hpt372;
996 break; 855 break;
997 default: 856 default:
@@ -1004,21 +863,21 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1004 /* 372N if rev >= 2*/ 863 /* 372N if rev >= 2*/
1005 if (class_rev >= 2) 864 if (class_rev >= 2)
1006 return -ENODEV; 865 return -ENODEV;
1007 port = &info_hpt372; 866 ppi[0] = &info_hpt372;
1008 chip_table = &hpt372a; 867 chip_table = &hpt372a;
1009 break; 868 break;
1010 case PCI_DEVICE_ID_TTI_HPT302: 869 case PCI_DEVICE_ID_TTI_HPT302:
1011 /* 302N if rev > 1 */ 870 /* 302N if rev > 1 */
1012 if (class_rev > 1) 871 if (class_rev > 1)
1013 return -ENODEV; 872 return -ENODEV;
1014 port = &info_hpt372; 873 ppi[0] = &info_hpt372;
1015 /* Check this */ 874 /* Check this */
1016 chip_table = &hpt302; 875 chip_table = &hpt302;
1017 break; 876 break;
1018 case PCI_DEVICE_ID_TTI_HPT371: 877 case PCI_DEVICE_ID_TTI_HPT371:
1019 if (class_rev > 1) 878 if (class_rev > 1)
1020 return -ENODEV; 879 return -ENODEV;
1021 port = &info_hpt372; 880 ppi[0] = &info_hpt372;
1022 chip_table = &hpt371; 881 chip_table = &hpt371;
1023 /* Single channel device, master is not present 882 /* Single channel device, master is not present
1024 but the BIOS (or us for non x86) must mark it 883 but the BIOS (or us for non x86) must mark it
@@ -1029,7 +888,10 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1029 break; 888 break;
1030 case PCI_DEVICE_ID_TTI_HPT374: 889 case PCI_DEVICE_ID_TTI_HPT374:
1031 chip_table = &hpt374; 890 chip_table = &hpt374;
1032 port = &info_hpt374; 891 if (!(PCI_FUNC(dev->devfn) & 1))
892 *ppi = &info_hpt374_fn0;
893 else
894 *ppi = &info_hpt374_fn1;
1033 break; 895 break;
1034 default: 896 default:
1035 printk(KERN_ERR "pata_hpt37x: PCI table is bogus please report (%d).\n", dev->device); 897 printk(KERN_ERR "pata_hpt37x: PCI table is bogus please report (%d).\n", dev->device);
@@ -1108,7 +970,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1108 int dpll, adjust; 970 int dpll, adjust;
1109 971
1110 /* Compute DPLL */ 972 /* Compute DPLL */
1111 dpll = (port->udma_mask & 0xC0) ? 3 : 2; 973 dpll = (ppi[0]->udma_mask & 0xC0) ? 3 : 2;
1112 974
1113 f_low = (MHz[clock_slot] * 48) / MHz[dpll]; 975 f_low = (MHz[clock_slot] * 48) / MHz[dpll];
1114 f_high = f_low + 2; 976 f_high = f_low + 2;
@@ -1148,19 +1010,16 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1148 * about lack of UDMA133 support on lower clocks 1010 * about lack of UDMA133 support on lower clocks
1149 */ 1011 */
1150 1012
1151 if (clock_slot < 2 && port == &info_hpt370) 1013 if (clock_slot < 2 && ppi[0] == &info_hpt370)
1152 port = &info_hpt370_33; 1014 ppi[0] = &info_hpt370_33;
1153 if (clock_slot < 2 && port == &info_hpt370a) 1015 if (clock_slot < 2 && ppi[0] == &info_hpt370a)
1154 port = &info_hpt370a_33; 1016 ppi[0] = &info_hpt370a_33;
1155 printk(KERN_INFO "pata_hpt37x: %s using %dMHz bus clock.\n", 1017 printk(KERN_INFO "pata_hpt37x: %s using %dMHz bus clock.\n",
1156 chip_table->name, MHz[clock_slot]); 1018 chip_table->name, MHz[clock_slot]);
1157 } 1019 }
1158 1020
1159 /* Now kick off ATA set up */ 1021 /* Now kick off ATA set up */
1160 port_info = *port; 1022 return ata_pci_sff_init_one(dev, ppi, &hpt37x_sht, private_data);
1161 port_info.private_data = private_data;
1162
1163 return ata_pci_init_one(dev, ppi);
1164} 1023}
1165 1024
1166static const struct pci_device_id hpt37x[] = { 1025static const struct pci_device_id hpt37x[] = {