From patchwork Fri May 9 13:57:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4143581 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 42FBDBFF02 for ; Fri, 9 May 2014 13:58:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FACA201E7 for ; Fri, 9 May 2014 13:58:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8FAA920109 for ; Fri, 9 May 2014 13:58:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756737AbaEIN6Z (ORCPT ); Fri, 9 May 2014 09:58:25 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:55254 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754431AbaEIN6V (ORCPT ); Fri, 9 May 2014 09:58:21 -0400 Received: by mail-pa0-f42.google.com with SMTP id rd3so4455221pab.15 for ; Fri, 09 May 2014 06:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z0fU3Ys8oNbKmbO+ZUKGBaPfPpeWZS0QOuXjZKebPo8=; b=lZu/cwnuw9EFAfwVmLXXZZSXJBPSPjdYKgcnmUkGbyAm3yA1fT5Fcm1zkJb+UFPV9Z MUab4L0Us6UCsMDazbTxf7YoK12Swc70DPllTzHzyXZL/6OZ0mUs6Jd1XYVbjNHqbw8G CYr0iBJnBzasBv9g34XJcGW5e4leFE6V4Z+5iigK8AMI35LRF0qdnt5/MVuvasrOE1AC pE2dvts7y+vIpNcN8ZsRUEZQTe2/9Dr9B9w4WydKrwwX23JBuyV/ezyxpll08AiLq5+B DPSlXbS3Ej6zwFDg6/quH/PgvfnmHTl5ex5pMkxCyePfFv/aIsMW2RLVHF+YaT1Bs6Du /iww== X-Received: by 10.66.192.73 with SMTP id he9mr20832463pac.88.1399643900550; Fri, 09 May 2014 06:58:20 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id iq10sm7809932pbc.14.2014.05.09.06.58.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 May 2014 06:58:19 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, gregkh@linuxfoundation.org, kishon@ti.com, mark.rutland@arm.com, robh+dt@kernel.org, balbi@ti.com, kgene.kim@samsung.com, t.figa@samsung.com, sylvester.nawrocki@gmail.com, k.debski@samsung.com, jg1.han@samsung.com, Vivek Gautam Subject: [PATCH v8 2/2] phy: exynos5-usbdrd: Add facility for VBUS supply Date: Fri, 9 May 2014 19:27:57 +0530 Message-Id: <1399643877-14528-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399643877-14528-1-git-send-email-gautam.vivek@samsung.com> References: <1399643877-14528-1-git-send-email-gautam.vivek@samsung.com> 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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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, to enable vbus supply on the port. Signed-off-by: Vivek Gautam --- Changes from v7: - Rebased on top of [PATCH v8 1/2] phy: Add new Exynos5 USB 3.0 PHY driver. drivers/phy/phy-exynos5-usbdrd.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c index 8fcdd94..76d862b 100644 --- a/drivers/phy/phy-exynos5-usbdrd.c +++ b/drivers/phy/phy-exynos5-usbdrd.c @@ -24,6 +24,7 @@ #include #include #include +#include /* Exynos USB PHY registers */ #define EXYNOS5_FSEL_9MHZ6 0x0 @@ -170,6 +171,7 @@ struct exynos5_usbdrd_phy { } phys[EXYNOS5_DRDPHYS_NUM]; u32 extrefclk; struct clk *ref_clk; + struct regulator *vbus; }; static inline @@ -438,6 +440,7 @@ static int exynos5_usbdrd_phy_exit(struct phy *phy) static int exynos5_usbdrd_phy_power_on(struct phy *phy) { + int ret; struct phy_usb_instance *inst = phy_get_drvdata(phy); struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); @@ -445,10 +448,24 @@ static int exynos5_usbdrd_phy_power_on(struct phy *phy) clk_prepare_enable(phy_drd->ref_clk); + /* Enable VBUS supply */ + if (phy_drd->vbus) { + ret = regulator_enable(phy_drd->vbus); + if (ret) { + dev_err(phy_drd->dev, "Failed to enable VBUS supply\n"); + goto fail_vbus; + } + } + /* Power-on PHY*/ inst->phy_cfg->phy_isol(inst, 0); return 0; + +fail_vbus: + clk_disable_unprepare(phy_drd->ref_clk); + + return ret; } static int exynos5_usbdrd_phy_power_off(struct phy *phy) @@ -461,6 +478,10 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy) /* Power-off the PHY */ inst->phy_cfg->phy_isol(inst, 1); + /* Disable VBUS supply */ + if (phy_drd->vbus) + regulator_disable(phy_drd->vbus); + clk_disable_unprepare(phy_drd->ref_clk); return 0; @@ -600,6 +621,17 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev) break; } + /* Get Vbus regulator */ + phy_drd->vbus = devm_regulator_get(dev, "vbus"); + if (IS_ERR(phy_drd->vbus)) { + ret = PTR_ERR(phy_drd->vbus); + if (ret == -EPROBE_DEFER) + return ret; + + dev_warn(dev, "Failed to get VBUS supply regulator\n"); + phy_drd->vbus = NULL; + } + dev_vdbg(dev, "Creating usbdrd_phy phy\n"); for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {