[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250807010339.smx62c375wakppql@synopsys.com>
Date: Thu, 7 Aug 2025 01:03:39 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Krishna Kurapati <krishna.kurapati@....qualcomm.com>
CC: Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Bjorn Andersson <bjorn.andersson@....qualcomm.com>,
Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>,
Konrad Dybcio <konrad.dybcio@....qualcomm.com>,
"linux-arm-msm@...r.kernel.org" <linux-arm-msm@...r.kernel.org>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5] usb: dwc3: qcom: Remove extcon functionality from glue
layer
On Tue, Jul 29, 2025, Krishna Kurapati wrote:
> Historically Qualcomm DWC3 glue driver supported both extcon and
> usb-role-switch kinds of notifications. When Bjorn contributed [1] the
> flattened representation for the DWC3 host controller, he also kept both
> extcon and usb-role-switch support in the flattened driver & bindings.
>
> Currently there are no in-kernel users for flattened DWC3 and extcon. As
> device's DT needs to be manually converted from legacy to the flat DWC3
> representation, we can drop (legacy / deprecated) extcon support from
> the new DWC3 glue driver, significantly simplifying the code.
>
> This potentially affects flattening effort for the following platforms:
>
> Platforms currently using linux,extcon-usb-gpio device that need to
> switch to gpio-usb-b-connector:
> - apq8096-db820c,
> - msm8996-sony-xperia-tone-dora
>
> Platforms currently using linux,extcon-usb-gpio device that need to
> switch to gpio-usb-c-connector (not supported at this moment) or to
> implement typec support
> - msm8996-sony-xperia-tone-kagura
> - msm8996-sony-xperia-tone-keyaki
> - msm8998-fxtec-pro1
> - msm8998-sony-xperia-yoshino-lilac
> - msm8998-sony-xperia-yoshino-maple
> - msm8998-sony-xperia-yoshino-poplar
> - sda660-inforce-ifc6560
> - sdm630-sony-xperia-nile-discovery
> - sdm630-sony-xperia-nile-pioneer
> - sdm630-sony-xperia-nile-voyager
> - sdm660-xiaomi-lavender
> - sm6125-sony-xperia-seine-pdx201
> - sm6125-xiaomi-ginkgo
> - sm6125-xiaomi-laurel-sprout
>
> Platforms using TI TUSB320L chip need to switch to represent the USB-C
> connector properly (and to have a typec-class driver for the TUSB320L
> chip):
> - msm8996-xiaomi-gemini
> - msm8996pro-xiaomi-natrium
> - msm8996pro-xiaomi-scoprpio
>
> Commit message suggested by Dmitry Baryshkov.
>
> [1]: https://urldefense.com/v3/__https://lore.kernel.org/all/20250414-dwc3-refactor-v7-0-f015b358722d@oss.qualcomm.com/__;!!A4F2R9G_pg!f2m60JqdIq5eGtr9jrPGKpmHZI5bTmiGGhO_CfenvRC56ZZvxTnaCRYj4e6r6_Ttmeq5MoABH_2kf0vRoLi3YZ4swnayUyaP28aSfA$
>
> Signed-off-by: Krishna Kurapati <krishna.kurapati@....qualcomm.com>
> ---
> Changes in v5:
> Changed commit message to explain the issue in more detail.
>
> Link to v4:
> https://urldefense.com/v3/__https://lore.kernel.org/all/20250718053856.2859946-1-krishna.kurapati@oss.qualcomm.com/__;!!A4F2R9G_pg!f2m60JqdIq5eGtr9jrPGKpmHZI5bTmiGGhO_CfenvRC56ZZvxTnaCRYj4e6r6_Ttmeq5MoABH_2kf0vRoLi3YZ4swnayUyaJ5iDj0g$
>
> Changes in v4:
> Updated commit text to reflect the patch doesn't affect in-kernel users.
> Removed RB tags from v3 since commit text is changed.
>
> Link to v3:
> https://urldefense.com/v3/__https://lore.kernel.org/all/20250714044703.2091075-1-krishna.kurapati@oss.qualcomm.com/__;!!A4F2R9G_pg!f2m60JqdIq5eGtr9jrPGKpmHZI5bTmiGGhO_CfenvRC56ZZvxTnaCRYj4e6r6_Ttmeq5MoABH_2kf0vRoLi3YZ4swnayUyZdza0mCw$
>
> Changes in v3:
> This change was 4rth patch in [1]. It was suggested to make this as the
> first patch of the series. Since this is independent of role switch
> patches, sending this out separately. Removed RB Tag of Dmitry since the
> patch has been changed.
>
> [1]: https://urldefense.com/v3/__https://lore.kernel.org/all/20250610091357.2983085-1-krishna.kurapati@oss.qualcomm.com/__;!!A4F2R9G_pg!f2m60JqdIq5eGtr9jrPGKpmHZI5bTmiGGhO_CfenvRC56ZZvxTnaCRYj4e6r6_Ttmeq5MoABH_2kf0vRoLi3YZ4swnayUyZ4cNNtlQ$
>
> drivers/usb/dwc3/dwc3-qcom.c | 90 +-----------------------------------
> 1 file changed, 1 insertion(+), 89 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index ca7e1c02773a..a7eaefaeec4d 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -11,7 +11,6 @@
> #include <linux/of_clk.h>
> #include <linux/module.h>
> #include <linux/kernel.h>
> -#include <linux/extcon.h>
> #include <linux/interconnect.h>
> #include <linux/platform_device.h>
> #include <linux/phy/phy.h>
> @@ -79,11 +78,6 @@ struct dwc3_qcom {
> struct dwc3_qcom_port ports[DWC3_QCOM_MAX_PORTS];
> u8 num_ports;
>
> - struct extcon_dev *edev;
> - struct extcon_dev *host_edev;
> - struct notifier_block vbus_nb;
> - struct notifier_block host_nb;
> -
> enum usb_dr_mode mode;
> bool is_suspended;
> bool pm_suspended;
> @@ -119,8 +113,7 @@ static inline void dwc3_qcom_clrbits(void __iomem *base, u32 offset, u32 val)
>
> /*
> * TODO: Make the in-core role switching code invoke dwc3_qcom_vbus_override_enable(),
> - * validate that the in-core extcon support is functional, and drop extcon
> - * handling from the glue
> + * validate that the in-core extcon support is functional
> */
> static void dwc3_qcom_vbus_override_enable(struct dwc3_qcom *qcom, bool enable)
> {
> @@ -137,80 +130,6 @@ static void dwc3_qcom_vbus_override_enable(struct dwc3_qcom *qcom, bool enable)
> }
> }
>
> -static int dwc3_qcom_vbus_notifier(struct notifier_block *nb,
> - unsigned long event, void *ptr)
> -{
> - struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, vbus_nb);
> -
> - /* enable vbus override for device mode */
> - dwc3_qcom_vbus_override_enable(qcom, event);
> - qcom->mode = event ? USB_DR_MODE_PERIPHERAL : USB_DR_MODE_HOST;
> -
> - return NOTIFY_DONE;
> -}
> -
> -static int dwc3_qcom_host_notifier(struct notifier_block *nb,
> - unsigned long event, void *ptr)
> -{
> - struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, host_nb);
> -
> - /* disable vbus override in host mode */
> - dwc3_qcom_vbus_override_enable(qcom, !event);
> - qcom->mode = event ? USB_DR_MODE_HOST : USB_DR_MODE_PERIPHERAL;
> -
> - return NOTIFY_DONE;
> -}
> -
> -static int dwc3_qcom_register_extcon(struct dwc3_qcom *qcom)
> -{
> - struct device *dev = qcom->dev;
> - struct extcon_dev *host_edev;
> - int ret;
> -
> - if (!of_property_present(dev->of_node, "extcon"))
> - return 0;
> -
> - qcom->edev = extcon_get_edev_by_phandle(dev, 0);
> - if (IS_ERR(qcom->edev))
> - return dev_err_probe(dev, PTR_ERR(qcom->edev),
> - "Failed to get extcon\n");
> -
> - qcom->vbus_nb.notifier_call = dwc3_qcom_vbus_notifier;
> -
> - qcom->host_edev = extcon_get_edev_by_phandle(dev, 1);
> - if (IS_ERR(qcom->host_edev))
> - qcom->host_edev = NULL;
> -
> - ret = devm_extcon_register_notifier(dev, qcom->edev, EXTCON_USB,
> - &qcom->vbus_nb);
> - if (ret < 0) {
> - dev_err(dev, "VBUS notifier register failed\n");
> - return ret;
> - }
> -
> - if (qcom->host_edev)
> - host_edev = qcom->host_edev;
> - else
> - host_edev = qcom->edev;
> -
> - qcom->host_nb.notifier_call = dwc3_qcom_host_notifier;
> - ret = devm_extcon_register_notifier(dev, host_edev, EXTCON_USB_HOST,
> - &qcom->host_nb);
> - if (ret < 0) {
> - dev_err(dev, "Host notifier register failed\n");
> - return ret;
> - }
> -
> - /* Update initial VBUS override based on extcon state */
> - if (extcon_get_state(qcom->edev, EXTCON_USB) ||
> - !extcon_get_state(host_edev, EXTCON_USB_HOST))
> - dwc3_qcom_vbus_notifier(&qcom->vbus_nb, true, qcom->edev);
> - else
> - dwc3_qcom_vbus_notifier(&qcom->vbus_nb, false, qcom->edev);
> -
> - return 0;
> -}
> -
> static int dwc3_qcom_interconnect_enable(struct dwc3_qcom *qcom)
> {
> int ret;
> @@ -737,11 +656,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> if (qcom->mode != USB_DR_MODE_HOST)
> dwc3_qcom_vbus_override_enable(qcom, true);
>
> - /* register extcon to override sw_vbus on Vbus change later */
> - ret = dwc3_qcom_register_extcon(qcom);
> - if (ret)
> - goto interconnect_exit;
> -
> wakeup_source = of_property_read_bool(dev->of_node, "wakeup-source");
> device_init_wakeup(&pdev->dev, wakeup_source);
>
> @@ -749,8 +663,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
>
> return 0;
>
> -interconnect_exit:
> - dwc3_qcom_interconnect_exit(qcom);
> remove_core:
> dwc3_core_remove(&qcom->dwc);
> clk_disable:
> --
> 2.34.1
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
Thanks,
Thinh
Powered by blists - more mailing lists