From patchwork Wed Dec 19 17:19:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13663 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 61DB223E2D for ; Wed, 19 Dec 2012 17:19:59 +0000 (UTC) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by fiordland.canonical.com (Postfix) with ESMTP id E637FA18DAF for ; Wed, 19 Dec 2012 17:19:58 +0000 (UTC) Received: by mail-ie0-f175.google.com with SMTP id qd14so3154780ieb.34 for ; Wed, 19 Dec 2012 09:19:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=chfMuiTVjxqCK4Hygbsjf6KGUIeHjPv8ls7X7IrMQIA=; b=jvNOJu7RDi/gX4thNQJBLMlTd0a/ifNYGJkpaTuPftoCx5GY/HM8FX4qkqDcaL/FtD VTaJM5o6OeeLmjEIMFjFldvuNAqoKtKq7FDAjp9UB7fnaqUB06adEPBBzehe/agGfqsH V7p2+jtrp+mc6HRPF1tC5xINsXcWsx9/nbZHDuYHsFnmb50fIJTrUcmTGjuyH8zzf42a v6Ga8iRP/XuOJQlgYMDrHqG2DTh7JlnrYKkIWNcFTNqe3dwUDnIz2L2+1fKhaHho4FLX NdCN/lKsOtFV4UCusLRLt3QyZgB0JWm2k7Hwv9cccKvKHgdAuSwY4dCCvvKkEYn4Uy8z 0jIQ== X-Received: by 10.50.53.175 with SMTP id c15mr2887918igp.106.1355937598180; Wed, 19 Dec 2012 09:19:58 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.115 with SMTP id m19csp251272igt; Wed, 19 Dec 2012 09:19:57 -0800 (PST) X-Received: by 10.180.79.37 with SMTP id g5mr12646655wix.8.1355937597003; Wed, 19 Dec 2012 09:19:57 -0800 (PST) Received: from mail-we0-f176.google.com (mail-we0-f176.google.com [74.125.82.176]) by mx.google.com with ESMTPS id b18si9255617wjz.3.2012.12.19.09.19.56 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Dec 2012 09:19:57 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.176 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.176; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.176 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f176.google.com with SMTP id r5so1079038wey.7 for ; Wed, 19 Dec 2012 09:19:56 -0800 (PST) X-Received: by 10.180.95.228 with SMTP id dn4mr12523158wib.16.1355937596470; Wed, 19 Dec 2012 09:19:56 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id i2sm21415170wiw.3.2012.12.19.09.19.55 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Dec 2012 09:19:55 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Steve Glendinning , netdev@vger.kernel.org Subject: [PATCH 4/4] net/smsc911x: Provide common clock functionality Date: Wed, 19 Dec 2012 17:19:47 +0000 Message-Id: <1355937587-31730-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1355937587-31730-1-git-send-email-lee.jones@linaro.org> References: <1355937587-31730-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQma0+pQWZehX3DWcX+gxTW40dUiDlbwdAofkP7/kGOojAABLDu3hLNhjzr2LCjZe4wL48gp Some platforms provide clocks which require enabling before the SMSC911x chip will power on. This patch uses the new common clk framework to do just that. If no clock is provided, it will just be ignored and the driver will continue to assume that no clock is required for the chip to run successfully. Cc: Steve Glendinning Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones --- drivers/net/ethernet/smsc/smsc911x.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 4616bf2..f6196cd 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -33,6 +33,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -144,6 +145,9 @@ struct smsc911x_data { /* regulators */ struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES]; + + /* clock */ + struct clk *clk; }; /* Easy access to information */ @@ -369,7 +373,7 @@ out: } /* - * enable resources, currently just regulators. + * enable regulator and clock resources. */ static int smsc911x_enable_resources(struct platform_device *pdev) { @@ -382,6 +386,13 @@ static int smsc911x_enable_resources(struct platform_device *pdev) if (ret) netdev_err(ndev, "failed to enable regulators %d\n", ret); + + if (pdata->clk) { + ret = clk_prepare_enable(pdata->clk); + if (ret < 0) + netdev_err(ndev, "failed to enable clock %d\n", ret); + } + return ret; } @@ -396,6 +407,10 @@ static int smsc911x_disable_resources(struct platform_device *pdev) ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies), pdata->supplies); + + if (pdata->clk) + clk_disable_unprepare(pdata->clk); + return ret; } @@ -421,6 +436,14 @@ static int smsc911x_request_resources(struct platform_device *pdev) if (ret) netdev_err(ndev, "couldn't get regulators %d\n", ret); + + /* Request clock */ + pdata->clk = clk_get(&pdev->dev, NULL); + if (IS_ERR(pdata->clk)) { + netdev_warn(ndev, "couldn't get clock %d\n", PTR_ERR(pdata->clk)); + pdata->clk = NULL; + } + return ret; } @@ -436,6 +459,12 @@ static void smsc911x_free_resources(struct platform_device *pdev) /* Free regulators */ regulator_bulk_free(ARRAY_SIZE(pdata->supplies), pdata->supplies); + + /* Free clock */ + if (pdata->clk) { + clk_put(pdata->clk); + pdata->clk = NULL; + } } /* waits for MAC not busy, with timeout. Only called by smsc911x_mac_read