From patchwork Sat Oct 17 20:33:25 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: 55169 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 0C5AC22FFA for ; Sat, 17 Oct 2015 20:35:16 +0000 (UTC) Received: by wibzt1 with SMTP id zt1sf12478518wib.0 for ; Sat, 17 Oct 2015 13:35:15 -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=lWH9SDD6lLWLDmtIrA8oZKEtLUtqulNuNow4MFVsuRvFuW6t53k6SlMNM++yJgT8Wb DrASqJvNbStfRurhUK1HZiD+NfCYioUbMWG7nphxKUdavgLarvhEk4oS26vKZ7Svib2j NNjk3BmOXcpUgt/hXtakZGLOYnuAReWyC3TeTtS9Itkxzi9FcO+QYFFgJcG32mx2USxl V6oGfP3UJHCRio5M4AvNjuRTmyX1E7Su5oRQmmoTP0mo0bO6qDTfjdY17h9mtdJuiTra lQp+aWkJPocDn06z7labL1XREMAAa18MhoVMpPnZFX8OzdLycNQo6hDPg6AMkxWh4n6e ALiw== X-Gm-Message-State: ALoCoQkmvANzBCWAGhONn/QTCXW+wRQFIH+WBf28Y/i7chye5mQPEznAnwXx/Y7psr+tBmyz+ItE X-Received: by 10.112.130.41 with SMTP id ob9mr5279965lbb.17.1445114115210; Sat, 17 Oct 2015 13:35:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.28.195 with SMTP id c186ls320071lfc.71.gmail; Sat, 17 Oct 2015 13:35:15 -0700 (PDT) X-Received: by 10.112.132.7 with SMTP id oq7mr11351123lbb.32.1445114115039; Sat, 17 Oct 2015 13:35:15 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id m72si7104294lfm.71.2015.10.17.13.35.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Oct 2015 13:35:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbes7 with SMTP id es7so30106703lbb.2 for ; Sat, 17 Oct 2015 13:35:14 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr11255320lbb.35.1445114114926; Sat, 17 Oct 2015 13:35:14 -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 w3csp659592lbq; Sat, 17 Oct 2015 13:35:13 -0700 (PDT) X-Received: by 10.68.94.69 with SMTP id da5mr4726663pbb.65.1445114113705; Sat, 17 Oct 2015 13:35:13 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rb3si39416698pbc.134.2015.10.17.13.35.13; Sat, 17 Oct 2015 13:35:13 -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 S1752159AbbJQUeI (ORCPT + 28 others); Sat, 17 Oct 2015 16:34:08 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:33044 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751380AbbJQUdd (ORCPT ); Sat, 17 Oct 2015 16:33:33 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id t9HKXWit025126; Sat, 17 Oct 2015 15:33:32 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9HKXW7K019250; Sat, 17 Oct 2015 15:33:32 -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.224.2; Sat, 17 Oct 2015 15:33:32 -0500 Received: from a0393678ub.am.dhcp.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 t9HKXVpf003521; Sat, 17 Oct 2015 15:33:31 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 1/7] phy: exynos-usb2: add vbus regulator support Date: Sun, 18 Oct 2015 02:03:25 +0530 Message-ID: <1445114011-4191-2-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1445114011-4191-1-git-send-email-kishon@ti.com> References: <1445114011-4191-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.181 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;