[PATCH] usb: chipidea: tegra: add dr_mode checking to tegra-udc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/usb/chipidea/ci_hdrc_tegra.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
index 12025358bb3c..8dd6f4e6cb3e 100644
--- a/drivers/usb/chipidea/ci_hdrc_tegra.c
+++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
@@ -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);
-- 
2.17.1




[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux