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 211AEEB64DA for ; Sun, 16 Jul 2023 04:08:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 211F486237; Sun, 16 Jul 2023 06:08:13 +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="cRieJMtt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1C9808623A; Sun, 16 Jul 2023 06:08:12 +0200 (CEST) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (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 CA248861E1 for ; Sun, 16 Jul 2023 06:08:09 +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-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fb7769f15aso5335424e87.0 for ; Sat, 15 Jul 2023 21:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689480489; x=1692072489; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=sma2xginPYzLfppQixxS2NN0kQ5TPLgmJGcgvVHHHK8=; b=cRieJMtt4ZYKgY86D3RZCh5UBCyXZ30O+Z0av1rxk2x8GXdnWqv9FF8111RjbcLH/R +o+L1Fy2HBwZvRxPXBFC/kTMkFpG+Y1q+DTlOAfbUdFVtlMeJpCQSa6naUA/hkDeE6Ya KCWsItBnx4OYfYfBHtc1jHma1qE7MEZWh78FU8/8NQupqC6boXD703U6tmknUmCewdPX daPt0JkPf1PB5B5cfvOIvz5UCNOU/uyI1IqVlA4U71iD1BYZulDj6xUWZdqf4gpKK4rS 0Lxc+nkRMdpXn2n/QqP+CcUHEzEcGjT1j5bS2pf6RocPDjnPMEf6EUbUO4Evbsb0tZbz 62iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689480489; x=1692072489; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sma2xginPYzLfppQixxS2NN0kQ5TPLgmJGcgvVHHHK8=; b=IcBnJbUS4oPT+3F8bAKZ3+sMGIvr/R6qdyCJF3pekoKaYkr2211HYUMdOz2eX2sCX+ Nv2BfUS1R1DZc/m39/m7MzSPgxlYV09k254Gm4lZl7s/DCMLDhB9AtUCd7RdMNKi3uJ9 ZpGjjqQdZS5CLf16z8hfzoVRn70ZZIeQ4jF2czHzK+199HrVv1eJIa45QDq6fPFkbf// rMRVBqPZGX3PWbqeIFxukWvFGAXq/Zi0nE0IMIsd80Zvpd8Nepl898EUwuswEfouGO13 ddUift6xBrdTMT/r0av0771JCn760rfDxQN2qZl9G2H5ezwnoOGldCUHdYp4Va07fal0 tocQ== X-Gm-Message-State: ABy/qLYt76YnReEIanUoWBlnHTCH1AAYYM2vLlTi2hCnUkNpRUgv9UC5 HaeoHeIwTfp9Crf1tZ/Kl4TnGxL++lM= X-Google-Smtp-Source: APBJJlF+/VopLxxRPdmKw940SOEqVgwJFHU6sYOi0iz2m1rZNX26dEC8QDWleam3/6ULOhe+Q2KINA== X-Received: by 2002:a2e:b70a:0:b0:2b6:eb5a:6504 with SMTP id j10-20020a2eb70a000000b002b6eb5a6504mr6950229ljo.18.1689480488713; Sat, 15 Jul 2023 21:08:08 -0700 (PDT) Received: from [127.0.0.1] ([46.211.159.203]) by smtp.gmail.com with ESMTPSA id d12-20020a1c730c000000b003fbb8c7c799sm4867520wmb.30.2023.07.15.21.08.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 15 Jul 2023 21:08:08 -0700 (PDT) Date: Sun, 16 Jul 2023 07:08:05 +0300 From: Svyatoslav Ryhel To: Simon Glass CC: Jaehoon Chung , Patrick Delaunay , u-boot@lists.denx.de Subject: Re: [PATCH v2 2/2] power: pmic: fix regulators behaviour User-Agent: K-9 Mail for Android In-Reply-To: References: <20230715183431.5318-1-clamor95@gmail.com> <20230715183431.5318-3-clamor95@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 16 =D0=BB=D0=B8=D0=BF=D0=BD=D1=8F 2023 =D1=80=2E 02:40:37 GMT+03:00, Simon= Glass =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=B2(-=D0= =BB=D0=B0): >Hi Svyatoslav, > >On Sat, 15 Jul 2023 at 12:34, Svyatoslav Ryhel wro= te: >> >> Currently device tree entries of regulators are completely >> ignored and regulators are probed only if they are called >> by the device which uses it=2E This results into two issues: >> regulators which must run under boot-on or always-on mode >> are ignored and not enabled; dts props like voltage are >> not applied to the regulator so the regulator may be enabled >> with random actual voltage, which may have unexpected >> consequences=2E >> >> This patch changes this behavior=2E Post-probe function is >> introduced which performs probing of each pmics child and if >> it is a regulator, regulator_autoset function is called, which >> handles always-on and boot-on regulators, but if none of those >> props are set, the regulator is disabled=2E >> >> Later disabled regulators can be re-enabled by devices which >> use them without issues=2E >> >> Signed-off-by: Svyatoslav Ryhel >> --- >> drivers/power/pmic/pmic-uclass=2Ec | 18 ++++++++++++++++++ >> 1 file changed, 18 insertions(+) > >Can you add a test for this to test/dm/pmic=2Ec ? > Sure, may you specify what I should add to tests/dm/pmic=2Ec? Which behavi= or is needed? >> >> diff --git a/drivers/power/pmic/pmic-uclass=2Ec b/drivers/power/pmic/pm= ic-uclass=2Ec >> index 0e2f5e1f41=2E=2E8a26b519c9 100644 >> --- a/drivers/power/pmic/pmic-uclass=2Ec >> +++ b/drivers/power/pmic/pmic-uclass=2Ec >> @@ -16,6 +16,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #if CONFIG_IS_ENABLED(PMIC_CHILDREN) >> @@ -198,9 +199,26 @@ static int pmic_pre_probe(struct udevice *dev) >> return 0; >> } >> >> +static int pmic_post_probe(struct udevice *dev) >> +{ >> + struct udevice *child; >> + int ret; >> + >> + device_foreach_child_probe(child, dev) { >> + if (device_get_uclass_id(child) =3D=3D UCLASS_REGULATOR= ) { >> + ret =3D regulator_autoset(child); >> + if (ret =3D=3D -EMEDIUMTYPE) >> + regulator_set_enable(child, false); >> + }; >> + }; >> + >> + return 0; >> +} >> + >> UCLASS_DRIVER(pmic) =3D { >> =2Eid =3D UCLASS_PMIC, >> =2Ename =3D "pmic", >> =2Epre_probe =3D pmic_pre_probe, >> + =2Epost_probe =3D pmic_post_probe, >> =2Eper_device_auto =3D sizeof(struct uc_pmic_priv), >> }; >> -- >> 2=2E39=2E2 >> > >Regards, >Simon