usb: dwc3: Addition of "dr_mode" dt property.
Subsystems (3)
PATCH 1/1 usb: dwc3: Addition of "dr_mode" dt property.
This patch adds an optional parameter "dr_mode" to the dwc3 core device node. In the case the compile flag for the DWC3 controller is set to "USB_DWC3_DUAL_ROLE" a device tree could restrain to either functionality of host or gadget. In the case the device tree does not use this optional flag or specifies it superfluously to "drd" the functionality will be that of a dual role device.
--- Documentation/devicetree/bindings/usb/dwc3.txt | 3 ++- drivers/usb/dwc3/core.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/usb/dwc3.txt +2 -1
@@ -10,7 +10,8 @@ Required properties: Optional properties: - tx-fifo-resize: determines if the FIFO *has* to be reallocated. - + - dr_mode: determines the mode of core. Supported modes are "gadget", "host" + and "drd". This is usually a subnode to DWC3 glue to which it is connected. dwc3@4a030000 {
drivers/usb/dwc3/core.c +17 -4
@@ -378,7 +378,7 @@ static int dwc3_probe(struct platform_device *pdev)void *mem;u8 mode; - +char *dr_mode; mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );if (!mem) {dev_err (dev,"not enough memory\n" );
@@ -520,9 +520,22 @@ static int dwc3_probe(struct platform_device *pdev) mode =DWC3_MODE_HOST ; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode =DWC3_MODE_DEVICE ; - else - mode =DWC3_MODE_DRD ; - + else { +if (of_property_read_string (node,"dr_mode" , &dr_mode)) + mode =DWC3_MODE_DRD ; +else { +if (strcmp (dr_mode,"host" ) ==0 ) + mode =DWC3_MODE_HOST ; +else if (strcmp (dr_mode,"gadget" ) ==0 ) + mode =DWC3_MODE_DEVICE ; +else if (strcmp (dr_mode,"drd" ) ==0 ) + mode =DWC3_MODE_DRD ; +else { +dev_err (dev,"invalid dr_mode property value\n" ); + goto err2; + } + } + }switch (mode) {case DWC3_MODE_DEVICE :dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE );
Signature · 1 line
1.7.5.4
Hello.
Quoted 32 lines · Ruchika Kharwar
This patch adds an optional parameter "
dr_mode" to the dwc3 core device node. In the case the compile flag for the DWC3 controller is set to "USB_DWC3_DUAL_ROLE" a device tree could restrain to either functionality of host or gadget. In the case the device tree does not use this optional flag or specifies it superfluously to "drd" the functionality will be that of a dual role device.Signed-off-by Ruchika Kharwar <[email protected]>--- Documentation/devicetree/bindings/usb/dwc3.txt | 3 ++- drivers/usb/dwc3/core.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)Documentation/devicetree/bindings/usb/dwc3.txt +2
-1@@ -10,7 +10,8 @@ Required properties: Optional properties: - tx-fifo-resize: determines if the FIFO *has* to be reallocated. - + - dr_mode: determines the mode of core. Supported modes are "gadget", "host" + and "drd". This is usually a subnode to DWC3 glue to which it is connected. dwc3@4a030000 {drivers/usb/dwc3/core.c +0
-0
drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 381
Quoted 5 lines
drivers/usb/dwc3/core.c +1
-1@@ -378,7 +378,7 @@ static int dwc3_probe(struct platform_device *pdev)void *mem;u8 mode; - +char *dr_mode;
Please leave empty line here, after the declarations.
drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 384
Quoted 4 lines
drivers/usb/dwc3/core.c +0
-0mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );if (!mem) {dev_err (dev,"not enough memory\n" );
WBR, Sergei
A message that is not in the archive (sent off-list or not yet received): [email protected]
Fix spelling in my own comments
Quoted 64 lines · Dan Murphy
Quoted 9 lines · Ruchika Kharwar
This patch adds an optional parameter "
dr_mode" to the dwc3 core device node. In the case the compile flag for the DWC3 controller is set to "USB_DWC3_DUAL_ROLE" a device tree could restrain to either functionality of host or gadget. In the case the device tree does not use this optional flag or specifies it superfluously to "drd" the functionality will be that of a dual role device.Signed-off-by Ruchika Kharwar <[email protected]>---
Can you add patch history if this is truly a new patch to a previous submission
Quoted 9 lines
Documentation/devicetree/bindings/usb/dwc3.txt | 3 ++- drivers/usb/dwc3/core.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)Documentation/devicetree/bindings/usb/dwc3.txt +0
-0Documentation/devicetree/bindings/usb/dwc3.txt Required properties: · line 14
Quoted 6 lines
Documentation/devicetree/bindings/usb/dwc3.txt +2
-1@@ -10,7 +10,8 @@ Required properties: Optional properties: - tx-fifo-resize: determines if the FIFO *has* to be reallocated. - + - dr_mode: determines the mode of core. Supported modes are "gadget", "host" + and "drd".My previous comments still stand for this section. Nothing was addressed or commented back
Quoted 23 lines
Documentation/devicetree/bindings/usb/dwc3.txt +0
-0This is usually a subnode to DWC3 glue to which it is connected. dwc3@4a030000 {drivers/usb/dwc3/core.c +1
-4@@ -378,7 +378,7 @@ static int dwc3_probe(struct platform_device *pdev)void *mem;u8 mode; - +char *dr_mode; mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );if (!mem) {dev_err (dev,"not enough memory\n" );@@ -520,9 +520,22 @@ static int dwc3_probe(struct platform_device *pdev) mode =DWC3_MODE_HOST ; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode =DWC3_MODE_DEVICE ; - else - mode =DWC3_MODE_DRD ; -drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 532
Quoted 10 lines
drivers/usb/dwc3/core.c +10
-0+else { +if (of_property_read_string (node,"dr_mode" , &dr_mode)) + mode =DWC3_MODE_DRD ; +else { +if (strcmp (dr_mode,"host" ) ==0 ) + mode =DWC3_MODE_HOST ; +else if (strcmp (dr_mode,"gadget" ) ==0 ) + mode =DWC3_MODE_DEVICE ; +else if (strcmp (dr_mode,"drd" ) ==0 ) + mode =DWC3_MODE_DRD ;My previous comments still stand for this section. Nothing was addressed or commented back
Quoted 5 lines
https://patchwork.kernel.org/patch/2638511/
drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 535
Quoted 3 lines
drivers/usb/dwc3/core.c +3
-0+else { +dev_err (dev,"invalid dr_mode property value\n" ); + goto err2;This is still wrong. You have not initialized and of the device's
s/and/any
Quoted 9 lines
drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 541
Quoted 6 lines
drivers/usb/dwc3/core.c +3
-0+ } + } + }switch (mode) {case DWC3_MODE_DEVICE :dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE );Is this a new patch?
Subject should say v2.
Signature · 2 lines
------------------ Dan Murphy
Quoted 14 lines · Dan Murphy
Fix spelling in my own comments
Quoted 11 lines · Dan Murphy
Quoted 9 lines · Ruchika Kharwar
This patch adds an optional parameter "
dr_mode" to the dwc3 core device node. In the case the compile flag for the DWC3 controller is set to "USB_DWC3_DUAL_ROLE" a device tree could restrain to either functionality of host or gadget. In the case the device tree does not use this optional flag or specifies it superfluously to "drd" the functionality will be that of a dual role device.Signed-off-by Ruchika Kharwar <[email protected]>---
Can you add patch history if this is truly a new patch to a previous submission
Will do in the next pach submitted.
Quoted 53 lines
Quoted 53 lines
Quoted 9 lines
Documentation/devicetree/bindings/usb/dwc3.txt | 3 ++- drivers/usb/dwc3/core.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)Documentation/devicetree/bindings/usb/dwc3.txt +0
-0Documentation/devicetree/bindings/usb/dwc3.txt Required properties: · line 14
Quoted 6 lines
Documentation/devicetree/bindings/usb/dwc3.txt +2
-1@@ -10,7 +10,8 @@ Required properties: Optional properties: - tx-fifo-resize: determines if the FIFO *has* to be reallocated. - + - dr_mode: determines the mode of core. Supported modes are "gadget", "host" + and "drd".My previous comments still stand for this section. Nothing was addressed or commented back
Quoted 23 lines
Documentation/devicetree/bindings/usb/dwc3.txt +0
-0This is usually a subnode to DWC3 glue to which it is connected. dwc3@4a030000 {drivers/usb/dwc3/core.c +1
-4@@ -378,7 +378,7 @@ static int dwc3_probe(struct platform_device *pdev)void *mem;u8 mode; - +char *dr_mode; mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );if (!mem) {dev_err (dev,"not enough memory\n" );@@ -520,9 +520,22 @@ static int dwc3_probe(struct platform_device *pdev) mode =DWC3_MODE_HOST ; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode =DWC3_MODE_DEVICE ; - else - mode =DWC3_MODE_DRD ; -drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 532
Quoted 10 lines
drivers/usb/dwc3/core.c +10
-0+else { +if (of_property_read_string (node,"dr_mode" , &dr_mode)) + mode =DWC3_MODE_DRD ; +else { +if (strcmp (dr_mode,"host" ) ==0 ) + mode =DWC3_MODE_HOST ; +else if (strcmp (dr_mode,"gadget" ) ==0 ) + mode =DWC3_MODE_DEVICE ; +else if (strcmp (dr_mode,"drd" ) ==0 ) + mode =DWC3_MODE_DRD ;My previous comments still stand for this section. Nothing was addressed or commented back
Quoted 1 line
Quoted 1 line
DRD mode is the super set mode for Host and Gadget. The compile
time flag is primary. If DRD is set, the host and gadget code is compiled in.
The dr_mode property can be used *if* specified in the device
tree. A specific example may be a board could have constraints where the port could only be a host
or gadget. In that case, the dr_mode property is specified
overrides the compile flag.
Quoted 5 lines
Quoted 4 lines
drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 535
Quoted 3 lines
drivers/usb/dwc3/core.c +3
-0+else { +dev_err (dev,"invalid dr_mode property value\n" ); + goto err2;This is still wrong. You have not initialized and of the device's
s/and/any
This is correct as per 3.10-rc3. If you're looking at an older
tree you'd be right.
Quoted 8 lines
Quoted 8 lines
drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 541
Quoted 6 lines
drivers/usb/dwc3/core.c +3
-0+ } + } + }switch (mode) {case DWC3_MODE_DEVICE :dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE );Is this a new patch?
Subject should say v2.
Yes, my bad.. learning.. next patch will have it.
Quoted 2 lines
Quoted 1 line
Hi,
Quoted 57 lines · Ruchika Kharwar
This patch adds an optional parameter "
dr_mode" to the dwc3 core device node. In the case the compile flag for the DWC3 controller is set to "USB_DWC3_DUAL_ROLE" a device tree could restrain to either functionality of host or gadget. In the case the device tree does not use this optional flag or specifies it superfluously to "drd" the functionality will be that of a dual role device.Signed-off-by Ruchika Kharwar <[email protected]>--- Documentation/devicetree/bindings/usb/dwc3.txt | 3 ++- drivers/usb/dwc3/core.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)Documentation/devicetree/bindings/usb/dwc3.txt +2
-1@@ -10,7 +10,8 @@ Required properties: Optional properties: - tx-fifo-resize: determines if the FIFO *has* to be reallocated. - + - dr_mode: determines the mode of core. Supported modes are "gadget", "host" + and "drd". This is usually a subnode to DWC3 glue to which it is connected. dwc3@4a030000 {drivers/usb/dwc3/core.c +10
-4@@ -378,7 +378,7 @@ static int dwc3_probe(struct platform_device *pdev)void *mem;u8 mode; - +char *dr_mode; mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );if (!mem) {dev_err (dev,"not enough memory\n" );@@ -520,9 +520,22 @@ static int dwc3_probe(struct platform_device *pdev) mode =DWC3_MODE_HOST ; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode =DWC3_MODE_DEVICE ; - else - mode =DWC3_MODE_DRD ; - + else { +if (of_property_read_string (node,"dr_mode" , &dr_mode)) + mode =DWC3_MODE_DRD ; +else { +if (strcmp (dr_mode,"host" ) ==0 ) + mode =DWC3_MODE_HOST ; +else if (strcmp (dr_mode,"gadget" ) ==0 ) + mode =DWC3_MODE_DEVICE ; +else if (strcmp (dr_mode,"drd" ) ==0 )
drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 541
Quoted 10 lines
drivers/usb/dwc3/core.c +7
-0+ mode =DWC3_MODE_DRD ; + else { +dev_err (dev,"invalid dr_mode property value\n" ); + goto err2; + } + } + }switch (mode) {case DWC3_MODE_DEVICE :dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE );
Why not help to make use of that code?
https://patchwork.kernel.org/patch/2193321/
We currently stuck in the discussion about all possible dr_mode properties. There came up a device that is host and device capable, but not otg.
What does the property drd stand for?
Thanks,
Michael
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |