From patchwork Sat Mar 8 09:29:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 25917 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B4242055F for ; Sat, 8 Mar 2014 09:34:49 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id j17sf19971586oag.2 for ; Sat, 08 Mar 2014 01:34:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=rFluIpQhGMh/AlUtNFKkXJcmkp5rpNBHfXlh597odIM=; b=MKDWsc5u0pVUPFrNhy2Z51HSvQ9mQl3cSAxdupp4qSuA3yPPlEtnRoPS5Iv3JZ1RRi xTRBeiOcCrw0xhkaUztGFD8VkHojsGYg00dtQfDMSKjeEtg/tUkzTZJeuGPLGryLqWbX aTMUwgB/s4meETz3Ol0+pGmfc3UYsouNBx7vDzLxaCk5bJe4TcCQqyZ02SAIejDL0B+J 5G4dzX+vMyY0QU4igAhdVZrODi8fig+gtAefF0k3jy+ySVTurqHBa2PQ9T1qeN7iXh5i N8kKF3l5sC2TTnhe8l22BVv1uVvftc8QY02q4YrBiP45XQkD5pqYvelkpuDHW7cNBzm7 6LKg== X-Gm-Message-State: ALoCoQnbn9xAOeQIygav0oV3y+Cjp/rUtJk5gdzn1xcPG1vNfce7QxXDURo90HcR5ArkUuDDT7UO X-Received: by 10.182.158.4 with SMTP id wq4mr8991438obb.18.1394271288889; Sat, 08 Mar 2014 01:34:48 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.162 with SMTP id w31ls750709qge.26.gmail; Sat, 08 Mar 2014 01:34:48 -0800 (PST) X-Received: by 10.221.55.133 with SMTP id vy5mr13865641vcb.17.1394271288780; Sat, 08 Mar 2014 01:34:48 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id t20si2947083vek.117.2014.03.08.01.34.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Mar 2014 01:34:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oz11so5257339veb.34 for ; Sat, 08 Mar 2014 01:34:48 -0800 (PST) X-Received: by 10.221.34.211 with SMTP id st19mr13866956vcb.5.1394271288690; Sat, 08 Mar 2014 01:34:48 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp172988vck; Sat, 8 Mar 2014 01:34:48 -0800 (PST) X-Received: by 10.66.161.38 with SMTP id xp6mr27386380pab.145.1394271287615; Sat, 08 Mar 2014 01:34:47 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zj6si10851934pac.291.2014.03.08.01.34.17; Sat, 08 Mar 2014 01:34:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567AbaCHJaY (ORCPT + 26 others); Sat, 8 Mar 2014 04:30:24 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:52779 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752363AbaCHJaH (ORCPT ); Sat, 8 Mar 2014 04:30:07 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s289U6Gw008539; Sat, 8 Mar 2014 03:30:06 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s289U6h5017071; Sat, 8 Mar 2014 03:30:06 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Sat, 8 Mar 2014 03:30:03 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s289TUGq006693; Sat, 8 Mar 2014 03:30:03 -0600 From: Kishon Vijay Abraham I To: , , Subject: [PATCH 21/28] phy: ti-pipe3: cleanup clock handling Date: Sat, 8 Mar 2014 14:59:22 +0530 Message-ID: <1394270969-11851-22-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1394270969-11851-1-git-send-email-kishon@ti.com> References: <1394270969-11851-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kishon@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Roger Quadros As this driver is no longer USB specific, use generic clock names. - Fix PLL_SD_SHIFT from 9 to 10 - Don't separate prepare/unprepare clock from enable/disable. This ensures optimal power savings. Signed-off-by: Roger Quadros Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/phy-ti-pipe3.c | 55 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c index fd029b1..211703c 100644 --- a/drivers/phy/phy-ti-pipe3.c +++ b/drivers/phy/phy-ti-pipe3.c @@ -45,7 +45,7 @@ #define PLL_SELFREQDCO_MASK 0x0000000E #define PLL_SELFREQDCO_SHIFT 0x1 #define PLL_SD_MASK 0x0003FC00 -#define PLL_SD_SHIFT 0x9 +#define PLL_SD_SHIFT 10 #define SET_PLL_GO 0x1 #define PLL_TICOPWDN 0x10000 #define PLL_LOCK 0x2 @@ -72,7 +72,7 @@ struct ti_pipe3 { struct device *control_dev; struct clk *wkupclk; struct clk *sys_clk; - struct clk *optclk; + struct clk *refclk; }; struct pipe3_dpll_map { @@ -270,23 +270,21 @@ static int ti_pipe3_probe(struct platform_device *pdev) phy->dev = &pdev->dev; - phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); + phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); if (IS_ERR(phy->wkupclk)) { - dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); + dev_err(&pdev->dev, "unable to get wkupclk\n"); return PTR_ERR(phy->wkupclk); } - clk_prepare(phy->wkupclk); - phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m"); - if (IS_ERR(phy->optclk)) { - dev_err(&pdev->dev, "unable to get usb_otg_ss_refclk960m\n"); - return PTR_ERR(phy->optclk); + phy->refclk = devm_clk_get(phy->dev, "refclk"); + if (IS_ERR(phy->refclk)) { + dev_err(&pdev->dev, "unable to get refclk\n"); + return PTR_ERR(phy->refclk); } - clk_prepare(phy->optclk); - phy->sys_clk = devm_clk_get(phy->dev, "sys_clkin"); + phy->sys_clk = devm_clk_get(phy->dev, "sysclk"); if (IS_ERR(phy->sys_clk)) { - pr_err("%s: unable to get sys_clkin\n", __func__); + dev_err(&pdev->dev, "unable to get sysclk\n"); return -EINVAL; } @@ -326,10 +324,6 @@ static int ti_pipe3_probe(struct platform_device *pdev) static int ti_pipe3_remove(struct platform_device *pdev) { - struct ti_pipe3 *phy = platform_get_drvdata(pdev); - - clk_unprepare(phy->wkupclk); - clk_unprepare(phy->optclk); if (!pm_runtime_suspended(&pdev->dev)) pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -343,8 +337,10 @@ static int ti_pipe3_runtime_suspend(struct device *dev) { struct ti_pipe3 *phy = dev_get_drvdata(dev); - clk_disable(phy->wkupclk); - clk_disable(phy->optclk); + if (!IS_ERR(phy->wkupclk)) + clk_disable_unprepare(phy->wkupclk); + if (!IS_ERR(phy->refclk)) + clk_disable_unprepare(phy->refclk); return 0; } @@ -354,22 +350,27 @@ static int ti_pipe3_runtime_resume(struct device *dev) u32 ret = 0; struct ti_pipe3 *phy = dev_get_drvdata(dev); - ret = clk_enable(phy->optclk); - if (ret) { - dev_err(phy->dev, "Failed to enable optclk %d\n", ret); - goto err1; + if (!IS_ERR(phy->refclk)) { + ret = clk_prepare_enable(phy->refclk); + if (ret) { + dev_err(phy->dev, "Failed to enable refclk %d\n", ret); + goto err1; + } } - ret = clk_enable(phy->wkupclk); - if (ret) { - dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); - goto err2; + if (!IS_ERR(phy->wkupclk)) { + ret = clk_prepare_enable(phy->wkupclk); + if (ret) { + dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); + goto err2; + } } return 0; err2: - clk_disable(phy->optclk); + if (!IS_ERR(phy->refclk)) + clk_disable_unprepare(phy->refclk); err1: return ret;