aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-12-18 02:33:06 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:12 -0500
commit021ee9a6da1cfc57f6a6c769c3c898bdd4753108 (patch)
treebb8c0246ded5a1d99320055343c7d277208fadd8
parenta0f79b929acaba10d4780acd2543eff20bf4b5b0 (diff)
libata: reimplement ata_acpi_cbl_80wire() using ata_acpi_gtm_xfermask()
Reimplement ata_acpi_cbl_80wire() using ata_acpi_gtm_xfermask() and while at it relocate the function below ata_acpi_gtm_xfermask(). New ata_acpi_cbl_80wire() implementation takes @gtm, in both pata_via and pata_amd, use the initial GTM value. Both are trying to peek initial BIOS configuration, so using initial caching value makes sense. This fixes ACPI part of cable detection in pata_amd which previously always returned 0 because configuring PIO0 during reset clears DMA configuration. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/ata/libata-acpi.c41
-rw-r--r--drivers/ata/pata_amd.c3
-rw-r--r--drivers/ata/pata_via.c3
-rw-r--r--include/linux/libata.h10
4 files changed, 27 insertions, 30 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index a6f1a6b56d8c..9e8ec19260af 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -490,38 +490,29 @@ EXPORT_SYMBOL_GPL(ata_acpi_gtm_xfermask);
490/** 490/**
491 * ata_acpi_cbl_80wire - Check for 80 wire cable 491 * ata_acpi_cbl_80wire - Check for 80 wire cable
492 * @ap: Port to check 492 * @ap: Port to check
493 * @gtm: GTM data to use
493 * 494 *
494 * Return 1 if the ACPI mode data for this port indicates the BIOS selected 495 * Return 1 if the @gtm indicates the BIOS selected an 80wire mode.
495 * an 80wire mode.
496 */ 496 */
497 497int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm)
498int ata_acpi_cbl_80wire(struct ata_port *ap)
499{ 498{
500 const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); 499 struct ata_device *dev;
501 int valid = 0;
502 500
503 if (!gtm) 501 ata_link_for_each_dev(dev, &ap->link) {
504 return 0; 502 unsigned long xfer_mask, udma_mask;
503
504 if (!ata_dev_enabled(dev))
505 continue;
506
507 xfer_mask = ata_acpi_gtm_xfermask(dev, gtm);
508 ata_unpack_xfermask(xfer_mask, NULL, NULL, &udma_mask);
509
510 if (udma_mask & ~ATA_UDMA_MASK_40C)
511 return 1;
512 }
505 513
506 /* Split timing, DMA enabled */
507 if ((gtm->flags & 0x11) == 0x11 && gtm->drive[0].dma < 55)
508 valid |= 1;
509 if ((gtm->flags & 0x14) == 0x14 && gtm->drive[1].dma < 55)
510 valid |= 2;
511 /* Shared timing, DMA enabled */
512 if ((gtm->flags & 0x11) == 0x01 && gtm->drive[0].dma < 55)
513 valid |= 1;
514 if ((gtm->flags & 0x14) == 0x04 && gtm->drive[0].dma < 55)
515 valid |= 2;
516
517 /* Drive check */
518 if ((valid & 1) && ata_dev_enabled(&ap->link.device[0]))
519 return 1;
520 if ((valid & 2) && ata_dev_enabled(&ap->link.device[1]))
521 return 1;
522 return 0; 514 return 0;
523} 515}
524
525EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); 516EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire);
526 517
527static void ata_acpi_gtf_to_tf(struct ata_device *dev, 518static void ata_acpi_gtf_to_tf(struct ata_device *dev,
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 3cc27b514654..e71125a4bd9b 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -272,7 +272,8 @@ static int nv_cable_detect(struct ata_port *ap)
272 if ((udma & 0xC4) == 0xC4 || (udma & 0xC400) == 0xC400) 272 if ((udma & 0xC4) == 0xC4 || (udma & 0xC400) == 0xC400)
273 cbl = ATA_CBL_PATA80; 273 cbl = ATA_CBL_PATA80;
274 /* And a triple check across suspend/resume with ACPI around */ 274 /* And a triple check across suspend/resume with ACPI around */
275 if (ata_acpi_cbl_80wire(ap)) 275 if (ata_acpi_init_gtm(ap) &&
276 ata_acpi_cbl_80wire(ap, ata_acpi_init_gtm(ap)))
276 cbl = ATA_CBL_PATA80; 277 cbl = ATA_CBL_PATA80;
277 return cbl; 278 return cbl;
278} 279}
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 453d72bf2598..39627ab684bf 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -185,7 +185,8 @@ static int via_cable_detect(struct ata_port *ap) {
185 if (ata66 & (0x10100000 >> (16 * ap->port_no))) 185 if (ata66 & (0x10100000 >> (16 * ap->port_no)))
186 return ATA_CBL_PATA80; 186 return ATA_CBL_PATA80;
187 /* Check with ACPI so we can spot BIOS reported SATA bridges */ 187 /* Check with ACPI so we can spot BIOS reported SATA bridges */
188 if (ata_acpi_cbl_80wire(ap)) 188 if (ata_acpi_init_gtm(ap) &&
189 ata_acpi_cbl_80wire(ap, ata_acpi_init_gtm(ap)))
189 return ATA_CBL_PATA80; 190 return ATA_CBL_PATA80;
190 return ATA_CBL_PATA40; 191 return ATA_CBL_PATA40;
191} 192}
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 8ede93b5c7a6..cc4eaef6f889 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -968,18 +968,16 @@ static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
968 return &ap->__acpi_init_gtm; 968 return &ap->__acpi_init_gtm;
969 return NULL; 969 return NULL;
970} 970}
971extern int ata_acpi_cbl_80wire(struct ata_port *ap);
972int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); 971int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm);
973int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); 972int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm);
974unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, 973unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
975 const struct ata_acpi_gtm *gtm); 974 const struct ata_acpi_gtm *gtm);
976 975int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm);
977#else 976#else
978static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) 977static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
979{ 978{
980 return NULL; 979 return NULL;
981} 980}
982static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; }
983 981
984static inline int ata_acpi_stm(const struct ata_port *ap, 982static inline int ata_acpi_stm(const struct ata_port *ap,
985 struct ata_acpi_gtm *stm) 983 struct ata_acpi_gtm *stm)
@@ -998,6 +996,12 @@ static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev,
998{ 996{
999 return 0; 997 return 0;
1000} 998}
999
1000static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
1001 const struct ata_acpi_gtm *gtm)
1002{
1003 return 0;
1004}
1001#endif 1005#endif
1002 1006
1003#ifdef CONFIG_PCI 1007#ifdef CONFIG_PCI