1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-25 08:03:20 +02:00

generic: ar8216: set chip type directly in ar8216_id_chip

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30854 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2012-03-08 10:21:10 +00:00
parent 1130aa078f
commit 7c5576c278

View File

@ -137,9 +137,11 @@ ar8216_id_chip(struct ar8216_priv *priv)
u16 id; u16 id;
int i; int i;
priv->chip = UNKNOWN;
val = ar8216_mii_read(priv, AR8216_REG_CTRL); val = ar8216_mii_read(priv, AR8216_REG_CTRL);
if (val == ~0) if (val == ~0)
return UNKNOWN; return -ENODEV;
id = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION); id = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION);
for (i = 0; i < AR8X16_PROBE_RETRIES; i++) { for (i = 0; i < AR8X16_PROBE_RETRIES; i++) {
@ -147,21 +149,24 @@ ar8216_id_chip(struct ar8216_priv *priv)
val = ar8216_mii_read(priv, AR8216_REG_CTRL); val = ar8216_mii_read(priv, AR8216_REG_CTRL);
if (val == ~0) if (val == ~0)
return UNKNOWN; return -ENODEV;
t = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION); t = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION);
if (t != id) if (t != id)
return UNKNOWN; return -ENODEV;
} }
switch (id) { switch (id) {
case 0x0101: case 0x0101:
return AR8216; priv->chip = AR8216;
break;
case 0x0301: case 0x0301:
return AR8236; priv->chip = AR8236;
break;
case 0x1000: case 0x1000:
case 0x1001: case 0x1001:
return AR8316; priv->chip = AR8316;
break;
default: default:
printk(KERN_DEBUG printk(KERN_DEBUG
"ar8216: Unknown Atheros device [ver=%d, rev=%d, phy_id=%04x%04x]\n", "ar8216: Unknown Atheros device [ver=%d, rev=%d, phy_id=%04x%04x]\n",
@ -170,8 +175,10 @@ ar8216_id_chip(struct ar8216_priv *priv)
mdiobus_read(priv->phy->bus, priv->phy->addr, 2), mdiobus_read(priv->phy->bus, priv->phy->addr, 2),
mdiobus_read(priv->phy->bus, priv->phy->addr, 3)); mdiobus_read(priv->phy->bus, priv->phy->addr, 3));
return UNKNOWN; return -ENODEV;
} }
return 0;
} }
static void static void
@ -821,7 +828,9 @@ ar8216_config_init(struct phy_device *pdev)
priv->phy = pdev; priv->phy = pdev;
priv->chip = ar8216_id_chip(priv); ret = ar8216_id_chip(priv);
if (ret)
goto err_free_priv;
if (pdev->addr != 0) { if (pdev->addr != 0) {
if (priv->chip == AR8316) { if (priv->chip == AR8316) {
@ -990,14 +999,9 @@ static int
ar8216_probe(struct phy_device *pdev) ar8216_probe(struct phy_device *pdev)
{ {
struct ar8216_priv priv; struct ar8216_priv priv;
u16 chip;
priv.phy = pdev; priv.phy = pdev;
chip = ar8216_id_chip(&priv); return ar8216_id_chip(&priv);
if (chip == UNKNOWN)
return -ENODEV;
return 0;
} }
static void static void