From patchwork Fri Jul 22 10:09:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 1659460 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lq4t73YNSz9sGZ for ; Fri, 22 Jul 2022 20:09:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D085583F82; Fri, 22 Jul 2022 12:09:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 0322783F94; Fri, 22 Jul 2022 12:09:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9813D83F4B for ; Fri, 22 Jul 2022 12:09:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=foss+uboot@0leil.net Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 8ECB7200003; Fri, 22 Jul 2022 10:09:20 +0000 (UTC) From: Quentin Schulz To: Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, kever.yang@rock-chips.com, alpernebiyasak@gmail.com, email2tema@gmail.com, u-boot@lists.denx.de, Quentin Schulz , Quentin Schulz , Xavier Drudis Ferran Subject: [PATCH v2 1/2] spl: enable regulator-boot-on and disable regulator-force-boot-off Date: Fri, 22 Jul 2022 12:09:07 +0200 Message-Id: <20220722100908.3853994-1-foss+uboot@0leil.net> X-Mailer: git-send-email 2.37.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.6 at phobos.denx.de X-Virus-Status: Clean From: Quentin Schulz This makes sure regulators that need to be turned on or off at boot are turned on or off in the SPL. This may be required for the SPL to do some operations, such as finding possible loading media for U-Boot proper. Cc: Quentin Schulz Tested-by: Xavier Drudis Ferran Signed-off-by: Quentin Schulz --- v2: - added Tested-by, - fixed build for boards with SPL_DM_REGULATOR disabled by always included power/regulator.h and defining a dummy implementation for regulators_enable_boot_off, common/spl/spl.c | 10 ++++++++++ include/power/regulator.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index 29e0898f03..6ab997279d 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -39,6 +39,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; DECLARE_BINMAN_MAGIC_SYM; @@ -773,6 +774,15 @@ void board_init_r(gd_t *dummy1, ulong dummy2) if (CONFIG_IS_ENABLED(GPIO_HOG)) gpio_hog_probe_all(); + if (CONFIG_IS_ENABLED(DM_REGULATOR)) { + if (regulators_enable_boot_on(false)) + debug("%s: Cannot enable boot on regulator\n", + __func__); + if (regulators_enable_boot_off(false)) + debug("%s: Cannot enable boot off regulator\n", + __func__); + } + #if CONFIG_IS_ENABLED(BOARD_INIT) spl_board_init(); #endif diff --git a/include/power/regulator.h b/include/power/regulator.h index ff1bfc2435..4bce61dd9f 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -631,6 +631,11 @@ static inline int regulators_enable_boot_on(bool verbose) return -ENOSYS; } +static inline int regulators_enable_boot_off(bool verbose) +{ + return -ENOSYS; +} + static inline int regulator_autoset(struct udevice *dev) { return -ENOSYS;