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 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>

authored by

Daniel Machon and committed by
Vinod Koul
d41bb5e0 0175a673

+19 -3
+13 -3
drivers/phy/microchip/sparx5_serdes.c
··· 2507 2507 { TARGET_SD_LANE_25G + 7, 0x5c8000 }, /* 0x610dd0000: sd_lane_25g_32 */ 2508 2508 }; 2509 2509 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 + 2510 2515 /* Client lookup function, uses serdes index */ 2511 2516 static struct phy *sparx5_serdes_xlate(struct device *dev, 2512 2517 const struct of_phandle_args *args) ··· 2560 2555 platform_set_drvdata(pdev, priv); 2561 2556 priv->dev = &pdev->dev; 2562 2557 2558 + priv->data = device_get_match_data(priv->dev); 2559 + if (!priv->data) 2560 + return -EINVAL; 2561 + 2563 2562 /* Get coreclock */ 2564 2563 clk = devm_clk_get(priv->dev, NULL); 2565 2564 if (IS_ERR(clk)) { ··· 2588 2579 iores->name); 2589 2580 return -ENOMEM; 2590 2581 } 2591 - for (idx = 0; idx < ARRAY_SIZE(sparx5_serdes_iomap); idx++) { 2592 - struct sparx5_serdes_io_resource *iomap = &sparx5_serdes_iomap[idx]; 2582 + for (idx = 0; idx < priv->data->iomap_size; idx++) { 2583 + const struct sparx5_serdes_io_resource *iomap = 2584 + &priv->data->iomap[idx]; 2593 2585 2594 2586 priv->regs[iomap->id] = iomem + iomap->offset; 2595 2587 } ··· 2609 2599 } 2610 2600 2611 2601 static const struct of_device_id sparx5_serdes_match[] = { 2612 - { .compatible = "microchip,sparx5-serdes" }, 2602 + { .compatible = "microchip,sparx5-serdes", .data = &sparx5_desc }, 2613 2603 { } 2614 2604 }; 2615 2605 MODULE_DEVICE_TABLE(of, sparx5_serdes_match);
+6
drivers/phy/microchip/sparx5_serdes.h
··· 26 26 SPX5_SD_MODE_SFI, 27 27 }; 28 28 29 + struct sparx5_serdes_match_data { 30 + const struct sparx5_serdes_io_resource *iomap; 31 + int iomap_size; 32 + }; 33 + 29 34 struct sparx5_serdes_private { 30 35 struct device *dev; 31 36 void __iomem *regs[NUM_TARGETS]; 32 37 struct phy *phys[SPX5_SERDES_MAX]; 33 38 unsigned long coreclock; 39 + const struct sparx5_serdes_match_data *data; 34 40 }; 35 41 36 42 struct sparx5_serdes_macro {