aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_hpt37x.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-08-31 00:03:49 -0400
committerJeff Garzik <jeff@garzik.org>2006-08-31 00:03:49 -0400
commit85cd7251b9112e3dabeac9fd3b175601ca607241 (patch)
treeb33b80f54883e224a586661165bd0aee2c47ed39 /drivers/ata/pata_hpt37x.c
parent481ff126e8d9be63809e7854badf815e54066eed (diff)
[libata #pata-drivers] Trim trailing whitespace.
Diffstat (limited to 'drivers/ata/pata_hpt37x.c')
-rw-r--r--drivers/ata/pata_hpt37x.c138
1 files changed, 69 insertions, 69 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 7c3da53f1e0c..532a7928f803 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -134,7 +134,7 @@ static const struct hpt_clock hpt370a_timings_66[] = {
134 { XFER_UDMA_0, 0x14a0e73f }, 134 { XFER_UDMA_0, 0x14a0e73f },
135 135
136 { XFER_MW_DMA_2, 0x2480fa73 }, 136 { XFER_MW_DMA_2, 0x2480fa73 },
137 { XFER_MW_DMA_1, 0x2480fa77 }, 137 { XFER_MW_DMA_1, 0x2480fa77 },
138 { XFER_MW_DMA_0, 0x2480fb3f }, 138 { XFER_MW_DMA_0, 0x2480fb3f },
139 139
140 { XFER_PIO_4, 0x0c82be73 }, 140 { XFER_PIO_4, 0x0c82be73 },
@@ -333,11 +333,11 @@ static const struct hpt_chip hpt374 = {
333 * Return the 32bit register programming information for this channel 333 * Return the 32bit register programming information for this channel
334 * that matches the speed provided. 334 * that matches the speed provided.
335 */ 335 */
336 336
337static u32 hpt37x_find_mode(struct ata_port *ap, int speed) 337static u32 hpt37x_find_mode(struct ata_port *ap, int speed)
338{ 338{
339 struct hpt_clock *clocks = ap->host->private_data; 339 struct hpt_clock *clocks = ap->host->private_data;
340 340
341 while(clocks->xfer_speed) { 341 while(clocks->xfer_speed) {
342 if (clocks->xfer_speed == speed) 342 if (clocks->xfer_speed == speed)
343 return clocks->timing; 343 return clocks->timing;
@@ -367,7 +367,7 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, cons
367 367
368 while(list[i] != NULL) { 368 while(list[i] != NULL) {
369 if (!strncmp(list[i], s, len)) { 369 if (!strncmp(list[i], s, len)) {
370 printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n", 370 printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n",
371 modestr, list[i]); 371 modestr, list[i]);
372 return 1; 372 return 1;
373 } 373 }
@@ -413,7 +413,7 @@ static const char *bad_ata100_5[] = {
413 * 413 *
414 * Block UDMA on devices that cause trouble with this controller. 414 * Block UDMA on devices that cause trouble with this controller.
415 */ 415 */
416 416
417static unsigned long hpt370_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask) 417static unsigned long hpt370_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask)
418{ 418{
419 if (adev->class != ATA_DEV_ATA) { 419 if (adev->class != ATA_DEV_ATA) {
@@ -432,7 +432,7 @@ static unsigned long hpt370_filter(const struct ata_port *ap, struct ata_device
432 * 432 *
433 * Block UDMA on devices that cause trouble with this controller. 433 * Block UDMA on devices that cause trouble with this controller.
434 */ 434 */
435 435
436static unsigned long hpt370a_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask) 436static unsigned long hpt370a_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask)
437{ 437{
438 if (adev->class != ATA_DEV_ATA) { 438 if (adev->class != ATA_DEV_ATA) {
@@ -441,36 +441,36 @@ static unsigned long hpt370a_filter(const struct ata_port *ap, struct ata_device
441 } 441 }
442 return ata_pci_default_filter(ap, adev, mask); 442 return ata_pci_default_filter(ap, adev, mask);
443} 443}
444 444
445/** 445/**
446 * hpt37x_pre_reset - reset the hpt37x bus 446 * hpt37x_pre_reset - reset the hpt37x bus
447 * @ap: ATA port to reset 447 * @ap: ATA port to reset
448 * 448 *
449 * Perform the initial reset handling for the 370/372 and 374 func 0 449 * Perform the initial reset handling for the 370/372 and 374 func 0
450 */ 450 */
451 451
452static int hpt37x_pre_reset(struct ata_port *ap) 452static int hpt37x_pre_reset(struct ata_port *ap)
453{ 453{
454 u8 scr2, ata66; 454 u8 scr2, ata66;
455 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 455 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
456 456
457 pci_read_config_byte(pdev, 0x5B, &scr2); 457 pci_read_config_byte(pdev, 0x5B, &scr2);
458 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 458 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
459 /* Cable register now active */ 459 /* Cable register now active */
460 pci_read_config_byte(pdev, 0x5A, &ata66); 460 pci_read_config_byte(pdev, 0x5A, &ata66);
461 /* Restore state */ 461 /* Restore state */
462 pci_write_config_byte(pdev, 0x5B, scr2); 462 pci_write_config_byte(pdev, 0x5B, scr2);
463 463
464 if (ata66 & (1 << ap->port_no)) 464 if (ata66 & (1 << ap->port_no))
465 ap->cbl = ATA_CBL_PATA40; 465 ap->cbl = ATA_CBL_PATA40;
466 else 466 else
467 ap->cbl = ATA_CBL_PATA80; 467 ap->cbl = ATA_CBL_PATA80;
468 468
469 /* Reset the state machine */ 469 /* Reset the state machine */
470 pci_write_config_byte(pdev, 0x50, 0x37); 470 pci_write_config_byte(pdev, 0x50, 0x37);
471 pci_write_config_byte(pdev, 0x54, 0x37); 471 pci_write_config_byte(pdev, 0x54, 0x37);
472 udelay(100); 472 udelay(100);
473 473
474 return ata_std_prereset(ap); 474 return ata_std_prereset(ap);
475} 475}
476 476
@@ -480,7 +480,7 @@ static int hpt37x_pre_reset(struct ata_port *ap)
480 * 480 *
481 * Perform probe for HPT37x, except for HPT374 channel 2 481 * Perform probe for HPT37x, except for HPT374 channel 2
482 */ 482 */
483 483
484static void hpt37x_error_handler(struct ata_port *ap) 484static void hpt37x_error_handler(struct ata_port *ap)
485{ 485{
486 ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset); 486 ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
@@ -490,7 +490,7 @@ static int hpt374_pre_reset(struct ata_port *ap)
490{ 490{
491 u16 mcr3, mcr6; 491 u16 mcr3, mcr6;
492 u8 ata66; 492 u8 ata66;
493 493
494 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 494 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
495 /* Do the extra channel work */ 495 /* Do the extra channel work */
496 pci_read_config_word(pdev, 0x52, &mcr3); 496 pci_read_config_word(pdev, 0x52, &mcr3);
@@ -504,17 +504,17 @@ static int hpt374_pre_reset(struct ata_port *ap)
504 /* Reset TCBLID/FCBLID to output */ 504 /* Reset TCBLID/FCBLID to output */
505 pci_write_config_word(pdev, 0x52, mcr3); 505 pci_write_config_word(pdev, 0x52, mcr3);
506 pci_write_config_word(pdev, 0x56, mcr6); 506 pci_write_config_word(pdev, 0x56, mcr6);
507 507
508 if (ata66 & (1 << ap->port_no)) 508 if (ata66 & (1 << ap->port_no))
509 ap->cbl = ATA_CBL_PATA40; 509 ap->cbl = ATA_CBL_PATA40;
510 else 510 else
511 ap->cbl = ATA_CBL_PATA80; 511 ap->cbl = ATA_CBL_PATA80;
512 512
513 /* Reset the state machine */ 513 /* Reset the state machine */
514 pci_write_config_byte(pdev, 0x50, 0x37); 514 pci_write_config_byte(pdev, 0x50, 0x37);
515 pci_write_config_byte(pdev, 0x54, 0x37); 515 pci_write_config_byte(pdev, 0x54, 0x37);
516 udelay(100); 516 udelay(100);
517 517
518 return ata_std_prereset(ap); 518 return ata_std_prereset(ap);
519} 519}
520 520
@@ -526,11 +526,11 @@ static int hpt374_pre_reset(struct ata_port *ap)
526 * channels. The function 0 channels work like usual but function 1 526 * channels. The function 0 channels work like usual but function 1
527 * is special 527 * is special
528 */ 528 */
529 529
530static void hpt374_error_handler(struct ata_port *ap) 530static void hpt374_error_handler(struct ata_port *ap)
531{ 531{
532 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 532 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
533 533
534 if (!(PCI_FUNC(pdev->devfn) & 1)) 534 if (!(PCI_FUNC(pdev->devfn) & 1))
535 hpt37x_error_handler(ap); 535 hpt37x_error_handler(ap);
536 else 536 else
@@ -542,9 +542,9 @@ static void hpt374_error_handler(struct ata_port *ap)
542 * @ap: ATA interface 542 * @ap: ATA interface
543 * @adev: device on the interface 543 * @adev: device on the interface
544 * 544 *
545 * Perform PIO mode setup. 545 * Perform PIO mode setup.
546 */ 546 */
547 547
548static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev) 548static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
549{ 549{
550 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 550 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -555,13 +555,13 @@ static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
555 555
556 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 556 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
557 addr2 = 0x51 + 4 * ap->port_no; 557 addr2 = 0x51 + 4 * ap->port_no;
558 558
559 /* Fast interrupt prediction disable, hold off interrupt disable */ 559 /* Fast interrupt prediction disable, hold off interrupt disable */
560 pci_read_config_byte(pdev, addr2, &fast); 560 pci_read_config_byte(pdev, addr2, &fast);
561 fast &= ~0x02; 561 fast &= ~0x02;
562 fast |= 0x01; 562 fast |= 0x01;
563 pci_write_config_byte(pdev, addr2, fast); 563 pci_write_config_byte(pdev, addr2, fast);
564 564
565 pci_read_config_dword(pdev, addr1, &reg); 565 pci_read_config_dword(pdev, addr1, &reg);
566 mode = hpt37x_find_mode(ap, adev->pio_mode); 566 mode = hpt37x_find_mode(ap, adev->pio_mode);
567 mode &= ~0x8000000; /* No FIFO in PIO */ 567 mode &= ~0x8000000; /* No FIFO in PIO */
@@ -578,7 +578,7 @@ static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
578 * Set up the channel for MWDMA or UDMA modes. Much the same as with 578 * Set up the channel for MWDMA or UDMA modes. Much the same as with
579 * PIO, load the mode number and then set MWDMA or UDMA flag. 579 * PIO, load the mode number and then set MWDMA or UDMA flag.
580 */ 580 */
581 581
582static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev) 582static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev)
583{ 583{
584 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 584 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -589,13 +589,13 @@ static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev)
589 589
590 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 590 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
591 addr2 = 0x51 + 4 * ap->port_no; 591 addr2 = 0x51 + 4 * ap->port_no;
592 592
593 /* Fast interrupt prediction disable, hold off interrupt disable */ 593 /* Fast interrupt prediction disable, hold off interrupt disable */
594 pci_read_config_byte(pdev, addr2, &fast); 594 pci_read_config_byte(pdev, addr2, &fast);
595 fast &= ~0x02; 595 fast &= ~0x02;
596 fast |= 0x01; 596 fast |= 0x01;
597 pci_write_config_byte(pdev, addr2, fast); 597 pci_write_config_byte(pdev, addr2, fast);
598 598
599 pci_read_config_dword(pdev, addr1, &reg); 599 pci_read_config_dword(pdev, addr1, &reg);
600 mode = hpt37x_find_mode(ap, adev->dma_mode); 600 mode = hpt37x_find_mode(ap, adev->dma_mode);
601 mode |= 0x8000000; /* FIFO in MWDMA or UDMA */ 601 mode |= 0x8000000; /* FIFO in MWDMA or UDMA */
@@ -611,7 +611,7 @@ static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev)
611 * The 370 and 370A want us to reset the DMA engine each time we 611 * The 370 and 370A want us to reset the DMA engine each time we
612 * use it. The 372 and later are fine. 612 * use it. The 372 and later are fine.
613 */ 613 */
614 614
615static void hpt370_bmdma_start(struct ata_queued_cmd *qc) 615static void hpt370_bmdma_start(struct ata_queued_cmd *qc)
616{ 616{
617 struct ata_port *ap = qc->ap; 617 struct ata_port *ap = qc->ap;
@@ -627,7 +627,7 @@ static void hpt370_bmdma_start(struct ata_queued_cmd *qc)
627 * 627 *
628 * Work around the HPT370 DMA engine. 628 * Work around the HPT370 DMA engine.
629 */ 629 */
630 630
631static void hpt370_bmdma_stop(struct ata_queued_cmd *qc) 631static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
632{ 632{
633 struct ata_port *ap = qc->ap; 633 struct ata_port *ap = qc->ap;
@@ -635,7 +635,7 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
635 u8 dma_stat = inb(ap->ioaddr.bmdma_addr + 2); 635 u8 dma_stat = inb(ap->ioaddr.bmdma_addr + 2);
636 u8 dma_cmd; 636 u8 dma_cmd;
637 unsigned long bmdma = ap->ioaddr.bmdma_addr; 637 unsigned long bmdma = ap->ioaddr.bmdma_addr;
638 638
639 if (dma_stat & 0x01) { 639 if (dma_stat & 0x01) {
640 udelay(20); 640 udelay(20);
641 dma_stat = inb(bmdma + 2); 641 dma_stat = inb(bmdma + 2);
@@ -662,9 +662,9 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
662 * @ap: ATA interface 662 * @ap: ATA interface
663 * @adev: device on the interface 663 * @adev: device on the interface
664 * 664 *
665 * Perform PIO mode setup. 665 * Perform PIO mode setup.
666 */ 666 */
667 667
668static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev) 668static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
669{ 669{
670 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 670 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -675,15 +675,15 @@ static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
675 675
676 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 676 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
677 addr2 = 0x51 + 4 * ap->port_no; 677 addr2 = 0x51 + 4 * ap->port_no;
678 678
679 /* Fast interrupt prediction disable, hold off interrupt disable */ 679 /* Fast interrupt prediction disable, hold off interrupt disable */
680 pci_read_config_byte(pdev, addr2, &fast); 680 pci_read_config_byte(pdev, addr2, &fast);
681 fast &= ~0x07; 681 fast &= ~0x07;
682 pci_write_config_byte(pdev, addr2, fast); 682 pci_write_config_byte(pdev, addr2, fast);
683 683
684 pci_read_config_dword(pdev, addr1, &reg); 684 pci_read_config_dword(pdev, addr1, &reg);
685 mode = hpt37x_find_mode(ap, adev->pio_mode); 685 mode = hpt37x_find_mode(ap, adev->pio_mode);
686 686
687 printk("Find mode for %d reports %X\n", adev->pio_mode, mode); 687 printk("Find mode for %d reports %X\n", adev->pio_mode, mode);
688 mode &= ~0x80000000; /* No FIFO in PIO */ 688 mode &= ~0x80000000; /* No FIFO in PIO */
689 mode &= ~0x30070000; /* Leave config bits alone */ 689 mode &= ~0x30070000; /* Leave config bits alone */
@@ -699,7 +699,7 @@ static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
699 * Set up the channel for MWDMA or UDMA modes. Much the same as with 699 * Set up the channel for MWDMA or UDMA modes. Much the same as with
700 * PIO, load the mode number and then set MWDMA or UDMA flag. 700 * PIO, load the mode number and then set MWDMA or UDMA flag.
701 */ 701 */
702 702
703static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev) 703static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev)
704{ 704{
705 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 705 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -710,12 +710,12 @@ static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev)
710 710
711 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 711 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
712 addr2 = 0x51 + 4 * ap->port_no; 712 addr2 = 0x51 + 4 * ap->port_no;
713 713
714 /* Fast interrupt prediction disable, hold off interrupt disable */ 714 /* Fast interrupt prediction disable, hold off interrupt disable */
715 pci_read_config_byte(pdev, addr2, &fast); 715 pci_read_config_byte(pdev, addr2, &fast);
716 fast &= ~0x07; 716 fast &= ~0x07;
717 pci_write_config_byte(pdev, addr2, fast); 717 pci_write_config_byte(pdev, addr2, fast);
718 718
719 pci_read_config_dword(pdev, addr1, &reg); 719 pci_read_config_dword(pdev, addr1, &reg);
720 mode = hpt37x_find_mode(ap, adev->dma_mode); 720 mode = hpt37x_find_mode(ap, adev->dma_mode);
721 printk("Find mode for DMA %d reports %X\n", adev->dma_mode, mode); 721 printk("Find mode for DMA %d reports %X\n", adev->dma_mode, mode);
@@ -731,14 +731,14 @@ static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev)
731 * 731 *
732 * Clean up after the HPT372 and later DMA engine 732 * Clean up after the HPT372 and later DMA engine
733 */ 733 */
734 734
735static void hpt37x_bmdma_stop(struct ata_queued_cmd *qc) 735static void hpt37x_bmdma_stop(struct ata_queued_cmd *qc)
736{ 736{
737 struct ata_port *ap = qc->ap; 737 struct ata_port *ap = qc->ap;
738 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 738 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
739 int mscreg = 0x50 + 2 * ap->port_no; 739 int mscreg = 0x50 + 2 * ap->port_no;
740 u8 bwsr_stat, msc_stat; 740 u8 bwsr_stat, msc_stat;
741 741
742 pci_read_config_byte(pdev, 0x6A, &bwsr_stat); 742 pci_read_config_byte(pdev, 0x6A, &bwsr_stat);
743 pci_read_config_byte(pdev, mscreg, &msc_stat); 743 pci_read_config_byte(pdev, mscreg, &msc_stat);
744 if (bwsr_stat & (1 << ap->port_no)) 744 if (bwsr_stat & (1 << ap->port_no))
@@ -768,13 +768,13 @@ static struct scsi_host_template hpt37x_sht = {
768/* 768/*
769 * Configuration for HPT370 769 * Configuration for HPT370
770 */ 770 */
771 771
772static struct ata_port_operations hpt370_port_ops = { 772static struct ata_port_operations hpt370_port_ops = {
773 .port_disable = ata_port_disable, 773 .port_disable = ata_port_disable,
774 .set_piomode = hpt370_set_piomode, 774 .set_piomode = hpt370_set_piomode,
775 .set_dmamode = hpt370_set_dmamode, 775 .set_dmamode = hpt370_set_dmamode,
776 .mode_filter = hpt370_filter, 776 .mode_filter = hpt370_filter,
777 777
778 .tf_load = ata_tf_load, 778 .tf_load = ata_tf_load,
779 .tf_read = ata_tf_read, 779 .tf_read = ata_tf_read,
780 .check_status = ata_check_status, 780 .check_status = ata_check_status,
@@ -802,18 +802,18 @@ static struct ata_port_operations hpt370_port_ops = {
802 .port_start = ata_port_start, 802 .port_start = ata_port_start,
803 .port_stop = ata_port_stop, 803 .port_stop = ata_port_stop,
804 .host_stop = ata_host_stop 804 .host_stop = ata_host_stop
805}; 805};
806 806
807/* 807/*
808 * Configuration for HPT370A. Close to 370 but less filters 808 * Configuration for HPT370A. Close to 370 but less filters
809 */ 809 */
810 810
811static struct ata_port_operations hpt370a_port_ops = { 811static struct ata_port_operations hpt370a_port_ops = {
812 .port_disable = ata_port_disable, 812 .port_disable = ata_port_disable,
813 .set_piomode = hpt370_set_piomode, 813 .set_piomode = hpt370_set_piomode,
814 .set_dmamode = hpt370_set_dmamode, 814 .set_dmamode = hpt370_set_dmamode,
815 .mode_filter = hpt370a_filter, 815 .mode_filter = hpt370a_filter,
816 816
817 .tf_load = ata_tf_load, 817 .tf_load = ata_tf_load,
818 .tf_read = ata_tf_read, 818 .tf_read = ata_tf_read,
819 .check_status = ata_check_status, 819 .check_status = ata_check_status,
@@ -841,19 +841,19 @@ static struct ata_port_operations hpt370a_port_ops = {
841 .port_start = ata_port_start, 841 .port_start = ata_port_start,
842 .port_stop = ata_port_stop, 842 .port_stop = ata_port_stop,
843 .host_stop = ata_host_stop 843 .host_stop = ata_host_stop
844}; 844};
845 845
846/* 846/*
847 * Configuration for HPT372, HPT371, HPT302. Slightly different PIO 847 * Configuration for HPT372, HPT371, HPT302. Slightly different PIO
848 * and DMA mode setting functionality. 848 * and DMA mode setting functionality.
849 */ 849 */
850 850
851static struct ata_port_operations hpt372_port_ops = { 851static struct ata_port_operations hpt372_port_ops = {
852 .port_disable = ata_port_disable, 852 .port_disable = ata_port_disable,
853 .set_piomode = hpt372_set_piomode, 853 .set_piomode = hpt372_set_piomode,
854 .set_dmamode = hpt372_set_dmamode, 854 .set_dmamode = hpt372_set_dmamode,
855 .mode_filter = ata_pci_default_filter, 855 .mode_filter = ata_pci_default_filter,
856 856
857 .tf_load = ata_tf_load, 857 .tf_load = ata_tf_load,
858 .tf_read = ata_tf_read, 858 .tf_read = ata_tf_read,
859 .check_status = ata_check_status, 859 .check_status = ata_check_status,
@@ -881,19 +881,19 @@ static struct ata_port_operations hpt372_port_ops = {
881 .port_start = ata_port_start, 881 .port_start = ata_port_start,
882 .port_stop = ata_port_stop, 882 .port_stop = ata_port_stop,
883 .host_stop = ata_host_stop 883 .host_stop = ata_host_stop
884}; 884};
885 885
886/* 886/*
887 * Configuration for HPT374. Mode setting works like 372 and friends 887 * Configuration for HPT374. Mode setting works like 372 and friends
888 * but we have a different cable detection procedure. 888 * but we have a different cable detection procedure.
889 */ 889 */
890 890
891static struct ata_port_operations hpt374_port_ops = { 891static struct ata_port_operations hpt374_port_ops = {
892 .port_disable = ata_port_disable, 892 .port_disable = ata_port_disable,
893 .set_piomode = hpt372_set_piomode, 893 .set_piomode = hpt372_set_piomode,
894 .set_dmamode = hpt372_set_dmamode, 894 .set_dmamode = hpt372_set_dmamode,
895 .mode_filter = ata_pci_default_filter, 895 .mode_filter = ata_pci_default_filter,
896 896
897 .tf_load = ata_tf_load, 897 .tf_load = ata_tf_load,
898 .tf_read = ata_tf_read, 898 .tf_read = ata_tf_read,
899 .check_status = ata_check_status, 899 .check_status = ata_check_status,
@@ -921,7 +921,7 @@ static struct ata_port_operations hpt374_port_ops = {
921 .port_start = ata_port_start, 921 .port_start = ata_port_start,
922 .port_stop = ata_port_stop, 922 .port_stop = ata_port_stop,
923 .host_stop = ata_host_stop 923 .host_stop = ata_host_stop
924}; 924};
925 925
926/** 926/**
927 * htp37x_clock_slot - Turn timing to PC clock entry 927 * htp37x_clock_slot - Turn timing to PC clock entry
@@ -931,7 +931,7 @@ static struct ata_port_operations hpt374_port_ops = {
931 * Turn the timing data intoa clock slot (0 for 33, 1 for 40, 2 for 50 931 * Turn the timing data intoa clock slot (0 for 33, 1 for 40, 2 for 50
932 * and 3 for 66Mhz) 932 * and 3 for 66Mhz)
933 */ 933 */
934 934
935static int hpt37x_clock_slot(unsigned int freq, unsigned int base) 935static int hpt37x_clock_slot(unsigned int freq, unsigned int base)
936{ 936{
937 unsigned int f = (base * freq) / 192; /* Mhz */ 937 unsigned int f = (base * freq) / 192; /* Mhz */
@@ -946,7 +946,7 @@ static int hpt37x_clock_slot(unsigned int freq, unsigned int base)
946 946
947/** 947/**
948 * hpt37x_calibrate_dpll - Calibrate the DPLL loop 948 * hpt37x_calibrate_dpll - Calibrate the DPLL loop
949 * @dev: PCI device 949 * @dev: PCI device
950 * 950 *
951 * Perform a calibration cycle on the HPT37x DPLL. Returns 1 if this 951 * Perform a calibration cycle on the HPT37x DPLL. Returns 1 if this
952 * succeeds 952 * succeeds
@@ -957,7 +957,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
957 u8 reg5b; 957 u8 reg5b;
958 u32 reg5c; 958 u32 reg5c;
959 int tries; 959 int tries;
960 960
961 for(tries = 0; tries < 0x5000; tries++) { 961 for(tries = 0; tries < 0x5000; tries++) {
962 udelay(50); 962 udelay(50);
963 pci_read_config_byte(dev, 0x5b, &reg5b); 963 pci_read_config_byte(dev, 0x5b, &reg5b);
@@ -1009,7 +1009,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
1009 * 1009 *
1010 * (1) UDMA133 support depends on the bus clock 1010 * (1) UDMA133 support depends on the bus clock
1011 */ 1011 */
1012 1012
1013static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 1013static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1014{ 1014{
1015 /* HPT370 - UDMA100 */ 1015 /* HPT370 - UDMA100 */
@@ -1072,7 +1072,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1072 1072
1073 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 1073 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
1074 class_rev &= 0xFF; 1074 class_rev &= 0xFF;
1075 1075
1076 if (dev->device == PCI_DEVICE_ID_TTI_HPT366) { 1076 if (dev->device == PCI_DEVICE_ID_TTI_HPT366) {
1077 /* May be a later chip in disguise. Check */ 1077 /* May be a later chip in disguise. Check */
1078 /* Older chips are in the HPT366 driver. Ignore them */ 1078 /* Older chips are in the HPT366 driver. Ignore them */
@@ -1082,7 +1082,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1082 if (class_rev == 6) 1082 if (class_rev == 6)
1083 return -ENODEV; 1083 return -ENODEV;
1084 1084
1085 switch(class_rev) { 1085 switch(class_rev) {
1086 case 3: 1086 case 3:
1087 port = &info_hpt370; 1087 port = &info_hpt370;
1088 chip_table = &hpt370; 1088 chip_table = &hpt370;
@@ -1147,16 +1147,16 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1147 * state on reset when PDIAG is a input. 1147 * state on reset when PDIAG is a input.
1148 */ 1148 */
1149 1149
1150 pci_write_config_byte(dev, 0x5b, 0x23); 1150 pci_write_config_byte(dev, 0x5b, 0x23);
1151 1151
1152 pci_read_config_dword(dev, 0x70, &freq); 1152 pci_read_config_dword(dev, 0x70, &freq);
1153 if ((freq >> 12) != 0xABCDE) { 1153 if ((freq >> 12) != 0xABCDE) {
1154 int i; 1154 int i;
1155 u8 sr; 1155 u8 sr;
1156 u32 total = 0; 1156 u32 total = 0;
1157 1157
1158 printk(KERN_WARNING "pata_hpt37x: BIOS has not set timing clocks.\n"); 1158 printk(KERN_WARNING "pata_hpt37x: BIOS has not set timing clocks.\n");
1159 1159
1160 /* This is the process the HPT371 BIOS is reported to use */ 1160 /* This is the process the HPT371 BIOS is reported to use */
1161 for(i = 0; i < 128; i++) { 1161 for(i = 0; i < 128; i++) {
1162 pci_read_config_byte(dev, 0x78, &sr); 1162 pci_read_config_byte(dev, 0x78, &sr);
@@ -1166,12 +1166,12 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1166 freq = total / 128; 1166 freq = total / 128;
1167 } 1167 }
1168 freq &= 0x1FF; 1168 freq &= 0x1FF;
1169 1169
1170 /* 1170 /*
1171 * Turn the frequency check into a band and then find a timing 1171 * Turn the frequency check into a band and then find a timing
1172 * table to match it. 1172 * table to match it.
1173 */ 1173 */
1174 1174
1175 clock_slot = hpt37x_clock_slot(freq, chip_table->base); 1175 clock_slot = hpt37x_clock_slot(freq, chip_table->base);
1176 if (chip_table->clocks[clock_slot] == NULL) { 1176 if (chip_table->clocks[clock_slot] == NULL) {
1177 /* 1177 /*
@@ -1180,7 +1180,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1180 unsigned int f_low = (MHz[clock_slot] * chip_table->base) / 192; 1180 unsigned int f_low = (MHz[clock_slot] * chip_table->base) / 192;
1181 unsigned int f_high = f_low + 2; 1181 unsigned int f_high = f_low + 2;
1182 int adjust; 1182 int adjust;
1183 1183
1184 for(adjust = 0; adjust < 8; adjust++) { 1184 for(adjust = 0; adjust < 8; adjust++) {
1185 if (hpt37x_calibrate_dpll(dev)) 1185 if (hpt37x_calibrate_dpll(dev))
1186 break; 1186 break;
@@ -1197,7 +1197,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1197 } 1197 }
1198 /* Check if this works for all cases */ 1198 /* Check if this works for all cases */
1199 port->private_data = (void *)hpt370_timings_66; 1199 port->private_data = (void *)hpt370_timings_66;
1200 1200
1201 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); 1201 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]);
1202 } else { 1202 } else {
1203 port->private_data = (void *)chip_table->clocks[clock_slot]; 1203 port->private_data = (void *)chip_table->clocks[clock_slot];
@@ -1205,7 +1205,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1205 * Perform a final fixup. The 371 and 372 clock determines 1205 * Perform a final fixup. The 371 and 372 clock determines
1206 * if UDMA133 is available. 1206 * if UDMA133 is available.
1207 */ 1207 */
1208 1208
1209 if (clock_slot == 2 && chip_table == &hpt372) { /* 50Mhz */ 1209 if (clock_slot == 2 && chip_table == &hpt372) { /* 50Mhz */
1210 printk(KERN_WARNING "pata_hpt37x: No UDMA133 support available with 50MHz bus clock.\n"); 1210 printk(KERN_WARNING "pata_hpt37x: No UDMA133 support available with 50MHz bus clock.\n");
1211 if (port == &info_hpt372) 1211 if (port == &info_hpt372)
@@ -1214,7 +1214,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1214 } 1214 }
1215 printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); 1215 printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]);
1216 } 1216 }
1217 port_info[0] = port_info[1] = port; 1217 port_info[0] = port_info[1] = port;
1218 /* Now kick off ATA set up */ 1218 /* Now kick off ATA set up */
1219 return ata_pci_init_one(dev, port_info, 2); 1219 return ata_pci_init_one(dev, port_info, 2);
1220} 1220}