diff mbox series

[V2,4/8] usb: dwc3: drd: Register the eud connector child node for dwc3

Message ID bcb48839a520b8bfc9b09e7a26ba8a8459ab602d.1638430506.git.quic_schowdhu@quicinc.com
State New
Headers show
Series Add Embedded USB Debugger (EUD) driver | expand

Commit Message

Souradeep Chowdhury Dec. 2, 2021, 9:51 a.m. UTC
Register the child node for dwc3 which is the "eud_usb_connector".
The eud driver will be able to switch the usb role from device to
host and vice versa using the role switch property of dwc3 node.

Signed-off-by: Souradeep Chowdhury <quic_schowdhu@quicinc.com>
---
 drivers/usb/dwc3/drd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Souradeep Chowdhury Dec. 15, 2021, 12:06 p.m. UTC | #1
On 12/14/2021 1:33 AM, Rob Herring wrote:
> On Thu, Dec 02, 2021 at 03:21:23PM +0530, Souradeep Chowdhury wrote:
>> Register the child node for dwc3 which is the "eud_usb_connector".
>> The eud driver will be able to switch the usb role from device to
>> host and vice versa using the role switch property of dwc3 node.
>>
>> Signed-off-by: Souradeep Chowdhury <quic_schowdhu@quicinc.com>
>> ---
>>   drivers/usb/dwc3/drd.c | 26 ++++++++++++++++++++++++++
>>   1 file changed, 26 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
>> index d7f7683..b4ea55c 100644
>> --- a/drivers/usb/dwc3/drd.c
>> +++ b/drivers/usb/dwc3/drd.c
>> @@ -8,6 +8,7 @@
>>    */
>>   
>>   #include <linux/extcon.h>
>> +#include <linux/of_platform.h>
>>   #include <linux/of_graph.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/property.h>
>> @@ -164,6 +165,27 @@ static int dwc3_otg_get_irq(struct dwc3 *dwc)
>>   	return irq;
>>   }
>>   
>> +static int dwc3_register_eud(struct dwc3 *dwc)
>> +{
>> +	struct device		*dev = dwc->dev;
>> +	struct device_node	*np = dev->of_node;
>> +	int                     ret;
>> +
>> +	of_get_child_by_name(np, "eud_usb_connector");
> Connector nodes are named 'connector' or possibly 'usb-connector'. If
> you are creating an ABI with the node name, it should be documented.
> However, it's preferred to use 'compatible' for identifying nodes rather
> than a node name.
Ack.
>> +	if (!np) {
>> +		dev_dbg(dev, "no usb_connector child node specified\n");
>> +		return 0;
>> +	}
>> +
>> +	ret = of_platform_populate(np, NULL, NULL, dev);
> But why is any of this needed. The connector doesn't have a driver (I
> expect eventually we will) and the EUD device is not a child.

Ack. This can be removed as we are no longer mapping EUD as a type C 
connector.


>> +	if (ret) {
>> +		dev_err(dev, "failed to register usb_connector - %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>   void dwc3_otg_init(struct dwc3 *dwc)
>>   {
>>   	u32 reg;
>> @@ -580,6 +602,10 @@ int dwc3_drd_init(struct dwc3 *dwc)
>>   		ret = dwc3_setup_role_switch(dwc);
>>   		if (ret < 0)
>>   			return ret;
>> +
>> +		ret = dwc3_register_eud(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.7.4
>>
>>
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index d7f7683..b4ea55c 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -8,6 +8,7 @@ 
  */
 
 #include <linux/extcon.h>
+#include <linux/of_platform.h>
 #include <linux/of_graph.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
@@ -164,6 +165,27 @@  static int dwc3_otg_get_irq(struct dwc3 *dwc)
 	return irq;
 }
 
+static int dwc3_register_eud(struct dwc3 *dwc)
+{
+	struct device		*dev = dwc->dev;
+	struct device_node	*np = dev->of_node;
+	int                     ret;
+
+	of_get_child_by_name(np, "eud_usb_connector");
+	if (!np) {
+		dev_dbg(dev, "no usb_connector child node specified\n");
+		return 0;
+	}
+
+	ret = of_platform_populate(np, NULL, NULL, dev);
+	if (ret) {
+		dev_err(dev, "failed to register usb_connector - %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
 void dwc3_otg_init(struct dwc3 *dwc)
 {
 	u32 reg;
@@ -580,6 +602,10 @@  int dwc3_drd_init(struct dwc3 *dwc)
 		ret = dwc3_setup_role_switch(dwc);
 		if (ret < 0)
 			return ret;
+
+		ret = dwc3_register_eud(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,