aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_legacy.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2011-10-13 09:06:56 -0400
committerJeff Garzik <jgarzik@redhat.com>2011-10-14 13:27:03 -0400
commit8c7e8f947f8068b01f798def52318f97e1338ee1 (patch)
tree047cf4c7555ddf6e841f9d283d81b34ed4b5f1ed /drivers/ata/pata_legacy.c
parent0dcd0a76370a526d4bc844d82d54c717eb40e042 (diff)
pata_legacy: unify QDI ->set_piomode methods
Add controller type field to struct legacy_data and then use it to merge together all ->set_piomode methods for QDI controllers. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/pata_legacy.c')
-rw-r--r--drivers/ata/pata_legacy.c98
1 files changed, 23 insertions, 75 deletions
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index e71fdfbf69b3..21d402c6dd56 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -79,15 +79,6 @@ static int all;
79module_param(all, int, 0444); 79module_param(all, int, 0444);
80MODULE_PARM_DESC(all, "Grab all legacy port devices, even if PCI(0=off, 1=on)"); 80MODULE_PARM_DESC(all, "Grab all legacy port devices, even if PCI(0=off, 1=on)");
81 81
82struct legacy_data {
83 unsigned long timing;
84 u8 clock[2];
85 u8 last;
86 int fast;
87 struct platform_device *platform_dev;
88
89};
90
91enum controller { 82enum controller {
92 BIOS = 0, 83 BIOS = 0,
93 SNOOP = 1, 84 SNOOP = 1,
@@ -104,6 +95,14 @@ enum controller {
104 UNKNOWN = -1 95 UNKNOWN = -1
105}; 96};
106 97
98struct legacy_data {
99 unsigned long timing;
100 u8 clock[2];
101 u8 last;
102 int fast;
103 enum controller type;
104 struct platform_device *platform_dev;
105};
107 106
108struct legacy_probe { 107struct legacy_probe {
109 unsigned char *name; 108 unsigned char *name;
@@ -637,40 +636,20 @@ static struct ata_port_operations opti82c46x_port_ops = {
637 .qc_issue = opti82c46x_qc_issue, 636 .qc_issue = opti82c46x_qc_issue,
638}; 637};
639 638
640static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev)
641{
642 struct ata_timing t;
643 struct legacy_data *ld_qdi = ap->host->private_data;
644 int active, recovery;
645 u8 timing;
646
647 /* Get the timing data in cycles */
648 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
649
650 if (ld_qdi->fast) {
651 active = 8 - clamp_val(t.active, 1, 8);
652 recovery = 18 - clamp_val(t.recover, 3, 18);
653 } else {
654 active = 9 - clamp_val(t.active, 2, 9);
655 recovery = 15 - clamp_val(t.recover, 0, 15);
656 }
657 timing = (recovery << 4) | active | 0x08;
658
659 ld_qdi->clock[adev->devno] = timing;
660
661 outb(timing, ld_qdi->timing);
662}
663
664/** 639/**
665 * qdi6580dp_set_piomode - PIO setup for dual channel 640 * qdi65x0_set_piomode - PIO setup for QDI65x0
666 * @ap: Port 641 * @ap: Port
667 * @adev: Device 642 * @adev: Device
668 * 643 *
644 * In single channel mode the 6580 has one clock per device and we can
645 * avoid the requirement to clock switch. We also have to load the timing
646 * into the right clock according to whether we are master or slave.
647 *
669 * In dual channel mode the 6580 has one clock per channel and we have 648 * In dual channel mode the 6580 has one clock per channel and we have
670 * to software clockswitch in qc_issue. 649 * to software clockswitch in qc_issue.
671 */ 650 */
672 651
673static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev) 652static void qdi65x0_set_piomode(struct ata_port *ap, struct ata_device *adev)
674{ 653{
675 struct ata_timing t; 654 struct ata_timing t;
676 struct legacy_data *ld_qdi = ap->host->private_data; 655 struct legacy_data *ld_qdi = ap->host->private_data;
@@ -688,47 +667,15 @@ static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev)
688 recovery = 15 - clamp_val(t.recover, 0, 15); 667 recovery = 15 - clamp_val(t.recover, 0, 15);
689 } 668 }
690 timing = (recovery << 4) | active | 0x08; 669 timing = (recovery << 4) | active | 0x08;
691
692 ld_qdi->clock[adev->devno] = timing; 670 ld_qdi->clock[adev->devno] = timing;
693 671
694 outb(timing, ld_qdi->timing + 2 * ap->port_no); 672 if (ld_qdi->type == QDI6580)
695 /* Clear the FIFO */ 673 outb(timing, ld_qdi->timing + 2 * adev->devno);
696 if (adev->class != ATA_DEV_ATA) 674 else
697 outb(0x5F, (ld_qdi->timing & 0xFFF0) + 3); 675 outb(timing, ld_qdi->timing + 2 * ap->port_no);
698}
699
700/**
701 * qdi6580_set_piomode - PIO setup for single channel
702 * @ap: Port
703 * @adev: Device
704 *
705 * In single channel mode the 6580 has one clock per device and we can
706 * avoid the requirement to clock switch. We also have to load the timing
707 * into the right clock according to whether we are master or slave.
708 */
709
710static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev)
711{
712 struct ata_timing t;
713 struct legacy_data *ld_qdi = ap->host->private_data;
714 int active, recovery;
715 u8 timing;
716
717 /* Get the timing data in cycles */
718 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
719 676
720 if (ld_qdi->fast) {
721 active = 8 - clamp_val(t.active, 1, 8);
722 recovery = 18 - clamp_val(t.recover, 3, 18);
723 } else {
724 active = 9 - clamp_val(t.active, 2, 9);
725 recovery = 15 - clamp_val(t.recover, 0, 15);
726 }
727 timing = (recovery << 4) | active | 0x08;
728 ld_qdi->clock[adev->devno] = timing;
729 outb(timing, ld_qdi->timing + 2 * adev->devno);
730 /* Clear the FIFO */ 677 /* Clear the FIFO */
731 if (adev->class != ATA_DEV_ATA) 678 if (ld_qdi->type != QDI6500 && adev->class != ATA_DEV_ATA)
732 outb(0x5F, (ld_qdi->timing & 0xFFF0) + 3); 679 outb(0x5F, (ld_qdi->timing & 0xFFF0) + 3);
733} 680}
734 681
@@ -795,20 +742,20 @@ static int qdi_port(struct platform_device *dev,
795 742
796static struct ata_port_operations qdi6500_port_ops = { 743static struct ata_port_operations qdi6500_port_ops = {
797 .inherits = &legacy_base_port_ops, 744 .inherits = &legacy_base_port_ops,
798 .set_piomode = qdi6500_set_piomode, 745 .set_piomode = qdi65x0_set_piomode,
799 .qc_issue = qdi_qc_issue, 746 .qc_issue = qdi_qc_issue,
800 .sff_data_xfer = vlb32_data_xfer, 747 .sff_data_xfer = vlb32_data_xfer,
801}; 748};
802 749
803static struct ata_port_operations qdi6580_port_ops = { 750static struct ata_port_operations qdi6580_port_ops = {
804 .inherits = &legacy_base_port_ops, 751 .inherits = &legacy_base_port_ops,
805 .set_piomode = qdi6580_set_piomode, 752 .set_piomode = qdi65x0_set_piomode,
806 .sff_data_xfer = vlb32_data_xfer, 753 .sff_data_xfer = vlb32_data_xfer,
807}; 754};
808 755
809static struct ata_port_operations qdi6580dp_port_ops = { 756static struct ata_port_operations qdi6580dp_port_ops = {
810 .inherits = &legacy_base_port_ops, 757 .inherits = &legacy_base_port_ops,
811 .set_piomode = qdi6580dp_set_piomode, 758 .set_piomode = qdi65x0_set_piomode,
812 .qc_issue = qdi_qc_issue, 759 .qc_issue = qdi_qc_issue,
813 .sff_data_xfer = vlb32_data_xfer, 760 .sff_data_xfer = vlb32_data_xfer,
814}; 761};
@@ -1028,6 +975,7 @@ static __init int legacy_init_one(struct legacy_probe *probe)
1028 ctrl_addr = devm_ioport_map(&pdev->dev, io + 0x0206, 1); 975 ctrl_addr = devm_ioport_map(&pdev->dev, io + 0x0206, 1);
1029 if (!io_addr || !ctrl_addr) 976 if (!io_addr || !ctrl_addr)
1030 goto fail; 977 goto fail;
978 ld->type = probe->type;
1031 if (controller->setup) 979 if (controller->setup)
1032 if (controller->setup(pdev, probe, ld) < 0) 980 if (controller->setup(pdev, probe, ld) < 0)
1033 goto fail; 981 goto fail;