From patchwork Wed Jun 26 23:55:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1952959 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=vKJLPsQx; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=GIvt4wLk; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W8lwX68pVz20XB for ; Thu, 27 Jun 2024 14:30:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DE16884FD; Thu, 27 Jun 2024 06:29:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (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=1719462590; bh=aHen6832IKsb5XblySpJKp+JaCzMetw7y5X/WvFEHI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vKJLPsQxCr2effotltFnlsRya2JVoImamDmW3y5674PtmenGo0z3X4PCorSCuQwQR B/wo5gyCdydAOgNiVbW/zpAUXN6aNOxK+CXxbnfQ1UorxRymFu8FAjck+Fz0iU66OE 59Hk0jroZo9f2E7JcfReHhHPP7giEBxmsWE+zofq1aWGNuvQWWjjgr7Dpb4mCdcCqp oCZyOSZzGzVrOTUgOf5OBXHN4K+y8qUaA4o+mRVSiBfJJqF11i6X0UcD4yibQWzTXC gEEjN2Q59Hmv7Jnf3aZaK9TMnD+B00dxBKzIqDeBfnyx+VNMVsBLOCfSBt8m6jdzAe 8XvALGt8biJGw== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (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 C59D4884BE; Thu, 27 Jun 2024 01:57:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1719446273; bh=aHen6832IKsb5XblySpJKp+JaCzMetw7y5X/WvFEHI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GIvt4wLk228mGRS5/n3S60iJ1fmnMsjCeZr5j3MTmD5P0NaJFcZgJqZyQcYBSRPR0 l2qrnKApFJIR7hnN2kbHpWVRnyYhLi7F4Ktc4yHtcw2X6LYUTnzpmIkd2mhPHgqfvL 674QgiUjeveMOI4XgmIjsDMSybEyFNc+yEJZ/dBup3vAGul0C87X6VXv8Uavj7cUNu AhCWewS0KD9pecCkWGDVbFqKzc3FA8TGlH87VWfczEK0vWxPTsXV0DdfMQozgfYibG +3JQFYfsYZHkjHT5QR4pmzkEMKGnoxS2ge43KGDUQr9KKlhfXAyy3i0I3tFdCF50CR BY4iU/hbwiHAw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Ben Wolsieffer , Caleb Connolly , Chris Morgan , Dragan Simic , Eugen Hristev , Francesco Dolcini , Heinrich Schuchardt , Jaehoon Chung , Jagan Teki , Jonas Karlman , Kever Yang , Kostya Porotchkin , Matteo Lisi , Mattijs Korpershoek , Max Krummenacher , Neil Armstrong , Patrice Chotard , Patrick Delaunay , Philipp Tomsich , Quentin Schulz , Sam Day , Simon Glass , Sumit Garg , Svyatoslav Ryhel , Thierry Reding , Tom Rini , Volodymyr Babchuk , u-boot-amlogic@groups.io, u-boot-qcom@groups.io, u-boot@dh-electronics.com, uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH 2/4] power: regulator: Convert regulators_enable_boot_on/off() to regulator_post_probe Date: Thu, 27 Jun 2024 01:55:42 +0200 Message-ID: <20240626235717.272219-2-marex@denx.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240626235717.272219-1-marex@denx.de> References: <20240626235717.272219-1-marex@denx.de> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 27 Jun 2024 06:29:48 +0200 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.8 at phobos.denx.de X-Virus-Status: Clean Turn regulators_enable_boot_on() and regulators_enable_boot_off() into empty functions. Implement matching functionality in regulator_post_probe() instead. The regulator_post_probe() is called for all regulators after they probe, and regulators that have regulator-always-on or regulator-boot-on DT properties now always probe due to DM_FLAG_PROBE_AFTER_BIND being set on such regulators in regulator_post_bind(). Finally, fold regulator_unset() functionality into regulator_autoset(). Signed-off-by: Marek Vasut --- Cc: Ben Wolsieffer Cc: Caleb Connolly Cc: Chris Morgan Cc: Dragan Simic Cc: Eugen Hristev Cc: Francesco Dolcini Cc: Heinrich Schuchardt Cc: Jaehoon Chung Cc: Jagan Teki Cc: Jonas Karlman Cc: Kever Yang Cc: Kostya Porotchkin Cc: Matteo Lisi Cc: Mattijs Korpershoek Cc: Max Krummenacher Cc: Neil Armstrong Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Philipp Tomsich Cc: Quentin Schulz Cc: Sam Day Cc: Simon Glass Cc: Sumit Garg Cc: Svyatoslav Ryhel Cc: Thierry Reding Cc: Tom Rini Cc: Volodymyr Babchuk Cc: u-boot-amlogic@groups.io Cc: u-boot-qcom@groups.io Cc: u-boot@dh-electronics.com Cc: u-boot@lists.denx.de Cc: uboot-stm32@st-md-mailman.stormreply.com --- drivers/power/regulator/regulator-uclass.c | 60 +++++++--------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index ccc4ef33d83..d52f273042f 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -308,6 +308,11 @@ int regulator_autoset(struct udevice *dev) return ret; } + if (uc_pdata->force_off) { + ret = regulator_set_enable(dev, false); + goto out; + } + if (!uc_pdata->always_on && !uc_pdata->boot_on) { ret = -EMEDIUMTYPE; goto out; @@ -512,56 +517,28 @@ static int regulator_pre_probe(struct udevice *dev) return 0; } -int regulators_enable_boot_on(bool verbose) +static int regulator_post_probe(struct udevice *dev) { - struct udevice *dev; - struct uclass *uc; int ret; - ret = uclass_get(UCLASS_REGULATOR, &uc); - if (ret) + ret = regulator_autoset(dev); + if (ret && ret != -EMEDIUMTYPE && ret != ENOSYS) return ret; - for (uclass_first_device(UCLASS_REGULATOR, &dev); - dev; - uclass_next_device(&dev)) { - ret = regulator_autoset(dev); - if (ret == -EMEDIUMTYPE) { - ret = 0; - continue; - } - if (verbose) - regulator_show(dev, ret); - if (ret == -ENOSYS) - ret = 0; - } - return ret; + if (_DEBUG) + regulator_show(dev, ret); + + return 0; } -int regulators_enable_boot_off(bool verbose) +int regulators_enable_boot_on(bool verbose) { - struct udevice *dev; - struct uclass *uc; - int ret; - - ret = uclass_get(UCLASS_REGULATOR, &uc); - if (ret) - return ret; - for (uclass_first_device(UCLASS_REGULATOR, &dev); - dev; - uclass_next_device(&dev)) { - ret = regulator_unset(dev); - if (ret == -EMEDIUMTYPE) { - ret = 0; - continue; - } - if (verbose) - regulator_show(dev, ret); - if (ret == -ENOSYS) - ret = 0; - } + return 0; +} - return ret; +int regulators_enable_boot_off(bool verbose) +{ + return 0; } UCLASS_DRIVER(regulator) = { @@ -569,5 +546,6 @@ UCLASS_DRIVER(regulator) = { .name = "regulator", .post_bind = regulator_post_bind, .pre_probe = regulator_pre_probe, + .post_probe = regulator_post_probe, .per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat), };