diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-18 18:30:09 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-18 18:30:09 -0400 |
commit | fbf47840fe679bf370d07267df6f851b4f53e78d (patch) | |
tree | 906045a06833d339220271db7edfe303468c9310 /drivers/ide/pci | |
parent | bfd314a304faec58a13febec5dea37b4eab1adc0 (diff) |
hpt366: remove ->init_setup
* Split off hpt{374,371,366}_init() helper from init_setup_hpt{374,371,366}().
* Merge init_setup_{374,372n,371,372a,302,366}() into hpt366_init_one().
While at it:
* Use "HPT36x" name for HPT366/HPT368 chipsets.
* Add .chip_name to struct hpt_info and use it to set set d->name.
* Convert .max_ultra in struct hpt_info to .udma_mask and use it to set
d->udma_mask.
* Fix hpt302 to use HPT302_ALLOW_ATA133_6 define.
* Change HPT366/HPT374 interrupt fixup message from KERN_WARNING to KERN_INFO.
* Use the second hpt366_chipsets[] entry for HPT37x chipsets using HPT36x PCI
device ID and fix .enablebits/.host_flags for HPT36x hpt366_chipsets[] entry.
* Bump driver version.
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci')
-rw-r--r-- | drivers/ide/pci/hpt366.c | 306 |
1 files changed, 127 insertions, 179 deletions
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 26c15f20537e..3817c7db616e 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -1,9 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/hpt366.c Version 1.15 Oct 1, 2007 | 2 | * linux/drivers/ide/pci/hpt366.c Version 1.20 Oct 1, 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. |
6 | * Portions Copyright (C) 2003 Red Hat Inc | 6 | * Portions Copyright (C) 2003 Red Hat Inc |
7 | * Portions Copyright (C) 2007 Bartlomiej Zolnierkiewicz | ||
7 | * Portions Copyright (C) 2005-2007 MontaVista Software, Inc. | 8 | * Portions Copyright (C) 2005-2007 MontaVista Software, Inc. |
8 | * | 9 | * |
9 | * Thanks to HighPoint Technologies for their assistance, and hardware. | 10 | * Thanks to HighPoint Technologies for their assistance, and hardware. |
@@ -393,8 +394,9 @@ enum ata_clock { | |||
393 | */ | 394 | */ |
394 | 395 | ||
395 | struct hpt_info { | 396 | struct hpt_info { |
397 | char *chip_name; /* Chip name */ | ||
396 | u8 chip_type; /* Chip type */ | 398 | u8 chip_type; /* Chip type */ |
397 | u8 max_ultra; /* Max. UltraDMA mode allowed */ | 399 | u8 udma_mask; /* Allowed UltraDMA modes mask. */ |
398 | u8 dpll_clk; /* DPLL clock in MHz */ | 400 | u8 dpll_clk; /* DPLL clock in MHz */ |
399 | u8 pci_clk; /* PCI clock in MHz */ | 401 | u8 pci_clk; /* PCI clock in MHz */ |
400 | u32 **settings; /* Chipset settings table */ | 402 | u32 **settings; /* Chipset settings table */ |
@@ -432,78 +434,89 @@ static u32 *hpt37x_settings[NUM_ATA_CLOCKS] = { | |||
432 | }; | 434 | }; |
433 | 435 | ||
434 | static struct hpt_info hpt36x __devinitdata = { | 436 | static struct hpt_info hpt36x __devinitdata = { |
437 | .chip_name = "HPT36x", | ||
435 | .chip_type = HPT36x, | 438 | .chip_type = HPT36x, |
436 | .max_ultra = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? 4 : 3) : 2, | 439 | .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, |
437 | .dpll_clk = 0, /* no DPLL */ | 440 | .dpll_clk = 0, /* no DPLL */ |
438 | .settings = hpt36x_settings | 441 | .settings = hpt36x_settings |
439 | }; | 442 | }; |
440 | 443 | ||
441 | static struct hpt_info hpt370 __devinitdata = { | 444 | static struct hpt_info hpt370 __devinitdata = { |
445 | .chip_name = "HPT370", | ||
442 | .chip_type = HPT370, | 446 | .chip_type = HPT370, |
443 | .max_ultra = HPT370_ALLOW_ATA100_5 ? 5 : 4, | 447 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, |
444 | .dpll_clk = 48, | 448 | .dpll_clk = 48, |
445 | .settings = hpt37x_settings | 449 | .settings = hpt37x_settings |
446 | }; | 450 | }; |
447 | 451 | ||
448 | static struct hpt_info hpt370a __devinitdata = { | 452 | static struct hpt_info hpt370a __devinitdata = { |
453 | .chip_name = "HPT370A", | ||
449 | .chip_type = HPT370A, | 454 | .chip_type = HPT370A, |
450 | .max_ultra = HPT370_ALLOW_ATA100_5 ? 5 : 4, | 455 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, |
451 | .dpll_clk = 48, | 456 | .dpll_clk = 48, |
452 | .settings = hpt37x_settings | 457 | .settings = hpt37x_settings |
453 | }; | 458 | }; |
454 | 459 | ||
455 | static struct hpt_info hpt374 __devinitdata = { | 460 | static struct hpt_info hpt374 __devinitdata = { |
461 | .chip_name = "HPT374", | ||
456 | .chip_type = HPT374, | 462 | .chip_type = HPT374, |
457 | .max_ultra = 5, | 463 | .udma_mask = ATA_UDMA5, |
458 | .dpll_clk = 48, | 464 | .dpll_clk = 48, |
459 | .settings = hpt37x_settings | 465 | .settings = hpt37x_settings |
460 | }; | 466 | }; |
461 | 467 | ||
462 | static struct hpt_info hpt372 __devinitdata = { | 468 | static struct hpt_info hpt372 __devinitdata = { |
469 | .chip_name = "HPT372", | ||
463 | .chip_type = HPT372, | 470 | .chip_type = HPT372, |
464 | .max_ultra = HPT372_ALLOW_ATA133_6 ? 6 : 5, | 471 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
465 | .dpll_clk = 55, | 472 | .dpll_clk = 55, |
466 | .settings = hpt37x_settings | 473 | .settings = hpt37x_settings |
467 | }; | 474 | }; |
468 | 475 | ||
469 | static struct hpt_info hpt372a __devinitdata = { | 476 | static struct hpt_info hpt372a __devinitdata = { |
477 | .chip_name = "HPT372A", | ||
470 | .chip_type = HPT372A, | 478 | .chip_type = HPT372A, |
471 | .max_ultra = HPT372_ALLOW_ATA133_6 ? 6 : 5, | 479 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
472 | .dpll_clk = 66, | 480 | .dpll_clk = 66, |
473 | .settings = hpt37x_settings | 481 | .settings = hpt37x_settings |
474 | }; | 482 | }; |
475 | 483 | ||
476 | static struct hpt_info hpt302 __devinitdata = { | 484 | static struct hpt_info hpt302 __devinitdata = { |
485 | .chip_name = "HPT302", | ||
477 | .chip_type = HPT302, | 486 | .chip_type = HPT302, |
478 | .max_ultra = HPT372_ALLOW_ATA133_6 ? 6 : 5, | 487 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
479 | .dpll_clk = 66, | 488 | .dpll_clk = 66, |
480 | .settings = hpt37x_settings | 489 | .settings = hpt37x_settings |
481 | }; | 490 | }; |
482 | 491 | ||
483 | static struct hpt_info hpt371 __devinitdata = { | 492 | static struct hpt_info hpt371 __devinitdata = { |
493 | .chip_name = "HPT371", | ||
484 | .chip_type = HPT371, | 494 | .chip_type = HPT371, |
485 | .max_ultra = HPT371_ALLOW_ATA133_6 ? 6 : 5, | 495 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
486 | .dpll_clk = 66, | 496 | .dpll_clk = 66, |
487 | .settings = hpt37x_settings | 497 | .settings = hpt37x_settings |
488 | }; | 498 | }; |
489 | 499 | ||
490 | static struct hpt_info hpt372n __devinitdata = { | 500 | static struct hpt_info hpt372n __devinitdata = { |
501 | .chip_name = "HPT372N", | ||
491 | .chip_type = HPT372N, | 502 | .chip_type = HPT372N, |
492 | .max_ultra = HPT372_ALLOW_ATA133_6 ? 6 : 5, | 503 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
493 | .dpll_clk = 77, | 504 | .dpll_clk = 77, |
494 | .settings = hpt37x_settings | 505 | .settings = hpt37x_settings |
495 | }; | 506 | }; |
496 | 507 | ||
497 | static struct hpt_info hpt302n __devinitdata = { | 508 | static struct hpt_info hpt302n __devinitdata = { |
509 | .chip_name = "HPT302N", | ||
498 | .chip_type = HPT302N, | 510 | .chip_type = HPT302N, |
499 | .max_ultra = HPT302_ALLOW_ATA133_6 ? 6 : 5, | 511 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
500 | .dpll_clk = 77, | 512 | .dpll_clk = 77, |
501 | .settings = hpt37x_settings | 513 | .settings = hpt37x_settings |
502 | }; | 514 | }; |
503 | 515 | ||
504 | static struct hpt_info hpt371n __devinitdata = { | 516 | static struct hpt_info hpt371n __devinitdata = { |
517 | .chip_name = "HPT371N", | ||
505 | .chip_type = HPT371N, | 518 | .chip_type = HPT371N, |
506 | .max_ultra = HPT371_ALLOW_ATA133_6 ? 6 : 5, | 519 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
507 | .dpll_clk = 77, | 520 | .dpll_clk = 77, |
508 | .settings = hpt37x_settings | 521 | .settings = hpt37x_settings |
509 | }; | 522 | }; |
@@ -1136,7 +1149,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1136 | * Select 66 MHz DPLL clock only if UltraATA/133 mode is | 1149 | * Select 66 MHz DPLL clock only if UltraATA/133 mode is |
1137 | * supported/enabled, use 50 MHz DPLL clock otherwise... | 1150 | * supported/enabled, use 50 MHz DPLL clock otherwise... |
1138 | */ | 1151 | */ |
1139 | if (info->max_ultra == 6) { | 1152 | if (info->udma_mask == ATA_UDMA6) { |
1140 | dpll_clk = 66; | 1153 | dpll_clk = 66; |
1141 | clock = ATA_CLOCK_66MHZ; | 1154 | clock = ATA_CLOCK_66MHZ; |
1142 | } else if (dpll_clk) { /* HPT36x chips don't have DPLL */ | 1155 | } else if (dpll_clk) { /* HPT36x chips don't have DPLL */ |
@@ -1366,53 +1379,19 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | |||
1366 | ide_setup_dma(hwif, dmabase, 8); | 1379 | ide_setup_dma(hwif, dmabase, 8); |
1367 | } | 1380 | } |
1368 | 1381 | ||
1369 | static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d) | 1382 | static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) |
1370 | { | 1383 | { |
1371 | struct pci_dev *dev2; | 1384 | if (dev2->irq != dev->irq) { |
1372 | 1385 | /* FIXME: we need a core pci_set_interrupt() */ | |
1373 | if (PCI_FUNC(dev->devfn) & 1) | 1386 | dev2->irq = dev->irq; |
1374 | return -ENODEV; | 1387 | printk(KERN_INFO "HPT374: PCI config space interrupt fixed\n"); |
1375 | |||
1376 | pci_set_drvdata(dev, &hpt374); | ||
1377 | |||
1378 | if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) { | ||
1379 | int ret; | ||
1380 | |||
1381 | pci_set_drvdata(dev2, &hpt374); | ||
1382 | |||
1383 | if (dev2->irq != dev->irq) { | ||
1384 | /* FIXME: we need a core pci_set_interrupt() */ | ||
1385 | dev2->irq = dev->irq; | ||
1386 | printk(KERN_WARNING "%s: PCI config space interrupt " | ||
1387 | "fixed.\n", d->name); | ||
1388 | } | ||
1389 | ret = ide_setup_pci_devices(dev, dev2, d); | ||
1390 | if (ret < 0) | ||
1391 | pci_dev_put(dev2); | ||
1392 | return ret; | ||
1393 | } | 1388 | } |
1394 | return ide_setup_pci_device(dev, d); | ||
1395 | } | ||
1396 | |||
1397 | static int __devinit init_setup_hpt372n(struct pci_dev *dev, ide_pci_device_t *d) | ||
1398 | { | ||
1399 | pci_set_drvdata(dev, &hpt372n); | ||
1400 | |||
1401 | return ide_setup_pci_device(dev, d); | ||
1402 | } | 1389 | } |
1403 | 1390 | ||
1404 | static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d) | 1391 | static void __devinit hpt371_init(struct pci_dev *dev) |
1405 | { | 1392 | { |
1406 | struct hpt_info *info; | ||
1407 | u8 mcr1 = 0; | 1393 | u8 mcr1 = 0; |
1408 | 1394 | ||
1409 | if (dev->revision > 1) { | ||
1410 | d->name = "HPT371N"; | ||
1411 | |||
1412 | info = &hpt371n; | ||
1413 | } else | ||
1414 | info = &hpt371; | ||
1415 | |||
1416 | /* | 1395 | /* |
1417 | * HPT371 chips physically have only one channel, the secondary one, | 1396 | * HPT371 chips physically have only one channel, the secondary one, |
1418 | * but the primary channel registers do exist! Go figure... | 1397 | * but the primary channel registers do exist! Go figure... |
@@ -1422,173 +1401,83 @@ static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d) | |||
1422 | pci_read_config_byte(dev, 0x50, &mcr1); | 1401 | pci_read_config_byte(dev, 0x50, &mcr1); |
1423 | if (mcr1 & 0x04) | 1402 | if (mcr1 & 0x04) |
1424 | pci_write_config_byte(dev, 0x50, mcr1 & ~0x04); | 1403 | pci_write_config_byte(dev, 0x50, mcr1 & ~0x04); |
1425 | |||
1426 | pci_set_drvdata(dev, info); | ||
1427 | |||
1428 | return ide_setup_pci_device(dev, d); | ||
1429 | } | ||
1430 | |||
1431 | static int __devinit init_setup_hpt372a(struct pci_dev *dev, ide_pci_device_t *d) | ||
1432 | { | ||
1433 | struct hpt_info *info; | ||
1434 | |||
1435 | if (dev->revision > 1) { | ||
1436 | d->name = "HPT372N"; | ||
1437 | |||
1438 | info = &hpt372n; | ||
1439 | } else | ||
1440 | info = &hpt372a; | ||
1441 | pci_set_drvdata(dev, info); | ||
1442 | |||
1443 | return ide_setup_pci_device(dev, d); | ||
1444 | } | 1404 | } |
1445 | 1405 | ||
1446 | static int __devinit init_setup_hpt302(struct pci_dev *dev, ide_pci_device_t *d) | 1406 | static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) |
1447 | { | 1407 | { |
1448 | struct hpt_info *info; | 1408 | u8 mcr1 = 0, pin1 = 0, pin2 = 0; |
1449 | |||
1450 | if (dev->revision > 1) { | ||
1451 | d->name = "HPT302N"; | ||
1452 | |||
1453 | info = &hpt302n; | ||
1454 | } else | ||
1455 | info = &hpt302; | ||
1456 | pci_set_drvdata(dev, info); | ||
1457 | 1409 | ||
1458 | return ide_setup_pci_device(dev, d); | 1410 | /* |
1459 | } | 1411 | * Now we'll have to force both channels enabled if |
1412 | * at least one of them has been enabled by BIOS... | ||
1413 | */ | ||
1414 | pci_read_config_byte(dev, 0x50, &mcr1); | ||
1415 | if (mcr1 & 0x30) | ||
1416 | pci_write_config_byte(dev, 0x50, mcr1 | 0x30); | ||
1460 | 1417 | ||
1461 | static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) | 1418 | pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1); |
1462 | { | 1419 | pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2); |
1463 | struct pci_dev *dev2; | ||
1464 | u8 rev = dev->revision; | ||
1465 | static char *chipset_names[] = { "HPT366", "HPT366", "HPT368", | ||
1466 | "HPT370", "HPT370A", "HPT372", | ||
1467 | "HPT372N" }; | ||
1468 | static struct hpt_info *info[] = { &hpt36x, &hpt36x, &hpt36x, | ||
1469 | &hpt370, &hpt370a, &hpt372, | ||
1470 | &hpt372n }; | ||
1471 | |||
1472 | if (PCI_FUNC(dev->devfn) & 1) | ||
1473 | return -ENODEV; | ||
1474 | 1420 | ||
1475 | switch (rev) { | 1421 | if (pin1 != pin2 && dev->irq == dev2->irq) { |
1476 | case 0: | 1422 | printk(KERN_INFO "HPT36x: onboard version of chipset, " |
1477 | case 1: | 1423 | "pin1=%d pin2=%d\n", pin1, pin2); |
1478 | case 2: | 1424 | return 1; |
1479 | /* | ||
1480 | * HPT36x chips have one channel per function and have | ||
1481 | * both channel enable bits located differently and visible | ||
1482 | * to both functions -- really stupid design decision... :-( | ||
1483 | * Bit 4 is for the primary channel, bit 5 for the secondary. | ||
1484 | */ | ||
1485 | d->host_flags |= IDE_HFLAG_SINGLE; | ||
1486 | d->enablebits[0].mask = d->enablebits[0].val = 0x10; | ||
1487 | |||
1488 | d->udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? | ||
1489 | ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2; | ||
1490 | break; | ||
1491 | case 3: | ||
1492 | case 4: | ||
1493 | d->udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4; | ||
1494 | break; | ||
1495 | default: | ||
1496 | rev = 6; | ||
1497 | /* fall thru */ | ||
1498 | case 5: | ||
1499 | case 6: | ||
1500 | d->udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5; | ||
1501 | break; | ||
1502 | } | 1425 | } |
1503 | 1426 | ||
1504 | d->name = chipset_names[rev]; | 1427 | return 0; |
1505 | |||
1506 | pci_set_drvdata(dev, info[rev]); | ||
1507 | |||
1508 | if (rev > 2) | ||
1509 | goto init_single; | ||
1510 | |||
1511 | if ((dev2 = pci_get_slot(dev->bus, dev->devfn + 1)) != NULL) { | ||
1512 | u8 mcr1 = 0, pin1 = 0, pin2 = 0; | ||
1513 | int ret; | ||
1514 | |||
1515 | pci_set_drvdata(dev2, info[rev]); | ||
1516 | |||
1517 | /* | ||
1518 | * Now we'll have to force both channels enabled if | ||
1519 | * at least one of them has been enabled by BIOS... | ||
1520 | */ | ||
1521 | pci_read_config_byte(dev, 0x50, &mcr1); | ||
1522 | if (mcr1 & 0x30) | ||
1523 | pci_write_config_byte(dev, 0x50, mcr1 | 0x30); | ||
1524 | |||
1525 | pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1); | ||
1526 | pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2); | ||
1527 | if (pin1 != pin2 && dev->irq == dev2->irq) { | ||
1528 | d->host_flags |= IDE_HFLAG_BOOTABLE; | ||
1529 | printk("%s: onboard version of chipset, pin1=%d pin2=%d\n", | ||
1530 | d->name, pin1, pin2); | ||
1531 | } | ||
1532 | ret = ide_setup_pci_devices(dev, dev2, d); | ||
1533 | if (ret < 0) | ||
1534 | pci_dev_put(dev2); | ||
1535 | return ret; | ||
1536 | } | ||
1537 | init_single: | ||
1538 | return ide_setup_pci_device(dev, d); | ||
1539 | } | 1428 | } |
1540 | 1429 | ||
1541 | static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | 1430 | static ide_pci_device_t hpt366_chipsets[] __devinitdata = { |
1542 | { /* 0 */ | 1431 | { /* 0 */ |
1543 | .name = "HPT366", | 1432 | .name = "HPT36x", |
1544 | .init_setup = init_setup_hpt366, | ||
1545 | .init_chipset = init_chipset_hpt366, | 1433 | .init_chipset = init_chipset_hpt366, |
1546 | .init_hwif = init_hwif_hpt366, | 1434 | .init_hwif = init_hwif_hpt366, |
1547 | .init_dma = init_dma_hpt366, | 1435 | .init_dma = init_dma_hpt366, |
1548 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1436 | /* |
1437 | * HPT36x chips have one channel per function and have | ||
1438 | * both channel enable bits located differently and visible | ||
1439 | * to both functions -- really stupid design decision... :-( | ||
1440 | * Bit 4 is for the primary channel, bit 5 for the secondary. | ||
1441 | */ | ||
1442 | .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, | ||
1549 | .extra = 240, | 1443 | .extra = 240, |
1550 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, | 1444 | .host_flags = IDE_HFLAG_SINGLE | |
1445 | IDE_HFLAG_NO_ATAPI_DMA | | ||
1446 | IDE_HFLAG_OFF_BOARD, | ||
1551 | .pio_mask = ATA_PIO4, | 1447 | .pio_mask = ATA_PIO4, |
1552 | .mwdma_mask = ATA_MWDMA2, | 1448 | .mwdma_mask = ATA_MWDMA2, |
1553 | },{ /* 1 */ | 1449 | },{ /* 1 */ |
1554 | .name = "HPT372A", | 1450 | .name = "HPT372A", |
1555 | .init_setup = init_setup_hpt372a, | ||
1556 | .init_chipset = init_chipset_hpt366, | 1451 | .init_chipset = init_chipset_hpt366, |
1557 | .init_hwif = init_hwif_hpt366, | 1452 | .init_hwif = init_hwif_hpt366, |
1558 | .init_dma = init_dma_hpt366, | 1453 | .init_dma = init_dma_hpt366, |
1559 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1454 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1560 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | ||
1561 | .extra = 240, | 1455 | .extra = 240, |
1562 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, | 1456 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, |
1563 | .pio_mask = ATA_PIO4, | 1457 | .pio_mask = ATA_PIO4, |
1564 | .mwdma_mask = ATA_MWDMA2, | 1458 | .mwdma_mask = ATA_MWDMA2, |
1565 | },{ /* 2 */ | 1459 | },{ /* 2 */ |
1566 | .name = "HPT302", | 1460 | .name = "HPT302", |
1567 | .init_setup = init_setup_hpt302, | ||
1568 | .init_chipset = init_chipset_hpt366, | 1461 | .init_chipset = init_chipset_hpt366, |
1569 | .init_hwif = init_hwif_hpt366, | 1462 | .init_hwif = init_hwif_hpt366, |
1570 | .init_dma = init_dma_hpt366, | 1463 | .init_dma = init_dma_hpt366, |
1571 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1464 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1572 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | ||
1573 | .extra = 240, | 1465 | .extra = 240, |
1574 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, | 1466 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, |
1575 | .pio_mask = ATA_PIO4, | 1467 | .pio_mask = ATA_PIO4, |
1576 | .mwdma_mask = ATA_MWDMA2, | 1468 | .mwdma_mask = ATA_MWDMA2, |
1577 | },{ /* 3 */ | 1469 | },{ /* 3 */ |
1578 | .name = "HPT371", | 1470 | .name = "HPT371", |
1579 | .init_setup = init_setup_hpt371, | ||
1580 | .init_chipset = init_chipset_hpt366, | 1471 | .init_chipset = init_chipset_hpt366, |
1581 | .init_hwif = init_hwif_hpt366, | 1472 | .init_hwif = init_hwif_hpt366, |
1582 | .init_dma = init_dma_hpt366, | 1473 | .init_dma = init_dma_hpt366, |
1583 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1474 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1584 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | ||
1585 | .extra = 240, | 1475 | .extra = 240, |
1586 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, | 1476 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, |
1587 | .pio_mask = ATA_PIO4, | 1477 | .pio_mask = ATA_PIO4, |
1588 | .mwdma_mask = ATA_MWDMA2, | 1478 | .mwdma_mask = ATA_MWDMA2, |
1589 | },{ /* 4 */ | 1479 | },{ /* 4 */ |
1590 | .name = "HPT374", | 1480 | .name = "HPT374", |
1591 | .init_setup = init_setup_hpt374, | ||
1592 | .init_chipset = init_chipset_hpt366, | 1481 | .init_chipset = init_chipset_hpt366, |
1593 | .init_hwif = init_hwif_hpt366, | 1482 | .init_hwif = init_hwif_hpt366, |
1594 | .init_dma = init_dma_hpt366, | 1483 | .init_dma = init_dma_hpt366, |
@@ -1600,12 +1489,10 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1600 | .mwdma_mask = ATA_MWDMA2, | 1489 | .mwdma_mask = ATA_MWDMA2, |
1601 | },{ /* 5 */ | 1490 | },{ /* 5 */ |
1602 | .name = "HPT372N", | 1491 | .name = "HPT372N", |
1603 | .init_setup = init_setup_hpt372n, | ||
1604 | .init_chipset = init_chipset_hpt366, | 1492 | .init_chipset = init_chipset_hpt366, |
1605 | .init_hwif = init_hwif_hpt366, | 1493 | .init_hwif = init_hwif_hpt366, |
1606 | .init_dma = init_dma_hpt366, | 1494 | .init_dma = init_dma_hpt366, |
1607 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1495 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1608 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | ||
1609 | .extra = 240, | 1496 | .extra = 240, |
1610 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, | 1497 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD, |
1611 | .pio_mask = ATA_PIO4, | 1498 | .pio_mask = ATA_PIO4, |
@@ -1620,16 +1507,77 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | |||
1620 | * | 1507 | * |
1621 | * Called when the PCI registration layer (or the IDE initialization) | 1508 | * Called when the PCI registration layer (or the IDE initialization) |
1622 | * finds a device matching our IDE device tables. | 1509 | * finds a device matching our IDE device tables. |
1623 | * | ||
1624 | * NOTE: since we'll have to modify some fields of the ide_pci_device_t | ||
1625 | * structure depending on the chip's revision, we'd better pass a local | ||
1626 | * copy down the call chain... | ||
1627 | */ | 1510 | */ |
1628 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 1511 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
1629 | { | 1512 | { |
1630 | ide_pci_device_t d = hpt366_chipsets[id->driver_data]; | 1513 | struct hpt_info *info = NULL; |
1514 | struct pci_dev *dev2 = NULL; | ||
1515 | ide_pci_device_t d; | ||
1516 | u8 idx = id->driver_data; | ||
1517 | u8 rev = dev->revision; | ||
1518 | |||
1519 | if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1)) | ||
1520 | return -ENODEV; | ||
1521 | |||
1522 | switch (idx) { | ||
1523 | case 0: | ||
1524 | if (rev < 3) | ||
1525 | info = &hpt36x; | ||
1526 | else { | ||
1527 | static struct hpt_info *hpt37x_info[] = | ||
1528 | { &hpt370, &hpt370a, &hpt372, &hpt372n }; | ||
1529 | |||
1530 | info = hpt37x_info[min_t(u8, rev, 6) - 3]; | ||
1531 | idx++; | ||
1532 | } | ||
1533 | break; | ||
1534 | case 1: | ||
1535 | info = (rev > 1) ? &hpt372n : &hpt372a; | ||
1536 | break; | ||
1537 | case 2: | ||
1538 | info = (rev > 1) ? &hpt302n : &hpt302; | ||
1539 | break; | ||
1540 | case 3: | ||
1541 | hpt371_init(dev); | ||
1542 | info = (rev > 1) ? &hpt371n : &hpt371; | ||
1543 | break; | ||
1544 | case 4: | ||
1545 | info = &hpt374; | ||
1546 | break; | ||
1547 | case 5: | ||
1548 | info = &hpt372n; | ||
1549 | break; | ||
1550 | } | ||
1551 | |||
1552 | d = hpt366_chipsets[idx]; | ||
1553 | |||
1554 | d.name = info->chip_name; | ||
1555 | d.udma_mask = info->udma_mask; | ||
1556 | |||
1557 | pci_set_drvdata(dev, info); | ||
1558 | |||
1559 | if (info == &hpt36x || info == &hpt374) | ||
1560 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); | ||
1561 | |||
1562 | if (dev2) { | ||
1563 | int ret; | ||
1564 | |||
1565 | pci_set_drvdata(dev2, info); | ||
1566 | |||
1567 | if (info == &hpt374) | ||
1568 | hpt374_init(dev, dev2); | ||
1569 | else { | ||
1570 | if (hpt36x_init(dev, dev2)) | ||
1571 | d.host_flags |= IDE_HFLAG_BOOTABLE; | ||
1572 | } | ||
1573 | |||
1574 | ret = ide_setup_pci_devices(dev, dev2, &d); | ||
1575 | if (ret < 0) | ||
1576 | pci_dev_put(dev2); | ||
1577 | return ret; | ||
1578 | } | ||
1631 | 1579 | ||
1632 | return d.init_setup(dev, &d); | 1580 | return ide_setup_pci_device(dev, &d); |
1633 | } | 1581 | } |
1634 | 1582 | ||
1635 | static const struct pci_device_id hpt366_pci_tbl[] = { | 1583 | static const struct pci_device_id hpt366_pci_tbl[] = { |