diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-06-13 10:59:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-17 16:47:17 -0400 |
commit | 691962d1593a16d5c8c9a5bb60b586ac3e54acc8 (patch) | |
tree | c1883ccaa32b99032b62e856b9db46e36e9c7d74 | |
parent | 40dcd0e8067b35e247f74409d79443634daf35ac (diff) |
usb: chipidea: introduce dual role mode pdata flags
Even if a chipidea core is otg capable the board may not be. This allows
to explicitly set the core to host/peripheral mode. Without these flags
the driver falls back to the old behaviour.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | Documentation/devicetree/bindings/usb/ci13xxx-imx.txt | 1 | ||||
-rw-r--r-- | drivers/usb/chipidea/core.c | 24 | ||||
-rw-r--r-- | include/linux/usb/chipidea.h | 2 |
3 files changed, 20 insertions, 7 deletions
diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt index 184a8e0f26dc..b4b5b7906c88 100644 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt | |||
@@ -9,6 +9,7 @@ Recommended properies: | |||
9 | - phy_type: the type of the phy connected to the core. Should be one | 9 | - phy_type: the type of the phy connected to the core. Should be one |
10 | of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this | 10 | of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this |
11 | property the PORTSC register won't be touched | 11 | property the PORTSC register won't be touched |
12 | - dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" | ||
12 | 13 | ||
13 | Optional properties: | 14 | Optional properties: |
14 | - fsl,usbphy: phandler of usb phy that connects to the only one port | 15 | - fsl,usbphy: phandler of usb phy that connects to the only one port |
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index a25f6b68550f..66c6c7157bb9 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c | |||
@@ -405,6 +405,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) | |||
405 | struct resource *res; | 405 | struct resource *res; |
406 | void __iomem *base; | 406 | void __iomem *base; |
407 | int ret; | 407 | int ret; |
408 | enum usb_dr_mode dr_mode; | ||
408 | 409 | ||
409 | if (!dev->platform_data) { | 410 | if (!dev->platform_data) { |
410 | dev_err(dev, "platform data missing\n"); | 411 | dev_err(dev, "platform data missing\n"); |
@@ -456,14 +457,25 @@ static int ci_hdrc_probe(struct platform_device *pdev) | |||
456 | if (!ci->platdata->phy_mode) | 457 | if (!ci->platdata->phy_mode) |
457 | ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); | 458 | ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); |
458 | 459 | ||
460 | if (!ci->platdata->dr_mode) | ||
461 | ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node); | ||
462 | |||
463 | if (ci->platdata->dr_mode == USB_DR_MODE_UNKNOWN) | ||
464 | ci->platdata->dr_mode = USB_DR_MODE_OTG; | ||
465 | |||
466 | dr_mode = ci->platdata->dr_mode; | ||
459 | /* initialize role(s) before the interrupt is requested */ | 467 | /* initialize role(s) before the interrupt is requested */ |
460 | ret = ci_hdrc_host_init(ci); | 468 | if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) { |
461 | if (ret) | 469 | ret = ci_hdrc_host_init(ci); |
462 | dev_info(dev, "doesn't support host\n"); | 470 | if (ret) |
471 | dev_info(dev, "doesn't support host\n"); | ||
472 | } | ||
463 | 473 | ||
464 | ret = ci_hdrc_gadget_init(ci); | 474 | if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) { |
465 | if (ret) | 475 | ret = ci_hdrc_gadget_init(ci); |
466 | dev_info(dev, "doesn't support gadget\n"); | 476 | if (ret) |
477 | dev_info(dev, "doesn't support gadget\n"); | ||
478 | } | ||
467 | 479 | ||
468 | if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { | 480 | if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { |
469 | dev_err(dev, "no supported roles\n"); | 481 | dev_err(dev, "no supported roles\n"); |
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 1a2aa1848804..b3146476be5c 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h | |||
@@ -20,7 +20,7 @@ struct ci13xxx_platform_data { | |||
20 | #define CI13XXX_REQUIRE_TRANSCEIVER BIT(1) | 20 | #define CI13XXX_REQUIRE_TRANSCEIVER BIT(1) |
21 | #define CI13XXX_PULLUP_ON_VBUS BIT(2) | 21 | #define CI13XXX_PULLUP_ON_VBUS BIT(2) |
22 | #define CI13XXX_DISABLE_STREAMING BIT(3) | 22 | #define CI13XXX_DISABLE_STREAMING BIT(3) |
23 | 23 | enum usb_dr_mode dr_mode; | |
24 | #define CI13XXX_CONTROLLER_RESET_EVENT 0 | 24 | #define CI13XXX_CONTROLLER_RESET_EVENT 0 |
25 | #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 | 25 | #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 |
26 | void (*notify_event) (struct ci13xxx *ci, unsigned event); | 26 | void (*notify_event) (struct ci13xxx *ci, unsigned event); |