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>
This commit is contained in:
Daniel Machon 2024-09-09 17:14:46 +02:00 committed by Vinod Koul
parent f16df05783
commit c8e4c8b7ea
3 changed files with 507 additions and 254 deletions

View File

@ -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,
@ -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,
@ -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)) {

View File

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

File diff suppressed because it is too large Load Diff