Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38592C001DF for ; Sun, 6 Aug 2023 17:53:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FBB686824; Sun, 6 Aug 2023 19:52:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qep9Xg5A"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7A40086852; Sun, 6 Aug 2023 19:52:54 +0200 (CEST) Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 65D068679F for ; Sun, 6 Aug 2023 19:52:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-99bf3f59905so561367766b.3 for ; Sun, 06 Aug 2023 10:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691344372; x=1691949172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A8eoRsoVa32XOODjgTSNQ/eetbYwjwqVJhMmxh+PprY=; b=qep9Xg5A2ETNOnFeAK4k08UWjDvwZkwj2GiO9EUm4s9+Ml2yl+ahvI4OY6ltAYAspM Fg5JHZahEtG05UmCLRpmOi8wFYMQNJSg2QXTlqQSXKkZWuFYvH0lu5OfLfy/9xmrWsHo nt7xKUWTY6YBfPm2jHRgfV0uDcHXPSgwNzXGM4cURenINf6cAIcvg5xC1lKk3xHSrBBv KOKDilZ8MkXe9ErNpVumlSZZJfkSSQlwYRHDGJh+WxZwo1Fg2r2O4X7RMW1GjSODtw0O ol5MyNZXnPZxQChWrRmQIWxRSfV4cvZxB3G304s5sX2Qu2iIpy0i8BfPYx/2uLwcPjzJ lhNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691344372; x=1691949172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A8eoRsoVa32XOODjgTSNQ/eetbYwjwqVJhMmxh+PprY=; b=kHEQEjRdTOxwau2pJBHdtEMivhx7y0i9SB1PGR/RA4RqA6H07E4roha4LSmy7giuyE xtnG6Vpg1ZVlvieFW2SnR14UXyarirwaQbUQLiLXqyYsSMiU2thsOkDt8joW2SzPMKfM JnJPM2GaAvBxGVe7//UT2nKNMu2Y9x5NmciTdTbpbOmgj51PTnLHhsyZq3yIvfz0aB3l +9oYxmgSMmizIhOULOADK6WCXI+HZ5zZYFhMsLyVidqALhGGGl68wbwL63paAy0LcOo5 jgXIb9ynHjlDYjeOy62yDhXXf2D3pLNkieZVyiSB/VnKIJB6HlThPqggTiqQePnWaR9A t3oA== X-Gm-Message-State: AOJu0YyAIKXdMYjBS7hm4uzDRuJ2OKZM8g84E1Ygn53J/55yoLDGnRY7 tmD1b+G983HUQuzc2M4XVJw= X-Google-Smtp-Source: AGHT+IHNFVKN/1yotDdNWCB6i3F9gOufMEqUH3eIwgcib2wVj/UgaSYglytdwhjbWvD1yYAv8KvUNg== X-Received: by 2002:a17:906:3086:b0:99b:d2a9:9a01 with SMTP id 6-20020a170906308600b0099bd2a99a01mr7104991ejv.0.1691344371841; Sun, 06 Aug 2023 10:52:51 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id la4-20020a170906ad8400b0099bd682f317sm4066454ejb.206.2023.08.06.10.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Aug 2023 10:52:51 -0700 (PDT) From: Svyatoslav Ryhel To: Jaehoon Chung , Simon Glass , Jonas Karlman , Svyatoslav Ryhel , Eugen Hristev , Patrice Chotard , John Keeping Cc: u-boot@lists.denx.de Subject: [PATCH v3 3/4] power: regulator: Perform regulator setup inside uclass Date: Sun, 6 Aug 2023 20:52:23 +0300 Message-Id: <20230806175224.103002-4-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230806175224.103002-1-clamor95@gmail.com> References: <20230806175224.103002-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Regulators initial setup was previously dependent on board call. To move from this behaviour next solution is proposed: on post_bind boot-on/always-on properties are checked, all regulators with such props will be probed just after binding which ensures that essential regulators are set, then in the post probe regulator autoset is called so that correct regulator state according to device tree is reached. Signed-off-by: Svyatoslav Ryhel [jonas@kwiboo.se: use autoset func, only probe with always/boot-on prop] Signed-off-by: Jonas Karlman --- drivers/power/regulator/regulator-uclass.c | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 4b2c6c2964..69d6d6428d 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -473,6 +473,7 @@ static int regulator_post_bind(struct udevice *dev) { struct dm_regulator_uclass_plat *uc_pdata; const char *property = "regulator-name"; + int ret; uc_pdata = dev_get_uclass_plat(dev); @@ -486,13 +487,20 @@ static int regulator_post_bind(struct udevice *dev) return -EINVAL; } - if (regulator_name_is_unique(dev, uc_pdata->name)) - return 0; + ret = regulator_name_is_unique(dev, uc_pdata->name); + if (!ret) { + debug("'%s' of dev: '%s', has nonunique value: '%s'\n", + property, dev->name, uc_pdata->name); + return -EINVAL; + } - debug("'%s' of dev: '%s', has nonunique value: '%s\n", - property, dev->name, uc_pdata->name); + uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on"); + uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on"); - return -EINVAL; + if (uc_pdata->always_on || uc_pdata->boot_on) + dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); + + return 0; } static int regulator_pre_probe(struct udevice *dev) @@ -546,6 +554,17 @@ static int regulator_pre_probe(struct udevice *dev) return 0; } +static int regulator_post_probe(struct udevice *dev) +{ + int ret; + + ret = regulator_autoset(dev); + if (ret == -EMEDIUMTYPE || ret == -ENOSYS) + return 0; + + return ret; +} + int regulators_enable_boot_on(bool verbose) { struct udevice *dev; @@ -603,5 +622,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), }; -- 2.39.2