Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
Link: https://lore.kernel.org/r/20200331081005.32752-2-peter.chen@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Chen and committed by
Greg Kroah-Hartman
85820de1 0f2d7761

-39
-37
drivers/usb/cdns3/core.c
··· 291 291 enum usb_role real_role, current_role; 292 292 int ret = 0; 293 293 294 - /* Do nothing if role based on syfs. */ 295 - if (cdns->role_override) 296 - return 0; 297 - 298 294 pm_runtime_get_sync(cdns->dev); 299 295 300 296 current_role = cdns->role; ··· 348 352 int ret = 0; 349 353 350 354 pm_runtime_get_sync(cdns->dev); 351 - 352 - /* 353 - * FIXME: switch role framework should be extended to meet 354 - * requirements. Driver assumes that role can be controlled 355 - * by SW or HW. Temporary workaround is to use USB_ROLE_NONE to 356 - * switch from SW to HW control. 357 - * 358 - * For dr_mode == USB_DR_MODE_OTG: 359 - * if user sets USB_ROLE_HOST or USB_ROLE_DEVICE then driver 360 - * sets role_override flag and forces that role. 361 - * if user sets USB_ROLE_NONE, driver clears role_override and lets 362 - * HW state machine take over. 363 - * 364 - * For dr_mode != USB_DR_MODE_OTG: 365 - * Assumptions: 366 - * 1. Restricted user control between NONE and dr_mode. 367 - * 2. Driver doesn't need to rely on role_override flag. 368 - * 3. Driver needs to ensure that HW state machine is never called 369 - * if dr_mode != USB_DR_MODE_OTG. 370 - */ 371 - if (role == USB_ROLE_NONE) 372 - cdns->role_override = 0; 373 - else 374 - cdns->role_override = 1; 375 - 376 - /* 377 - * HW state might have changed so driver need to trigger 378 - * HW state machine if dr_mode == USB_DR_MODE_OTG. 379 - */ 380 - if (!cdns->role_override && cdns->dr_mode == USB_DR_MODE_OTG) { 381 - cdns3_hw_role_switch(cdns); 382 - goto pm_put; 383 - } 384 355 385 356 if (cdns->role == role) 386 357 goto pm_put;
-2
drivers/usb/cdns3/core.h
··· 62 62 * This field based on firmware setting, kernel configuration 63 63 * and hardware configuration. 64 64 * @role_sw: pointer to role switch object. 65 - * @role_override: set 1 if role rely on SW. 66 65 */ 67 66 struct cdns3 { 68 67 struct device *dev; ··· 89 90 struct mutex mutex; 90 91 enum usb_dr_mode dr_mode; 91 92 struct usb_role_switch *role_sw; 92 - int role_override; 93 93 }; 94 94 95 95 int cdns3_hw_role_switch(struct cdns3 *cdns);