From patchwork Mon Feb 8 13:55:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4A67C433DB for ; Mon, 8 Feb 2021 13:57:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FFB564D9F for ; Mon, 8 Feb 2021 13:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231646AbhBHN5H (ORCPT ); Mon, 8 Feb 2021 08:57:07 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:56764 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbhBHN46 (ORCPT ); Mon, 8 Feb 2021 08:56:58 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , , Rob Herring Subject: [PATCH v2 02/24] dt-bindings: net: dwmac: Extend number of PBL values Date: Mon, 8 Feb 2021 16:55:46 +0300 Message-ID: <20210208135609.7685-3-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org In accordance with [1] the permitted PBL values can be set as one of [1, 2, 4, 8, 16, 32]. The rest of the values result in undefined behavior. At the same time some of the permitted values can be also invalid depending on the controller FIFOs size and the data bus width. Due to having too many variables all the possible PBL property constraints can't be implemented in the bindings schema, let's extend the set of permitted PBL values to be as much as the configuration register supports leaving the undefined behaviour cases for developers to handle. [1] DesignWare Cores Ethernet MAC Universal Databook, Revision 3.73a, October 2013, p. 380. Signed-off-by: Serge Semin Reviewed-by: Rob Herring Changelog v2: - Use correct syntax of the JSON pointers, so the later would begin with a '/' after the '#'. --- Documentation/devicetree/bindings/net/snps,dwmac.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 40a002770441..cb68a8dcafd7 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -267,23 +267,26 @@ properties: snps,pbl: description: - Programmable Burst Length (tx and rx) + Programmable Burst Length (tx and rx). Note some of these values + can be still invalid due to HW limitations connected with the data + bus width and the FIFOs depth, so a total length of a single DMA + burst shouldn't exceed half the FIFO depth. $ref: /schemas/types.yaml#/definitions/uint32 - enum: [2, 4, 8] + enum: [1, 2, 4, 8, 16, 32] snps,txpbl: description: Tx Programmable Burst Length. If set, DMA tx will use this value rather than snps,pbl. $ref: /schemas/types.yaml#/definitions/uint32 - enum: [2, 4, 8] + enum: [1, 2, 4, 8, 16, 32] snps,rxpbl: description: Rx Programmable Burst Length. If set, DMA rx will use this value rather than snps,pbl. $ref: /schemas/types.yaml#/definitions/uint32 - enum: [2, 4, 8] + enum: [1, 2, 4, 8, 16, 32] snps,no-pbl-x8: $ref: /schemas/types.yaml#/definitions/flag From patchwork Mon Feb 8 13:55:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34B6DC433E9 for ; Mon, 8 Feb 2021 13:57:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0273364E50 for ; Mon, 8 Feb 2021 13:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231825AbhBHN5P (ORCPT ); Mon, 8 Feb 2021 08:57:15 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:56784 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbhBHN5B (ORCPT ); Mon, 8 Feb 2021 08:57:01 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , Subject: [PATCH v2 03/24] dt-bindings: net: dwmac: Fix the TSO property declaration Date: Mon, 8 Feb 2021 16:55:47 +0300 Message-ID: <20210208135609.7685-4-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Indeed the STMMAC driver doesn't take the vendor-specific compatible string into account to parse the "snps,tso" boolean property. It just makes sure the node is compatible with DW MAC 4.x, 5.x and DW xGMAC IP-cores. The original allwinner sunXi bindings file also didn't have the TSO-related property declared. Taking all of that into account fix the conditional statement so the TSO-property would be evaluated for the compatibles having the corresponding IP-core version. While at it move the whole allOf-block from the tail of the binding file to the head of it, as it's normally done in the most of the DT schemas. Signed-off-by: Serge Semin Reviewed-by: Rob Herring --- Note this won't break the bindings description, since the "snps,tso" property isn't parsed by the Allwinner SunX GMAC glue driver, but only by the generic platform DT-parser. Changelog v2: - Use correct syntax of the JSON pointers, so the later would begin with a '/' after the '#'. --- .../devicetree/bindings/net/snps,dwmac.yaml | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index cb68a8dcafd7..03d58bf9965f 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -37,6 +37,30 @@ select: required: - compatible +allOf: + - $ref: "ethernet-controller.yaml#" + - if: + properties: + compatible: + contains: + enum: + - snps,dwmac-4.00 + - snps,dwmac-4.10a + - snps,dwmac-4.20a + - snps,dwmac-5.10a + - snps,dwxgmac + - snps,dwxgmac-2.10 + + required: + - compatible + then: + properties: + snps,tso: + $ref: /schemas/types.yaml#/definitions/flag + description: + Enables the TSO feature otherwise it will be managed by + MAC HW capability register. + properties: # We need to include all the compatibles from schemas that will @@ -317,34 +341,6 @@ dependencies: snps,reset-active-low: ["snps,reset-gpio"] snps,reset-delay-us: ["snps,reset-gpio"] -allOf: - - $ref: "ethernet-controller.yaml#" - - if: - properties: - compatible: - contains: - enum: - - allwinner,sun7i-a20-gmac - - allwinner,sun8i-a83t-emac - - allwinner,sun8i-h3-emac - - allwinner,sun8i-r40-emac - - allwinner,sun8i-v3s-emac - - allwinner,sun50i-a64-emac - - snps,dwmac-4.00 - - snps,dwmac-4.10a - - snps,dwmac-4.20a - - snps,dwxgmac - - snps,dwxgmac-2.10 - - st,spear600-gmac - - then: - properties: - snps,tso: - $ref: /schemas/types.yaml#/definitions/flag - description: - Enables the TSO feature otherwise it will be managed by - MAC HW capability register. - additionalProperties: true examples: From patchwork Mon Feb 8 13:55:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67E29C433DB for ; Mon, 8 Feb 2021 13:58:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 255B964E16 for ; Mon, 8 Feb 2021 13:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231175AbhBHN6t (ORCPT ); Mon, 8 Feb 2021 08:58:49 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57062 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbhBHN5p (ORCPT ); Mon, 8 Feb 2021 08:57:45 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , , Rob Herring Subject: [PATCH v2 05/24] dt-bindings: net: dwmac: Elaborate stmmaceth/pclk description Date: Mon, 8 Feb 2021 16:55:49 +0300 Message-ID: <20210208135609.7685-6-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Current clocks description doesn't provide a comprehensive notion about what "stmmaceth" and "pclk" actually represent from the IP-core manual point of view. The bindings file states: stmmaceth - "GMAC main clock", apb - "Peripheral registers interface clock". It isn't that easy to understand what they actually mean especially seeing the DW *MAC manual operates with clock definitions like Application, System, Host, CSR, Transmit, Receive, etc clocks. Moreover the clocks usage in the driver doesn't shade a full light on their essence. What inferred from there is that the "stmmaceth" name has been assigned to the common clock, which feeds both system and CSR interfaces. But what about "apb"? The bindings defines it as the clock for "peripheral registers interface". So it's close to the CSR clock in the IP-core manual notation. If so then when "apb" clock is specified aside with the "stmmaceth", it represents a case when the DW *MAC is synthesized with CSR_SLV_CLK=y (separate system and CSR clocks). But even though the "apb" clock is requested in the MAC driver, the driver doesn't actually use it as a separate CSR clock where the IP-core manual requires. All of that makes me thinking that the case of separate system and CSR clocks isn't correctly implemented in the driver. Let's start with elaborating the clocks description so anyone reading the DW *MAC bindings file would understand that "stmmaceth" is the system clock and "pclk" is actually the CSR clock. Indeed in accordance with sheets depicted in [1]: system/application clock can be either of: hclk_i, aclk_i, clk_app_i; CSR clock can be either of: hclk_i, aclk_i, clk_app_i, clk_csr_i. (Most likely the similar definitions present in the others IP-core manuals.) So the CSR clock can be tied to the application clock considering the later as the main clock, but not the other way around. In case if there is only "stmmaceth" clock specified in a DT node, then it will be considered as a source of clocks for both application and CSR. But if "pclk" is also specified in the list of the device clocks, then it will be perceived as the separate CSR clock. [1] DesignWare Cores Ethernet MAC Universal Databook, Revision 3.73a, October 2013, p. 564. Signed-off-by: Serge Semin Reviewed-by: Rob Herring --- .../devicetree/bindings/net/snps,dwmac.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 4dda9ffa822c..21e53427551c 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -116,8 +116,16 @@ properties: maxItems: 5 additionalItems: true items: - - description: GMAC main clock - - description: Peripheral registers interface clock + - description: + GMAC main clock, also called as system/application clock. + This clock is used to provide a periodic signal for the DMA/MTL + interface and optionally for CSR, if the later isn't separately + clocked. + - description: + Peripheral registers interface clock, also called as CSR clock. + MCI, CSR and SMA interfaces run on this clock. If it's omitted, + the CSR interfaces are considered as synchronous to the system + clock domain. - description: PTP reference clock. This clock is used for programming the Timestamp Addend Register. If not passed then the system From patchwork Mon Feb 8 13:55:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A702C433E0 for ; Mon, 8 Feb 2021 13:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05EB464E16 for ; Mon, 8 Feb 2021 13:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232132AbhBHN65 (ORCPT ); Mon, 8 Feb 2021 08:58:57 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57070 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbhBHN5r (ORCPT ); Mon, 8 Feb 2021 08:57:47 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 10/24] net: stmmac: dwmac-sti: Cleanup STMMAC DT-config in remove cb Date: Mon, 8 Feb 2021 16:55:54 +0300 Message-ID: <20210208135609.7685-11-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The stmmac_remove_config_dt() method needs to be called on the device remove procedure otherwise for at least some of device-nodes will be left requested. Fixes: d2ed0a7755fe ("net: ethernet: stmmac: fix of-node and fixed-link-phydev leaks") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c index e1b63df6f96f..3454c5eff822 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c @@ -370,11 +370,14 @@ static int sti_dwmac_probe(struct platform_device *pdev) static int sti_dwmac_remove(struct platform_device *pdev) { + struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); int ret = stmmac_dvr_remove(&pdev->dev); clk_disable_unprepare(dwmac->clk); + stmmac_remove_config_dt(pdev, priv->plat); + return ret; } From patchwork Mon Feb 8 13:55:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 099EEC433E6 for ; Mon, 8 Feb 2021 13:59:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCA9E64E16 for ; Mon, 8 Feb 2021 13:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232181AbhBHN7O (ORCPT ); Mon, 8 Feb 2021 08:59:14 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57076 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbhBHN5r (ORCPT ); Mon, 8 Feb 2021 08:57:47 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 11/24] net: stmmac: dwmac-stm32: Cleanup STMMAC DT-config in remove cb Date: Mon, 8 Feb 2021 16:55:55 +0300 Message-ID: <20210208135609.7685-12-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The stmmac_remove_config_dt() method needs to be called on the device remove procedure otherwise for at least some of device-nodes will be left requested. Fixes: d2ed0a7755fe ("net: ethernet: stmmac: fix of-node and fixed-link-phydev leaks") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c index 5d4df4c5254e..b45aab38c7b0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c @@ -426,6 +426,8 @@ static int stm32_dwmac_remove(struct platform_device *pdev) stm32_dwmac_clk_disable(priv->plat->bsp_priv); + stmmac_remove_config_dt(pdev, priv->plat); + if (dwmac->irq_pwr_wakeup >= 0) { dev_pm_clear_wake_irq(&pdev->dev); device_init_wakeup(&pdev->dev, false); From patchwork Mon Feb 8 13:55:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CE6CC43381 for ; Mon, 8 Feb 2021 13:59:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2547B64E16 for ; Mon, 8 Feb 2021 13:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232209AbhBHN7T (ORCPT ); Mon, 8 Feb 2021 08:59:19 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57074 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231876AbhBHN5s (ORCPT ); Mon, 8 Feb 2021 08:57:48 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 12/24] net: stmmac: Directly call reverse methods in stmmac_probe_config_dt() Date: Mon, 8 Feb 2021 16:55:56 +0300 Message-ID: <20210208135609.7685-13-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Calling an antagonistic method from the corresponding protagonist isn't good from maintainability point of view, since prevents us from directly adding a functionality in the later, which needs to be reverted in the former. Since that's what we are about to do in order to fix the commit 573c0b9c4e0 ("stmmac: move stmmac_clk, pclk, clk_ptp_ref and stmmac_rst to platform structure"), let's replace the stmmac_remove_config_dt() method invocation in stmmac_probe_config_dt() with direct reversal procedures. Fixes: f573c0b9c4e0 ("stmmac: move stmmac_clk, pclk, clk_ptp_ref and stmmac_rst to platform structure") Signed-off-by: Serge Semin --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 1815fe36b62f..c9feac70ca77 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -402,7 +402,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) struct device_node *np = pdev->dev.of_node; struct plat_stmmacenet_data *plat; struct stmmac_dma_cfg *dma_cfg; - void *ret; int rc; plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); @@ -458,7 +457,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) /* To Configure PHY by using all device-tree supported properties */ rc = stmmac_dt_phy(plat, np, &pdev->dev); if (rc) - return ERR_PTR(rc); + goto error_dt_phy_parse; of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); @@ -536,8 +535,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), GFP_KERNEL); if (!dma_cfg) { - stmmac_remove_config_dt(pdev, plat); - return ERR_PTR(-ENOMEM); + rc = -ENOMEM; + goto error_dma_cfg_alloc; } plat->dma_cfg = dma_cfg; @@ -564,10 +563,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->axi = stmmac_axi_setup(pdev); rc = stmmac_mtl_setup(pdev, plat); - if (rc) { - stmmac_remove_config_dt(pdev, plat); - return ERR_PTR(rc); - } + if (rc) + goto error_dma_cfg_alloc; /* clock setup */ if (!of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) { @@ -582,7 +579,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); if (IS_ERR(plat->pclk)) { - ret = plat->pclk; + rc = PTR_ERR(plat->pclk); goto error_pclk_get; } clk_prepare_enable(plat->pclk); @@ -601,7 +598,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME); if (IS_ERR(plat->stmmac_rst)) { - ret = plat->stmmac_rst; + rc = PTR_ERR(plat->stmmac_rst); goto error_hw_init; } @@ -611,8 +608,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) clk_disable_unprepare(plat->pclk); error_pclk_get: clk_disable_unprepare(plat->stmmac_clk); +error_dma_cfg_alloc: + of_node_put(plat->mdio_node); +error_dt_phy_parse: + of_node_put(plat->phy_node); - return ret; + return ERR_PTR(rc); } /** From patchwork Mon Feb 8 13:55:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1245C433E0 for ; Mon, 8 Feb 2021 13:59:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DCBC64E50 for ; Mon, 8 Feb 2021 13:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbhBHN7G (ORCPT ); Mon, 8 Feb 2021 08:59:06 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57080 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231882AbhBHN5r (ORCPT ); Mon, 8 Feb 2021 08:57:47 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 14/24] net: stmmac: Use optional clock request method to get stmmaceth Date: Mon, 8 Feb 2021 16:55:58 +0300 Message-ID: <20210208135609.7685-15-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The "stmmaceth" clock is expected to be optional by the current driver design, but there are several problems in the implementation. First if the clock is specified, but failed to be requested due to an internal error or due to not being ready yet for configuration, then the DT-probe procedure will just proceed with further initializations. It is erroneous in both cases. Secondly if we'd use the clock API, which expect the clock being optional we wouldn't have needed to avoid the clock request procedure for the "snps,dwc-qos-ethernet-4.10"-compatible devices to prevent the error message from being printed. All of that can be fixed by using the devm_clk_get_optional() method here provided by the common clock framework. Signed-off-by: Serge Semin --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index ff66c470f07f..a66467baf30a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -566,16 +566,17 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) if (rc) goto error_dma_cfg_alloc; - /* clock setup */ - if (!of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) { - plat->stmmac_clk = devm_clk_get(&pdev->dev, - STMMAC_RESOURCE_NAME); - if (IS_ERR(plat->stmmac_clk)) { - dev_warn(&pdev->dev, "Cannot get CSR clock\n"); - plat->stmmac_clk = NULL; - } - clk_prepare_enable(plat->stmmac_clk); + /* All clocks are optional since the sub-drivers may use the platform + * clocks pointers to preserve their own clock-descriptors. + */ + plat->stmmac_clk = devm_clk_get_optional(&pdev->dev, + STMMAC_RESOURCE_NAME); + if (IS_ERR(plat->stmmac_clk)) { + rc = PTR_ERR(plat->stmmac_clk); + dev_err_probe(&pdev->dev, rc, "Cannot get CSR clock\n"); + goto error_dma_cfg_alloc; } + clk_prepare_enable(plat->stmmac_clk); plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); if (IS_ERR(plat->pclk)) { From patchwork Mon Feb 8 13:56:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A097C433E6 for ; Mon, 8 Feb 2021 14:00:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BA0E64E15 for ; Mon, 8 Feb 2021 14:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232254AbhBHN7j (ORCPT ); Mon, 8 Feb 2021 08:59:39 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57062 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbhBHN6I (ORCPT ); Mon, 8 Feb 2021 08:58:08 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin , Jisheng Zhang CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 16/24] net: stmmac: Use optional reset control API to work with stmmaceth Date: Mon, 8 Feb 2021 16:56:00 +0300 Message-ID: <20210208135609.7685-17-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Since commit bb3222f71b57 ("net: stmmac: platform: use optional clk/reset get APIs") a manual implementation of the optional device reset control functionality has been replaced with using the devm_reset_control_get_optional() method. But for some reason the optional reset control handler usage hasn't been fixed and preserved the NULL-checking statements. There is no need in that in order to perform the reset control assertion/deassertion because the passed NULL will be considered by the reset framework as absent optional reset control handler anyway. Fixes: bb3222f71b57 ("net: stmmac: platform: use optional clk/reset get APIs") Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4f1bf8f6538b..a8dec219c295 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -4935,15 +4935,13 @@ int stmmac_dvr_probe(struct device *device, if ((phyaddr >= 0) && (phyaddr <= 31)) priv->plat->phy_addr = phyaddr; - if (priv->plat->stmmac_rst) { - ret = reset_control_assert(priv->plat->stmmac_rst); - reset_control_deassert(priv->plat->stmmac_rst); - /* Some reset controllers have only reset callback instead of - * assert + deassert callbacks pair. - */ - if (ret == -ENOTSUPP) - reset_control_reset(priv->plat->stmmac_rst); - } + ret = reset_control_assert(priv->plat->stmmac_rst); + reset_control_deassert(priv->plat->stmmac_rst); + /* Some reset controllers have only reset callback instead of + * assert + deassert callbacks pair. + */ + if (ret == -ENOTSUPP) + reset_control_reset(priv->plat->stmmac_rst); /* Init MAC and get the capabilities */ ret = stmmac_hw_init(priv); @@ -5155,8 +5153,7 @@ int stmmac_dvr_remove(struct device *dev) stmmac_exit_fs(ndev); #endif phylink_destroy(priv->phylink); - if (priv->plat->stmmac_rst) - reset_control_assert(priv->plat->stmmac_rst); + reset_control_assert(priv->plat->stmmac_rst); if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); From patchwork Mon Feb 8 13:56:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12773C433DB for ; Mon, 8 Feb 2021 14:01:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9FF964E6C for ; Mon, 8 Feb 2021 14:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbhBHOAu (ORCPT ); Mon, 8 Feb 2021 09:00:50 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57084 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbhBHN6d (ORCPT ); Mon, 8 Feb 2021 08:58:33 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 17/24] net: stmmac: dwc-qos: Cleanup STMMAC platform data clock pointers Date: Mon, 8 Feb 2021 16:56:01 +0300 Message-ID: <20210208135609.7685-18-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The pointers need to be nullified otherwise the stmmac_remove_config_dt() method called after them being initialized will disable the clocks. That then will cause a WARN() backtrace being printed since the clocks would be also disabled in the locally defined remove method. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index 27254b27d7ed..20b3696fb776 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -123,39 +123,46 @@ static int dwc_qos_probe(struct platform_device *pdev, struct plat_stmmacenet_data *plat_dat, struct stmmac_resources *stmmac_res) { + struct clk *clk; int err; - plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk"); - if (IS_ERR(plat_dat->stmmac_clk)) { + clk = devm_clk_get(&pdev->dev, "apb_pclk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "apb_pclk clock not found.\n"); - return PTR_ERR(plat_dat->stmmac_clk); + return PTR_ERR(clk); } - err = clk_prepare_enable(plat_dat->stmmac_clk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable apb_pclk clock: %d\n", err); return err; } - plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk"); - if (IS_ERR(plat_dat->pclk)) { + plat_dat->stmmac_clk = clk; + + clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); - err = PTR_ERR(plat_dat->pclk); + err = PTR_ERR(clk); goto disable; } - err = clk_prepare_enable(plat_dat->pclk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n", err); goto disable; } + plat_dat->pclk = clk; + return 0; disable: clk_disable_unprepare(plat_dat->stmmac_clk); + plat_dat->stmmac_clk = NULL; + return err; } @@ -164,8 +171,15 @@ static int dwc_qos_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct stmmac_priv *priv = netdev_priv(ndev); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ clk_disable_unprepare(priv->plat->pclk); + priv->plat->pclk = NULL; + clk_disable_unprepare(priv->plat->stmmac_clk); + priv->plat->stmmac_clk = NULL; return 0; } @@ -301,12 +315,12 @@ static int tegra_eqos_probe(struct platform_device *pdev, goto disable_master; } - data->stmmac_clk = eqos->clk_slave; - err = clk_prepare_enable(eqos->clk_slave); if (err < 0) goto disable_master; + data->stmmac_clk = eqos->clk_slave; + eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); if (IS_ERR(eqos->clk_rx)) { err = PTR_ERR(eqos->clk_rx); @@ -377,6 +391,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, clk_disable_unprepare(eqos->clk_rx); disable_slave: clk_disable_unprepare(eqos->clk_slave); + data->stmmac_clk = NULL; disable_master: clk_disable_unprepare(eqos->clk_master); error: @@ -385,6 +400,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, static int tegra_eqos_remove(struct platform_device *pdev) { + struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); struct tegra_eqos *eqos = get_stmmac_bsp_priv(&pdev->dev); reset_control_assert(eqos->rst); @@ -394,6 +410,12 @@ static int tegra_eqos_remove(struct platform_device *pdev) clk_disable_unprepare(eqos->clk_slave); clk_disable_unprepare(eqos->clk_master); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ + priv->plat->stmmac_clk = NULL; + return 0; } From patchwork Mon Feb 8 13:56:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE17CC433E0 for ; Mon, 8 Feb 2021 14:01:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A91664E6C for ; Mon, 8 Feb 2021 14:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232003AbhBHOBL (ORCPT ); Mon, 8 Feb 2021 09:01:11 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57088 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231625AbhBHN6j (ORCPT ); Mon, 8 Feb 2021 08:58:39 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 20/24] net: stmmac: dwc-qos: Discard Tx/Rx clocks request Date: Mon, 8 Feb 2021 16:56:04 +0300 Message-ID: <20210208135609.7685-21-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Since the Tx/Rx clocks with the same names are now requested and enabled/disabled in the STMMAC DT-based platform config method, there is no need in duplicating the same procedures in the DWC QoS Eth sub-driver. Discard it then, but make sure the denoted clocks have been specified for the platform. Note also the deprecated clock "phy_ref_clk" have been defined as the Tx clock in the DWC QoS Eth bindings. Let's use a pointer to the Tx clock defined in the platform data then instead of the unrelated pclk pointer. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index b71f0c3faebe..f315ca395e12 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -31,8 +31,6 @@ struct tegra_eqos { struct reset_control *rst; struct clk *clk_master; struct clk *clk_slave; - struct clk *clk_tx; - struct clk *clk_rx; struct gpio_desc *reset; }; @@ -155,7 +153,7 @@ static int dwc_qos_probe(struct platform_device *pdev, goto disable; } - plat_dat->pclk = clk; + plat_dat->tx_clk = clk; return 0; @@ -175,8 +173,8 @@ static int dwc_qos_remove(struct platform_device *pdev) * data so the stmmac_remove_config_dt() method wouldn't have disabled * the clocks too. */ - clk_disable_unprepare(priv->plat->pclk); - priv->plat->pclk = NULL; + clk_disable_unprepare(priv->plat->tx_clk); + priv->plat->tx_clk = NULL; clk_disable_unprepare(priv->plat->stmmac_clk); priv->plat->stmmac_clk = NULL; @@ -197,6 +195,7 @@ static int dwc_qos_remove(struct platform_device *pdev) static void tegra_eqos_fix_speed(void *priv, unsigned int speed) { struct tegra_eqos *eqos = priv; + struct stmmac_priv *sp = netdev_priv(dev_get_drvdata(eqos->dev)); unsigned long rate = 125000000; bool needs_calibration = false; u32 value; @@ -262,7 +261,7 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed) writel(value, eqos->regs + AUTO_CAL_CONFIG); } - err = clk_set_rate(eqos->clk_tx, rate); + err = clk_set_rate(sp->plat->tx_clk, rate); if (err < 0) dev_err(eqos->dev, "failed to set TX rate: %d\n", err); } @@ -299,6 +298,11 @@ static int tegra_eqos_probe(struct platform_device *pdev, if (!is_of_node(dev->fwnode)) goto bypass_clk_reset_gpio; + if (!data->tx_clk || !data->rx_clk) { + err = -EINVAL; + goto error; + } + eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus"); if (IS_ERR(eqos->clk_master)) { err = PTR_ERR(eqos->clk_master); @@ -321,30 +325,10 @@ static int tegra_eqos_probe(struct platform_device *pdev, data->stmmac_clk = eqos->clk_slave; - eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); - if (IS_ERR(eqos->clk_rx)) { - err = PTR_ERR(eqos->clk_rx); - goto disable_slave; - } - - err = clk_prepare_enable(eqos->clk_rx); - if (err < 0) - goto disable_slave; - - eqos->clk_tx = devm_clk_get(&pdev->dev, "tx"); - if (IS_ERR(eqos->clk_tx)) { - err = PTR_ERR(eqos->clk_tx); - goto disable_rx; - } - - err = clk_prepare_enable(eqos->clk_tx); - if (err < 0) - goto disable_rx; - eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); if (IS_ERR(eqos->reset)) { err = PTR_ERR(eqos->reset); - goto disable_tx; + goto disable_slave; } usleep_range(2000, 4000); @@ -385,10 +369,6 @@ static int tegra_eqos_probe(struct platform_device *pdev, reset_control_assert(eqos->rst); reset_phy: gpiod_set_value(eqos->reset, 1); -disable_tx: - clk_disable_unprepare(eqos->clk_tx); -disable_rx: - clk_disable_unprepare(eqos->clk_rx); disable_slave: clk_disable_unprepare(eqos->clk_slave); data->stmmac_clk = NULL; @@ -405,8 +385,6 @@ static int tegra_eqos_remove(struct platform_device *pdev) reset_control_assert(eqos->rst); gpiod_set_value(eqos->reset, 1); - clk_disable_unprepare(eqos->clk_tx); - clk_disable_unprepare(eqos->clk_rx); clk_disable_unprepare(eqos->clk_slave); clk_disable_unprepare(eqos->clk_master); From patchwork Mon Feb 8 13:56:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3C65C433DB for ; Mon, 8 Feb 2021 14:00:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6356964E16 for ; Mon, 8 Feb 2021 14:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbhBHOA2 (ORCPT ); Mon, 8 Feb 2021 09:00:28 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57076 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbhBHN6N (ORCPT ); Mon, 8 Feb 2021 08:58:13 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 21/24] net: stmmac: dwmac-imx: Discard Tx clock request Date: Mon, 8 Feb 2021 16:56:05 +0300 Message-ID: <20210208135609.7685-22-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Since the Tx clock is now requested and enabled/disabled in the STMMAC DT-based platform config method, there is no need in duplicating the same procedures in the DW MAC iMX sub-driver. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index 223f69da7e95..8b2c7f1ba745 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -40,7 +40,6 @@ struct imx_dwmac_ops { struct imx_priv_data { struct device *dev; - struct clk *clk_tx; struct clk *clk_mem; struct regmap *intf_regmap; u32 intf_reg_off; @@ -104,12 +103,6 @@ static int imx_dwmac_init(struct platform_device *pdev, void *priv) return ret; } - ret = clk_prepare_enable(dwmac->clk_tx); - if (ret) { - dev_err(&pdev->dev, "tx clock enable failed\n"); - goto clk_tx_en_failed; - } - if (dwmac->ops->set_intf_mode) { ret = dwmac->ops->set_intf_mode(plat_dat); if (ret) @@ -119,8 +112,6 @@ static int imx_dwmac_init(struct platform_device *pdev, void *priv) return 0; intf_mode_failed: - clk_disable_unprepare(dwmac->clk_tx); -clk_tx_en_failed: clk_disable_unprepare(dwmac->clk_mem); return ret; } @@ -129,7 +120,6 @@ static void imx_dwmac_exit(struct platform_device *pdev, void *priv) { struct imx_priv_data *dwmac = priv; - clk_disable_unprepare(dwmac->clk_tx); clk_disable_unprepare(dwmac->clk_mem); } @@ -162,7 +152,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed) return; } - err = clk_set_rate(dwmac->clk_tx, rate); + err = clk_set_rate(plat_dat->tx_clk, rate); if (err < 0) dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); } @@ -176,10 +166,9 @@ imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev) if (of_get_property(np, "snps,rmii_refclk_ext", NULL)) dwmac->rmii_refclk_ext = true; - dwmac->clk_tx = devm_clk_get(dev, "tx"); - if (IS_ERR(dwmac->clk_tx)) { - dev_err(dev, "failed to get tx clock\n"); - return PTR_ERR(dwmac->clk_tx); + if (!dwmac->plat_dat->tx_clk) { + dev_err(dev, "no tx clock found\n"); + return -EINVAL; } dwmac->clk_mem = NULL; @@ -239,6 +228,7 @@ static int imx_dwmac_probe(struct platform_device *pdev) dwmac->ops = data; dwmac->dev = &pdev->dev; + dwmac->plat_dat = plat_dat; ret = imx_dwmac_parse_dt(dwmac, &pdev->dev); if (ret) { @@ -251,7 +241,6 @@ static int imx_dwmac_probe(struct platform_device *pdev) plat_dat->exit = imx_dwmac_exit; plat_dat->fix_mac_speed = imx_dwmac_fix_speed; plat_dat->bsp_priv = dwmac; - dwmac->plat_dat = plat_dat; ret = imx_dwmac_init(pdev, dwmac); if (ret) From patchwork Mon Feb 8 13:56:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E7D5C433DB for ; Mon, 8 Feb 2021 14:00:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA12764E60 for ; Mon, 8 Feb 2021 14:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232283AbhBHN7z (ORCPT ); Mon, 8 Feb 2021 08:59:55 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57068 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbhBHN6K (ORCPT ); Mon, 8 Feb 2021 08:58:10 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 24/24] net: stmmac: dwc-qos: Save master/slave clocks in the plat-data Date: Mon, 8 Feb 2021 16:56:08 +0300 Message-ID: <20210208135609.7685-25-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Currently the "master_bus" clock of the DW QoS Eth controller isn't preserved in the STMMAC platform data, while the "slave_bus" clock is assigned to the stmmaceth clock pointer. It isn't correct from the platform clock bindings point of view. The "stmmaceth" clock is supposed to be the system clock, which is responsible for clocking the DMA transfers from/to the controller FIFOs to/from the system memory and the CSR interface if the later isn't separately clocked. If it's clocked separately then the STMMAC platform code expects to also have "pclk" specified. So in order to have the STMMAC platform data properly initialized we need to set the "master_bus" clock handler to the "stmmaceth" clock pointer, and the "slave_bus" clock handler to the "pclk" clock pointer. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index f315ca395e12..bb2297638805 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -313,6 +313,8 @@ static int tegra_eqos_probe(struct platform_device *pdev, if (err < 0) goto error; + data->stmmac_clk = eqos->clk_master; + eqos->clk_slave = devm_clk_get(&pdev->dev, "slave_bus"); if (IS_ERR(eqos->clk_slave)) { err = PTR_ERR(eqos->clk_slave); @@ -323,7 +325,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, if (err < 0) goto disable_master; - data->stmmac_clk = eqos->clk_slave; + data->pclk = eqos->clk_slave; eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); if (IS_ERR(eqos->reset)) { @@ -371,9 +373,10 @@ static int tegra_eqos_probe(struct platform_device *pdev, gpiod_set_value(eqos->reset, 1); disable_slave: clk_disable_unprepare(eqos->clk_slave); - data->stmmac_clk = NULL; + data->pclk = NULL; disable_master: clk_disable_unprepare(eqos->clk_master); + data->stmmac_clk = NULL; error: return err; } @@ -392,6 +395,7 @@ static int tegra_eqos_remove(struct platform_device *pdev) * data so the stmmac_remove_config_dt() method wouldn't have disabled * the clocks too. */ + priv->plat->pclk = NULL; priv->plat->stmmac_clk = NULL; return 0;