[PATCH] usb: dwc2: introduce config parameter to ignore supplies vusb_a and vusb_d

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Supplies for vusb_a and vusb_d are needed only on a minority of systems
supported by the dwc2 driver (AFAIK systems with Samsung SoCs).

On all other systems this results in these harmless but annoying
warnings:

c9000000.usb supply vusb_d not found, using dummy regulator
c9000000.usb supply vusb_a not found, using dummy regulator

Introduce a configuration parameter to ignore the supplies on
systems not needing it.

Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx>
---
 drivers/usb/dwc2/core.h     |  2 ++
 drivers/usb/dwc2/params.c   |  6 ++++++
 drivers/usb/dwc2/platform.c | 30 +++++++++++++++++++-----------
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index a708e4fa..42deeeb4 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -433,6 +433,7 @@ enum dwc2_ep0_state {
  *			needed.
  *			0 - No (default)
  *			1 - Yes
+ * @needs_supplies:	Chip needs supplies (for vusb_a and vusb_d)
  * @ahb_burst:          Specifies the AHB burst.
  *                       0 - Single
  *                       1 - INCR
@@ -506,6 +507,7 @@ struct dwc2_core_params {
 	int uframe_sched;
 	int external_id_pin_ctl;
 	int hibernation;
+	bool needs_supplies;
 
 	/*
 	 * The following parameters are *only* set via device
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 014e269f..baf8b821 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -67,6 +67,7 @@ static const struct dwc2_core_params params_hi6220 = {
 	.uframe_sched			= 0,
 	.external_id_pin_ctl		= -1,
 	.hibernation			= -1,
+	.needs_supplies			= false,
 };
 
 static const struct dwc2_core_params params_bcm2835 = {
@@ -104,6 +105,7 @@ static const struct dwc2_core_params params_bcm2835 = {
 	.uframe_sched			= 0,
 	.external_id_pin_ctl		= -1,
 	.hibernation			= -1,
+	.needs_supplies			= false,
 };
 
 static const struct dwc2_core_params params_rk3066 = {
@@ -135,6 +137,7 @@ static const struct dwc2_core_params params_rk3066 = {
 	.uframe_sched			= -1,
 	.external_id_pin_ctl		= -1,
 	.hibernation			= -1,
+	.needs_supplies			= false,
 };
 
 static const struct dwc2_core_params params_ltq = {
@@ -166,6 +169,7 @@ static const struct dwc2_core_params params_ltq = {
 	.uframe_sched			= -1,
 	.external_id_pin_ctl		= -1,
 	.hibernation			= -1,
+	.needs_supplies			= false,
 };
 
 static const struct dwc2_core_params params_amlogic = {
@@ -197,6 +201,7 @@ static const struct dwc2_core_params params_amlogic = {
 	.uframe_sched			= 0,
 	.external_id_pin_ctl		= -1,
 	.hibernation			= -1,
+	.needs_supplies			= false,
 };
 
 static const struct dwc2_core_params params_default = {
@@ -234,6 +239,7 @@ static const struct dwc2_core_params params_default = {
 	.uframe_sched			= -1,
 	.external_id_pin_ctl		= -1,
 	.hibernation			= -1,
+	.needs_supplies			= true,
 };
 
 const struct of_device_id dwc2_of_match_table[] = {
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 3f59a73d..b218a72e 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -125,10 +125,12 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
 	struct platform_device *pdev = to_platform_device(hsotg->dev);
 	int ret;
 
-	ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
-				    hsotg->supplies);
-	if (ret)
-		return ret;
+	if (hsotg->params.needs_supplies) {
+		ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
+					    hsotg->supplies);
+		if (ret)
+			return ret;
+	}
 
 	if (hsotg->clk) {
 		ret = clk_prepare_enable(hsotg->clk);
@@ -185,8 +187,9 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
 	if (hsotg->clk)
 		clk_disable_unprepare(hsotg->clk);
 
-	ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
-				     hsotg->supplies);
+	if (hsotg->params.needs_supplies)
+		ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
+					     hsotg->supplies);
 
 	return ret;
 }
@@ -293,12 +296,17 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 	for (i = 0; i < ARRAY_SIZE(hsotg->supplies); i++)
 		hsotg->supplies[i].supply = dwc2_hsotg_supply_names[i];
 
-	ret = devm_regulator_bulk_get(hsotg->dev, ARRAY_SIZE(hsotg->supplies),
-				      hsotg->supplies);
-	if (ret) {
-		dev_err(hsotg->dev, "failed to request supplies: %d\n", ret);
-		return ret;
+	if (hsotg->params.needs_supplies) {
+		ret = devm_regulator_bulk_get(hsotg->dev,
+					      ARRAY_SIZE(hsotg->supplies),
+					      hsotg->supplies);
+		if (ret) {
+			dev_err(hsotg->dev,
+				"failed to request supplies: %d\n", ret);
+			return ret;
+		}
 	}
+
 	return 0;
 }
 
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux