History log of /linux-master/drivers/usb/mtu3/mtu3_dr.c
Revision Date Author Comments
# 976a5c25 16-Apr-2023 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: expose role-switch control to userspace

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 <angelogioacchino.delregno@collabora.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20230417025203.18097-5-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 456244ae 19-Apr-2022 Macpaul Lin <macpaul.lin@mediatek.com>

usb: mtu3: fix USB 3.0 dual-role-switch from device to host

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: stable@vger.kernel.org
Tested-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
Signed-off-by: Tainping Fang <tianping.fang@mediatek.com>
Link: https://lore.kernel.org/r/20220419081245.21015-1-macpaul.lin@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6b587394 15-Jul-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: support suspend/resume for dual-role mode

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 <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1626340078-29111-14-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 88c6b901 15-Jul-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: support property role-switch-default-mode

Support default mode config when use usb-role-switch

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1626340078-29111-8-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bfce43c4 08-Jun-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: rebuild role switch get/set hooks

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 <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1623139069-8173-14-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 13862176 08-Jun-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: use force mode for dual role switch

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 <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1623139069-8173-13-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6c7b9497 08-Jun-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: add helper to get pointer of ssusb_mtk struct

Add a helper to get pointer of ssusb_mtk struct from the pointer
of otg_switch_mtk struct.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1623139069-8173-12-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 18cfd7b8 08-Jun-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: rebuild role switch flow of extcon

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 <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1623139069-8173-11-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a04c9f2d 08-Jun-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: use enum usb_role instead of private defined ones

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 <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1623139069-8173-10-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ae634f93 08-Jun-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: drop support vbus detection

Until now it's never used on any platform, and will not used
later.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1623139069-8173-9-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3abf5627 08-Jun-2021 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: remove wakelock

Prefer to use /sys/power/wake_lock instead.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1623139069-8173-8-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bce3052f 02-Mar-2020 Heikki Krogerus <heikki.krogerus@linux.intel.com>

usb: roles: Provide the switch drivers handle to the switch in the API

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 <Peter.Chen@nxp.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: Bin Liu <b-liu@ti.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200302135353.56659-6-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1ac91ac5 29-Aug-2019 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: register a USB Role Switch for dual role mode

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 <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1567070558-29417-12-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f926da42 20-Mar-2019 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: add a function to switch mailbox state to string

By introducing mailbox_state_string(), allow to make debug
log more readable

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 83374e03 20-Mar-2019 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: add tracepoints to help debug

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4aab6ad2 20-Mar-2019 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: move vbus and mode debugfs interfaces into mtu3_debugfs.c

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ae078092 20-Mar-2019 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: add debugfs interface files

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 03d8bfc1 20-Mar-2019 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: check return value of devm_extcon_register_notifier()

Check the return value of devm_extcon_register_notifier() and
add error handling.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 71cae9ad 29-May-2018 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: mtu3: no need to check return value of debugfs_create_dir()

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 681e9485 23-May-2018 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: fix warning of sleep in atomic context in notifier callback

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 11254eb2 23-Apr-2018 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: fix an unrecognized issue when connected with PC

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 4c55a157 06-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: mtu3: Remove redundant license text

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5fd54ace 03-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: add SPDX identifiers to all remaining files in drivers/usb/

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 <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c776f2c3 13-Oct-2017 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: use FORCE/RG_IDDIG to implement manual DRD switch

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# e97d2a39 03-Aug-2017 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: add a vbus debugfs interface

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5c33f8f4 03-Aug-2017 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: add a vbus debugfs interface

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# a2cfed43 27-Mar-2017 Chanwoo Choi <cw00.choi@samsung.com>

usb: mtu3: Replace the extcon API

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 <gregkh@linuxfoundation.org>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: linux-usb@vger.kernel.org
Tested-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# d0ed062a 18-Oct-2016 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: mtu3: dual-role mode support

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 <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>