diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2015-02-05 14:40:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-08 01:38:40 -0500 |
commit | b083668c93e5bf889e6ec4761540be1accc3f1b1 (patch) | |
tree | 17a7a133339559dd076e6c0a73da9ac9caff9513 | |
parent | 3c09e92fb6b94b7597442c1f232a260c35b30698 (diff) |
net: dsa: bcm_sf2: move GPHY enabling to its own function
Move the code that touches the single GPHY register from
bcm_sf2_sw_resume() to a separate function since we will have to
enable/disable the GPHY from different locations, and we want the code
to be self-contained.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/dsa/bcm_sf2.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index 09f6b3cc1f66..45c0e2b97f5f 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c | |||
@@ -233,6 +233,24 @@ static void bcm_sf2_eee_enable_set(struct dsa_switch *ds, int port, bool enable) | |||
233 | core_writel(priv, reg, CORE_EEE_EN_CTRL); | 233 | core_writel(priv, reg, CORE_EEE_EN_CTRL); |
234 | } | 234 | } |
235 | 235 | ||
236 | static void bcm_sf2_gphy_enable_set(struct dsa_switch *ds, bool enable) | ||
237 | { | ||
238 | struct bcm_sf2_priv *priv = ds_to_priv(ds); | ||
239 | u32 reg; | ||
240 | |||
241 | if (!enable) | ||
242 | return; | ||
243 | |||
244 | reg = reg_readl(priv, REG_SPHY_CNTRL); | ||
245 | reg |= PHY_RESET; | ||
246 | reg &= ~(EXT_PWR_DOWN | IDDQ_BIAS); | ||
247 | reg_writel(priv, reg, REG_SPHY_CNTRL); | ||
248 | udelay(21); | ||
249 | reg = reg_readl(priv, REG_SPHY_CNTRL); | ||
250 | reg &= ~PHY_RESET; | ||
251 | reg_writel(priv, reg, REG_SPHY_CNTRL); | ||
252 | } | ||
253 | |||
236 | static int bcm_sf2_port_setup(struct dsa_switch *ds, int port, | 254 | static int bcm_sf2_port_setup(struct dsa_switch *ds, int port, |
237 | struct phy_device *phy) | 255 | struct phy_device *phy) |
238 | { | 256 | { |
@@ -771,7 +789,6 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds) | |||
771 | { | 789 | { |
772 | struct bcm_sf2_priv *priv = ds_to_priv(ds); | 790 | struct bcm_sf2_priv *priv = ds_to_priv(ds); |
773 | unsigned int port; | 791 | unsigned int port; |
774 | u32 reg; | ||
775 | int ret; | 792 | int ret; |
776 | 793 | ||
777 | ret = bcm_sf2_sw_rst(priv); | 794 | ret = bcm_sf2_sw_rst(priv); |
@@ -780,17 +797,8 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds) | |||
780 | return ret; | 797 | return ret; |
781 | } | 798 | } |
782 | 799 | ||
783 | /* Reinitialize the single GPHY */ | 800 | if (priv->hw_params.num_gphy == 1) |
784 | if (priv->hw_params.num_gphy == 1) { | 801 | bcm_sf2_gphy_enable_set(ds, true); |
785 | reg = reg_readl(priv, REG_SPHY_CNTRL); | ||
786 | reg |= PHY_RESET; | ||
787 | reg &= ~(EXT_PWR_DOWN | IDDQ_BIAS); | ||
788 | reg_writel(priv, reg, REG_SPHY_CNTRL); | ||
789 | udelay(21); | ||
790 | reg = reg_readl(priv, REG_SPHY_CNTRL); | ||
791 | reg &= ~PHY_RESET; | ||
792 | reg_writel(priv, reg, REG_SPHY_CNTRL); | ||
793 | } | ||
794 | 802 | ||
795 | for (port = 0; port < DSA_MAX_PORTS; port++) { | 803 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
796 | if ((1 << port) & ds->phys_port_mask) | 804 | if ((1 << port) & ds->phys_port_mask) |