From 691962d1593a16d5c8c9a5bb60b586ac3e54acc8 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 13 Jun 2013 17:59:57 +0300 Subject: 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 Signed-off-by: Alexander Shishkin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/core.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'drivers/usb/chipidea') 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) 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"); -- cgit v1.2.3