From patchwork Fri Aug 21 12:38:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 7051601 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0520F9F344 for ; Fri, 21 Aug 2015 12:40:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B56920616 for ; Fri, 21 Aug 2015 12:40:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12D832057F for ; Fri, 21 Aug 2015 12:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753444AbbHUMjS (ORCPT ); Fri, 21 Aug 2015 08:39:18 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:12826 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751703AbbHUMjP (ORCPT ); Fri, 21 Aug 2015 08:39:15 -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 <0NTF009UXN5DJF10@mailout2.w1.samsung.com>; Fri, 21 Aug 2015 13:39:13 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-53-55d71bf12738 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 9F.48.05269.1FB17D55; Fri, 21 Aug 2015 13:39:13 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NTF00L5CN50J880@eusync2.samsung.com>; Fri, 21 Aug 2015 13:39:13 +0100 (BST) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Robert Baldyga , John Youn , Krzysztof Kozlowski , Kukjin Kim , Kamil Debski , Kishon Vijay Abraham I Subject: [PATCH 1/7] phy: exynos-usb2: add vbus regulator support Date: Fri, 21 Aug 2015 14:38:37 +0200 Message-id: <1440160723-6636-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1440160723-6636-1-git-send-email-m.szyprowski@samsung.com> References: <1440160723-6636-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrILMWRmVeSWpSXmKPExsVy+t/xK7ofpa+HGmy5yGSx+/QlRosfry+w Wbx+YWjR//g1s8WFpz1sFpd3zWGzmHF+H5PFomWtzBZrj9xlt3hweCe7A5fHplWdbB59W1Yx emzZ/5nR4/iN7UwenzfJBbBGcdmkpOZklqUW6dslcGUsbTnMXvBHpuLA0YPsDYz3xLsYOTkk BEwkjjdtYYOwxSQu3FsPZHNxCAksZZR40LSHCcJpYpK49GgCK0gVm4ChRNfbLrAOEYEEib7l /WAdzAKzmSROb+ll72Lk4BAWcJQ4MD8ExGQRUJU4uLIGpJxXwF1iw9/X7BDL5CT+v1zBBGJz CnhI7Lk4jxHEFgKq2fzyNOMERt4FjAyrGEVTS5MLipPSc430ihNzi0vz0vWS83M3MUIC7usO xqXHrA4xCnAwKvHwzoi8FirEmlhWXJl7iFGCg1lJhNf6BVCINyWxsiq1KD++qDQntfgQozQH i5I478xd70OEBNITS1KzU1MLUotgskwcnFINjCy+sTevc3lJSoYtXPiO75PCTvWY143zLGcZ 7lT2u8KQ1ZrYPF/xBmf1xXiHymkn7iW0y39Yc65/RqD3j/Nh5VZZLZGxTzys8neW+K63l8lJ fFQZFSCcuTnh6qtedU7rXWc1Ui++UNk7bcrZ+V8CdxxtDtbXXGMlcuu8RdVnQ1XJ57/lVi2y U2Ipzkg01GIuKk4EAK41f3w0AgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- .../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 60c6f2a633e0..0289d3b07853 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 f278a9c547e1..1d22d93b552d 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 44bead9b8f34..6563e7ca0ac4 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;