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 A1650C433F5 for ; Sun, 8 May 2022 18:21:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3F65483AEF; Sun, 8 May 2022 20:21: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=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="HZohL2Sd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 52A4A83C0C; Sun, 8 May 2022 20:21:10 +0200 (CEST) Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) (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 61F5A8344E for ; Sun, 8 May 2022 20:21:07 +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=seanga2@gmail.com Received: by mail-qt1-x833.google.com with SMTP id p4so9585450qtq.12 for ; Sun, 08 May 2022 11:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zfOAOltfyWIJSqeg+P0dHCl7n0yrFAwAlAC9ZYR0K9w=; b=HZohL2SdfU2FfMXJGbaBZgQq/thgVaDvSbymZdtCBVY0SLbP8xfe/7Ca3Zzc+tUnwU PDNTwlfWMyclWfh5FJbhtWZVIuMMriPA7X9+Y1/FmRB77pE/mCjokuRj+P/j0lLr/ott e5Qni/gOsCR4cJnON3Y3561mBN5Xc9OCiLdID9nZghYFfDhyWGGztHpnOhaCkkPokhyd 8hnt/HKvQhMT8xU9w9+6xSPz4OHT+Mn2u3qRpXVi5pcZB0jc6CeK41maGFWUQYHnsklT 7F/ihz5StlUK3MTAasfnrBjO6KQG34xLj4XQL+WWHEyQ/6+kahZgq4se7FZ44Zx58PDw PsOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zfOAOltfyWIJSqeg+P0dHCl7n0yrFAwAlAC9ZYR0K9w=; b=7+QzS7/FvemdujtKEdciIM4ikyt/OuEYXX26gP6ViskrK6jHfUz8QzllFJxEUkREmb NE9S0+PShCYCtvAgGskPyLN0JBH9KsD4H/zpcFqoJrh8GydxLsyLGTOwDZEqAfBZkOAS kEPtCihItE69KaKpNVzWdynH8i5p6xUYP/l9C/V/SDSyNAsBDPQmSMWctEU1oxc/prov NNsNRr0O4liop3uoIYZtnuIEAppw2L1ZKXZmLaTrfdrnX6MtDvEfnjqWTXqjMJhHAX57 a6E/iOi7ELPQtH0DvR0H1N9Ms9KcKN85wLmDm38HiqU+CL9oKHdeIRIOqjnbBoFnRnwm 8g5w== X-Gm-Message-State: AOAM531rf45+DR7DjDRaKb7XinzZVQ+tQ7ktGuiZkwhQWMOSoAfyleM0 Lx67W5bxwswu2xqfYBCr3b0= X-Google-Smtp-Source: ABdhPJwHieEneMx4BTXmjayE9a0VGx1S8t7D3tPZux45cct7QENpA5NM7ggYpO7OeyI/gzqSbGDoHA== X-Received: by 2002:ac8:5f88:0:b0:2f3:b80c:a7a4 with SMTP id j8-20020ac85f88000000b002f3b80ca7a4mr12354050qta.38.1652034066194; Sun, 08 May 2022 11:21:06 -0700 (PDT) Received: from [192.168.1.201] (pool-108-18-248-138.washdc.fios.verizon.net. [108.18.248.138]) by smtp.googlemail.com with ESMTPSA id o28-20020a05620a0d5c00b0069fc167df92sm5682791qkl.82.2022.05.08.11.21.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 May 2022 11:21:05 -0700 (PDT) Subject: Re: [PATCH 1/3] phy: stm32-usbphyc: add counter of PLL consumer To: Patrick Delaunay , u-boot@lists.denx.de Cc: Joe Hershberger , Patrice Chotard , uboot-stm32@st-md-mailman.stormreply.com References: <20220426123750.579726-1-patrick.delaunay@foss.st.com> <20220426143736.1.I15bd7c3c8c983d6a6cec3d2ee371d75fe72fcd41@changeid> From: Sean Anderson Message-ID: <27373592-d6c9-ff00-799b-a2f04f4500b1@gmail.com> Date: Sun, 8 May 2022 14:21:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20220426143736.1.I15bd7c3c8c983d6a6cec3d2ee371d75fe72fcd41@changeid> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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.5 at phobos.denx.de X-Virus-Status: Clean On 4/26/22 8:37 AM, Patrick Delaunay wrote: > Add the counter of the PLL user n_pll_cons managed by the 2 functions > stm32_usbphyc_pll_enable / stm32_usbphyc_pll_disable. > > This counter allow to remove the function stm32_usbphyc_is_init > and it is a preliminary step for ck_usbo_48m introduction. Is it necessary to disable this clock before booting to Linux? If it isn't, then perhaps it is simpler to just not disable the clock. --Sean > Signed-off-by: Patrick Delaunay > --- > > drivers/phy/phy-stm32-usbphyc.c | 76 +++++++++++++++++++++------------ > 1 file changed, 48 insertions(+), 28 deletions(-) > > diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c > index 9c1dcfae52..16c8799eca 100644 > --- a/drivers/phy/phy-stm32-usbphyc.c > +++ b/drivers/phy/phy-stm32-usbphyc.c > @@ -65,6 +65,7 @@ struct stm32_usbphyc { > bool init; > bool powered; > } phys[MAX_PHYS]; > + int n_pll_cons; > }; > > static void stm32_usbphyc_get_pll_params(u32 clk_rate, > @@ -124,18 +125,6 @@ static int stm32_usbphyc_pll_init(struct stm32_usbphyc *usbphyc) > return 0; > } > > -static bool stm32_usbphyc_is_init(struct stm32_usbphyc *usbphyc) > -{ > - int i; > - > - for (i = 0; i < MAX_PHYS; i++) { > - if (usbphyc->phys[i].init) > - return true; > - } > - > - return false; > -} > - > static bool stm32_usbphyc_is_powered(struct stm32_usbphyc *usbphyc) > { > int i; > @@ -148,18 +137,17 @@ static bool stm32_usbphyc_is_powered(struct stm32_usbphyc *usbphyc) > return false; > } > > -static int stm32_usbphyc_phy_init(struct phy *phy) > +static int stm32_usbphyc_pll_enable(struct stm32_usbphyc *usbphyc) > { > - struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev); > - struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id; > bool pllen = readl(usbphyc->base + STM32_USBPHYC_PLL) & PLLEN ? > true : false; > int ret; > > - dev_dbg(phy->dev, "phy ID = %lu\n", phy->id); > - /* Check if one phy port has already configured the pll */ > - if (pllen && stm32_usbphyc_is_init(usbphyc)) > - goto initialized; > + /* Check if one consumer has already configured the pll */ > + if (pllen && usbphyc->n_pll_cons) { > + usbphyc->n_pll_cons++; > + return 0; > + } > > if (usbphyc->vdda1v1) { > ret = regulator_set_enable(usbphyc->vdda1v1, true); > @@ -190,23 +178,19 @@ static int stm32_usbphyc_phy_init(struct phy *phy) > if (!(readl(usbphyc->base + STM32_USBPHYC_PLL) & PLLEN)) > return -EIO; > > -initialized: > - usbphyc_phy->init = true; > + usbphyc->n_pll_cons++; > > return 0; > } > > -static int stm32_usbphyc_phy_exit(struct phy *phy) > +static int stm32_usbphyc_pll_disable(struct stm32_usbphyc *usbphyc) > { > - struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev); > - struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id; > int ret; > > - dev_dbg(phy->dev, "phy ID = %lu\n", phy->id); > - usbphyc_phy->init = false; > + usbphyc->n_pll_cons--; > > - /* Check if other phy port requires pllen */ > - if (stm32_usbphyc_is_init(usbphyc)) > + /* Check if other consumer requires pllen */ > + if (usbphyc->n_pll_cons) > return 0; > > clrbits_le32(usbphyc->base + STM32_USBPHYC_PLL, PLLEN); > @@ -235,6 +219,42 @@ static int stm32_usbphyc_phy_exit(struct phy *phy) > return 0; > } > > +static int stm32_usbphyc_phy_init(struct phy *phy) > +{ > + struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev); > + struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id; > + int ret; > + > + dev_dbg(phy->dev, "phy ID = %lu\n", phy->id); > + if (usbphyc_phy->init) > + return 0; > + > + ret = stm32_usbphyc_pll_enable(usbphyc); > + if (ret) > + return log_ret(ret); > + > + usbphyc_phy->init = true; > + > + return 0; > +} > + > +static int stm32_usbphyc_phy_exit(struct phy *phy) > +{ > + struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev); > + struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id; > + int ret; > + > + dev_dbg(phy->dev, "phy ID = %lu\n", phy->id); > + if (!usbphyc_phy->init) > + return 0; > + > + ret = stm32_usbphyc_pll_disable(usbphyc); > + > + usbphyc_phy->init = false; > + > + return log_ret(ret); > +} > + > static int stm32_usbphyc_phy_power_on(struct phy *phy) > { > struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev); >