summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-09-01 10:52:42 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-03 09:49:06 +0200
commitfb11747bfeb0227bfbcce667c7e486b0440f78e4 (patch)
treeaff9f924e8cb74b68db7d0e5a3db16042153ea02
parent655dc6b8aa3b1b1340d257a33b6e05569e089f25 (diff)
downloadbarebox-fb11747bfeb0227bfbcce667c7e486b0440f78e4.tar.gz
barebox-fb11747bfeb0227bfbcce667c7e486b0440f78e4.tar.xz
smc911x: improve detection handle
detect if the bus is swapped and report a 32bit drivers is used on a 16bit bus Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/net/smc911x.c21
-rw-r--r--drivers/net/smc911x.h2
2 files changed, 22 insertions, 1 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 75a332e134..8528527549 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -470,9 +470,28 @@ static int smc911x_probe(struct device_d *dev)
}
val = smc911x_reg_read(priv, BYTE_TEST);
- if(val != 0x87654321) {
+ if (val == 0x43218765) {
+ dev_dbg(dev, "BYTE_TEST looks swapped, "
+ "applying WORD_SWAP");
+ smc911x_reg_write(priv, WORD_SWAP, 0xffffffff);
+
+ /* 1 dummy read of BYTE_TEST is needed after a write to
+ * WORD_SWAP before its contents are valid */
+ val = smc911x_reg_read(priv, BYTE_TEST);
+
+ val = smc911x_reg_read(priv, BYTE_TEST);
+ }
+
+ if (val != 0x87654321) {
dev_err(dev, "no smc911x found on 0x%p (byte_test=0x%08x)\n",
priv->base, val);
+ if (((val >> 16) & 0xFFFF) == (val & 0xFFFF)) {
+ /*
+ * This may mean the chip is set
+ * for 32 bit while the bus is reading 16 bit
+ */
+ dev_err(dev, "top 16 bits equal to bottom 16 bits\n");
+ }
return -ENODEV;
}
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index baf359848c..d409247e6f 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -26,6 +26,8 @@
* of the Lan911x memory space
*/
+#define WORD_SWAP 0x98
+
#define RX_DATA_FIFO 0x00
#define TX_DATA_FIFO 0x20