aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/pata_hpt37x.c182
1 files changed, 101 insertions, 81 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 9c62951c3e26..9e2c98449055 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -24,7 +24,7 @@
24#include <linux/libata.h> 24#include <linux/libata.h>
25 25
26#define DRV_NAME "pata_hpt37x" 26#define DRV_NAME "pata_hpt37x"
27#define DRV_VERSION "0.6.16" 27#define DRV_VERSION "0.6.17"
28 28
29struct hpt_clock { 29struct hpt_clock {
30 u8 xfer_speed; 30 u8 xfer_speed;
@@ -210,7 +210,7 @@ static u32 hpt37x_find_mode(struct ata_port *ap, int speed)
210{ 210{
211 struct hpt_clock *clocks = ap->host->private_data; 211 struct hpt_clock *clocks = ap->host->private_data;
212 212
213 while(clocks->xfer_speed) { 213 while (clocks->xfer_speed) {
214 if (clocks->xfer_speed == speed) 214 if (clocks->xfer_speed == speed)
215 return clocks->timing; 215 return clocks->timing;
216 clocks++; 216 clocks++;
@@ -219,7 +219,8 @@ static u32 hpt37x_find_mode(struct ata_port *ap, int speed)
219 return 0xffffffffU; /* silence compiler warning */ 219 return 0xffffffffU; /* silence compiler warning */
220} 220}
221 221
222static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[]) 222static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
223 const char * const list[])
223{ 224{
224 unsigned char model_num[ATA_ID_PROD_LEN + 1]; 225 unsigned char model_num[ATA_ID_PROD_LEN + 1];
225 int i = 0; 226 int i = 0;
@@ -237,18 +238,23 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, cons
237 return 0; 238 return 0;
238} 239}
239 240
240static const char *bad_ata33[] = { 241static const char * const bad_ata33[] = {
241 "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2", 242 "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3",
242 "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2", 243 "Maxtor 90845U3", "Maxtor 90650U2",
243 "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4", 244 "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5",
245 "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2",
246 "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6",
247 "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4",
244 "Maxtor 90510D4", 248 "Maxtor 90510D4",
245 "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2", 249 "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2",
246 "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4", 250 "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7",
247 "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2", 251 "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4",
252 "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5",
253 "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2",
248 NULL 254 NULL
249}; 255};
250 256
251static const char *bad_ata100_5[] = { 257static const char * const bad_ata100_5[] = {
252 "IBM-DTLA-307075", 258 "IBM-DTLA-307075",
253 "IBM-DTLA-307060", 259 "IBM-DTLA-307060",
254 "IBM-DTLA-307045", 260 "IBM-DTLA-307045",
@@ -389,6 +395,7 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline)
389 { 0x50, 1, 0x04, 0x04 }, 395 { 0x50, 1, 0x04, 0x04 },
390 { 0x54, 1, 0x04, 0x04 } 396 { 0x54, 1, 0x04, 0x04 }
391 }; 397 };
398
392 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) 399 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
393 return -ENOENT; 400 return -ENOENT;
394 401
@@ -673,12 +680,12 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
673 u32 reg5c; 680 u32 reg5c;
674 int tries; 681 int tries;
675 682
676 for(tries = 0; tries < 0x5000; tries++) { 683 for (tries = 0; tries < 0x5000; tries++) {
677 udelay(50); 684 udelay(50);
678 pci_read_config_byte(dev, 0x5b, &reg5b); 685 pci_read_config_byte(dev, 0x5b, &reg5b);
679 if (reg5b & 0x80) { 686 if (reg5b & 0x80) {
680 /* See if it stays set */ 687 /* See if it stays set */
681 for(tries = 0; tries < 0x1000; tries ++) { 688 for (tries = 0; tries < 0x1000; tries++) {
682 pci_read_config_byte(dev, 0x5b, &reg5b); 689 pci_read_config_byte(dev, 0x5b, &reg5b);
683 /* Failed ? */ 690 /* Failed ? */
684 if ((reg5b & 0x80) == 0) 691 if ((reg5b & 0x80) == 0)
@@ -686,7 +693,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
686 } 693 }
687 /* Turn off tuning, we have the DPLL set */ 694 /* Turn off tuning, we have the DPLL set */
688 pci_read_config_dword(dev, 0x5c, &reg5c); 695 pci_read_config_dword(dev, 0x5c, &reg5c);
689 pci_write_config_dword(dev, 0x5c, reg5c & ~ 0x100); 696 pci_write_config_dword(dev, 0x5c, reg5c & ~0x100);
690 return 1; 697 return 1;
691 } 698 }
692 } 699 }
@@ -698,6 +705,7 @@ static u32 hpt374_read_freq(struct pci_dev *pdev)
698{ 705{
699 u32 freq; 706 u32 freq;
700 unsigned long io_base = pci_resource_start(pdev, 4); 707 unsigned long io_base = pci_resource_start(pdev, 4);
708
701 if (PCI_FUNC(pdev->devfn) & 1) { 709 if (PCI_FUNC(pdev->devfn) & 1) {
702 struct pci_dev *pdev_0; 710 struct pci_dev *pdev_0;
703 711
@@ -839,64 +847,68 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
839 if (rev == 6) 847 if (rev == 6)
840 return -ENODEV; 848 return -ENODEV;
841 849
842 switch(rev) { 850 switch (rev) {
843 case 3: 851 case 3:
844 ppi[0] = &info_hpt370; 852 ppi[0] = &info_hpt370;
845 chip_table = &hpt370; 853 chip_table = &hpt370;
846 prefer_dpll = 0; 854 prefer_dpll = 0;
847 break; 855 break;
848 case 4: 856 case 4:
849 ppi[0] = &info_hpt370a; 857 ppi[0] = &info_hpt370a;
850 chip_table = &hpt370a; 858 chip_table = &hpt370a;
851 prefer_dpll = 0; 859 prefer_dpll = 0;
852 break; 860 break;
853 case 5: 861 case 5:
854 ppi[0] = &info_hpt372; 862 ppi[0] = &info_hpt372;
855 chip_table = &hpt372; 863 chip_table = &hpt372;
856 break; 864 break;
857 default: 865 default:
858 printk(KERN_ERR "pata_hpt37x: Unknown HPT366 " 866 printk(KERN_ERR "pata_hpt37x: Unknown HPT366 subtype, "
859 "subtype, please report (%d).\n", rev); 867 "please report (%d).\n", rev);
860 return -ENODEV; 868 return -ENODEV;
861 } 869 }
862 } else { 870 } else {
863 switch(dev->device) { 871 switch (dev->device) {
864 case PCI_DEVICE_ID_TTI_HPT372: 872 case PCI_DEVICE_ID_TTI_HPT372:
865 /* 372N if rev >= 2 */ 873 /* 372N if rev >= 2 */
866 if (rev >= 2) 874 if (rev >= 2)
867 return -ENODEV; 875 return -ENODEV;
868 ppi[0] = &info_hpt372; 876 ppi[0] = &info_hpt372;
869 chip_table = &hpt372a; 877 chip_table = &hpt372a;
870 break; 878 break;
871 case PCI_DEVICE_ID_TTI_HPT302: 879 case PCI_DEVICE_ID_TTI_HPT302:
872 /* 302N if rev > 1 */ 880 /* 302N if rev > 1 */
873 if (rev > 1) 881 if (rev > 1)
874 return -ENODEV; 882 return -ENODEV;
875 ppi[0] = &info_hpt302; 883 ppi[0] = &info_hpt302;
876 /* Check this */ 884 /* Check this */
877 chip_table = &hpt302; 885 chip_table = &hpt302;
878 break; 886 break;
879 case PCI_DEVICE_ID_TTI_HPT371: 887 case PCI_DEVICE_ID_TTI_HPT371:
880 if (rev > 1) 888 if (rev > 1)
881 return -ENODEV; 889 return -ENODEV;
882 ppi[0] = &info_hpt302; 890 ppi[0] = &info_hpt302;
883 chip_table = &hpt371; 891 chip_table = &hpt371;
884 /* Single channel device, master is not present 892 /*
885 but the BIOS (or us for non x86) must mark it 893 * Single channel device, master is not present
886 absent */ 894 * but the BIOS (or us for non x86) must mark it
887 pci_read_config_byte(dev, 0x50, &mcr1); 895 * absent
888 mcr1 &= ~0x04; 896 */
889 pci_write_config_byte(dev, 0x50, mcr1); 897 pci_read_config_byte(dev, 0x50, &mcr1);
890 break; 898 mcr1 &= ~0x04;
891 case PCI_DEVICE_ID_TTI_HPT374: 899 pci_write_config_byte(dev, 0x50, mcr1);
892 chip_table = &hpt374; 900 break;
893 if (!(PCI_FUNC(dev->devfn) & 1)) 901 case PCI_DEVICE_ID_TTI_HPT374:
894 *ppi = &info_hpt374_fn0; 902 chip_table = &hpt374;
895 else 903 if (!(PCI_FUNC(dev->devfn) & 1))
896 *ppi = &info_hpt374_fn1; 904 *ppi = &info_hpt374_fn0;
897 break; 905 else
898 default: 906 *ppi = &info_hpt374_fn1;
899 printk(KERN_ERR "pata_hpt37x: PCI table is bogus please report (%d).\n", dev->device); 907 break;
908 default:
909 printk(KERN_ERR
910 "pata_hpt37x: PCI table is bogus, please report (%d).\n",
911 dev->device);
900 return -ENODEV; 912 return -ENODEV;
901 } 913 }
902 } 914 }
@@ -927,9 +939,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
927 if (chip_table == &hpt372a) 939 if (chip_table == &hpt372a)
928 outb(0x0e, iobase + 0x9c); 940 outb(0x0e, iobase + 0x9c);
929 941
930 /* Some devices do not let this value be accessed via PCI space 942 /*
931 according to the old driver. In addition we must use the value 943 * Some devices do not let this value be accessed via PCI space
932 from FN 0 on the HPT374 */ 944 * according to the old driver. In addition we must use the value
945 * from FN 0 on the HPT374.
946 */
933 947
934 if (chip_table == &hpt374) { 948 if (chip_table == &hpt374) {
935 freq = hpt374_read_freq(dev); 949 freq = hpt374_read_freq(dev);
@@ -943,10 +957,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
943 u8 sr; 957 u8 sr;
944 u32 total = 0; 958 u32 total = 0;
945 959
946 printk(KERN_WARNING "pata_hpt37x: BIOS has not set timing clocks.\n"); 960 printk(KERN_WARNING
961 "pata_hpt37x: BIOS has not set timing clocks.\n");
947 962
948 /* This is the process the HPT371 BIOS is reported to use */ 963 /* This is the process the HPT371 BIOS is reported to use */
949 for(i = 0; i < 128; i++) { 964 for (i = 0; i < 128; i++) {
950 pci_read_config_byte(dev, 0x78, &sr); 965 pci_read_config_byte(dev, 0x78, &sr);
951 total += sr & 0x1FF; 966 total += sr & 0x1FF;
952 udelay(15); 967 udelay(15);
@@ -981,17 +996,22 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
981 996
982 /* Select the DPLL clock. */ 997 /* Select the DPLL clock. */
983 pci_write_config_byte(dev, 0x5b, 0x21); 998 pci_write_config_byte(dev, 0x5b, 0x21);
984 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100); 999 pci_write_config_dword(dev, 0x5C,
1000 (f_high << 16) | f_low | 0x100);
985 1001
986 for(adjust = 0; adjust < 8; adjust++) { 1002 for (adjust = 0; adjust < 8; adjust++) {
987 if (hpt37x_calibrate_dpll(dev)) 1003 if (hpt37x_calibrate_dpll(dev))
988 break; 1004 break;
989 /* See if it'll settle at a fractionally different clock */ 1005 /*
1006 * See if it'll settle at a fractionally
1007 * different clock
1008 */
990 if (adjust & 1) 1009 if (adjust & 1)
991 f_low -= adjust >> 1; 1010 f_low -= adjust >> 1;
992 else 1011 else
993 f_high += adjust >> 1; 1012 f_high += adjust >> 1;
994 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100); 1013 pci_write_config_dword(dev, 0x5C,
1014 (f_high << 16) | f_low | 0x100);
995 } 1015 }
996 if (adjust == 8) { 1016 if (adjust == 8) {
997 printk(KERN_ERR "pata_hpt37x: DPLL did not stabilize!\n"); 1017 printk(KERN_ERR "pata_hpt37x: DPLL did not stabilize!\n");
@@ -1010,7 +1030,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1010 * Perform a final fixup. Note that we will have used the 1030 * Perform a final fixup. Note that we will have used the
1011 * DPLL on the HPT372 which means we don't have to worry 1031 * DPLL on the HPT372 which means we don't have to worry
1012 * about lack of UDMA133 support on lower clocks 1032 * about lack of UDMA133 support on lower clocks
1013 */ 1033 */
1014 1034
1015 if (clock_slot < 2 && ppi[0] == &info_hpt370) 1035 if (clock_slot < 2 && ppi[0] == &info_hpt370)
1016 ppi[0] = &info_hpt370_33; 1036 ppi[0] = &info_hpt370_33;
@@ -1035,9 +1055,9 @@ static const struct pci_device_id hpt37x[] = {
1035}; 1055};
1036 1056
1037static struct pci_driver hpt37x_pci_driver = { 1057static struct pci_driver hpt37x_pci_driver = {
1038 .name = DRV_NAME, 1058 .name = DRV_NAME,
1039 .id_table = hpt37x, 1059 .id_table = hpt37x,
1040 .probe = hpt37x_init_one, 1060 .probe = hpt37x_init_one,
1041 .remove = ata_pci_remove_one 1061 .remove = ata_pci_remove_one
1042}; 1062};
1043 1063