Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp70619lqg; Fri, 26 Apr 2024 09:02:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUyS6jwSLMkm93pF65s8YKyNdDHYUOmie6fdGmHNbKXP67Jbb0BurlmOv/CJsoILtM1LetNSJen5OGXG1d9UJXU4lYo5WvaU/KSKNcihw== X-Google-Smtp-Source: AGHT+IEVoCxwK4/Gpfxu1yEeCTTDvxTiVQFOUhkVL61YEwEcDCEgBeZO3Td9xX90gR5TIA1XjBNL X-Received: by 2002:a2e:9e41:0:b0:2d6:8e88:5a8b with SMTP id g1-20020a2e9e41000000b002d68e885a8bmr2327927ljk.32.1714147348430; Fri, 26 Apr 2024 09:02:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714147348; cv=pass; d=google.com; s=arc-20160816; b=kSPI7JZAQttE9/ryfGW4Jx0Dt1L+hUIcVq5kmKV5m0jEw55MRqhof1ct48iYapWqU3 5TytMkBDxanxlwyL+iWrZcWYbOQnPOummyh9WjStiNTLxkDTDBIQ5lZwRATyV/93dZBo whshbZSj5U00mzj0JypdyrC1C/zM/OQIU8wRPUTy7n4t/qI0e29VoVK3M6jk1Yghmg/P ZGehhMeJbXSV1JE9kGGf0a4HvU845U+FNHhtIPZ/vGx6zHUffJSfzO2GLGlcWdILdVR/ PsZPR5zf69n/gSfmJZOfj1BTfxQ2bVRYfH0bdm1JiuztFX+A33wu4lLY+N9I4FbxjLKT dkHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Amw4/bajJowEQc3xMpXrC2fZXOfCeYn8U9XHLfZLBK8=; fh=MZgvy/AmeHE5/588XAg1mUij55f12DiWyocFDxS19BU=; b=fJ7rwmC+Mt0KM4bb5erh4tPm5EXVPsHt6uQ21KR5gDAeGJUVlHYmbwy1o34PpO3DvK w4PGWJ8FhHrtWgyQGVW5xJwGYzGQYFo7ZsJcdwZn85VSggK8QgX9VAOuq32DolyjLKSv 7RsZ3kzx63bOJBYMx22DfZTvOdtn1poHyrecqB98uGqIC4FOpqN3axMuwOaif1qYuFPr I+RmPzW8r2k7A+zULVLZsHXFKrOITZEUjxXK5ydkE8oQ0V0Bn/2iBCLOMM96Izm3rbnn Wcn1wCa/eTVIg2Yotrw/IqBc7bP0jyIDGOwfIRkEszRwMlE/BJdKk9A0AmgBGOWtHspT 1CoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=KLc6eWKI; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-kernel+bounces-160348-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160348-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ha26-20020a170906a89a00b00a58831a12b8si4630460ejb.569.2024.04.26.09.02.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 09:02:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160348-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=KLc6eWKI; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-kernel+bounces-160348-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160348-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 496561F24BF3 for ; Fri, 26 Apr 2024 16:02:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E14FF15ECE3; Fri, 26 Apr 2024 16:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="KLc6eWKI" 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.subspace.kernel.org (Postfix) with ESMTPS id 4CE3514A4D9; Fri, 26 Apr 2024 16:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.62.61 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714147258; cv=none; b=CUKe4GzsJ2iDqSxyeLaR0lQmlpTqUZULlDK1vwnsbI2xuEVjipncwtvdgscWQ7EQBq4JsiOHsEYFMACa/XLM/qvU2CfarflZukDAyXDC6t8O3vEMCQSHdMRl7yle11Y6rfQXEI0oDkdogR6akm04jBDiI3GkBl2JyPWSZeAPEtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714147258; c=relaxed/simple; bh=GHpAhp43gXbQiBLunOPFF1TgsOqR+/UXG5NrXX5hE8A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qwyhfNqg7IeuTyhNQhYycgvRSdu5mSHRHxhj7trE0OdFutLYbhFcotwyJVKVQgg0MVnWCJxYwe1+JwpOkCBkweoiYAQpR4j+3hkthlIy/7+ISeANmolEpe6h5H4rHA2M5jJeiawWU9M8xc8mFGBwdCJayayZsidXHZHPLTSBbk4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de; spf=pass smtp.mailfrom=denx.de; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b=KLc6eWKI; arc=none smtp.client-ip=85.214.62.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=denx.de Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 7D9FB8857C; Fri, 26 Apr 2024 18:00:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1714147251; bh=Amw4/bajJowEQc3xMpXrC2fZXOfCeYn8U9XHLfZLBK8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=KLc6eWKIpa/Wh3b5Q63HZaxGBZwMGpx4phoHXtpPPNVSgZ+sMEVfxdH41flNm35TC tO57KUR5RU12Ce3Kaz2k+xYbJT7Bj8qE+9qF2H7ljtYFh+Fd1PGUOOAzQY9HjmaiAU OlK22tHP3YNOk93pjPUEeBDY66K1zE3ZMgSgojIO6KEqsqNJ/ea9PGcDQDfYStXUkp SGJ9Yf9WetN+yRsDhTex6HVbCjWUngf4aI+7SVp08CrHttLxqvg3NupJ5hpUa6ST/c 6xMeZm8JGlUR1IVvxMShD0QjSGLC5wcJsUECgLhWvpgiU4didTAzctuzdRiteOB9Gd NyTnMv0uMqW9A== Message-ID: Date: Fri, 26 Apr 2024 17:37:51 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 05/11] net: stmmac: dwmac-stm32: update config management for phy wo cristal To: Christophe Roullier , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue , Richard Cochran , Jose Abreu , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240426125707.585269-1-christophe.roullier@foss.st.com> <20240426125707.585269-6-christophe.roullier@foss.st.com> Content-Language: en-US From: Marek Vasut In-Reply-To: <20240426125707.585269-6-christophe.roullier@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 4/26/24 2:57 PM, Christophe Roullier wrote: > Some cleaning because some Ethernet PHY configs do not need to add > st,ext-phyclk property. > Change print info message "No phy clock provided" only when debug. > > Signed-off-by: Christophe Roullier > --- > .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 27 ++++++++++--------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > index 7529a8d15492..e648c4e790a7 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > @@ -55,17 +55,17 @@ > *| | | 25MHz | 50MHz | | > * --------------------------------------------------------------------------- > *| MII | - | eth-ck | n/a | n/a | > - *| | | st,ext-phyclk | | | > + *| | | | | | > * --------------------------------------------------------------------------- > *| GMII | - | eth-ck | n/a | n/a | > - *| | | st,ext-phyclk | | | > + *| | | | | | > * --------------------------------------------------------------------------- > *| RGMII | - | eth-ck | n/a | eth-ck | > - *| | | st,ext-phyclk | | st,eth-clk-sel or| > + *| | | | | st,eth-clk-sel or| > *| | | | | st,ext-phyclk | > * --------------------------------------------------------------------------- > *| RMII | - | eth-ck | eth-ck | n/a | > - *| | | st,ext-phyclk | st,eth-ref-clk-sel | | > + *| | | | st,eth-ref-clk-sel | | > *| | | | or st,ext-phyclk | | > * --------------------------------------------------------------------------- > * > @@ -174,23 +174,22 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat) > dwmac->enable_eth_ck = false; > switch (plat_dat->mac_interface) { > case PHY_INTERFACE_MODE_MII: > - if (clk_rate == ETH_CK_F_25M && dwmac->ext_phyclk) > + if (clk_rate == ETH_CK_F_25M) I see two problems here. First, according to the table above, in MII mode, clk_rate cannot be anything else but 25 MHz, so the (clk_rate == ETH_CK_F_25M) condition is always true. Why not drop that condition ? The "dwmac->ext_phyclk" means "Ethernet PHY have no crystal", which means the clock are provided by the STM32 RCC clock IP instead, which means if the dwmac->ext_phyclk is true, dwmac->enable_eth_ck should be set to true, because dwmac->enable_eth_ck controls the enablement of these STM32 clock IP generated clock. Second, as far as I understand it, there is no way to operate this IP with external clock in MII mode, so this section should always be only: dwmac->enable_eth_ck = true; > dwmac->enable_eth_ck = true; > val = dwmac->ops->pmcsetr.eth1_selmii; > pr_debug("SYSCFG init : PHY_INTERFACE_MODE_MII\n"); > break; > case PHY_INTERFACE_MODE_GMII: > val = SYSCFG_PMCR_ETH_SEL_GMII; > - if (clk_rate == ETH_CK_F_25M && > - (dwmac->eth_clk_sel_reg || dwmac->ext_phyclk)) { > + if (clk_rate == ETH_CK_F_25M) > dwmac->enable_eth_ck = true; > - val |= dwmac->ops->pmcsetr.eth1_clk_sel; > - } > pr_debug("SYSCFG init : PHY_INTERFACE_MODE_GMII\n"); > break; > case PHY_INTERFACE_MODE_RMII: > val = dwmac->ops->pmcsetr.eth1_sel_rmii | dwmac->ops->pmcsetr.eth2_sel_rmii; > - if ((clk_rate == ETH_CK_F_25M || clk_rate == ETH_CK_F_50M) && > + if (clk_rate == ETH_CK_F_25M) > + dwmac->enable_eth_ck = true; > + if (clk_rate == ETH_CK_F_50M && > (dwmac->eth_ref_clk_sel_reg || dwmac->ext_phyclk)) { This doesn't seem to be equivalent change to the previous code . Here, if the clock frequency is 25 MHz, the clock are unconditionally enabled. Before, the code enabled the clock only if clock frequency was 25 MHz AND one of the "dwmac->eth_ref_clk_sel_reg" or "dwmac->ext_phyclk" was set (i.e. clock provided by SoC RCC clock IP). I think it might make this code easier if you drop all of the frequency test conditionals, which aren't really all that useful, and only enable the clock if either dwmac->ext_phyclk / dwmac->eth_clk_sel_reg / dwmac->eth_ref_clk_sel_reg is set , because effectively what this entire convoluted code is implementing is "if (clock supplied by clock IP i.e. RCC) enable the clock()" *, right ? * And it is also toggling the right clock mux bit in PMCSETR. So, for MII this would be plain: dwmac->enable_eth_ck = true; For GMII/RGMII this would be: if (dwmac->ext_phyclk || dwmac->eth_clk_sel_reg) dwmac->enable_eth_ck = true; For RMII this would be: if (dwmac->ext_phyclk || dwmac->eth_ref_clk_sel_reg) dwmac->enable_eth_ck = true; Maybe the clock frequency validation can be retained, but done separately? > dwmac->enable_eth_ck = true; > val |= dwmac->ops->pmcsetr.eth1_ref_clk_sel; > @@ -203,7 +202,9 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat) > case PHY_INTERFACE_MODE_RGMII_RXID: > case PHY_INTERFACE_MODE_RGMII_TXID: > val = dwmac->ops->pmcsetr.eth1_sel_rgmii | dwmac->ops->pmcsetr.eth2_sel_rgmii; > - if ((clk_rate == ETH_CK_F_25M || clk_rate == ETH_CK_F_125M) && > + if (clk_rate == ETH_CK_F_25M) > + dwmac->enable_eth_ck = true; > + if (clk_rate == ETH_CK_F_125M && > (dwmac->eth_clk_sel_reg || dwmac->ext_phyclk)) { > dwmac->enable_eth_ck = true; > val |= dwmac->ops->pmcsetr.eth1_clk_sel; > @@ -219,7 +220,7 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat) > } > > /* Need to update PMCCLRR (clear register) */ > - regmap_write(dwmac->regmap, reg + dwmac->ops->syscfg_clr_off, > + regmap_write(dwmac->regmap, dwmac->ops->syscfg_clr_off, > dwmac->mode_mask); > > /* Update PMCSETR (set register) */ > @@ -328,7 +329,7 @@ static int stm32mp1_parse_data(struct stm32_dwmac *dwmac, > /* Get ETH_CLK clocks */ > dwmac->clk_eth_ck = devm_clk_get(dev, "eth-ck"); > if (IS_ERR(dwmac->clk_eth_ck)) { > - dev_info(dev, "No phy clock provided...\n"); > + dev_dbg(dev, "No phy clock provided...\n"); > dwmac->clk_eth_ck = NULL; > } >