From patchwork Tue May 13 10:00:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4164991 Return-Path: X-Original-To: patchwork-linux-arm@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 5C49A9F271 for ; Tue, 13 May 2014 10:03:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78D7920364 for ; Tue, 13 May 2014 10:03:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 613AE2035C for ; Tue, 13 May 2014 10:03:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wk9WV-0007WE-2c; Tue, 13 May 2014 10:01:23 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wk9WD-0007LZ-HY for linux-arm-kernel@lists.infradead.org; Tue, 13 May 2014 10:01:06 +0000 Received: by mail-pa0-f41.google.com with SMTP id lj1so95986pab.28 for ; Tue, 13 May 2014 03:00:48 -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=nG6IeFAl4GQdLaDsjHfh6Bk5j1r23O3X2tnCucUVs64=; b=Xe95ERIMAQHZ8eC63DGJYcQ35t6Waq4OR0GHHQedVhDUh398IpJolvFe5SjPNhERxw 6uAxKaTAWSiPn0q5mJV4wmcruDW5giOqmpqfDlzQAYigIe8PTctWlDj4dSxRIe/RcT5W KWiNuhvERA82AYhpULXmo8r5NXEiZMC46++q2RrRocAYN7yDsEfoXKtSt+IDXK2B87cz iL04El+lZdZ4S0u4PRoNXAJlkf7vVZiyS32PVePQ9atgzVDJKt5RNhTXrXJ/loHo0T0Z 4V5NMvJUNOrGBmLZoLnoV+8eo1ErliU05UmDpQ7aBGWeyWK3n9U6xQ+61RQ2YNp0sN/u dFGA== X-Received: by 10.68.110.226 with SMTP id id2mr4058547pbb.40.1399975248452; Tue, 13 May 2014 03:00:48 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id xx4sm27342309pbb.51.2014.05.13.03.00.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 03:00:47 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, kishon@ti.com Subject: [PATCH v9 3/3] phy: exynos5-usbdrd: Add facility for VBUS supply Date: Tue, 13 May 2014 15:30:17 +0530 Message-Id: <1399975217-3231-4-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399975217-3231-1-git-send-email-gautam.vivek@samsung.com> References: <1399975217-3231-1-git-send-email-gautam.vivek@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140513_030105_635290_6D8E673C X-CRM114-Status: GOOD ( 15.54 ) X-Spam-Score: 0.2 (/) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, k.debski@samsung.com, kgene.kim@samsung.com, linux-doc@vger.kernel.org, gregkh@linuxfoundation.org, t.figa@samsung.com, jg1.han@samsung.com, linux-kernel@vger.kernel.org, balbi@ti.com, robh+dt@kernel.org, Vivek Gautam , sylvester.nawrocki@gmail.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 --- 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++) {