Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52484e1b authored by Jack Pham's avatar Jack Pham Committed by Gerrit - the friendly Code Review server
Browse files

usb: phy: qmp: Allow specifying regulator max load from DT



The PHY may have different load requirements depending on SoC
or platform. Allow for specifying the maximum load current
requirement for both core and vdda supplies from device tree
and use this value to pass to regulator_set_load(). Otherwise
use a default of 30mA.

Change-Id: Ia993e95e998f3d617a13843ba1829f9b39f4cf1a
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 303265c6
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -110,8 +110,12 @@ Optional properties:
 - qcom,vbus-valid-override: If present, indicates VBUS pin is not connected to
 - qcom,vbus-valid-override: If present, indicates VBUS pin is not connected to
   the USB PHY and the controller must rely on external VBUS notification in
   the USB PHY and the controller must rely on external VBUS notification in
   order to manually relay the notification to the SSPHY.
   order to manually relay the notification to the SSPHY.
 - qcom,vdd-max-load-uA: If present, indicates the maximum current (in uA) the
   PHY is expected to draw from the vdd power supply.
 - qcom,core-voltage-level: This property must be a list of three integer
 - qcom,core-voltage-level: This property must be a list of three integer
   values (no, min, max) where each value represents either a voltage in
   values (no, min, max) where each value represents either a voltage in
 - qcom,core-max-load-uA: If present, indicates the maximum current (in uA) the
   PHY is expected to draw from the core power supply.
   microvolts or a value corresponding to voltage corner.
   microvolts or a value corresponding to voltage corner.
 - qcom,link-training-reset: This property indicates to start link training
 - qcom,link-training-reset: This property indicates to start link training
   timer to reset the elastic buffer based on rx equalization value.
   timer to reset the elastic buffer based on rx equalization value.
+12 −2
Original line number Original line Diff line number Diff line
@@ -118,8 +118,10 @@ struct msm_ssphy_qmp {


	struct regulator	*vdd;
	struct regulator	*vdd;
	int			vdd_levels[3]; /* none, low, high */
	int			vdd_levels[3]; /* none, low, high */
	int			vdd_max_uA;
	struct regulator	*core_ldo;
	struct regulator	*core_ldo;
	int			core_voltage_levels[3];
	int			core_voltage_levels[3];
	int			core_max_uA;
	struct clk		*ref_clk_src;
	struct clk		*ref_clk_src;
	struct clk		*ref_clk;
	struct clk		*ref_clk;
	struct clk		*aux_clk;
	struct clk		*aux_clk;
@@ -248,7 +250,7 @@ static int msm_ssusb_qmp_ldo_enable(struct msm_ssphy_qmp *phy, int on)
	if (!on)
	if (!on)
		goto disable_regulators;
		goto disable_regulators;


	rc = regulator_set_load(phy->vdd, USB_SSPHY_HPM_LOAD);
	rc = regulator_set_load(phy->vdd, phy->vdd_max_uA);
	if (rc < 0) {
	if (rc < 0) {
		dev_err(phy->phy.dev, "Unable to set HPM of %s\n", "vdd");
		dev_err(phy->phy.dev, "Unable to set HPM of %s\n", "vdd");
		return rc;
		return rc;
@@ -270,7 +272,7 @@ static int msm_ssusb_qmp_ldo_enable(struct msm_ssphy_qmp *phy, int on)
		goto unconfig_vdd;
		goto unconfig_vdd;
	}
	}


	rc = regulator_set_load(phy->core_ldo, USB_SSPHY_HPM_LOAD);
	rc = regulator_set_load(phy->core_ldo, phy->core_max_uA);
	if (rc < 0) {
	if (rc < 0) {
		dev_err(phy->phy.dev, "Unable to set HPM of %s\n", "core_ldo");
		dev_err(phy->phy.dev, "Unable to set HPM of %s\n", "core_ldo");
		goto disable_vdd;
		goto disable_vdd;
@@ -1119,6 +1121,10 @@ static int msm_ssphy_qmp_probe(struct platform_device *pdev)
		}
		}
	}
	}


	if (of_property_read_s32(dev->of_node, "qcom,core-max-load-uA",
				&phy->core_max_uA) || !phy->core_max_uA)
		phy->core_max_uA = USB_SSPHY_HPM_LOAD;

	if (of_get_property(dev->of_node, "qcom,vdd-voltage-level", &len) &&
	if (of_get_property(dev->of_node, "qcom,vdd-voltage-level", &len) &&
		len == sizeof(phy->vdd_levels)) {
		len == sizeof(phy->vdd_levels)) {
		ret = of_property_read_u32_array(dev->of_node,
		ret = of_property_read_u32_array(dev->of_node,
@@ -1135,6 +1141,10 @@ static int msm_ssphy_qmp_probe(struct platform_device *pdev)
		goto err;
		goto err;
	}
	}


	if (of_property_read_s32(dev->of_node, "qcom,vdd-max-load-uA",
				&phy->vdd_max_uA) || !phy->vdd_max_uA)
		phy->vdd_max_uA = USB_SSPHY_HPM_LOAD;

	phy->vdd = devm_regulator_get(dev, "vdd");
	phy->vdd = devm_regulator_get(dev, "vdd");
	if (IS_ERR(phy->vdd)) {
	if (IS_ERR(phy->vdd)) {
		dev_err(dev, "unable to get vdd supply\n");
		dev_err(dev, "unable to get vdd supply\n");