* [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set for YT8521
@ 2026-11-30 10:00 Chukun Pan
2026-11-30 10:00 ` [PATCH net-next v3 2/2] net: phy: motorcomm: add missing trigger link " Chukun Pan
2026-11-30 13:17 ` [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set " Andrew Lunn
0 siblings, 2 replies; 3+ messages in thread
From: Chukun Pan @ 2026-11-30 10:00 UTC (permalink / raw)
To: Frank
Cc: Andrew Lunn, Paolo Abeni, Jakub Kicinski, Eric Dumazet,
David S . Miller, Heiner Kallweit, linux-kernel, netdev,
Chukun Pan
Add support for manual brightness setting on YT8521/YT8531 PHY.
Switching to the netdev trigger will disable led forced mode.
Testing with netdev and heartbeat on the Radxa E20C (YT8531).
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
---
Changes in v3:
Use GENMASK() to describe the FORCE_MODE field
Changes in v2:
Fix macro definition location
Add missing checks for using ytphy_read_ext()
Clear force led status in led_hw_control_set()
---
drivers/net/phy/motorcomm.c | 49 +++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index a87e83fdf590..e0c6477a53e4 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -271,6 +271,10 @@
*/
#define YTPHY_WCR_TYPE_PULSE BIT(0)
+#define YTPHY_LED_GENERAL_CFG_REG 0xA00B
+#define YTPHY_LED_FORCE_EN(x) BIT((x) * 3 + 2)
+#define YTPHY_LED_FORCE_MODE(x) GENMASK((x) * 3 + 1, (x) * 3)
+
#define YTPHY_PAD_DRIVE_STRENGTH_REG 0xA010
#define YT8531_RGMII_RXC_DS_MASK GENMASK(15, 13)
#define YT8531_RGMII_RXD_DS_HI_MASK BIT(12) /* Bit 2 of rxd_ds */
@@ -1775,6 +1779,44 @@ static int yt8531s_config_init(struct phy_device *phydev)
return phy_restore_page(phydev, old_page, ret);
}
+static int yt8521_hw_led_on_set(struct phy_device *phydev, u8 index,
+ bool value)
+{
+ int reg, val;
+ u16 mask;
+
+ val = ytphy_read_ext(phydev, YTPHY_LED_GENERAL_CFG_REG);
+ if (val < 0)
+ return val;
+
+ mask = YTPHY_LED_FORCE_EN(index) | YTPHY_LED_FORCE_MODE(index);
+ /* 0: force OFF, 1: force ON, same as the value */
+ reg = (val & ~mask) | (value << (index * 3));
+ if (value)
+ reg |= YTPHY_LED_FORCE_EN(index);
+
+ if (reg == val)
+ return 0;
+
+ return ytphy_write_ext(phydev, YTPHY_LED_GENERAL_CFG_REG, reg);
+}
+
+static int yt8521_led_brightness_set(struct phy_device *phydev, u8 index,
+ enum led_brightness value)
+{
+ int ret;
+
+ if (index >= YT8521_MAX_LEDS)
+ return -EINVAL;
+
+ /* clear HW LED setup */
+ ret = ytphy_write_ext(phydev, YT8521_LED0_CFG_REG + index, 0);
+ if (ret < 0)
+ return ret;
+
+ return yt8521_hw_led_on_set(phydev, index, (value != LED_OFF));
+}
+
static const unsigned long supported_trgs = (BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
BIT(TRIGGER_NETDEV_HALF_DUPLEX) |
BIT(TRIGGER_NETDEV_LINK) |
@@ -1801,10 +1843,15 @@ static int yt8521_led_hw_control_set(struct phy_device *phydev, u8 index,
unsigned long rules)
{
u16 val = 0;
+ int ret;
if (index >= YT8521_MAX_LEDS)
return -EINVAL;
+ ret = yt8521_hw_led_on_set(phydev, index, false);
+ if (ret < 0)
+ return ret;
+
if (test_bit(TRIGGER_NETDEV_LINK, &rules)) {
val |= YT8521_LED_10_ON_EN;
val |= YT8521_LED_100_ON_EN;
@@ -3266,6 +3313,7 @@ static struct phy_driver motorcomm_phy_drvs[] = {
.soft_reset = yt8521_soft_reset,
.suspend = yt8521_suspend,
.resume = yt8521_resume,
+ .led_brightness_set = yt8521_led_brightness_set,
.led_hw_is_supported = yt8521_led_hw_is_supported,
.led_hw_control_set = yt8521_led_hw_control_set,
.led_hw_control_get = yt8521_led_hw_control_get,
@@ -3288,6 +3336,7 @@ static struct phy_driver motorcomm_phy_drvs[] = {
.get_wol = ytphy_get_wol,
.set_wol = yt8531_set_wol,
.link_change_notify = yt8531_link_change_notify,
+ .led_brightness_set = yt8521_led_brightness_set,
.led_hw_is_supported = yt8521_led_hw_is_supported,
.led_hw_control_set = yt8521_led_hw_control_set,
.led_hw_control_get = yt8521_led_hw_control_get,
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net-next v3 2/2] net: phy: motorcomm: add missing trigger link for YT8521
2026-11-30 10:00 [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set for YT8521 Chukun Pan
@ 2026-11-30 10:00 ` Chukun Pan
2026-11-30 13:17 ` [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set " Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: Chukun Pan @ 2026-11-30 10:00 UTC (permalink / raw)
To: Frank
Cc: Andrew Lunn, Paolo Abeni, Jakub Kicinski, Eric Dumazet,
David S . Miller, Heiner Kallweit, linux-kernel, netdev,
Chukun Pan
TRIGGER_NETDEV_LINK is available in led_hw_control_set,
but missing in led_hw_control_get. Add it.
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
Changes in v2:
Collect Reviewed-by
---
drivers/net/phy/motorcomm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index e0c6477a53e4..27aee44a420f 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -1919,6 +1919,11 @@ static int yt8521_led_hw_control_get(struct phy_device *phydev, u8 index,
if (val & YT8521_LED_10_ON_EN)
__set_bit(TRIGGER_NETDEV_LINK_10, rules);
+ if ((val & YT8521_LED_10_ON_EN) &&
+ (val & YT8521_LED_100_ON_EN) &&
+ (val & YT8521_LED_1000_ON_EN))
+ __set_bit(TRIGGER_NETDEV_LINK, rules);
+
return 0;
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set for YT8521
2026-11-30 10:00 [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set for YT8521 Chukun Pan
2026-11-30 10:00 ` [PATCH net-next v3 2/2] net: phy: motorcomm: add missing trigger link " Chukun Pan
@ 2026-11-30 13:17 ` Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2026-11-30 13:17 UTC (permalink / raw)
To: Chukun Pan
Cc: Frank, Paolo Abeni, Jakub Kicinski, Eric Dumazet,
David S . Miller, Heiner Kallweit, linux-kernel, netdev
On Mon, Nov 30, 2026 at 06:00:00PM +0800, Chukun Pan wrote:
> Add support for manual brightness setting on YT8521/YT8531 PHY.
> Switching to the netdev trigger will disable led forced mode.
> Testing with netdev and heartbeat on the Radxa E20C (YT8531).
>
> Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 13:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 10:00 [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set for YT8521 Chukun Pan
2026-11-30 10:00 ` [PATCH net-next v3 2/2] net: phy: motorcomm: add missing trigger link " Chukun Pan
2026-11-30 13:17 ` [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set " Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®