From patchwork Wed May 18 21:24:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102324 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2858581qge; Wed, 18 May 2016 14:25:09 -0700 (PDT) X-Received: by 10.66.7.69 with SMTP id h5mr14076481paa.11.1463606709030; Wed, 18 May 2016 14:25:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si14462644paa.218.2016.05.18.14.25.08; Wed, 18 May 2016 14:25:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754113AbcERVYp (ORCPT + 29 others); Wed, 18 May 2016 17:24:45 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:53823 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752609AbcERVYg (ORCPT ); Wed, 18 May 2016 17:24:36 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0MPt6U-1azHL91MFW-004x3V; Wed, 18 May 2016 23:24:25 +0200 From: Arnd Bergmann To: Felipe Balbi Cc: Arnd Bergmann , Andy Gross , David Brown , Peter Chen , Greg Kroah-Hartman , Alan Stern , Mark Brown , Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC 2/8] usb: ehci-msm: call usb_phy_init instead of open-coding it Date: Wed, 18 May 2016 23:24:07 +0200 Message-Id: <1463606653-325131-3-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de> References: <1463606653-325131-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:kkT5CElXYq+0+fd/fMoVS8P3XPyKTWNKeC19w4iUuv66ofbyK93 GIDMrLkp2PF15j+5TBoLYffd/f0xYA10OCMqHQEuUX2o0jkDEioO/+ZKbf86ayc9165PoKz kQHHGmNNXD1gheyPHP3tgcoTL4+ciPpXIMs/BhGwPzJiL2BXHTZPP2Ce4Vrza/ZzeCviyUG Rh5C+mRmKG79HUSy3++aw== X-UI-Out-Filterresults: notjunk:1; V01:K0:ajpHu5d6QR4=:xClLKIKfN951TjAvtR9rNV N8WXTodS03utrDkqhl+xVLbO2icTsue6iUqRo1yuHiiWOTMjRd/9eD13M6+wKy2gUb7NB6INP MPFzI0sp3brCq/UwxhOBFvXB7t2VmBBohCnCf519Scy3mLjtb/EipnZafnGywntDxRQv178sn lg1YD02aCOnty662k+iGumPPMQEdsQE/YlfR1zdv3jYLREL8wuK2OwuLsQVEs/PVmMJorPF2w 1udoCZCZDlL+uS/fPP+7dwhOGytI22AkJ5rvFxefMQPyhO9iLIvHGDF+Bc8k3tswp3tMHLuN6 aKK40ClsAJTk3WyZkyw5F34RegilukO5u7laN9vdOQyE7rd7kgs3nWDREWl07YuJgwMhL0b/2 pzfImtmVNTSGWO1XNHuj61/yH6T5X+qM8zmR6a6UFPaWRT3cQq3mCZ7GqBr8Xy6j1A6rJbp1o G/1N0itUT29BBtcJOD0Dw6WNacvsqLM4QgHUNAS5Y8MgVwbiq/rhUGzt+L+4MFVnRvGbwh75J 4rxxHk43JqsOiPft6JDl0kah65p/rxDYN57HaPXV3TlHtI74SKq917oxbjpR9DRUnP90/M3XW LxPbPZa2K1BQUHixmHQD48X/f9VPhh1KB/UVpaLSr4AmTnOFLWLJwyt1e2Y0hKCXIs8/CYuT6 FYRAjOgJ2PmdvZBXpHFAw3yOfSMD8WDpCeVeKd1xDVUWfyWggcD2alo5ky9R6AWFp5Vk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While looking at the phy-msm-usb driver, I noticed that its registers are also accessed by teh ehci-msm driver, basically duplicating part of the logic that is already present in the phy driver. This removes the duplicate code from the ehci driver and instead calls the usb_phy_init() function. I did not test this change, so please review the patch carefully and wait for a positive test result before applying. Signed-off-by: Arnd Bergmann --- drivers/usb/host/ehci-msm.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) -- 2.7.0 diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index d3afc89d00f5..4a9f31f77c46 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -30,15 +30,12 @@ #include #include #include -#include #include #include #include #include "ehci.h" -#define MSM_USB_BASE (hcd->regs) - #define DRIVER_DESC "Qualcomm On-Chip EHCI Host Controller" static const char hcd_name[] = "ehci-msm"; @@ -49,24 +46,13 @@ static int ehci_msm_reset(struct usb_hcd *hcd) struct ehci_hcd *ehci = hcd_to_ehci(hcd); int retval; - ehci->caps = USB_CAPLENGTH; + ehci->caps = hcd->regs + 0x100; hcd->has_tt = 1; retval = ehci_setup(hcd); if (retval) return retval; - /* select ULPI phy and clear other status/control bits in PORTSC */ - writel(PORTSC_PTS_ULPI, USB_PORTSC); - /* bursts of unspecified length. */ - writel(0, USB_AHBBURST); - /* Use the AHB transactor, allow posted data writes */ - writel(0x8, USB_AHBMODE); - /* Disable streaming mode and select host mode */ - writel(0x13, USB_USBMODE); - /* Disable ULPI_TX_PKT_EN_CLR_FIX which is valid only for HSIC */ - writel(readl(USB_GENCONFIG_2) & ~ULPI_TX_PKT_EN_CLR_FIX, USB_GENCONFIG_2); - return 0; } @@ -144,6 +130,7 @@ static int ehci_msm_probe(struct platform_device *pdev) pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); } else { + usb_phy_init(phy); ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); if (ret) goto put_hcd; From patchwork Wed May 18 21:24:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102318 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2858964qge; Wed, 18 May 2016 14:26:21 -0700 (PDT) X-Received: by 10.98.31.65 with SMTP id f62mr14145770pff.83.1463606780925; Wed, 18 May 2016 14:26:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8si14548728pad.28.2016.05.18.14.26.20; Wed, 18 May 2016 14:26:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754276AbcERV0E (ORCPT + 29 others); Wed, 18 May 2016 17:26:04 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:50365 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921AbcERVY4 (ORCPT ); Wed, 18 May 2016 17:24:56 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0LgtFa-1bOT9F2tza-00oDxJ; Wed, 18 May 2016 23:24:39 +0200 From: Arnd Bergmann To: Felipe Balbi Cc: Arnd Bergmann , Andy Gross , David Brown , Peter Chen , Greg Kroah-Hartman , Alan Stern , Mark Brown , Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC 3/8] usb: chipidea: msm: remove open-coded phy init Date: Wed, 18 May 2016 23:24:08 +0200 Message-Id: <1463606653-325131-4-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de> References: <1463606653-325131-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:bGlYaVsX8PlhOAPSHSWRhsbYGp5aTqdWN7R0Na1puKOhw6azz+v xfNfc34aHiqQiA1MbTk8xXP79XgOmr82YHY3faJWbbW/W8YCBwiQCgCzy4m68fWqDXpsI1w d9YH2ciIPPnEHS7VJMDv02fcIXXduzgZGxLSv6zWBS3dr5d7Xe5ttAnsTnO6HGQK0ds3ufP 0tN6LM7RVHxIkg9UaHEkg== X-UI-Out-Filterresults: notjunk:1; V01:K0:NutqGIXUyUI=:oBPIiXkLIoCLMK9LUejocC gZL4HovwBfSgHVMIqNt4kGgNJaGSLnIO7AdD2j9rVRxCQujDPKtyRgf57/U+6h/SdR7nJS11B wJMDoUHAnH8w5fH1gl7yx27C/ZGP3WrP2sWXeiRdD4ljmM312FyZNtgjTqKqeDvy3mB2ArulD xqUVWeC82lSy15mpB1wtxR5hX6eXt9meErZWzN/lVZESLjvkUoB/ostyGrdpISGvdDoQ1w0Yb bfO+Jj6tIaggp9yqtLZVJKT2kJGi2HjYtAnwiuPbe5n9FCCTfO/HfgtTVulwru8BFAjR0K60r JEojMTy1HweVDQADvUZ1m1j6y3CFhFxqImHWDGqrEzSDAhlapk5oRgo1zE/Kn9cgx2oDNiyca bXk3rFNFDxbJYpRQBwjplP9Fp1A8YtcQFvVSgGGLeDbV22zK28d1wO8dzXUfQ5ftbukfJ8nMY at4rFUE0sS/BDgj5SmL5/cnf+BjYywRM4U7SGY9BLlohVd9sa/MvVwdk8Rc9zG1SuJHFqKjuj 5MXNbDYRB/Nxr6AiD8e54lMBGXabBv/9XWidKffCD2UIoY9XhYxEJ069oV2WCMKAEa0x59XG+ 63dXm9ozpfdkqKK1sohRujcp1ISyj2Annvqx0YRHeVsd4XhU87tK9+fvA9b4xF+6fMelrO4l+ eNRWgCYLYLCKpH//8XeNU1Mc5vXpSCXwVaBmyDEVplQDNC+4EcvFWjeWgmz4cCPn0hYo= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After commit 233c7daf4eec ("usb: chipidea: msm: Initialize PHY on reset event"), we always call usb_phy_init() when receiving a CI_HDRC_CONTROLLER_RESET_EVENT event, but we also set the USB_AHBBURST and USB_AHBMODE registers to the same values that the reset function does. This removes the duplicate initialization, to avoid the dependency on the header file and the phy registers. Signed-off-by: Arnd Bergmann --- drivers/usb/chipidea/ci_hdrc_msm.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.7.0 diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 3889809fd0c4..7cae571d15f8 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -8,15 +8,12 @@ #include #include #include -#include #include #include #include #include "ci.h" -#define MSM_USB_BASE (ci->hw_bank.abs) - static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) { struct device *dev = ci->gadget.dev.parent; @@ -24,9 +21,6 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) switch (event) { case CI_HDRC_CONTROLLER_RESET_EVENT: dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n"); - writel(0, USB_AHBBURST); - /* use AHB transactor, allow posted data writes */ - writel(0x8, USB_AHBMODE); usb_phy_init(ci->usb_phy); break; case CI_HDRC_CONTROLLER_STOPPED_EVENT: From patchwork Wed May 18 21:24:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102321 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2858622qge; Wed, 18 May 2016 14:25:19 -0700 (PDT) X-Received: by 10.66.62.106 with SMTP id x10mr14090983par.136.1463606719741; Wed, 18 May 2016 14:25:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a124si14513503pfb.99.2016.05.18.14.25.19; Wed, 18 May 2016 14:25:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932413AbcERVZL (ORCPT + 29 others); Wed, 18 May 2016 17:25:11 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:51673 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752609AbcERVZF (ORCPT ); Wed, 18 May 2016 17:25:05 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0MMJXF-1avghR0SB3-007zKM; Wed, 18 May 2016 23:24:40 +0200 From: Arnd Bergmann To: Felipe Balbi Cc: Arnd Bergmann , Andy Gross , David Brown , Peter Chen , Greg Kroah-Hartman , Alan Stern , Mark Brown , Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC 4/8] usb: phy: move TCSR driver into new file Date: Wed, 18 May 2016 23:24:09 +0200 Message-Id: <1463606653-325131-5-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de> References: <1463606653-325131-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:yp5XBbQDJbnezCLMREXhL9xQMX5cvnYpt6gnufnpFty8jDtqgLm FgD4ySAztG6gHsmtG+3cAPsl/DPDx4DP9ImMrQRJC42O+gy5ot8uU4at7QOMIeuxV9oWrnm BZOIAMR6rNK6O0TAHYZQXk8q5Y5wlvkPY0oZ6i2Evpbr690vXp1gyO3Rie8jrLme5b7Sql8 wkY+v9pxLO5MQpneUIrEA== X-UI-Out-Filterresults: notjunk:1; V01:K0:0djeiHn85rk=:EBwHPLSm8P0BI8djTiAMfs ePZc3I3cNbs81bbu5UW6PRRVtf2YuS9tkaxNeTuabwEU88KPZMu8bd9XS984Mozmmz477nnzF m7VolI1cRSt5Dl1XVhVF1o8MhejQeSnIbLDWBLGV/Bs2txqDxnkGiFlBR79LuH4Efp5l7hHfG 7GrfVp4ftEcWr+bNJsgc0z3XQ06mVW2juuIowkiOSVvVVJcnbAvqFmVIyDU4PexmJKGWUsnnz 2/fHNG+c1xdA2uC9j5gClvILmvbfqU8wUk+5ml2HMGTHkB/oyc3rvGYnO5QDc8HEl4cbfOelp FJg0wsHiE9Lf+keHbypX52ThmqAmEsN8abF6ruILfe8YHNIoCMtRvgalKen5C7KQgslRKFoKg nFXwiUKMMlYoLjoZJNgIuWFq6WHm12LzEpSOpL/MTLQQEH1mLompjOuOKlVtGz5gsdOnwtpOw +SY606ZO5+w6/L4xXwpf6ZkLFeyuQbFcTYlBIQOhI4R06K7MKJvWOO4y1B0a7cMpqHmGsNf5W UFZ66E8xAvL9WDWVdpY8hRgVZofbRRK7weI9HzbV3bkv1T2ahPmNtkg3afY/BwpfLPo8HzsoN M8QQNhJ2h9CDgxwkHSltpHErvaCl9PRXrbPP6R3p9I7yx7yuv6zouuZGxFn0en5fPexbKy3li Pgis3C+1grVUgte+PV0DKL77tLqfllP/SP0JPSCKsOJ4t21ZDPG3nW/U6xJF0NNibDJw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The phy-msm-usb driver open-codes access to the Top Control and Status Register area for setting the phy mode, without any serialization or checks if these registers are actually present. This moves the hack to a more prominent location in the hope that it can eventually get cleaned up. Signed-off-by: Arnd Bergmann --- drivers/soc/qcom/Kconfig | 6 +++++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom-tcsr.c | 57 ++++++++++++++++++++++++++++++++++++++++ drivers/usb/phy/Kconfig | 1 + drivers/usb/phy/phy-msm-usb.c | 10 +++---- include/linux/soc/qcom/tcsr.h | 13 +++++++++ include/linux/usb/msm_hsusb_hw.h | 3 --- 7 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 drivers/soc/qcom/qcom-tcsr.c create mode 100644 include/linux/soc/qcom/tcsr.h -- 2.7.0 diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 461b387d03cc..37fe433d49db 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -76,3 +76,9 @@ config QCOM_WCNSS_CTRL help Client driver for the WCNSS_CTRL SMD channel, used to download nv firmware to a newly booted WCNSS chip. + +config QCOM_TCSR + bool + help + This is a driver for the "Top Control and Status Register" area, + and is used by the usb PHY driver. diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index fdd664edf0bd..672d392aa6c4 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -6,4 +6,5 @@ obj-$(CONFIG_QCOM_SMEM) += smem.o obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM) += smsm.o +obj-$(CONFIG_QCOM_TCSR) += qcom-tcsr.o obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o diff --git a/drivers/soc/qcom/qcom-tcsr.c b/drivers/soc/qcom/qcom-tcsr.c new file mode 100644 index 000000000000..fdb4ed762292 --- /dev/null +++ b/drivers/soc/qcom/qcom-tcsr.c @@ -0,0 +1,57 @@ +/* + * This abstracts the TCSR register area in Qualcomm SoCs, originally + * introduced by Tim Bird as part of the phy-msm-usb.ko device driver, + * and split out by Arnd Bergmann into a separate file. + * + * This file shouldn't really exist, since we have no way to detect + * if the TCSR actually exists in the hardcoded location, or if it + * is compatible with the version that was originally used. + * + * If the assumptions ever change, we have to come up with a better + * solution. + */ +#include +#include + +/* USB phy selector - in TCSR address range */ +#define USB2_PHY_SEL 0xfd4ab000 + +/* + * qcom_tcsr_phy_sel -- Select secondary PHY via TCSR + * + * Select the secondary PHY using the TCSR register, if phy-num=1 + * in the DTS (or phy_number is set in the platform data). The + * SOC has 2 PHYs which can be used with the OTG port, and this + * code allows configuring the correct one. + * + * Note: This resolves the problem I was seeing where I couldn't + * get the USB driver working at all on a dragonboard, from cold + * boot. This patch depends on patch 5/14 from Ivan's msm USB + * patch set. It does not use DT for the register address, as + * there's no evidence that this address changes between SoC + * versions. + * - Tim + */ +int qcom_tcsr_phy_sel(u32 val) +{ + void __iomem *phy_select; + int ret; + + phy_select = ioremap(USB2_PHY_SEL, 4); + + if (!phy_select) { + ret = -ENOMEM; + goto out; + } + /* Enable second PHY with the OTG port */ + writel(0x1, phy_select); + ret = 0; +out: + iounmap(phy_select); + return ret; +} +EXPORT_SYMBOL_GPL(qcom_tcsr_phy_sel); + +MODULE_AUTHOR("Tim Bird "); +MODULE_DESCRIPTION("Qualcomm TCSR abstraction"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index c6904742e2aa..5427f48973cf 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -143,6 +143,7 @@ config USB_MSM_OTG depends on RESET_CONTROLLER depends on EXTCON select USB_PHY + select QCOM_TCSR if ARCH_QCOM help Enable this to support the USB OTG transceiver on Qualcomm chips. It handles PHY initialization, clock management, and workarounds diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 8a34759727bb..f559d73fd7bc 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -1820,7 +1821,6 @@ static int msm_otg_probe(struct platform_device *pdev) struct resource *res; struct msm_otg *motg; struct usb_phy *phy; - void __iomem *phy_select; motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL); if (!motg) @@ -1882,13 +1882,9 @@ static int msm_otg_probe(struct platform_device *pdev) * the dwc3 driver does not set this bit in an incompatible way. */ if (motg->phy_number) { - phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4); - if (!phy_select) { - ret = -ENOMEM; + ret = qcom_tcsr_phy_sel(0x1); + if (ret) goto unregister_extcon; - } - /* Enable second PHY with the OTG port */ - writel(0x1, phy_select); } dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs); diff --git a/include/linux/soc/qcom/tcsr.h b/include/linux/soc/qcom/tcsr.h new file mode 100644 index 000000000000..7332a07806ca --- /dev/null +++ b/include/linux/soc/qcom/tcsr.h @@ -0,0 +1,13 @@ +#ifndef __QCOM_TCSR_H +#define __QCOM_TCSR_H + +#ifdef CONFIG_QCOM_TCSR +int qcom_tcsr_phy_sel(u32 val); +#else +static inline int qcom_tcsr_phy_sel(u32 val) +{ + return 0; +} +#endif + +#endif diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index 974c3796a23f..368e94389bf1 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b/include/linux/usb/msm_hsusb_hw.h @@ -16,9 +16,6 @@ #ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__ #define __LINUX_USB_GADGET_MSM72K_UDC_H__ -/* USB phy selector - in TCSR address range */ -#define USB2_PHY_SEL 0xfd4ab000 - #define USB_AHBBURST (MSM_USB_BASE + 0x0090) #define USB_AHBMODE (MSM_USB_BASE + 0x0098) #define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00a0) From patchwork Wed May 18 21:24:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102320 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2858743qge; Wed, 18 May 2016 14:25:45 -0700 (PDT) X-Received: by 10.67.14.7 with SMTP id fc7mr13985434pad.1.1463606745385; Wed, 18 May 2016 14:25:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 192si788168pfw.92.2016.05.18.14.25.45; Wed, 18 May 2016 14:25:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754212AbcERVZn (ORCPT + 29 others); Wed, 18 May 2016 17:25:43 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:52974 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754133AbcERVY4 (ORCPT ); Wed, 18 May 2016 17:24:56 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0MV0jR-1b4S9t2Acn-00YUQM; Wed, 18 May 2016 23:24:40 +0200 From: Arnd Bergmann To: Felipe Balbi Cc: Arnd Bergmann , Andy Gross , David Brown , Peter Chen , Greg Kroah-Hartman , Alan Stern , Mark Brown , Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC 5/8] usb: phy: msm: move register definitions into driver Date: Wed, 18 May 2016 23:24:10 +0200 Message-Id: <1463606653-325131-6-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de> References: <1463606653-325131-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:MJ5EIgqaXNQ/9DP2pg3t/I0j9QsUg55t3V8i7W5bcgug1+4LQWZ P0r4pz9x/I0rchqvecL3dgIVbImajfNJFmyk6jLj+Fvz9DmuTQCG+KnDzDDhJVchIHQwWd6 CQ3Po9jArh0+jzKD6YZxPrHk3Zdn/vp3RLKTa+JLt6pETE7lWy250sFgqTWmi2Ub3+tvHww BfxtPYV7Sw3dSH44T+2wg== X-UI-Out-Filterresults: notjunk:1; V01:K0:gsXdwSPVck0=:mQdMEq1jMIchhJ/qLfsmDY G8VtPl/MR31XiwmhhnSostsMa58Lj2/5J2FHG1iOlY5/zI+q8bIF7zFSD3NLtKW5/K7/TXAwI 7AOmiBFzoGY8zCarV0P41VbES553k+DynQ/ArtTijfVCEmR2KrWXNtErG6sQclLcMNACQDjPL VQiMYPzNHBRweAYA/bS71/Xc75G2hWnYAhVZFQ768JuEs1ECDOupEXb8p83X5UMvp7miTIh/M GfWoQkRq9Xj7c4Gdwehr9lm1ijhYemBKIbVgMxxJJ/qusaNLg5OlcBF/2I0cBWVbs0Tm7RheE MGeqxHurWEOOcbumProsEwPnKBopx09AdLCHIg9Ru/nwA6STwlk5ozt9xh+rPRqc9kTQJWL4y yeHj3+gMYPhcmpBmnq2Vg6RrCUt7XvPT+GGjQhkzS4UqTbkOXyzDbE9w9E1JTtW3/wjhhziL8 Y+W4zpX4hnraIkOp0uFo1rbzfy8lHcRLmrA/mUEs4ssZaDWXFy+cGsFfzismN34GIASF7nVT3 hy2Dh99mRYPT1UbTP5k1Xrp26X7OH5yfI8//dKzvnTiP29gxSqJBet1IH/h/bQapGXAjjeqOU G3mwlUhZ/4o6FTBuo2QIInKZ2VmzSbdrkHE+zEP4wollRsFoV2n/GhT+30MimtYBnEfyO4o/i rjvZHVbOlnaaxnPV8K+XVbad0Sf0BaOLBDBItsPreUfsNULO68UoG9aOyPmVcm05KUBw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The linux/usb/msm_hsusb_hw.h header is now only included by one file and can be merged into that for simplicity. Signed-off-by: Arnd Bergmann --- drivers/usb/phy/phy-msm-usb.c | 56 +++++++++++++++++++++++++++++- include/linux/usb/msm_hsusb_hw.h | 74 ---------------------------------------- 2 files changed, 55 insertions(+), 75 deletions(-) delete mode 100644 include/linux/usb/msm_hsusb_hw.h -- 2.7.0 diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index f559d73fd7bc..ea4ed6c17b00 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -46,9 +46,63 @@ #include #include #include -#include #include +#define USB_AHBBURST (MSM_USB_BASE + 0x0090) +#define USB_AHBMODE (MSM_USB_BASE + 0x0098) +#define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00a0) +#define ULPI_TX_PKT_EN_CLR_FIX BIT(19) + +#define USB_CAPLENGTH (MSM_USB_BASE + 0x0100) /* 8 bit */ + +#define USB_USBCMD (MSM_USB_BASE + 0x0140) +#define USB_PORTSC (MSM_USB_BASE + 0x0184) +#define USB_OTGSC (MSM_USB_BASE + 0x01A4) +#define USB_USBMODE (MSM_USB_BASE + 0x01A8) +#define USB_PHY_CTRL (MSM_USB_BASE + 0x0240) +#define USB_PHY_CTRL2 (MSM_USB_BASE + 0x0278) + +#define GENCONFIG_2_SESS_VLD_CTRL_EN BIT(7) +#define USBCMD_SESS_VLD_CTRL BIT(25) + +#define USBCMD_RESET 2 +#define USB_USBINTR (MSM_USB_BASE + 0x0148) + +#define PORTSC_PHCD (1 << 23) /* phy suspend mode */ +#define PORTSC_PTS_MASK (3 << 30) +#define PORTSC_PTS_ULPI (2 << 30) +#define PORTSC_PTS_SERIAL (3 << 30) + +#define USB_ULPI_VIEWPORT (MSM_USB_BASE + 0x0170) +#define ULPI_RUN (1 << 30) +#define ULPI_WRITE (1 << 29) +#define ULPI_READ (0 << 29) +#define ULPI_ADDR(n) (((n) & 255) << 16) +#define ULPI_DATA(n) ((n) & 255) +#define ULPI_DATA_READ(n) (((n) >> 8) & 255) + +/* synopsys 28nm phy registers */ +#define ULPI_PWR_CLK_MNG_REG 0x88 +#define OTG_COMP_DISABLE BIT(0) + +#define ULPI_MISC_A 0x96 +#define ULPI_MISC_A_VBUSVLDEXTSEL BIT(1) +#define ULPI_MISC_A_VBUSVLDEXT BIT(0) + +#define ASYNC_INTR_CTRL (1 << 29) /* Enable async interrupt */ +#define ULPI_STP_CTRL (1 << 30) /* Block communication with PHY */ +#define PHY_RETEN (1 << 1) /* PHY retention enable/disable */ +#define PHY_POR_ASSERT (1 << 0) /* USB2 28nm PHY POR ASSERT */ + +/* OTG definitions */ +#define OTGSC_INTSTS_MASK (0x7f << 16) +#define OTGSC_ID (1 << 8) +#define OTGSC_BSV (1 << 11) +#define OTGSC_IDIS (1 << 16) +#define OTGSC_BSVIS (1 << 19) +#define OTGSC_IDIE (1 << 24) +#define OTGSC_BSVIE (1 << 27) + /** * OTG control * diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h deleted file mode 100644 index 368e94389bf1..000000000000 --- a/include/linux/usb/msm_hsusb_hw.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2007 Google, Inc. - * Author: Brian Swetland - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__ -#define __LINUX_USB_GADGET_MSM72K_UDC_H__ - -#define USB_AHBBURST (MSM_USB_BASE + 0x0090) -#define USB_AHBMODE (MSM_USB_BASE + 0x0098) -#define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00a0) -#define ULPI_TX_PKT_EN_CLR_FIX BIT(19) - -#define USB_CAPLENGTH (MSM_USB_BASE + 0x0100) /* 8 bit */ - -#define USB_USBCMD (MSM_USB_BASE + 0x0140) -#define USB_PORTSC (MSM_USB_BASE + 0x0184) -#define USB_OTGSC (MSM_USB_BASE + 0x01A4) -#define USB_USBMODE (MSM_USB_BASE + 0x01A8) -#define USB_PHY_CTRL (MSM_USB_BASE + 0x0240) -#define USB_PHY_CTRL2 (MSM_USB_BASE + 0x0278) - -#define GENCONFIG_2_SESS_VLD_CTRL_EN BIT(7) -#define USBCMD_SESS_VLD_CTRL BIT(25) - -#define USBCMD_RESET 2 -#define USB_USBINTR (MSM_USB_BASE + 0x0148) - -#define PORTSC_PHCD (1 << 23) /* phy suspend mode */ -#define PORTSC_PTS_MASK (3 << 30) -#define PORTSC_PTS_ULPI (2 << 30) -#define PORTSC_PTS_SERIAL (3 << 30) - -#define USB_ULPI_VIEWPORT (MSM_USB_BASE + 0x0170) -#define ULPI_RUN (1 << 30) -#define ULPI_WRITE (1 << 29) -#define ULPI_READ (0 << 29) -#define ULPI_ADDR(n) (((n) & 255) << 16) -#define ULPI_DATA(n) ((n) & 255) -#define ULPI_DATA_READ(n) (((n) >> 8) & 255) - -/* synopsys 28nm phy registers */ -#define ULPI_PWR_CLK_MNG_REG 0x88 -#define OTG_COMP_DISABLE BIT(0) - -#define ULPI_MISC_A 0x96 -#define ULPI_MISC_A_VBUSVLDEXTSEL BIT(1) -#define ULPI_MISC_A_VBUSVLDEXT BIT(0) - -#define ASYNC_INTR_CTRL (1 << 29) /* Enable async interrupt */ -#define ULPI_STP_CTRL (1 << 30) /* Block communication with PHY */ -#define PHY_RETEN (1 << 1) /* PHY retention enable/disable */ -#define PHY_POR_ASSERT (1 << 0) /* USB2 28nm PHY POR ASSERT */ - -/* OTG definitions */ -#define OTGSC_INTSTS_MASK (0x7f << 16) -#define OTGSC_ID (1 << 8) -#define OTGSC_BSV (1 << 11) -#define OTGSC_IDIS (1 << 16) -#define OTGSC_BSVIS (1 << 19) -#define OTGSC_IDIE (1 << 24) -#define OTGSC_BSVIE (1 << 27) - -#endif /* __LINUX_USB_GADGET_MSM72K_UDC_H__ */ From patchwork Wed May 18 21:24:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102323 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2858582qge; Wed, 18 May 2016 14:25:09 -0700 (PDT) X-Received: by 10.66.123.105 with SMTP id lz9mr14189681pab.37.1463606709484; Wed, 18 May 2016 14:25:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si14462644paa.218.2016.05.18.14.25.09; Wed, 18 May 2016 14:25:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932180AbcERVYx (ORCPT + 29 others); Wed, 18 May 2016 17:24:53 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:58650 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752609AbcERVYv (ORCPT ); Wed, 18 May 2016 17:24:51 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0MPbr3-1az05R3pcf-004fwM; Wed, 18 May 2016 23:24:41 +0200 From: Arnd Bergmann To: Felipe Balbi Cc: Arnd Bergmann , Andy Gross , David Brown , Peter Chen , Greg Kroah-Hartman , Alan Stern , Mark Brown , Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC 6/8] usb: phy: qcom: use bulk regulator interfaces Date: Wed, 18 May 2016 23:24:11 +0200 Message-Id: <1463606653-325131-7-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de> References: <1463606653-325131-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:AlWWmv7llrkSLnTYmL/IaARqhGyDpGHPAkm8UgwHVMmZHoHsI47 VobQcNg0GeLjmoYfMx754DFB9fycQaT45QSyoOaOZZrb2WEQbFCTWOCpWSc/HBEzWeesuYI LawRx/fMg8289nuDHF1SgrkIpoJA3Wtmx8RxQaityrVFFprxDH4klkYJTEIcxwjqWuBsTFQ K7wWJJss46pcQh7Dm+/ng== X-UI-Out-Filterresults: notjunk:1; V01:K0:USzZ8bJ9//0=:+/DJZwRZl71RA0ZqvG/O+w 1AMCU7KlLJ6LxFcXsbR514ch4RSWUqJzu1o4tVlrYWhKPJ3g31w6JqyfJLo0pPK/5L1ExOw5t 6YNvGo+olIyGvDQPUR2nf/IUMRjeBeyf/B2EkGSlUbAdCH/FOoxZn9TN7X9QvcWpFjDxECuem 2rphoWyCbCmMq3LOgmrA4Hk3jXDmOIOx+L98FgG0XPaA2V7V3C42qxtbT2Bi8NF+xSFjfTw44 cAhBFPsLR/qDJXT83xixGAw2qFVWFSY6SDR37HsPnFu9E9wwfVeiP2XOafcF2ZXQ7o3G2ge9l mWor9PIHH7MrKrhKIayvm5k5wCJvnIDeDp5mWxYzJ/qokmxXMQ3aSEleHCVqxfIXuwc6ABFeI lrQxLoWL7ViVseLfHb1TN4Wd0sMHF1Qn4Of29tytm2edUIA51gDD3/DujEIs9ubszKQlek04T 6WQhUozllQ+OCDd6upaunRNj+nk+dAyyk7NKceWl++aDQ9E6OKKGj/3ZboR/Qq3joSActCZ9h asnypBAmzCZSuLCT2wANrH8PaNIkenvl5ZxhFuky3d7QeddnGg7LUH4P/1wyCguOC5XB41Tyd n4yWUBE+YycOgTbkJzg5qA6A7yTkRwy86ao4NPOpAn1+PHcF8Wx+RzDuoHgGOMNpDDDEIwneX MF47je3PtR2WQslYz/K2WivJh1X+dlyZGO2cIfWhE1rfOzTundj33THMmeBPoyMlVEjw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When build-testing the phy-msm-usb driver, we can run into a gcc warning: drivers/usb/phy/phy-msm-usb.c: In function 'msm_otg_probe': drivers/usb/phy/phy-msm-usb.c:1735:14: error: 'regs[0].consumer' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/usb/phy/phy-msm-usb.c:1736:14: error: 'regs[1].consumer' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/usb/phy/phy-msm-usb.c:1737:14: error: 'regs[2].consumer' may be used uninitialized in this function [-Werror=maybe-uninitialized] Like in the phy-qcom-8x16-usb.c driver that was reworked in 7e8ac87a4474 ("usb: phy: qcom-8x16: fix regulator API abuse"), this warning goes away once we consistently use the bulk regulator API, which also simplifies the driver a bit. This patch should not change the behavior of the driver, other than how we now first set the voltage on all regulators and then enable or disable them, rather than doing it one regulator at a time. In particular, it looks like a mistake that msm_otg_remove() disables only two of the three regulators that are enabled in msm_otg_probe(), but changing that is left for another patch. Signed-off-by: Arnd Bergmann --- drivers/usb/phy/phy-msm-usb.c | 155 ++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 90 deletions(-) -- 2.7.0 diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index ea4ed6c17b00..bdcf049e465f 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -260,9 +260,7 @@ struct msm_otg { enum usb_chg_state chg_state; enum usb_chg_type chg_type; u8 dcd_retries; - struct regulator *v3p3; - struct regulator *v1p8; - struct regulator *vddcx; + struct regulator_bulk_data regulators[3]; struct reset_control *phy_rst; struct reset_control *link_rst; @@ -303,96 +301,69 @@ enum vdd_levels { VDD_LEVEL_MAX, }; +enum regulators { + VDDCX = 0, + V3P3 = 1, + V1P8 = 2, +}; + static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) { int ret = 0; + struct regulator *vddcx = motg->regulators[VDDCX].consumer; - if (init) { - ret = regulator_set_voltage(motg->vddcx, + if (init) + ret = regulator_set_voltage(vddcx, motg->vdd_levels[VDD_LEVEL_MIN], motg->vdd_levels[VDD_LEVEL_MAX]); - if (ret) { - dev_err(motg->phy.dev, "Cannot set vddcx voltage\n"); - return ret; - } - - ret = regulator_enable(motg->vddcx); - if (ret) - dev_err(motg->phy.dev, "unable to enable hsusb vddcx\n"); - } else { - ret = regulator_set_voltage(motg->vddcx, 0, + else + ret = regulator_set_voltage(vddcx, 0, motg->vdd_levels[VDD_LEVEL_MAX]); - if (ret) - dev_err(motg->phy.dev, "Cannot set vddcx voltage\n"); - ret = regulator_disable(motg->vddcx); - if (ret) - dev_err(motg->phy.dev, "unable to disable hsusb vddcx\n"); - } + + + if (ret) + dev_err(motg->phy.dev, "Cannot set vddcx voltage\n"); return ret; } -static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) +static int msm_hsusb_ldo_init(struct msm_otg *motg) { int rc = 0; - if (init) { - rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN, - USB_PHY_3P3_VOL_MAX); - if (rc) { - dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n"); - goto exit; - } - rc = regulator_enable(motg->v3p3); - if (rc) { - dev_err(motg->phy.dev, "unable to enable the hsusb 3p3\n"); - goto exit; - } - rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN, - USB_PHY_1P8_VOL_MAX); - if (rc) { - dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n"); - goto disable_3p3; - } - rc = regulator_enable(motg->v1p8); - if (rc) { - dev_err(motg->phy.dev, "unable to enable the hsusb 1p8\n"); - goto disable_3p3; - } - - return 0; + rc = regulator_set_voltage(motg->regulators[V3P3].consumer, + USB_PHY_3P3_VOL_MIN, USB_PHY_3P3_VOL_MAX); + if (rc) { + dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n"); + goto exit; + } + rc = regulator_set_voltage(motg->regulators[V1P8].consumer, + USB_PHY_1P8_VOL_MIN, USB_PHY_1P8_VOL_MAX); + if (rc) { + dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n"); } - - regulator_disable(motg->v1p8); -disable_3p3: - regulator_disable(motg->v3p3); exit: return rc; } static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) { - int ret = 0; + int ret; + int load_v1p8 = on ? USB_PHY_1P8_HPM_LOAD : USB_PHY_1P8_LPM_LOAD; + int load_v3p3 = on ? USB_PHY_3P3_HPM_LOAD : USB_PHY_3P3_LPM_LOAD; + const char *state = on ? "HPM" : "LPM"; - if (on) { - ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_HPM_LOAD); - if (ret < 0) { - pr_err("Could not set HPM for v1p8\n"); - return ret; - } - ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_HPM_LOAD); - if (ret < 0) { - pr_err("Could not set HPM for v3p3\n"); - regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD); - return ret; - } - } else { - ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD); - if (ret < 0) - pr_err("Could not set LPM for v1p8\n"); - ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_LPM_LOAD); - if (ret < 0) - pr_err("Could not set LPM for v3p3\n"); + ret = regulator_set_load(motg->regulators[V1P8].consumer, load_v1p8); + if (ret < 0) { + pr_err("Could not set %s for v1p8\n", state); + return ret; + } + ret = regulator_set_load(motg->regulators[V3P3].consumer, load_v3p3); + if (ret < 0) { + pr_err("Could not set %s for v3p3\n", state); + regulator_set_load(motg->regulators[V1P8].consumer, + USB_PHY_1P8_LPM_LOAD); + return ret; } pr_debug("reg (%s)\n", on ? "HPM" : "LPM"); @@ -701,7 +672,8 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high) else min_vol = motg->vdd_levels[VDD_LEVEL_NONE]; - ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol); + ret = regulator_set_voltage(motg->regulators[VDDCX].consumer, + min_vol, max_vol); if (ret) { pr_err("Cannot set vddcx voltage\n"); return ret; @@ -1868,7 +1840,6 @@ static int msm_otg_reboot_notify(struct notifier_block *this, static int msm_otg_probe(struct platform_device *pdev) { - struct regulator_bulk_data regs[3]; int ret = 0; struct device_node *np = pdev->dev.of_node; struct msm_otg_platform_data *pdata; @@ -1950,18 +1921,16 @@ static int msm_otg_probe(struct platform_device *pdev) goto unregister_extcon; } - regs[0].supply = "vddcx"; - regs[1].supply = "v3p3"; - regs[2].supply = "v1p8"; + motg->regulators[VDDCX].supply = "vddcx"; + motg->regulators[V3P3].supply = "v3p3"; + motg->regulators[V1P8].supply = "v1p8"; - ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(regs), regs); + ret = devm_regulator_bulk_get(motg->phy.dev, + ARRAY_SIZE(motg->regulators), + motg->regulators); if (ret) goto unregister_extcon; - motg->vddcx = regs[0].consumer; - motg->v3p3 = regs[1].consumer; - motg->v1p8 = regs[2].consumer; - clk_set_rate(motg->clk, 60000000); clk_prepare_enable(motg->clk); @@ -1976,15 +1945,21 @@ static int msm_otg_probe(struct platform_device *pdev) goto disable_clks; } - ret = msm_hsusb_ldo_init(motg, 1); + ret = msm_hsusb_ldo_init(motg); if (ret) { dev_err(&pdev->dev, "hsusb vreg configuration failed\n"); - goto disable_vddcx; + goto disable_clks; + } + ret = regulator_bulk_enable(ARRAY_SIZE(motg->regulators), motg->regulators); + if (ret) + { + dev_err(&pdev->dev, "hsusb could not enable regulators\n"); + goto disable_clks; } ret = msm_hsusb_ldo_set_mode(motg, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg enable failed\n"); - goto disable_ldo; + goto disable_regulators; } writel(0, USB_USBINTR); @@ -1996,7 +1971,7 @@ static int msm_otg_probe(struct platform_device *pdev) "msm_otg", motg); if (ret) { dev_err(&pdev->dev, "request irq failed\n"); - goto disable_ldo; + goto disable_regulators; } phy->init = msm_phy_init; @@ -2015,7 +1990,7 @@ static int msm_otg_probe(struct platform_device *pdev) ret = usb_add_phy_dev(&motg->phy); if (ret) { dev_err(&pdev->dev, "usb_add_phy failed\n"); - goto disable_ldo; + goto disable_regulators; } platform_set_drvdata(pdev, motg); @@ -2044,10 +2019,9 @@ static int msm_otg_probe(struct platform_device *pdev) return 0; -disable_ldo: - msm_hsusb_ldo_init(motg, 0); -disable_vddcx: +disable_regulators: msm_hsusb_init_vddcx(motg, 0); + regulator_bulk_disable(ARRAY_SIZE(motg->regulators), motg->regulators); disable_clks: clk_disable_unprepare(motg->pclk); clk_disable_unprepare(motg->clk); @@ -2114,7 +2088,8 @@ static int msm_otg_remove(struct platform_device *pdev) clk_disable_unprepare(motg->clk); if (!IS_ERR(motg->core_clk)) clk_disable_unprepare(motg->core_clk); - msm_hsusb_ldo_init(motg, 0); + /* vddcx is left active */ + regulator_bulk_disable(2, &motg->regulators[V3P3]); pm_runtime_set_suspended(&pdev->dev); From patchwork Wed May 18 21:24:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102322 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2858592qge; Wed, 18 May 2016 14:25:12 -0700 (PDT) X-Received: by 10.66.232.226 with SMTP id tr2mr14235300pac.44.1463606709873; Wed, 18 May 2016 14:25:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si14462644paa.218.2016.05.18.14.25.09; Wed, 18 May 2016 14:25:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932289AbcERVY6 (ORCPT + 29 others); Wed, 18 May 2016 17:24:58 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:62822 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932087AbcERVYy (ORCPT ); Wed, 18 May 2016 17:24:54 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0Le9A8-1bLhzh1KUm-00pseR; Wed, 18 May 2016 23:24:41 +0200 From: Arnd Bergmann To: Felipe Balbi Cc: Arnd Bergmann , Andy Gross , David Brown , Peter Chen , Greg Kroah-Hartman , Alan Stern , Mark Brown , Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC 7/8] usb: phy: msm: remove v1p8/v3p3 voltage setting Date: Wed, 18 May 2016 23:24:12 +0200 Message-Id: <1463606653-325131-8-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de> References: <1463606653-325131-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:ktEDNHblQBC2SiJrRgRdcFESRxw98QD24xKSGU8CD4SagVyV2R9 W4FaZyD7fGzQXz/BnkWX/DLEk2a26ls70ZNsiB1yNUiV4ZTfleNbdVcnHxRhK0g6VZN2ApO dn2CnfhV99sO/CMCt8UdNIFfH3Tx5Crk5irKK0gtmyAngzBLCoBX8geHI4lObmZlBWp2l4/ gTNcmE5+IbPFyQuucjzug== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZZh11vhJ5a8=:W+Fn64qJr7Js88+LeBwwvm UbMjHCqE888GMIDGYnfSZbWeD7XxuS5cEh2l6RZpPbDokFhPdbQ0fFDBQ2wO4R0HCeR5OdHR2 EhfwXxFkNWw2Ayel5Fx+zcNwglsw8i7H9Tn5raFRm9RJe/d8eqwjYMxiMeAlOCgRfbbDjg+XN Y3QMXw+0vHsLHF8oC7S+ExOf5L1rTxIjt74I1QNCKvJPifpsEGyKA+JvpEQ67h+KHK7lqlOE/ DvH/dkfQPnUeL+jMhBcvAegm+yM74MFyv9uQuqBQAiGyvVmGAs8Vwc12KOU0LyBUgun0AHpvn /RVuGGOD+hU6n64LvxZXiK9VbdSvOWnGYdSbpW8f9FIcPRnkly4v4SgBdk5mr9De75KLdC9ez turQpGfKterIeVXv8NUyAmrIT7yfXa01btklBdsKKcZJb1IXUZz6UkglU4AUcS1Y/l7FLncmc dOzw2NBK52yONciKIrg0ZgrCQ01oSNWrvV/ohCx/5m3t00J6iAhCTk3EHqiJdgkjAHFycwKIu hO66RVU2p7ojJC5kyoRrtX6HRUjcriqC26AX8Radz7KMhDonnDKN03nuo3vIujwZSGJyBDtqo 3Ib83azluDgIrcgCRDu8S3FDLvsGm1n3BEDczJ96t/t3TxJpEYvVfEQGLGfsXTd3iRl3n+vep dNp58IFfY/NOoWOUj2yOJ+u8E5duhlb5kN8sgH/nfosCoC3Bu7pLLn9cxaNgI+BWlLgo= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As pointed out by Mark Brown, regulators that are always set to a fixed voltage range should be initialized from the values in the device tree rather than having client drivers set the voltage manually. This removes the msm_hsusb_ldo_init() function that adapts the voltage on the fixed 1.8v and 3.3v regulators in the MSM usb phy driver. For consistency, the msm_hsusb_init_vddcx() is also removed, and instead we just set the voltages directly where needed, reducing the code size further and making it more obvious what is actually going on here. Signed-off-by: Arnd Bergmann --- drivers/usb/phy/phy-msm-usb.c | 100 +++++++++--------------------------------- 1 file changed, 21 insertions(+), 79 deletions(-) -- 2.7.0 diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index bdcf049e465f..570fd3433937 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -281,13 +281,9 @@ struct msm_otg { #define ULPI_IO_TIMEOUT_USEC (10 * 1000) #define LINK_RESET_TIMEOUT_USEC (250 * 1000) -#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */ -#define USB_PHY_3P3_VOL_MAX 3300000 /* uV */ #define USB_PHY_3P3_HPM_LOAD 50000 /* uA */ #define USB_PHY_3P3_LPM_LOAD 4000 /* uA */ -#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */ -#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */ #define USB_PHY_1P8_HPM_LOAD 50000 /* uA */ #define USB_PHY_1P8_LPM_LOAD 4000 /* uA */ @@ -307,51 +303,18 @@ enum regulators { V1P8 = 2, }; -static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) -{ - int ret = 0; - struct regulator *vddcx = motg->regulators[VDDCX].consumer; - - if (init) - ret = regulator_set_voltage(vddcx, - motg->vdd_levels[VDD_LEVEL_MIN], - motg->vdd_levels[VDD_LEVEL_MAX]); - else - ret = regulator_set_voltage(vddcx, 0, - motg->vdd_levels[VDD_LEVEL_MAX]); - - - if (ret) - dev_err(motg->phy.dev, "Cannot set vddcx voltage\n"); - - return ret; -} - -static int msm_hsusb_ldo_init(struct msm_otg *motg) -{ - int rc = 0; - - rc = regulator_set_voltage(motg->regulators[V3P3].consumer, - USB_PHY_3P3_VOL_MIN, USB_PHY_3P3_VOL_MAX); - if (rc) { - dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n"); - goto exit; - } - rc = regulator_set_voltage(motg->regulators[V1P8].consumer, - USB_PHY_1P8_VOL_MIN, USB_PHY_1P8_VOL_MAX); - if (rc) { - dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n"); - } -exit: - return rc; -} - static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) { + int load_v1p8 = USB_PHY_1P8_LPM_LOAD; + int load_v3p3 = USB_PHY_3P3_LPM_LOAD; + const char *state = "LPM"; int ret; - int load_v1p8 = on ? USB_PHY_1P8_HPM_LOAD : USB_PHY_1P8_LPM_LOAD; - int load_v3p3 = on ? USB_PHY_3P3_HPM_LOAD : USB_PHY_3P3_LPM_LOAD; - const char *state = on ? "HPM" : "LPM"; + + if (on) { + load_v1p8 = USB_PHY_1P8_HPM_LOAD; + load_v3p3 = USB_PHY_3P3_HPM_LOAD; + state = "HPM"; + } ret = regulator_set_load(motg->regulators[V1P8].consumer, load_v1p8); if (ret < 0) { @@ -366,7 +329,7 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) return ret; } - pr_debug("reg (%s)\n", on ? "HPM" : "LPM"); + pr_debug("reg (%s)\n", state); return ret < 0 ? ret : 0; } @@ -661,29 +624,6 @@ static int msm_phy_init(struct usb_phy *phy) #ifdef CONFIG_PM -static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high) -{ - int max_vol = motg->vdd_levels[VDD_LEVEL_MAX]; - int min_vol; - int ret; - - if (high) - min_vol = motg->vdd_levels[VDD_LEVEL_MIN]; - else - min_vol = motg->vdd_levels[VDD_LEVEL_NONE]; - - ret = regulator_set_voltage(motg->regulators[VDDCX].consumer, - min_vol, max_vol); - if (ret) { - pr_err("Cannot set vddcx voltage\n"); - return ret; - } - - pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol); - - return ret; -} - static int msm_otg_suspend(struct msm_otg *motg) { struct usb_phy *phy = &motg->phy; @@ -765,7 +705,9 @@ static int msm_otg_suspend(struct msm_otg *motg) if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY && motg->pdata->otg_control == OTG_PMIC_CONTROL) { msm_hsusb_ldo_set_mode(motg, 0); - msm_hsusb_config_vddcx(motg, 0); + regulator_set_voltage(motg->regulators[VDDCX].consumer, + motg->vdd_levels[VDD_LEVEL_NONE], + motg->vdd_levels[VDD_LEVEL_MAX]); } if (device_may_wakeup(phy->dev)) @@ -805,7 +747,9 @@ static int msm_otg_resume(struct msm_otg *motg) addr = USB_PHY_CTRL2; msm_hsusb_ldo_set_mode(motg, 1); - msm_hsusb_config_vddcx(motg, 1); + regulator_set_voltage(motg->regulators[VDDCX].consumer, + motg->vdd_levels[VDD_LEVEL_MIN], + motg->vdd_levels[VDD_LEVEL_MAX]); writel(readl(addr) & ~PHY_RETEN, addr); } @@ -1939,17 +1883,14 @@ static int msm_otg_probe(struct platform_device *pdev) if (!IS_ERR(motg->core_clk)) clk_prepare_enable(motg->core_clk); - ret = msm_hsusb_init_vddcx(motg, 1); + ret = regulator_set_voltage(motg->regulators[VDDCX].consumer, + motg->vdd_levels[VDD_LEVEL_MIN], + motg->vdd_levels[VDD_LEVEL_MAX]); if (ret) { dev_err(&pdev->dev, "hsusb vddcx configuration failed\n"); goto disable_clks; } - ret = msm_hsusb_ldo_init(motg); - if (ret) { - dev_err(&pdev->dev, "hsusb vreg configuration failed\n"); - goto disable_clks; - } ret = regulator_bulk_enable(ARRAY_SIZE(motg->regulators), motg->regulators); if (ret) { @@ -2020,7 +1961,8 @@ static int msm_otg_probe(struct platform_device *pdev) return 0; disable_regulators: - msm_hsusb_init_vddcx(motg, 0); + regulator_set_voltage(motg->regulators[VDDCX].consumer, 0, + motg->vdd_levels[VDD_LEVEL_MAX]); regulator_bulk_disable(ARRAY_SIZE(motg->regulators), motg->regulators); disable_clks: clk_disable_unprepare(motg->pclk); From patchwork Wed May 18 21:24:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102319 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2858875qge; Wed, 18 May 2016 14:26:06 -0700 (PDT) X-Received: by 10.66.6.98 with SMTP id z2mr13981156paz.95.1463606766534; Wed, 18 May 2016 14:26:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fc1si14519305pab.126.2016.05.18.14.26.06; Wed, 18 May 2016 14:26:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754240AbcERV0D (ORCPT + 29 others); Wed, 18 May 2016 17:26:03 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:57383 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753536AbcERVY4 (ORCPT ); Wed, 18 May 2016 17:24:56 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0MCMK5-1aueVs30HR-0097uo; Wed, 18 May 2016 23:24:41 +0200 From: Arnd Bergmann To: Felipe Balbi Cc: Arnd Bergmann , Andy Gross , David Brown , Peter Chen , Greg Kroah-Hartman , Alan Stern , Mark Brown , Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC 8/8] usb: phy: msm: disable regulator for remove() Date: Wed, 18 May 2016 23:24:13 +0200 Message-Id: <1463606653-325131-9-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de> References: <1463606653-325131-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:hDBztP+e8k67vs6FqcSRTzxf+yXqpZlDzU0FtZpDThg7ELAQkTt z/zEJ/+VHGl29AYokm71XxuTJWHEY3C2naBZgVgM/pp89i+mlkDdIwGc2Xi1ecVqsEcrMKp hIG4tiFrMYHghe6XKCmDPPGkvtQ6Ii+QvDZSBdDjst5mIEeRs0fM6xQRNKDZqOXk0ilRF4G fDyQVs+ioHyxZQpLOSvPA== X-UI-Out-Filterresults: notjunk:1; V01:K0:gJJbgVU9ac0=:L4cjuY58zHjaPmsRXaND7C /sQOGM3yyFY7w3nTRJeN+aqdlLHEz5DGY4Jg4di8p4pdqeBktzS2gES6IYrUKm6HmCfkwKhhC nak6/yCDwdF7Y84mYmvFHoNOqKFE8psLa87jpsjQQl9G6JTSfyxAKXIliSCC0OpKgQmbPzlGu 21IO0mZsziD7skYfDGhGAUif7MXCIPXeHuUFA++QdX+kaxVwvyf0ejq6cRTgEGVkvVK8kJMJS kq/d5tSj9d9qJG6F/o+X5Zn5hJmRwrvmfxQt5jHF4VEW3EW5bX6Jga264bcazNdUXID/nyzZU ozYEKak2IOSLEhPeVEnTlWTuTBDzCMknFdirW7anlwR9Q8QtCev7y2oI4L+BiS6RWFCWo9AZs qcBMl04mslviwj11d6JfkDmWu6J8e9sMhdLRW9x7jiWYL4h54rRO0DmCPVOUDmwEcUfhAZkDL +6GWAQca0TefABrcczIA6+8tSXWjE7nEHw8qQuh3wDiM/8h8SaxnirvDqD0kDuiacI87WngRe bHt5W6dza29QP8qGm3u7BfUFfq5ecp2ttcDHwzfkxZDCTMDhEr5baT9Q/8wU70pQ+sKJCAZkl tp9YJ0PGsaoP/0L1LLUKqqN87IBzaoWGaZo5+/m5q5CJkIH9HKQuxaGSlqBb5+1sBq4jlQU24 9ms/nRAuVvdeGEJqqnPiXXM2350GwPZUjDJdb00z8+/PW1wesnur+9ulZAG7nHIgkXYw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It seems odd that this driver explicitly enables the vddcx regulator on probe along with the other regulators, but doesn't disable it again when the device is removed. This changes the remove callback to handle all three regulators the same way and disable them in the end. Signed-off-by: Arnd Bergmann --- drivers/usb/phy/phy-msm-usb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.7.0 diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 570fd3433937..48fe48e5bf6d 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -2030,8 +2030,7 @@ static int msm_otg_remove(struct platform_device *pdev) clk_disable_unprepare(motg->clk); if (!IS_ERR(motg->core_clk)) clk_disable_unprepare(motg->core_clk); - /* vddcx is left active */ - regulator_bulk_disable(2, &motg->regulators[V3P3]); + regulator_bulk_disable(ARRAY_SIZE(motg->regulators), motg->regulators); pm_runtime_set_suspended(&pdev->dev);