From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 6/7] smc911x: update chip detection
Date: Tue, 14 Aug 2012 19:32:19 +0200 [thread overview]
Message-ID: <1344965540-31534-6-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1344965540-31534-1-git-send-email-plagnioj@jcrosoft.com>
Use linux kernel chip detection from 3.5
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/net/smc911x.c | 59 +++++++++++++++++++++++++++----------------------
drivers/net/smc911x.h | 33 +++++++++++++++++----------
2 files changed, 54 insertions(+), 38 deletions(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 67d82df..021a194 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -48,29 +48,12 @@ struct smc911x_priv {
u32 width;
int shift;
+ int generation;
u32 (*reg_read)(struct smc911x_priv *priv, u32 reg);
void (*reg_write)(struct smc911x_priv *priv, u32 reg, u32 val);
};
-struct chip_id {
- u16 id;
- char *name;
-};
-
-static const struct chip_id chip_ids[] = {
- { CHIP_9115, "LAN9115" },
- { CHIP_9116, "LAN9116" },
- { CHIP_9117, "LAN9117" },
- { CHIP_9118, "LAN9118" },
- { CHIP_9215, "LAN9215" },
- { CHIP_9216, "LAN9216" },
- { CHIP_9217, "LAN9217" },
- { CHIP_9218, "LAN9218" },
- { CHIP_9221, "LAN9221" },
- { 0, NULL },
-};
-
#define DRIVERNAME "smc911x"
#define __smc_shift(priv, reg) ((reg) << ((priv)->shift))
@@ -429,7 +412,6 @@ static int smc911x_probe(struct device_d *dev)
struct eth_device *edev;
struct smc911x_priv *priv;
uint32_t val;
- int i;
struct smc911x_plat *pdata = dev->platform_data;
priv = xzalloc(sizeof(*priv));
@@ -474,16 +456,41 @@ static int smc911x_probe(struct device_d *dev)
return -ENODEV;
}
- val = smc911x_reg_read(priv, ID_REV) >> 16;
- for(i = 0; chip_ids[i].id != 0; i++) {
- if (chip_ids[i].id == val) break;
- }
- if (!chip_ids[i].id) {
- dev_err(dev, "Unknown chip ID %04x\n", val);
+ val = smc911x_reg_read(priv, ID_REV);
+ switch (val & 0xFFFF0000) {
+ case 0x01180000:
+ case 0x01170000:
+ case 0x01160000:
+ case 0x01150000:
+ case 0x218A0000:
+ /* LAN911[5678] family */
+ priv->generation = val & 0x0000FFFF;
+ break;
+
+ case 0x118A0000:
+ case 0x117A0000:
+ case 0x116A0000:
+ case 0x115A0000:
+ /* LAN921[5678] family */
+ priv->generation = 3;
+ break;
+
+ case 0x92100000:
+ case 0x92110000:
+ case 0x92200000:
+ case 0x92210000:
+ /* LAN9210/LAN9211/LAN9220/LAN9221 */
+ priv->generation = 4;
+ break;
+
+ default:
+ dev_err(dev, "LAN911x not identified, idrev: 0x%08X\n",
+ val);
return -ENODEV;
}
- dev_info(dev, "detected %s controller\n", chip_ids[i].name);
+ dev_info(dev, "LAN911x identified, idrev: 0x%08X, generation: %d\n",
+ val, priv->generation);
edev = &priv->edev;
edev->priv = priv;
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index d409247..623e192 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -341,15 +341,24 @@
#define WUCSR_WAKE_EN 0x00000004
#define WUCSR_MPEN 0x00000002
-/* Chip ID values */
-#define CHIP_9115 0x115
-#define CHIP_9116 0x116
-#define CHIP_9117 0x117
-#define CHIP_9118 0x118
-#define CHIP_9215 0x115a
-#define CHIP_9216 0x116a
-#define CHIP_9217 0x117a
-#define CHIP_9218 0x118a
-#define CHIP_9221 0x9221
-
-
+/* SMSC PHY */
+#define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */
+#define MII_LAN83C185_IM 30 /* Interrupt Mask */
+#define MII_LAN83C185_CTRL_STATUS 17 /* Mode/Status Register */
+
+#define MII_LAN83C185_ISF_INT1 (1<<1) /* Auto-Negotiation Page Received */
+#define MII_LAN83C185_ISF_INT2 (1<<2) /* Parallel Detection Fault */
+#define MII_LAN83C185_ISF_INT3 (1<<3) /* Auto-Negotiation LP Ack */
+#define MII_LAN83C185_ISF_INT4 (1<<4) /* Link Down */
+#define MII_LAN83C185_ISF_INT5 (1<<5) /* Remote Fault Detected */
+#define MII_LAN83C185_ISF_INT6 (1<<6) /* Auto-Negotiation complete */
+#define MII_LAN83C185_ISF_INT7 (1<<7) /* ENERGYON */
+
+#define MII_LAN83C185_ISF_INT_ALL (0x0e)
+
+#define MII_LAN83C185_ISF_INT_PHYLIB_EVENTS \
+ (MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4 | \
+ MII_LAN83C185_ISF_INT7)
+
+#define MII_LAN83C185_EDPWRDOWN (1 << 13) /* EDPWRDOWN */
+#define MII_LAN83C185_ENERGYON (1 << 1) /* ENERGYON */
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-08-14 17:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-14 17:25 [PATCH 0/7] smsc911x: runtime configuration improvement Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:32 ` [PATCH 1/7] smc911x: move register define to smc911x.h Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:32 ` [PATCH 2/7] smc911x: introduce read/write ops Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:32 ` [PATCH 3/7] smc911x: add 16bit bus width support Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 20:21 ` Sascha Hauer
2012-08-15 4:30 ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 14:20 ` Sascha Hauer
2012-08-14 17:32 ` [PATCH 4/7] smc911x: add support to pass the shift via platform data Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:32 ` [PATCH 5/7] smc911x: improve detection handle Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:32 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-08-14 17:32 ` [PATCH 7/7] smm911x: check if the device is ready before using it Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 20:19 ` [PATCH 1/7] smc911x: move register define to smc911x.h Sascha Hauer
2012-08-15 4:34 ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-29 4:27 [PATCH 0/7 2] smsc911x: runtime configuration improvement Jean-Christophe PLAGNIOL-VILLARD
2012-08-29 5:06 ` [PATCH 1/7] smc911x: move register define to smc911x.h Jean-Christophe PLAGNIOL-VILLARD
2012-08-29 5:06 ` [PATCH 6/7] smc911x: update chip detection Jean-Christophe PLAGNIOL-VILLARD
2012-09-01 8:47 [PATCH 0/7 v3] smsc911x: runtime configuration improvement Jean-Christophe PLAGNIOL-VILLARD
2012-09-01 8:52 ` [PATCH 1/7] smc911x: move register define to smc911x.h Jean-Christophe PLAGNIOL-VILLARD
2012-09-01 8:52 ` [PATCH 6/7] smc911x: update chip detection Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1344965540-31534-6-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox