aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-02-10 19:02:01 +0000
committerGabor Juhos <juhosg@openwrt.org>2013-02-10 19:02:01 +0000
commit617076c6130d5eb1be1741f7f1265e89fe3187ab (patch)
treed7665c3f5a5519c0b270f25d2b411cbd1242150b /target/linux/generic
parent98b13e39ac63ab6ff2d69287b16a465669d68db1 (diff)
downloadupstream-617076c6130d5eb1be1741f7f1265e89fe3187ab.tar.gz
upstream-617076c6130d5eb1be1741f7f1265e89fe3187ab.tar.bz2
upstream-617076c6130d5eb1be1741f7f1265e89fe3187ab.zip
generic: ar8216: add ar8xxx_probe_switch helper
Signed-off-by: Gabor Juhos <juhosg@openwrt.org> SVN-Revision: 35547
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/files/drivers/net/phy/ar8216.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 2edd415778..c0b51e7c67 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -1803,6 +1803,45 @@ ar8xxx_create_mii(struct mii_bus *bus)
}
static int
+ar8xxx_probe_switch(struct ar8216_priv *priv)
+{
+ struct switch_dev *swdev;
+ int ret;
+
+ ret = ar8216_id_chip(priv);
+ if (ret)
+ return ret;
+
+ swdev = &priv->dev;
+ swdev->cpu_port = AR8216_PORT_CPU;
+ swdev->ops = &ar8216_sw_ops;
+
+ if (chip_is_ar8316(priv)) {
+ swdev->name = "Atheros AR8316";
+ swdev->vlans = AR8X16_MAX_VLANS;
+ swdev->ports = AR8216_NUM_PORTS;
+ } else if (chip_is_ar8236(priv)) {
+ swdev->name = "Atheros AR8236";
+ swdev->vlans = AR8216_NUM_VLANS;
+ swdev->ports = AR8216_NUM_PORTS;
+ } else if (chip_is_ar8327(priv)) {
+ swdev->name = "Atheros AR8327";
+ swdev->vlans = AR8X16_MAX_VLANS;
+ swdev->ports = AR8327_NUM_PORTS;
+ } else {
+ swdev->name = "Atheros AR8216";
+ swdev->vlans = AR8216_NUM_VLANS;
+ swdev->ports = AR8216_NUM_PORTS;
+ }
+
+ ret = ar8xxx_mib_init(priv);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int
ar8216_config_init(struct phy_device *pdev)
{
struct ar8216_priv *priv = pdev->priv;
@@ -1815,7 +1854,7 @@ ar8216_config_init(struct phy_device *pdev)
if (priv == NULL)
return -ENOMEM;
- ret = ar8216_id_chip(priv);
+ ret = ar8xxx_probe_switch(priv);
if (ret)
goto err_free_priv;
}
@@ -1840,6 +1879,7 @@ ar8216_config_init(struct phy_device *pdev)
/* switch device has not been initialized, reuse priv */
if (!pdev->priv) {
priv->port4_phy = true;
+ priv->dev.ports = (AR8216_NUM_PORTS - 1);
pdev->priv = priv;
return 0;
}
@@ -1862,35 +1902,6 @@ ar8216_config_init(struct phy_device *pdev)
pdev->priv = priv;
swdev = &priv->dev;
- swdev->cpu_port = AR8216_PORT_CPU;
- swdev->ops = &ar8216_sw_ops;
- swdev->ports = AR8216_NUM_PORTS;
-
- if (chip_is_ar8316(priv)) {
- swdev->name = "Atheros AR8316";
- swdev->vlans = AR8X16_MAX_VLANS;
-
- if (priv->port4_phy) {
- /* port 5 connected to the other mac, therefore unusable */
- swdev->ports = (AR8216_NUM_PORTS - 1);
- }
- } else if (chip_is_ar8236(priv)) {
- swdev->name = "Atheros AR8236";
- swdev->vlans = AR8216_NUM_VLANS;
- swdev->ports = AR8216_NUM_PORTS;
- } else if (chip_is_ar8327(priv)) {
- swdev->name = "Atheros AR8327";
- swdev->vlans = AR8X16_MAX_VLANS;
- swdev->ports = AR8327_NUM_PORTS;
- } else {
- swdev->name = "Atheros AR8216";
- swdev->vlans = AR8216_NUM_VLANS;
- }
-
- ret = ar8xxx_mib_init(priv);
- if (ret)
- goto err_free_priv;
-
ret = register_switch(swdev, pdev->attached_dev);
if (ret)
goto err_free_priv;
@@ -2038,7 +2049,7 @@ ar8216_probe(struct phy_device *pdev)
priv->phy = pdev;
- ret = ar8216_id_chip(priv);
+ ret = ar8xxx_probe_switch(priv);
ar8xxx_free(priv);
return ret;