diff options
| author | Jonas Jelonek | 2025-12-13 10:12:35 +0000 |
|---|---|---|
| committer | Robert Marko | 2025-12-16 12:38:13 +0000 |
| commit | 40201e7f73b41c9539ea79d6cad112d53f8ef935 (patch) | |
| tree | 5d67a9a4e3974cf5a61393ae424088fdf8e29be3 | |
| parent | b9e5803d046cbc92bbd758debcc13b055c0def26 (diff) | |
| download | openwrt-40201e7f73b41c9539ea79d6cad112d53f8ef935.tar.gz | |
realtek: pcs: add separate SerDes struct
Add a separate structure for a SerDes. This is needed to appropriately
store per-SerDes information, which in turn is needed for future work.
Additionally, it's intended to reduce boilerplate and several
inconsistencies.
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21146
Signed-off-by: Robert Marko <robimarko@gmail.com>
(cherry picked from commit 6b3f8fb16faf1e9c28b282340a112b2bcb06b0d3)
| -rw-r--r-- | target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c index 7cc5bb1730..566e79962c 100644 --- a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c +++ b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c @@ -129,11 +129,20 @@ enum rtpcs_sds_mode { RTPCS_SDS_MODE_USXGMII_2_5GSXGMII, }; +struct rtpcs_ctrl; + +struct rtpcs_serdes { + struct rtpcs_ctrl *ctrl; + u8 id; + enum rtpcs_sds_mode mode; +}; + struct rtpcs_ctrl { struct device *dev; struct regmap *map; struct mii_bus *bus; const struct rtpcs_config *cfg; + struct rtpcs_serdes serdes[RTPCS_SDS_CNT]; struct rtpcs_link *link[RTPCS_PORT_CNT]; bool rx_pol_inv[RTPCS_SDS_CNT]; bool tx_pol_inv[RTPCS_SDS_CNT]; @@ -3025,9 +3034,10 @@ static int rtpcs_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; struct device_node *child; + struct rtpcs_serdes *sds; struct rtpcs_ctrl *ctrl; - u32 sds; - int ret; + u32 sds_id; + int i, ret; ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL); if (!ctrl) @@ -3045,15 +3055,21 @@ static int rtpcs_probe(struct platform_device *pdev) if (IS_ERR(ctrl->bus)) return PTR_ERR(ctrl->bus); + for (i = 0; i < ctrl->cfg->serdes_count; i++) { + sds = &ctrl->serdes[i]; + sds->ctrl = ctrl; + sds->id = i; + } + for_each_child_of_node(dev->of_node, child) { - ret = of_property_read_u32(child, "reg", &sds); + ret = of_property_read_u32(child, "reg", &sds_id); if (ret) return ret; if (sds >= ctrl->cfg->serdes_count) return -EINVAL; - ctrl->rx_pol_inv[sds] = of_property_read_bool(child, "realtek,pnswap-rx"); - ctrl->tx_pol_inv[sds] = of_property_read_bool(child, "realtek,pnswap-tx"); + ctrl->rx_pol_inv[sds_id] = of_property_read_bool(child, "realtek,pnswap-rx"); + ctrl->tx_pol_inv[sds_id] = of_property_read_bool(child, "realtek,pnswap-tx"); } if (ctrl->cfg->init_serdes_common) { |