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 = <R G B>; /* colour only (unchanged) */ led-default-intensity = <R G B brightness>; /* 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 <ht@twx-software.de>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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: <R G B> (three u32 values, each 0-255)
|
||||
* Property format: <R G B> (three u32 values, each 0-255)
|
||||
* or: <R G B brightness> (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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user