From patchwork Sat Oct 17 02:22:12 2015 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: 55146 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 6D62C22EAC for ; Sat, 17 Oct 2015 02:23:57 +0000 (UTC) Received: by lffy185 with SMTP id y185sf23600022lff.2 for ; Fri, 16 Oct 2015 19:23:56 -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:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=0pTXLG4/+u6mls9nNOZbpTP/pZswnpt9b8FvjnHKyW4=; b=mPKS/PoUSsIikrg5fufY9U/avHE0TnA1tkwrRwJUqtB74h4J1haxElOb4IaEpQEgre MuN2tFFlr0pBZFJ6/vH1Xtf/Y8Ra/1kR0BKkR9N9N0RU2qTgZyPdVgv5p1s/GeqnNGX5 PQaky19x/Uhlze2/keZnxF2BByKo3o+NdO4ofp7XInenXgOfYx60uYoKK8oCe8JN8Lxw CQkXfMjBWj2Hsit/zD59H6FOmaSXwdz09OXVYIQxNryw99fqB2VAUhCsRoyoeVQAxUQ5 oVQKyZGFNFmyEfiBDdXAuzi5Pzzc+hLS7LEe04C1J81qLSK10INMuCITo+D/jo7UrdVz zFUw== X-Gm-Message-State: ALoCoQmhEapH3xdAWuR/3fAE5KFwLp+gx6zHixCitew8rpzjQaYqqzAjXWwwFkxo3vpglQLND9tA X-Received: by 10.180.189.49 with SMTP id gf17mr1918926wic.6.1445048635961; Fri, 16 Oct 2015 19:23:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.43.133 with SMTP id r127ls368545lfr.74.gmail; Fri, 16 Oct 2015 19:23:55 -0700 (PDT) X-Received: by 10.112.161.42 with SMTP id xp10mr9574457lbb.49.1445048635783; Fri, 16 Oct 2015 19:23:55 -0700 (PDT) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id ew1si14775007lbc.98.2015.10.16.19.23.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 19:23:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lffz202 with SMTP id z202so4423830lff.3 for ; Fri, 16 Oct 2015 19:23:55 -0700 (PDT) X-Received: by 10.25.207.82 with SMTP id f79mr6468976lfg.73.1445048635661; Fri, 16 Oct 2015 19:23:55 -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.59.35 with SMTP id w3csp244523lbq; Fri, 16 Oct 2015 19:23:54 -0700 (PDT) X-Received: by 10.68.104.66 with SMTP id gc2mr19768122pbb.21.1445048634364; Fri, 16 Oct 2015 19:23:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si33458979pbq.128.2015.10.16.19.23.53; Fri, 16 Oct 2015 19:23:54 -0700 (PDT) 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 S1753082AbbJQCXF (ORCPT + 30 others); Fri, 16 Oct 2015 22:23:05 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:39801 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752342AbbJQCWU (ORCPT ); Fri, 16 Oct 2015 22:22:20 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id t9H2MIl6029039; Fri, 16 Oct 2015 21:22:19 -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 t9H2MI1H012539; Fri, 16 Oct 2015 21:22:18 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Fri, 16 Oct 2015 21:22:18 -0500 Received: from a0393678ub.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9H2MIuW003368; Fri, 16 Oct 2015 21:22:18 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 1/7] phy: exynos-usb2: add vbus regulator support Date: Sat, 17 Oct 2015 07:52:12 +0530 Message-ID: <1445048538-4855-2-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1445048538-4855-1-git-send-email-kishon@ti.com> References: <1445048538-4855-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.215.42 as permitted sender) smtp.mailfrom=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: Marek Szyprowski Exynos USB2 PHY has separate power supply, which is usually provided by VBUS regulator. This patch adds support for it. VBUS regulator is optional, to keep compatibility with boards, which have VBUS provided from some always-on power source. Signed-off-by: Marek Szyprowski Tested-by: Krzysztof Kozlowski Signed-off-by: Kishon Vijay Abraham I --- .../devicetree/bindings/phy/samsung-phy.txt | 3 +++ drivers/phy/phy-samsung-usb2.c | 25 ++++++++++++++++++-- drivers/phy/phy-samsung-usb2.h | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 60c6f2a..0289d3b 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -44,6 +44,9 @@ Required properties: - the "ref" clock is used to get the rate of the clock provided to the PHY module +Optional properties: +- vbus-supply: power-supply phandle for vbus power source + The first phandle argument in the PHY specifier identifies the PHY, its meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 and Exynos 4212) it is as follows: diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c index f278a9c..1d22d93 100644 --- a/drivers/phy/phy-samsung-usb2.c +++ b/drivers/phy/phy-samsung-usb2.c @@ -27,6 +27,13 @@ static int samsung_usb2_phy_power_on(struct phy *phy) dev_dbg(drv->dev, "Request to power_on \"%s\" usb phy\n", inst->cfg->label); + + if (drv->vbus) { + ret = regulator_enable(drv->vbus); + if (ret) + goto err_regulator; + } + ret = clk_prepare_enable(drv->clk); if (ret) goto err_main_clk; @@ -48,6 +55,9 @@ err_power_on: err_instance_clk: clk_disable_unprepare(drv->clk); err_main_clk: + if (drv->vbus) + regulator_disable(drv->vbus); +err_regulator: return ret; } @@ -55,7 +65,7 @@ static int samsung_usb2_phy_power_off(struct phy *phy) { struct samsung_usb2_phy_instance *inst = phy_get_drvdata(phy); struct samsung_usb2_phy_driver *drv = inst->drv; - int ret; + int ret = 0; dev_dbg(drv->dev, "Request to power_off \"%s\" usb phy\n", inst->cfg->label); @@ -68,7 +78,10 @@ static int samsung_usb2_phy_power_off(struct phy *phy) } clk_disable_unprepare(drv->ref_clk); clk_disable_unprepare(drv->clk); - return 0; + if (drv->vbus) + ret = regulator_disable(drv->vbus); + + return ret; } static const struct phy_ops samsung_usb2_phy_ops = { @@ -203,6 +216,14 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev) return ret; } + drv->vbus = devm_regulator_get(dev, "vbus"); + if (IS_ERR(drv->vbus)) { + ret = PTR_ERR(drv->vbus); + if (ret == -EPROBE_DEFER) + return ret; + drv->vbus = NULL; + } + for (i = 0; i < drv->cfg->num_phys; i++) { char *label = drv->cfg->phys[i].label; struct samsung_usb2_phy_instance *p = &drv->instances[i]; diff --git a/drivers/phy/phy-samsung-usb2.h b/drivers/phy/phy-samsung-usb2.h index 44bead9..6563e7c 100644 --- a/drivers/phy/phy-samsung-usb2.h +++ b/drivers/phy/phy-samsung-usb2.h @@ -17,6 +17,7 @@ #include #include #include +#include #define KHZ 1000 #define MHZ (KHZ * KHZ) @@ -37,6 +38,7 @@ struct samsung_usb2_phy_driver { const struct samsung_usb2_phy_config *cfg; struct clk *clk; struct clk *ref_clk; + struct regulator *vbus; unsigned long ref_rate; u32 ref_reg_val; struct device *dev;