From patchwork Tue Oct 6 13:41:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 54532 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 7955422FC5 for ; Tue, 6 Oct 2015 13:41:18 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf41708696wic.1 for ; Tue, 06 Oct 2015 06:41:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=msc+NN7byiK0gWR7I7TiAbRrzlGburOky+qdsfX51CI=; b=VTbx2BgD0C4TvAvLzrlBUTwNMw+ZPKIRG+78nEDdGcp+eKvdojRxu9SYNwimG6colf UuCuQcpuRhG+ig4Y5IjG9B1X8I5gDFARKATR+WgH6RPY27yDsNdhBB6tNZ90Shpym5jR VB1Wv15O7uCkJr1WNUY41ktrQseaASmO8Vb+aaHhWsHOiTD0wssS5G/v4JXb1/Su2oTm zBFnBX82Ck+YHYU0Y9jfEL21Av6L4I1ViOKPlFZ/eK+LLa/CEkGqlMuOcZ8h0fIfzy+T tsW5aqCBedtlWOq1T3nqOjW7zDCQ/GUt7KDXrCoiJDA7KGfDwvlwnVpDNFgKdtOe5ja/ q6wA== X-Gm-Message-State: ALoCoQnqvgvt8C4okolnDetWSULFQ5cMYt6GtSFS9VgV9Jw1Y3crLLH9HbFYytf38k8qCXLM/p76 X-Received: by 10.112.132.6 with SMTP id oq6mr6356176lbb.1.1444138877786; Tue, 06 Oct 2015 06:41:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.160.75 with SMTP id j72ls507041lfe.106.gmail; Tue, 06 Oct 2015 06:41:17 -0700 (PDT) X-Received: by 10.112.142.9 with SMTP id rs9mr14490239lbb.39.1444138877649; Tue, 06 Oct 2015 06:41:17 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id bc7si20982444lbc.6.2015.10.06.06.41.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Oct 2015 06:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by labzv5 with SMTP id zv5so144541513lab.1 for ; Tue, 06 Oct 2015 06:41:17 -0700 (PDT) X-Received: by 10.25.210.206 with SMTP id j197mr9773631lfg.86.1444138877337; Tue, 06 Oct 2015 06:41:17 -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 w3csp1859014lbq; Tue, 6 Oct 2015 06:41:15 -0700 (PDT) X-Received: by 10.66.182.135 with SMTP id ee7mr47087175pac.95.1444138875655; Tue, 06 Oct 2015 06:41:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si26663996pat.162.2015.10.06.06.41.15; Tue, 06 Oct 2015 06:41:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-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 S1752127AbbJFNlO (ORCPT + 4 others); Tue, 6 Oct 2015 09:41:14 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:14726 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751706AbbJFNlN (ORCPT ); Tue, 6 Oct 2015 09:41:13 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NVS00GXJWOMCX50@mailout2.w1.samsung.com>; Tue, 06 Oct 2015 14:41:11 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-f7-5613cf7603e7 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 0C.E6.05269.67FC3165; Tue, 6 Oct 2015 14:41:10 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NVS00D3ZWOJE240@eusync3.samsung.com>; Tue, 06 Oct 2015 14:41:10 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Krzysztof Kozlowski , Kishon Vijay Abraham I Subject: [PATCH RESEND] phy: exynos-usb2: add vbus regulator support Date: Tue, 06 Oct 2015 15:41:00 +0200 Message-id: <1444138860-23595-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGJMWRmVeSWpSXmKPExsVy+t/xq7pl54XDDO7OUbB4/cLQ4sLTHjaL y7vmsFnMOL+PyWLtkbvsDqwefVtWMXocv7GdyePzJrkA5igum5TUnMyy1CJ9uwSujOZbZ1gL nshVbD+2nb2BcapkFyMnh4SAicS2uQsYIWwxiQv31rOB2EICSxklmg5bQNhNTBLHD2qA2GwC hhJdb7vAakQEnCVuf/jG0sXIxcEs0MUo8fn0YRaQhLCAi8S6PdfAbBYBVYn/386zgti8Ah4S p9peM0Msk5P4/3IF0wRG7gWMDKsYRVNLkwuKk9JzjfSKE3OLS/PS9ZLzczcxQnz/dQfj0mNW hxgFOBiVeHglbgqFCbEmlhVX5h5ilOBgVhLhVTgiHCbEm5JYWZValB9fVJqTWnyIUZqDRUmc d+au9yFCAumJJanZqakFqUUwWSYOTqkGRlHhiv2l0vZOzFmLA0+vkJg+f13DfCN9i867H+/k x/k1F3vt5Lp84rOF3a+/5feerb1WeVBaexODgcy1f+fmKJ/1ZtDQc6vh8Z4hpbee+Yu+gP6z xNlML5eI/6zamnSh1mIzx+J0lfMJ3QyHSvULT5xpb91mt7mRt1n8fJZgQ7IBt7O887afSizF GYmGWsxFxYkAl0UjCfkBAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.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.47 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: , 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 --- This is just a resend of a patch posted in the following thread: https://lkml.org/lkml/2015/8/21/306 I really hope that it will finally get merged to v4.4. For more information and background, please refer to the mentioned thread. Marek Szyprowski --- .../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;