From patchwork Wed Sep 24 13:47:10 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: 37822 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6D3F620BF9 for ; Wed, 24 Sep 2014 13:48:46 +0000 (UTC) Received: by mail-we0-f198.google.com with SMTP id t60sf3599567wes.1 for ; Wed, 24 Sep 2014 06:48:45 -0700 (PDT) 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:cc: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=pxo5tFF7fmV/e0Yy+514n5MkpTlI1LjYttE/3+iZ3aI=; b=gSo0v8/GbCocr1GzOoRQOqZi1atmd/07N8pub1M0HddTiGuiJ0TiJ9tCPMLpHiqt7M TAxtrVucy7gvigT5EPOLUUXhNiR7+t87KIlgm/6NmoGHdtOqORav8S8jUqGSSez3hMtv hhZJx8utNnGJrtGcKH44Hpv10bRC/0RDk34yrOqiEeB0f0GIB9W0STaQQDetmPidmsXH FgjFY7HYhdknraMFNshp7+bAoQO6hgkSwH7zUKk4GmsRPNg1jeVK6ljx6+KUMn2JS18e bM+Ez6BQbQ/nMWPoawtOAoBkI0gQhlr78kZwBIyHYBPMRgWEmBxsHiQR3uz74wVv7jDS ugAw== X-Gm-Message-State: ALoCoQmvsFvOHB7BpFn5TG45EgYWV8ySCOE85eGkiUC8yyaNEs0RrGATwGRVo7DGX89DMJeCs19r X-Received: by 10.152.18.199 with SMTP id y7mr450205lad.9.1411566525126; Wed, 24 Sep 2014 06:48:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.104 with SMTP id lf8ls138516lac.87.gmail; Wed, 24 Sep 2014 06:48:44 -0700 (PDT) X-Received: by 10.152.4.97 with SMTP id j1mr6437239laj.73.1411566524955; Wed, 24 Sep 2014 06:48:44 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by mx.google.com with ESMTPS id pg10si22852876lbb.127.2014.09.24.06.48.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Sep 2014 06:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id l4so10555378lbv.5 for ; Wed, 24 Sep 2014 06:48:44 -0700 (PDT) X-Received: by 10.112.130.226 with SMTP id oh2mr3104406lbb.100.1411566524804; Wed, 24 Sep 2014 06:48:44 -0700 (PDT) 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.112.130.169 with SMTP id of9csp585174lbb; Wed, 24 Sep 2014 06:48:44 -0700 (PDT) X-Received: by 10.70.21.228 with SMTP id y4mr9442953pde.19.1411566518194; Wed, 24 Sep 2014 06:48:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id id8si26374912pad.155.2014.09.24.06.48.37 for ; Wed, 24 Sep 2014 06:48:38 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753849AbaIXNsC (ORCPT + 27 others); Wed, 24 Sep 2014 09:48:02 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:55836 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753758AbaIXNr5 (ORCPT ); Wed, 24 Sep 2014 09:47:57 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s8ODlutU005415; Wed, 24 Sep 2014 08:47:56 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s8ODlf7T009475; Wed, 24 Sep 2014 08:47:41 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Wed, 24 Sep 2014 08:47:41 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s8ODlKDV015622; Wed, 24 Sep 2014 08:47:40 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 12/22] usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls Date: Wed, 24 Sep 2014 19:17:10 +0530 Message-ID: <1411566440-19169-13-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1411566440-19169-1-git-send-email-kishon@ti.com> References: <1411566440-19169-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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) 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: Tony Lindgren We don't need twl4030_phy_power() any longer now that we have the runtime PM calls. Let's get rid of it as it's confusing. No functional changes, just move the code and use res instead of ret as we are not returning that value. Signed-off-by: Tony Lindgren Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/phy-twl4030-usb.c | 72 ++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index a292db0..519cc90 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -383,45 +383,6 @@ static void __twl4030_phy_power(struct twl4030_usb *twl, int on) WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0); } -static void twl4030_phy_power(struct twl4030_usb *twl, int on) -{ - int ret; - - if (on) { - ret = regulator_enable(twl->usb3v1); - if (ret) - dev_err(twl->dev, "Failed to enable usb3v1\n"); - - ret = regulator_enable(twl->usb1v8); - if (ret) - dev_err(twl->dev, "Failed to enable usb1v8\n"); - - /* - * Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP - * in twl4030) resets the VUSB_DEDICATED2 register. This reset - * enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to - * SLEEP. We work around this by clearing the bit after usv3v1 - * is re-activated. This ensures that VUSB3V1 is really active. - */ - twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); - - ret = regulator_enable(twl->usb1v5); - if (ret) - dev_err(twl->dev, "Failed to enable usb1v5\n"); - - __twl4030_phy_power(twl, 1); - twl4030_usb_write(twl, PHY_CLK_CTRL, - twl4030_usb_read(twl, PHY_CLK_CTRL) | - (PHY_CLK_CTRL_CLOCKGATING_EN | - PHY_CLK_CTRL_CLK32K_EN)); - } else { - __twl4030_phy_power(twl, 0); - regulator_disable(twl->usb1v5); - regulator_disable(twl->usb1v8); - regulator_disable(twl->usb3v1); - } -} - static int twl4030_usb_runtime_suspend(struct device *dev) { struct twl4030_usb *twl = dev_get_drvdata(dev); @@ -430,7 +391,10 @@ static int twl4030_usb_runtime_suspend(struct device *dev) if (twl->asleep) return 0; - twl4030_phy_power(twl, 0); + __twl4030_phy_power(twl, 0); + regulator_disable(twl->usb1v5); + regulator_disable(twl->usb1v8); + regulator_disable(twl->usb3v1); twl->asleep = 1; return 0; @@ -439,12 +403,38 @@ static int twl4030_usb_runtime_suspend(struct device *dev) static int twl4030_usb_runtime_resume(struct device *dev) { struct twl4030_usb *twl = dev_get_drvdata(dev); + int res; dev_dbg(twl->dev, "%s\n", __func__); if (!twl->asleep) return 0; - twl4030_phy_power(twl, 1); + res = regulator_enable(twl->usb3v1); + if (res) + dev_err(twl->dev, "Failed to enable usb3v1\n"); + + res = regulator_enable(twl->usb1v8); + if (res) + dev_err(twl->dev, "Failed to enable usb1v8\n"); + + /* + * Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP + * in twl4030) resets the VUSB_DEDICATED2 register. This reset + * enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to + * SLEEP. We work around this by clearing the bit after usv3v1 + * is re-activated. This ensures that VUSB3V1 is really active. + */ + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); + + res = regulator_enable(twl->usb1v5); + if (res) + dev_err(twl->dev, "Failed to enable usb1v5\n"); + + __twl4030_phy_power(twl, 1); + twl4030_usb_write(twl, PHY_CLK_CTRL, + twl4030_usb_read(twl, PHY_CLK_CTRL) | + (PHY_CLK_CTRL_CLOCKGATING_EN | + PHY_CLK_CTRL_CLK32K_EN)); twl->asleep = 0; return 0;