Skip to content

Commit c8e4c8b

Browse files
Danielmachonvinodkoul
authored andcommitted
phy: sparx5-serdes: add indirection layer to register macros
The register macros are used to read and write to the SERDES registers. The registers are largely the same on Sparx5 and lan969x, however some register target sizes differ. Therefore we introduce a new indirection to the register macros. The target sizes are looked up, using a mapping table (sparx5_serdes_tsize) that maps the register target to the register target size. With this addition, we can reuse all the existing macros for lan969x. Also the autogenerated macros are now formatted slightly different, to adhere to a 80 character limit. 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-6-d695bcb57b84@microchip.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent f16df05 commit c8e4c8b

File tree

3 files changed

+507
-254
lines changed

3 files changed

+507
-254
lines changed

drivers/phy/microchip/sparx5_serdes.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
/* Optimal power settings from GUC */
2929
#define SPX5_SERDES_QUIET_MODE_VAL 0x01ef4e0c
3030

31+
/* Register target sizes */
32+
const unsigned int sparx5_serdes_tsize[TSIZE_LAST] = {
33+
[TC_SD10G_LANE] = 12,
34+
[TC_SD_CMU] = 14,
35+
[TC_SD_CMU_CFG] = 14,
36+
[TC_SD_LANE] = 25,
37+
};
38+
39+
/* Pointer to the register target size table */
40+
const unsigned int *tsize;
41+
3142
enum sparx5_sd25g28_mode_preset_type {
3243
SPX5_SD25G28_MODE_PRESET_25000,
3344
SPX5_SD25G28_MODE_PRESET_10000,
@@ -2506,6 +2517,7 @@ static struct sparx5_serdes_io_resource sparx5_serdes_iomap[] = {
25062517
static const struct sparx5_serdes_match_data sparx5_desc = {
25072518
.iomap = sparx5_serdes_iomap,
25082519
.iomap_size = ARRAY_SIZE(sparx5_serdes_iomap),
2520+
.tsize = sparx5_serdes_tsize,
25092521
.consts = {
25102522
.sd_max = 33,
25112523
.cmu_max = 14,
@@ -2568,6 +2580,8 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
25682580
if (!priv->data)
25692581
return -EINVAL;
25702582

2583+
tsize = priv->data->tsize;
2584+
25712585
/* Get coreclock */
25722586
clk = devm_clk_get(priv->dev, NULL);
25732587
if (IS_ERR(clk)) {

drivers/phy/microchip/sparx5_serdes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct sparx5_serdes_match_data {
6060
const struct sparx5_serdes_ops ops;
6161
const struct sparx5_serdes_io_resource *iomap;
6262
int iomap_size;
63+
const unsigned int *tsize;
6364
};
6465

6566
struct sparx5_serdes_private {

0 commit comments

Comments
 (0)