Prashanth K
df8d390a21
usb: common: usb-conn-gpio: Prevent bailing out if initial role is none
...
commit 8e21a620c7e6e00347ade1a6ed4967b359eada5a upstream.
Currently if we bootup a device without cable connected, then
usb-conn-gpio won't call set_role() because last_role is same
as current role. This happens since last_role gets initialised
to zero during the probe.
To avoid this, add a new flag initial_detection into struct
usb_conn_info, which prevents bailing out during initial
detection.
Cc: <stable@vger.kernel.org > # 5.4
Fixes: 4602f3bff2
("usb: common: add USB GPIO based connection detection driver")
Signed-off-by: Prashanth K <quic_prashk@quicinc.com >
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com >
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com >
Link: https://lore.kernel.org/r/1690880632-12588-1-git-send-email-quic_prashk@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-08-16 18:21:00 +02:00
Greg Kroah-Hartman
8e00ae25a3
Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection"
...
[ Upstream commit df49f2a0ac4a34c0cb4b5c233fcfa0add644c43c ]
This reverts commit edd60d24bd858cef165274e4cd6cab43bdc58d15.
Heikki reports that this should not be a global flag just to work around
one broken driver and should be fixed differently, so revert it.
Reported-by: Heikki Krogerus <heikki.krogerus@linux.intel.com >
Fixes: edd60d24bd85 ("usb: common: usb-conn-gpio: Set last role to unknown before initial detection")
Link: https://lore.kernel.org/r/ZImE4L3YgABnCIsP@kuha.fi.intel.com
Cc: Prashanth K <quic_prashk@quicinc.com >
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2023-07-27 08:44:06 +02:00
Prashanth K
7ade555ac5
usb: common: usb-conn-gpio: Set last role to unknown before initial detection
...
[ Upstream commit edd60d24bd858cef165274e4cd6cab43bdc58d15 ]
Currently if we bootup a device without cable connected, then
usb-conn-gpio won't call set_role() since last_role is same as
current role. This happens because during probe last_role gets
initialised to zero.
To avoid this, added a new constant in enum usb_role, last_role
is set to USB_ROLE_UNKNOWN before performing initial detection.
While at it, also handle default case for the usb_role switch
in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid
build warnings.
Fixes: 4602f3bff2
("usb: common: add USB GPIO based connection detection driver")
Signed-off-by: Prashanth K <quic_prashk@quicinc.com >
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com >
Message-ID: <1685544074-17337-1-git-send-email-quic_prashk@quicinc.com >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2023-07-27 08:44:06 +02:00
Chunfeng Yun
8e8d910e9a
usb: common: usb-conn-gpio: fix NULL pointer dereference of charger
...
[ Upstream commit 880287910b1892ed2cb38977893b947382a09d21 ]
When power on system with OTG cable, IDDIG's interrupt arises before
the charger registration, it will cause a NULL pointer dereference,
fix the issue by registering the power supply before requesting
IDDIG/VBUS irq.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com >
Link: https://lore.kernel.org/r/1621406386-18838-1-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2021-07-20 16:05:39 +02:00
Thierry Reding
f06c206aad
usb: common: usb-conn-gpio: Print error on failure to get VBUS
...
The exact error that happened trying to get the VBUS supply can be
useful to troubleshoot what's going on.
Signed-off-by: Thierry Reding <treding@nvidia.com >
Link: https://lore.kernel.org/r/20200806160248.3936771-2-thierry.reding@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-08-18 12:13:44 +02:00
Thierry Reding
4ddf1ac79e
usb: common: usb-conn-gpio: Make VBUS supply optional
...
If the connector is the child of a USB port and that USB port already
has a VBUS supply attached to it, it would be redundant to require the
connector to have a VBUS supply. In this case, allow the VBUS supply to
be optional.
Signed-off-by: Thierry Reding <treding@nvidia.com >
Link: https://lore.kernel.org/r/20200806160248.3936771-1-thierry.reding@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-08-18 12:13:44 +02:00
Paul Cercueil
e3ee0e740c
usb: common: usb-conn-gpio: Register charger
...
Register a power supply charger, whose online state depends on whether
the USB role is set to device or not.
This is useful when the USB role is the only way to know if the device
is charging from USB. The API is the standard power supply charger API,
you get a /sys/class/power_supply/xxx/online node which tells you the
state of the charger.
The sole purpose of this is to give userspace applications a way to
know whether or not the charger is plugged.
Signed-off-by: Paul Cercueil <paul@crapouillou.net >
Link: https://lore.kernel.org/r/20200727170413.23131-1-paul@crapouillou.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-30 08:45:24 +02:00
Lee Jones
11d96a5912
usb: common: usb-conn-gpio: Demote comment block which is clearly not kerneldoc
...
This block lacks a title and argument descriptions.
Fixes the following W=1 kernel build warning:
drivers/usb/common/usb-conn-gpio.c:44: warning: Cannot understand * "DEVICE" = VBUS and "HOST" = !ID, so we have:
on line 44 - I thought it was a doc line
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com >
Signed-off-by: Lee Jones <lee.jones@linaro.org >
Link: https://lore.kernel.org/r/20200702144625.2533530-5-lee.jones@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-07-03 09:34:11 +02:00
Bryan O'Donoghue
59120962e4
usb: common: usb-conn-gpio: Don't log an error on probe deferral
...
This patch makes the printout of the error message for failing to get a
VBUS regulator handle conditional on the error code being something other
than -EPROBE_DEFER.
Deferral is a normal thing, we don't need an error message for this.
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com >
Cc: Nagarjuna Kristam <nkristam@nvidia.com >
Cc: Linus Walleij <linus.walleij@linaro.org >
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Cc: linux-usb@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org >
Cc: stable <stable@vger.kernel.org >
Link: https://lore.kernel.org/r/20191128134358.3880498-2-bryan.odonoghue@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2019-12-10 11:41:20 +01:00
Chunfeng Yun
4602f3bff2
usb: common: add USB GPIO based connection detection driver
...
Due to the requirement of usb-connector.txt binding, the old way
using extcon to support USB Dual-Role switch is now deprecated
when use Type-B connector.
This patch introduces a USB GPIO based connection detection driver,
used to support Type-B connector which typically uses an input GPIO
to detect USB ID pin, and try to replace the function provided
by the extcon-usb-gpio driver
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com >
Tested-by: Nagarjuna Kristam <nkristam@nvidia.com >
Reviewed-by: Linus Walleij <linus.walleij@linaro.org >
Link: https://lore.kernel.org/r/1567070558-29417-11-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2019-09-03 19:01:04 +02:00