Skip to contentSkip to conversation

usb: chipidea: Hook into mux framework to toggle usb switch

PATCH Superseded Yossi Mansharoff 4 participants 7 messages Feb 21, 2018 – Apr 17, 2018 1 message not in the archive

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 2/4 usb: chipidea: Hook into mux framework to toggle usb switch

In reply to a message not in the archive

On the db410c 96boards platform we have a TC7USB40MU on the board to mux the D+/D- lines coming from the controller between a micro usb "device" port and a USB hub for "host" roles[1]. During a role switch, we need to toggle this mux to forward the D+/D- lines to either the port or the hub. Add the necessary code to do the role switch in chipidea core via the generic mux framework. Board configurations like on db410c are expected to change roles via the sysfs API described in Documentation/ABI/testing/sysfs-platform-chipidea-usb2.

[1] https://github.com/96boards/documentation/raw/master/ConsumerEdition/DragonBoard-410c/HardwareDocs/Schematics_DragonBoard.pdf

Cc Peter Rosin <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |  6 ++++++
 drivers/usb/chipidea/Kconfig                           |  2 ++
 drivers/usb/chipidea/core.c                            |  6 ++++++
 drivers/usb/chipidea/host.c                            |  7 +++++++
 drivers/usb/chipidea/udc.c                             | 13 ++++++++++++-
 include/linux/usb/chipidea.h                           |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +6 -0
index 0e03344..2e93181 100644
@@ -76,6 +76,10 @@ Optional properties:
   needs to make sure it does not send more than 90%
   maximum_periodic_data_per_frame. The use case is multiple transactions, but
   less frame rate.
+- mux-controls: The mux control for toggling host/device output of this
+  controller. It's expected that a mux state of 0 indicates device mode and a
+  mux state of 1 indicates host mode.
+- mux-control-names: Shall be "usb_switch" if mux-controls is specified.
 
 i.mx specific properties
 - fsl,usbmisc: phandler of non-core register device, with one
@@ -102,4 +106,6 @@ Example:
 		rx-burst-size-dword = <0x10>;
 		extcon = <0>, <&usb_id>;
 		phy-clkgate-delay-us = <400>;
+		mux-controls = <&usb_switch>;
+		mux-control-names = "usb_switch";
 	};
drivers/usb/chipidea/Kconfig +2 -0
index 51f4157..72aadfa 100644
@@ -3,6 +3,8 @@ config USB_CHIPIDEA
 	depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
 	select EXTCON
 	select RESET_CONTROLLER
+	select MULTIPLEXER
+	select MUX_GPIO
 	help
 	  Say Y here if your system has a dual role high speed USB
 	  controller based on ChipIdea silicon IP. It supports:
drivers/usb/chipidea/core.c +6 -0
index 43ea5fb..aa71b96 100644
@@ -64,6 +64,7 @@
 #include <linux/of.h>
 #include <linux/regulator/consumer.h>
 #include <linux/usb/ehci_def.h>
+#include <linux/mux/consumer.h>
 
 #include "ci.h"
 #include "udc.h"
@@ -690,6 +691,11 @@ static int ci_get_platdata(struct device *dev,
 	if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL))
 		platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA;
 
+	platdata->usb_switch = devm_mux_control_get_optional(dev, "usb_switch");
+	if (IS_ERR(platdata->usb_switch)){
+		return PTR_ERR(platdata->usb_switch);
+	}
+
 	ext_id = ERR_PTR(-ENODEV);
 	ext_vbus = ERR_PTR(-ENODEV);
 	if (of_property_read_bool(dev->of_node, "extcon")) {
drivers/usb/chipidea/host.c +7 -0
index 18cb8e4..9ef3ecf 100644
@@ -25,6 +25,7 @@
 #include <linux/usb/hcd.h>
 #include <linux/usb/chipidea.h>
 #include <linux/regulator/consumer.h>
+#include <linux/mux/consumer.h>
 
 #include "../host/ehci.h"
 
@@ -175,6 +176,10 @@ static int host_start(struct ci_hdrc *ci)
 		if (ci_otg_is_fsm_mode(ci)) {
 			otg->host = &hcd->self;
 			hcd->self.otg_port = 1;
+		} else {
+			ret = mux_control_select(ci->platdata->usb_switch, 1);
+			if (ret)
+				goto disable_reg;
 		}
 	}
 
@@ -195,6 +200,8 @@ static void host_stop(struct ci_hdrc *ci)
 	struct usb_hcd *hcd = ci->hcd;
 
 	if (hcd) {
+		if (!ci_otg_is_fsm_mode(ci))
+			mux_control_deselect(ci->platdata->usb_switch);
 		if (ci->platdata->notify_event)
 			ci->platdata->notify_event(ci,
 				CI_HDRC_CONTROLLER_STOPPED_EVENT);
drivers/usb/chipidea/udc.c +12 -1
index fe8a905..17f22e2 100644
@@ -22,6 +22,7 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/otg-fsm.h>
 #include <linux/usb/chipidea.h>
+#include <linux/mux/consumer.h>
 
 #include "ci.h"
 #include "udc.h"
@@ -1964,16 +1965,26 @@ void ci_hdrc_gadget_destroy(struct ci_hdrc *ci)
 
 static int udc_id_switch_for_device(struct ci_hdrc *ci)
 {
+	int ret = 0;
+
 	if (ci->is_otg)
 		/* Clear and enable BSV irq */
 		hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
 					OTGSC_BSVIS | OTGSC_BSVIE);
 
-	return 0;
+	if (!ci_otg_is_fsm_mode(ci))
+		ret = mux_control_select(ci->platdata->usb_switch, 0);
+
+	if (ci->is_otg && ret)
+		hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);
+
+	return ret;
 }
 
 static void udc_id_switch_for_host(struct ci_hdrc *ci)
 {
+	mux_control_deselect(ci->platdata->usb_switch);
+
 	/*
 	 * host doesn't care B_SESSION_VALID event
 	 * so clear and disbale BSV irq
include/linux/usb/chipidea.h +2 -0
index d725cff..7e5d008 100644
@@ -9,6 +9,7 @@
 #include <linux/usb/otg.h>
 
 struct ci_hdrc;
+struct mux_control;
 
 /**
  * struct ci_hdrc_cable - structure for external connector cable state tracking
@@ -75,6 +76,7 @@ struct ci_hdrc_platform_data {
 	/* VBUS and ID signal state tracking, using extcon framework */
 	struct ci_hdrc_cable		vbus_extcon;
 	struct ci_hdrc_cable		id_extcon;
+	struct mux_control		*usb_switch;
 	u32			phy_clkgate_delay_us;
 };
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#2 lore raw
Quoted 18 lines · Yossi Mansharoff

On the db410c 96boards platform we have a TC7USB40MU on the board to mux the D+/D- lines coming from the controller between a micro usb "device" port and a USB hub for "host" roles[1]. During a role switch, we need to toggle this mux to forward the D+/D- lines to either the port or the hub. Add the necessary code to do the role switch in chipidea core via the generic mux framework. Board configurations like on db410c are expected to change roles via the sysfs API described in Documentation/ABI/testing/sysfs-platform-chipidea-usb2.

[1] https://github.com/96boards/documentation/raw/master/ConsumerEdition/DragonBoard-410c/HardwareDocs/Schematics_DragonBoard.pdf

Cc Peter Rosin <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 3 lines
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |  6 ++++++

Please make bindings a separate patch.

Quoted 12 lines
 drivers/usb/chipidea/Kconfig                           |  2 ++
 drivers/usb/chipidea/core.c                            |  6 ++++++
 drivers/usb/chipidea/host.c                            |  7 +++++++
 drivers/usb/chipidea/udc.c                             | 13 ++++++++++++-
 include/linux/usb/chipidea.h                           |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +0 -0
index 0e03344..2e93181 100644

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Optional properties: · line 82

Quoted 7 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +4 -0
@@ -76,6 +76,10 @@ Optional properties:
   needs to make sure it does not send more than 90%
   maximum_periodic_data_per_frame. The use case is multiple transactions, but
   less frame rate.
+- mux-controls: The mux control for toggling host/device output of this
+  controller. It's expected that a mux state of 0 indicates device mode and a
+  mux state of 1 indicates host mode.
+- mux-control-names: Shall be "usb_switch" if mux-controls is specified.

-names is pointless when there is only 1.

Quoted 10 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -0
 i.mx specific properties
 - fsl,usbmisc: phandler of non-core register device, with one
@@ -102,4 +106,6 @@ Example:
 		rx-burst-size-dword = <0x10>;
 		extcon = <0>, <&usb_id>;
 		phy-clkgate-delay-us = <400>;
+		mux-controls = <&usb_switch>;
+		mux-control-names = "usb_switch";
 	};
#3 lore raw
Quoted 19 lines · Yossi Mansharoff
Quoted 18 lines

On the db410c 96boards platform we have a TC7USB40MU on the board to mux the D+/D- lines coming from the controller between a micro usb "device" port and a USB hub for "host" roles[1]. During a role switch, we need to toggle this mux to forward the D+/D- lines to either the port or the hub. Add the necessary code to do the role switch in chipidea core via the generic mux framework. Board configurations like on db410c are expected to change roles via the sysfs API described in Documentation/ABI/testing/sysfs-platform-chipidea-usb2.

[1] https://github.com/96boards/documentation/raw/master/ConsumerEdition/DragonBoard-410c/HardwareDocs/Schematics_DragonBoard.pdf

Cc Peter Rosin <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 5 lines
Quoted 3 lines
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |  6 ++++++

Please make bindings a separate patch.

sure

Quoted 8 lines
Quoted 8 lines
 drivers/usb/chipidea/Kconfig                           |  2 ++
 drivers/usb/chipidea/core.c                            |  6 ++++++
 drivers/usb/chipidea/host.c                            |  7 +++++++
 drivers/usb/chipidea/udc.c                             | 13 ++++++++++++-
 include/linux/usb/chipidea.h                           |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)
Quoted 14 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Optional properties: · line 82

Quoted 12 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +4 -0
index 0e03344..2e93181 100644
@@ -76,6 +76,10 @@ Optional properties:
   needs to make sure it does not send more than 90%
   maximum_periodic_data_per_frame. The use case is multiple transactions, but
   less frame rate.
+- mux-controls: The mux control for toggling host/device output of this
+  controller. It's expected that a mux state of 0 indicates device mode and a
+  mux state of 1 indicates host mode.
+- mux-control-names: Shall be "usb_switch" if mux-controls is specified.

-names is pointless when there is only 1.

the names is used to find the attached mux in the dt . it is used in the following lines in mux/core.c

if (mux_name) {
		index = of_property_match_string(np, "mux-control-names",
						 mux_name);

so I think iwe need to keep it, agreed?

Quoted 11 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Example: · line 111

Quoted 11 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -0
 i.mx specific properties
 - fsl,usbmisc: phandler of non-core register device, with one
@@ -102,4 +106,6 @@ Example:
 		rx-burst-size-dword = <0x10>;
 		extcon = <0>, <&usb_id>;
 		phy-clkgate-delay-us = <400>;
+		mux-controls = <&usb_switch>;
+		mux-control-names = "usb_switch";
 	};

_______________________________________________
Dragonboard-aosp mailing list
[email protected]
https://lists.96boards.org/mailman/listinfo/dragonboard-aosp

#4 lore raw
Quoted 47 lines · Yossi Mansharoff
Quoted 19 lines · Yossi Mansharoff
Quoted 18 lines

On the db410c 96boards platform we have a TC7USB40MU on the board to mux the D+/D- lines coming from the controller between a micro usb "device" port and a USB hub for "host" roles[1]. During a role switch, we need to toggle this mux to forward the D+/D- lines to either the port or the hub. Add the necessary code to do the role switch in chipidea core via the generic mux framework. Board configurations like on db410c are expected to change roles via the sysfs API described in Documentation/ABI/testing/sysfs-platform-chipidea-usb2.

[1] https://github.com/96boards/documentation/raw/master/ConsumerEdition/DragonBoard-410c/HardwareDocs/Schematics_DragonBoard.pdf

Cc Peter Rosin <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 5 lines
Quoted 3 lines
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |  6 ++++++

Please make bindings a separate patch.

sure

Quoted 8 lines
Quoted 8 lines
 drivers/usb/chipidea/Kconfig                           |  2 ++
 drivers/usb/chipidea/core.c                            |  6 ++++++
 drivers/usb/chipidea/host.c                            |  7 +++++++
 drivers/usb/chipidea/udc.c                             | 13 ++++++++++++-
 include/linux/usb/chipidea.h                           |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)
Quoted 14 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Optional properties: · line 82

Quoted 12 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +4 -0
index 0e03344..2e93181 100644
@@ -76,6 +76,10 @@ Optional properties:
   needs to make sure it does not send more than 90%
   maximum_periodic_data_per_frame. The use case is multiple transactions, but
   less frame rate.
+- mux-controls: The mux control for toggling host/device output of this
+  controller. It's expected that a mux state of 0 indicates device mode and a
+  mux state of 1 indicates host mode.
+- mux-control-names: Shall be "usb_switch" if mux-controls is specified.

-names is pointless when there is only 1.

Quoted 6 lines

the names is used to find the attached mux in the dt . it is used in the following lines in mux/core.c

if (mux_name) {
		index = of_property_match_string(np, "mux-control-names",
						 mux_name);

so I think iwe need to keep it, agreed?

If mux_name is NULL, index defaults to 0, i.e. the first (and presumably only) mux control is grabbed from the mux-controls list.

So, you should be able to call mux_control_get_optional with a NULL mux_name argument for this to work. But please try it...

Cheers,
Peter

Quoted 16 lines
Quoted 11 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Example: · line 111

Quoted 11 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -0
 i.mx specific properties
 - fsl,usbmisc: phandler of non-core register device, with one
@@ -102,4 +106,6 @@ Example:
 		rx-burst-size-dword = <0x10>;
 		extcon = <0>, <&usb_id>;
 		phy-clkgate-delay-us = <400>;
+		mux-controls = <&usb_switch>;
+		mux-control-names = "usb_switch";
 	};

_______________________________________________
Dragonboard-aosp mailing list
[email protected]
https://lists.96boards.org/mailman/listinfo/dragonboard-aosp

#5 lore raw
Quoted 59 lines · Yossi Mansharoff
Quoted 52 lines
Quoted 21 lines · Yossi Mansharoff
Quoted 20 lines

On the db410c 96boards platform we have a TC7USB40MU on the board to mux the D+/D- lines coming from the controller between a micro usb "device" port and a USB hub for "host" roles[1]. During a role switch, we need to toggle this mux to forward the D+/D- lines to either the port or the hub. Add the necessary code to do the role switch in chipidea core via the generic mux framework. Board configurations like on db410c are expected to change roles via the sysfs API described in Documentation/ABI/testing/sysfs-platform-chipidea-usb2.

[1]
https://github.com/96boards/documentation/raw/master/ConsumerEdition
/DragonBoard-410c/HardwareDocs/Schematics_DragonBoard.pdf

Cc Peter Rosin <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 5 lines
Quoted 3 lines
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |  6 ++++++

Please make bindings a separate patch.

sure

Quoted 17 lines
Quoted 17 lines
 drivers/usb/chipidea/Kconfig                           |  2 ++
 drivers/usb/chipidea/core.c                            |  6 ++++++
 drivers/usb/chipidea/host.c                            |  7 +++++++
 drivers/usb/chipidea/udc.c                             | 13 ++++++++++++-
 include/linux/usb/chipidea.h                           |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +0 -0
index 0e03344..2e93181 100644
@@ -76,6 +76,10 @@ Optional properties:
   needs to make sure it does not send more than 90%
   maximum_periodic_data_per_frame. The use case is multiple transactions, but
   less frame rate.
Quoted 8 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Optional properties: · line 84

Quoted 6 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +6 -0
+- mux-controls: The mux control for toggling host/device output of 
+this
+  controller. It's expected that a mux state of 0 indicates device 
+mode and a
+  mux state of 1 indicates host mode.
+- mux-control-names: Shall be "usb_switch" if mux-controls is specified.

-names is pointless when there is only 1.

Quoted 5 lines

the names is used to find the attached mux in the dt . it is used in the following lines in mux/core.c if (mux_name) {

		index = of_property_match_string(np, "mux-control-names",
						 mux_name);

so I think iwe need to keep it, agreed?

Quoted 7 lines

If mux_name is NULL, index defaults to 0, i.e. the first (and presumably only) mux control is grabbed from the mux-controls list.

So, you should be able to call mux_control_get_optional with a NULL mux_name argument for this to work. But please try it...

Cheers,
Peter

that's correct, my thought is that it would be safer to explicitly call the mux_control_get_optional function with a mux name, just for the case of multiple muxes. Thanks.
For example another mux to switch off vBUS.
Yossi

Quoted 19 lines
Quoted 17 lines
Quoted 12 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Example: · line 111

Quoted 12 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -1
 i.mx specific properties
 - fsl,usbmisc: phandler of non-core register device, with one @@ 
-102,4 +106,6 @@ Example:
 		rx-burst-size-dword = <0x10>;
 		extcon = <0>, <&usb_id>;
 		phy-clkgate-delay-us = <400>;
+		mux-controls = <&usb_switch>;
+		mux-control-names = "usb_switch";
 	};

_______________________________________________
Dragonboard-aosp mailing list
[email protected]
https://lists.96boards.org/mailman/listinfo/dragonboard-aosp

#6 lore raw

[finally remembered to switch email for Stephen Boyd]

Quoted 64 lines · Yossi Mansharoff
Quoted 64 lines · Yossi Mansharoff
Quoted 52 lines
Quoted 21 lines · Yossi Mansharoff
Quoted 20 lines

On the db410c 96boards platform we have a TC7USB40MU on the board to mux the D+/D- lines coming from the controller between a micro usb "device" port and a USB hub for "host" roles[1]. During a role switch, we need to toggle this mux to forward the D+/D- lines to either the port or the hub. Add the necessary code to do the role switch in chipidea core via the generic mux framework. Board configurations like on db410c are expected to change roles via the sysfs API described in Documentation/ABI/testing/sysfs-platform-chipidea-usb2.

[1]
https://github.com/96boards/documentation/raw/master/ConsumerEdition
/DragonBoard-410c/HardwareDocs/Schematics_DragonBoard.pdf

Cc Peter Rosin <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 5 lines
Quoted 3 lines
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |  6 ++++++

Please make bindings a separate patch.

sure

Quoted 17 lines
Quoted 17 lines
 drivers/usb/chipidea/Kconfig                           |  2 ++
 drivers/usb/chipidea/core.c                            |  6 ++++++
 drivers/usb/chipidea/host.c                            |  7 +++++++
 drivers/usb/chipidea/udc.c                             | 13 ++++++++++++-
 include/linux/usb/chipidea.h                           |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +0 -0
index 0e03344..2e93181 100644
@@ -76,6 +76,10 @@ Optional properties:
   needs to make sure it does not send more than 90%
   maximum_periodic_data_per_frame. The use case is multiple transactions, but
   less frame rate.
Quoted 8 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Optional properties: · line 84

Quoted 6 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +6 -0
+- mux-controls: The mux control for toggling host/device output of 
+this
+  controller. It's expected that a mux state of 0 indicates device 
+mode and a
+  mux state of 1 indicates host mode.
+- mux-control-names: Shall be "usb_switch" if mux-controls is specified.

-names is pointless when there is only 1.

Quoted 5 lines

the names is used to find the attached mux in the dt . it is used in the following lines in mux/core.c if (mux_name) {

		index = of_property_match_string(np, "mux-control-names",
						 mux_name);

so I think iwe need to keep it, agreed?

If mux_name is NULL, index defaults to 0, i.e. the first (and presumably only) mux control is grabbed from the mux-controls list.

So, you should be able to call mux_control_get_optional with a NULL mux_name argument for this to work. But please try it...

Quoted 7 lines
Quoted 2 lines

Cheers,
Peter

that's correct, my thought is that it would be safer to explicitly call the mux_control_get_optional function with a mux name, just for the case of multiple muxes. Thanks.
For example another mux to switch off vBUS.
Yossi

Right. Rob, how do you propose to handle the future where a second mux with a different function is needed? Specifically, everything I come up with introduces some ugly compatibility crap in the future code to handle old devicetrees w/o the mux-control-names property. So, how to avoid that?

I'm inclined to just requiring a mux-control-names up front to keep the future simple.

Cheers,
Peter

Quoted 20 lines
Quoted 20 lines
Quoted 18 lines
Quoted 4 lines
Quoted 4 lines
Quoted 9 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Example: · line 111

Quoted 9 lines

i.mx specific properties
- fsl,usbmisc: phandler of non-core register device, with one @@
-102,4 +106,6 @@ Example:

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -0
 		rx-burst-size-dword = <0x10>;
 		extcon = <0>, <&usb_id>;
 		phy-clkgate-delay-us = <400>;
+		mux-controls = <&usb_switch>;
+		mux-control-names = "usb_switch";
 	};

_______________________________________________
Dragonboard-aosp mailing list
[email protected]
https://lists.96boards.org/mailman/listinfo/dragonboard-aosp

#7 lore raw
Quoted 89 lines · Peter Rosin

[finally remembered to switch email for Stephen Boyd]

Quoted 72 lines · Yossi Mansharoff
Quoted 72 lines · Yossi Mansharoff
Quoted 60 lines
Quoted 21 lines · Yossi Mansharoff
Quoted 20 lines

On the db410c 96boards platform we have a TC7USB40MU on the board to mux the D+/D- lines coming from the controller between a micro usb "device" port and a USB hub for "host" roles[1]. During a role switch, we need to toggle this mux to forward the D+/D- lines to either the port or the hub. Add the necessary code to do the role switch in chipidea core via the generic mux framework. Board configurations like on db410c are expected to change roles via the sysfs API described in Documentation/ABI/testing/sysfs-platform-chipidea-usb2.

[1]
https://github.com/96boards/documentation/raw/master/ConsumerEdition
/DragonBoard-410c/HardwareDocs/Schematics_DragonBoard.pdf

Cc Peter Rosin <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
Quoted 4 lines
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |  6 

++++++

Please make bindings a separate patch.

sure

Quoted 24 lines
Quoted 24 lines
 drivers/usb/chipidea/Kconfig                           |  2 ++
 drivers/usb/chipidea/core.c                            |  6 
++++++
 drivers/usb/chipidea/host.c                            |  7 
+++++++
 drivers/usb/chipidea/udc.c                             | 13 
++++++++++++-
 include/linux/usb/chipidea.h                           |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +0 -0
index 0e03344..2e93181 100644
@@ -76,6 +76,10 @@ Optional properties:
   needs to make sure it does not send more than 90%
   maximum_periodic_data_per_frame. The use case is multiple 

transactions, but
less frame rate.
+- mux-controls: The mux control for toggling host/device output of
+this

Quoted 8 lines
Quoted 6 lines

+ controller. It's expected that a mux state of 0 indicates device

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +3 -0
+mode and a
+  mux state of 1 indicates host mode.
+- mux-control-names: Shall be "usb_switch" if mux-controls is 

specified.

-names is pointless when there is only 1.

Quoted 5 lines

the names is used to find the attached mux in the dt . it is used in the following lines in mux/core.c if (mux_name) {

		index = of_property_match_string(np, "mux-control-names",
						 mux_name);

so I think iwe need to keep it, agreed?

If mux_name is NULL, index defaults to 0, i.e. the first (and presumably only) mux control is grabbed from the mux-controls list.

So, you should be able to call mux_control_get_optional with a NULL mux_name argument for this to work. But please try it...

Quoted 7 lines
Quoted 2 lines

Cheers,
Peter

that's correct, my thought is that it would be safer to explicitly call the mux_control_get_optional function with a mux name, just for the case of multiple muxes. Thanks.
For example another mux to switch off vBUS.
Yossi

Right. Rob, how do you propose to handle the future where a second mux with a different function is needed? Specifically, everything I come up with introduces some ugly compatibility crap in the future code to handle old devicetrees w/o the mux-control-names property. So, how to avoid that?

Quoted 6 lines

I'm inclined to just requiring a mux-control-names up front to keep the future simple.

Cheers,
Peter

is it ok to keep the "mux-control-names"?
I want to make a new patch set for this, currently, I'm splitting this patch into two (one for bindings and one for chipidea).

Thanks,
Yossi

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 18 lines
Quoted 4 lines
Quoted 4 lines
Quoted 9 lines

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt Example: · line 111

Quoted 9 lines

i.mx specific properties
- fsl,usbmisc: phandler of non-core register device, with one @@
-102,4 +106,6 @@ Example:

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -0
 		rx-burst-size-dword = <0x10>;
 		extcon = <0>, <&usb_id>;
 		phy-clkgate-delay-us = <400>;
+		mux-controls = <&usb_switch>;
+		mux-control-names = "usb_switch";
 	};

_______________________________________________
Dragonboard-aosp mailing list
[email protected]
https://lists.96boards.org/mailman/listinfo/dragonboard-aosp