From e1e42b2f42c0e48f54a7207e33b68efcbd7a955d Mon Sep 17 00:00:00 2001 From: Heinrich Toews Date: Thu, 9 Apr 2026 17:12:19 +0200 Subject: [PATCH] leds: wago-m4: extend 'led-default-intensity' with optional brightness cell The 'led-default-intensity' property now accepts an optional 4th cell for the initial LED brightness, in addition to the three R/G/B cells: led-default-intensity = ; /* colour only (unchanged) */ led-default-intensity = ; /* colour + brightness */ Both forms are accepted; existing 3-cell entries are unaffected. Driver (drivers/leds/rgb/wago-m4-led-wrapper.c): - Use fwnode_property_count_u32() to detect 3- vs. 4-cell form. - When 4 cells are present, apply the 4th value to led_cdev.brightness via clamp_val(rgba[3], 0, LED_FULL). DTS (arch/arm64/boot/dts/ti/k3-am623-pfc-750-8400.dts): - Set sys LED to <255 80 0 64> so it blinks orange at brightness 64/255 instead of the default full brightness. Signed-off-by: Heinrich Toews --- .../boot/dts/ti/k3-am623-pfc-750-8400.dts | 2 +- drivers/leds/rgb/wago-m4-led-wrapper.c | 31 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/arch/arm64/boot/dts/ti/k3-am623-pfc-750-8400.dts b/arch/arm64/boot/dts/ti/k3-am623-pfc-750-8400.dts index 7500cedecef3..5f59d8c7486c 100644 --- a/arch/arm64/boot/dts/ti/k3-am623-pfc-750-8400.dts +++ b/arch/arm64/boot/dts/ti/k3-am623-pfc-750-8400.dts @@ -26,7 +26,7 @@ reg = <0>; label = "sys"; linux,default-trigger = "timer"; - led-default-intensity = <255 80 0>; /* Orange */ + led-default-intensity = <255 80 0 64>; /* Orange, brightness 64/255 */ }; led@1 { diff --git a/drivers/leds/rgb/wago-m4-led-wrapper.c b/drivers/leds/rgb/wago-m4-led-wrapper.c index 7f5ec5dff076..e0d4bbb75b61 100644 --- a/drivers/leds/rgb/wago-m4-led-wrapper.c +++ b/drivers/leds/rgb/wago-m4-led-wrapper.c @@ -394,9 +394,10 @@ static void wago_led_init_subled(struct wago_led *led) /* * wago_led_apply_default_intensity - read optional 'led-default-intensity' - * DT property and apply R/G/B values to subled_info[]. + * DT property and apply R/G/B values and optional brightness to the LED. * - * Property format: (three u32 values, each 0-255) + * Property format: (three u32 values, each 0-255) + * or: (four u32 values, each 0-255) * If the property is absent or malformed the subled defaults (255/255/255) * set by wago_led_init_subled() are kept unchanged. */ @@ -404,18 +405,28 @@ static void wago_led_apply_default_intensity(struct device *dev, struct wago_led *led, struct fwnode_handle *fwnode) { - u32 rgb[3]; + u32 rgba[4] = { 255, 255, 255, LED_FULL }; + int count; + + /* Accept both 3-cell (R G B) and 4-cell (R G B brightness) */ + count = fwnode_property_count_u32(fwnode, "led-default-intensity"); + if (count != 3 && count != 4) + return; /* property absent or wrong size — keep defaults */ if (fwnode_property_read_u32_array(fwnode, "led-default-intensity", - rgb, ARRAY_SIZE(rgb))) - return; /* property absent — keep defaults */ + rgba, count)) + return; - led->subled_info[CH_RED].intensity = clamp_val(rgb[0], 0, 255); - led->subled_info[CH_GREEN].intensity = clamp_val(rgb[1], 0, 255); - led->subled_info[CH_BLUE].intensity = clamp_val(rgb[2], 0, 255); + led->subled_info[CH_RED].intensity = clamp_val(rgba[0], 0, 255); + led->subled_info[CH_GREEN].intensity = clamp_val(rgba[1], 0, 255); + led->subled_info[CH_BLUE].intensity = clamp_val(rgba[2], 0, 255); - dev_dbg(dev, "LED %u: default intensity RGB(%u,%u,%u) from DT\n", - led->index, rgb[0], rgb[1], rgb[2]); + if (count == 4) + led->mc_cdev.led_cdev.brightness = clamp_val(rgba[3], 0, LED_FULL); + + dev_dbg(dev, "LED %u: default intensity RGB(%u,%u,%u) brightness=%u from DT\n", + led->index, rgba[0], rgba[1], rgba[2], + led->mc_cdev.led_cdev.brightness); } /*