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

Commit a08ae2b2 authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: xhci-msm-hsic: Add support for GDSC regulator



Global Distributed Switch Controller (GDSC) regulator is
needed to turn on and off HSIC controller.

Change-Id: Ibe73038f2d903a09d77e38bfee0da1b3eb78d92d
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent a9f87265
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ Required properties :
	"pwr_event_irq" : Interrupt generated by HSIC controller due to
	change in power state.
- <supply-name>-supply: handle to the regulator device tree node
  Required "supply-name" is "hsic-vdd-dig".
  Required "supply-name" are "hsic-vdd-dig" and "hsic-gdsc-supply".
- hsic,<gpio-name>-gpio : handle to the GPIO node, see "gpios property"
  in Documentation/devicetree/bindings/gpio/gpio.txt.
  Required "gpio-name" are "strobe" and "data".
@@ -25,6 +25,7 @@ Example MSM HSIC XHCI controller device node :
			   <0 29 0>;
		interrupt-names = "core_irq", "pwr_event_irq";
		hsic-vdd-dig-supply = <&pma8084_s2_corner>;
		hsic-gdsc-supply = <&gdsc_usb_hsic>;
		hsic,strobe-gpio = <&msmgpio 134 0x00>;
		hsic,data-gpio = <&msmgpio 135 0x00>;
		qcom,vdd-voltage-level = <1 5 7>;
+35 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ struct mxhci_hsic_hcd {
	struct clk		*cal_clk;

	struct regulator	*hsic_vddcx;
	struct regulator	*hsic_gdsc;

	struct wakeup_source	ws;

@@ -255,6 +256,33 @@ out:
	return ret;
}

/*
 * Config Global Distributed Switch Controller (GDSC)
 * to turn on/off HSIC controller
 */
static int mxhci_msm_config_gdsc(struct mxhci_hsic_hcd *mxhci, int on)
{
	int ret = 0;

	if (!mxhci->hsic_gdsc) {
		mxhci->hsic_gdsc = devm_regulator_get(mxhci->dev, "hsic-gdsc");
			if (IS_ERR(mxhci->hsic_gdsc))
				return PTR_ERR(mxhci->hsic_gdsc);
	}

	if (on) {
		ret = regulator_enable(mxhci->hsic_gdsc);
		if (ret) {
			dev_err(mxhci->dev, "unable to enable hsic gdsc\n");
			return ret;
		}
	} else {
		regulator_disable(mxhci->hsic_gdsc);
	}

	return 0;
}

static int mxhci_hsic_config_gpios(struct mxhci_hsic_hcd *mxhci)
{
	int rc = 0;
@@ -655,6 +683,12 @@ static int mxhci_hsic_probe(struct platform_device *pdev)
		goto put_hcd;
	}

	ret = mxhci_msm_config_gdsc(mxhci, 1);
	if (ret) {
		dev_err(&pdev->dev, "unable to configure hsic gdsc\n");
		goto put_hcd;
	}

	ret = mxhci_hsic_init_clocks(mxhci, 1);
	if (ret) {
		dev_err(&pdev->dev, "unable to initialize clocks\n");
@@ -808,6 +842,7 @@ static int mxhci_hsic_remove(struct platform_device *pdev)
	device_init_wakeup(&pdev->dev, 0);
	mxhci_hsic_init_vddcx(mxhci, 0);
	mxhci_hsic_init_clocks(mxhci, 0);
	mxhci_msm_config_gdsc(mxhci, 0);
	wakeup_source_trash(&mxhci->ws);
	usb_put_hcd(hcd);