From patchwork Fri Apr 22 13:15:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1620830 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=BMkQ+JeU; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=RfoZJNVQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlFKS5kQMz9s0w for ; Fri, 22 Apr 2022 23:16:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7890483D57; Fri, 22 Apr 2022 15:16:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650633370; bh=sc85woU8kPbJ5sb3k6+qkp/1V9m6RZWdmgp9VnOyuKI=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=BMkQ+JeUYyIT7e9Jp4BSGPPGPzfthbkl13scRpqfYTMPpjCHSte/vCfjvhY65w97H vUuVq17t1woofnWsYwsJeTGXgF7zsA0hTvvLtc72Jptpoj73Iho1siCnvoEElB/M7l bjkbItRUjxXekwxDx68pDZgQZWCtAoOIBEt6ctTzDi/lPJpQ5JbP1WyUilZG+Z/yQE rj+fco4xgJxq5efMHfofMBuFprmQ9wrKgIApOZgp1NDb11MJfBAw5MTjEgzdNV6APE eEGNSLQ/+xtNJKKpvA4vsGWgpm2rHQ7viiFZaZeQx/segjnWegsM6TDTylmln6c90M pI7L/jjnrSexA== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id D314E83C70; Fri, 22 Apr 2022 15:16:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650633367; bh=sc85woU8kPbJ5sb3k6+qkp/1V9m6RZWdmgp9VnOyuKI=; h=From:To:Cc:Subject:Date:From; b=RfoZJNVQ9OL1yvTIXE/F4JFqRQjbk6JyQEXtTRCf31U9T18ZWeOJ8WgbnHzfPiZms oXJU+zHadgmMvgOyWLLV5xoz81VcAjUxfoTGglqt/CI/DsSI06hVOjnqSd5k68GKh6 VtuqHvAx+0PQ7v1S93UuZKDwLRV2akpuHysh9bLBQEYaY6bIIWGoiZWeNT1NSAxQWQ 5PVY53+99uzLjttOBIQQIQkYxpwEO97GsM6WIY1sD54PXAhprNWQMYgqlKv07sp70Y nDTj+YkdKgsDXeLmaYcbLv3YVWeqkfRTRs+4poU+941GyZDqKy7TGuoNuHz0MToHQ6 i+9tV5Y6upn1w== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrice Chotard , Patrick Delaunay , Sean Anderson , Simon Glass , Steven Lawrance Subject: [PATCH 1/3] dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag Date: Fri, 22 Apr 2022 15:15:53 +0200 Message-Id: <20220422131555.123598-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 e09c12f4d6e..17dd1205a32 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 e0f86f5df9f..e7dd90399f9 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 patchwork Fri Apr 22 13:15:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1620831 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=qpICm5lQ; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=U/Ul+QeZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlFKc5Vh9z9s0w for ; Fri, 22 Apr 2022 23:16:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 86E9F83D5B; Fri, 22 Apr 2022 15:16:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650633372; bh=ayKBD29lsll5CM/0V2Ho4i57TjFcmx22RWzfnXSJktY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qpICm5lQZ3Z4VztMBH7QhDR4j95xFcK+KlOOT7DrEl1T1VRePy14WHoqBBQlr1ArM BWJBJiiCx/6omwqn+zNjPPhq3swYhMOnssW0VAP+0j3sSgftNk9CEsPbJZxXGVrnAq vyYXd2HNdepE4R1aK90ola8PiM3grJeIGC+evJeg8o/85hGBdMp9RrNnx4NFQvGGsT nJE673OZfZLvQnFqPtx2QqfkxD6n/F7oqqgdbJwmFS6akYeIBKcHtOgYHyakcrKF53 fJGMt4xvEI9usQuAuX4VqgFaXKmfwjrL+a1/ftkVbNz0Sx/5eyMHsVxOV9ELzQQhtP K0+Wl5IAjcRMQ== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 60F1883D57; Fri, 22 Apr 2022 15:16:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650633367; bh=ayKBD29lsll5CM/0V2Ho4i57TjFcmx22RWzfnXSJktY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/Ul+QeZLRhWxNtO34WrxxxBpBRzbnA/6avHQGrQjz5msdgQXGX81qSqBPrngczwi mwdSrkSIwZVIZWgYhHwWFQfD5wD4rAKS3d3yCx11GEojfX130wgtrZkmphbmgdd5BP JkcZHYUofQH3VKAcrmDn5gbDfKt8z0F7nlo+eiZUgC8O6jMsT1YC1JcMRxCN9f9u2b s5R9KeWWqgJ+pJsO1DIezcEXWh8a8xTHfiXBBcSz5P39/ShTxzhi1Kb4BLM4s8t9Il Wa3WWFNdsESCSyH+cgNBvA9vMpWAgBys0DwWytRdIYMIBeJLVg5cShgZyybG7g+Di4 P2cVj82KQLzMw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrice Chotard , Patrick Delaunay , Sean Anderson , Simon Glass , Steven Lawrance Subject: [PATCH 2/3] led: Mark device instance with DM_FLAG_PROBE_AFTER_BIND Date: Fri, 22 Apr 2022 15:15:54 +0200 Message-Id: <20220422131555.123598-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422131555.123598-1-marex@denx.de> References: <20220422131555.123598-1-marex@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 5d7bf40896b..2ce72933b6c 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 patchwork Fri Apr 22 13:15:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1620832 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=mbxK9nvI; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=W+Wf7bgu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlFKp1yTVz9s0w for ; Fri, 22 Apr 2022 23:16:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B56E83D85; Fri, 22 Apr 2022 15:16:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650633383; bh=5Fr/jqkk7TSLZxGtB8Ypvrl+DXYneZaC9O0QX2SyDx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mbxK9nvIzkYhvl9TZ8Pqj/6HJNwauSk56+O/e21s/UotpD7LYRwPJ1cS4rNT2x9vl i8OGDNT6Fpg45A8uhipOlz21dcfUC3C37Mj+oMWgJy71sRX9Fatyo4bbckm3IvmEz4 XlPQ9uI2Uij+g5+WhM+ttJyBPtwqF9BYbc5tacsQekRakCSfX06Jom3ldHGj/qDa4x gpOH/4cgp9BWWemD8Dx44fJM7vl0vo8qeLrJydoYy2+73VcOrkXUKj44Jg/0/m6MnK s1UFecL0w7djQAh9d5+uJI39/Ciawckbj/tImPn+xI6MTLGQsrQjdYbx0gr5OdfFMe aSmctTB3wZ0cg== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id DC5EC83D62; Fri, 22 Apr 2022 15:16:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650633368; bh=5Fr/jqkk7TSLZxGtB8Ypvrl+DXYneZaC9O0QX2SyDx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+Wf7bguD3cYuxqrvVLu7fBTXKVZXPz04/iS7YfiGzzwVTXno4fgUigtNqejeqtSA 7Vcmu90V6AqDKHdfRVbcSCF/LRYvPnv9wsOVtK7HQOB7euZvKzLfoyAHf+uUTs8z0h pKolO13DIBC+3ecg1vORySAGFqcTu4Lf/KnCbK9M8uCdHbgFWxW/FL6PAexwUkIEPB WjfhargG0sE/MogX6a/bPS3r30YbV+6nykLPO6x9Cv9efVVprZfZtW3IwmYC5fu1Be VRxVQrUDUVieCXWUiVzywoqHuqTptSXqMVQ+C0sFv1Sl+Zl9IaDTR+Za54smXvwMWd WH599VqJUDSOQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrice Chotard , Patrick Delaunay , Sean Anderson , Simon Glass , Steven Lawrance Subject: [PATCH 3/3] led: gpio: Check device compatible string to determine the top level node Date: Fri, 22 Apr 2022 15:15:55 +0200 Message-Id: <20220422131555.123598-3-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422131555.123598-1-marex@denx.de> References: <20220422131555.123598-1-marex@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 958dbd31e77..23156907593 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);