diff options
Diffstat (limited to 'drivers/ata/pata_ali.c')
-rw-r--r-- | drivers/ata/pata_ali.c | 107 |
1 files changed, 70 insertions, 37 deletions
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index 73c466e452ca..a7999c19f0c9 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c | |||
@@ -19,7 +19,9 @@ | |||
19 | * | 19 | * |
20 | * TODO/CHECK | 20 | * TODO/CHECK |
21 | * Cannot have ATAPI on both master & slave for rev < c2 (???) but | 21 | * Cannot have ATAPI on both master & slave for rev < c2 (???) but |
22 | * otherwise should do atapi DMA. | 22 | * otherwise should do atapi DMA (For now for old we do PIO only for |
23 | * ATAPI) | ||
24 | * Review Sunblade workaround. | ||
23 | */ | 25 | */ |
24 | 26 | ||
25 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
@@ -33,12 +35,14 @@ | |||
33 | #include <linux/dmi.h> | 35 | #include <linux/dmi.h> |
34 | 36 | ||
35 | #define DRV_NAME "pata_ali" | 37 | #define DRV_NAME "pata_ali" |
36 | #define DRV_VERSION "0.7.5" | 38 | #define DRV_VERSION "0.7.8" |
37 | 39 | ||
38 | static int ali_atapi_dma = 0; | 40 | static int ali_atapi_dma = 0; |
39 | module_param_named(atapi_dma, ali_atapi_dma, int, 0644); | 41 | module_param_named(atapi_dma, ali_atapi_dma, int, 0644); |
40 | MODULE_PARM_DESC(atapi_dma, "Enable ATAPI DMA (0=disable, 1=enable)"); | 42 | MODULE_PARM_DESC(atapi_dma, "Enable ATAPI DMA (0=disable, 1=enable)"); |
41 | 43 | ||
44 | static struct pci_dev *isa_bridge; | ||
45 | |||
42 | /* | 46 | /* |
43 | * Cable special cases | 47 | * Cable special cases |
44 | */ | 48 | */ |
@@ -147,8 +151,7 @@ static void ali_fifo_control(struct ata_port *ap, struct ata_device *adev, int o | |||
147 | 151 | ||
148 | pci_read_config_byte(pdev, pio_fifo, &fifo); | 152 | pci_read_config_byte(pdev, pio_fifo, &fifo); |
149 | fifo &= ~(0x0F << shift); | 153 | fifo &= ~(0x0F << shift); |
150 | if (on) | 154 | fifo |= (on << shift); |
151 | fifo |= (on << shift); | ||
152 | pci_write_config_byte(pdev, pio_fifo, fifo); | 155 | pci_write_config_byte(pdev, pio_fifo, fifo); |
153 | } | 156 | } |
154 | 157 | ||
@@ -337,6 +340,23 @@ static int ali_check_atapi_dma(struct ata_queued_cmd *qc) | |||
337 | return 0; | 340 | return 0; |
338 | } | 341 | } |
339 | 342 | ||
343 | static void ali_c2_c3_postreset(struct ata_link *link, unsigned int *classes) | ||
344 | { | ||
345 | u8 r; | ||
346 | int port_bit = 4 << link->ap->port_no; | ||
347 | |||
348 | /* If our bridge is an ALI 1533 then do the extra work */ | ||
349 | if (isa_bridge) { | ||
350 | /* Tristate and re-enable the bus signals */ | ||
351 | pci_read_config_byte(isa_bridge, 0x58, &r); | ||
352 | r &= ~port_bit; | ||
353 | pci_write_config_byte(isa_bridge, 0x58, r); | ||
354 | r |= port_bit; | ||
355 | pci_write_config_byte(isa_bridge, 0x58, r); | ||
356 | } | ||
357 | ata_sff_postreset(link, classes); | ||
358 | } | ||
359 | |||
340 | static struct scsi_host_template ali_sht = { | 360 | static struct scsi_host_template ali_sht = { |
341 | ATA_BMDMA_SHT(DRV_NAME), | 361 | ATA_BMDMA_SHT(DRV_NAME), |
342 | }; | 362 | }; |
@@ -349,10 +369,11 @@ static struct ata_port_operations ali_early_port_ops = { | |||
349 | .inherits = &ata_sff_port_ops, | 369 | .inherits = &ata_sff_port_ops, |
350 | .cable_detect = ata_cable_40wire, | 370 | .cable_detect = ata_cable_40wire, |
351 | .set_piomode = ali_set_piomode, | 371 | .set_piomode = ali_set_piomode, |
372 | .sff_data_xfer = ata_sff_data_xfer32, | ||
352 | }; | 373 | }; |
353 | 374 | ||
354 | static const struct ata_port_operations ali_dma_base_ops = { | 375 | static const struct ata_port_operations ali_dma_base_ops = { |
355 | .inherits = &ata_bmdma_port_ops, | 376 | .inherits = &ata_bmdma32_port_ops, |
356 | .set_piomode = ali_set_piomode, | 377 | .set_piomode = ali_set_piomode, |
357 | .set_dmamode = ali_set_dmamode, | 378 | .set_dmamode = ali_set_dmamode, |
358 | }; | 379 | }; |
@@ -377,6 +398,17 @@ static struct ata_port_operations ali_c2_port_ops = { | |||
377 | .check_atapi_dma = ali_check_atapi_dma, | 398 | .check_atapi_dma = ali_check_atapi_dma, |
378 | .cable_detect = ali_c2_cable_detect, | 399 | .cable_detect = ali_c2_cable_detect, |
379 | .dev_config = ali_lock_sectors, | 400 | .dev_config = ali_lock_sectors, |
401 | .postreset = ali_c2_c3_postreset, | ||
402 | }; | ||
403 | |||
404 | /* | ||
405 | * Port operations for DMA capable ALi with cable detect | ||
406 | */ | ||
407 | static struct ata_port_operations ali_c4_port_ops = { | ||
408 | .inherits = &ali_dma_base_ops, | ||
409 | .check_atapi_dma = ali_check_atapi_dma, | ||
410 | .cable_detect = ali_c2_cable_detect, | ||
411 | .dev_config = ali_lock_sectors, | ||
380 | }; | 412 | }; |
381 | 413 | ||
382 | /* | 414 | /* |
@@ -401,52 +433,49 @@ static struct ata_port_operations ali_c5_port_ops = { | |||
401 | static void ali_init_chipset(struct pci_dev *pdev) | 433 | static void ali_init_chipset(struct pci_dev *pdev) |
402 | { | 434 | { |
403 | u8 tmp; | 435 | u8 tmp; |
404 | struct pci_dev *north, *isa_bridge; | 436 | struct pci_dev *north; |
405 | 437 | ||
406 | /* | 438 | /* |
407 | * The chipset revision selects the driver operations and | 439 | * The chipset revision selects the driver operations and |
408 | * mode data. | 440 | * mode data. |
409 | */ | 441 | */ |
410 | 442 | ||
411 | if (pdev->revision >= 0x20 && pdev->revision < 0xC2) { | 443 | if (pdev->revision <= 0x20) { |
412 | /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */ | 444 | pci_read_config_byte(pdev, 0x53, &tmp); |
413 | pci_read_config_byte(pdev, 0x4B, &tmp); | 445 | tmp |= 0x03; |
414 | /* Clear CD-ROM DMA write bit */ | 446 | pci_write_config_byte(pdev, 0x53, tmp); |
415 | tmp &= 0x7F; | 447 | } else { |
416 | pci_write_config_byte(pdev, 0x4B, tmp); | 448 | pci_read_config_byte(pdev, 0x4a, &tmp); |
417 | } else if (pdev->revision >= 0xC2) { | 449 | pci_write_config_byte(pdev, 0x4a, tmp | 0x20); |
418 | /* Enable cable detection logic */ | ||
419 | pci_read_config_byte(pdev, 0x4B, &tmp); | 450 | pci_read_config_byte(pdev, 0x4B, &tmp); |
420 | pci_write_config_byte(pdev, 0x4B, tmp | 0x08); | 451 | if (pdev->revision < 0xC2) |
421 | } | 452 | /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */ |
422 | north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); | 453 | /* Clear CD-ROM DMA write bit */ |
423 | isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); | 454 | tmp &= 0x7F; |
424 | 455 | /* Cable and UDMA */ | |
425 | if (north && north->vendor == PCI_VENDOR_ID_AL && isa_bridge) { | 456 | pci_write_config_byte(pdev, 0x4B, tmp | 0x09); |
426 | /* Configure the ALi bridge logic. For non ALi rely on BIOS. | ||
427 | Set the south bridge enable bit */ | ||
428 | pci_read_config_byte(isa_bridge, 0x79, &tmp); | ||
429 | if (pdev->revision == 0xC2) | ||
430 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04); | ||
431 | else if (pdev->revision > 0xC2 && pdev->revision < 0xC5) | ||
432 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02); | ||
433 | } | ||
434 | if (pdev->revision >= 0x20) { | ||
435 | /* | 457 | /* |
436 | * CD_ROM DMA on (0x53 bit 0). Enable this even if we want | 458 | * CD_ROM DMA on (0x53 bit 0). Enable this even if we want |
437 | * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control | 459 | * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control |
438 | * via 0x54/55. | 460 | * via 0x54/55. |
439 | */ | 461 | */ |
440 | pci_read_config_byte(pdev, 0x53, &tmp); | 462 | pci_read_config_byte(pdev, 0x53, &tmp); |
441 | if (pdev->revision <= 0x20) | ||
442 | tmp &= ~0x02; | ||
443 | if (pdev->revision >= 0xc7) | 463 | if (pdev->revision >= 0xc7) |
444 | tmp |= 0x03; | 464 | tmp |= 0x03; |
445 | else | 465 | else |
446 | tmp |= 0x01; /* CD_ROM enable for DMA */ | 466 | tmp |= 0x01; /* CD_ROM enable for DMA */ |
447 | pci_write_config_byte(pdev, 0x53, tmp); | 467 | pci_write_config_byte(pdev, 0x53, tmp); |
448 | } | 468 | } |
449 | pci_dev_put(isa_bridge); | 469 | north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); |
470 | if (north && north->vendor == PCI_VENDOR_ID_AL && isa_bridge) { | ||
471 | /* Configure the ALi bridge logic. For non ALi rely on BIOS. | ||
472 | Set the south bridge enable bit */ | ||
473 | pci_read_config_byte(isa_bridge, 0x79, &tmp); | ||
474 | if (pdev->revision == 0xC2) | ||
475 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04); | ||
476 | else if (pdev->revision > 0xC2 && pdev->revision < 0xC5) | ||
477 | pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02); | ||
478 | } | ||
450 | pci_dev_put(north); | 479 | pci_dev_put(north); |
451 | ata_pci_bmdma_clear_simplex(pdev); | 480 | ata_pci_bmdma_clear_simplex(pdev); |
452 | } | 481 | } |
@@ -503,7 +532,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
503 | .pio_mask = 0x1f, | 532 | .pio_mask = 0x1f, |
504 | .mwdma_mask = 0x07, | 533 | .mwdma_mask = 0x07, |
505 | .udma_mask = ATA_UDMA5, | 534 | .udma_mask = ATA_UDMA5, |
506 | .port_ops = &ali_c2_port_ops | 535 | .port_ops = &ali_c4_port_ops |
507 | }; | 536 | }; |
508 | /* Revision 0xC5 is UDMA133 with LBA48 DMA */ | 537 | /* Revision 0xC5 is UDMA133 with LBA48 DMA */ |
509 | static const struct ata_port_info info_c5 = { | 538 | static const struct ata_port_info info_c5 = { |
@@ -516,7 +545,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
516 | 545 | ||
517 | const struct ata_port_info *ppi[] = { NULL, NULL }; | 546 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
518 | u8 tmp; | 547 | u8 tmp; |
519 | struct pci_dev *isa_bridge; | ||
520 | int rc; | 548 | int rc; |
521 | 549 | ||
522 | rc = pcim_enable_device(pdev); | 550 | rc = pcim_enable_device(pdev); |
@@ -543,14 +571,12 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
543 | 571 | ||
544 | ali_init_chipset(pdev); | 572 | ali_init_chipset(pdev); |
545 | 573 | ||
546 | isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); | ||
547 | if (isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) { | 574 | if (isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) { |
548 | /* Are we paired with a UDMA capable chip */ | 575 | /* Are we paired with a UDMA capable chip */ |
549 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); | 576 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); |
550 | if ((tmp & 0x1E) == 0x12) | 577 | if ((tmp & 0x1E) == 0x12) |
551 | ppi[0] = &info_20_udma; | 578 | ppi[0] = &info_20_udma; |
552 | } | 579 | } |
553 | pci_dev_put(isa_bridge); | ||
554 | 580 | ||
555 | return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL); | 581 | return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL); |
556 | } | 582 | } |
@@ -590,13 +616,20 @@ static struct pci_driver ali_pci_driver = { | |||
590 | 616 | ||
591 | static int __init ali_init(void) | 617 | static int __init ali_init(void) |
592 | { | 618 | { |
593 | return pci_register_driver(&ali_pci_driver); | 619 | int ret; |
620 | isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); | ||
621 | |||
622 | ret = pci_register_driver(&ali_pci_driver); | ||
623 | if (ret < 0) | ||
624 | pci_dev_put(isa_bridge); | ||
625 | return ret; | ||
594 | } | 626 | } |
595 | 627 | ||
596 | 628 | ||
597 | static void __exit ali_exit(void) | 629 | static void __exit ali_exit(void) |
598 | { | 630 | { |
599 | pci_unregister_driver(&ali_pci_driver); | 631 | pci_unregister_driver(&ali_pci_driver); |
632 | pci_dev_put(isa_bridge); | ||
600 | } | 633 | } |
601 | 634 | ||
602 | 635 | ||