ar71xx: ag71xx: check PHY IDs before accessing the switch registers
SVN-Revision: 29541
This commit is contained in:
parent
0655552860
commit
b7d7481b07
1 changed files with 8 additions and 9 deletions
|
@ -852,6 +852,14 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
|
||||||
u8 ver;
|
u8 ver;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1);
|
||||||
|
phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2);
|
||||||
|
if (phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) {
|
||||||
|
pr_err("%s: unknown phy id '%04x:%04x'\n",
|
||||||
|
ag->dev->name, phy_id1, phy_id2);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
as = kzalloc(sizeof(*as), GFP_KERNEL);
|
as = kzalloc(sizeof(*as), GFP_KERNEL);
|
||||||
if (!as)
|
if (!as)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -859,7 +867,6 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
|
||||||
as->mii_bus = mii;
|
as->mii_bus = mii;
|
||||||
|
|
||||||
ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL);
|
ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL);
|
||||||
|
|
||||||
ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) & AR7240_MASK_CTRL_VERSION_M;
|
ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) & AR7240_MASK_CTRL_VERSION_M;
|
||||||
if (ver != 1) {
|
if (ver != 1) {
|
||||||
pr_err("%s: unsupported chip, ctrl=%08x\n",
|
pr_err("%s: unsupported chip, ctrl=%08x\n",
|
||||||
|
@ -867,14 +874,6 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1);
|
|
||||||
phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2);
|
|
||||||
if (phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) {
|
|
||||||
pr_err("%s: unknown phy id '%04x:%04x'\n",
|
|
||||||
ag->dev->name, phy_id1, phy_id2);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
swdev = &as->swdev;
|
swdev = &as->swdev;
|
||||||
swdev->name = "AR7240 built-in switch";
|
swdev->name = "AR7240 built-in switch";
|
||||||
swdev->ports = AR7240_NUM_PORTS - 1;
|
swdev->ports = AR7240_NUM_PORTS - 1;
|
||||||
|
|
Loading…
Reference in a new issue