From patchwork Mon Jun 8 11:07:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 6564181 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 3C76F9F3D1 for ; Mon, 8 Jun 2015 11:06:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4373D20527 for ; Mon, 8 Jun 2015 11:06:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A464520525 for ; Mon, 8 Jun 2015 11:06:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752414AbbFHLGl (ORCPT ); Mon, 8 Jun 2015 07:06:41 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:48252 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752202AbbFHLGi (ORCPT ); Mon, 8 Jun 2015 07:06:38 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NPM02UYCHI5C790@mailout4.samsung.com>; Mon, 08 Jun 2015 20:06:05 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id D2.A8.29324.C1775755; Mon, 8 Jun 2015 20:06:04 +0900 (KST) X-AuditID: cbfee68d-f79106d00000728c-91-5575771c482e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BF.A3.25346.C1775755; Mon, 8 Jun 2015 20:06:04 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NPM000DFHGWYR80@mmp1.samsung.com>; Mon, 08 Jun 2015 20:06:04 +0900 (KST) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, gregkh@linuxfoundation.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jingoo Han , Krzysztof Kozlowski , Alan Stern Subject: [PATCH v4 1/2] usb: ehci-exynos: Make provision for vdd regulators Date: Mon, 08 Jun 2015 16:37:12 +0530 Message-id: <1433761633-8542-1-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 2.2.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrILMWRmVeSWpSXmKPExsWyRsSkSlemvDTUYOFcG4v5R86xWjQvXs9m cXnhJVaL1y8MLS7vmsNmMeP8PiaLRctamS0m/L7A5sDhsX/uGnaP2Xd/MHr0bVnF6PF5k1wA SxSXTUpqTmZZapG+XQJXxvvuv6wFK9UrXm3lb2A8oNDFyMEhIWAicXd1cBcjJ5ApJnHh3no2 EFtIYCmjxI7f5RBxE4mbE1awdzFyAcUXMUosPraYDcJpZZK4tWs7C0gVm4CuRNPbXYwgtohA nMSyN8/AipgFdjNK7LvzGywhLOAtceT9NbAVLAKqEt/a9oDZvALuErfP7WKDWCcnseXWI7B1 EgK/2SRu9qxngmgQkPg2+RALxNmyEpsOMEPUS0ocXHGDZQKj4AJGhlWMoqkFyQXFSelFhnrF ibnFpXnpesn5uZsYgSF7+t+z3h2Mtw9YH2IU4GBU4uGVWFoSKsSaWFZcmXuI0RRow0RmKdHk fGBk5JXEGxqbGVmYmpgaG5lbmimJ8ypK/QwWEkhPLEnNTk0tSC2KLyrNSS0+xMjEwSnVwHjk ZNGxt0uKP7+71HxB74Bwc0jjef7o3zGf1n66lL1FQd+V/5Ic/4ey2upth7dsvBzjWqvh67F+ jaZmYIHtzIj6lR5NMn7qZ3fOeVY40+Pj9wtl1vP2Hd46db3k3t2CNic1X1RPMPlw0TB65r8N HzuW8d9IW9L/6rL4fom7rv6HWWWft7M6FPMrsRRnJBpqMRcVJwIAlsXVylQCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42I5/e+xgK5MeWmowa02A4v5R86xWjQvXs9m cXnhJVaL1y8MLS7vmsNmMeP8PiaLRctamS0m/L7A5sDhsX/uGnaP2Xd/MHr0bVnF6PF5k1wA S1QDo01GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO0BlK CmWJOaVAoYDE4mIlfTtME0JD3HQtYBojdH1DguB6jAzQQMIaxoz33X9ZC1aqV7zayt/AeECh i5GTQ0LAROLmhBXsELaYxIV769m6GLk4hAQWMUosPrYYymllkri1azsLSBWbgK5E09tdjCC2 iECcxLI3z8CKmAV2M0rsu/MbLCEs4C1x5P01NhCbRUBV4lvbHjCbV8Bd4va5XWwQ6+Qkttx6 xD6BkXsBI8MqRtHUguSC4qT0XEO94sTc4tK8dL3k/NxNjOCoeCa1g3Flg8UhRgEORiUeXoml JaFCrIllxZW5hxglOJiVRHiZLEpDhXhTEiurUovy44tKc1KLDzGaAm2fyCwlmpwPjNi8knhD YxNzU2NTSxMLEzNLJXHek/k+oUIC6YklqdmpqQWpRTB9TBycUg2MGSGnNvyzT/8Y9n3Ttp01 4uvfPYqNY1qbmhW3cc7Exi+HJFaXLVyVnXmi1MFNYsXlC7szf+tyuuYflBf/z+1Rm/bIQOlu iLSr3JbVktk/xUWiaqvlE7h6KthnK62Rd11nbLCsvrm514F5UcTHZ2XT5F8xirC4dGrVzbTe Xcu658Nvu5c9068osRRnJBpqMRcVJwIAKBr44KACAAA= 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 Facilitate getting required 3.3V and 1.0V VDD supply for EHCI controller on Exynos. For example, patches for regulators' nodes: c8c253f ARM: dts: Add regulator entries to smdk5420 275dcd2 ARM: dts: add max77686 pmic node for smdk5250, enable only minimum number of regulators on smdk5250. So ensuring now that the controller driver requests the necessary VDD regulators (if available, unless there are direct VDD rails), and enable them so as to make them working on exynos systems. Signed-off-by: Vivek Gautam Cc: Jingoo Han Cc: Krzysztof Kozlowski Cc: Alan Stern --- These patches had long been posted, and i lost track of them. My apologies for that. Thanks to Krzysztof for catching this. Kindly review. Changes since v3: - added a if (!IS_ERR()) check for regulators before disabling them in error path. Changes since v2: - replaced devm_regulator_get() with devm_regulator_get_optional(). - Added Documentation for the vdd supplies for the controller. - Re-did the commit message. .../devicetree/bindings/usb/exynos-usb.txt | 2 + drivers/usb/host/ehci-exynos.c | 57 +++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt b/Documentation/devicetree/bindings/usb/exynos-usb.txt index 9b4dbe3..776fa03 100644 --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt @@ -23,6 +23,8 @@ Required properties: Optional properties: - samsung,vbus-gpio: if present, specifies the GPIO that needs to be pulled up for the bus to be powered. + - vdd33-supply: handle to 3.3V Vdd supply regulator for the controller. + - vdd10-supply: handle to 1.0V Vdd supply regulator for the controller. Example: diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index df538fd..160ad66 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,8 @@ static struct hc_driver __read_mostly exynos_ehci_hc_driver; struct exynos_ehci_hcd { struct clk *clk; struct phy *phy[PHY_NUMBER]; + struct regulator *vdd33; + struct regulator *vdd10; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv) @@ -170,7 +173,27 @@ static int exynos_ehci_probe(struct platform_device *pdev) err = exynos_ehci_get_phy(&pdev->dev, exynos_ehci); if (err) - goto fail_clk; + goto fail_regulator1; + + exynos_ehci->vdd33 = devm_regulator_get_optional(&pdev->dev, "vdd33"); + if (!IS_ERR(exynos_ehci->vdd33)) { + err = regulator_enable(exynos_ehci->vdd33); + if (err) { + dev_err(&pdev->dev, + "Failed to enable 3.3V Vdd supply\n"); + goto fail_regulator1; + } + } + + exynos_ehci->vdd10 = devm_regulator_get_optional(&pdev->dev, "vdd10"); + if (!IS_ERR(exynos_ehci->vdd10)) { + err = regulator_enable(exynos_ehci->vdd10); + if (err) { + dev_err(&pdev->dev, + "Failed to enable 1.0V Vdd supply\n"); + goto fail_regulator2; + } + } skip_phy: @@ -231,6 +254,12 @@ fail_add_hcd: fail_io: clk_disable_unprepare(exynos_ehci->clk); fail_clk: + if (!IS_ERR(exynos_ehci->vdd10)) + regulator_disable(exynos_ehci->vdd10); +fail_regulator2: + if (!IS_ERR(exynos_ehci->vdd33)) + regulator_disable(exynos_ehci->vdd33); +fail_regulator1: usb_put_hcd(hcd); return err; } @@ -246,6 +275,11 @@ static int exynos_ehci_remove(struct platform_device *pdev) clk_disable_unprepare(exynos_ehci->clk); + if (!IS_ERR(exynos_ehci->vdd33)) + regulator_disable(exynos_ehci->vdd33); + if (!IS_ERR(exynos_ehci->vdd10)) + regulator_disable(exynos_ehci->vdd10); + usb_put_hcd(hcd); return 0; @@ -268,6 +302,11 @@ static int exynos_ehci_suspend(struct device *dev) clk_disable_unprepare(exynos_ehci->clk); + if (!IS_ERR(exynos_ehci->vdd33)) + regulator_disable(exynos_ehci->vdd33); + if (!IS_ERR(exynos_ehci->vdd10)) + regulator_disable(exynos_ehci->vdd10); + return rc; } @@ -277,6 +316,22 @@ static int exynos_ehci_resume(struct device *dev) struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd); int ret; + if (!IS_ERR(exynos_ehci->vdd33)) { + ret = regulator_enable(exynos_ehci->vdd33); + if (ret) { + dev_err(dev, "Failed to enable 3.3V Vdd supply\n"); + return ret; + } + } + + if (!IS_ERR(exynos_ehci->vdd10)) { + ret = regulator_enable(exynos_ehci->vdd10); + if (ret) { + dev_err(dev, "Failed to enable 1.0V Vdd supply\n"); + return ret; + } + } + clk_prepare_enable(exynos_ehci->clk); ret = exynos_ehci_phy_enable(dev);