diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-03-07 11:56:54 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 14:15:56 -0400 |
commit | 97cb81c335565f3ce27cd26d71480dff0211797a (patch) | |
tree | 7430171dd00d04d2f99cadfe467f8c5a39851d89 /drivers/ata | |
parent | 2e413f510f1b77846e0e7728b991849e697d7f8b (diff) |
pata_via: Use cable_detect method
We end up shifting a few bits of logic around in this driver but the
basic change is the same.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/pata_via.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 946ade0e1f1b..96b71791d2f4 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -62,7 +62,7 @@ | |||
62 | #include <linux/libata.h> | 62 | #include <linux/libata.h> |
63 | 63 | ||
64 | #define DRV_NAME "pata_via" | 64 | #define DRV_NAME "pata_via" |
65 | #define DRV_VERSION "0.2.1" | 65 | #define DRV_VERSION "0.3.1" |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx | 68 | * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx |
@@ -135,16 +135,23 @@ static const struct via_isa_bridge { | |||
135 | */ | 135 | */ |
136 | 136 | ||
137 | static int via_cable_detect(struct ata_port *ap) { | 137 | static int via_cable_detect(struct ata_port *ap) { |
138 | const struct via_isa_bridge *config = ap->host->private_data; | ||
138 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 139 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
139 | u32 ata66; | 140 | u32 ata66; |
140 | 141 | ||
142 | /* Early chips are 40 wire */ | ||
143 | if ((config->flags & VIA_UDMA) < VIA_UDMA_66) | ||
144 | return ATA_CBL_PATA40; | ||
145 | /* UDMA 66 chips have only drive side logic */ | ||
146 | else if((config->flags & VIA_UDMA) < VIA_UDMA_100) | ||
147 | return ATA_CBL_PATA_UNK; | ||
148 | /* UDMA 100 or later */ | ||
141 | pci_read_config_dword(pdev, 0x50, &ata66); | 149 | pci_read_config_dword(pdev, 0x50, &ata66); |
142 | /* Check both the drive cable reporting bits, we might not have | 150 | /* Check both the drive cable reporting bits, we might not have |
143 | two drives */ | 151 | two drives */ |
144 | if (ata66 & (0x10100000 >> (16 * ap->port_no))) | 152 | if (ata66 & (0x10100000 >> (16 * ap->port_no))) |
145 | return ATA_CBL_PATA80; | 153 | return ATA_CBL_PATA80; |
146 | else | 154 | return ATA_CBL_PATA40; |
147 | return ATA_CBL_PATA40; | ||
148 | } | 155 | } |
149 | 156 | ||
150 | static int via_pre_reset(struct ata_port *ap) | 157 | static int via_pre_reset(struct ata_port *ap) |
@@ -156,22 +163,10 @@ static int via_pre_reset(struct ata_port *ap) | |||
156 | { 0x40, 1, 0x02, 0x02 }, | 163 | { 0x40, 1, 0x02, 0x02 }, |
157 | { 0x40, 1, 0x01, 0x01 } | 164 | { 0x40, 1, 0x01, 0x01 } |
158 | }; | 165 | }; |
159 | |||
160 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 166 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
161 | |||
162 | if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no])) | 167 | if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no])) |
163 | return -ENOENT; | 168 | return -ENOENT; |
164 | } | 169 | } |
165 | |||
166 | if ((config->flags & VIA_UDMA) >= VIA_UDMA_100) | ||
167 | ap->cbl = via_cable_detect(ap); | ||
168 | /* The UDMA66 series has no cable detect so do drive side detect */ | ||
169 | else if ((config->flags & VIA_UDMA) < VIA_UDMA_66) | ||
170 | ap->cbl = ATA_CBL_PATA40; | ||
171 | else | ||
172 | ap->cbl = ATA_CBL_PATA_UNK; | ||
173 | |||
174 | |||
175 | return ata_std_prereset(ap); | 170 | return ata_std_prereset(ap); |
176 | } | 171 | } |
177 | 172 | ||
@@ -327,6 +322,7 @@ static struct ata_port_operations via_port_ops = { | |||
327 | .thaw = ata_bmdma_thaw, | 322 | .thaw = ata_bmdma_thaw, |
328 | .error_handler = via_error_handler, | 323 | .error_handler = via_error_handler, |
329 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 324 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
325 | .cable_detect = via_cable_detect, | ||
330 | 326 | ||
331 | .bmdma_setup = ata_bmdma_setup, | 327 | .bmdma_setup = ata_bmdma_setup, |
332 | .bmdma_start = ata_bmdma_start, | 328 | .bmdma_start = ata_bmdma_start, |
@@ -362,6 +358,7 @@ static struct ata_port_operations via_port_ops_noirq = { | |||
362 | .thaw = ata_bmdma_thaw, | 358 | .thaw = ata_bmdma_thaw, |
363 | .error_handler = via_error_handler, | 359 | .error_handler = via_error_handler, |
364 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 360 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
361 | .cable_detect = via_cable_detect, | ||
365 | 362 | ||
366 | .bmdma_setup = ata_bmdma_setup, | 363 | .bmdma_setup = ata_bmdma_setup, |
367 | .bmdma_start = ata_bmdma_start, | 364 | .bmdma_start = ata_bmdma_start, |