@@ -75,6 +75,29 @@ static int tegra_udc_probe(struct platform_device *pdev)
return -EINVAL;
}
+ /* check the dual mode and warn about bad configurations */
+ switch (usb_get_dr_mode(&pdev->dev)) {
+ case USB_DR_MODE_HOST:
+ dev_dbg(&pdev->dev, "dr_mode is host, tegra-udc does not support host mode\n");
+ return -EINVAL;
+
+ case USB_DR_MODE_UNKNOWN:
+ dev_warn(&pdev->dev, "dr_mode is unset or unknown, setting peripheral mode\n");
+ udc->data.dr_mode = USB_DR_MODE_PERIPHERAL;
+ break;
+
+ case USB_DR_MODE_PERIPHERAL:
+ dev_dbg(&pdev->dev, "dr_mode is set to peripheral\n");
+ udc->data.dr_mode = USB_DR_MODE_PERIPHERAL;
+ break;
+
+ case USB_DR_MODE_OTG:
+ dev_warn(&pdev->dev, "dr_mode is otg, tegra-udc does not support otg mode\n");
+ dev_warn(&pdev->dev, "setting peripheral mode, if you need host use tegra-ehci\n");
+ udc->data.dr_mode = USB_DR_MODE_PERIPHERAL;
+ break;
+ }
+
udc->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0);
if (IS_ERR(udc->phy)) {
err = PTR_ERR(udc->phy);
As the tegra-udc driver does not yet support all modes, add dr_mode checking capability. Warn about invalid configurations and explicitly assign dr_mode before handing off to the chipidea core driver. Signed-off-by: Peter Geis <pgwipeout@gmail.com> --- drivers/usb/chipidea/ci_hdrc_tegra.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)