Skip to content

Commit d41bb5e

Browse files
Danielmachonvinodkoul
authored andcommitted
phy: sparx5-serdes: add support for private match data
In order to reuse the existing Sparx5 SERDES driver for lan969x, we add support for private match data, with initial fields for the iomap and imap_size. 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-1-d695bcb57b84@microchip.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 0175a67 commit d41bb5e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

drivers/phy/microchip/sparx5_serdes.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,11 @@ static struct sparx5_serdes_io_resource sparx5_serdes_iomap[] = {
25072507
{ TARGET_SD_LANE_25G + 7, 0x5c8000 }, /* 0x610dd0000: sd_lane_25g_32 */
25082508
};
25092509

2510+
static const struct sparx5_serdes_match_data sparx5_desc = {
2511+
.iomap = sparx5_serdes_iomap,
2512+
.iomap_size = ARRAY_SIZE(sparx5_serdes_iomap),
2513+
};
2514+
25102515
/* Client lookup function, uses serdes index */
25112516
static struct phy *sparx5_serdes_xlate(struct device *dev,
25122517
const struct of_phandle_args *args)
@@ -2555,6 +2560,10 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
25552560
platform_set_drvdata(pdev, priv);
25562561
priv->dev = &pdev->dev;
25572562

2563+
priv->data = device_get_match_data(priv->dev);
2564+
if (!priv->data)
2565+
return -EINVAL;
2566+
25582567
/* Get coreclock */
25592568
clk = devm_clk_get(priv->dev, NULL);
25602569
if (IS_ERR(clk)) {
@@ -2579,8 +2588,9 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
25792588
iores->name);
25802589
return -ENOMEM;
25812590
}
2582-
for (idx = 0; idx < ARRAY_SIZE(sparx5_serdes_iomap); idx++) {
2583-
struct sparx5_serdes_io_resource *iomap = &sparx5_serdes_iomap[idx];
2591+
for (idx = 0; idx < priv->data->iomap_size; idx++) {
2592+
const struct sparx5_serdes_io_resource *iomap =
2593+
&priv->data->iomap[idx];
25842594

25852595
priv->regs[iomap->id] = iomem + iomap->offset;
25862596
}
@@ -2599,7 +2609,7 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
25992609
}
26002610

26012611
static const struct of_device_id sparx5_serdes_match[] = {
2602-
{ .compatible = "microchip,sparx5-serdes" },
2612+
{ .compatible = "microchip,sparx5-serdes", .data = &sparx5_desc },
26032613
{ }
26042614
};
26052615
MODULE_DEVICE_TABLE(of, sparx5_serdes_match);

drivers/phy/microchip/sparx5_serdes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ enum sparx5_serdes_mode {
2626
SPX5_SD_MODE_SFI,
2727
};
2828

29+
struct sparx5_serdes_match_data {
30+
const struct sparx5_serdes_io_resource *iomap;
31+
int iomap_size;
32+
};
33+
2934
struct sparx5_serdes_private {
3035
struct device *dev;
3136
void __iomem *regs[NUM_TARGETS];
3237
struct phy *phys[SPX5_SERDES_MAX];
3338
unsigned long coreclock;
39+
const struct sparx5_serdes_match_data *data;
3440
};
3541

3642
struct sparx5_serdes_macro {

0 commit comments

Comments
 (0)