Skip to content

Commit 6158a32

Browse files
Danielmachonvinodkoul
authored andcommitted
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>
1 parent c8e4c8b commit 6158a32

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

drivers/phy/microchip/sparx5_serdes.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,10 +2298,12 @@ static int sparx5_serdes_set_speed(struct phy *phy, int speed)
22982298
{
22992299
struct sparx5_serdes_macro *macro = phy_get_drvdata(phy);
23002300

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+
}
23052307
if (speed != macro->speed) {
23062308
macro->speed = speed;
23072309
if (macro->serdesmode != SPX5_SD_MODE_NONE)
@@ -2338,11 +2340,14 @@ static int sparx5_serdes_validate(struct phy *phy, enum phy_mode mode,
23382340
if (macro->speed == 0)
23392341
return -EINVAL;
23402342

2341-
if (macro->sidx < SPX5_SERDES_10G_START && macro->speed > SPEED_5000)
2342-
return -EINVAL;
2343-
if (macro->sidx < SPX5_SERDES_25G_START && macro->speed > SPEED_10000)
2344-
return -EINVAL;
2345-
2343+
if (macro->priv->data->type == SPX5_TARGET_SPARX5) {
2344+
if (macro->sidx < SPX5_SERDES_10G_START &&
2345+
macro->speed > SPEED_5000)
2346+
return -EINVAL;
2347+
if (macro->sidx < SPX5_SERDES_25G_START &&
2348+
macro->speed > SPEED_10000)
2349+
return -EINVAL;
2350+
}
23462351
switch (submode) {
23472352
case PHY_INTERFACE_MODE_1000BASEX:
23482353
if (macro->speed != SPEED_100 && /* This is for 100BASE-FX */
@@ -2515,6 +2520,7 @@ static struct sparx5_serdes_io_resource sparx5_serdes_iomap[] = {
25152520
};
25162521

25172522
static const struct sparx5_serdes_match_data sparx5_desc = {
2523+
.type = SPX5_TARGET_SPARX5,
25182524
.iomap = sparx5_serdes_iomap,
25192525
.iomap_size = ARRAY_SIZE(sparx5_serdes_iomap),
25202526
.tsize = sparx5_serdes_tsize,
@@ -2618,8 +2624,9 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
26182624
return err;
26192625
}
26202626

2621-
/* Power down all CMUs by default */
2622-
sparx5_serdes_cmu_power_off(priv);
2627+
/* Power down all CMU's by default */
2628+
if (priv->data->type == SPX5_TARGET_SPARX5)
2629+
sparx5_serdes_cmu_power_off(priv);
26232630

26242631
provider = devm_of_phy_provider_register(priv->dev, sparx5_serdes_xlate);
26252632

drivers/phy/microchip/sparx5_serdes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ enum sparx5_10g28cmu_mode {
3434
SPX5_SD10G28_CMU_MAX,
3535
};
3636

37+
enum sparx5_target {
38+
SPX5_TARGET_SPARX5,
39+
};
40+
3741
struct sparx5_serdes_macro {
3842
struct sparx5_serdes_private *priv;
3943
u32 sidx;
@@ -56,6 +60,7 @@ struct sparx5_serdes_ops {
5660
};
5761

5862
struct sparx5_serdes_match_data {
63+
enum sparx5_target type;
5964
const struct sparx5_serdes_consts consts;
6065
const struct sparx5_serdes_ops ops;
6166
const struct sparx5_serdes_io_resource *iomap;

0 commit comments

Comments
 (0)