diff options
Diffstat (limited to 'drivers/ide/pci/hpt366.c')
-rw-r--r-- | drivers/ide/pci/hpt366.c | 89 |
1 files changed, 46 insertions, 43 deletions
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 5623cad569da..d0f7bb8b8adf 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -121,12 +121,8 @@ | |||
121 | #include <linux/module.h> | 121 | #include <linux/module.h> |
122 | #include <linux/kernel.h> | 122 | #include <linux/kernel.h> |
123 | #include <linux/delay.h> | 123 | #include <linux/delay.h> |
124 | #include <linux/timer.h> | ||
125 | #include <linux/mm.h> | ||
126 | #include <linux/ioport.h> | ||
127 | #include <linux/blkdev.h> | 124 | #include <linux/blkdev.h> |
128 | #include <linux/hdreg.h> | 125 | #include <linux/hdreg.h> |
129 | |||
130 | #include <linux/interrupt.h> | 126 | #include <linux/interrupt.h> |
131 | #include <linux/pci.h> | 127 | #include <linux/pci.h> |
132 | #include <linux/init.h> | 128 | #include <linux/init.h> |
@@ -134,7 +130,6 @@ | |||
134 | 130 | ||
135 | #include <asm/uaccess.h> | 131 | #include <asm/uaccess.h> |
136 | #include <asm/io.h> | 132 | #include <asm/io.h> |
137 | #include <asm/irq.h> | ||
138 | 133 | ||
139 | /* various tuning parameters */ | 134 | /* various tuning parameters */ |
140 | #define HPT_RESET_STATE_ENGINE | 135 | #define HPT_RESET_STATE_ENGINE |
@@ -1279,12 +1274,55 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1279 | return dev->irq; | 1274 | return dev->irq; |
1280 | } | 1275 | } |
1281 | 1276 | ||
1277 | static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif) | ||
1278 | { | ||
1279 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
1280 | struct hpt_info *info = pci_get_drvdata(dev); | ||
1281 | u8 chip_type = info->chip_type; | ||
1282 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; | ||
1283 | |||
1284 | /* | ||
1285 | * The HPT37x uses the CBLID pins as outputs for MA15/MA16 | ||
1286 | * address lines to access an external EEPROM. To read valid | ||
1287 | * cable detect state the pins must be enabled as inputs. | ||
1288 | */ | ||
1289 | if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) { | ||
1290 | /* | ||
1291 | * HPT374 PCI function 1 | ||
1292 | * - set bit 15 of reg 0x52 to enable TCBLID as input | ||
1293 | * - set bit 15 of reg 0x56 to enable FCBLID as input | ||
1294 | */ | ||
1295 | u8 mcr_addr = hwif->select_data + 2; | ||
1296 | u16 mcr; | ||
1297 | |||
1298 | pci_read_config_word(dev, mcr_addr, &mcr); | ||
1299 | pci_write_config_word(dev, mcr_addr, (mcr | 0x8000)); | ||
1300 | /* now read cable id register */ | ||
1301 | pci_read_config_byte(dev, 0x5a, &scr1); | ||
1302 | pci_write_config_word(dev, mcr_addr, mcr); | ||
1303 | } else if (chip_type >= HPT370) { | ||
1304 | /* | ||
1305 | * HPT370/372 and 374 pcifn 0 | ||
1306 | * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs | ||
1307 | */ | ||
1308 | u8 scr2 = 0; | ||
1309 | |||
1310 | pci_read_config_byte(dev, 0x5b, &scr2); | ||
1311 | pci_write_config_byte(dev, 0x5b, (scr2 & ~1)); | ||
1312 | /* now read cable id register */ | ||
1313 | pci_read_config_byte(dev, 0x5a, &scr1); | ||
1314 | pci_write_config_byte(dev, 0x5b, scr2); | ||
1315 | } else | ||
1316 | pci_read_config_byte(dev, 0x5a, &scr1); | ||
1317 | |||
1318 | return (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
1319 | } | ||
1320 | |||
1282 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | 1321 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) |
1283 | { | 1322 | { |
1284 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1323 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1285 | struct hpt_info *info = pci_get_drvdata(dev); | 1324 | struct hpt_info *info = pci_get_drvdata(dev); |
1286 | int serialize = HPT_SERIALIZE_IO; | 1325 | int serialize = HPT_SERIALIZE_IO; |
1287 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; | ||
1288 | u8 chip_type = info->chip_type; | 1326 | u8 chip_type = info->chip_type; |
1289 | u8 new_mcr, old_mcr = 0; | 1327 | u8 new_mcr, old_mcr = 0; |
1290 | 1328 | ||
@@ -1301,6 +1339,8 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1301 | hwif->udma_filter = &hpt3xx_udma_filter; | 1339 | hwif->udma_filter = &hpt3xx_udma_filter; |
1302 | hwif->mdma_filter = &hpt3xx_mdma_filter; | 1340 | hwif->mdma_filter = &hpt3xx_mdma_filter; |
1303 | 1341 | ||
1342 | hwif->cable_detect = hpt3xx_cable_detect; | ||
1343 | |||
1304 | /* | 1344 | /* |
1305 | * HPT3xxN chips have some complications: | 1345 | * HPT3xxN chips have some complications: |
1306 | * | 1346 | * |
@@ -1346,43 +1386,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1346 | if (hwif->dma_base == 0) | 1386 | if (hwif->dma_base == 0) |
1347 | return; | 1387 | return; |
1348 | 1388 | ||
1349 | /* | ||
1350 | * The HPT37x uses the CBLID pins as outputs for MA15/MA16 | ||
1351 | * address lines to access an external EEPROM. To read valid | ||
1352 | * cable detect state the pins must be enabled as inputs. | ||
1353 | */ | ||
1354 | if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) { | ||
1355 | /* | ||
1356 | * HPT374 PCI function 1 | ||
1357 | * - set bit 15 of reg 0x52 to enable TCBLID as input | ||
1358 | * - set bit 15 of reg 0x56 to enable FCBLID as input | ||
1359 | */ | ||
1360 | u8 mcr_addr = hwif->select_data + 2; | ||
1361 | u16 mcr; | ||
1362 | |||
1363 | pci_read_config_word (dev, mcr_addr, &mcr); | ||
1364 | pci_write_config_word(dev, mcr_addr, (mcr | 0x8000)); | ||
1365 | /* now read cable id register */ | ||
1366 | pci_read_config_byte (dev, 0x5a, &scr1); | ||
1367 | pci_write_config_word(dev, mcr_addr, mcr); | ||
1368 | } else if (chip_type >= HPT370) { | ||
1369 | /* | ||
1370 | * HPT370/372 and 374 pcifn 0 | ||
1371 | * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs | ||
1372 | */ | ||
1373 | u8 scr2 = 0; | ||
1374 | |||
1375 | pci_read_config_byte (dev, 0x5b, &scr2); | ||
1376 | pci_write_config_byte(dev, 0x5b, (scr2 & ~1)); | ||
1377 | /* now read cable id register */ | ||
1378 | pci_read_config_byte (dev, 0x5a, &scr1); | ||
1379 | pci_write_config_byte(dev, 0x5b, scr2); | ||
1380 | } else | ||
1381 | pci_read_config_byte (dev, 0x5a, &scr1); | ||
1382 | |||
1383 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
1384 | hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
1385 | |||
1386 | if (chip_type >= HPT374) { | 1389 | if (chip_type >= HPT374) { |
1387 | hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; | 1390 | hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; |
1388 | hwif->ide_dma_end = &hpt374_ide_dma_end; | 1391 | hwif->ide_dma_end = &hpt374_ide_dma_end; |