Commit 160c1634 authored by Peter Chen's avatar Peter Chen Committed by Felipe Balbi
Browse files

usb: cdns3: delete role_override



In short, we have three kinds of role switches:
- Based on SoC: ID and VBUS
- Based on external connnctor, eg, Type-C or GPIO Connector
- Based on user choices through sysfs

Since HW handling and usb-role-switch handling are at
different places, we do not need role_override any more,
and this flag could not judge external connector case well.

With role_override deleted, We use cdns3_hw_role_switch for
the 1st use case, and usb-role-switch for the 2nd and 3rd cases.

Reviewed-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 23d6dd6c
Loading
Loading
Loading
Loading
+0 −37
Original line number Diff line number Diff line
@@ -291,10 +291,6 @@ int cdns3_hw_role_switch(struct cdns3 *cdns)
	enum usb_role real_role, current_role;
	int ret = 0;

	/* Do nothing if role based on syfs. */
	if (cdns->role_override)
		return 0;

	pm_runtime_get_sync(cdns->dev);

	current_role = cdns->role;
@@ -353,39 +349,6 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role)

	pm_runtime_get_sync(cdns->dev);

	/*
	 * FIXME: switch role framework should be extended to meet
	 * requirements. Driver assumes that role can be controlled
	 * by SW or HW. Temporary workaround is to use USB_ROLE_NONE to
	 * switch from SW to HW control.
	 *
	 * For dr_mode == USB_DR_MODE_OTG:
	 *	if user sets USB_ROLE_HOST or USB_ROLE_DEVICE then driver
	 *	sets role_override flag and forces that role.
	 *	if user sets USB_ROLE_NONE, driver clears role_override and lets
	 *	HW state machine take over.
	 *
	 * For dr_mode != USB_DR_MODE_OTG:
	 *	Assumptions:
	 *	1. Restricted user control between NONE and dr_mode.
	 *	2. Driver doesn't need to rely on role_override flag.
	 *	3. Driver needs to ensure that HW state machine is never called
	 *	   if dr_mode != USB_DR_MODE_OTG.
	 */
	if (role == USB_ROLE_NONE)
		cdns->role_override = 0;
	else
		cdns->role_override = 1;

	/*
	 * HW state might have changed so driver need to trigger
	 * HW state machine if dr_mode == USB_DR_MODE_OTG.
	 */
	if (!cdns->role_override && cdns->dr_mode == USB_DR_MODE_OTG) {
		cdns3_hw_role_switch(cdns);
		goto pm_put;
	}

	if (cdns->role == role)
		goto pm_put;

+0 −2
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ struct cdns3_role_driver {
 *           This field based on firmware setting, kernel configuration
 *           and hardware configuration.
 * @role_sw: pointer to role switch object.
 * @role_override: set 1 if role rely on SW.
 */
struct cdns3 {
	struct device			*dev;
@@ -90,7 +89,6 @@ struct cdns3 {
	struct mutex			mutex;
	enum usb_dr_mode		dr_mode;
	struct usb_role_switch		*role_sw;
	int				role_override;
};

int cdns3_hw_role_switch(struct cdns3 *cdns);