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 ops to match data

We need to handle code differently in a few places. Add a struct:
sparx5_serdes_ops for this purpose, and populate it a with function to
set the SERDES type.

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-4-d695bcb57b84@microchip.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Daniel Machon and committed by
Vinod Koul
d61d42a9 5206ba96

+35 -21
+19 -10
drivers/phy/microchip/sparx5_serdes.c
··· 2373 2373 .owner = THIS_MODULE, 2374 2374 }; 2375 2375 2376 + static void sparx5_serdes_type_set(struct sparx5_serdes_macro *macro, int sidx) 2377 + { 2378 + if (sidx < SPX5_SERDES_10G_START) { 2379 + macro->serdestype = SPX5_SDT_6G; 2380 + macro->stpidx = macro->sidx; 2381 + } else if (sidx < SPX5_SERDES_25G_START) { 2382 + macro->serdestype = SPX5_SDT_10G; 2383 + macro->stpidx = macro->sidx - SPX5_SERDES_10G_START; 2384 + } else { 2385 + macro->serdestype = SPX5_SDT_25G; 2386 + macro->stpidx = macro->sidx - SPX5_SERDES_25G_START; 2387 + } 2388 + } 2389 + 2376 2390 static int sparx5_phy_create(struct sparx5_serdes_private *priv, 2377 2391 int idx, struct phy **phy) 2378 2392 { ··· 2403 2389 macro->sidx = idx; 2404 2390 macro->priv = priv; 2405 2391 macro->speed = SPEED_UNKNOWN; 2406 - if (idx < SPX5_SERDES_10G_START) { 2407 - macro->serdestype = SPX5_SDT_6G; 2408 - macro->stpidx = macro->sidx; 2409 - } else if (idx < SPX5_SERDES_25G_START) { 2410 - macro->serdestype = SPX5_SDT_10G; 2411 - macro->stpidx = macro->sidx - SPX5_SERDES_10G_START; 2412 - } else { 2413 - macro->serdestype = SPX5_SDT_25G; 2414 - macro->stpidx = macro->sidx - SPX5_SERDES_25G_START; 2415 - } 2392 + 2393 + priv->data->ops.serdes_type_set(macro, idx); 2416 2394 2417 2395 phy_set_drvdata(*phy, macro); 2418 2396 ··· 2517 2511 .consts = { 2518 2512 .sd_max = 33, 2519 2513 .cmu_max = 14, 2514 + }, 2515 + .ops = { 2516 + .serdes_type_set = &sparx5_serdes_type_set, 2520 2517 }, 2521 2518 }; 2522 2519
+16 -11
drivers/phy/microchip/sparx5_serdes.h
··· 26 26 SPX5_SD_MODE_SFI, 27 27 }; 28 28 29 + struct sparx5_serdes_macro { 30 + struct sparx5_serdes_private *priv; 31 + u32 sidx; 32 + u32 stpidx; 33 + enum sparx5_serdes_type serdestype; 34 + enum sparx5_serdes_mode serdesmode; 35 + phy_interface_t portmode; 36 + int speed; 37 + enum phy_media media; 38 + }; 39 + 29 40 struct sparx5_serdes_consts { 30 41 int sd_max; 31 42 int cmu_max; 32 43 }; 33 44 45 + struct sparx5_serdes_ops { 46 + void (*serdes_type_set)(struct sparx5_serdes_macro *macro, int sidx); 47 + }; 48 + 34 49 struct sparx5_serdes_match_data { 35 50 const struct sparx5_serdes_consts consts; 51 + const struct sparx5_serdes_ops ops; 36 52 const struct sparx5_serdes_io_resource *iomap; 37 53 int iomap_size; 38 54 }; ··· 59 43 struct phy *phys[SPX5_SERDES_MAX]; 60 44 unsigned long coreclock; 61 45 const struct sparx5_serdes_match_data *data; 62 - }; 63 - 64 - struct sparx5_serdes_macro { 65 - struct sparx5_serdes_private *priv; 66 - u32 sidx; 67 - u32 stpidx; 68 - enum sparx5_serdes_type serdestype; 69 - enum sparx5_serdes_mode serdesmode; 70 - phy_interface_t portmode; 71 - int speed; 72 - enum phy_media media; 73 46 }; 74 47 75 48 /* Read, Write and modify registers content.