From patchwork Thu Dec 11 12:02:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 5475481 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D3A8A9F2E8 for ; Thu, 11 Dec 2014 12:12:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3B8420149 for ; Thu, 11 Dec 2014 12:12:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B681200F0 for ; Thu, 11 Dec 2014 12:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754417AbaLKMMC (ORCPT ); Thu, 11 Dec 2014 07:12:02 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:62746 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbaLKMMA (ORCPT ); Thu, 11 Dec 2014 07:12:00 -0500 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGF00FH437YO560@mailout1.samsung.com>; Thu, 11 Dec 2014 21:11:58 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 6C.08.11124.E0A89845; Thu, 11 Dec 2014 21:11:58 +0900 (KST) X-AuditID: cbfee68e-f79b46d000002b74-4c-54898a0e731a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B5.34.09430.E0A89845; Thu, 11 Dec 2014 21:11:58 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGF0022Q33NTFA0@mmp1.samsung.com>; Thu, 11 Dec 2014 21:11:58 +0900 (KST) From: Vivek Gautam To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org Cc: robh+dt@kernel.org, kishon@ti.com, k.debski@samsung.com, kgene@kernel.org, jg1.han@samsung.com, Vivek Gautam Subject: [PATCH 2/4] phy: samsung-usb2: Add facility for VBUS supply Date: Thu, 11 Dec 2014 17:32:45 +0530 Message-id: <1418299367-2412-3-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 2.2.0 In-reply-to: <1418299367-2412-1-git-send-email-gautam.vivek@samsung.com> References: <1418299367-2412-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRmVeSWpSXmKPExsWyRsSkTpevqzPE4MJtZYv5R86xWrRdOchu cXnhJVaLH68vsFn0P37NbHHhaQ+bxeVdc9gsZpzfx2SxaFkrs0Xr3iPsDlwem1Z1snn0bVnF 6HH8xnYmj8+b5AJYorhsUlJzMstSi/TtErgyfr2+zlZwVa7iVWN2A+NviS5GTg4JAROJXXe+ MUHYYhIX7q1n62Lk4hASWMoocffOV3aYon8zfzNBJBYxSkzdcQnKmcAkMeXNJLB2NgFdiaa3 uxhBbBGBGokpt66wgxQxC/QySvz7cI4VJCEs4CKxanIzkM3BwSKgKtF7WAokzCvgLrFnyiEW iG1yEltuPQLbzCngIbGo5ycLSLkQUM3VXk2QkRICy9glPq97CLaLRUBA4tvkQ2A1EgKyEpsO MEOMkZQ4uOIGywRG4QWMDKsYRVMLkguKk9KLjPSKE3OLS/PS9ZLzczcxAgP/9L9nfTsYbx6w PsQowMGoxMObEd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xZmyEa3LOCddXCHfmC+RriwR+KxHpXBip/s551 omTd50Y3Fa3t+Tl3f3RO8Zj+224O1/4P8Y1G869WuYZzHncuabPgXr31vhJLcUaioRZzUXEi AGhDErHBAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected 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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Adding support to enable/disable VBUS controlled by a regulator on USB 2.0 port. This is a part of moving vbus setting out of ehci-exynos. Since vbus can be handled by USB 2.0 phy itself, so the host need not care about it. Moreover, setting VBUS in USB 2.0 phy helps both ehci as well as ohci. This issue was not taken care of until now; when ehci is not enabled and only ohci is enabled the VBUS was never set. Keeping the vbus setting code in ehci-exynos intact for now to keep supporting older dt bindings. Signed-off-by: Vivek Gautam --- .../devicetree/bindings/phy/samsung-phy.txt | 3 ++ drivers/phy/phy-samsung-usb2.c | 30 ++++++++++++++++++++ drivers/phy/phy-samsung-usb2.h | 1 + 3 files changed, 34 insertions(+) diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 0090ad1..44d82ba 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 : Reference to regulator node which supplies VBUS on the PHY. + 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 4a12f66..7fe7c84 100644 --- a/drivers/phy/phy-samsung-usb2.c +++ b/drivers/phy/phy-samsung-usb2.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "phy-samsung-usb2.h" @@ -33,6 +34,16 @@ static int samsung_usb2_phy_power_on(struct phy *phy) ret = clk_prepare_enable(drv->ref_clk); if (ret) goto err_instance_clk; + + /* Enable VBUS supply */ + if (drv->vbus) { + ret = regulator_enable(drv->vbus); + if (ret) { + dev_err(drv->dev, "Failed to enable VBUS supply\n"); + goto err_fail_vbus; + } + } + if (inst->cfg->power_on) { spin_lock(&drv->lock); ret = inst->cfg->power_on(inst); @@ -41,6 +52,8 @@ static int samsung_usb2_phy_power_on(struct phy *phy) return 0; +err_fail_vbus: + clk_disable_unprepare(drv->ref_clk); err_instance_clk: clk_disable_unprepare(drv->clk); err_main_clk: @@ -60,8 +73,14 @@ static int samsung_usb2_phy_power_off(struct phy *phy) ret = inst->cfg->power_off(inst); spin_unlock(&drv->lock); } + + /* Disable VBUS supply */ + if (drv->vbus) + regulator_disable(drv->vbus); + clk_disable_unprepare(drv->ref_clk); clk_disable_unprepare(drv->clk); + return ret; } @@ -197,6 +216,17 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev) return ret; } + /* Get Vbus regulators */ + drv->vbus = devm_regulator_get(dev, "vbus"); + if (IS_ERR(drv->vbus)) { + ret = PTR_ERR(drv->vbus); + if (ret == -EPROBE_DEFER) + return ret; + + dev_warn(dev, "Failed to get VBUS supply regulator\n"); + 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..cb92e3e 100644 --- a/drivers/phy/phy-samsung-usb2.h +++ b/drivers/phy/phy-samsung-usb2.h @@ -43,6 +43,7 @@ struct samsung_usb2_phy_driver { void __iomem *reg_phy; struct regmap *reg_pmu; struct regmap *reg_sys; + struct regulator *vbus; spinlock_t lock; struct samsung_usb2_phy_instance instances[0]; };