[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200311191501.8165-6-bryan.odonoghue@linaro.org>
Date: Wed, 11 Mar 2020 19:14:59 +0000
From: Bryan O'Donoghue <bryan.odonoghue@...aro.org>
To: balbi@...nel.org, gregkh@...uxfoundation.org,
linux-usb@...r.kernel.org
Cc: linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
bjorn.andersson@...aro.org, jackp@...eaurora.org, robh@...nel.org,
Bryan O'Donoghue <bryan.odonoghue@...aro.org>,
John Stultz <john.stultz@...aro.org>,
Lee Jones <lee.jones@...aro.org>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
ShuFan Lee <shufan_lee@...htek.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
Yu Chen <chenyu56@...wei.com>,
Hans de Goede <hdegoede@...hat.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Jun Li <lijun.kernel@...il.com>,
Valentin Schneider <valentin.schneider@....com>,
devicetree@...r.kernel.org
Subject: [PATCH 5/7] usb: dwc3: Add support for usb-conn-gpio connectors
This patch adds the ability to probe and enumerate a connector based on
usb-conn-gpio.
You would use usb-conn-gpio when a regulator in your system provides VBUS
directly to the connector instead of supplying via the USB PHY.
The parent device must have the "usb-role-switch" property, so that when
the usb-conn-gpio driver calls usb_role_switch_set_role() the notification
in dwc3 will run and the block registers will be updated to match the state
detected at the connector.
Cc: John Stultz <john.stultz@...aro.org>
Cc: Bjorn Andersson <bjorn.andersson@...aro.org>
Cc: Lee Jones <lee.jones@...aro.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Rob Herring <robh+dt@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>
CC: ShuFan Lee <shufan_lee@...htek.com>
Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc: Suzuki K Poulose <suzuki.poulose@....com>
Cc: Chunfeng Yun <chunfeng.yun@...iatek.com>
Cc: Yu Chen <chenyu56@...wei.com>
Cc: Felipe Balbi <balbi@...nel.org>
Cc: Hans de Goede <hdegoede@...hat.com>
Cc: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Jun Li <lijun.kernel@...il.com>
Cc: Valentin Schneider <valentin.schneider@....com>
Cc: Jack Pham <jackp@...eaurora.org>
Cc: linux-usb@...r.kernel.org
Cc: devicetree@...r.kernel.org
Tested-by: Bjorn Andersson <bjorn.andersson@...aro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@...aro.org>
---
drivers/usb/dwc3/drd.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index ba0f6cdc4c71..2705871ec95e 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -11,6 +11,7 @@
#include <linux/of_graph.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/of_platform.h>
#include "debug.h"
#include "core.h"
@@ -539,9 +540,30 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
return 0;
}
+
+static int dwc3_register_gpio_usb_connector(struct dwc3 *dwc)
+{
+ struct device *dev = dwc->dev;
+ struct device_node *np = dev->of_node, *conn_np;
+ int ret = 0;
+
+ conn_np = of_get_child_by_name(np, "connector");
+ if (!conn_np) {
+ dev_dbg(dev, "no connector child node specified\n");
+ goto done;
+ }
+
+ if (of_device_is_compatible(conn_np, "gpio-usb-b-connector"))
+ ret = of_platform_populate(np, NULL, NULL, dev);
+done:
+ of_node_put(conn_np);
+ return ret;
+}
+
#else
#define ROLE_SWITCH 0
#define dwc3_setup_role_switch(x) 0
+#define dwc3_register_gpio_usb_connector(x) 0
#endif
int dwc3_drd_init(struct dwc3 *dwc)
@@ -557,6 +579,9 @@ int dwc3_drd_init(struct dwc3 *dwc)
ret = dwc3_setup_role_switch(dwc);
if (ret < 0)
return ret;
+ ret = dwc3_register_gpio_usb_connector(dwc);
+ if (ret < 0)
+ return ret;
} else if (dwc->edev) {
dwc->edev_nb.notifier_call = dwc3_drd_notifier;
ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
--
2.25.1
Powered by blists - more mailing lists