usb: dwc2: gadget: remove D+ pull-up while no vbus with usb-role-switch
authorAmelie Delaunay <amelie.delaunay@foss.st.com>
Wed, 22 Jun 2022 16:07:17 +0000 (18:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:40:33 +0000 (11:40 +0200)
commitb9c31d4ae9becb837caa00ac663e8d695660efb4
treedf4397f27fdacf750f0e0a93d6366efb636017a8
parentfbdbd61a36d887e00114321c6758e359e9573a8e
usb: dwc2: gadget: remove D+ pull-up while no vbus with usb-role-switch

[ Upstream commit db638c6500abaffb8f7770b2a69c40d003d54ae1 ]

When using usb-role-switch, D+ pull-up is set as soon as DTCL_SFTDISCON is
cleared, whatever the vbus valid signal state is. The pull-up should not
be set when vbus isn't present (this is determined by the drd controller).

This patch ensures that B-Session (so Peripheral role + vbus valid signal)
is valid before clearing the DCTL_SFTDISCON bit when role switch is used.
Keep original behavior when usb-role-switch isn't used.

Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20220622160717.314580-1-fabrice.gasnier@foss.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/dwc2/gadget.c