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 99571C001DE for ; Sun, 6 Aug 2023 05:41:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7751C854BD; Sun, 6 Aug 2023 07:41:16 +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="YTYyoj56"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E33E847D9; Sun, 6 Aug 2023 07:41:15 +0200 (CEST) Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (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 9BDA1854BD for ; Sun, 6 Aug 2023 07:41:12 +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-x62b.google.com with SMTP id a640c23a62f3a-99357737980so503381166b.2 for ; Sat, 05 Aug 2023 22:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691300472; x=1691905272; 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=19iONng6Tbc5/MGfiy2OxmunoOjv75WsG/a8kSqgdNo=; b=YTYyoj56pzaR38r/+J1+jPcnfeeCrKkrC7jPwKKD9ze5KkyLcKH2NFMTXlp85BR1Fy X9BqEnL2NT3XskIO8dKM4s165i9mMYIz2h+JwdrfrbqYyLxSjaA8u1IZMkJavykYxLsz fX/NaBiFq40UIwdmJxBSvPYPz5WNZd+E6kuFfw/crs3xAPcYlR9O1Iyznez/Ol5R5H6G Q7DImaH32nbnxH4t6wohrye11W4Anm+ICg2NqcPpKNODPruN3+eXP34YH/NdFuPrmOit yFij/7RLb1j0/jCmn8WkBWkgRiRcXpwoXzBWgxgkXzqI1mhGEivkKU3Ie2goNAJvoNjE M+Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691300472; x=1691905272; 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=19iONng6Tbc5/MGfiy2OxmunoOjv75WsG/a8kSqgdNo=; b=Ifc+SKbaVtsX0x+KKHBTgR6yM0vlMZqAP8ijfJNk0PCHjH2PrJW5L0lQzot6StucC8 +AHQ0iCKufXI4eedBolAKa/+zKqglaPwS5MtdS5hTFHV5vizVVdyl8sdiIiL4rtzYNx/ bR4XFc3ee9B+rkfl21GDbiPThU9vaBRWxl8mM89e6t91P2epkSy+2bfRrRKlxFfmCW5p w7chCbwYH2y7ZzFh8e84iuEIRF+H5CPDllJVlNouP3DihXuuXnjlZqp3o4P5FKMxurcs ctyjct+H85oVXlCo6eYgzrbJoUm5Y88AfGxRlvdKj9Ug2HF8qQAERLEY2Ne4uAqjdzpH oaXw== X-Gm-Message-State: AOJu0YwVaP+YMYTTK0nHuJWfCQ6uon2xSCf+JKaq0NCGfFIrVBXD1rv+ vmWPO4XeDC72Nu21upFxWVA= X-Google-Smtp-Source: AGHT+IGbU1oxoCxhbAb6ekspjZ+xitT2fTQvQb1n30v9fwqMeoZi3A+wcIy94TznB/eRFNMH3SAOhQ== X-Received: by 2002:a17:906:1085:b0:99b:f3ef:f084 with SMTP id u5-20020a170906108500b0099bf3eff084mr6633259eju.66.1691300471896; Sat, 05 Aug 2023 22:41:11 -0700 (PDT) Received: from [127.0.0.1] ([46.211.153.198]) by smtp.gmail.com with ESMTPSA id m17-20020a170906235100b00985bdb7dd5fsm3441608eja.201.2023.08.05.22.41.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Aug 2023 22:41:11 -0700 (PDT) Date: Sun, 06 Aug 2023 08:41:09 +0300 From: Svyatoslav Ryhel To: Jonas Karlman , Simon Glass CC: Philipp Tomsich , Kever Yang , Neil Armstrong , Marek Vasut , Patrick Delaunay , Patrice Chotard , Jagan Teki , Matteo Lisi , Jaehoon Chung , Anatolij Gustschin , Quentin Schulz , Eugen Hristev , u-boot@lists.denx.de, u-boot-amlogic@groups.io, u-boot@dh-electronics.com, uboot-stm32@st-md-mailman.stormreply.com Subject: =?US-ASCII?Q?Re=3A_=5BPATCH_v2_3/7=5D_power=3A_regulator-ucla?= =?US-ASCII?Q?ss=3A_perform_regulator_setup_inside_uclass?= User-Agent: K-9 Mail for Android In-Reply-To: References: <20230720123744.26854-1-clamor95@gmail.com> <20230720123744.26854-4-clamor95@gmail.com> <09c6ff35-250a-18ff-667d-9ce62e24b18c@kwiboo.se> <4222D0DC-D1D9-4382-93A0-E09EFD807CCC@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 5 =D1=81=D0=B5=D1=80=D0=BF=D0=BD=D1=8F 2023 =D1=80=2E 23:46:27 GMT+03:00, = Jonas Karlman =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0= =B2(-=D0=BB=D0=B0): >On 2023-08-05 21:58, Svyatoslav Ryhel wrote: >>=20 >>=20 >> 5 =D1=81=D0=B5=D1=80=D0=BF=D0=BD=D1=8F 2023 =D1=80=2E 15:49:32 GMT+03:0= 0, Jonas Karlman =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0= =D0=B2(-=D0=BB=D0=B0): >>> Hi, >>> >>> On 2023-07-21 07:34, Svyatoslav Ryhel wrote: >>>> =D1=87=D1=82, 20 =D0=BB=D0=B8=D0=BF=2E 2023=E2=80=AF=D1=80=2E =D0=BE = 22:43 Simon Glass =D0=BF=D0=B8=D1=88=D0=B5: >>>>> >>>>> Hi Svyatoslav, >>>>> >>>>> On Thu, 20 Jul 2023 at 06:38, Svyatoslav Ryhel wrote: >>>>>> >>>>>> Regulators initial setup was previously dependent on board call=2E >>>>>> To move from this behaviour were introduced two steps=2E First is >>>>>> that all individual regulators will be probed just after binding >>>>> >>>>> We must not probe devices automatically when bound=2E The i2c interf= ace >>>>> may not be available, etc=2E Do a probe afterwards=2E >>>>> >>>>> Perhaps I am misunderstanding this, iwc please reword this commit me= ssage=2E >>>> >>>> After bound=2E If the regulator is a self-sufficient i2c device then = it >>>> will be bound >>>> after i2c is available by code design so i2c interface should be >>>> available at that >>>> moment=2E At least led and gpio uclasses perform this for initial set= up >>>> of devices=2E >>>> >>>> Platform regulators (aka fixed/gpio regulators) work perfectly fine= =2E I >>>> have no i2c >>>> regulators to test deeply=2E >>>> >>>> As for now only one uclass is not compatible with this system - PMIC = which has >>>> strong dependency between regulator and main mfd=2E This is why probi= ng after >>>> bind for pmic regulators is disabled and pmic regulators are probed o= n pmic core >>>> post_probe=2E >>> >>> This sounds more like a possible bug of some dependency not being >>> probed in correct order or not leaving the device in a ready state >>> after probe=2E >>> >>> If pmic regulators are bind in pmic bind with the pmic as parent, then >>> at regulator probe the driver core ensure that pmic has probed before >>> regulator use=2E >>> >>> This works perfect fine with the RK8xx I2C PMIC and its regulators=2E >>> Wich a call to device_get_supply_regulator(dev, "test-supply", ®) >>> probe happens in i2c, pmic and regulator order=2E >>> >>=20 >> I will check and re-test drivers I have ASAP=2E=20 >>=20 >>>> >>>>>> which ensures that regulator pdata is filled and second is setting >>>>>> up regulator in post probe which enseres that correct regulator >>>>>> state according to pdata is reached=2E >>> >>> I think that the approach in this patch is trying to change too much a= ll >>> at once=2E >>> >>> Have made some adjustments that I think should help with transition=2E >>> - Added a flag to protect regulator_autoset from being called more the= n >>> once for each regulator, in a separate patch=2E >>=20 >> It is not a good decision in the long run and you should keep in mind t= hat there is nothing more constant than a temporary solution=2E > >Nor do I propose this to be a long-term solution, only that it is more >reviewable to see changes in non-breaking smaller steps=2E In current >state this patch breaks building U-Boot and requires the last patch to >fix build again=2E > >Anyway, I will be posting a similar patch for autoset as linked below as >part of a series to add a Rockchip IO-domain driver shortly=2E In current >state autoset cannot safely be called multiple times, and such patch >should not have an impact on the direction of this series=2E > >>=20 >>> - Changed to only probe-after-bind on regulators marked as >>> always-on/boot-on=2E >>> >>> And it works something like this: >>> >>> static int regulator_post_bind(struct udevice *dev) >>> { >>> [=2E=2E=2E] >>> >>> if (uc_pdata->always_on || uc_pdata->boot_on) >>> dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); >>> } >>> >>> static int regulator_post_probe(struct udevice *dev) >>> { >>> ret =3D regulator_autoset(dev); >>> } >>> >>> With that any always-on/boot-on regulator would automatically probe an= d >>> autoset after bind, remaining would only probe and autoset if they are >>> used=2E >>=20 >> uc_pdata is filled in pre_probe, while you are runing check in post_bin= d=2E > >Please look closer at the code and not the snippet above, they are >filled in post_bind or the code would not have worked :-) So you have moved that, alright=2E Well, I am fine with less invasive patc= h as long as my devices continue to work as intended=2E I will test your su= ggestions and reload patchset=2E Thanks=2E Best regards, Svyatoslav R=2E >Regards, >Jonas > >>=20 >>> This approach should also prevent having to change existing code that >>> may call autoset, and cleanup can be done in follow-up patches/series= =2E >>> >>> Probe-after-bind and call to autoset could also be protected with a ne= w >>> Kconfig to help with transition=2E >>> >>> See following for a working example using a new driver that depends >>> on that regulators have been autoset prior to regulator_get_value=2E >>> https://github=2Ecom/Kwiboo/u-boot-rockchip/compare/master=2E=2E=2Erk3= 568-io-domain >>> >>> Or the two commits separate: >>> >>> power: regulator: Only run autoset once for each regulator >>> https://github=2Ecom/Kwiboo/u-boot-rockchip/commit/05db4dbcb8f908b417e= d5cae8a7a325c82112d75 >>> >>> power: regulator: Perform regulator setup inside uclass >>> https://github=2Ecom/Kwiboo/u-boot-rockchip/commit/489bd5d2c1a2a33824e= ac4f2d54399ef5dff4fdf >>> >>> Regards, >>> Jonas >>> >>>>>> >>>>>> Signed-off-by: Svyatoslav Ryhel >>>>>> --- >>>>>> drivers/power/regulator/regulator-uclass=2Ec | 212 ++++++---------= ------ >>>>>> include/power/regulator=2Eh | 119 ------------ >>>>>> 2 files changed, 62 insertions(+), 269 deletions(-) >>>>> >>>>> Regards, >>>>> SImon >>> >