net: dsa: microchip: split ksz8_config_cpu_port()

ksz8_config_cpu_port() is only called twice, once by ksz8_setup() and
once by ksz8463_setup(). It contains a ksz8463 branch that could be
avoided in the ksz8_setup() case and a ksz87xx/ksz88xx branches that
could be avoided in ksz8463_setup() case.

Create ksz8463_config_cpu_port() that only handles the ksz8463 case and
remove the ksz8463 specificities from the common ksz8_config_cpu_port().

Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260727-ksz-new-ptp-v3-2-caba39e680e3@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Bastien Curutchet (Schneider Electric)
2026-07-27 12:20:44 +02:00
committed by Jakub Kicinski
parent 7ed1d2b87f
commit 9089bde4db

View File

@@ -2029,6 +2029,50 @@ static void ksz88x3_config_rmii_clk(struct ksz_device *dev)
KSZ88X3_PORT3_RMII_CLK_INTERNAL, rmii_clk_internal);
}
static void ksz8463_config_cpu_port(struct dsa_switch *ds)
{
struct ksz_device *dev = ds->priv;
struct ksz_port *p;
u8 fiber_ports = 0;
const u32 *masks;
const u16 *regs;
int i;
masks = dev->info->masks;
regs = dev->info->regs;
ksz_cfg(dev, regs[S_TAIL_TAG_CTRL], masks[SW_TAIL_TAG_ENABLE], true);
ksz8_port_setup(dev, dev->cpu_port, true);
for (i = 0; i < dev->phy_port_cnt; i++)
ksz_port_stp_state_set(ds, i, BR_STATE_DISABLED);
for (i = 0; i < dev->phy_port_cnt; i++) {
p = &dev->ports[i];
ksz_port_cfg(dev, i, regs[P_STP_CTRL], PORT_FORCE_FLOW_CTRL,
p->fiber);
if (p->fiber)
fiber_ports |= (1 << i);
}
/* Setup fiber ports. */
if (fiber_ports) {
fiber_ports &= 3;
regmap_update_bits(ksz_regmap_16(dev), KSZ8463_REG_CFG_CTRL,
fiber_ports << PORT_COPPER_MODE_S,
0);
regmap_update_bits(ksz_regmap_16(dev), KSZ8463_REG_DSP_CTRL_6,
COPPER_RECEIVE_ADJUSTMENT, 0);
}
/* Turn off PTP function as the switch enables it by default */
regmap_update_bits(ksz_regmap_16(dev), KSZ8463_PTP_MSG_CONF1,
PTP_ENABLE, 0);
regmap_update_bits(ksz_regmap_16(dev), KSZ8463_PTP_CLK_CTRL,
PTP_CLK_ENABLE, 0);
}
static void ksz8_config_cpu_port(struct dsa_switch *ds)
{
struct ksz_device *dev = ds->priv;
@@ -2036,7 +2080,6 @@ static void ksz8_config_cpu_port(struct dsa_switch *ds)
const u32 *masks;
const u16 *regs;
u8 remote;
u8 fiber_ports = 0;
int i;
masks = dev->info->masks;
@@ -2067,32 +2110,6 @@ static void ksz8_config_cpu_port(struct dsa_switch *ds)
else
ksz_port_cfg(dev, i, regs[P_STP_CTRL],
PORT_FORCE_FLOW_CTRL, false);
if (p->fiber)
fiber_ports |= (1 << i);
}
if (ksz_is_ksz8463(dev)) {
/* Setup fiber ports. */
if (fiber_ports) {
fiber_ports &= 3;
regmap_update_bits(ksz_regmap_16(dev),
KSZ8463_REG_CFG_CTRL,
fiber_ports << PORT_COPPER_MODE_S,
0);
regmap_update_bits(ksz_regmap_16(dev),
KSZ8463_REG_DSP_CTRL_6,
COPPER_RECEIVE_ADJUSTMENT, 0);
}
/* Turn off PTP function as the switch's proprietary way of
* handling timestamp is not supported in current Linux PTP
* stack implementation.
*/
regmap_update_bits(ksz_regmap_16(dev),
KSZ8463_PTP_MSG_CONF1,
PTP_ENABLE, 0);
regmap_update_bits(ksz_regmap_16(dev),
KSZ8463_PTP_CLK_CTRL,
PTP_CLK_ENABLE, 0);
}
}
@@ -2332,7 +2349,7 @@ static int ksz8463_setup(struct dsa_switch *ds)
regmap_update_bits(ksz_regmap_16(dev), regs[S_BROADCAST_CTRL],
storm_mask, storm_rate);
ksz8_config_cpu_port(ds);
ksz8463_config_cpu_port(ds);
ksz8_enable_stp_addr(dev);