net: phy: realtek: add hwmon support
Subsystems (4)
Heiner Kallweit
maintainerv2 cover net: phy: realtek: add hwmon support
This adds hwmon support for the temperature sensor on RTL822x. It's available on the standalone versions of the PHY's, and on the internal PHY's of RTL8125B(P)/RTL8125D/RTL8126.
v2:
- patch 2: move Realtek PHY driver to its own subdirectory
- patch 3: remove alarm attribute
Heiner Kallweit (3):
net: phy: realtek: add support for reading MDIO_MMD_VEND2 regs on
RTL8125/RTL8126
net: phy: move realtek PHY driver to its own subdirectory
net: phy: realtek: add hwmon support for temp sensor on RTL822x
drivers/net/phy/Kconfig | 5 +-
drivers/net/phy/Makefile | 2 +-
drivers/net/phy/realtek/Kconfig | 11 +++
drivers/net/phy/realtek/Makefile | 4 +
drivers/net/phy/realtek/realtek.h | 10 +++
drivers/net/phy/realtek/realtek_hwmon.c | 79 +++++++++++++++++++
.../phy/{realtek.c => realtek/realtek_main.c} | 24 +++++-
7 files changed, 128 insertions(+), 7 deletions(-)
create mode 100644 drivers/net/phy/realtek/Kconfig
create mode 100644 drivers/net/phy/realtek/Makefile
create mode 100644 drivers/net/phy/realtek/realtek.h
create mode 100644 drivers/net/phy/realtek/realtek_hwmon.c
rename drivers/net/phy/{realtek.c => realtek/realtek_main.c} (98%)Signature · 1 line
2.47.1
Heiner Kallweit
maintainerPATCH v2 1/3 net: phy: realtek: add support for reading MDIO_MMD_VEND2 regs on RTL8125/RTL8126
RTL8125/RTL8126 don't support MMD access to the internal PHY, but provide a mechanism to access at least all MDIO_MMD_VEND2 registers. By exposing this mechanism standard MMD access functions can be used to access the MDIO_MMD_VEND2 registers.
--- drivers/net/phy/realtek.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/phy/realtek.c +10 -2
@@ -736,7 +736,11 @@ static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) {int ret; -if (devnum ==MDIO_MMD_PCS && regnum ==MDIO_PCS_EEE_ABLE ) { +if (devnum ==MDIO_MMD_VEND2 ) { +rtl821x_write_page (phydev, regnum >>4 ); + ret =__phy_read (phydev,0x10 + ((regnum &0xf ) >>1 )); +rtl821x_write_page (phydev,0 ); + }else if (devnum ==MDIO_MMD_PCS && regnum ==MDIO_PCS_EEE_ABLE ) {rtl821x_write_page (phydev,0xa5c ); ret =__phy_read (phydev,0x12 );rtl821x_write_page (phydev,0 );
@@ -760,7 +764,11 @@ static int rtlgen_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, {int ret; -if (devnum ==MDIO_MMD_AN && regnum ==MDIO_AN_EEE_ADV ) { +if (devnum ==MDIO_MMD_VEND2 ) { +rtl821x_write_page (phydev, regnum >>4 ); + ret =__phy_write (phydev,0x10 + ((regnum &0xf ) >>1 ), val); +rtl821x_write_page (phydev,0 ); + }else if (devnum ==MDIO_MMD_AN && regnum ==MDIO_AN_EEE_ADV ) {rtl821x_write_page (phydev,0xa5d ); ret =__phy_write (phydev,0x10 , val);rtl821x_write_page (phydev,0 );
Signature · 1 line
2.47.1
Re: [PATCH net-next v2 1/3] net: phy: realtek: add support for reading MDIO_MMD_VEND2 regs on RTL8125/RTL8126
Quoted 6 lines · Heiner Kallweit
RTL8125/RTL8126 don't support MMD access to the internal PHY, but provide a mechanism to access at least all
MDIO_MMD_VEND2registers. By exposing this mechanism standard MMD access functions can be used to access theMDIO_MMD_VEND2registers.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH v2 2/3 net: phy: move realtek PHY driver to its own subdirectory
In reply to Heiner KallweitIn preparation of adding a source file with hwmon support, move the Realtek PHY driver to its own subdirectory and rename realtek.c to realtek_main.c.
---
drivers/net/phy/Kconfig | 5 +----
drivers/net/phy/Makefile | 2 +-
drivers/net/phy/realtek/Kconfig | 5 +++++
drivers/net/phy/realtek/Makefile | 3 +++
drivers/net/phy/{realtek.c => realtek/realtek_main.c} | 0
5 files changed, 10 insertions(+), 5 deletions(-)
create mode 100644 drivers/net/phy/realtek/Kconfig
create mode 100644 drivers/net/phy/realtek/Makefile
rename drivers/net/phy/{realtek.c => realtek/realtek_main.c} (100%)drivers/net/phy/Kconfig +1 -4
@@ -350,10 +350,7 @@ config QSEMI_PHY help Currently supports the qs6612 -config REALTEK_PHY - tristate "Realtek PHYs" - help - Supports the Realtek 821x PHY. +source "drivers/net/phy/realtek/Kconfig" config RENESAS_PHY tristate "Renesas PHYs"
drivers/net/phy/Makefile +1 -1
@@ -95,7 +95,7 @@ obj-$(CONFIG_NXP_CBTX_PHY) += nxp-cbtx.o obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o obj-y += qcom/ obj-$(CONFIG_QSEMI_PHY) += qsemi.o -obj-$(CONFIG_REALTEK_PHY) += realtek.o +obj-$(CONFIG_REALTEK_PHY) += realtek/ obj-$(CONFIG_RENESAS_PHY) += uPD60620.o obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o obj-$(CONFIG_SMSC_PHY) += smsc.o
drivers/net/phy/realtek/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only +config REALTEK_PHY + tristate "Realtek PHYs" + help + Currently supports RTL821x/RTL822x and fast ethernet PHYs
drivers/net/phy/realtek/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +realtek-y += realtek_main.o +obj-$(CONFIG_REALTEK_PHY) += realtek.o
drivers/net/phy/realtek/realtek_main.c renamed from drivers/net/phy/realtek.c +0 -0
Signature · 1 line
2.47.1
Re: [PATCH net-next v2 2/3] net: phy: move realtek PHY driver to its own subdirectory
Quoted 5 lines · Heiner Kallweit
In preparation of adding a source file with hwmon support, move the Realtek PHY driver to its own subdirectory and rename
realtek.ctorealtek_main.c.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH v2 3/3 net: phy: realtek: add hwmon support for temp sensor on RTL822x
In reply to Heiner KallweitThis adds hwmon support for the temperature sensor on RTL822x. It's available on the standalone versions of the PHY's, and on the integrated PHY's in RTL8125B/RTL8125D/RTL8126.
--- drivers/net/phy/realtek/Kconfig | 6 ++ drivers/net/phy/realtek/Makefile | 1 + drivers/net/phy/realtek/realtek.h | 10 ++++ drivers/net/phy/realtek/realtek_hwmon.c | 79 +++++++++++++++++++++++++ drivers/net/phy/realtek/realtek_main.c | 12 ++++ 5 files changed, 108 insertions(+) create mode 100644 drivers/net/phy/realtek/realtek.h create mode 100644 drivers/net/phy/realtek/realtek_hwmon.c
drivers/net/phy/realtek/Kconfig +6 -0
@@ -3,3 +3,9 @@ config REALTEK_PHY tristate "Realtek PHYs" help Currently supports RTL821x/RTL822x and fast ethernet PHYs + +config REALTEK_PHY_HWMON + def_bool REALTEK_PHY && HWMON + depends on !(REALTEK_PHY=y && HWMON=m) + help + Optional hwmon support for the temperature sensor
drivers/net/phy/realtek/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 realtek-y += realtek_main.o +realtek-$(CONFIG_REALTEK_PHY_HWMON) += realtek_hwmon.o obj-$(CONFIG_REALTEK_PHY) += realtek.o
drivers/net/phy/realtek/realtek.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef REALTEK_H +#define REALTEK_H + +#include <linux/phy.h> + +int rtl822x_hwmon_init (struct phy_device *phydev); + +#endif /* REALTEK_H */
drivers/net/phy/realtek/realtek_hwmon.c new file +79 -0
79 lines not on this page · raw message
drivers/net/phy/realtek/realtek_main.c +12 -0
@@ -14,6 +14,8 @@#include <linux/delay.h> #include <linux/clk.h> +#include "realtek.h" +#define RTL821x_PHYSR 0x11#define RTL821x_PHYSR_DUPLEX BIT(13)#define RTL821x_PHYSR_SPEED GENMASK(15, 14)
@@ -820,6 +822,15 @@ static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,return ret; } +static int rtl822x_probe (struct phy_device *phydev) +{ +if (IS_ENABLED (CONFIG_REALTEK_PHY_HWMON ) && + phydev->phy_id !=RTL_GENERIC_PHYID ) +return rtl822x_hwmon_init (phydev); + +return 0 ; +} +static int rtl822xb_config_init (struct phy_device *phydev) {bool has_2500, has_sgmii;
@@ -1519,6 +1530,7 @@ static struct phy_driver realtek_drvs[] = { .match_phy_device = rtl_internal_nbaset_match_phy_device, .name = "Realtek Internal NBASE-T PHY", .flags = PHY_IS_INTERNAL, + .probe = rtl822x_probe, .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .read_status = rtl822x_read_status,
Signature · 1 line
2.47.1
Andrew Lunn
maintainerRe: [PATCH net-next v2 3/3] net: phy: realtek: add hwmon support for temp sensor on RTL822x
drivers/net/phy/realtek/Kconfig config REALTEK_PHY · line 11
Quoted 5 lines
drivers/net/phy/realtek/Kconfig +5
-0+config REALTEK_PHY_HWMON + def_bool REALTEK_PHY && HWMON + depends on !(REALTEK_PHY=y && HWMON=m) + help + Optional hwmon support for the temperature sensor
We frequently end up with build problems with HWMON. All the other PHYs use:
depends on HWMON || HWMON=n
We have not yet seen 0-day report issues with your earlier patchsets versions, but maybe we should keep it the same as all other PHYs? But maybe it is actually the same, if you apply De Morgan's Law?
Andrew
Heiner Kallweit
maintainerRe: [PATCH net-next v2 3/3] net: phy: realtek: add hwmon support for temp sensor on RTL822x
Quoted 11 lines · Andrew Lunn
drivers/net/phy/realtek/Kconfig config REALTEK_PHY · line 11
Quoted 5 lines
drivers/net/phy/realtek/Kconfig +5
-0+config REALTEK_PHY_HWMON + def_bool REALTEK_PHY && HWMON + depends on !(REALTEK_PHY=y && HWMON=m) + help + Optional hwmon support for the temperature sensorWe frequently end up with build problems with HWMON. All the other PHYs use:
depends on HWMON || HWMON=n
The situation is different here. In the other cases HWMON is used from the main source file. If HWMON=n, then the main source file can be built as module or be built-in, and the stubs of the HWMON functions are used.
In my case, if HWMON=n, I want REALTEK_PHY_HWMON to be n, because then I omit building realtek_hwmon.c (see Makefile).
Quoted 5 lines
We have not yet seen 0-day report issues with your earlier patchsets versions, but maybe we should keep it the same as all other PHYs? But maybe it is actually the same, if you apply De Morgan's Law?
Andrew
Heiner
Re: [PATCH net-next v2 3/3] net: phy: realtek: add hwmon support for temp sensor on RTL822x
Quoted 2 lines
In my case, if HWMON=n, I want
REALTEK_PHY_HWMONto be n, because then I omit buildingrealtek_hwmon.c(seeMakefile).
Thanks for the explanation.
Andrew
Re: [PATCH net-next v2 3/3] net: phy: realtek: add hwmon support for temp sensor on RTL822x
In reply to Heiner KallweitHi Heiner,
CC hwmon
Quoted 5 lines · Heiner Kallweit
This adds hwmon support for the temperature sensor on RTL822x. It's available on the standalone versions of the PHY's, and on the integrated PHY's in RTL8125B/RTL8125D/RTL8126.
Signed-off-by Heiner Kallweit <[email protected]>
Thanks for your patch, which is now commit 33700ca45b7d2e16 ("net: phy: realtek: add hwmon support for temp sensor on RTL822x") in net-next.
drivers/net/phy/realtek/Kconfig config REALTEK_PHY · line 11
Quoted 12 lines
drivers/net/phy/realtek/Kconfig +6
-0@@ -3,3 +3,9 @@ config REALTEK_PHY tristate "Realtek PHYs" help Currently supports RTL821x/RTL822x and fast ethernet PHYs + +config REALTEK_PHY_HWMON + def_bool REALTEK_PHY && HWMON + depends on !(REALTEK_PHY=y && HWMON=m) + help + Optional hwmon support for the temperature sensor
So this is optional, but as the symbol is invisible, it cannot be disabled by the user. Is that intentional?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Heiner Kallweit
maintainerRe: [PATCH net-next v2 3/3] net: phy: realtek: add hwmon support for temp sensor on RTL822x
Quoted 15 lines · Geert Uytterhoeven
Hi Heiner,
CC hwmon
Quoted 5 lines · Heiner Kallweit
This adds hwmon support for the temperature sensor on RTL822x. It's available on the standalone versions of the PHY's, and on the integrated PHY's in RTL8125B/RTL8125D/RTL8126.
Signed-off-by Heiner Kallweit <[email protected]>Thanks for your patch, which is now commit
33700ca45b7d2e16("net: phy: realtek: add hwmon support for temp sensor on RTL822x") in net-next.
Quoted 16 lines
drivers/net/phy/realtek/Kconfig config REALTEK_PHY · line 11
Quoted 12 lines
drivers/net/phy/realtek/Kconfig +0
-0@@ -3,3 +3,9 @@ config REALTEK_PHYtristate "Realtek PHYs"
help
Currently supports RTL821x/RTL822x and fast ethernet PHYsdrivers/net/phy/realtek/Kconfig +6
-0+ +config REALTEK_PHY_HWMON + def_bool REALTEK_PHY && HWMON + depends on !(REALTEK_PHY=y && HWMON=m) + help + Optional hwmon support for the temperature sensorSo this is optional, but as the symbol is invisible, it cannot be disabled by the user. Is that intentional?
Well, it isn't intentional in either direction. Thanks for the hint, I should make it user-visible.
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sat, 11 Jan 2025 21:48:29 +0100 you wrote:
This adds hwmon support for the temperature sensor on RTL822x. It's available on the standalone versions of the PHY's, and on the internal PHY's of RTL8125B(P)/RTL8125D/RTL8126.
v2:
- patch 2: move Realtek PHY driver to its own subdirectory
- patch 3: remove alarm attribute[...]
Here is the summary with links:
- [net-next,v2,1/3] net: phy: realtek: add support for reading MDIO_MMD_VEND2 regs on RTL8125/RTL8126
https://git.kernel.org/netdev/net-next/c/3d483a10327f - [net-next,v2,2/3] net: phy: move realtek PHY driver to its own subdirectory https://git.kernel.org/netdev/net-next/c/1416a9b2ba71 - [net-next,v2,3/3] net: phy: realtek: add hwmon support for temp sensor on RTL822x https://git.kernel.org/netdev/net-next/c/33700ca45b7d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html