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

Commit b4008bc2 authored by Jack Pham's avatar Jack Pham
Browse files

usb: dwc3: of-simple: add support for GDSC regulator



On QCOM platforms, the GDSC regulator is required to be enabled
prior to enabling the clocks. Add support for this optional
regulator.

Change-Id: Ic9484af727e8a7176521e9366e38d852c7747995
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 83569191
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -29,11 +29,13 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>

struct dwc3_of_simple {
	struct device		*dev;
	struct clk		**clks;
	int			num_clocks;
	struct regulator	*gdsc;
};

static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count)
@@ -96,6 +98,17 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
	platform_set_drvdata(pdev, simple);
	simple->dev = dev;

	simple->gdsc = devm_regulator_get(dev, "USB3_GDSC");
	if (IS_ERR(simple->gdsc)) {
		simple->gdsc = NULL;
	} else {
		ret = regulator_enable(simple->gdsc);
		if (ret) {
			dev_err(dev, "unable to enable usb3 gdsc\n");
			return ret;
		}
	}

	ret = dwc3_of_simple_clk_init(simple, of_clk_get_parent_count(np));
	if (ret)
		return ret;
@@ -128,6 +141,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev)
		clk_put(simple->clks[i]);
	}

	if (simple->gdsc)
		regulator_disable(simple->gdsc);

	of_platform_depopulate(dev);

	pm_runtime_put_sync(dev);