Hi Felipe, On Thu, May 30, 2013 at 03:31:21PM -0500, Ruchika Kharwar wrote: > 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 <ruchika@xxxxxx> > --- > Documentation/devicetree/bindings/usb/dwc3.txt | 3 ++- > drivers/usb/dwc3/core.c | 20 +++++++++++++++++--- > 2 files changed, 19 insertions(+), 4 deletions(-) > > diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt > index 7a95c65..2f5d584 100644 > --- a/Documentation/devicetree/bindings/usb/dwc3.txt > +++ b/Documentation/devicetree/bindings/usb/dwc3.txt > @@ -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 { > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index c35d49d..05c0c8b 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -378,6 +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) { > @@ -520,9 +521,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); > -- > 1.7.5.4 this is more likely to be solved with a common property description for the gadget layer. We have some prepared parts in the latest patch series: [PATCH 1/7] USB: add devicetree helpers for determining dr_mode and phy_type http://www.spinics.net/lists/linux-usb/msg86829.html What do you think? Thanks, Michael -- 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 | -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html