diff mbox series

[10/13] ehci-mx6: Add OTG ID detecting by GPIO

Message ID 20200916125705.4341-11-peng.fan@nxp.com
State New
Delegated to: Marek Vasut
Headers show
Series ehci-mx6: update and fix | expand

Commit Message

Peng Fan Sept. 16, 2020, 12:57 p.m. UTC
From: Ye Li <ye.li@nxp.com>

The i.MX7ulp EVK board uses GPIO to detect ID for USB OTG0,
but when using DM USB driver, it is hard coded to use OTG ID pin.
Add a board override function that when extcon property is provided,
the function can check the GPIO to get ID.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/usb/host/ehci-mx6.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Marek Vasut Sept. 16, 2020, 1:43 p.m. UTC | #1
On 9/16/20 2:57 PM, peng.fan@nxp.com wrote:
[...]
> +int __weak board_ehci_usb_phy_mode(struct udevice *dev)
> +{
> +	return USB_INIT_HOST;
> +}
> +
>  static int ehci_usb_phy_mode(struct udevice *dev)
>  {
>  	struct usb_platdata *plat = dev_get_platdata(dev);
> @@ -634,6 +653,15 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
>  {
>  	struct usb_platdata *plat = dev_get_platdata(dev);
>  	enum usb_dr_mode dr_mode;
> +	const struct fdt_property *extcon;
> +
> +	extcon = fdt_get_property(gd->fdt_blob, dev_of_offset(dev),
> +			"extcon", NULL);
> +	if (extcon) {
> +		plat->init_type = board_ehci_usb_phy_mode(dev);

Shouldn't this information be available in the DT too ?
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index aa0c1c355d..555a810953 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -568,6 +568,25 @@  static const struct ehci_ops mx6_ehci_ops = {
 	.init_after_reset	= mx6_init_after_reset
 };
 
+/**
+ * board_ehci_usb_phy_mode - override usb phy mode
+ * @port:	usb host/otg port
+ *
+ * Target board specific, override usb_phy_mode.
+ * When usb-otg is used as usb host port, iomux pad usb_otg_id can be
+ * left disconnected in this case usb_phy_mode will not be able to identify
+ * the phy mode that usb port is used.
+ * Machine file overrides board_usb_phy_mode.
+ * When the extcon property is set in DTB, machine must provide this function, otherwise
+ * it will default return HOST.
+ *
+ * Return: USB_INIT_DEVICE or USB_INIT_HOST
+ */
+int __weak board_ehci_usb_phy_mode(struct udevice *dev)
+{
+	return USB_INIT_HOST;
+}
+
 static int ehci_usb_phy_mode(struct udevice *dev)
 {
 	struct usb_platdata *plat = dev_get_platdata(dev);
@@ -634,6 +653,15 @@  static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct usb_platdata *plat = dev_get_platdata(dev);
 	enum usb_dr_mode dr_mode;
+	const struct fdt_property *extcon;
+
+	extcon = fdt_get_property(gd->fdt_blob, dev_of_offset(dev),
+			"extcon", NULL);
+	if (extcon) {
+		plat->init_type = board_ehci_usb_phy_mode(dev);
+
+		return 0;
+	}
 
 	dr_mode = usb_get_dr_mode(dev->node);