aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/hpt366.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:31 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:31 -0500
commitbfa14b42a3bd671f0287b3db42e703e86ef27b48 (patch)
treead902a99aa59232832d8e663be8d86a615e24114 /drivers/ide/pci/hpt366.c
parentc413b9b94d9a8e7548cc4b2e04b7df0439ce76fd (diff)
ide: add ->cable_detect method to ide_hwif_t
* Add ->cable_detect method to ide_hwif_t. * Call the new method in ide_init_port() if: - the host supports UDMA modes > UDMA2 ('hwif->ultra_mask & 78') - DMA initialization was successful (if hwif->dma_base is not set ide_init_port() sets hwif->ultra_mask to zero) - "idex=ata66" is not used ('hwif->cbl != ATA_CBL_PATA40_SHORT') * Convert PCI host drivers to use ->cable_detect method. While at it: * Factor out cable detection to separate functions (if not already done). * hpt366.c/it8213.c/slc90e66.c: - don't check cable type if "idex=ata66" is used * pdc202xx_new.c: - add __devinit tag to pdcnew_cable_detect() * pdc202xx_old.c: - rename pdc202xx_old_cable_detect() to pdc2026x_old_cable_detect() - add __devinit tag to pdc2026x_old_cable_detect() Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/hpt366.c')
-rw-r--r--drivers/ide/pci/hpt366.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 5623cad569da..7a8c8c7a8b96 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1279,12 +1279,55 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1279 return dev->irq; 1279 return dev->irq;
1280} 1280}
1281 1281
1282static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
1283{
1284 struct pci_dev *dev = to_pci_dev(hwif->dev);
1285 struct hpt_info *info = pci_get_drvdata(dev);
1286 u8 chip_type = info->chip_type;
1287 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02;
1288
1289 /*
1290 * The HPT37x uses the CBLID pins as outputs for MA15/MA16
1291 * address lines to access an external EEPROM. To read valid
1292 * cable detect state the pins must be enabled as inputs.
1293 */
1294 if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) {
1295 /*
1296 * HPT374 PCI function 1
1297 * - set bit 15 of reg 0x52 to enable TCBLID as input
1298 * - set bit 15 of reg 0x56 to enable FCBLID as input
1299 */
1300 u8 mcr_addr = hwif->select_data + 2;
1301 u16 mcr;
1302
1303 pci_read_config_word(dev, mcr_addr, &mcr);
1304 pci_write_config_word(dev, mcr_addr, (mcr | 0x8000));
1305 /* now read cable id register */
1306 pci_read_config_byte(dev, 0x5a, &scr1);
1307 pci_write_config_word(dev, mcr_addr, mcr);
1308 } else if (chip_type >= HPT370) {
1309 /*
1310 * HPT370/372 and 374 pcifn 0
1311 * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs
1312 */
1313 u8 scr2 = 0;
1314
1315 pci_read_config_byte(dev, 0x5b, &scr2);
1316 pci_write_config_byte(dev, 0x5b, (scr2 & ~1));
1317 /* now read cable id register */
1318 pci_read_config_byte(dev, 0x5a, &scr1);
1319 pci_write_config_byte(dev, 0x5b, scr2);
1320 } else
1321 pci_read_config_byte(dev, 0x5a, &scr1);
1322
1323 return (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
1324}
1325
1282static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) 1326static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1283{ 1327{
1284 struct pci_dev *dev = to_pci_dev(hwif->dev); 1328 struct pci_dev *dev = to_pci_dev(hwif->dev);
1285 struct hpt_info *info = pci_get_drvdata(dev); 1329 struct hpt_info *info = pci_get_drvdata(dev);
1286 int serialize = HPT_SERIALIZE_IO; 1330 int serialize = HPT_SERIALIZE_IO;
1287 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02;
1288 u8 chip_type = info->chip_type; 1331 u8 chip_type = info->chip_type;
1289 u8 new_mcr, old_mcr = 0; 1332 u8 new_mcr, old_mcr = 0;
1290 1333
@@ -1301,6 +1344,8 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1301 hwif->udma_filter = &hpt3xx_udma_filter; 1344 hwif->udma_filter = &hpt3xx_udma_filter;
1302 hwif->mdma_filter = &hpt3xx_mdma_filter; 1345 hwif->mdma_filter = &hpt3xx_mdma_filter;
1303 1346
1347 hwif->cable_detect = hpt3xx_cable_detect;
1348
1304 /* 1349 /*
1305 * HPT3xxN chips have some complications: 1350 * HPT3xxN chips have some complications:
1306 * 1351 *
@@ -1346,43 +1391,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1346 if (hwif->dma_base == 0) 1391 if (hwif->dma_base == 0)
1347 return; 1392 return;
1348 1393
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) { 1394 if (chip_type >= HPT374) {
1387 hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; 1395 hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq;
1388 hwif->ide_dma_end = &hpt374_ide_dma_end; 1396 hwif->ide_dma_end = &hpt374_ide_dma_end;