From patchwork Tue Apr 22 11:24:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4031211 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 818C19F391 for ; Tue, 22 Apr 2014 11:29:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57490201E4 for ; Tue, 22 Apr 2014 11:29:54 +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 D7E3B20221 for ; Tue, 22 Apr 2014 11:29:46 +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 1WcYp3-0007B4-LX; Tue, 22 Apr 2014 11:25:09 +0000 Received: from mail-pb0-x22e.google.com ([2607:f8b0:400e:c01::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WcYp1-00064J-0b for linux-arm-kernel@lists.infradead.org; Tue, 22 Apr 2014 11:25:07 +0000 Received: by mail-pb0-f46.google.com with SMTP id rq2so4834294pbb.19 for ; Tue, 22 Apr 2014 04:24:45 -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=tumnSGOWr4f3dC0RcGHb3Jaa2H3Cp5dTgH/9WVbx6TY=; b=HD7zMamtds8oQ9ngy/hOXI4zuFtLahfqcN4KvuSF5kVInmosSyz3sdpOUL02jycqCW PYLFiK/78ZnGGwKJY2nLnAZv8AQQpaaYqckLhmG6CtZSaAA0SfPFqIt1L8zIqJGhhJhg jfYTDZP0iTblHY8cTVW61rCxQoupS9zBnLDep+Tt9g816NVHjxgSiNBMOlJyv1FuwIl+ ZNBTt+G1vE1JWfOa/9GYQ1DojL54H8/pC1YOuA2QWvu678IFGi7cmsTGI0t0wFzH0G20 UgpSmx2O3H1N6bW2WpSwXSO8C9WmlfGDveJQPh/4A23zzmjSdIzaoTKDXA2rT4ygPPh3 GUww== X-Received: by 10.66.146.170 with SMTP id td10mr43906679pab.105.1398165885694; Tue, 22 Apr 2014 04:24:45 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id ss2sm200747890pab.8.2014.04.22.04.24.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 04:24:45 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, kishon@ti.com Subject: [PATCH v6 2/2] phy: exynos5-usbdrd: Add facility for VBUS supply Date: Tue, 22 Apr 2014 16:54:30 +0530 Message-Id: <1398165871-20326-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398165871-20326-1-git-send-email-gautam.vivek@samsung.com> References: <1398165871-20326-1-git-send-email-gautam.vivek@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140422_042507_107174_62DB8C07 X-CRM114-Status: GOOD ( 16.40 ) X-Spam-Score: 0.2 (/) Cc: k.debski@samsung.com, kgene.kim@samsung.com, gregkh@linuxfoundation.org, t.figa@samsung.com, linux-kernel@vger.kernel.org, balbi@ti.com, 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 --- Mistakenly sent a WIP patchset in v5 version of this patch, that gives build errors. So fixed those. Changes from v5: - Removed any mention about sclk_usbphy30* in the driver. drivers/phy/phy-exynos5-usbdrd.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c index ca1f6ab..ad94c98 100644 --- a/drivers/phy/phy-exynos5-usbdrd.c +++ b/drivers/phy/phy-exynos5-usbdrd.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Exynos USB PHY registers */ #define EXYNOS5_FSEL_9MHZ6 0x0 @@ -171,6 +172,7 @@ struct exynos5_usbdrd_phy { unsigned int extrefclk; struct clk *ref_clk; unsigned long ref_rate; + struct regulator *vbus; }; #define to_usbdrd_phy(inst) \ @@ -441,6 +443,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); @@ -448,10 +451,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) @@ -464,6 +481,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; @@ -534,7 +555,7 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev) const struct exynos5_usbdrd_phy_drvdata *drv_data; struct regmap *reg_pmu; u32 pmu_offset; - int i; + int i, ret; phy_drd = devm_kzalloc(dev, sizeof(*phy_drd), GFP_KERNEL); if (!phy_drd) @@ -577,6 +598,17 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev) return PTR_ERR(reg_pmu); } + /* Get required GPIO for vbus */ + 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; + } + if (of_property_read_u32(node, "samsung,pmu-offset", &pmu_offset)) { dev_err(dev, "Missing pmu-offset for phy isolation\n"); return -EINVAL;