Skip to content

Commit f86ad77

Browse files
ffainellidavem330
authored andcommitted
net: dsa: bcm_sf2: Utilize b53_{enable, disable}_port
Export b53_{enable,disable}_port and use these two functions in bcm_sf2_port_setup and bcm_sf2_port_disable. The generic functions cannot be used without wrapping because we need to manage additional switch integration details (PHY, Broadcom tag etc.). Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 152b6fd commit f86ad77

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,7 @@ void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port)
502502
}
503503
EXPORT_SYMBOL(b53_imp_vlan_setup);
504504

505-
static int b53_enable_port(struct dsa_switch *ds, int port,
506-
struct phy_device *phy)
505+
int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
507506
{
508507
struct b53_device *dev = ds->priv;
509508
unsigned int cpu_port = dev->cpu_port;
@@ -530,9 +529,9 @@ static int b53_enable_port(struct dsa_switch *ds, int port,
530529

531530
return 0;
532531
}
532+
EXPORT_SYMBOL(b53_enable_port);
533533

534-
static void b53_disable_port(struct dsa_switch *ds, int port,
535-
struct phy_device *phy)
534+
void b53_disable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
536535
{
537536
struct b53_device *dev = ds->priv;
538537
u8 reg;
@@ -542,6 +541,7 @@ static void b53_disable_port(struct dsa_switch *ds, int port,
542541
reg |= PORT_CTRL_RX_DISABLE | PORT_CTRL_TX_DISABLE;
543542
b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), reg);
544543
}
544+
EXPORT_SYMBOL(b53_disable_port);
545545

546546
void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
547547
{

drivers/net/dsa/b53/b53_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ int b53_mirror_add(struct dsa_switch *ds, int port,
311311
struct dsa_mall_mirror_tc_entry *mirror, bool ingress);
312312
void b53_mirror_del(struct dsa_switch *ds, int port,
313313
struct dsa_mall_mirror_tc_entry *mirror);
314+
int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
315+
void b53_disable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
314316
void b53_brcm_hdr_setup(struct dsa_switch *ds, int port);
315317
void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable);
316318
int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy);

drivers/net/dsa/bcm_sf2.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
163163
struct phy_device *phy)
164164
{
165165
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
166-
s8 cpu_port = ds->dst->cpu_dp->index;
167166
unsigned int i;
168167
u32 reg;
169168

@@ -184,9 +183,6 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
184183
reg |= i << (PRT_TO_QID_SHIFT * i);
185184
core_writel(priv, reg, CORE_PORT_TC2_QOS_MAP_PORT(port));
186185

187-
/* Clear the Rx and Tx disable bits and set to no spanning tree */
188-
core_writel(priv, 0, CORE_G_PCTL_PORT(port));
189-
190186
/* Re-enable the GPHY and re-apply workarounds */
191187
if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1) {
192188
bcm_sf2_gphy_enable_set(ds, true);
@@ -209,23 +205,7 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
209205
if (port == priv->moca_port)
210206
bcm_sf2_port_intr_enable(priv, port);
211207

212-
/* Set this port, and only this one to be in the default VLAN,
213-
* if member of a bridge, restore its membership prior to
214-
* bringing down this port.
215-
*/
216-
reg = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(port));
217-
reg &= ~PORT_VLAN_CTRL_MASK;
218-
reg |= (1 << port);
219-
reg |= priv->dev->ports[port].vlan_ctl_mask;
220-
core_writel(priv, reg, CORE_PORT_VLAN_CTL_PORT(port));
221-
222-
b53_imp_vlan_setup(ds, cpu_port);
223-
224-
/* If EEE was enabled, restore it */
225-
if (priv->dev->ports[port].eee.eee_enabled)
226-
b53_eee_enable_set(ds, port, true);
227-
228-
return 0;
208+
return b53_enable_port(ds, port, phy);
229209
}
230210

231211
static void bcm_sf2_port_disable(struct dsa_switch *ds, int port,
@@ -248,9 +228,7 @@ static void bcm_sf2_port_disable(struct dsa_switch *ds, int port,
248228
else
249229
off = CORE_G_PCTL_PORT(port);
250230

251-
reg = core_readl(priv, off);
252-
reg |= RX_DIS | TX_DIS;
253-
core_writel(priv, reg, off);
231+
b53_disable_port(ds, port, phy);
254232

255233
/* Power down the port memory */
256234
reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);

0 commit comments

Comments
 (0)