Skip to content

Commit dc3de2a

Browse files
claudiu-mdavem330
authored andcommitted
net: mscc: ocelot: filter out ocelot SoC specific PCS config from common path
The adjust_link routine should be generic enough to be (re)used by any SoC that integrates a switch core compatible with the Ocelot core switch driver. Currently all configurations are generic except for the PCS settings that are SoC specific. Move these out to the Ocelot SoC/board instance. Signed-off-by: Claudiu Manoil <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 259630e commit dc3de2a

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -455,23 +455,8 @@ static void ocelot_adjust_link(struct ocelot *ocelot, int port,
455455
ocelot_port_writel(ocelot_port, DEV_MAC_HDX_CFG_LATE_COL_POS(67),
456456
DEV_MAC_HDX_CFG);
457457

458-
/* Disable HDX fast control */
459-
ocelot_port_writel(ocelot_port, DEV_PORT_MISC_HDX_FAST_DIS,
460-
DEV_PORT_MISC);
461-
462-
/* SGMII only for now */
463-
ocelot_port_writel(ocelot_port, PCS1G_MODE_CFG_SGMII_MODE_ENA,
464-
PCS1G_MODE_CFG);
465-
ocelot_port_writel(ocelot_port, PCS1G_SD_CFG_SD_SEL, PCS1G_SD_CFG);
466-
467-
/* Enable PCS */
468-
ocelot_port_writel(ocelot_port, PCS1G_CFG_PCS_ENA, PCS1G_CFG);
469-
470-
/* No aneg on SGMII */
471-
ocelot_port_writel(ocelot_port, 0, PCS1G_ANEG_CFG);
472-
473-
/* No loopback */
474-
ocelot_port_writel(ocelot_port, 0, PCS1G_LB_CFG);
458+
if (ocelot->ops->pcs_init)
459+
ocelot->ops->pcs_init(ocelot, port);
475460

476461
/* Set Max Length and maximum tags allowed */
477462
ocelot_port_writel(ocelot_port, VLAN_ETH_FRAME_LEN,

drivers/net/ethernet/mscc/ocelot.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,19 @@ enum ocelot_tag_prefix {
435435
};
436436

437437
struct ocelot_port;
438+
struct ocelot;
438439

439440
struct ocelot_stat_layout {
440441
u32 offset;
441442
char name[ETH_GSTRING_LEN];
442443
};
443444

445+
struct ocelot_ops {
446+
void (*pcs_init)(struct ocelot *ocelot, int port);
447+
};
448+
444449
struct ocelot {
450+
const struct ocelot_ops *ops;
445451
struct device *dev;
446452

447453
struct regmap *targets[TARGET_MAX];
@@ -553,7 +559,7 @@ struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
553559

554560
int ocelot_init(struct ocelot *ocelot);
555561
void ocelot_deinit(struct ocelot *ocelot);
556-
int ocelot_chip_init(struct ocelot *ocelot);
562+
int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops);
557563
int ocelot_probe_port(struct ocelot *ocelot, u8 port,
558564
void __iomem *regs,
559565
struct phy_device *phy);

drivers/net/ethernet/mscc/ocelot_board.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,33 @@ static const struct of_device_id mscc_ocelot_match[] = {
254254
};
255255
MODULE_DEVICE_TABLE(of, mscc_ocelot_match);
256256

257+
static void ocelot_port_pcs_init(struct ocelot *ocelot, int port)
258+
{
259+
struct ocelot_port *ocelot_port = ocelot->ports[port];
260+
261+
/* Disable HDX fast control */
262+
ocelot_port_writel(ocelot_port, DEV_PORT_MISC_HDX_FAST_DIS,
263+
DEV_PORT_MISC);
264+
265+
/* SGMII only for now */
266+
ocelot_port_writel(ocelot_port, PCS1G_MODE_CFG_SGMII_MODE_ENA,
267+
PCS1G_MODE_CFG);
268+
ocelot_port_writel(ocelot_port, PCS1G_SD_CFG_SD_SEL, PCS1G_SD_CFG);
269+
270+
/* Enable PCS */
271+
ocelot_port_writel(ocelot_port, PCS1G_CFG_PCS_ENA, PCS1G_CFG);
272+
273+
/* No aneg on SGMII */
274+
ocelot_port_writel(ocelot_port, 0, PCS1G_ANEG_CFG);
275+
276+
/* No loopback */
277+
ocelot_port_writel(ocelot_port, 0, PCS1G_LB_CFG);
278+
}
279+
280+
static const struct ocelot_ops ocelot_ops = {
281+
.pcs_init = ocelot_port_pcs_init,
282+
};
283+
257284
static int mscc_ocelot_probe(struct platform_device *pdev)
258285
{
259286
struct device_node *np = pdev->dev.of_node;
@@ -315,7 +342,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
315342

316343
ocelot->targets[HSIO] = hsio;
317344

318-
err = ocelot_chip_init(ocelot);
345+
err = ocelot_chip_init(ocelot, &ocelot_ops);
319346
if (err)
320347
return err;
321348

drivers/net/ethernet/mscc/ocelot_regs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,15 @@ static void ocelot_pll5_init(struct ocelot *ocelot)
423423
HSIO_PLL5G_CFG2_AMPC_SEL(0x10));
424424
}
425425

426-
int ocelot_chip_init(struct ocelot *ocelot)
426+
int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops)
427427
{
428428
int ret;
429429

430430
ocelot->map = ocelot_regmap;
431431
ocelot->stats_layout = ocelot_stats_layout;
432432
ocelot->num_stats = ARRAY_SIZE(ocelot_stats_layout);
433433
ocelot->shared_queue_sz = 224 * 1024;
434+
ocelot->ops = ops;
434435

435436
ret = ocelot_regfields_init(ocelot, ocelot_regfields);
436437
if (ret)

0 commit comments

Comments
 (0)