From 1974aed8292dd68f8680d92411601b5a13f600db Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Thu, 20 Apr 2017 18:52:28 -0700 Subject: [PATCH] usb: phy: qusb: Support specifying vdda33 levels from device tree The specific voltage levels for the vdda33 regulator may vary depending on the target. Add an optional device tree property to allow specifying a 3-tuple of voltages for minimum, operating and maximum voltage levels. The minimum level is used when simply powering on, whereas the operating level is used when initializing the PHY. Change-Id: Ia5d301efdb6964434a01264e7aa19421a41e98ca Signed-off-by: Jack Pham --- .../devicetree/bindings/usb/msm-phy.txt | 2 ++ drivers/usb/phy/phy-msm-qusb-v2.c | 31 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/msm-phy.txt b/Documentation/devicetree/bindings/usb/msm-phy.txt index 032f07535415..88ad24900f28 100644 --- a/Documentation/devicetree/bindings/usb/msm-phy.txt +++ b/Documentation/devicetree/bindings/usb/msm-phy.txt @@ -212,6 +212,8 @@ Optional properties: - qcom,hold-reset: Indicates that hold QUSB PHY into reset state. - qcom,phy-clk-scheme: Should be one of "cml" or "cmos" if ref_clk_addr is provided. - qcom,major-rev: provide major revision number to differentiate power up sequence. default is 2.0 + - qcom,vdda33-voltage-level: A list of three integer values (min, op, max) representing + specific voltages (in microvolts) used for the vdda33 supply. Example: qusb_phy: qusb@f9b39000 { diff --git a/drivers/usb/phy/phy-msm-qusb-v2.c b/drivers/usb/phy/phy-msm-qusb-v2.c index 6fb91134b0c5..5df091a5454b 100644 --- a/drivers/usb/phy/phy-msm-qusb-v2.c +++ b/drivers/usb/phy/phy-msm-qusb-v2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -90,6 +90,7 @@ struct qusb_phy { struct regulator *vdda18; struct regulator *vdda12; int vdd_levels[3]; /* none, low, high */ + int vdda33_levels[3]; int init_seq_len; int *qusb_phy_init_seq; int host_init_seq_len; @@ -236,8 +237,8 @@ static int qusb_phy_enable_power(struct qusb_phy *qphy, bool on, goto disable_vdda18; } - ret = regulator_set_voltage(qphy->vdda33, QUSB2PHY_3P3_VOL_MIN, - QUSB2PHY_3P3_VOL_MAX); + ret = regulator_set_voltage(qphy->vdda33, qphy->vdda33_levels[0], + qphy->vdda33_levels[2]); if (ret) { dev_err(qphy->phy.dev, "Unable to set voltage for vdda33:%d\n", ret); @@ -262,7 +263,7 @@ disable_vdda33: dev_err(qphy->phy.dev, "Unable to disable vdda33:%d\n", ret); unset_vdd33: - ret = regulator_set_voltage(qphy->vdda33, 0, QUSB2PHY_3P3_VOL_MAX); + ret = regulator_set_voltage(qphy->vdda33, 0, qphy->vdda33_levels[2]); if (ret) dev_err(qphy->phy.dev, "Unable to set (0) voltage for vdda33:%d\n", ret); @@ -455,6 +456,15 @@ static int qusb_phy_init(struct usb_phy *phy) if (ret) return ret; + /* bump up vdda33 voltage to operating level*/ + ret = regulator_set_voltage(qphy->vdda33, qphy->vdda33_levels[1], + qphy->vdda33_levels[2]); + if (ret) { + dev_err(qphy->phy.dev, + "Unable to set voltage for vdda33:%d\n", ret); + return ret; + } + qusb_phy_enable_clocks(qphy, true); /* Perform phy reset */ @@ -1016,6 +1026,19 @@ static int qusb_phy_probe(struct platform_device *pdev) return ret; } + ret = of_property_read_u32_array(dev->of_node, + "qcom,vdda33-voltage-level", + (u32 *) qphy->vdda33_levels, + ARRAY_SIZE(qphy->vdda33_levels)); + if (ret == -EINVAL) { + qphy->vdda33_levels[0] = QUSB2PHY_3P3_VOL_MIN; + qphy->vdda33_levels[1] = QUSB2PHY_3P3_VOL_MIN; + qphy->vdda33_levels[2] = QUSB2PHY_3P3_VOL_MAX; + } else if (ret) { + dev_err(dev, "error reading qcom,vdda33-voltage-level property\n"); + return ret; + } + qphy->vdd = devm_regulator_get(dev, "vdd"); if (IS_ERR(qphy->vdd)) { dev_err(dev, "unable to get vdd supply\n");