* [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property @ 2012-06-27 12:21 Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 1/3] usb: chipidea: pci: make platformdata static Marc Kleine-Budde ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 12:21 UTC (permalink / raw) To: linux-arm-kernel Hello, while hacking on the chipidea driver, I fixed the error path in the udc part of the chipidea driver. Further I added the possibility to limit the driver to host or device only mode. It's possible via platformdata and device tree. For dt I selected the dr_role property which is already used for other dual role usb drivers. regards, Marc ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] usb: chipidea: pci: make platformdata static 2012-06-27 12:21 [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Marc Kleine-Budde @ 2012-06-27 12:21 ` Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 2/3] usb: chipidea: udc: fix error path in udc_start() Marc Kleine-Budde ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 12:21 UTC (permalink / raw) To: linux-arm-kernel Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- drivers/usb/chipidea/ci13xxx_pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/chipidea/ci13xxx_pci.c b/drivers/usb/chipidea/ci13xxx_pci.c index 918e149..9f5c171 100644 --- a/drivers/usb/chipidea/ci13xxx_pci.c +++ b/drivers/usb/chipidea/ci13xxx_pci.c @@ -23,17 +23,17 @@ /****************************************************************************** * PCI block *****************************************************************************/ -struct ci13xxx_platform_data pci_platdata = { +static struct ci13xxx_platform_data pci_platdata = { .name = UDC_DRIVER_NAME, .capoffset = DEF_CAPOFFSET, }; -struct ci13xxx_platform_data langwell_pci_platdata = { +static struct ci13xxx_platform_data langwell_pci_platdata = { .name = UDC_DRIVER_NAME, .capoffset = 0, }; -struct ci13xxx_platform_data penwell_pci_platdata = { +static struct ci13xxx_platform_data penwell_pci_platdata = { .name = UDC_DRIVER_NAME, .capoffset = 0, .power_budget = 200, -- 1.7.10 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] usb: chipidea: udc: fix error path in udc_start() 2012-06-27 12:21 [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 1/3] usb: chipidea: pci: make platformdata static Marc Kleine-Budde @ 2012-06-27 12:21 ` Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 3/3] usb: chipidea: ci13xxx-imx: add "dr_role" property to device tree bindings Marc Kleine-Budde 2012-06-27 12:42 ` [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Richard Zhao 3 siblings, 0 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 12:21 UTC (permalink / raw) To: linux-arm-kernel This patch fixes the error path of udc_start(). Now NULL is used to unset the peripheral with otg_set_peripheral(). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- drivers/usb/chipidea/udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 6d166a7..eeaeb26 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1739,7 +1739,7 @@ static int udc_start(struct ci13xxx *ci) remove_trans: if (ci->transceiver) { - otg_set_peripheral(ci->transceiver->otg, &ci->gadget); + otg_set_peripheral(ci->transceiver->otg, NULL); if (ci->global_phy) usb_put_transceiver(ci->transceiver); } -- 1.7.10 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] usb: chipidea: ci13xxx-imx: add "dr_role" property to device tree bindings 2012-06-27 12:21 [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 1/3] usb: chipidea: pci: make platformdata static Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 2/3] usb: chipidea: udc: fix error path in udc_start() Marc Kleine-Budde @ 2012-06-27 12:21 ` Marc Kleine-Budde 2012-06-27 13:11 ` Richard Zhao 2012-06-27 12:42 ` [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Richard Zhao 3 siblings, 1 reply; 9+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 12:21 UTC (permalink / raw) To: linux-arm-kernel This patch allows the device tree to limit the chipidea to host or peripheral mode only. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- .../devicetree/bindings/usb/ci13xxx-imx.txt | 4 ++ arch/arm/boot/dts/imx28.dtsi | 1 + drivers/usb/chipidea/ci13xxx_imx.c | 3 ++ drivers/usb/chipidea/core.c | 40 +++++++++++++++++--- include/linux/usb/chipidea.h | 9 +++++ 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt index 8bcd071..f55f2d5 100644 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt @@ -4,6 +4,9 @@ Required properties: - compatible: Should be "fsl,imx27-usb" - reg: Should contain registers location and length - interrupts: Should contain controller interrupt +- dr_mode: indicates the working mode for "fsl,imx27-usb" compatible + controllers. Can be "host", "peripheral", or "otg". Defaults to + "otg" if not defined. Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port @@ -17,4 +20,5 @@ usb at 02184000 { /* USB OTG */ interrupts = <0 43 0x04>; fsl,usbphy = <&usbphy1>; fsl,vbus-power-gpios = <&gpio3 22 0>; + dr_mode= "otg"; }; diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi index 65d6ae3..9cbf9b9 100644 --- a/arch/arm/boot/dts/imx28.dtsi +++ b/arch/arm/boot/dts/imx28.dtsi @@ -467,6 +467,7 @@ interrupts = <93>; fsl,usbphy = <&usbphy0>; status = "disabled"; + dr_mode = "host"; }; usb1: usb at 80090000 { diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index efae2be..8e926fb 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -120,6 +120,9 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) *pdev->dev.dma_mask = DMA_BIT_MASK(32); dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask); } + + ci13xxx_get_dr_mode(pdev->dev.of_node, &ci13xxx_imx_platdata); + plat_ci = ci13xxx_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &ci13xxx_imx_platdata); diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 1083585..89d2cae 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -63,6 +63,7 @@ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/pm_runtime.h> +#include <linux/of_platform.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> @@ -386,6 +387,23 @@ void ci13xxx_remove_device(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(ci13xxx_remove_device); +void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata) +{ + const unsigned char *dr_mode; + + dr_mode = of_get_property(of_node, "dr_mode", NULL); + if (!dr_mode) + return; + + if (!strcmp(dr_mode, "host")) + pdata->flags |= CI13XXX_DR_MODE_HOST; + else if (!strcmp(dr_mode, "peripheral")) + pdata->flags |= CI13XXX_DR_MODE_PERIPHERAL; + else if (!strcmp(dr_mode, "otg")) + pdata->flags |= CI13XXX_DR_MODE_OTG; +} +EXPORT_SYMBOL_GPL(ci13xxx_get_dr_mode); + static int __devinit ci_hdrc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -446,13 +464,23 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev) } /* initialize role(s) before the interrupt is requested */ - ret = ci_hdrc_host_init(ci); - if (ret) - dev_info(dev, "doesn't support host\n"); + /* default to otg */ + if (!(ci->platdata->flags & CI13XXX_DR_MODE_MASK)) + ci->platdata->flags |= CI13XXX_DR_MODE_OTG; + + if (ci->platdata->flags & + (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_OTG)) { + ret = ci_hdrc_host_init(ci); + if (ret) + dev_info(dev, "doesn't support host\n"); + } - ret = ci_hdrc_gadget_init(ci); - if (ret) - dev_info(dev, "doesn't support gadget\n"); + if (ci->platdata->flags & + (CI13XXX_DR_MODE_PERIPHERAL | CI13XXX_DR_MODE_OTG)) { + ret = ci_hdrc_gadget_init(ci); + if (ret) + dev_info(dev, "doesn't support gadget\n"); + } if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { dev_err(dev, "no supported roles\n"); diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 544825d..29ad908 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -19,6 +19,12 @@ struct ci13xxx_platform_data { #define CI13XXX_REQUIRE_TRANSCEIVER BIT(1) #define CI13XXX_PULLUP_ON_VBUS BIT(2) #define CI13XXX_DISABLE_STREAMING BIT(3) +#define CI13XXX_DR_MODE_HOST BIT(4) +#define CI13XXX_DR_MODE_PERIPHERAL BIT(5) +#define CI13XXX_DR_MODE_OTG BIT(6) +#define CI13XXX_DR_MODE_MASK \ + (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_PERIPHERAL | \ + CI13XXX_DR_MODE_OTG) #define CI13XXX_CONTROLLER_RESET_EVENT 0 #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 @@ -35,4 +41,7 @@ struct platform_device *ci13xxx_add_device(struct device *dev, /* Remove ci13xxx device */ void ci13xxx_remove_device(struct platform_device *pdev); +/* Parse of-tree "dr_mode" property */ +void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata); + #endif -- 1.7.10 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] usb: chipidea: ci13xxx-imx: add "dr_role" property to device tree bindings 2012-06-27 12:21 ` [PATCH 3/3] usb: chipidea: ci13xxx-imx: add "dr_role" property to device tree bindings Marc Kleine-Budde @ 2012-06-27 13:11 ` Richard Zhao 2012-06-27 13:21 ` Marc Kleine-Budde 0 siblings, 1 reply; 9+ messages in thread From: Richard Zhao @ 2012-06-27 13:11 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jun 27, 2012 at 02:21:50PM +0200, Marc Kleine-Budde wrote: > This patch allows the device tree to limit the chipidea to host or > peripheral mode only. > > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> > --- > .../devicetree/bindings/usb/ci13xxx-imx.txt | 4 ++ > arch/arm/boot/dts/imx28.dtsi | 1 + > drivers/usb/chipidea/ci13xxx_imx.c | 3 ++ > drivers/usb/chipidea/core.c | 40 +++++++++++++++++--- > include/linux/usb/chipidea.h | 9 +++++ > 5 files changed, 51 insertions(+), 6 deletions(-) > > diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > index 8bcd071..f55f2d5 100644 > --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > @@ -4,6 +4,9 @@ Required properties: > - compatible: Should be "fsl,imx27-usb" > - reg: Should contain registers location and length > - interrupts: Should contain controller interrupt > +- dr_mode: indicates the working mode for "fsl,imx27-usb" compatible ^^^^^^^^^^^^^ The word seems redundant? > + controllers. Can be "host", "peripheral", or "otg". Defaults to > + "otg" if not defined. How about fsl,force-role = "host" or "gadget" ? or fsl,force-host and fsl,force-gadget properties. If you're trying to make it generic, do anyone else have the case besides imx? > > Optional properties: > - fsl,usbphy: phandler of usb phy that connects to the only one port > @@ -17,4 +20,5 @@ usb at 02184000 { /* USB OTG */ > interrupts = <0 43 0x04>; > fsl,usbphy = <&usbphy1>; > fsl,vbus-power-gpios = <&gpio3 22 0>; > + dr_mode= "otg"; > }; > diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi > index 65d6ae3..9cbf9b9 100644 > --- a/arch/arm/boot/dts/imx28.dtsi > +++ b/arch/arm/boot/dts/imx28.dtsi You can not put arch/ part in the same patch. > @@ -467,6 +467,7 @@ > interrupts = <93>; > fsl,usbphy = <&usbphy0>; > status = "disabled"; > + dr_mode = "host"; > }; > > usb1: usb at 80090000 { > diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c > index efae2be..8e926fb 100644 > --- a/drivers/usb/chipidea/ci13xxx_imx.c > +++ b/drivers/usb/chipidea/ci13xxx_imx.c > @@ -120,6 +120,9 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) > *pdev->dev.dma_mask = DMA_BIT_MASK(32); > dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask); > } > + > + ci13xxx_get_dr_mode(pdev->dev.of_node, &ci13xxx_imx_platdata); > + > plat_ci = ci13xxx_add_device(&pdev->dev, > pdev->resource, pdev->num_resources, > &ci13xxx_imx_platdata); > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c > index 1083585..89d2cae 100644 > --- a/drivers/usb/chipidea/core.c > +++ b/drivers/usb/chipidea/core.c > @@ -63,6 +63,7 @@ > #include <linux/kernel.h> > #include <linux/slab.h> > #include <linux/pm_runtime.h> > +#include <linux/of_platform.h> It makes core code depends on of. Do you really mean it? Thanks Richard > #include <linux/usb/ch9.h> > #include <linux/usb/gadget.h> > #include <linux/usb/otg.h> > @@ -386,6 +387,23 @@ void ci13xxx_remove_device(struct platform_device *pdev) > } > EXPORT_SYMBOL_GPL(ci13xxx_remove_device); > > +void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata) > +{ > + const unsigned char *dr_mode; > + > + dr_mode = of_get_property(of_node, "dr_mode", NULL); > + if (!dr_mode) > + return; > + > + if (!strcmp(dr_mode, "host")) > + pdata->flags |= CI13XXX_DR_MODE_HOST; > + else if (!strcmp(dr_mode, "peripheral")) > + pdata->flags |= CI13XXX_DR_MODE_PERIPHERAL; > + else if (!strcmp(dr_mode, "otg")) > + pdata->flags |= CI13XXX_DR_MODE_OTG; > +} > +EXPORT_SYMBOL_GPL(ci13xxx_get_dr_mode); > + > static int __devinit ci_hdrc_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -446,13 +464,23 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev) > } > > /* initialize role(s) before the interrupt is requested */ > - ret = ci_hdrc_host_init(ci); > - if (ret) > - dev_info(dev, "doesn't support host\n"); > + /* default to otg */ > + if (!(ci->platdata->flags & CI13XXX_DR_MODE_MASK)) > + ci->platdata->flags |= CI13XXX_DR_MODE_OTG; > + > + if (ci->platdata->flags & > + (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_OTG)) { > + ret = ci_hdrc_host_init(ci); > + if (ret) > + dev_info(dev, "doesn't support host\n"); > + } > > - ret = ci_hdrc_gadget_init(ci); > - if (ret) > - dev_info(dev, "doesn't support gadget\n"); > + if (ci->platdata->flags & > + (CI13XXX_DR_MODE_PERIPHERAL | CI13XXX_DR_MODE_OTG)) { > + ret = ci_hdrc_gadget_init(ci); > + if (ret) > + dev_info(dev, "doesn't support gadget\n"); > + } > > if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { > dev_err(dev, "no supported roles\n"); > diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h > index 544825d..29ad908 100644 > --- a/include/linux/usb/chipidea.h > +++ b/include/linux/usb/chipidea.h > @@ -19,6 +19,12 @@ struct ci13xxx_platform_data { > #define CI13XXX_REQUIRE_TRANSCEIVER BIT(1) > #define CI13XXX_PULLUP_ON_VBUS BIT(2) > #define CI13XXX_DISABLE_STREAMING BIT(3) > +#define CI13XXX_DR_MODE_HOST BIT(4) > +#define CI13XXX_DR_MODE_PERIPHERAL BIT(5) > +#define CI13XXX_DR_MODE_OTG BIT(6) > +#define CI13XXX_DR_MODE_MASK \ > + (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_PERIPHERAL | \ > + CI13XXX_DR_MODE_OTG) > > #define CI13XXX_CONTROLLER_RESET_EVENT 0 > #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 > @@ -35,4 +41,7 @@ struct platform_device *ci13xxx_add_device(struct device *dev, > /* Remove ci13xxx device */ > void ci13xxx_remove_device(struct platform_device *pdev); > > +/* Parse of-tree "dr_mode" property */ > +void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata); > + > #endif > -- > 1.7.10 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] usb: chipidea: ci13xxx-imx: add "dr_role" property to device tree bindings 2012-06-27 13:11 ` Richard Zhao @ 2012-06-27 13:21 ` Marc Kleine-Budde 0 siblings, 0 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 13:21 UTC (permalink / raw) To: linux-arm-kernel On 06/27/2012 03:11 PM, Richard Zhao wrote: > On Wed, Jun 27, 2012 at 02:21:50PM +0200, Marc Kleine-Budde wrote: >> This patch allows the device tree to limit the chipidea to host or >> peripheral mode only. >> >> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> >> --- >> .../devicetree/bindings/usb/ci13xxx-imx.txt | 4 ++ >> arch/arm/boot/dts/imx28.dtsi | 1 + >> drivers/usb/chipidea/ci13xxx_imx.c | 3 ++ >> drivers/usb/chipidea/core.c | 40 +++++++++++++++++--- >> include/linux/usb/chipidea.h | 9 +++++ >> 5 files changed, 51 insertions(+), 6 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt >> index 8bcd071..f55f2d5 100644 >> --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt >> +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt >> @@ -4,6 +4,9 @@ Required properties: >> - compatible: Should be "fsl,imx27-usb" >> - reg: Should contain registers location and length >> - interrupts: Should contain controller interrupt >> +- dr_mode: indicates the working mode for "fsl,imx27-usb" compatible > ^^^^^^^^^^^^^ > The word seems redundant? Yes, can remove it. (I reused the existing documentation from fsl-usb.txt, see below.) >> + controllers. Can be "host", "peripheral", or "otg". Defaults to >> + "otg" if not defined. > How about fsl,force-role = "host" or "gadget" ? > or fsl,force-host and fsl,force-gadget properties. > If you're trying to make it generic, do anyone else have the case > besides imx? I forgot to mention, that there are already two documented users of this property. They Both use peripheral instead of gadget. see: Documentation/devicetree/bindings/usb/tegra-usb.txt Documentation/devicetree/bindings/usb/fsl-usb.txt >> >> Optional properties: >> - fsl,usbphy: phandler of usb phy that connects to the only one port >> @@ -17,4 +20,5 @@ usb at 02184000 { /* USB OTG */ >> interrupts = <0 43 0x04>; >> fsl,usbphy = <&usbphy1>; >> fsl,vbus-power-gpios = <&gpio3 22 0>; >> + dr_mode= "otg"; >> }; >> diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi >> index 65d6ae3..9cbf9b9 100644 >> --- a/arch/arm/boot/dts/imx28.dtsi >> +++ b/arch/arm/boot/dts/imx28.dtsi > You can not put arch/ part in the same patch. Okay. >> @@ -467,6 +467,7 @@ >> interrupts = <93>; >> fsl,usbphy = <&usbphy0>; >> status = "disabled"; >> + dr_mode = "host"; >> }; >> >> usb1: usb at 80090000 { >> diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c >> index efae2be..8e926fb 100644 >> --- a/drivers/usb/chipidea/ci13xxx_imx.c >> +++ b/drivers/usb/chipidea/ci13xxx_imx.c >> @@ -120,6 +120,9 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) >> *pdev->dev.dma_mask = DMA_BIT_MASK(32); >> dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask); >> } >> + >> + ci13xxx_get_dr_mode(pdev->dev.of_node, &ci13xxx_imx_platdata); >> + >> plat_ci = ci13xxx_add_device(&pdev->dev, >> pdev->resource, pdev->num_resources, >> &ci13xxx_imx_platdata); >> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c >> index 1083585..89d2cae 100644 >> --- a/drivers/usb/chipidea/core.c >> +++ b/drivers/usb/chipidea/core.c >> @@ -63,6 +63,7 @@ >> #include <linux/kernel.h> >> #include <linux/slab.h> >> #include <linux/pm_runtime.h> >> +#include <linux/of_platform.h> > It makes core code depends on of. Do you really mean it? No. I didn't test on non of-enabled archs. However I think there are of-stubs available: http://lxr.free-electrons.com/source/include/linux/of.h#L320 Marc > > Thanks > Richard >> #include <linux/usb/ch9.h> >> #include <linux/usb/gadget.h> >> #include <linux/usb/otg.h> >> @@ -386,6 +387,23 @@ void ci13xxx_remove_device(struct platform_device *pdev) >> } >> EXPORT_SYMBOL_GPL(ci13xxx_remove_device); >> >> +void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata) >> +{ >> + const unsigned char *dr_mode; >> + >> + dr_mode = of_get_property(of_node, "dr_mode", NULL); >> + if (!dr_mode) >> + return; >> + >> + if (!strcmp(dr_mode, "host")) >> + pdata->flags |= CI13XXX_DR_MODE_HOST; >> + else if (!strcmp(dr_mode, "peripheral")) >> + pdata->flags |= CI13XXX_DR_MODE_PERIPHERAL; >> + else if (!strcmp(dr_mode, "otg")) >> + pdata->flags |= CI13XXX_DR_MODE_OTG; >> +} >> +EXPORT_SYMBOL_GPL(ci13xxx_get_dr_mode); >> + >> static int __devinit ci_hdrc_probe(struct platform_device *pdev) >> { >> struct device *dev = &pdev->dev; >> @@ -446,13 +464,23 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev) >> } >> >> /* initialize role(s) before the interrupt is requested */ >> - ret = ci_hdrc_host_init(ci); >> - if (ret) >> - dev_info(dev, "doesn't support host\n"); >> + /* default to otg */ >> + if (!(ci->platdata->flags & CI13XXX_DR_MODE_MASK)) >> + ci->platdata->flags |= CI13XXX_DR_MODE_OTG; >> + >> + if (ci->platdata->flags & >> + (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_OTG)) { >> + ret = ci_hdrc_host_init(ci); >> + if (ret) >> + dev_info(dev, "doesn't support host\n"); >> + } >> >> - ret = ci_hdrc_gadget_init(ci); >> - if (ret) >> - dev_info(dev, "doesn't support gadget\n"); >> + if (ci->platdata->flags & >> + (CI13XXX_DR_MODE_PERIPHERAL | CI13XXX_DR_MODE_OTG)) { >> + ret = ci_hdrc_gadget_init(ci); >> + if (ret) >> + dev_info(dev, "doesn't support gadget\n"); >> + } >> >> if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { >> dev_err(dev, "no supported roles\n"); >> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h >> index 544825d..29ad908 100644 >> --- a/include/linux/usb/chipidea.h >> +++ b/include/linux/usb/chipidea.h >> @@ -19,6 +19,12 @@ struct ci13xxx_platform_data { >> #define CI13XXX_REQUIRE_TRANSCEIVER BIT(1) >> #define CI13XXX_PULLUP_ON_VBUS BIT(2) >> #define CI13XXX_DISABLE_STREAMING BIT(3) >> +#define CI13XXX_DR_MODE_HOST BIT(4) >> +#define CI13XXX_DR_MODE_PERIPHERAL BIT(5) >> +#define CI13XXX_DR_MODE_OTG BIT(6) >> +#define CI13XXX_DR_MODE_MASK \ >> + (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_PERIPHERAL | \ >> + CI13XXX_DR_MODE_OTG) >> >> #define CI13XXX_CONTROLLER_RESET_EVENT 0 >> #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 >> @@ -35,4 +41,7 @@ struct platform_device *ci13xxx_add_device(struct device *dev, >> /* Remove ci13xxx device */ >> void ci13xxx_remove_device(struct platform_device *pdev); >> >> +/* Parse of-tree "dr_mode" property */ >> +void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata); >> + >> #endif >> -- >> 1.7.10 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-usb" in >> the body of a message to majordomo at vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120627/39fed723/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property 2012-06-27 12:21 [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Marc Kleine-Budde ` (2 preceding siblings ...) 2012-06-27 12:21 ` [PATCH 3/3] usb: chipidea: ci13xxx-imx: add "dr_role" property to device tree bindings Marc Kleine-Budde @ 2012-06-27 12:42 ` Richard Zhao 2012-06-27 12:49 ` Marc Kleine-Budde 3 siblings, 1 reply; 9+ messages in thread From: Richard Zhao @ 2012-06-27 12:42 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jun 27, 2012 at 02:21:47PM +0200, Marc Kleine-Budde wrote: > Hello, > > while hacking on the chipidea driver, I fixed the error path in > the udc part of the chipidea driver. Further I added the possibility > to limit the driver to host or device only mode. It's possible via > platformdata and device tree. For dt I selected the dr_role property > which is already used for other dual role usb drivers. What's it based on then? Thanks Richard > > regards, Marc > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property 2012-06-27 12:42 ` [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Richard Zhao @ 2012-06-27 12:49 ` Marc Kleine-Budde 2012-06-27 13:06 ` Marc Kleine-Budde 0 siblings, 1 reply; 9+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 12:49 UTC (permalink / raw) To: linux-arm-kernel On 06/27/2012 02:42 PM, Richard Zhao wrote: > On Wed, Jun 27, 2012 at 02:21:47PM +0200, Marc Kleine-Budde wrote: >> Hello, >> >> while hacking on the chipidea driver, I fixed the error path in >> the udc part of the chipidea driver. Further I added the possibility >> to limit the driver to host or device only mode. It's possible via >> platformdata and device tree. For dt I selected the dr_role property >> which is already used for other dual role usb drivers. > What's it based on then? Your tree: https://github.com/riczhao/kernel-imx/commits/topics/usb-driver Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120627/90b62bf5/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property 2012-06-27 12:49 ` Marc Kleine-Budde @ 2012-06-27 13:06 ` Marc Kleine-Budde 0 siblings, 0 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2012-06-27 13:06 UTC (permalink / raw) To: linux-arm-kernel On 06/27/2012 02:49 PM, Marc Kleine-Budde wrote: > On 06/27/2012 02:42 PM, Richard Zhao wrote: >> On Wed, Jun 27, 2012 at 02:21:47PM +0200, Marc Kleine-Budde wrote: >>> Hello, >>> >>> while hacking on the chipidea driver, I fixed the error path in >>> the udc part of the chipidea driver. Further I added the possibility >>> to limit the driver to host or device only mode. It's possible via >>> platformdata and device tree. For dt I selected the dr_role property >>> which is already used for other dual role usb drivers. >> What's it based on then? > > Your tree: > https://github.com/riczhao/kernel-imx/commits/topics/usb-driver If it doesn't apply, I'll resend the series. I just discovered some patches in between. Sorry. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120627/8335d551/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-06-27 13:21 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-06-27 12:21 [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 1/3] usb: chipidea: pci: make platformdata static Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 2/3] usb: chipidea: udc: fix error path in udc_start() Marc Kleine-Budde 2012-06-27 12:21 ` [PATCH 3/3] usb: chipidea: ci13xxx-imx: add "dr_role" property to device tree bindings Marc Kleine-Budde 2012-06-27 13:11 ` Richard Zhao 2012-06-27 13:21 ` Marc Kleine-Budde 2012-06-27 12:42 ` [PATCH 0/3] usb: chipidea: fix error handling and add dr_role property Richard Zhao 2012-06-27 12:49 ` Marc Kleine-Budde 2012-06-27 13:06 ` Marc Kleine-Budde
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.