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 97554EB64D9 for ; Tue, 4 Jul 2023 12:35:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 53EFC861C3; Tue, 4 Jul 2023 14:34:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=londelec.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=londelec-com.20221208.gappssmtp.com header.i=@londelec-com.20221208.gappssmtp.com header.b="u/9HI+bK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6678A85241; Tue, 4 Jul 2023 12:05:34 +0200 (CEST) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 150EF8565A for ; Tue, 4 Jul 2023 12:05:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=londelec.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=cody@londelec.com Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fa93d61d48so64561175e9.0 for ; Tue, 04 Jul 2023 03:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=londelec-com.20221208.gappssmtp.com; s=20221208; t=1688465129; x=1691057129; 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=Uq5xZjXBJ6s6TuQfJ5wHFNLgd2CfNO+yuqiR/jzcKoA=; b=u/9HI+bK7iZ1W0lhwWYRnZYXdAk3TWZkbuaLzMmihOYCVNwp3aKueTxDI03TxggtZ2 IxUefmR1V2QU+DlzqUvFNSQ+Y7RLBhDvCAzECdpqAVKu2pPwaydKogvAp00EpI+IMWoj iF6e2bwNPcQ7SayYuc7XTiA8xZ8yVvNK8FhaKR+Ud6cFdOMFRoNpI7kFqw4HF0+rwcVP 0jtkYz9CNgXbAtI8wQ+Zw6pB/3Vvnqn9KgJHb4PYdaXaSDOPIQzuoEpKhzzshjOZlzDq VDSLjFDGOLbDQMC3ppDdhdoF3kpUa3DXyOzybgx+HCgJgHXo+UpvvjGJig2xZ/L/J9WR U5/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688465129; x=1691057129; 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=Uq5xZjXBJ6s6TuQfJ5wHFNLgd2CfNO+yuqiR/jzcKoA=; b=JNhXMet+/LZnOlTG5HnrPgb9ZCTss+S64/JK3BpFoEIUgWNeqTtgGWi57HZrcq2R18 UwTzf3sPd5jttXmIDwO+PyjJanqOoqbfo4/Yz8RzZyTad1qluSpmuJFPKB3ZQJOJG+P+ /6kNxBm0OWUMgq742oBXUh7arjnmJqhEkDheENLrBlYadljjK1cT9ili51sQuKIB1clQ uHI/Ht+3pW+d5Y+VXgbseafc67fRtxC+L69Tj0Aa80HxzOWFeo9i7n61cz8JkFvs1E4v DNbxYzgj9iAZjXolaXtSUJod6X7WGVlYF/9MlM5KcWaujZOw+eYhldIh0gEyUGGpqHTt Nmhw== X-Gm-Message-State: AC+VfDy43+Z0EIL1Yt/XnPFp1GzEaxbg3bhi5PYvYdRkzM7+DMGg3L8y McuueTPPwu2drmDq832esRKt6W2o5qQe7cBSWYrUrik3 X-Google-Smtp-Source: ACHHUZ4r6e58Y3Yz3mI4+KR9B2ZFPQSbvw7wA501Pz3IhVGi65ZRvp8WxUQAwtNcB3KSr8FLNUxveQ== X-Received: by 2002:a1c:7409:0:b0:3fb:7724:254b with SMTP id p9-20020a1c7409000000b003fb7724254bmr10685386wmc.9.1688465129354; Tue, 04 Jul 2023 03:05:29 -0700 (PDT) Received: from localhost.localdomain ([146.70.95.150]) by smtp.gmail.com with ESMTPSA id x5-20020adff645000000b0031432f1528csm6544649wrp.45.2023.07.04.03.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 03:05:28 -0700 (PDT) From: Cody Green To: u-boot@lists.denx.de Cc: Stefano Babic , Marek Vasut , Fabio Estevam , Lukasz Majewski Subject: Re: [PATCH 2/2] mxs: Don't enable 4P2 reg if MXS is powered only from DCDC_BATT Date: Tue, 4 Jul 2023 11:05:13 +0100 Message-Id: <20230704100513.56895-1-cody@londelec.com> In-Reply-To: <20230704101857.7ca296c7@wsk> References: <20230704101857.7ca296c7@wsk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 04 Jul 2023 14:34:28 +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 On Tue, Jul 4, 2023 at 9:19 AM Lukasz Majewski wrote: Hi Lukasz, > > Hi Marek, Cody, > > > On 7/3/23 18:33, Cody Green wrote: > > > 'mxs_power_enable_4p2()' function call was added to > > > 'mxs_batt_boot()' in 'commit a0f97610757d' to enable DCDC converter > > > when board is powered from 5V and has detected sufficient battery > > > voltage. This involves enabling 4P2 regulator and there is a code > > > in 'mxs_power_enable_4p2()' that disables VDDIO, VDDA, VDDD outputs > > > of the DCDC converter and enables BO for each power rail: > > > > > >    setbits_le32(&power_regs->hw_power_vddioctrl, > > >      POWER_VDDIOCTRL_DISABLE_FET | POWER_VDDIOCTRL_PWDN_BRNOUT); > > > > > > There is no issue if the MXS is powered from the 5V source and > > > linear regulators are supplying power to the VDDIO, VDDA, VDDD > > > rails. However, if the MXS is powered only from the DCDC_BATT > > > without 5V, disabling the DCDC converter outputs causes VDDIO, > > > VDDA, VDDD rails to lose power. > > I think that I've also hit the same issue with the XEA board > (upstreamed). > > I've prepared a set of patches: > https://patchwork.ozlabs.org/project/uboot/patch/20230509143243.1523791-5-lukma@denx.de/ > > to fix this problem. > > Those patches are now for some time on the mailing list for review - and > I do hope that Stefano will pull them with next PR for u-boot-imx > repository. > > > > > > > The proposed solution is not to call the 'mxs_power_enable_4p2()' > > > function if the MXS is powered only by the DCDC_BATT, because there > > > is no reason to enable 4P2 regulator in this case. > > I think this patch: > https://patchwork.ozlabs.org/project/uboot/patch/20230509143243.1523791-3-lukma@denx.de/ > > address exactly this issue. Yes, your patch [3/5] addresses the issue perfectly! I was considering to add the Kconfig option, but decided against it, as I thought nobody else is running the MXS only from DCDC_BATT without 5V. In my opinion Kconfig option is better solution than my patch and I am happy to add 'Tested-by' tag to your patch [3/5], if you wish. > > > > Also 5V brownout > > > should not be enabled in 'mxs_power_init()' and linear regulator > > > checks should be disabled in 'mxs_power_set_vddx()'. > > > > > I've also added some code to limit the VDD5V current when we intend to > use DCDC_BATT input as the _primary_ source of power (AN4199 advises > this one for industrial applications as the most reliable). > I checked other patches in your set and as far as I can tell the rest of them apply if the board is powered from both DCDC_BATT and 5V source. This is all good stuff, but what shall we do about enabling 5V brownout: writel(POWER_5VCTRL_PWDN_5VBRNOUT, &power_regs->hw_power_5vctrl_set); in 'void mxs_power_init()'? Would you consider using the new 'MXS_PMU_ENABLE_4P2_LINEAR_REGULATOR' option to not enable 5V brownout as well? e.g. if (CONFIG_IS_ENABLED(MXS_PMU_ENABLE_4P2_LINEAR_REGULATOR)) writel(POWER_5VCTRL_PWDN_5VBRNOUT, &power_regs->hw_power_5vctrl_set); My reasoning is the 4P2 regulator would be disabled only in the scenario if the board is running without 5V hence there is no need for a 5V brownout. There is a slightly different problem with: if (cfg->powered_by_linreg) powered_by_linreg = cfg->powered_by_linreg(); in 'mxs_power_set_vddx()'. I noticed that function 'mxs_get_vddd_power_source_off()' returns '1' (i.e. powered_by_linreg) because of the following code: if (!(tmp & POWER_VDDDCTRL_ENABLE_LINREG)) { if ((tmp & POWER_VDDDCTRL_LINREG_OFFSET_MASK) == POWER_VDDDCTRL_LINREG_OFFSET_1STEPS_BELOW) { return 1; } } I am not sure why this piece of code even exists, but rather than risking to brake something by removing it, I decided that we can simply disable calling 'mxs_get_vddd_power_source_off()' if the board is powered from DCDC_BATT only. So would you consider the following as well? if (CONFIG_IS_ENABLED(MXS_PMU_ENABLE_4P2_LINEAR_REGULATOR)) if (cfg->powered_by_linreg) powered_by_linreg = cfg->powered_by_linreg(); > > > > Signed-off-by: Cody Green > > > Cc: Stefano Babic > > > Cc: Marek Vasut > > > Cc: Fabio Estevam > > > --- > > >   arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 7 +++++++ > > >   1 file changed, 7 insertions(+) > > > > > > diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c > > > b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c index > > > 33b76533e4..72172705f2 100644 --- > > > a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +++ > > > b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c @@ -752,7 +752,9 @@ > > > static void mxs_batt_boot(void) POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK, > > >             0x8 << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET); > > >   > > > +#ifndef CFG_SPL_MXS_NO_VDD5V_SOURCE > > >     mxs_power_enable_4p2(); > > > +#endif > > >   } > > >   > > >   /** > > > @@ -1137,8 +1139,11 @@ static void mxs_power_set_vddx(const struct > > > mxs_vddx_cfg *cfg, cur_target += cfg->lowest_mV; > > >   > > >     adjust_up = new_target > cur_target; > > > + > > > +#ifndef CFG_SPL_MXS_NO_VDD5V_SOURCE > > >     if (cfg->powered_by_linreg) > > >             powered_by_linreg = cfg->powered_by_linreg(); > > > +#endif > > >   > > >     if (adjust_up && cfg->bo_irq) { > > >             if (powered_by_linreg) { > > > @@ -1269,7 +1274,9 @@ void mxs_power_init(void) > > >             POWER_CTRL_VBUS_VALID_IRQ | > > > POWER_CTRL_BATT_BO_IRQ | POWER_CTRL_DCDC4P2_BO_IRQ, > > > &power_regs->hw_power_ctrl_clr); > > > +#ifndef CFG_SPL_MXS_NO_VDD5V_SOURCE > > >     writel(POWER_5VCTRL_PWDN_5VBRNOUT, > > > &power_regs->hw_power_5vctrl_set); +#endif > > >   > > >     early_delay(1000); > > >   } > > > > +CC Lukasz > > > > > Best regards, > > Lukasz Majewski > > -- > > DENX Software Engineering GmbH,      Managing Director: Erika Unter > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de