diff options
Diffstat (limited to 'drivers/ide/pci/hpt366.c')
-rw-r--r-- | drivers/ide/pci/hpt366.c | 138 |
1 files changed, 79 insertions, 59 deletions
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 2cd74c345a6c..39f1c89f7c86 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/hpt366.c Version 1.10 Jun 29, 2007 | 2 | * linux/drivers/ide/pci/hpt366.c Version 1.12 Aug 19, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
@@ -68,7 +68,8 @@ | |||
68 | * HPT37x chip family; save space by introducing the separate transfer mode | 68 | * HPT37x chip family; save space by introducing the separate transfer mode |
69 | * table in which the mode lookup is done | 69 | * table in which the mode lookup is done |
70 | * - use f_CNT value saved by the HighPoint BIOS as reading it directly gives | 70 | * - use f_CNT value saved by the HighPoint BIOS as reading it directly gives |
71 | * the wrong PCI frequency since DPLL has already been calibrated by BIOS | 71 | * the wrong PCI frequency since DPLL has already been calibrated by BIOS; |
72 | * read it only from the function 0 of HPT374 chips | ||
72 | * - fix the hotswap code: it caused RESET- to glitch when tristating the bus, | 73 | * - fix the hotswap code: it caused RESET- to glitch when tristating the bus, |
73 | * and for HPT36x the obsolete HDIO_TRISTATE_HWIF handler was called instead | 74 | * and for HPT36x the obsolete HDIO_TRISTATE_HWIF handler was called instead |
74 | * - pass to init_chipset() handlers a copy of the IDE PCI device structure as | 75 | * - pass to init_chipset() handlers a copy of the IDE PCI device structure as |
@@ -113,6 +114,7 @@ | |||
113 | * unify HPT36x/37x timing setup code and the speedproc handlers by joining | 114 | * unify HPT36x/37x timing setup code and the speedproc handlers by joining |
114 | * the register setting lists into the table indexed by the clock selected | 115 | * the register setting lists into the table indexed by the clock selected |
115 | * - set the correct hwif->ultra_mask for each individual chip | 116 | * - set the correct hwif->ultra_mask for each individual chip |
117 | * - add UltraDMA mode filtering for the HPT37[24] based SATA cards | ||
116 | * Sergei Shtylyov, <sshtylyov@ru.mvista.com> or <source@mvista.com> | 118 | * Sergei Shtylyov, <sshtylyov@ru.mvista.com> or <source@mvista.com> |
117 | */ | 119 | */ |
118 | 120 | ||
@@ -517,42 +519,44 @@ static int check_in_drive_list(ide_drive_t *drive, const char **list) | |||
517 | } | 519 | } |
518 | 520 | ||
519 | /* | 521 | /* |
520 | * Note for the future; the SATA hpt37x we must set | 522 | * The Marvell bridge chips used on the HighPoint SATA cards do not seem |
521 | * either PIO or UDMA modes 0,4,5 | 523 | * to support the UltraDMA modes 1, 2, and 3 as well as any MWDMA modes... |
522 | */ | 524 | */ |
523 | 525 | ||
524 | static u8 hpt3xx_udma_filter(ide_drive_t *drive) | 526 | static u8 hpt3xx_udma_filter(ide_drive_t *drive) |
525 | { | 527 | { |
526 | struct hpt_info *info = pci_get_drvdata(HWIF(drive)->pci_dev); | 528 | ide_hwif_t *hwif = HWIF(drive); |
527 | u8 mask; | 529 | struct hpt_info *info = pci_get_drvdata(hwif->pci_dev); |
530 | u8 mask = hwif->ultra_mask; | ||
528 | 531 | ||
529 | switch (info->chip_type) { | 532 | switch (info->chip_type) { |
530 | case HPT370A: | ||
531 | if (!HPT370_ALLOW_ATA100_5 || | ||
532 | check_in_drive_list(drive, bad_ata100_5)) | ||
533 | return 0x1f; | ||
534 | else | ||
535 | return 0x3f; | ||
536 | case HPT370: | ||
537 | if (!HPT370_ALLOW_ATA100_5 || | ||
538 | check_in_drive_list(drive, bad_ata100_5)) | ||
539 | mask = 0x1f; | ||
540 | else | ||
541 | mask = 0x3f; | ||
542 | break; | ||
543 | case HPT36x: | 533 | case HPT36x: |
544 | if (!HPT366_ALLOW_ATA66_4 || | 534 | if (!HPT366_ALLOW_ATA66_4 || |
545 | check_in_drive_list(drive, bad_ata66_4)) | 535 | check_in_drive_list(drive, bad_ata66_4)) |
546 | mask = 0x0f; | 536 | mask = ATA_UDMA3; |
547 | else | ||
548 | mask = 0x1f; | ||
549 | 537 | ||
550 | if (!HPT366_ALLOW_ATA66_3 || | 538 | if (!HPT366_ALLOW_ATA66_3 || |
551 | check_in_drive_list(drive, bad_ata66_3)) | 539 | check_in_drive_list(drive, bad_ata66_3)) |
552 | mask = 0x07; | 540 | mask = ATA_UDMA2; |
541 | break; | ||
542 | case HPT370: | ||
543 | if (!HPT370_ALLOW_ATA100_5 || | ||
544 | check_in_drive_list(drive, bad_ata100_5)) | ||
545 | mask = ATA_UDMA4; | ||
553 | break; | 546 | break; |
547 | case HPT370A: | ||
548 | if (!HPT370_ALLOW_ATA100_5 || | ||
549 | check_in_drive_list(drive, bad_ata100_5)) | ||
550 | return ATA_UDMA4; | ||
551 | case HPT372 : | ||
552 | case HPT372A: | ||
553 | case HPT372N: | ||
554 | case HPT374 : | ||
555 | if (ide_dev_is_sata(drive->id)) | ||
556 | mask &= ~0x0e; | ||
557 | /* Fall thru */ | ||
554 | default: | 558 | default: |
555 | return 0x7f; | 559 | return mask; |
556 | } | 560 | } |
557 | 561 | ||
558 | return check_in_drive_list(drive, bad_ata33) ? 0x00 : mask; | 562 | return check_in_drive_list(drive, bad_ata33) ? 0x00 : mask; |
@@ -981,6 +985,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
981 | struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL); | 985 | struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL); |
982 | unsigned long io_base = pci_resource_start(dev, 4); | 986 | unsigned long io_base = pci_resource_start(dev, 4); |
983 | u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */ | 987 | u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */ |
988 | u8 chip_type; | ||
984 | enum ata_clock clock; | 989 | enum ata_clock clock; |
985 | 990 | ||
986 | if (info == NULL) { | 991 | if (info == NULL) { |
@@ -992,7 +997,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
992 | * Copy everything from a static "template" structure | 997 | * Copy everything from a static "template" structure |
993 | * to just allocated per-chip hpt_info structure. | 998 | * to just allocated per-chip hpt_info structure. |
994 | */ | 999 | */ |
995 | *info = *(struct hpt_info *)pci_get_drvdata(dev); | 1000 | memcpy(info, pci_get_drvdata(dev), sizeof(struct hpt_info)); |
1001 | chip_type = info->chip_type; | ||
996 | 1002 | ||
997 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); | 1003 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); |
998 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78); | 1004 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78); |
@@ -1002,7 +1008,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1002 | /* | 1008 | /* |
1003 | * First, try to estimate the PCI clock frequency... | 1009 | * First, try to estimate the PCI clock frequency... |
1004 | */ | 1010 | */ |
1005 | if (info->chip_type >= HPT370) { | 1011 | if (chip_type >= HPT370) { |
1006 | u8 scr1 = 0; | 1012 | u8 scr1 = 0; |
1007 | u16 f_cnt = 0; | 1013 | u16 f_cnt = 0; |
1008 | u32 temp = 0; | 1014 | u32 temp = 0; |
@@ -1016,7 +1022,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1016 | * HighPoint does this for HPT372A. | 1022 | * HighPoint does this for HPT372A. |
1017 | * NOTE: This register is only writeable via I/O space. | 1023 | * NOTE: This register is only writeable via I/O space. |
1018 | */ | 1024 | */ |
1019 | if (info->chip_type == HPT372A) | 1025 | if (chip_type == HPT372A) |
1020 | outb(0x0e, io_base + 0x9c); | 1026 | outb(0x0e, io_base + 0x9c); |
1021 | 1027 | ||
1022 | /* | 1028 | /* |
@@ -1034,13 +1040,28 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1034 | * First try reading the register in which the HighPoint BIOS | 1040 | * First try reading the register in which the HighPoint BIOS |
1035 | * saves f_CNT value before reprogramming the DPLL from its | 1041 | * saves f_CNT value before reprogramming the DPLL from its |
1036 | * default setting (which differs for the various chips). | 1042 | * default setting (which differs for the various chips). |
1037 | * NOTE: This register is only accessible via I/O space. | ||
1038 | * | 1043 | * |
1039 | * In case the signature check fails, we'll have to resort to | 1044 | * NOTE: This register is only accessible via I/O space; |
1040 | * reading the f_CNT register itself in hopes that nobody has | 1045 | * HPT374 BIOS only saves it for the function 0, so we have to |
1041 | * touched the DPLL yet... | 1046 | * always read it from there -- no need to check the result of |
1047 | * pci_get_slot() for the function 0 as the whole device has | ||
1048 | * been already "pinned" (via function 1) in init_setup_hpt374() | ||
1049 | */ | ||
1050 | if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) { | ||
1051 | struct pci_dev *dev1 = pci_get_slot(dev->bus, | ||
1052 | dev->devfn - 1); | ||
1053 | unsigned long io_base = pci_resource_start(dev1, 4); | ||
1054 | |||
1055 | temp = inl(io_base + 0x90); | ||
1056 | pci_dev_put(dev1); | ||
1057 | } else | ||
1058 | temp = inl(io_base + 0x90); | ||
1059 | |||
1060 | /* | ||
1061 | * In case the signature check fails, we'll have to | ||
1062 | * resort to reading the f_CNT register itself in hopes | ||
1063 | * that nobody has touched the DPLL yet... | ||
1042 | */ | 1064 | */ |
1043 | temp = inl(io_base + 0x90); | ||
1044 | if ((temp & 0xFFFFF000) != 0xABCDE000) { | 1065 | if ((temp & 0xFFFFF000) != 0xABCDE000) { |
1045 | int i; | 1066 | int i; |
1046 | 1067 | ||
@@ -1120,7 +1141,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1120 | * We also don't like using the DPLL because this causes glitches | 1141 | * We also don't like using the DPLL because this causes glitches |
1121 | * on PRST-/SRST- when the state engine gets reset... | 1142 | * on PRST-/SRST- when the state engine gets reset... |
1122 | */ | 1143 | */ |
1123 | if (info->chip_type >= HPT374 || info->settings[clock] == NULL) { | 1144 | if (chip_type >= HPT374 || info->settings[clock] == NULL) { |
1124 | u16 f_low, delta = pci_clk < 50 ? 2 : 4; | 1145 | u16 f_low, delta = pci_clk < 50 ? 2 : 4; |
1125 | int adjust; | 1146 | int adjust; |
1126 | 1147 | ||
@@ -1190,7 +1211,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1190 | /* Point to this chip's own instance of the hpt_info structure. */ | 1211 | /* Point to this chip's own instance of the hpt_info structure. */ |
1191 | pci_set_drvdata(dev, info); | 1212 | pci_set_drvdata(dev, info); |
1192 | 1213 | ||
1193 | if (info->chip_type >= HPT370) { | 1214 | if (chip_type >= HPT370) { |
1194 | u8 mcr1, mcr4; | 1215 | u8 mcr1, mcr4; |
1195 | 1216 | ||
1196 | /* | 1217 | /* |
@@ -1209,7 +1230,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1209 | * the MISC. register to stretch the UltraDMA Tss timing. | 1230 | * the MISC. register to stretch the UltraDMA Tss timing. |
1210 | * NOTE: This register is only writeable via I/O space. | 1231 | * NOTE: This register is only writeable via I/O space. |
1211 | */ | 1232 | */ |
1212 | if (info->chip_type == HPT371N && clock == ATA_CLOCK_66MHZ) | 1233 | if (chip_type == HPT371N && clock == ATA_CLOCK_66MHZ) |
1213 | 1234 | ||
1214 | outb(inb(io_base + 0x9c) | 0x04, io_base + 0x9c); | 1235 | outb(inb(io_base + 0x9c) | 0x04, io_base + 0x9c); |
1215 | 1236 | ||
@@ -1218,25 +1239,24 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1218 | 1239 | ||
1219 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | 1240 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) |
1220 | { | 1241 | { |
1221 | struct pci_dev *dev = hwif->pci_dev; | 1242 | struct pci_dev *dev = hwif->pci_dev; |
1222 | struct hpt_info *info = pci_get_drvdata(dev); | 1243 | struct hpt_info *info = pci_get_drvdata(dev); |
1223 | int serialize = HPT_SERIALIZE_IO; | 1244 | int serialize = HPT_SERIALIZE_IO; |
1224 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; | 1245 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; |
1225 | u8 chip_type = info->chip_type; | 1246 | u8 chip_type = info->chip_type; |
1226 | u8 new_mcr, old_mcr = 0; | 1247 | u8 new_mcr, old_mcr = 0; |
1227 | 1248 | ||
1228 | /* Cache the channel's MISC. control registers' offset */ | 1249 | /* Cache the channel's MISC. control registers' offset */ |
1229 | hwif->select_data = hwif->channel ? 0x54 : 0x50; | 1250 | hwif->select_data = hwif->channel ? 0x54 : 0x50; |
1230 | 1251 | ||
1231 | hwif->tuneproc = &hpt3xx_tune_drive; | 1252 | hwif->tuneproc = &hpt3xx_tune_drive; |
1232 | hwif->speedproc = &hpt3xx_tune_chipset; | 1253 | hwif->speedproc = &hpt3xx_tune_chipset; |
1233 | hwif->quirkproc = &hpt3xx_quirkproc; | 1254 | hwif->quirkproc = &hpt3xx_quirkproc; |
1234 | hwif->intrproc = &hpt3xx_intrproc; | 1255 | hwif->intrproc = &hpt3xx_intrproc; |
1235 | hwif->maskproc = &hpt3xx_maskproc; | 1256 | hwif->maskproc = &hpt3xx_maskproc; |
1236 | hwif->busproc = &hpt3xx_busproc; | 1257 | hwif->busproc = &hpt3xx_busproc; |
1237 | 1258 | ||
1238 | if (chip_type <= HPT370A) | 1259 | hwif->udma_filter = &hpt3xx_udma_filter; |
1239 | hwif->udma_filter = &hpt3xx_udma_filter; | ||
1240 | 1260 | ||
1241 | /* | 1261 | /* |
1242 | * HPT3xxN chips have some complications: | 1262 | * HPT3xxN chips have some complications: |
@@ -1486,19 +1506,19 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) | |||
1486 | d->host_flags |= IDE_HFLAG_SINGLE; | 1506 | d->host_flags |= IDE_HFLAG_SINGLE; |
1487 | d->enablebits[0].mask = d->enablebits[0].val = 0x10; | 1507 | d->enablebits[0].mask = d->enablebits[0].val = 0x10; |
1488 | 1508 | ||
1489 | d->udma_mask = HPT366_ALLOW_ATA66_3 ? | 1509 | d->udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? |
1490 | (HPT366_ALLOW_ATA66_4 ? 0x1f : 0x0f) : 0x07; | 1510 | ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2; |
1491 | break; | 1511 | break; |
1492 | case 3: | 1512 | case 3: |
1493 | case 4: | 1513 | case 4: |
1494 | d->udma_mask = HPT370_ALLOW_ATA100_5 ? 0x3f : 0x1f; | 1514 | d->udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4; |
1495 | break; | 1515 | break; |
1496 | default: | 1516 | default: |
1497 | rev = 6; | 1517 | rev = 6; |
1498 | /* fall thru */ | 1518 | /* fall thru */ |
1499 | case 5: | 1519 | case 5: |
1500 | case 6: | 1520 | case 6: |
1501 | d->udma_mask = HPT372_ALLOW_ATA133_6 ? 0x7f : 0x3f; | 1521 | d->udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5; |
1502 | break; | 1522 | break; |
1503 | } | 1523 | } |
1504 | 1524 | ||
@@ -1559,7 +1579,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1559 | .init_dma = init_dma_hpt366, | 1579 | .init_dma = init_dma_hpt366, |
1560 | .autodma = AUTODMA, | 1580 | .autodma = AUTODMA, |
1561 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1581 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1562 | .udma_mask = HPT372_ALLOW_ATA133_6 ? 0x7f : 0x3f, | 1582 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
1563 | .bootable = OFF_BOARD, | 1583 | .bootable = OFF_BOARD, |
1564 | .extra = 240, | 1584 | .extra = 240, |
1565 | .pio_mask = ATA_PIO4, | 1585 | .pio_mask = ATA_PIO4, |
@@ -1571,7 +1591,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1571 | .init_dma = init_dma_hpt366, | 1591 | .init_dma = init_dma_hpt366, |
1572 | .autodma = AUTODMA, | 1592 | .autodma = AUTODMA, |
1573 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1593 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1574 | .udma_mask = HPT302_ALLOW_ATA133_6 ? 0x7f : 0x3f, | 1594 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
1575 | .bootable = OFF_BOARD, | 1595 | .bootable = OFF_BOARD, |
1576 | .extra = 240, | 1596 | .extra = 240, |
1577 | .pio_mask = ATA_PIO4, | 1597 | .pio_mask = ATA_PIO4, |
@@ -1583,7 +1603,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1583 | .init_dma = init_dma_hpt366, | 1603 | .init_dma = init_dma_hpt366, |
1584 | .autodma = AUTODMA, | 1604 | .autodma = AUTODMA, |
1585 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1605 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1586 | .udma_mask = HPT371_ALLOW_ATA133_6 ? 0x7f : 0x3f, | 1606 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
1587 | .bootable = OFF_BOARD, | 1607 | .bootable = OFF_BOARD, |
1588 | .extra = 240, | 1608 | .extra = 240, |
1589 | .pio_mask = ATA_PIO4, | 1609 | .pio_mask = ATA_PIO4, |
@@ -1595,7 +1615,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1595 | .init_dma = init_dma_hpt366, | 1615 | .init_dma = init_dma_hpt366, |
1596 | .autodma = AUTODMA, | 1616 | .autodma = AUTODMA, |
1597 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1617 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1598 | .udma_mask = 0x3f, | 1618 | .udma_mask = ATA_UDMA5, |
1599 | .bootable = OFF_BOARD, | 1619 | .bootable = OFF_BOARD, |
1600 | .extra = 240, | 1620 | .extra = 240, |
1601 | .pio_mask = ATA_PIO4, | 1621 | .pio_mask = ATA_PIO4, |
@@ -1607,7 +1627,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1607 | .init_dma = init_dma_hpt366, | 1627 | .init_dma = init_dma_hpt366, |
1608 | .autodma = AUTODMA, | 1628 | .autodma = AUTODMA, |
1609 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1629 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1610 | .udma_mask = HPT372_ALLOW_ATA133_6 ? 0x7f : 0x3f, | 1630 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
1611 | .bootable = OFF_BOARD, | 1631 | .bootable = OFF_BOARD, |
1612 | .extra = 240, | 1632 | .extra = 240, |
1613 | .pio_mask = ATA_PIO4, | 1633 | .pio_mask = ATA_PIO4, |