Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2337361rdh; Tue, 26 Sep 2023 22:25:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpY+Gzv/i5OSSm6bSof0WLmoNGkvWfQ6xJhE4Gp5TjMXX1chfyRrlG+d/5jAs50pBkN/D0 X-Received: by 2002:a17:903:41c9:b0:1c4:5a9:a45e with SMTP id u9-20020a17090341c900b001c405a9a45emr1789370ple.27.1695792330889; Tue, 26 Sep 2023 22:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695792330; cv=none; d=google.com; s=arc-20160816; b=YEWvjm4vT5RP9i0UHW0PkRKUjKQoHshugjF5le/UepAu4QaHs9IxtfjebPb11FYxRg dpVZ4vWKvgC8Gtb6aJfXY/26uiLIMYd/u8ft6Y+qXO3n3s0dOGnOQyqwU93fYNU6na4x Eb6Ls2qcx8nkbBO6Maj9OZGhHo5s1j9i1H/jbR3mqy6NYKgm2yvRINEZlV0HMrGCPOVb hUNmqpuzM3OSZSJvK/O+WvhAmuCjbuUeEQEaCYyt/3RF16hp+VtjYL60d/YZ+gtYFmBw WGO16wdU9cBhD3JzqbH4T+IR34UvWFzG/AMRrLpNL1enamviJXarAmS6X2dylp+mwFhV euKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=+bH4U16aWMoXsVXSzEOmw6O9u/kNT62WdhMO/fQ80QI=; fh=SIJYaYepNTH+m1HEi/kzC1brmX2Jzzlv7bwIYsPCicw=; b=NfkOhVfiww9M0MQ9x9yo+qkjm9kDD307XlgKJpFvUQdLW2GKnQ01N/B0ffX/9a9gyD q9Yw0q8Ppq7Zo5n1XnFmgHyUrMb3Ztt3NEAiZObSa2gM9wPduMt+OLSgUg1twAiCSIse lgHHqZj/quh85WFwRbpIWflNI2ely9mkUU1SZiRl1dV/GOM3tFcGP8Hm/r43dU7AiNvh hBuyC9wyddZvg94XeB4WO37VZESGLk/tN75Hh8c9amZ3obfm9L7dpSWU8xY0no3KCPIv oY0KsR93FgS+i3KgGgzT39+ZyB6ooh7El6QWupS9f0dPXgHHf1yzvHHu38/CfYcYd4Jf voAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bs5-20020a632805000000b005855f67e48csi59482pgb.697.2023.09.26.22.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 22:25:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4F5E4807FC2B; Tue, 26 Sep 2023 21:50:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbjI0EuI convert rfc822-to-8bit (ORCPT + 99 others); Wed, 27 Sep 2023 00:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjI0EtM (ORCPT ); Wed, 27 Sep 2023 00:49:12 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B50E10FB; Tue, 26 Sep 2023 20:46:17 -0700 (PDT) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 87BB27FDC; Wed, 27 Sep 2023 11:46:09 +0800 (CST) Received: from EXMBX168.cuchost.com (172.16.6.78) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 27 Sep 2023 11:46:09 +0800 Received: from [192.168.125.113] (113.72.144.128) by EXMBX168.cuchost.com (172.16.6.78) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 27 Sep 2023 11:46:08 +0800 Message-ID: Date: Wed, 27 Sep 2023 11:46:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] riscv: dts: starfive: Add VisionFive 2 PHY supplies To: Emil Renner Berthing , "Daniel Maslowski" , , , CC: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Daniel Maslowski References: <20230923152653.3371216-1-cyrevolt@gmail.com> Content-Language: en-US From: Walker Chen In-Reply-To: Content-Type: text/plain; charset="UTF-8" X-Originating-IP: [113.72.144.128] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) To EXMBX168.cuchost.com (172.16.6.78) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 26 Sep 2023 21:50:27 -0700 (PDT) On 2023/9/24 20:22, Emil Renner Berthing wrote: > Daniel Maslowski wrote: >> I checked the schematics to see what power supplies are needed. >> This allows for using ethernet without other drivers enabled >> that would coincidentally enable the same power supply. ⚡ >> >> Signed-off-by: Daniel Maslowski >> --- >> .../boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dts | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dts b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dts >> index d4ea4a2c0b9b..bc1ac12bc71b 100644 >> --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dts >> +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dts >> @@ -16,12 +16,14 @@ &gmac0 { >> starfive,tx-use-rgmii-clk; >> assigned-clocks = <&aoncrg JH7110_AONCLK_GMAC0_TX>; >> assigned-clock-parents = <&aoncrg JH7110_AONCLK_GMAC0_RMII_RTX>; >> + phy-supply = <&vcc_3v3>; >> }; >> >> &gmac1 { >> starfive,tx-use-rgmii-clk; >> assigned-clocks = <&syscrg JH7110_SYSCLK_GMAC1_TX>; >> assigned-clock-parents = <&syscrg JH7110_SYSCLK_GMAC1_RMII_RTX>; >> + phy-supply = <&vcc_3v3>; >> }; > > Hi Daniel, > > Thank you for the patch! I've looked into this a bit now and I found 3 things: > > 1) The vcc_3v3 regulator (DCDC1 on the PMIC) already has the > regulator-always-on property, so should never be turned off even if there > are no consumers. > > 2) As far as I can tell the schematic for both the 1.2A and 1.3B says the PHYs > are powered by DCDC6 (and not DCDC1) on the PMIC via the VDD33_IO line. > > 3) There doesn't seem to be any generic code in the dwmac driver handling the > phy-supply property, only the Rockchip wrapper (dwmac-rk.c) does that. > > So all in all I'm a little confused how this change can make a difference for > you. > > @Walker does the above and 2) in particular seem correct to you? I checked the schematic of VisionFive2 again, the GMAC PHY is powered by DCDC6 via the VDD33_IO line, not DCDC1. So there's no need to add the property 'phy-supply' and handler code for regulator in probe(). > > I'd expect something like the following instead (although split in 3 patches). > Daniel, does this work for you? > > diff --git a/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml > b/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml > index 5e7cfbbebce6..9ce877782419 100644 > --- a/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml > +++ b/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml > @@ -54,6 +54,9 @@ properties: > minItems: 3 > maxItems: 3 > > + phy-supply: > + description: PHY regulator > + > resets: > items: > - description: MAC Reset signal. > diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi > b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi > index 2209d5348928..6633c8d29be7 100644 > --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi > +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi > @@ -101,6 +101,7 @@ &tdm_ext { > &gmac0 { > phy-handle = <&phy0>; > phy-mode = "rgmii-id"; > + phy-supply = <&vdd33_io>; > status = "okay"; > > mdio { > @@ -117,6 +118,7 @@ phy0: ethernet-phy@0 { > &gmac1 { > phy-handle = <&phy1>; > phy-mode = "rgmii-id"; > + phy-supply = <&vdd33_io>; > status = "okay"; > > mdio { > @@ -182,6 +184,13 @@ vdd_cpu: dcdc2 { > regulator-name = "vdd-cpu"; > }; > > + vdd33_io: dcdc6 { > + regulator-boot-on; > + regulator-min-microvolt = <3300000>; > + regulator-max-microvolt = <3300000>; > + regulator-name = "vdd33_io"; > + }; > + > emmc_vdd: aldo4 { > regulator-boot-on; > regulator-always-on; > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > index 9289bb87c3e3..2ce349421981 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > > #include "stmmac_platform.h" > > @@ -97,6 +98,7 @@ static int starfive_dwmac_probe(struct platform_device *pdev) > struct plat_stmmacenet_data *plat_dat; > struct stmmac_resources stmmac_res; > struct starfive_dwmac *dwmac; > + struct regulator *reg_phy; > struct clk *clk_gtx; > int err; > > @@ -124,6 +126,11 @@ static int starfive_dwmac_probe(struct > platform_device *pdev) > return dev_err_probe(&pdev->dev, PTR_ERR(clk_gtx), > "error getting gtx clock\n"); > > + reg_phy = devm_regulator_get_enable_optional(&pdev->dev, "phy"); > + if (IS_ERR(reg_phy)) > + return dev_err_probe(&pdev->dev, PTR_ERR(reg_phy), > + "error getting phy regulator\n"); > + > /* Generally, the rgmii_tx clock is provided by the internal clock, > * which needs to match the corresponding clock frequency according > * to different speeds. If the rgmii_tx clock is provided by the