From 9cc32bfa49d23a4d1bed9e6119255f2e78e20232 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 22 Apr 2022 15:15:53 +0200 Subject: [PATCH 1/8] dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag Introduce DM_FLAG_PROBE_AFTER_BIND flag, which can be set by driver or uclass in .bind(), to indicate such driver instance should be probe()d once binding of all devices is complete. This is useful in case the driver determines that hardware initialization is mandatory on boot, and such initialization happens only in probe(). This also solves the inability to call device_probe() from .bind(). Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance Reviewed-by: Patrice Chotard Tested-by: Patrice Chotard --- drivers/core/root.c | 24 +++++++++++++++++++++++- include/dm/device.h | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/core/root.c b/drivers/core/root.c index e09c12f4d6..17dd1205a3 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -361,6 +361,28 @@ void *dm_priv_to_rw(void *priv) } #endif +static int dm_probe_devices(struct udevice *dev, bool pre_reloc_only) +{ + u32 mask = DM_FLAG_PROBE_AFTER_BIND; + u32 flags = dev_get_flags(dev); + struct udevice *child; + int ret; + + if (pre_reloc_only) + mask |= DM_FLAG_PRE_RELOC; + + if ((flags & mask) == mask) { + ret = device_probe(dev); + if (ret) + return ret; + } + + list_for_each_entry(child, &dev->child_head, sibling_node) + dm_probe_devices(child, pre_reloc_only); + + return 0; +} + /** * dm_scan() - Scan tables to bind devices * @@ -393,7 +415,7 @@ static int dm_scan(bool pre_reloc_only) if (ret) return ret; - return 0; + return dm_probe_devices(gd->dm_root, pre_reloc_only); } int dm_init_and_scan(bool pre_reloc_only) diff --git a/include/dm/device.h b/include/dm/device.h index b474888d02..5bdb10653f 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -80,6 +80,9 @@ struct driver_info; */ #define DM_FLAG_VITAL (1 << 14) +/* Device must be probed after it was bound */ +#define DM_FLAG_PROBE_AFTER_BIND (1 << 15) + /* * One or multiple of these flags are passed to device_remove() so that * a selective device removal as specified by the remove-stage and the From c438866b16745fc69f0f05636b9cf69b16378fca Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 22 Apr 2022 15:15:54 +0200 Subject: [PATCH 2/8] led: Mark device instance with DM_FLAG_PROBE_AFTER_BIND Calling device_probe() from uclass .post_bind() callback has all kinds of odd side-effects, e.g. device instances not being available just yet. Make use of the DM_FLAG_PROBE_AFTER_BIND instead, mark device instances which need to be probe()d in order to configure the LED default state with this flag and let the DM core do the device_probe() at the right time instead. Fixes: 72675b063b6 ("led: Configure LED default-state on boot") Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance Reviewed-by: Patrice Chotard Tested-by: Patrice Chotard --- drivers/led/led-uclass.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 5d7bf40896..2ce72933b6 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -98,7 +98,9 @@ static int led_post_bind(struct udevice *dev) * In case the LED has default-state DT property, trigger * probe() to configure its default state during startup. */ - return device_probe(dev); + dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); + + return 0; } static int led_post_probe(struct udevice *dev) From e3aa76644c2af14631a1fb5ba17022e0a396a6c4 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 22 Apr 2022 15:15:55 +0200 Subject: [PATCH 3/8] led: gpio: Check device compatible string to determine the top level node Since 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing"), all LED nodes have some sort of label. Use device_is_compatible(..."leds-gpio") to determine whether this is a top-level node, since it is only the top level node which is compatible with "leds-gpio", the GPIO LEDs subnodes are not. Fixes: 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing") Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance Reviewed-by: Patrice Chotard Tested-by: Patrice Chotard --- drivers/led/led_gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c index 958dbd31e7..2315690759 100644 --- a/drivers/led/led_gpio.c +++ b/drivers/led/led_gpio.c @@ -57,12 +57,11 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev) static int led_gpio_probe(struct udevice *dev) { - struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct led_gpio_priv *priv = dev_get_priv(dev); int ret; /* Ignore the top-level LED node */ - if (!uc_plat->label) + if (device_is_compatible(dev, "gpio-leds")) return 0; ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); From 01074697801bc0709ac2ca915250096311ec1b7e Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 22 Apr 2022 15:34:00 +0200 Subject: [PATCH 4/8] led: gpio: Use NOP uclass driver for top-level node The top level DT node of gpio-leds is not a LED itself, bind NOP uclass driver to it, and bind different LED uclass driver to its subnodes which represent the actual LEDs. This simplifies the probe() implementation and fixes the bogus top-level not-an-LED in 'led list' command output: ``` => led list led Error -121 <--- This is removed/fixed by this patch green:user0 off ``` Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance Reviewed-by: Patrice Chotard Tested-by: Patrice Chotard --- drivers/led/led_gpio.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c index 2315690759..fbed151b5d 100644 --- a/drivers/led/led_gpio.c +++ b/drivers/led/led_gpio.c @@ -58,17 +58,8 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev) static int led_gpio_probe(struct udevice *dev) { struct led_gpio_priv *priv = dev_get_priv(dev); - int ret; - /* Ignore the top-level LED node */ - if (device_is_compatible(dev, "gpio-leds")) - return 0; - - ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); - if (ret) - return ret; - - return 0; + return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); } static int led_gpio_remove(struct udevice *dev) @@ -109,18 +100,23 @@ static const struct led_ops gpio_led_ops = { .get_state = gpio_led_get_state, }; +U_BOOT_DRIVER(led_gpio) = { + .name = "gpio_led", + .id = UCLASS_LED, + .ops = &gpio_led_ops, + .priv_auto = sizeof(struct led_gpio_priv), + .probe = led_gpio_probe, + .remove = led_gpio_remove, +}; + static const struct udevice_id led_gpio_ids[] = { { .compatible = "gpio-leds" }, { } }; -U_BOOT_DRIVER(led_gpio) = { - .name = "gpio_led", - .id = UCLASS_LED, +U_BOOT_DRIVER(led_gpio_wrap) = { + .name = "gpio_led_wrap", + .id = UCLASS_NOP, .of_match = led_gpio_ids, - .ops = &gpio_led_ops, - .priv_auto = sizeof(struct led_gpio_priv), .bind = led_gpio_bind, - .probe = led_gpio_probe, - .remove = led_gpio_remove, }; From 69245e406e919012d45d40f045f9b7369086ce17 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 22 Apr 2022 15:41:42 +0200 Subject: [PATCH 5/8] led: Drop led_default_state() This function is empty, drop it. Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance Reviewed-by: Patrice Chotard --- board/aristainetos/aristainetos.c | 1 - board/bosch/guardian/board.c | 3 --- board/dhelectronics/dh_stm32mp1/board.c | 3 --- board/gardena/smart-gateway-at91sam/board.c | 3 --- board/gardena/smart-gateway-mt7688/board.c | 3 --- board/gateworks/venice/venice.c | 2 -- board/k+p/kp_imx6q_tpc/kp_imx6q_tpc.c | 3 --- board/mscc/jr2/jr2.c | 4 ---- board/mscc/luton/luton.c | 4 ---- board/mscc/ocelot/ocelot.c | 4 ---- board/mscc/serval/serval.c | 4 ---- board/mscc/servalt/servalt.c | 4 ---- board/phytec/pcm052/pcm052.c | 3 --- board/sandbox/sandbox.c | 3 --- board/siemens/capricorn/board.c | 4 ---- board/st/stm32mp1/stm32mp1.c | 3 --- drivers/led/led-uclass.c | 6 ------ include/led.h | 9 --------- test/dm/led.c | 3 --- 19 files changed, 69 deletions(-) diff --git a/board/aristainetos/aristainetos.c b/board/aristainetos/aristainetos.c index 19af59606d..514cb60d5b 100644 --- a/board/aristainetos/aristainetos.c +++ b/board/aristainetos/aristainetos.c @@ -418,7 +418,6 @@ int board_late_init(void) int x, y; int ret; - led_default_state(); splash_get_pos(&x, &y); bmp_display((ulong)&bmp_logo_bitmap[0], x, y); diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c index 105b75e65e..68f2744610 100644 --- a/board/bosch/guardian/board.c +++ b/board/bosch/guardian/board.c @@ -327,9 +327,6 @@ int board_late_init(void) int ret; struct udevice *cdev; -#ifdef CONFIG_LED_GPIO - led_default_state(); -#endif set_bootmode_env(); ret = uclass_get_device(UCLASS_PANEL, 0, &cdev); diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index f44afb01e2..67273f9099 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -607,9 +607,6 @@ int board_init(void) board_init_fmc2(); - if (CONFIG_IS_ENABLED(LED)) - led_default_state(); - return 0; } diff --git a/board/gardena/smart-gateway-at91sam/board.c b/board/gardena/smart-gateway-at91sam/board.c index 3f402cfeee..c6eb11e932 100644 --- a/board/gardena/smart-gateway-at91sam/board.c +++ b/board/gardena/smart-gateway-at91sam/board.c @@ -24,9 +24,6 @@ int board_late_init(void) { at91_prepare_cpu_var(); - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - return 0; } diff --git a/board/gardena/smart-gateway-mt7688/board.c b/board/gardena/smart-gateway-mt7688/board.c index 8a3a6e3482..aa833a030f 100644 --- a/board/gardena/smart-gateway-mt7688/board.c +++ b/board/gardena/smart-gateway-mt7688/board.c @@ -183,9 +183,6 @@ err_free: int board_late_init(void) { - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - factory_data_env_config(); return 0; diff --git a/board/gateworks/venice/venice.c b/board/gateworks/venice/venice.c index 4290a69807..f1efabb203 100644 --- a/board/gateworks/venice/venice.c +++ b/board/gateworks/venice/venice.c @@ -128,8 +128,6 @@ int board_late_init(void) u8 enetaddr[6]; char fdt[64]; - led_default_state(); - /* Set board serial/model */ if (!env_get("serial#")) env_set_ulong("serial#", eeprom_get_serial()); diff --git a/board/k+p/kp_imx6q_tpc/kp_imx6q_tpc.c b/board/k+p/kp_imx6q_tpc/kp_imx6q_tpc.c index 110496d995..e6877e4c07 100644 --- a/board/k+p/kp_imx6q_tpc/kp_imx6q_tpc.c +++ b/board/k+p/kp_imx6q_tpc/kp_imx6q_tpc.c @@ -137,9 +137,6 @@ int board_late_init(void) add_board_boot_modes(board_boot_modes); #endif - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - env_set("boardname", "kp-tpc"); env_set("boardsoc", "imx6q"); return 0; diff --git a/board/mscc/jr2/jr2.c b/board/mscc/jr2/jr2.c index 1c516aacd8..6abf08bd24 100644 --- a/board/mscc/jr2/jr2.c +++ b/board/mscc/jr2/jr2.c @@ -30,10 +30,6 @@ int board_early_init_r(void) /* Address of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE; - /* LED setup */ - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - return 0; } diff --git a/board/mscc/luton/luton.c b/board/mscc/luton/luton.c index 038902d08a..76e3f2ebbc 100644 --- a/board/mscc/luton/luton.c +++ b/board/mscc/luton/luton.c @@ -31,10 +31,6 @@ int board_early_init_r(void) /* Address of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE; - /* LED setup */ - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - return 0; } diff --git a/board/mscc/ocelot/ocelot.c b/board/mscc/ocelot/ocelot.c index c462890bb8..2a75ec281c 100644 --- a/board/mscc/ocelot/ocelot.c +++ b/board/mscc/ocelot/ocelot.c @@ -79,10 +79,6 @@ int board_early_init_r(void) /* Address of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE; - /* LED setup */ - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - return 0; } diff --git a/board/mscc/serval/serval.c b/board/mscc/serval/serval.c index 94c1c42b79..87e7907657 100644 --- a/board/mscc/serval/serval.c +++ b/board/mscc/serval/serval.c @@ -24,10 +24,6 @@ int board_early_init_r(void) /* Address of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE; - /* LED setup */ - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - return 0; } diff --git a/board/mscc/servalt/servalt.c b/board/mscc/servalt/servalt.c index 252d8e3156..bd8c7e8b70 100644 --- a/board/mscc/servalt/servalt.c +++ b/board/mscc/servalt/servalt.c @@ -24,10 +24,6 @@ int board_early_init_r(void) /* Address of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE; - /* LED setup */ - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - return 0; } diff --git a/board/phytec/pcm052/pcm052.c b/board/phytec/pcm052/pcm052.c index f9cf4abd47..0f7235979b 100644 --- a/board/phytec/pcm052/pcm052.c +++ b/board/phytec/pcm052/pcm052.c @@ -360,9 +360,6 @@ int board_late_init(void) struct src *psrc = (struct src *)SRC_BASE_ADDR; u32 reg; - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - /* * BK4r1 handle emergency/service SD card boot * Checking the SBMR1 register BOOTCFG1 byte: diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 28ad6efd13..e054f300c4 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -107,9 +107,6 @@ int dram_init(void) int board_init(void) { - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - return 0; } diff --git a/board/siemens/capricorn/board.c b/board/siemens/capricorn/board.c index dcbab8e4d2..4a02d64aec 100644 --- a/board/siemens/capricorn/board.c +++ b/board/siemens/capricorn/board.c @@ -244,10 +244,6 @@ static int board_led_init(void) u8 pca_led[2] = { 0x00, 0x00 }; int ret; - /* init all GPIO LED's */ - if (IS_ENABLED(CONFIG_LED)) - led_default_state(); - /* enable all leds on PCA9552 */ ret = uclass_get_device_by_seq(UCLASS_I2C, PCA9552_1_I2C_BUS, &bus); if (ret) { diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index fff1880e5b..7466e1c732 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -666,9 +666,6 @@ int board_init(void) if (IS_ENABLED(CONFIG_ARMV7_NONSEC)) sysconf_init(); - if (CONFIG_IS_ENABLED(LED)) - led_default_state(); - setup_led(LEDST_ON); return 0; diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 2ce72933b6..68ca3c2970 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -66,12 +66,6 @@ int led_set_period(struct udevice *dev, int period_ms) } #endif -/* This is superseded by led_post_bind()/led_post_probe() below. */ -int led_default_state(void) -{ - return 0; -} - static int led_post_bind(struct udevice *dev) { struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); diff --git a/include/led.h b/include/led.h index 43acca8571..329041008c 100644 --- a/include/led.h +++ b/include/led.h @@ -110,13 +110,4 @@ enum led_state_t led_get_state(struct udevice *dev); */ int led_set_period(struct udevice *dev, int period_ms); -/** - * led_default_state() - set the default state for all the LED - * - * This enables all leds which have default state. - * see Documentation/devicetree/bindings/leds/common.txt - * - */ -int led_default_state(void); - #endif diff --git a/test/dm/led.c b/test/dm/led.c index ac6ee36394..5bbe04648a 100644 --- a/test/dm/led.c +++ b/test/dm/led.c @@ -33,9 +33,6 @@ static int dm_test_led_default_state(struct unit_test_state *uts) { struct udevice *dev; - /* configure the default state (auto-probe) */ - led_default_state(); - /* Check that we handle the default-state property correctly. */ ut_assertok(led_get_by_label("sandbox:default_on", &dev)); ut_asserteq(LEDST_ON, led_get_state(dev)); From 876276f5de92cbaa4a55706606451354650cc730 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Mon, 25 Apr 2022 18:33:50 +0200 Subject: [PATCH 6/8] test: dm: led: Fix LED enumeration The GPIO LED driver no longer considers the top level node an LED, because it is not an LED. With this bug fixed, the LED enumeration has changed. Update the test accordingly. Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance --- test/dm/led.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/dm/led.c b/test/dm/led.c index 5bbe04648a..eed3f4654c 100644 --- a/test/dm/led.c +++ b/test/dm/led.c @@ -21,8 +21,7 @@ static int dm_test_led_base(struct unit_test_state *uts) ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); ut_assertok(uclass_get_device(UCLASS_LED, 2, &dev)); ut_assertok(uclass_get_device(UCLASS_LED, 3, &dev)); - ut_assertok(uclass_get_device(UCLASS_LED, 4, &dev)); - ut_asserteq(-ENODEV, uclass_get_device(UCLASS_LED, 5, &dev)); + ut_asserteq(-ENODEV, uclass_get_device(UCLASS_LED, 4, &dev)); return 0; } @@ -52,10 +51,10 @@ static int dm_test_led_gpio(struct unit_test_state *uts) struct udevice *dev, *gpio; /* - * Check that we can manipulate an LED. LED 1 is connected to GPIO + * Check that we can manipulate an LED. LED 0 is connected to GPIO * bank gpio_a, offset 1. */ - ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); + ut_assertok(uclass_get_device(UCLASS_LED, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio)); ut_asserteq(0, sandbox_gpio_get_value(gpio, offset)); ut_assertok(led_set_state(dev, LEDST_ON)); @@ -77,10 +76,10 @@ static int dm_test_led_toggle(struct unit_test_state *uts) struct udevice *dev, *gpio; /* - * Check that we can manipulate an LED. LED 1 is connected to GPIO + * Check that we can manipulate an LED. LED 0 is connected to GPIO * bank gpio_a, offset 1. */ - ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); + ut_assertok(uclass_get_device(UCLASS_LED, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio)); ut_asserteq(0, sandbox_gpio_get_value(gpio, offset)); ut_assertok(led_set_state(dev, LEDST_TOGGLE)); @@ -102,12 +101,12 @@ static int dm_test_led_label(struct unit_test_state *uts) ut_assertok(led_get_by_label("sandbox:red", &dev)); ut_asserteq(1, device_active(dev)); - ut_assertok(uclass_get_device(UCLASS_LED, 1, &cmp)); + ut_assertok(uclass_get_device(UCLASS_LED, 0, &cmp)); ut_asserteq_ptr(dev, cmp); ut_assertok(led_get_by_label("sandbox:green", &dev)); ut_asserteq(1, device_active(dev)); - ut_assertok(uclass_get_device(UCLASS_LED, 2, &cmp)); + ut_assertok(uclass_get_device(UCLASS_LED, 1, &cmp)); ut_asserteq_ptr(dev, cmp); ut_asserteq(-ENODEV, led_get_by_label("sandbox:blue", &dev)); @@ -127,7 +126,7 @@ static int dm_test_led_blink(struct unit_test_state *uts) * Check that we get an error when trying to blink an LED, since it is * not supported by the GPIO LED driver. */ - ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); + ut_assertok(uclass_get_device(UCLASS_LED, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio)); ut_asserteq(0, sandbox_gpio_get_value(gpio, offset)); ut_asserteq(-ENOSYS, led_set_state(dev, LEDST_BLINK)); From 891ec35a7a428c0c08c95ed5686bc1cd10e0c4dd Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Mon, 25 Apr 2022 18:33:51 +0200 Subject: [PATCH 7/8] test: dm: pinmux: Get LED2 udevice in the pinmux test The UT reinitializes the pin controller state, get LED2 udevice to trigger its probe and configure the pin controller pin state as it is expected by the test. Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance --- test/cmd/pinmux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/cmd/pinmux.c b/test/cmd/pinmux.c index de3bb0d2f9..df40bb7743 100644 --- a/test/cmd/pinmux.c +++ b/test/cmd/pinmux.c @@ -7,12 +7,17 @@ #include #include +#include #include #include #include static int dm_test_cmd_pinmux_status_pinname(struct unit_test_state *uts) { + struct udevice *dev; + + ut_assertok(uclass_get_device(UCLASS_LED, 2, &dev)); + /* Test that 'pinmux status ' displays the selected pin. */ console_record_reset(); run_command("pinmux status a5", 0); From 53ee48b67302e188dc2805cef393707975b305c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 28 Apr 2022 13:26:53 +0200 Subject: [PATCH 8/8] dt-bindings: leds: import common led bindings from linux 5.17 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows usage of LED_COLOR_ID_RGB macro in DTS files. Signed-off-by: Pali Rohár --- include/dt-bindings/leds/common.h | 48 ++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 9e1256a7c1..3be89a7c20 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -6,6 +6,7 @@ * Author: Jacek Anaszewski * * Copyright (C) 2019 Jacek Anaszewski + * Copyright (C) 2020 Pavel Machek */ #ifndef __DT_BINDINGS_LEDS_H @@ -29,19 +30,51 @@ #define LED_COLOR_ID_VIOLET 5 #define LED_COLOR_ID_YELLOW 6 #define LED_COLOR_ID_IR 7 -#define LED_COLOR_ID_MAX 8 +#define LED_COLOR_ID_MULTI 8 /* For multicolor LEDs */ +#define LED_COLOR_ID_RGB 9 /* For multicolor LEDs that can do arbitrary color, + so this would include RGBW and similar */ +#define LED_COLOR_ID_MAX 10 /* Standard LED functions */ +/* Keyboard LEDs, usually it would be input4::capslock etc. */ +/* Obsolete equivalent: "shift-key-light" */ +#define LED_FUNCTION_CAPSLOCK "capslock" +#define LED_FUNCTION_SCROLLLOCK "scrolllock" +#define LED_FUNCTION_NUMLOCK "numlock" +/* Obsolete equivalents: "tpacpi::thinklight" (IBM/Lenovo Thinkpads), + "lp5523:kb{1,2,3,4,5,6}" (Nokia N900) */ +#define LED_FUNCTION_KBD_BACKLIGHT "kbd_backlight" + +/* System LEDs, usually found on system body. + platform::mute (etc) is sometimes seen, :mute would be better */ +#define LED_FUNCTION_POWER "power" +#define LED_FUNCTION_DISK "disk" + +/* Obsolete: "platform:*:charging" (allwinner sun50i) */ +#define LED_FUNCTION_CHARGING "charging" +/* Used RGB notification LEDs common on phones. + Obsolete equivalents: "status-led:{red,green,blue}" (Motorola Droid 4), + "lp5523:{r,g,b}" (Nokia N900) */ +#define LED_FUNCTION_STATUS "status" + +#define LED_FUNCTION_MICMUTE "micmute" +#define LED_FUNCTION_MUTE "mute" + +/* Used for player LEDs as found on game controllers from e.g. Nintendo, Sony. */ +#define LED_FUNCTION_PLAYER1 "player-1" +#define LED_FUNCTION_PLAYER2 "player-2" +#define LED_FUNCTION_PLAYER3 "player-3" +#define LED_FUNCTION_PLAYER4 "player-4" +#define LED_FUNCTION_PLAYER5 "player-5" + +/* Miscelleaus functions. Use functions above if you can. */ #define LED_FUNCTION_ACTIVITY "activity" #define LED_FUNCTION_ALARM "alarm" #define LED_FUNCTION_BACKLIGHT "backlight" #define LED_FUNCTION_BLUETOOTH "bluetooth" #define LED_FUNCTION_BOOT "boot" #define LED_FUNCTION_CPU "cpu" -#define LED_FUNCTION_CAPSLOCK "capslock" -#define LED_FUNCTION_CHARGING "charging" #define LED_FUNCTION_DEBUG "debug" -#define LED_FUNCTION_DISK "disk" #define LED_FUNCTION_DISK_ACTIVITY "disk-activity" #define LED_FUNCTION_DISK_ERR "disk-err" #define LED_FUNCTION_DISK_READ "disk-read" @@ -50,21 +83,14 @@ #define LED_FUNCTION_FLASH "flash" #define LED_FUNCTION_HEARTBEAT "heartbeat" #define LED_FUNCTION_INDICATOR "indicator" -#define LED_FUNCTION_KBD_BACKLIGHT "kbd_backlight" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" #define LED_FUNCTION_MTD "mtd" -#define LED_FUNCTION_MICMUTE "micmute" -#define LED_FUNCTION_MUTE "mute" -#define LED_FUNCTION_NUMLOCK "numlock" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -#define LED_FUNCTION_POWER "power" #define LED_FUNCTION_RX "rx" #define LED_FUNCTION_SD "sd" -#define LED_FUNCTION_SCROLLLOCK "scrolllock" #define LED_FUNCTION_STANDBY "standby" -#define LED_FUNCTION_STATUS "status" #define LED_FUNCTION_TORCH "torch" #define LED_FUNCTION_TX "tx" #define LED_FUNCTION_USB "usb"