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);