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

Merge tag 'extcon-next-for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next

Chanwoo writes:

Update extcon next for v5.13

Detailed description for this pull request:

1. Update extcon provider driver
- Add the support of charging interrupt to detect charger connector
for extcon-max8997.c

- Detect OTG when USB_ID pin is connected to ground for extcon-sm5502.c

- Add the support for VBUS detection for extcon-qcom-spmi-misc.c
and replace qcom,pm8941-misc binding document with yaml style.

* tag 'extcon-next-for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon:
extcon: qcom-spmi: Add support for VBUS detection
bindings: pm8941-misc: Add support for VBUS detection
bindings: pm8941-misc: Convert bindings to YAML
extcon: sm5502: Detect OTG when USB_ID is connected to ground
extcon: max8997: Add CHGINS and CHGRM interrupt handling

+167 -63
-41
Documentation/devicetree/bindings/extcon/qcom,pm8941-misc.txt
··· 1 - Qualcomm's PM8941 USB ID Extcon device 2 - 3 - Some Qualcomm PMICs have a "misc" module that can be used to detect when 4 - the USB ID pin has been pulled low or high. 5 - 6 - PROPERTIES 7 - 8 - - compatible: 9 - Usage: required 10 - Value type: <string> 11 - Definition: Should contain "qcom,pm8941-misc"; 12 - 13 - - reg: 14 - Usage: required 15 - Value type: <u32> 16 - Definition: Should contain the offset to the misc address space 17 - 18 - - interrupts: 19 - Usage: required 20 - Value type: <prop-encoded-array> 21 - Definition: Should contain the usb id interrupt 22 - 23 - - interrupt-names: 24 - Usage: required 25 - Value type: <stringlist> 26 - Definition: Should contain the string "usb_id" for the usb id interrupt 27 - 28 - Example: 29 - 30 - pmic { 31 - usb_id: misc@900 { 32 - compatible = "qcom,pm8941-misc"; 33 - reg = <0x900>; 34 - interrupts = <0x0 0x9 0 IRQ_TYPE_EDGE_BOTH>; 35 - interrupt-names = "usb_id"; 36 - }; 37 - } 38 - 39 - usb-controller { 40 - extcon = <&usb_id>; 41 - };
+62
Documentation/devicetree/bindings/extcon/qcom,pm8941-misc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/extcon/qcom,pm8941-misc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm Technologies, Inc. PM8941 USB ID Extcon device 8 + 9 + maintainers: 10 + - Guru Das Srinagesh <gurus@codeaurora.org> 11 + 12 + description: | 13 + Some Qualcomm PMICs have a "misc" module that can be used to detect when 14 + the USB ID pin has been pulled low or high. 15 + 16 + properties: 17 + compatible: 18 + items: 19 + - const: qcom,pm8941-misc 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + interrupts: 25 + minItems: 1 26 + maxItems: 2 27 + 28 + interrupt-names: 29 + minItems: 1 30 + items: 31 + - const: usb_id 32 + - const: usb_vbus 33 + 34 + required: 35 + - compatible 36 + - reg 37 + - interrupts 38 + - interrupt-names 39 + 40 + additionalProperties: false 41 + 42 + examples: 43 + - | 44 + #include <dt-bindings/interrupt-controller/irq.h> 45 + 46 + pmic { 47 + #address-cells = <1>; 48 + #size-cells = <0>; 49 + interrupt-controller; 50 + #interrupt-cells = <4>; 51 + 52 + usb_id: misc@900 { 53 + compatible = "qcom,pm8941-misc"; 54 + reg = <0x900>; 55 + interrupts = <0x0 0x9 0 IRQ_TYPE_EDGE_BOTH>; 56 + interrupt-names = "usb_id"; 57 + }; 58 + }; 59 + 60 + usb-controller { 61 + extcon = <&usb_id>; 62 + };
+4
drivers/extcon/extcon-max8997.c
··· 44 44 { MAX8997_MUICIRQ_ChgDetRun, "muic-CHGDETRUN" }, 45 45 { MAX8997_MUICIRQ_ChgTyp, "muic-CHGTYP" }, 46 46 { MAX8997_MUICIRQ_OVP, "muic-OVP" }, 47 + { MAX8997_PMICIRQ_CHGINS, "pmic-CHGINS" }, 48 + { MAX8997_PMICIRQ_CHGRM, "pmic-CHGRM" }, 47 49 }; 48 50 49 51 /* Define supported cable type */ ··· 540 538 case MAX8997_MUICIRQ_DCDTmr: 541 539 case MAX8997_MUICIRQ_ChgDetRun: 542 540 case MAX8997_MUICIRQ_ChgTyp: 541 + case MAX8997_PMICIRQ_CHGINS: 542 + case MAX8997_PMICIRQ_CHGRM: 543 543 /* Handle charger cable */ 544 544 ret = max8997_muic_chg_handler(info); 545 545 break;
+81 -20
drivers/extcon/extcon-qcom-spmi-misc.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /** 3 3 * extcon-qcom-spmi-misc.c - Qualcomm USB extcon driver to support USB ID 4 - * detection based on extcon-usb-gpio.c. 4 + * and VBUS detection based on extcon-usb-gpio.c. 5 5 * 6 6 * Copyright (C) 2016 Linaro, Ltd. 7 7 * Stephen Boyd <stephen.boyd@linaro.org> ··· 21 21 22 22 struct qcom_usb_extcon_info { 23 23 struct extcon_dev *edev; 24 - int irq; 24 + int id_irq; 25 + int vbus_irq; 25 26 struct delayed_work wq_detcable; 26 27 unsigned long debounce_jiffies; 27 28 }; 28 29 29 30 static const unsigned int qcom_usb_extcon_cable[] = { 31 + EXTCON_USB, 30 32 EXTCON_USB_HOST, 31 33 EXTCON_NONE, 32 34 }; 33 35 34 36 static void qcom_usb_extcon_detect_cable(struct work_struct *work) 35 37 { 36 - bool id; 38 + bool state = false; 37 39 int ret; 40 + union extcon_property_value val; 38 41 struct qcom_usb_extcon_info *info = container_of(to_delayed_work(work), 39 42 struct qcom_usb_extcon_info, 40 43 wq_detcable); 41 44 42 - /* check ID and update cable state */ 43 - ret = irq_get_irqchip_state(info->irq, IRQCHIP_STATE_LINE_LEVEL, &id); 44 - if (ret) 45 - return; 45 + if (info->id_irq > 0) { 46 + /* check ID and update cable state */ 47 + ret = irq_get_irqchip_state(info->id_irq, 48 + IRQCHIP_STATE_LINE_LEVEL, &state); 49 + if (ret) 50 + return; 46 51 47 - extcon_set_state_sync(info->edev, EXTCON_USB_HOST, !id); 52 + if (!state) { 53 + val.intval = true; 54 + extcon_set_property(info->edev, EXTCON_USB_HOST, 55 + EXTCON_PROP_USB_SS, val); 56 + } 57 + extcon_set_state_sync(info->edev, EXTCON_USB_HOST, !state); 58 + } 59 + 60 + if (info->vbus_irq > 0) { 61 + /* check VBUS and update cable state */ 62 + ret = irq_get_irqchip_state(info->vbus_irq, 63 + IRQCHIP_STATE_LINE_LEVEL, &state); 64 + if (ret) 65 + return; 66 + 67 + if (state) { 68 + val.intval = true; 69 + extcon_set_property(info->edev, EXTCON_USB, 70 + EXTCON_PROP_USB_SS, val); 71 + } 72 + extcon_set_state_sync(info->edev, EXTCON_USB, state); 73 + } 48 74 } 49 75 50 76 static irqreturn_t qcom_usb_irq_handler(int irq, void *dev_id) ··· 105 79 return ret; 106 80 } 107 81 82 + ret = extcon_set_property_capability(info->edev, 83 + EXTCON_USB, EXTCON_PROP_USB_SS); 84 + ret |= extcon_set_property_capability(info->edev, 85 + EXTCON_USB_HOST, EXTCON_PROP_USB_SS); 86 + if (ret) { 87 + dev_err(dev, "failed to register extcon props rc=%d\n", 88 + ret); 89 + return ret; 90 + } 91 + 108 92 info->debounce_jiffies = msecs_to_jiffies(USB_ID_DEBOUNCE_MS); 109 93 INIT_DELAYED_WORK(&info->wq_detcable, qcom_usb_extcon_detect_cable); 110 94 111 - info->irq = platform_get_irq_byname(pdev, "usb_id"); 112 - if (info->irq < 0) 113 - return info->irq; 114 - 115 - ret = devm_request_threaded_irq(dev, info->irq, NULL, 95 + info->id_irq = platform_get_irq_byname(pdev, "usb_id"); 96 + if (info->id_irq > 0) { 97 + ret = devm_request_threaded_irq(dev, info->id_irq, NULL, 116 98 qcom_usb_irq_handler, 117 99 IRQF_TRIGGER_RISING | 118 100 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 119 101 pdev->name, info); 120 - if (ret < 0) { 121 - dev_err(dev, "failed to request handler for ID IRQ\n"); 122 - return ret; 102 + if (ret < 0) { 103 + dev_err(dev, "failed to request handler for ID IRQ\n"); 104 + return ret; 105 + } 106 + } 107 + 108 + info->vbus_irq = platform_get_irq_byname(pdev, "usb_vbus"); 109 + if (info->vbus_irq > 0) { 110 + ret = devm_request_threaded_irq(dev, info->vbus_irq, NULL, 111 + qcom_usb_irq_handler, 112 + IRQF_TRIGGER_RISING | 113 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 114 + pdev->name, info); 115 + if (ret < 0) { 116 + dev_err(dev, "failed to request handler for VBUS IRQ\n"); 117 + return ret; 118 + } 119 + } 120 + 121 + if (info->id_irq < 0 && info->vbus_irq < 0) { 122 + dev_err(dev, "ID and VBUS IRQ not found\n"); 123 + return -EINVAL; 123 124 } 124 125 125 126 platform_set_drvdata(pdev, info); ··· 173 120 struct qcom_usb_extcon_info *info = dev_get_drvdata(dev); 174 121 int ret = 0; 175 122 176 - if (device_may_wakeup(dev)) 177 - ret = enable_irq_wake(info->irq); 123 + if (device_may_wakeup(dev)) { 124 + if (info->id_irq > 0) 125 + ret = enable_irq_wake(info->id_irq); 126 + if (info->vbus_irq > 0) 127 + ret = enable_irq_wake(info->vbus_irq); 128 + } 178 129 179 130 return ret; 180 131 } ··· 188 131 struct qcom_usb_extcon_info *info = dev_get_drvdata(dev); 189 132 int ret = 0; 190 133 191 - if (device_may_wakeup(dev)) 192 - ret = disable_irq_wake(info->irq); 134 + if (device_may_wakeup(dev)) { 135 + if (info->id_irq > 0) 136 + ret = disable_irq_wake(info->id_irq); 137 + if (info->vbus_irq > 0) 138 + ret = disable_irq_wake(info->vbus_irq); 139 + } 193 140 194 141 return ret; 195 142 }
+20 -2
drivers/extcon/extcon-sm5502.c
··· 144 144 SM5502_MUIC_ADC_AUDIO_TYPE1_FULL_REMOTE = 0x3e, /* | 001|11110| */ 145 145 SM5502_MUIC_ADC_AUDIO_TYPE1_SEND_END = 0x5e, /* | 010|11110| */ 146 146 /* |Dev Type1|--ADC| */ 147 + SM5502_MUIC_ADC_GROUND_USB_OTG = 0x80, /* | 100|00000| */ 147 148 SM5502_MUIC_ADC_OPEN_USB = 0x5f, /* | 010|11111| */ 148 149 SM5502_MUIC_ADC_OPEN_TA = 0xdf, /* | 110|11111| */ 149 150 SM5502_MUIC_ADC_OPEN_USB_OTG = 0xff, /* | 111|11111| */ ··· 292 291 * connected with to MUIC device. 293 292 */ 294 293 cable_type = adc & SM5502_REG_ADC_MASK; 295 - if (cable_type == SM5502_MUIC_ADC_GROUND) 296 - return SM5502_MUIC_ADC_GROUND; 297 294 298 295 switch (cable_type) { 299 296 case SM5502_MUIC_ADC_GROUND: 297 + ret = regmap_read(info->regmap, SM5502_REG_DEV_TYPE1, 298 + &dev_type1); 299 + if (ret) { 300 + dev_err(info->dev, "failed to read DEV_TYPE1 reg\n"); 301 + return ret; 302 + } 303 + 304 + switch (dev_type1) { 305 + case SM5502_REG_DEV_TYPE1_USB_OTG_MASK: 306 + cable_type = SM5502_MUIC_ADC_GROUND_USB_OTG; 307 + break; 308 + default: 309 + dev_dbg(info->dev, 310 + "cannot identify the cable type: adc(0x%x), dev_type1(0x%x)\n", 311 + adc, dev_type1); 312 + return -EINVAL; 313 + } 314 + break; 300 315 case SM5502_MUIC_ADC_SEND_END_BUTTON: 301 316 case SM5502_MUIC_ADC_REMOTE_S1_BUTTON: 302 317 case SM5502_MUIC_ADC_REMOTE_S2_BUTTON: ··· 413 396 con_sw = DM_DP_SWITCH_OPEN; 414 397 vbus_sw = VBUSIN_SWITCH_VBUSOUT; 415 398 break; 399 + case SM5502_MUIC_ADC_GROUND_USB_OTG: 416 400 case SM5502_MUIC_ADC_OPEN_USB_OTG: 417 401 id = EXTCON_USB_HOST; 418 402 con_sw = DM_DP_SWITCH_USB;