Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: sparx5-serdes: add support for branching on chip type

In preparation for lan969x, add a way to branch out on code that is to
be executed on either Sparx5 or lan969x. Initially, this is required to
branch out when checking the SERDES types and SERDES speeds, since the
handling of these differ on the two platforms. This will also be used by
the lan969x driver introduced in a subsequent patch.

Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Link: https://lore.kernel.org/r/20240909-sparx5-lan969x-serdes-driver-v2-7-d695bcb57b84@microchip.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Daniel Machon and committed by
Vinod Koul
6158a32b c8e4c8b7

+23 -11
+18 -11
drivers/phy/microchip/sparx5_serdes.c
··· 2298 2298 { 2299 2299 struct sparx5_serdes_macro *macro = phy_get_drvdata(phy); 2300 2300 2301 - if (macro->sidx < SPX5_SERDES_10G_START && speed > SPEED_5000) 2302 - return -EINVAL; 2303 - if (macro->sidx < SPX5_SERDES_25G_START && speed > SPEED_10000) 2304 - return -EINVAL; 2301 + if (macro->priv->data->type == SPX5_TARGET_SPARX5) { 2302 + if (macro->sidx < SPX5_SERDES_10G_START && speed > SPEED_5000) 2303 + return -EINVAL; 2304 + if (macro->sidx < SPX5_SERDES_25G_START && speed > SPEED_10000) 2305 + return -EINVAL; 2306 + } 2305 2307 if (speed != macro->speed) { 2306 2308 macro->speed = speed; 2307 2309 if (macro->serdesmode != SPX5_SD_MODE_NONE) ··· 2340 2338 if (macro->speed == 0) 2341 2339 return -EINVAL; 2342 2340 2343 - if (macro->sidx < SPX5_SERDES_10G_START && macro->speed > SPEED_5000) 2344 - return -EINVAL; 2345 - if (macro->sidx < SPX5_SERDES_25G_START && macro->speed > SPEED_10000) 2346 - return -EINVAL; 2347 - 2341 + if (macro->priv->data->type == SPX5_TARGET_SPARX5) { 2342 + if (macro->sidx < SPX5_SERDES_10G_START && 2343 + macro->speed > SPEED_5000) 2344 + return -EINVAL; 2345 + if (macro->sidx < SPX5_SERDES_25G_START && 2346 + macro->speed > SPEED_10000) 2347 + return -EINVAL; 2348 + } 2348 2349 switch (submode) { 2349 2350 case PHY_INTERFACE_MODE_1000BASEX: 2350 2351 if (macro->speed != SPEED_100 && /* This is for 100BASE-FX */ ··· 2520 2515 }; 2521 2516 2522 2517 static const struct sparx5_serdes_match_data sparx5_desc = { 2518 + .type = SPX5_TARGET_SPARX5, 2523 2519 .iomap = sparx5_serdes_iomap, 2524 2520 .iomap_size = ARRAY_SIZE(sparx5_serdes_iomap), 2525 2521 .tsize = sparx5_serdes_tsize, ··· 2624 2618 return err; 2625 2619 } 2626 2620 2627 - /* Power down all CMUs by default */ 2628 - sparx5_serdes_cmu_power_off(priv); 2621 + /* Power down all CMU's by default */ 2622 + if (priv->data->type == SPX5_TARGET_SPARX5) 2623 + sparx5_serdes_cmu_power_off(priv); 2629 2624 2630 2625 provider = devm_of_phy_provider_register(priv->dev, sparx5_serdes_xlate); 2631 2626
+5
drivers/phy/microchip/sparx5_serdes.h
··· 34 34 SPX5_SD10G28_CMU_MAX, 35 35 }; 36 36 37 + enum sparx5_target { 38 + SPX5_TARGET_SPARX5, 39 + }; 40 + 37 41 struct sparx5_serdes_macro { 38 42 struct sparx5_serdes_private *priv; 39 43 u32 sidx; ··· 60 56 }; 61 57 62 58 struct sparx5_serdes_match_data { 59 + enum sparx5_target type; 63 60 const struct sparx5_serdes_consts consts; 64 61 const struct sparx5_serdes_ops ops; 65 62 const struct sparx5_serdes_io_resource *iomap;