diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2010-04-09 08:40:12 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2010-04-09 08:40:12 +0000 |
commit | c1278631d6aab1843680afc71443558ce4da7fa1 (patch) | |
tree | 1dfb2d2be562d070e7b869ae41ce1ad0fa08cfeb /target/linux/generic-2.6/files/drivers | |
parent | da7993d9f857f10427b74630e9250ca50ef65019 (diff) | |
download | master-187ad058-c1278631d6aab1843680afc71443558ce4da7fa1.tar.gz master-187ad058-c1278631d6aab1843680afc71443558ce4da7fa1.tar.bz2 master-187ad058-c1278631d6aab1843680afc71443558ce4da7fa1.zip |
generic: make chip detection more reliable in the AR8216 driver
Fixes broken ethernet on the Planex MZK-W04NU/W300NH boards.
Cc: bacfire@openwrt.org
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20753 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic-2.6/files/drivers')
-rw-r--r-- | target/linux/generic-2.6/files/drivers/net/phy/ar8216.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/target/linux/generic-2.6/files/drivers/net/phy/ar8216.c b/target/linux/generic-2.6/files/drivers/net/phy/ar8216.c index 394e50d479..a473e3b181 100644 --- a/target/linux/generic-2.6/files/drivers/net/phy/ar8216.c +++ b/target/linux/generic-2.6/files/drivers/net/phy/ar8216.c @@ -33,6 +33,7 @@ /* size of the vlan table */ #define AR8X16_MAX_VLANS 128 +#define AR8X16_PROBE_RETRIES 10 struct ar8216_priv { struct switch_dev dev; @@ -119,8 +120,25 @@ ar8216_id_chip(struct ar8216_priv *priv) { u32 val; u16 id; + int i; + val = ar8216_mii_read(priv, AR8216_REG_CTRL); + if (val == ~0) + return UNKNOWN; + id = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION); + for (i = 0; i < AR8X16_PROBE_RETRIES; i++) { + u16 t; + + val = ar8216_mii_read(priv, AR8216_REG_CTRL); + if (val == ~0) + return UNKNOWN; + + t = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION); + if (t != id) + return UNKNOWN; + } + switch (id) { case 0x0101: return AR8216; @@ -736,11 +754,13 @@ static int ar8216_probe(struct phy_device *pdev) { struct ar8216_priv priv; + u16 chip; priv.phy = pdev; - if (ar8216_id_chip(&priv) == UNKNOWN) { + chip = ar8216_id_chip(&priv); + if (chip == UNKNOWN) return -ENODEV; - } + return 0; } |