diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-03-07 16:32:46 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-03-07 16:32:46 +0000 |
commit | d41f998ce04376e84f52b940e06f808f5e57f92f (patch) | |
tree | 70284d51096ba6250ca14d4f2664cd27cc09a05f /target/linux/generic/files/drivers/net/phy/ar8216.c | |
parent | 295e64ddd8a090249cff8e010c8682c14b60c0e3 (diff) | |
download | upstream-d41f998ce04376e84f52b940e06f808f5e57f92f.tar.gz upstream-d41f998ce04376e84f52b940e06f808f5e57f92f.tar.bz2 upstream-d41f998ce04376e84f52b940e06f808f5e57f92f.zip |
generic: ar8216: move port initialization into a separate function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30848 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy/ar8216.c')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/ar8216.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c index 26a79be7ef..3b7937d72b 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.c +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c @@ -718,6 +718,32 @@ out: return 0; } +static void +ar8216_init_port(struct ar8216_priv *priv, int port) +{ + /* Enable port learning and tx */ + priv->write(priv, AR8216_REG_PORT_CTRL(port), + AR8216_PORT_CTRL_LEARN | + (4 << AR8216_PORT_CTRL_STATE_S)); + + priv->write(priv, AR8216_REG_PORT_VLAN(port), 0); + + if (port == AR8216_PORT_CPU) { + priv->write(priv, AR8216_REG_PORT_STATUS(port), + AR8216_PORT_STATUS_LINK_UP | + ((priv->chip == AR8316) ? + AR8216_PORT_SPEED_1000M : AR8216_PORT_SPEED_100M) | + AR8216_PORT_STATUS_TXMAC | + AR8216_PORT_STATUS_RXMAC | + ((priv->chip == AR8316) ? AR8216_PORT_STATUS_RXFLOW : 0) | + ((priv->chip == AR8316) ? AR8216_PORT_STATUS_TXFLOW : 0) | + AR8216_PORT_STATUS_DUPLEX); + } else { + priv->write(priv, AR8216_REG_PORT_STATUS(port), + AR8216_PORT_STATUS_LINK_AUTO); + } +} + static int ar8216_reset_switch(struct switch_dev *dev) { @@ -730,30 +756,11 @@ ar8216_reset_switch(struct switch_dev *dev) for (i = 0; i < AR8X16_MAX_VLANS; i++) { priv->vlan_id[i] = i; } - for (i = 0; i < AR8216_NUM_PORTS; i++) { - /* Enable port learning and tx */ - priv->write(priv, AR8216_REG_PORT_CTRL(i), - AR8216_PORT_CTRL_LEARN | - (4 << AR8216_PORT_CTRL_STATE_S)); - - priv->write(priv, AR8216_REG_PORT_VLAN(i), 0); - - /* Configure all PHYs */ - if (i == AR8216_PORT_CPU) { - priv->write(priv, AR8216_REG_PORT_STATUS(i), - AR8216_PORT_STATUS_LINK_UP | - ((priv->chip == AR8316) ? - AR8216_PORT_SPEED_1000M : AR8216_PORT_SPEED_100M) | - AR8216_PORT_STATUS_TXMAC | - AR8216_PORT_STATUS_RXMAC | - ((priv->chip == AR8316) ? AR8216_PORT_STATUS_RXFLOW : 0) | - ((priv->chip == AR8316) ? AR8216_PORT_STATUS_TXFLOW : 0) | - AR8216_PORT_STATUS_DUPLEX); - } else { - priv->write(priv, AR8216_REG_PORT_STATUS(i), - AR8216_PORT_STATUS_LINK_AUTO); - } - } + + /* Configure all ports */ + for (i = 0; i < AR8216_NUM_PORTS; i++) + ar8216_init_port(priv, i); + /* XXX: undocumented magic from atheros, required! */ priv->write(priv, 0x38, 0xc000050e); |