summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Jelonek2025-10-08 08:19:25 +0000
committerRobert Marko2025-10-10 09:00:15 +0000
commit3cf04d2e0b95b853c09af7f709a81ee1a2ca6480 (patch)
tree3b4134b008ff8370b4c6111eed8f00ba9872248b
parent74f74edfe1ea7bd324afe5cd5b79ea3a101d8fc4 (diff)
downloadopenwrt-3cf04d2e0b95b853c09af7f709a81ee1a2ca6480.tar.gz
realtek: pcs: add more SerDes access helpers
Add more SerDes access helpers for the upcoming code import from PHY driver. There, similar helpers are used to read and write full SerDes registers or only parts of them (aka bitfields). The helpers are expected to replace the following used in PHY SerDes code: - rtl9300_sds_field_r - rtl9300_sds_field_w - rtsds_931x_read - rtsds_931x_read_field - rtsds_931x_write - rtsds_931x_write_field Mark the helpers as unused for now to make the compiler happy. This will be removed as soon as they are used. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> Link: https://github.com/openwrt/openwrt/pull/20352 Signed-off-by: Robert Marko <robimarko@gmail.com>
-rw-r--r--target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c54
1 files changed, 43 insertions, 11 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 6a88b8c766..72b37ba8e2 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
@@ -92,16 +92,48 @@ static int rtpcs_sds_read(struct rtpcs_ctrl *ctrl, int sds, int page, int regnum
return mdiobus_c45_read(ctrl->bus, sds, MDIO_MMD_VEND1, mmd_regnum);
}
-/*
- * For later use, when the SerDes registers need to be written ...
- *
- * static int rtpcs_sds_write(struct rtpcs_ctrl *ctrl, int sds, int page, int regnum, u16 value)
- * {
- * int mmd_regnum = rtpcs_sds_to_mmd(page, regnum);
- *
- * return mdiobus_c45_write(ctrl->bus, sds, MDIO_MMD_VEND1, mmd_regnum, value);
- * }
- */
+__attribute__((unused))
+static int rtpcs_sds_read_bits(struct rtpcs_ctrl *ctrl, int sds, int page,
+ int regnum, int bithigh, int bitlow)
+{
+ int mask, val;
+
+ WARN_ON(bithigh < bitlow);
+
+ mask = GENMASK(bithigh, bitlow);
+ val = rtpcs_sds_read(ctrl, sds, page, regnum);
+ if (val < 0)
+ return val;
+
+ return (val & mask) >> bitlow;
+}
+
+__attribute__((unused))
+static int rtpcs_sds_write(struct rtpcs_ctrl *ctrl, int sds, int page, int regnum, u16 value)
+{
+ int mmd_regnum = rtpcs_sds_to_mmd(page, regnum);
+
+ return mdiobus_c45_write(ctrl->bus, sds, MDIO_MMD_VEND1, mmd_regnum, value);
+}
+
+__attribute__((unused))
+static int rtpcs_sds_write_bits(struct rtpcs_ctrl *ctrl, int sds, int page,
+ int regnum, int bithigh, int bitlow, u16 value)
+{
+ int mask, reg;
+
+ WARN_ON(bithigh < bitlow);
+
+ mask = GENMASK(bithigh, bitlow);
+ reg = rtpcs_sds_read(ctrl, sds, page, regnum);
+ if (reg < 0)
+ return reg;
+
+ reg = (reg & ~mask);
+ reg |= (value << bitlow) & mask;
+
+ return rtpcs_sds_write(ctrl, sds, page, regnum, reg);
+}
static int rtpcs_sds_modify(struct rtpcs_ctrl *ctrl, int sds, int page, int regnum,
u16 mask, u16 set)
@@ -476,4 +508,4 @@ module_platform_driver(rtpcs_driver);
MODULE_AUTHOR("Markus Stockhausen <markus.stockhausen@gmx.de>");
MODULE_DESCRIPTION("Realtek Otto SerDes PCS driver");
-MODULE_LICENSE("GPL v2"); \ No newline at end of file
+MODULE_LICENSE("GPL v2");