Message ID | 20231011123856.1443308-2-o.rempel@pengutronix.de (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,v1,1/3] net: phy: micrel: Extend KSZ886X PHY Special Ctrl/Status Reg definitions | expand |
Hi Oleksij, kernel test robot noticed the following build warnings: [auto build test WARNING on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Oleksij-Rempel/net-dsa-microchip-ksz8-Enable-MIIM-PHY-Control-reg-access/20231011-204502 base: net-next/main patch link: https://lore.kernel.org/r/20231011123856.1443308-2-o.rempel%40pengutronix.de patch subject: [PATCH net-next v1 2/3] net: dsa: microchip: ksz8: Enable MIIM PHY Control reg access config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231011/202310112224.iYgvjBUy-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231011/202310112224.iYgvjBUy-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202310112224.iYgvjBUy-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/net/dsa/microchip/ksz8795.c:646: warning: Function parameter or member 'val' not described in 'ksz8_r_phy_ctrl' vim +646 drivers/net/dsa/microchip/ksz8795.c 634 635 /** 636 * ksz8_r_phy_ctrl - Translates and reads from the SMI interface to a MIIM PHY 637 * Control register (Reg. 31). 638 * @dev: The KSZ device instance. 639 * @port: The port number to be read. 640 * 641 * This function reads the SMI interface and translates the hardware register 642 * bit values into their corresponding control settings for a MIIM PHY Control 643 * register. 644 */ 645 static int ksz8_r_phy_ctrl(struct ksz_device *dev, int port, u16 *val) > 646 { 647 const u16 *regs = dev->info->regs; 648 u8 reg_val; 649 int ret; 650 651 *val = 0; 652 653 ret = ksz_pread8(dev, port, regs[P_LINK_STATUS], ®_val); 654 if (ret < 0) 655 return ret; 656 657 if (reg_val & PORT_MDIX_STATUS) 658 *val |= KSZ886X_CTRL_MDIX_STAT; 659 660 ret = ksz_pread8(dev, port, REG_PORT_LINK_MD_CTRL, ®_val); 661 if (ret < 0) 662 return ret; 663 664 if (reg_val & PORT_FORCE_LINK) 665 *val |= KSZ886X_CTRL_FORCE_LINK; 666 667 if (reg_val & PORT_POWER_SAVING) 668 *val |= KSZ886X_CTRL_PWRSAVE; 669 670 if (reg_val & PORT_PHY_REMOTE_LOOPBACK) 671 *val |= KSZ886X_CTRL_REMOTE_LOOPBACK; 672 673 return 0; 674 } 675
On Wed, Oct 11, 2023 at 02:38:55PM +0200, Oleksij Rempel wrote: > Provide access to MIIM PHY Control register (Reg. 31) through > ksz8_r_phy_ctrl() and ksz8_w_phy_ctrl() functions. Necessary for > upcoming micrel.c patch to address forced link mode configuration. > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > --- > drivers/net/dsa/microchip/ksz8795.c | 81 +++++++++++++++++++++++++++-- > 1 file changed, 78 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c > index 91aba470fb2f..11cb054cb54f 100644 > --- a/drivers/net/dsa/microchip/ksz8795.c > +++ b/drivers/net/dsa/microchip/ksz8795.c > @@ -632,6 +632,47 @@ static void ksz8_w_vlan_table(struct ksz_device *dev, u16 vid, u16 vlan) > ksz8_w_table(dev, TABLE_VLAN, addr, buf); > } > > +/** > + * ksz8_r_phy_ctrl - Translates and reads from the SMI interface to a MIIM PHY > + * Control register (Reg. 31). > + * @dev: The KSZ device instance. > + * @port: The port number to be read. nit: please include an entry for @val here > + * > + * This function reads the SMI interface and translates the hardware register > + * bit values into their corresponding control settings for a MIIM PHY Control > + * register. > + */ > +static int ksz8_r_phy_ctrl(struct ksz_device *dev, int port, u16 *val) ...
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 91aba470fb2f..11cb054cb54f 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -632,6 +632,47 @@ static void ksz8_w_vlan_table(struct ksz_device *dev, u16 vid, u16 vlan) ksz8_w_table(dev, TABLE_VLAN, addr, buf); } +/** + * ksz8_r_phy_ctrl - Translates and reads from the SMI interface to a MIIM PHY + * Control register (Reg. 31). + * @dev: The KSZ device instance. + * @port: The port number to be read. + * + * This function reads the SMI interface and translates the hardware register + * bit values into their corresponding control settings for a MIIM PHY Control + * register. + */ +static int ksz8_r_phy_ctrl(struct ksz_device *dev, int port, u16 *val) +{ + const u16 *regs = dev->info->regs; + u8 reg_val; + int ret; + + *val = 0; + + ret = ksz_pread8(dev, port, regs[P_LINK_STATUS], ®_val); + if (ret < 0) + return ret; + + if (reg_val & PORT_MDIX_STATUS) + *val |= KSZ886X_CTRL_MDIX_STAT; + + ret = ksz_pread8(dev, port, REG_PORT_LINK_MD_CTRL, ®_val); + if (ret < 0) + return ret; + + if (reg_val & PORT_FORCE_LINK) + *val |= KSZ886X_CTRL_FORCE_LINK; + + if (reg_val & PORT_POWER_SAVING) + *val |= KSZ886X_CTRL_PWRSAVE; + + if (reg_val & PORT_PHY_REMOTE_LOOPBACK) + *val |= KSZ886X_CTRL_REMOTE_LOOPBACK; + + return 0; +} + int ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) { u8 restart, speed, ctrl, link; @@ -769,12 +810,10 @@ int ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) FIELD_GET(PORT_CABLE_FAULT_COUNTER_L, val2)); break; case PHY_REG_PHY_CTRL: - ret = ksz_pread8(dev, p, regs[P_LINK_STATUS], &link); + ret = ksz8_r_phy_ctrl(dev, p, &data); if (ret) return ret; - if (link & PORT_MDIX_STATUS) - data |= KSZ886X_CTRL_MDIX_STAT; break; default: processed = false; @@ -786,6 +825,36 @@ int ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) return 0; } +/** + * ksz8_w_phy_ctrl - Translates and writes to the SMI interface from a MIIM PHY + * Control register (Reg. 31). + * @dev: The KSZ device instance. + * @port: The port number to be configured. + * @val: The register value to be written. + * + * This function translates control settings from a MIIM PHY Control register + * into their corresponding hardware register bit values for the SMI + * interface. + */ +static int ksz8_w_phy_ctrl(struct ksz_device *dev, int port, u16 val) +{ + u8 reg_val = 0; + int ret; + + if (val & KSZ886X_CTRL_FORCE_LINK) + reg_val |= PORT_FORCE_LINK; + + if (val & KSZ886X_CTRL_PWRSAVE) + reg_val |= PORT_POWER_SAVING; + + if (val & KSZ886X_CTRL_REMOTE_LOOPBACK) + reg_val |= PORT_PHY_REMOTE_LOOPBACK; + + ret = ksz_prmw8(dev, port, REG_PORT_LINK_MD_CTRL, PORT_FORCE_LINK | + PORT_POWER_SAVING | PORT_PHY_REMOTE_LOOPBACK, reg_val); + return ret; +} + int ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val) { u8 restart, speed, ctrl, data; @@ -926,6 +995,12 @@ int ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val) if (val & PHY_START_CABLE_DIAG) ksz_port_cfg(dev, p, REG_PORT_LINK_MD_CTRL, PORT_START_CABLE_DIAG, true); break; + + case PHY_REG_PHY_CTRL: + ret = ksz8_w_phy_ctrl(dev, p, val); + if (ret) + return ret; + break; default: break; }
Provide access to MIIM PHY Control register (Reg. 31) through ksz8_r_phy_ctrl() and ksz8_w_phy_ctrl() functions. Necessary for upcoming micrel.c patch to address forced link mode configuration. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> --- drivers/net/dsa/microchip/ksz8795.c | 81 +++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-)