From patchwork Mon Apr 12 13:26:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 12198035 X-Patchwork-Delegate: geert@linux-m68k.org 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 4639BC433ED for ; Mon, 12 Apr 2021 13:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD86F610CA for ; Mon, 12 Apr 2021 13:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237607AbhDLN1C (ORCPT ); Mon, 12 Apr 2021 09:27:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237277AbhDLN1C (ORCPT ); Mon, 12 Apr 2021 09:27:02 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C14BC061574; Mon, 12 Apr 2021 06:26:44 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id l19so7095981ilk.13; Mon, 12 Apr 2021 06:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1aO1TpF9MgF5lN0TP7fat48f1wzPDiMoVBU35EFvOUY=; b=hZbmHOUsxJrApOYlVpHX0NnNIambFgFj57y1C7dMuRwaYhLGhUFJrD1N2JT/A1zCyQ +1zrmVcfQTHu+vU2mW3T7e+sgsjRaVyZURQQF17VB6PmM8kfKumR+2djTtJ6eaWvAZkC K47XC1xFM6kpL/QaiE3Mg0vLA0Uw4ea3h+Whxb19W0tkAhmRYwO+FmKdAgaRXA3ikCZV HpisGjxH5ctqg2YswzNkfktESX8DKW1B8D7fWl+DiH1O4veAYcA5P3z1A3bjDfDc9Ou2 cEdS5s9koHb3VJFvvPMMtf0mjVpAJOcm0CZNYco+j1FkFDl4yt2MC9eYnliKH5JgIR+5 T4lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1aO1TpF9MgF5lN0TP7fat48f1wzPDiMoVBU35EFvOUY=; b=LTZqmEBAXODxOMoxN9ZujR925DuXVg1MvtZRn7cGebLtG16+D2voBf77zoCPU2BxJx dVFwsdaHsP0ZbBQ/PQeJhUbR/q7iSw7J2CN4AhIAFU3yTMv+TlaSlXvEPbxI/EIOBf2V b1NucNt4KYf4POczdwK3ULUqasSBm5DRQ8KGxTsjXolNaNr6jqsJU6JhK4C9Jf6HeeQR k5gWdWbq7Lnlj0wSNadJXfikiL+1xnONIQ2bsOLnrTv/7I3LXKhIb2zWt1MSeO4crTol 35hQzHMIxadljQpiDQak/wAlKzYFfFoVwrTFgY63rzvUQhN36hPakvnDkDsdFf/OowZy 8WyA== X-Gm-Message-State: AOAM532xHFTsAPeWJDGrZBNy/ZUaxLu0b//xCeN+TTq9A4WzGAOxWPm6 QvRpk3tSjzVS8zyIWOUPhkAxbTJTL5lcEQ== X-Google-Smtp-Source: ABdhPJzWPKU50yhJTHZ80V98+NgHmzDKfCtomnXKv0s9HfBWRnZ/62rg7zaVAozcOhTgmrq2vr+z1Q== X-Received: by 2002:a92:5204:: with SMTP id g4mr23487727ilb.84.1618234003269; Mon, 12 Apr 2021 06:26:43 -0700 (PDT) Received: from aford-OptiPlex-7050.logicpd.com ([174.46.170.158]) by smtp.gmail.com with ESMTPSA id x8sm5261118iov.7.2021.04.12.06.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 06:26:42 -0700 (PDT) From: Adam Ford To: netdev@vger.kernel.org Cc: aford@beaconembedded.com, Adam Ford , Sergei Shtylyov , "David S. Miller" , Jakub Kicinski , Rob Herring , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 1/2] dt-bindings: net: renesas,etheravb: Add additional clocks Date: Mon, 12 Apr 2021 08:26:18 -0500 Message-Id: <20210412132619.7896-1-aford173@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The AVB driver assumes there is an external crystal, but it could be clocked by other means. In order to enable a programmable clock, it needs to be added to the clocks list and enabled in the driver. Since there currently only one clock, there is no clock-names list either. Update bindings to add the additional optional clock, and explicitly name both of them. Signed-off-by: Adam Ford Reviewed-by: Geert Uytterhoeven Acked-by: Rob Herring Reviewed-by: Sergei Shtylyov --- V4: No Change V3: No Change V2: No Change diff --git a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml index 91ba96d43c6c..fe72a5598add 100644 --- a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml +++ b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml @@ -50,7 +50,16 @@ properties: interrupt-names: true clocks: - maxItems: 1 + minItems: 1 + maxItems: 2 + items: + - description: AVB functional clock + - description: Optional TXC reference clock + + clock-names: + items: + - const: fck + - const: refclk iommus: maxItems: 1 From patchwork Mon Apr 12 13:26:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 12198037 X-Patchwork-Delegate: geert@linux-m68k.org 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 24B04C433B4 for ; Mon, 12 Apr 2021 13:26:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4A66610CA for ; Mon, 12 Apr 2021 13:26:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241409AbhDLN1E (ORCPT ); Mon, 12 Apr 2021 09:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241174AbhDLN1D (ORCPT ); Mon, 12 Apr 2021 09:27:03 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D0EDC061574; Mon, 12 Apr 2021 06:26:45 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id r5so2797465ilb.2; Mon, 12 Apr 2021 06:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6stQHJumAX9IpA85olnqPlMQgoZlJcV7yJSibxNhYxs=; b=X19LBFEsB1YnZMaWEbOi6vt3YH2OPYgoFt2C4nGduZa3A+Um+0hSqPyzqgAL7ynixu Rf0wz+Y0nyOqBK7YOtPIiDiOTAasprbs0huCE7RoxI7J1kaZTcVFfR7JhnsjcNqWC0xV e4vBcNCUajiqnVILmfZMC3PEZ/h3uoURn7dfxhUme1u71owUli9HJFlnFT/dIhzFRLy2 OOz2rZaLiIiOSSqRtYnWxUFjJ/PKR9dyRwf53wbtyLiT9MFujn/AhhJQUVDX3l/Y7GK2 xe6wG2E2RzplzBmgvl+7khwc4o+69aI0428kt36I3drvK+3+yH4xvk0Wy4FkxCXYaeFz VFAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6stQHJumAX9IpA85olnqPlMQgoZlJcV7yJSibxNhYxs=; b=MrgDC4U+w3niR5W6G7XDGMoLTDGh7zUA8MkIOraAXPY4bXjK+FuehI15Vs2/2Vvm5r t8bAm8LSJzlL7i9OHDHPm9C0/t7Kozm+Uvj1xd1jqADk+0f9U24s6ky/3ybBEk5g5loy 1Nq34+1i+XFh0jxf1yKLASua7/1TB/VZeWFpKtTcLSJPefByTTd7GjKRJXO+E/vYjMLO Lfhtw1R3K2CTABapNbPq9UpGXjWZxBMscwTbTHhzIN6ClFX5R+dX7PgiVvHb+2B0VHJ1 4EghO1cx3vYzRB+F6XLHgK7PoWwitWRbdqWO8w2LJ8D5P2iFyLEeuMUCxGQaapIDDZnL cU+w== X-Gm-Message-State: AOAM533ertiW7CKGfQT9JgPElWEorVUfnEXRRYd/5iQ4UgW0Y5kzokl3 jRAZjmZTQjOfzSSYNNFAH04n8C6xa+EEWg== X-Google-Smtp-Source: ABdhPJxtXtVnD7jBbjK3qjQXDL4WhomCCX93LmqBxwKN1LTRZd4YKlh0yxvMXD26py3wHojzVix+qA== X-Received: by 2002:a92:ca06:: with SMTP id j6mr5323636ils.234.1618234004657; Mon, 12 Apr 2021 06:26:44 -0700 (PDT) Received: from aford-OptiPlex-7050.logicpd.com ([174.46.170.158]) by smtp.gmail.com with ESMTPSA id x8sm5261118iov.7.2021.04.12.06.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 06:26:44 -0700 (PDT) From: Adam Ford To: netdev@vger.kernel.org Cc: aford@beaconembedded.com, Adam Ford , Sergei Shtylyov , "David S. Miller" , Jakub Kicinski , Rob Herring , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 2/2] net: ethernet: ravb: Enable optional refclk Date: Mon, 12 Apr 2021 08:26:19 -0500 Message-Id: <20210412132619.7896-2-aford173@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210412132619.7896-1-aford173@gmail.com> References: <20210412132619.7896-1-aford173@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org For devices that use a programmable clock for the AVB reference clock, the driver may need to enable them. Add code to find the optional clock and enable it when available. Signed-off-by: Adam Ford Reviewed-by: Andrew Lunn Reviewed-by: Geert Uytterhoeven --- V4: Eliminate the NULL check when disabling refclk, and add a line to disable the refclk if there is a failure after it's been initialized. V3: Change 'avb' to 'AVB' Remove unnessary else statement and pointer maniupluation when enabling the refclock. Add disable_unprepare call in remove funtion. V2: The previous patch to fetch the fclk was dropped. In its place is code to enable the refclk diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index cb47e68c1a3e..86a1eb0634e8 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -993,6 +993,7 @@ struct ravb_private { struct platform_device *pdev; void __iomem *addr; struct clk *clk; + struct clk *refclk; struct mdiobb_ctrl mdiobb; u32 num_rx_ring[NUM_RX_QUEUE]; u32 num_tx_ring[NUM_TX_QUEUE]; diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index eb0c03bdb12d..1409ae986aa2 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2148,6 +2148,13 @@ static int ravb_probe(struct platform_device *pdev) goto out_release; } + priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); + if (IS_ERR(priv->refclk)) { + error = PTR_ERR(priv->refclk); + goto out_release; + } + clk_prepare_enable(priv->refclk); + ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); ndev->min_mtu = ETH_MIN_MTU; @@ -2244,6 +2251,7 @@ static int ravb_probe(struct platform_device *pdev) if (chip_id != RCAR_GEN2) ravb_ptp_stop(ndev); out_release: + clk_disable_unprepare(priv->refclk); free_netdev(ndev); pm_runtime_put(&pdev->dev); @@ -2260,6 +2268,8 @@ static int ravb_remove(struct platform_device *pdev) if (priv->chip_id != RCAR_GEN2) ravb_ptp_stop(ndev); + clk_disable_unprepare(priv->refclk); + dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); /* Set reset mode */