Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc3: qcom: Remove extcon functionality from glue layer

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://lore.kernel.org/all/20250414-dwc3-refactor-v7-0-f015b358722d@oss.qualcomm.com/

Signed-off-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250729092708.3628187-1-krishna.kurapati@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Krishna Kurapati and committed by
Greg Kroah-Hartman
aeb01692 4b58e063

+1 -89
+1 -89
drivers/usb/dwc3/dwc3-qcom.c
··· 11 11 #include <linux/of_clk.h> 12 12 #include <linux/module.h> 13 13 #include <linux/kernel.h> 14 - #include <linux/extcon.h> 15 14 #include <linux/interconnect.h> 16 15 #include <linux/platform_device.h> 17 16 #include <linux/phy/phy.h> ··· 78 79 struct dwc3_qcom_port ports[DWC3_QCOM_MAX_PORTS]; 79 80 u8 num_ports; 80 81 81 - struct extcon_dev *edev; 82 - struct extcon_dev *host_edev; 83 - struct notifier_block vbus_nb; 84 - struct notifier_block host_nb; 85 - 86 82 enum usb_dr_mode mode; 87 83 bool is_suspended; 88 84 bool pm_suspended; ··· 113 119 114 120 /* 115 121 * TODO: Make the in-core role switching code invoke dwc3_qcom_vbus_override_enable(), 116 - * validate that the in-core extcon support is functional, and drop extcon 117 - * handling from the glue 122 + * validate that the in-core extcon support is functional 118 123 */ 119 124 static void dwc3_qcom_vbus_override_enable(struct dwc3_qcom *qcom, bool enable) 120 125 { ··· 128 135 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_HS_PHY_CTRL, 129 136 UTMI_OTG_VBUS_VALID | SW_SESSVLD_SEL); 130 137 } 131 - } 132 - 133 - static int dwc3_qcom_vbus_notifier(struct notifier_block *nb, 134 - unsigned long event, void *ptr) 135 - { 136 - struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, vbus_nb); 137 - 138 - /* enable vbus override for device mode */ 139 - dwc3_qcom_vbus_override_enable(qcom, event); 140 - qcom->mode = event ? USB_DR_MODE_PERIPHERAL : USB_DR_MODE_HOST; 141 - 142 - return NOTIFY_DONE; 143 - } 144 - 145 - static int dwc3_qcom_host_notifier(struct notifier_block *nb, 146 - unsigned long event, void *ptr) 147 - { 148 - struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, host_nb); 149 - 150 - /* disable vbus override in host mode */ 151 - dwc3_qcom_vbus_override_enable(qcom, !event); 152 - qcom->mode = event ? USB_DR_MODE_HOST : USB_DR_MODE_PERIPHERAL; 153 - 154 - return NOTIFY_DONE; 155 - } 156 - 157 - static int dwc3_qcom_register_extcon(struct dwc3_qcom *qcom) 158 - { 159 - struct device *dev = qcom->dev; 160 - struct extcon_dev *host_edev; 161 - int ret; 162 - 163 - if (!of_property_present(dev->of_node, "extcon")) 164 - return 0; 165 - 166 - qcom->edev = extcon_get_edev_by_phandle(dev, 0); 167 - if (IS_ERR(qcom->edev)) 168 - return dev_err_probe(dev, PTR_ERR(qcom->edev), 169 - "Failed to get extcon\n"); 170 - 171 - qcom->vbus_nb.notifier_call = dwc3_qcom_vbus_notifier; 172 - 173 - qcom->host_edev = extcon_get_edev_by_phandle(dev, 1); 174 - if (IS_ERR(qcom->host_edev)) 175 - qcom->host_edev = NULL; 176 - 177 - ret = devm_extcon_register_notifier(dev, qcom->edev, EXTCON_USB, 178 - &qcom->vbus_nb); 179 - if (ret < 0) { 180 - dev_err(dev, "VBUS notifier register failed\n"); 181 - return ret; 182 - } 183 - 184 - if (qcom->host_edev) 185 - host_edev = qcom->host_edev; 186 - else 187 - host_edev = qcom->edev; 188 - 189 - qcom->host_nb.notifier_call = dwc3_qcom_host_notifier; 190 - ret = devm_extcon_register_notifier(dev, host_edev, EXTCON_USB_HOST, 191 - &qcom->host_nb); 192 - if (ret < 0) { 193 - dev_err(dev, "Host notifier register failed\n"); 194 - return ret; 195 - } 196 - 197 - /* Update initial VBUS override based on extcon state */ 198 - if (extcon_get_state(qcom->edev, EXTCON_USB) || 199 - !extcon_get_state(host_edev, EXTCON_USB_HOST)) 200 - dwc3_qcom_vbus_notifier(&qcom->vbus_nb, true, qcom->edev); 201 - else 202 - dwc3_qcom_vbus_notifier(&qcom->vbus_nb, false, qcom->edev); 203 - 204 - return 0; 205 138 } 206 139 207 140 static int dwc3_qcom_interconnect_enable(struct dwc3_qcom *qcom) ··· 656 737 if (qcom->mode != USB_DR_MODE_HOST) 657 738 dwc3_qcom_vbus_override_enable(qcom, true); 658 739 659 - /* register extcon to override sw_vbus on Vbus change later */ 660 - ret = dwc3_qcom_register_extcon(qcom); 661 - if (ret) 662 - goto interconnect_exit; 663 - 664 740 wakeup_source = of_property_read_bool(dev->of_node, "wakeup-source"); 665 741 device_init_wakeup(&pdev->dev, wakeup_source); 666 742 ··· 663 749 664 750 return 0; 665 751 666 - interconnect_exit: 667 - dwc3_qcom_interconnect_exit(qcom); 668 752 remove_core: 669 753 dwc3_core_remove(&qcom->dwc); 670 754 clk_disable: