* [PATCH 1/2] net: phy: motorcomm: add led_brightness_set for YT8521
@ 2026-11-10 10:00 Chukun Pan
2026-11-10 10:00 ` [PATCH 2/2] net: phy: motorcomm: add missing trigger link " Chukun Pan
2026-11-10 16:53 ` [PATCH 1/2] net: phy: motorcomm: add led_brightness_set " Andrew Lunn
0 siblings, 2 replies; 6+ messages in thread
From: Chukun Pan @ 2026-11-10 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.
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
---
drivers/net/phy/motorcomm.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 463e1ea3efc9..bcd3afef0d49 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -258,6 +258,10 @@
#define YTPHY_WCR_INTR_SEL BIT(6)
#define YTPHY_WCR_ENABLE BIT(3)
+#define YTPHY_LED_GENERAL_CFG_REG 0xA00B
+#define YTPHY_LED_FORCE_MODE(x) BIT((x) * 3)
+#define YTPHY_LED_FORCE_EN(x) BIT((x) * 3 + 2)
+
/* 2b00 84ms
* 2b01 168ms *default*
* 2b10 336ms
@@ -1775,6 +1779,31 @@ static int yt8531s_config_init(struct phy_device *phydev)
return phy_restore_page(phydev, old_page, ret);
}
+static int yt8521_led_brightness_set(struct phy_device *phydev, u8 index,
+ enum led_brightness value)
+{
+ u16 regs;
+ 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;
+
+ regs = ytphy_read_ext(phydev, YTPHY_LED_GENERAL_CFG_REG);
+ if (value != LED_OFF)
+ regs |= YTPHY_LED_FORCE_EN(index) |
+ YTPHY_LED_FORCE_MODE(index);
+ else
+ regs &= ~(YTPHY_LED_FORCE_EN(index) |
+ YTPHY_LED_FORCE_MODE(index));
+
+ return ytphy_write_ext(phydev, YTPHY_LED_GENERAL_CFG_REG, regs);
+}
+
static const unsigned long supported_trgs = (BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
BIT(TRIGGER_NETDEV_HALF_DUPLEX) |
BIT(TRIGGER_NETDEV_LINK) |
@@ -3266,6 +3295,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 +3318,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] 6+ messages in thread
* [PATCH 2/2] net: phy: motorcomm: add missing trigger link for YT8521
2026-11-10 10:00 [PATCH 1/2] net: phy: motorcomm: add led_brightness_set for YT8521 Chukun Pan
@ 2026-11-10 10:00 ` Chukun Pan
2026-11-10 16:54 ` Andrew Lunn
2026-11-10 16:53 ` [PATCH 1/2] net: phy: motorcomm: add led_brightness_set " Andrew Lunn
1 sibling, 1 reply; 6+ messages in thread
From: Chukun Pan @ 2026-11-10 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>
---
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 bcd3afef0d49..5b1d17bd231a 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -1901,6 +1901,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] 6+ messages in thread
* Re: [PATCH 1/2] net: phy: motorcomm: add led_brightness_set for YT8521
2026-11-10 10:00 [PATCH 1/2] net: phy: motorcomm: add led_brightness_set for YT8521 Chukun Pan
2026-11-10 10:00 ` [PATCH 2/2] net: phy: motorcomm: add missing trigger link " Chukun Pan
@ 2026-11-10 16:53 ` Andrew Lunn
2026-11-11 6:50 ` Chukun Pan
1 sibling, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2026-11-10 16:53 UTC (permalink / raw)
To: Chukun Pan
Cc: Frank, Paolo Abeni, Jakub Kicinski, Eric Dumazet,
David S . Miller, Heiner Kallweit, linux-kernel, netdev
On Tue, Nov 10, 2026 at 06:00:00PM +0800, Chukun Pan wrote:
> Add support for manual brightness setting on YT8521/YT8531 PHY.
Has this been tested on real hardware? Have you had it blinking the
heartbeat? Shift-lock etc.
> --- a/drivers/net/phy/motorcomm.c
> +++ b/drivers/net/phy/motorcomm.c
> @@ -258,6 +258,10 @@
> #define YTPHY_WCR_INTR_SEL BIT(6)
> #define YTPHY_WCR_ENABLE BIT(3)
>
> +#define YTPHY_LED_GENERAL_CFG_REG 0xA00B
> +#define YTPHY_LED_FORCE_MODE(x) BIT((x) * 3)
> +#define YTPHY_LED_FORCE_EN(x) BIT((x) * 3 + 2)
> +
> /* 2b00 84ms
> * 2b01 168ms *default*
> * 2b10 336ms
I _think_ this is the wrong place to insert these. 2b00 84ms refers to
YTPHY_WCR_PULSE_WIDTH_MASK which is used with YTPHY_WOL_CONFIG_REG? So
you insert these in the middle of WOL bits.
The sorting of registers is a bit messed up in this driver, but i
think you need to insert before:
#define YTPHY_PAD_DRIVE_STRENGTH_REG 0xA010
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] net: phy: motorcomm: add missing trigger link for YT8521
2026-11-10 10:00 ` [PATCH 2/2] net: phy: motorcomm: add missing trigger link " Chukun Pan
@ 2026-11-10 16:54 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2026-11-10 16:54 UTC (permalink / raw)
To: Chukun Pan
Cc: Frank, Paolo Abeni, Jakub Kicinski, Eric Dumazet,
David S . Miller, Heiner Kallweit, linux-kernel, netdev
On Tue, Nov 10, 2026 at 06:00:01PM +0800, Chukun Pan wrote:
> 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>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] net: phy: motorcomm: add led_brightness_set for YT8521
2026-11-10 16:53 ` [PATCH 1/2] net: phy: motorcomm: add led_brightness_set " Andrew Lunn
@ 2026-11-11 6:50 ` Chukun Pan
2026-11-11 13:20 ` Andrew Lunn
0 siblings, 1 reply; 6+ messages in thread
From: Chukun Pan @ 2026-11-11 6:50 UTC (permalink / raw)
To: andrew
Cc: Frank.Sae, amadeus, davem, edumazet, hkallweit1, kuba,
linux-kernel, netdev, pabeni
Hi,
> Has this been tested on real hardware?
I tested yt8531 on some SBCs and will add this to the commit message.
> Have you had it blinking the heartbeat? Shift-lock etc.
Only supports forced LED on/off. Forced blink is disabled by default.
Do I need to implement heartbeat?
> I _think_ this is the wrong place to insert these.
>
> The sorting of registers is a bit messed up in this driver, but i
> think you need to insert before:
>
> #define YTPHY_PAD_DRIVE_STRENGTH_REG 0xA010
Indeed, I will correct this.
Thanks,
Chukun
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] net: phy: motorcomm: add led_brightness_set for YT8521
2026-11-11 6:50 ` Chukun Pan
@ 2026-11-11 13:20 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2026-11-11 13:20 UTC (permalink / raw)
To: Chukun Pan
Cc: Frank.Sae, davem, edumazet, hkallweit1, kuba, linux-kernel,
netdev, pabeni
> Only supports forced LED on/off. Forced blink is disabled by default.
> Do I need to implement heartbeat?
drivers/leds/trigger/ledtrig-heartbeat.c
You can enable it just like any other trigger.
I find it useful to know when my bugs have caused a deadlock, etc.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-11 13:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 10:00 [PATCH 1/2] net: phy: motorcomm: add led_brightness_set for YT8521 Chukun Pan
2026-11-10 10:00 ` [PATCH 2/2] net: phy: motorcomm: add missing trigger link " Chukun Pan
2026-11-10 16:54 ` Andrew Lunn
2026-11-10 16:53 ` [PATCH 1/2] net: phy: motorcomm: add led_brightness_set " Andrew Lunn
2026-11-11 6:50 ` Chukun Pan
2026-11-11 13:20 ` 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®