From patchwork Wed Jun 26 09:59:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Perttunen X-Patchwork-Id: 254685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 576A62C0085 for ; Wed, 26 Jun 2013 20:02:57 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751633Ab3FZKCO (ORCPT ); Wed, 26 Jun 2013 06:02:14 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:4694 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751569Ab3FZKCM (ORCPT ); Wed, 26 Jun 2013 06:02:12 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Wed, 26 Jun 2013 03:01:44 -0700 Received: from hqemhub02.nvidia.com ([172.20.12.94]) by hqnvupgp08.nvidia.com (PGP Universal service); Wed, 26 Jun 2013 03:02:10 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Wed, 26 Jun 2013 03:02:10 -0700 Received: from deemhub01.nvidia.com (10.21.69.137) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.298.1; Wed, 26 Jun 2013 03:02:10 -0700 Received: from mperttunen-lnx.Nvidia.com (10.21.65.27) by deemhub01.nvidia.com (10.21.69.137) with Microsoft SMTP Server (TLS) id 8.3.298.1; Wed, 26 Jun 2013 12:02:07 +0200 From: Mikko Perttunen To: CC: , , , , , Mikko Perttunen Subject: [PATCH 1/4] usb: phy: tegra: Add support for device tree-based vbus regulator control Date: Wed, 26 Jun 2013 12:59:38 +0300 Message-ID: <1372240781-1017-2-git-send-email-mperttunen@nvidia.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1372240781-1017-1-git-send-email-mperttunen@nvidia.com> References: <1372240781-1017-1-git-send-email-mperttunen@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org After this patch, usb vbus regulators for tegra usb phy devices can be specified with the device tree attribute vbus-supply = <&x> where x is a regulator defined in the device tree. Signed-off-by: Mikko Perttunen --- drivers/usb/phy/phy-tegra-usb.c | 24 ++++++++++++++++++++++++ include/linux/usb/tegra_usb_phy.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index d7d6bd7..6122590 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -34,6 +34,7 @@ #include #include #include +#include #define ULPI_VIEWPORT 0x170 @@ -250,12 +251,24 @@ static int utmip_pad_open(struct tegra_usb_phy *phy) return PTR_ERR(phy->pad_clk); } + phy->vbus = devm_regulator_get(phy->dev, "vbus"); + /* On some boards, the VBUS regulator doesn't need to be controlled */ + if (IS_ERR(phy->vbus)) { + if (PTR_ERR(phy->vbus) == -ENODEV) { + dev_notice(phy->dev, "no vbus regulator"); + phy->vbus = NULL; + } else { + return PTR_ERR(phy->vbus); + } + } + return 0; } static void utmip_pad_power_on(struct tegra_usb_phy *phy) { unsigned long val, flags; + int err; void __iomem *base = phy->pad_regs; clk_prepare_enable(phy->pad_clk); @@ -280,6 +293,14 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy) spin_unlock_irqrestore(&utmip_pad_lock, flags); clk_disable_unprepare(phy->pad_clk); + + if (phy->vbus) { + err = regulator_enable(phy->vbus); + if (err) + dev_err(phy->dev, + "failed to enable usb vbus regulator: %d\n", + err); + } } static int utmip_pad_power_off(struct tegra_usb_phy *phy) @@ -306,6 +327,9 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy) clk_disable_unprepare(phy->pad_clk); + if (phy->vbus) + regulator_disable(phy->vbus); + return 0; } diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h index d2ca919..2b5fa94 100644 --- a/include/linux/usb/tegra_usb_phy.h +++ b/include/linux/usb/tegra_usb_phy.h @@ -55,6 +55,7 @@ struct tegra_usb_phy { struct clk *clk; struct clk *pll_u; struct clk *pad_clk; + struct regulator *vbus; enum tegra_usb_phy_mode mode; void *config; struct usb_phy *ulpi;