aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/mtu3/mtu3_dr.c
AgeCommit message (Collapse)AuthorFilesLines
2023-04-20usb: mtu3: expose role-switch control to userspaceChunfeng Yun1-0/+1
The allow_userspace_control flag enables manual role switch from userspace, turn this feature on like several other USB DRD controller drivers. Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2022-04-21usb: mtu3: fix USB 3.0 dual-role-switch from device to hostMacpaul Lin1-4/+2
Issue description: When an OTG port has been switched to device role and then switch back to host role again, the USB 3.0 Host (XHCI) will not be able to detect "plug in event of a connected USB 2.0/1.0 ((Highspeed and Fullspeed) devices until system reboot. Root cause and Solution: There is a condition checking flag "ssusb->otg_switch.is_u3_drd" in toggle_opstate(). At the end of role switch procedure, toggle_opstate() will be called to set DC_SESSION and SOFT_CONN bit. If "is_u3_drd" was set and switched the role to USB host 3.0, bit DC_SESSION and SOFT_CONN will be skipped hence caused the port cannot detect connected USB 2.0 (Highspeed and Fullspeed) devices. Simply remove the condition check to solve this issue. Fixes: d0ed062a8b75 ("usb: mtu3: dual-role mode support") Cc: [email protected] Tested-by: Fabien Parent <[email protected]> Reviewed-by: Chunfeng Yun <[email protected]> Signed-off-by: Macpaul Lin <[email protected]> Signed-off-by: Tainping Fang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-07-27usb: mtu3: support suspend/resume for dual-role modeChunfeng Yun1-0/+2
Support suspend/resume for dual-role mode including the single port and multi-ports supported by host controller, when the host supports mult-ports, only port0 (u2/u3) is used to support dual role mode. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-07-27usb: mtu3: support property role-switch-default-modeChunfeng Yun1-4/+20
Support default mode config when use usb-role-switch Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-06-15usb: mtu3: rebuild role switch get/set hooksChunfeng Yun1-10/+3
Use common helper ssusb_set_mode() to do role switch instead of manual switch helper; Remove unnecessary local variable when get role status Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-06-15usb: mtu3: use force mode for dual role switchChunfeng Yun1-7/+3
Force IDDIG status for all three ways of dual role switch, this is needed when use Type-C to switch mode. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-06-15usb: mtu3: add helper to get pointer of ssusb_mtk structChunfeng Yun1-10/+10
Add a helper to get pointer of ssusb_mtk struct from the pointer of otg_switch_mtk struct. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-06-15usb: mtu3: rebuild role switch flow of extconChunfeng Yun1-28/+33
This is a preparation patch to plan to use the same work to handle role switch for all three supported ways. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-06-15usb: mtu3: use enum usb_role instead of private defined onesChunfeng Yun1-37/+15
Now we mainly use usb-role-switch to set dual role mode, and all three ways supported use the same function to switch mode, use usb_role enum will make code clear Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-06-15usb: mtu3: drop support vbus detectionChunfeng Yun1-48/+2
Until now it's never used on any platform, and will not used later. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-06-15usb: mtu3: remove wakelockChunfeng Yun1-3/+0
Prefer to use /sys/power/wake_lock instead. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2020-03-04usb: roles: Provide the switch drivers handle to the switch in the APIHeikki Krogerus1-4/+5
The USB role callback functions had a parameter pointing to the parent device (struct device) of the switch. The assumption was that the switch parent is always the controller. Firstly, that may not be true in every case, and secondly, it prevents us from supporting devices that supply multiple muxes. Changing the first parameter of usb_role_switch_set_t and usb_role_switch_get_t from struct device to struct usb_role_switch. Cc: Peter Chen <[email protected]> Cc: Felipe Balbi <[email protected]> Cc: Chunfeng Yun <[email protected]> Cc: Bin Liu <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-09-03usb: mtu3: register a USB Role Switch for dual role modeChunfeng Yun1-1/+47
Because extcon is not allowed for new bindings, and the dual role switch is supported by USB Role Switch, especially for Type-C drivers, so register a USB Role Switch to support the new way Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-03-26usb: mtu3: add a function to switch mailbox state to stringChunfeng Yun1-2/+18
By introducing mailbox_state_string(), allow to make debug log more readable Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-03-26usb: mtu3: add tracepoints to help debugChunfeng Yun1-0/+1
This patch implements a few initial tracepoints for the mtu3 driver. More traces can be added as necessary in order to ease the task of debugging. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-03-26usb: mtu3: move vbus and mode debugfs interfaces into mtu3_debugfs.cChunfeng Yun1-110/+3
Due to the separated debugfs files are added, move vbus and mode debugfs interfaces related with dual-role switch from mtu3_dr.c into mtu3_debugfs.c Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-03-26usb: mtu3: add debugfs interface filesChunfeng Yun1-12/+1
This adds more debugfs consumers. The debugfs entries read some important registers, fifo status, QMU ring, endpoint status, and IPPC probe interface to get internal status. With these entries, users can check the registers, endpoint and GPD used during run time. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-03-26usb: mtu3: check return value of devm_extcon_register_notifier()Chunfeng Yun1-4/+9
Check the return value of devm_extcon_register_notifier() and add error handling. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2018-05-31USB: mtu3: no need to check return value of debugfs_create_dir()Greg Kroah-Hartman1-4/+0
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2018-05-24usb: mtu3: fix warning of sleep in atomic context in notifier callbackChunfeng Yun1-8/+36
The notifier callbacks of extcon are called in atomic context, but the callbacks will call regulator_enable()/regulator_disable() which may sleep caused by mutex, so use work queue to call the sleep functions. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2018-05-15usb: mtu3: fix an unrecognized issue when connected with PCChunfeng Yun1-22/+3
When boot on the platform with the USB cable connected to Win7, the Win7 will pop up an error dialog: "USB Device not recognized", but finally the Win7 can enumerate it successfully. The root cause is as the following: When the xHCI driver set PORT_POWER of the OTG port, and if both IDPIN and VBUS_VALID are high at the same time, the MTU3 controller will set SESSION and pull up DP, so the Win7 can detect existence of USB device, but if the mtu3 driver can't switch to device mode during the debounce time, the Win7 can not enumerate it. Here to fix it by removing the 1s delayed EXTCON register to speed up mode switch. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2017-11-07USB: mtu3: Remove redundant license textGreg Kroah-Hartman1-10/+0
Now that the SPDX tag is in all USB files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Acked-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-11-04USB: add SPDX identifiers to all remaining files in drivers/usb/Greg Kroah-Hartman1-0/+1
It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Update the drivers/usb/ and include/linux/usb* files with the correct SPDX license identifier based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This work is based on a script and data from Thomas Gleixner, Philippe Ombredanne, and Kate Stewart. Cc: Thomas Gleixner <[email protected]> Cc: Kate Stewart <[email protected]> Cc: Philippe Ombredanne <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Acked-by: Felipe Balbi <[email protected]> Acked-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-10-19usb: mtu3: use FORCE/RG_IDDIG to implement manual DRD switchChunfeng Yun1-16/+45
In order to keep manual DRD switch independent on IDDIG interrupt, make use of FORCE/RG_IDDIG instead of IDDIG EINT interrupt to implement manual DRD switch function. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2017-08-10usb: mtu3: add a vbus debugfs interfaceChunfeng Yun1-8/+50
Provides a new vbus debugfs interface used to turn on/off vbus regulator, it also can be used to get/put reference count of vbus, due to sometimes we need keep it alive when manually switch mtu3 to device mode. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-04-11usb: mtu3: Replace the extcon APIChanwoo Choi1-13/+6
This patch uses the resource-managed extcon API for extcon_register_notifier() and replaces the deprecated extcon API as following: - extcon_get_cable_state_() -> extcon_get_state() Cc: Greg Kroah-Hartman <[email protected]> Cc: Chunfeng Yun <[email protected]> Cc: [email protected] Tested-by: Chunfeng Yun <[email protected]> Acked-by: Chunfeng Yun <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-10-27usb: mtu3: dual-role mode supportChunfeng Yun1-0/+379
support dual-role mode; there are two ways to switch between host and device modes, one is by idpin, another is by debugfs which depends on user input. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>