[openwrt/openwrt] realtek: pcs: add SerDes register struct and use it
LEDE Commits
lede-commits at lists.infradead.org
Mon Feb 16 06:43:25 PST 2026
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/fb0bc84182ff44acd61701c6d7f685a1596dc133
commit fb0bc84182ff44acd61701c6d7f685a1596dc133
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Fri Feb 13 22:05:32 2026 +0000
realtek: pcs: add SerDes register struct and use it
Slight differences between the variants of the Otto family are handled
so far handled using function indirection by defining per-variant
operations which are called from generic implementations. In several
case, this can still be optimized because the variants only differ in
some register addresses and/or bits while the procedure otherwise is
exactly the same.
To address this, add a new SerDes register struct where register fields
can be described and later used by generic implementations which otherwise
would need to be separate just because of slight differences. Add two
register fields for autonegotiation to that register struct which are
used by a successing patch to address a real issue.
Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/22013
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../files-6.12/drivers/net/pcs/pcs-rtl-otto.c | 29 ++++++++++++++++++++++
1 file changed, 29 insertions(+)
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 b0c1674bb7..96dc3ab00f 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
@@ -174,9 +174,23 @@ struct rtpcs_serdes_ops {
void (*restart_autoneg)(struct rtpcs_serdes *sds);
};
+struct rtpcs_sds_reg_field {
+ u8 page;
+ u8 reg;
+ u8 msb;
+ u8 lsb;
+};
+
+struct rtpcs_sds_regs {
+ struct rtpcs_sds_reg_field an_enable;
+ struct rtpcs_sds_reg_field an_restart;
+ struct rtpcs_sds_reg_field an_advertise;
+};
+
struct rtpcs_serdes {
struct rtpcs_ctrl *ctrl;
const struct rtpcs_serdes_ops *ops;
+ const struct rtpcs_sds_regs *regs;
enum rtpcs_sds_mode hw_mode;
u8 id;
u8 num_of_links;
@@ -218,6 +232,7 @@ struct rtpcs_config {
const struct phylink_pcs_ops *pcs_ops;
const struct rtpcs_serdes_ops *sds_ops;
+ const struct rtpcs_sds_regs *sds_regs;
int (*init_serdes_common)(struct rtpcs_ctrl *ctrl);
int (*setup_serdes)(struct rtpcs_serdes *sds, enum rtpcs_sds_mode hw_mode);
};
@@ -313,6 +328,19 @@ static int rtpcs_sds_write(struct rtpcs_serdes *sds, int page, int regnum, u16 v
return sds->ops->write(sds, page, regnum, 15, 0, value);
}
+__maybe_unused
+static int rtpcs_sds_read_field(struct rtpcs_serdes *sds, const struct rtpcs_sds_reg_field *field)
+{
+ return sds->ops->read(sds, field->page, field->reg, field->msb, field->lsb);
+}
+
+__maybe_unused
+static int rtpcs_sds_write_field(struct rtpcs_serdes *sds, const struct rtpcs_sds_reg_field *field,
+ u16 value)
+{
+ return sds->ops->write(sds, field->page, field->reg, field->msb, field->lsb, value);
+}
+
__maybe_unused
static int rtpcs_sds_xsg_write_bits(struct rtpcs_serdes *sds, int page, int regnum, int bithigh,
int bitlow, u16 value)
@@ -4016,6 +4044,7 @@ static int rtpcs_probe(struct platform_device *pdev)
sds->first_start = true;
sds->id = i;
sds->ops = ctrl->cfg->sds_ops;
+ sds->regs = ctrl->cfg->sds_regs;
}
for_each_child_of_node(dev->of_node, child) {
More information about the lede-commits
mailing list