From: Arnd Bergmann <arnd@arndb.de>
To: Felipe Balbi <balbi@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, Andy Gross <andy.gross@linaro.org>,
David Brown <david.brown@linaro.org>,
Peter Chen <Peter.Chen@nxp.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Mark Brown <broonie@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
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 [thread overview]
Message-ID: <1463606653-325131-8-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1463606653-325131-1-git-send-email-arnd@arndb.de>
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 <arnd@arndb.de>
---
drivers/usb/phy/phy-msm-usb.c | 100 +++++++++---------------------------------
1 file changed, 21 insertions(+), 79 deletions(-)
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);
--
2.7.0
next prev parent reply other threads:[~2016-05-18 21:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-18 21:24 [RFC 0/8] usb: phy: msm: various cleanups Arnd Bergmann
2016-05-18 21:24 ` [RFC 1/8] usb: phy: move msm_hsusb.h into driver Arnd Bergmann
2016-05-18 21:24 ` [RFC 2/8] usb: ehci-msm: call usb_phy_init instead of open-coding it Arnd Bergmann
2016-05-18 21:24 ` [RFC 3/8] usb: chipidea: msm: remove open-coded phy init Arnd Bergmann
2016-05-18 21:24 ` [RFC 4/8] usb: phy: move TCSR driver into new file Arnd Bergmann
2016-05-19 19:08 ` Andy Gross
2016-05-20 12:24 ` Arnd Bergmann
2016-05-20 12:44 ` Mark Brown
2016-05-20 14:15 ` Arnd Bergmann
2016-05-18 21:24 ` [RFC 5/8] usb: phy: msm: move register definitions into driver Arnd Bergmann
2016-05-18 21:24 ` [RFC 6/8] usb: phy: qcom: use bulk regulator interfaces Arnd Bergmann
2016-05-18 21:24 ` Arnd Bergmann [this message]
2016-05-18 21:24 ` [RFC 8/8] usb: phy: msm: disable regulator for remove() Arnd Bergmann
[not found] ` <CAL411-q+B0fuFj6XDR4R21qWknnNj1Z=K8MzSyg0dZyEivk5nw@mail.gmail.com>
2016-05-19 15:28 ` [RFC 0/8] usb: phy: msm: various cleanups Andy Gross
2016-06-21 8:14 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463606653-325131-8-git-send-email-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=Peter.Chen@nxp.com \
--cc=andy.gross@linaro.org \
--cc=balbi@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=david.brown@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®