summary refs log tree commit diff
path: root/drivers/usb/common/usb-conn-gpio.c
AgeCommit message (Collapse)Author
2023-08-16usb: common: usb-conn-gpio: Prevent bailing out if initial role is nonePrashanth K
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: 4602f3bff266 ("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-07-19Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial ↵Greg Kroah-Hartman
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-19usb: common: usb-conn-gpio: Set last role to unknown before initial detectionPrashanth K
[ 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: 4602f3bff266 ("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>
2022-08-18usb: common: usb-conn-gpio: Simplify some error messageChristophe JAILLET
dev_err_probe() already prints the error code in a human readable way, so there is no need to duplicate it as a numerical value at the end of the message. Reviewed-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/7505a9dfa1e097070c492d6f6f84afa2a490b040.1659763173.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-10usb: common: usb-conn-gpio: Allow wakeup from system suspendPrashanth K
Currently the VBUS/ID detection interrupts are disabled during system suspend. So the USB cable connect/disconnect event can't wakeup the system from low power mode. To allow this, we keep these interrupts enabled and configure them as wakeup capable. This behavior can be controlled through device wakeup source policy by the user space. Signed-off-by: Prashanth K <quic_prashk@quicinc.com> Link: https://lore.kernel.org/r/1653634146-12215-1-git-send-email-quic_prashk@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-15usb: common: usb-conn-gpio: Make VBUS supply completely optionalAlexander Stein
It makes sense that if the USB connector is a child of an USB port providing VBUS supply, there is no need to do it again. But this does not handle the case where VBUS is controlled by PWR from USB host controller, without any regulator at all. Support this by making VBUS pure optional. Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> Link: https://lore.kernel.org/r/20220309093842.113260-1-alexander.stein@ew.tq-group.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27usb: common: usb-conn-gpio: use usb_role_string() to print role statusChunfeng Yun
Use usb_role_string() to print role status, make the log readable. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Link: https://lore.kernel.org/r/1621932786-9335-2-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-21usb: common: usb-conn-gpio: use dev_err_probe() to print logChunfeng Yun
Use dev_err_probe() to print debug or error message depending on whether the error value is -DPROBE_DEFER or not. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Link: https://lore.kernel.org/r/1621406386-18838-2-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-21usb: common: usb-conn-gpio: fix NULL pointer dereference of chargerChunfeng Yun
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>
2020-08-18usb: common: usb-conn-gpio: Print error on failure to get VBUSThierry Reding
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-18usb: common: usb-conn-gpio: Make VBUS supply optionalThierry Reding
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-07-30usb: common: usb-conn-gpio: Register chargerPaul Cercueil
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-03usb: common: usb-conn-gpio: Demote comment block which is clearly not kerneldocLee Jones
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>
2019-12-10usb: common: usb-conn-gpio: Don't log an error on probe deferralBryan O'Donoghue
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-09-03usb: common: add USB GPIO based connection detection driverChunfeng Yun
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>