Skip to content

Commit

Permalink
phy: sparx5-serdes: add indirection layer to register macros
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Machon authored and Vinod Koul committed Oct 21, 2024
1 parent f16df05 commit c8e4c8b
Show file tree
Hide file tree
Showing 3 changed files with 507 additions and 254 deletions.
14 changes: 14 additions & 0 deletions drivers/phy/microchip/sparx5_serdes.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
/* Optimal power settings from GUC */
#define SPX5_SERDES_QUIET_MODE_VAL 0x01ef4e0c

/* Register target sizes */
const unsigned int sparx5_serdes_tsize[TSIZE_LAST] = {
[TC_SD10G_LANE] = 12,
[TC_SD_CMU] = 14,
[TC_SD_CMU_CFG] = 14,
[TC_SD_LANE] = 25,
};

/* Pointer to the register target size table */
const unsigned int *tsize;

enum sparx5_sd25g28_mode_preset_type {
SPX5_SD25G28_MODE_PRESET_25000,
SPX5_SD25G28_MODE_PRESET_10000,
Expand Down Expand Up @@ -2506,6 +2517,7 @@ static struct sparx5_serdes_io_resource sparx5_serdes_iomap[] = {
static const struct sparx5_serdes_match_data sparx5_desc = {
.iomap = sparx5_serdes_iomap,
.iomap_size = ARRAY_SIZE(sparx5_serdes_iomap),
.tsize = sparx5_serdes_tsize,
.consts = {
.sd_max = 33,
.cmu_max = 14,
Expand Down Expand Up @@ -2568,6 +2580,8 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
if (!priv->data)
return -EINVAL;

tsize = priv->data->tsize;

/* Get coreclock */
clk = devm_clk_get(priv->dev, NULL);
if (IS_ERR(clk)) {
Expand Down
1 change: 1 addition & 0 deletions drivers/phy/microchip/sparx5_serdes.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct sparx5_serdes_match_data {
const struct sparx5_serdes_ops ops;
const struct sparx5_serdes_io_resource *iomap;
int iomap_size;
const unsigned int *tsize;
};

struct sparx5_serdes_private {
Expand Down
Loading

0 comments on commit c8e4c8b

Please sign in to comment.