mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-02-20 04:06:51 +01:00
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>
This commit is contained in:
parent
74f74edfe1
commit
3cf04d2e0b
1 changed files with 43 additions and 11 deletions
|
|
@ -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");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue