]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
usb: chipidea: introduce dual role mode pdata flags
authorSascha Hauer <s.hauer@pengutronix.de>
Thu, 13 Jun 2013 14:59:57 +0000 (17:59 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jun 2013 20:47:17 +0000 (13:47 -0700)
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>
Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
drivers/usb/chipidea/core.c
include/linux/usb/chipidea.h

index 184a8e0f26dcaf9cb3e2ba4609498852ed3fb899..b4b5b7906c88b0d2e06111068c9e3279e14b07a8 100644 (file)
@@ -9,6 +9,7 @@ Recommended properies:
 - phy_type: the type of the phy connected to the core. Should be one
   of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
   property the PORTSC register won't be touched
+- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
index a25f6b68550f853f5bcd6ce662436260c46c3cfb..66c6c7157bb9a820bacf325651f38bb0236fee87 100644 (file)
@@ -405,6 +405,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
        struct resource *res;
        void __iomem    *base;
        int             ret;
+       enum usb_dr_mode dr_mode;
 
        if (!dev->platform_data) {
                dev_err(dev, "platform data missing\n");
@@ -456,14 +457,25 @@ static int ci_hdrc_probe(struct platform_device *pdev)
        if (!ci->platdata->phy_mode)
                ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
 
+       if (!ci->platdata->dr_mode)
+               ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
+
+       if (ci->platdata->dr_mode == USB_DR_MODE_UNKNOWN)
+               ci->platdata->dr_mode = USB_DR_MODE_OTG;
+
+       dr_mode = ci->platdata->dr_mode;
        /* initialize role(s) before the interrupt is requested */
-       ret = ci_hdrc_host_init(ci);
-       if (ret)
-               dev_info(dev, "doesn't support host\n");
+       if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
+               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 (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
+               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");
index 1a2aa18488043741ee25ac5ab7aee502dd79d8aa..b3146476be5c362e402692323523d6eb9a7ae3e6 100644 (file)
@@ -20,7 +20,7 @@ struct ci13xxx_platform_data {
 #define CI13XXX_REQUIRE_TRANSCEIVER    BIT(1)
 #define CI13XXX_PULLUP_ON_VBUS         BIT(2)
 #define CI13XXX_DISABLE_STREAMING      BIT(3)
-
+       enum usb_dr_mode        dr_mode;
 #define CI13XXX_CONTROLLER_RESET_EVENT         0
 #define CI13XXX_CONTROLLER_STOPPED_EVENT       1
        void    (*notify_event) (struct ci13xxx *ci, unsigned event);