[PATCH] CS5536: fix overly optimistic cable detect (handle libataAPI imprecision).

From: Andreas Mohr
Date: Wed Jul 17 2013 - 12:49:58 EST


We unconditionally indicated 80-pin cable capability
in case *any* of Master/Slave devices had 80c cable presence
configure-indicated by the BIOS.
This, however, does not seem at all appropriate since CS5536
does manage its primary IDE's master/slave devices independently,
both in cable detect and timing programming.
Since libata does not offer API support for such per-device
configurations yet, we really need to restrict things to the lowest
common denominator.

Signed-off-by: Andreas Mohr <andim2@xxxxxxxxxxxx>
---
drivers/ata/pata_cs5536.c | 34 +++++++++++++++++++++++++++++++---
1 Datei geändert, 31 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c
index 0448860..f58bf04 100644
--- a/drivers/ata/pata_cs5536.c
+++ b/drivers/ata/pata_cs5536.c
@@ -146,10 +146,38 @@ static int cs5536_cable_detect(struct ata_port *ap)

cs5536_read(pdev, CFG, &cfg);

- if (cfg & IDE_CFG_CABLE)
- return ATA_CBL_PATA80;
- else
+ /*
+ * FIXME libata API limitation:
+ * CS5536 data sheet says
+ * "The IDE interface timing is completely programmable.
+ * Timing control covers the command active and recover pulse
+ * widths, and command block register accesses. The IDE
+ * data transfer speed for each device on each channel can
+ * be independently programmed allowing high speed IDE
+ * peripherals to co-exist on the same channel as older,
+ * compatible devices." and it does have per-drive-separate
+ * cable detect and timing programming bits for primary Master/Slave
+ * and in fact some devices (e.g. PCM-9375) do have e.g.
+ * directly-soldered (read: ~80c) CompactFlash primary Master
+ * and a 44pin (read: 40c) IDE primary Slave.
+ * However, libata only offers whole-ata_port cable detect callback
+ * that's arguably too imprecise for such hardware capabilities.
+ * Given this imprecision, we arguably are required for now
+ * to indicate the lowest common denominator, i.e. 40c in case
+ * *any* of Master/Slave does not indicate 80c support,
+ * in order to avoid imposing incorrect timing to the
+ * per-device-separate timing programming.
+ * This care seems especially important given evidence of
+ * existing other timing issues of CS5536:
+ * see errata 47 "UDMA Mode 5 stability issues" in PDF
+ * "AMD Geode (tm) CS5536 Companion Device Silicon Revision B1
+ * Specification Update".
+ */
+ bool have_any_40c_only_device = (cfg & IDE_CFG_CABLE) < IDE_CFG_CABLE;
+ if (have_any_40c_only_device)
return ATA_CBL_PATA40;
+ else
+ return ATA_CBL_PATA80;
}

/**
--
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/