From patchwork Thu Apr 11 09:29:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 235944 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 7FF212C0191 for ; Fri, 12 Apr 2013 09:41:49 +1000 (EST) Received: from mail-bk0-x22d.google.com (mail-bk0-x22d.google.com [IPv6:2a00:1450:4008:c01::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2261B2C00D6; Thu, 11 Apr 2013 19:29:48 +1000 (EST) Received: by mail-bk0-f45.google.com with SMTP id j10so697858bkw.32 for ; Thu, 11 Apr 2013 02:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=df+tFT+wg/5xcVWss3cLbjrIIJRdmM8MBp5fZfgV7ms=; b=T3hKmwCJySy4BfOiHDNX9WX2q0zhMu9gSnuVfbDsI5ic8yU49h9ywC19KkDkjJANnT 06Qglo8h+S/N9H1yh5xNWN7Bb+DYSEQA0FPEoRReq0Ys86DgVotBVloSH/v4Q+E0I2g3 9OvN0R5e2N2ToXFVw+aTGBzsHuzFj7jklR2xW2lBRXUWQQqPdZ11HEiKCsvam8MwgIc/ 8CJRJIdEGvgqJsgnhnucJBoHtDUr25ad4NFwNOkhYl212aV84l/2KRG3Hb5yQdFzeSlg GvS8/+ExyizK44gGw8y7OEc/d0AVRCu1Nc0tEzoWpjXN3RaxZVy/mWh/j+hOG53dOREN 5pYA== X-Received: by 10.205.10.10 with SMTP id oy10mr2130615bkb.89.1365672584877; Thu, 11 Apr 2013 02:29:44 -0700 (PDT) Received: from edge.mip.uni-hannover.de (ip195.250.mip.uni-hannover.de. [130.75.250.195]) by mx.google.com with ESMTPS id da16sm1457004bkb.2.2013.04.11.02.29.43 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 02:29:44 -0700 (PDT) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH 1/2] net: mv643xx_eth: add shared clk and cleanup existing clk handling Date: Thu, 11 Apr 2013 11:29:33 +0200 Message-Id: <1365672574-31123-2-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1365672574-31123-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1365672574-31123-1-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailman-Approved-At: Fri, 12 Apr 2013 09:40:38 +1000 Cc: Andrew Lunn , Jason Cooper , Sergei Shtylyov , linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, Rob Herring , Paul Mackerras , Rob Landley , netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Florian Fainelli , Lennert Buytenhek X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This patch adds an optional shared block clock to avoid lockups on clock gated controllers. Besides the new clock, clock handling for existing clocks is cleaned up and moved to devm_clk_get. Device tree binding documentation is updated for the new clocks property. Signed-off-by: Sebastian Hesselbarth --- Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Cc: Lennert Buytenhek Cc: Sebastian Hesselbarth Cc: Andrew Lunn Cc: Jason Cooper Cc: Florian Fainelli Cc: Sergei Shtylyov Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org --- Documentation/devicetree/bindings/marvell.txt | 3 +++ drivers/net/ethernet/marvell/mv643xx_eth.c | 27 ++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt index f1533d9..f7a0da6 100644 --- a/Documentation/devicetree/bindings/marvell.txt +++ b/Documentation/devicetree/bindings/marvell.txt @@ -115,6 +115,9 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd. - compatible : "marvell,mv64360-eth-block" - reg : Offset and length of the register set for this block + Optional properties: + - clocks : Phandle to the clock control device and gate bit + Example Discovery Ethernet block node: ethernet-block@2000 { #address-cells = <1>; diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index aedbd82..bbe6104 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -268,7 +268,7 @@ struct mv643xx_eth_shared_private { int extended_rx_coal_limit; int tx_bw_control; int tx_csum_limit; - + struct clk *clk; }; #define TX_BW_CONTROL_ABSENT 0 @@ -410,9 +410,7 @@ struct mv643xx_eth_private { /* * Hardware-specific parameters. */ -#if defined(CONFIG_HAVE_CLK) struct clk *clk; -#endif unsigned int t_clk; }; @@ -2569,6 +2567,10 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) if (msp->base == NULL) goto out_free; + msp->clk = devm_clk_get(&pdev->dev, NULL); + if (!IS_ERR(msp->clk)) + clk_prepare_enable(msp->clk); + /* * (Re-)program MBUS remapping windows if we are asked to. */ @@ -2595,6 +2597,8 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev) struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev); iounmap(msp->base); + if (!IS_ERR(msp->clk)) + clk_disable_unprepare(msp->clk); kfree(msp); return 0; @@ -2801,13 +2805,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev) * it to override the default. */ mp->t_clk = 133000000; -#if defined(CONFIG_HAVE_CLK) - mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); + mp->clk = devm_clk_get(&pdev->dev, NULL); if (!IS_ERR(mp->clk)) { clk_prepare_enable(mp->clk); mp->t_clk = clk_get_rate(mp->clk); } -#endif + set_params(mp, pd); netif_set_real_num_tx_queues(dev, mp->txq_count); netif_set_real_num_rx_queues(dev, mp->rxq_count); @@ -2889,12 +2892,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev) return 0; out: -#if defined(CONFIG_HAVE_CLK) - if (!IS_ERR(mp->clk)) { + if (!IS_ERR(mp->clk)) clk_disable_unprepare(mp->clk); - clk_put(mp->clk); - } -#endif free_netdev(dev); return err; @@ -2909,12 +2908,8 @@ static int mv643xx_eth_remove(struct platform_device *pdev) phy_detach(mp->phy); cancel_work_sync(&mp->tx_timeout_task); -#if defined(CONFIG_HAVE_CLK) - if (!IS_ERR(mp->clk)) { + if (!IS_ERR(mp->clk)) clk_disable_unprepare(mp->clk); - clk_put(mp->clk); - } -#endif free_netdev(mp->dev);