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

ASoC: da7219: Add jack insertion detection polarity

Merge series from David Rau <David.Rau.opensource@dm.renesas.com>:

This patchset adds the support of DA7219 Jack insertion detection
polarity selection.

The first patch replaces the old txt binding with a new schema binding.

The second patch adds `dlg,jack-ins-det-pty` property for Jack
insertion detection polarity selection.

The last patch adds the driver support for this topic.

The series has been verified on the DA7219 development kit.

+281 -116
-112
Documentation/devicetree/bindings/sound/da7219.txt
··· 1 - Dialog Semiconductor DA7219 Audio Codec bindings 2 - 3 - DA7219 is an audio codec with advanced accessory detect features. 4 - 5 - ====== 6 - 7 - Required properties: 8 - - compatible : Should be "dlg,da7219" 9 - - reg: Specifies the I2C slave address 10 - 11 - - interrupts : IRQ line info for DA7219. 12 - (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for 13 - further information relating to interrupt properties) 14 - 15 - - VDD-supply: VDD power supply for the device 16 - - VDDMIC-supply: VDDMIC power supply for the device 17 - - VDDIO-supply: VDDIO power supply for the device 18 - (See Documentation/devicetree/bindings/regulator/regulator.txt for further 19 - information relating to regulators) 20 - 21 - Optional properties: 22 - - interrupt-names : Name associated with interrupt line. Should be "wakeup" if 23 - interrupt is to be used to wake system, otherwise "irq" should be used. 24 - - wakeup-source: Flag to indicate this device can wake system (suspend/resume). 25 - 26 - - #clock-cells : Should be set to '<1>', two clock sources provided; 27 - - clock-output-names : Names given for DAI clock outputs (WCLK & BCLK); 28 - 29 - - clocks : phandle and clock specifier for codec MCLK. 30 - - clock-names : Clock name string for 'clocks' attribute, should be "mclk". 31 - 32 - - dlg,micbias-lvl : Voltage (mV) for Mic Bias 33 - [<1600>, <1800>, <2000>, <2200>, <2400>, <2600>] 34 - - dlg,mic-amp-in-sel : Mic input source type 35 - ["diff", "se_p", "se_n"] 36 - 37 - Deprecated properties: 38 - - dlg,ldo-lvl : Required internal LDO voltage (mV) level for digital engine 39 - (LDO unavailable in production HW so property no longer required). 40 - 41 - ====== 42 - 43 - Child node - 'da7219_aad': 44 - 45 - Optional properties: 46 - - dlg,micbias-pulse-lvl : Mic bias higher voltage pulse level (mV). 47 - [<2800>, <2900>] 48 - - dlg,micbias-pulse-time : Mic bias higher voltage pulse duration (ms) 49 - - dlg,btn-cfg : Periodic button press measurements for 4-pole jack (ms) 50 - [<2>, <5>, <10>, <50>, <100>, <200>, <500>] 51 - - dlg,mic-det-thr : Impedance threshold for mic detection measurement (Ohms) 52 - [<200>, <500>, <750>, <1000>] 53 - - dlg,jack-ins-deb : Debounce time for jack insertion (ms) 54 - [<5>, <10>, <20>, <50>, <100>, <200>, <500>, <1000>] 55 - - dlg,jack-det-rate: Jack type detection latency (3/4 pole) 56 - ["32ms_64ms", "64ms_128ms", "128ms_256ms", "256ms_512ms"] 57 - - dlg,jack-rem-deb : Debounce time for jack removal (ms) 58 - [<1>, <5>, <10>, <20>] 59 - - dlg,a-d-btn-thr : Impedance threshold between buttons A and D 60 - [0x0 - 0xFF] 61 - - dlg,d-b-btn-thr : Impedance threshold between buttons D and B 62 - [0x0 - 0xFF] 63 - - dlg,b-c-btn-thr : Impedance threshold between buttons B and C 64 - [0x0 - 0xFF] 65 - - dlg,c-mic-btn-thr : Impedance threshold between button C and Mic 66 - [0x0 - 0xFF] 67 - - dlg,btn-avg : Number of 8-bit readings for averaged button measurement 68 - [<1>, <2>, <4>, <8>] 69 - - dlg,adc-1bit-rpt : Repeat count for 1-bit button measurement 70 - [<1>, <2>, <4>, <8>] 71 - 72 - ====== 73 - 74 - Example: 75 - 76 - codec: da7219@1a { 77 - compatible = "dlg,da7219"; 78 - reg = <0x1a>; 79 - 80 - interrupt-parent = <&gpio6>; 81 - interrupts = <11 IRQ_TYPE_LEVEL_LOW>; 82 - 83 - VDD-supply = <&reg_audio>; 84 - VDDMIC-supply = <&reg_audio>; 85 - VDDIO-supply = <&reg_audio>; 86 - 87 - #clock-cells = <1>; 88 - clock-output-names = "dai-wclk", "dai-bclk"; 89 - 90 - clocks = <&clks 201>; 91 - clock-names = "mclk"; 92 - 93 - dlg,ldo-lvl = <1200>; 94 - dlg,micbias-lvl = <2600>; 95 - dlg,mic-amp-in-sel = "diff"; 96 - 97 - da7219_aad { 98 - dlg,btn-cfg = <50>; 99 - dlg,mic-det-thr = <500>; 100 - dlg,jack-ins-deb = <20>; 101 - dlg,jack-det-rate = "32ms_64ms"; 102 - dlg,jack-rem-deb = <1>; 103 - 104 - dlg,a-d-btn-thr = <0xa>; 105 - dlg,d-b-btn-thr = <0x16>; 106 - dlg,b-c-btn-thr = <0x21>; 107 - dlg,c-mic-btn-thr = <0x3E>; 108 - 109 - dlg,btn-avg = <4>; 110 - dlg,adc-1bit-rpt = <1>; 111 - }; 112 - };
+237
Documentation/devicetree/bindings/sound/dialog,da7219.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/sound/dialog,da7219.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Dialog Semiconductor DA7219 Audio Codec 8 + 9 + maintainers: 10 + - David Rau <David.Rau.opensource@dm.renesas.com> 11 + 12 + description: 13 + The DA7219 is an ultra low-power audio codec with 14 + in-built advanced accessory detection (AAD) for mobile 15 + computing and accessory applications, which supports 16 + sample rates up to 96 kHz at 24-bit resolution. 17 + 18 + properties: 19 + compatible: 20 + const: dlg,da7219 21 + 22 + reg: 23 + maxItems: 1 24 + 25 + interrupts: 26 + maxItems: 1 27 + 28 + VDD-supply: 29 + description: 30 + VDD power supply for the device. 31 + 32 + VDDMIC-supply: 33 + description: 34 + VDDMIC power supply for the device. 35 + 36 + VDDIO-supply: 37 + description: 38 + VDDIO power supply for the device. 39 + 40 + interrupt-names: 41 + description: 42 + Should be "wakeup" if interrupt is to be used to wake system, 43 + otherwise "irq" should be used. 44 + enum: 45 + - wakeup 46 + - irq 47 + 48 + wakeup-source: 49 + type: boolean 50 + description: 51 + Flag to indicate this device can wake system (suspend/resume). 52 + 53 + "#clock-cells": 54 + const: 1 55 + 56 + clock-output-names: 57 + minItems: 2 58 + maxItems: 2 59 + description: 60 + Name given for DAI WCLK and BCLK outputs. 61 + 62 + clocks: 63 + maxItems: 1 64 + description: 65 + phandle and clock specifier for codec MCLK. 66 + 67 + clock-names: 68 + const: mclk 69 + 70 + dlg,micbias-lvl: 71 + enum: [1600, 1800, 2000, 2200, 2400, 2600] 72 + description: 73 + Voltage (mV) for Mic Bias. 74 + $ref: /schemas/types.yaml#/definitions/uint32 75 + 76 + dlg,mic-amp-in-sel: 77 + enum: ["diff", "se_p", "se_n"] 78 + description: 79 + Mic input source type. 80 + 81 + diff - Differential. 82 + 83 + se_p - MIC_P. 84 + Positive differential analog microphone input. 85 + 86 + se_n - MIC_N. 87 + Negative differential analog microphone input. 88 + $ref: /schemas/types.yaml#/definitions/string 89 + 90 + da7219_aad: 91 + type: object 92 + description: 93 + Configuration of advanced accessory detection. 94 + properties: 95 + dlg,micbias-pulse-lvl: 96 + enum: [2800, 2900] 97 + description: 98 + Mic bias higher voltage pulse level (mV). 99 + $ref: /schemas/types.yaml#/definitions/uint32 100 + 101 + dlg,micbias-pulse-time: 102 + description: 103 + Mic bias higher voltage pulse duration (ms). 104 + $ref: /schemas/types.yaml#/definitions/uint32 105 + minimum: 0 106 + 107 + dlg,btn-cfg: 108 + enum: [2, 5, 10, 50, 100, 200, 500] 109 + description: 110 + Periodic button press measurements for 4-pole jack (ms). 111 + $ref: /schemas/types.yaml#/definitions/uint32 112 + 113 + dlg,mic-det-thr: 114 + enum: [200, 500, 750, 1000] 115 + description: 116 + Impedance threshold for mic detection measurement (Ohms). 117 + $ref: /schemas/types.yaml#/definitions/uint32 118 + 119 + dlg,jack-ins-deb: 120 + enum: [5, 10, 20, 50, 100, 200, 500, 1000] 121 + description: 122 + Debounce time for jack insertion (ms). 123 + $ref: /schemas/types.yaml#/definitions/uint32 124 + 125 + dlg,jack-ins-det-pty: 126 + enum: ["low", "high"] 127 + description: 128 + Polarity for jack insertion detection. 129 + $ref: /schemas/types.yaml#/definitions/string 130 + 131 + dlg,jack-det-rate: 132 + enum: ["32_64", "64_128", "128_256", "256_512"] 133 + description: 134 + Jack type (3/4 pole) detection latency (ms). 135 + $ref: /schemas/types.yaml#/definitions/string 136 + 137 + dlg,jack-rem-deb: 138 + enum: [1, 5, 10, 20] 139 + description: 140 + Debounce time for jack removal (ms). 141 + $ref: /schemas/types.yaml#/definitions/uint32 142 + 143 + dlg,a-d-btn-thr: 144 + description: 145 + Impedance threshold between buttons A and D. 146 + $ref: /schemas/types.yaml#/definitions/uint32 147 + minimum: 0 148 + maximum: 255 149 + 150 + dlg,d-b-btn-thr: 151 + description: 152 + Impedance threshold between buttons D and B. 153 + $ref: /schemas/types.yaml#/definitions/uint32 154 + minimum: 0 155 + maximum: 255 156 + 157 + dlg,b-c-btn-thr: 158 + description: 159 + Impedance threshold between buttons B and C. 160 + $ref: /schemas/types.yaml#/definitions/uint32 161 + minimum: 0 162 + maximum: 255 163 + 164 + dlg,c-mic-btn-thr: 165 + description: 166 + Impedance threshold between button C and Mic. 167 + $ref: /schemas/types.yaml#/definitions/uint32 168 + minimum: 0 169 + maximum: 255 170 + 171 + dlg,btn-avg: 172 + enum: [1, 2, 4, 8] 173 + description: 174 + Number of 8-bit readings for averaged button measurement. 175 + $ref: /schemas/types.yaml#/definitions/uint32 176 + 177 + dlg,adc-1bit-rpt: 178 + enum: [1, 2, 4, 8] 179 + description: 180 + Repeat count for 1-bit button measurement. 181 + $ref: /schemas/types.yaml#/definitions/uint32 182 + 183 + required: 184 + - compatible 185 + - reg 186 + - interrupts 187 + - VDD-supply 188 + - VDDMIC-supply 189 + - VDDIO-supply 190 + 191 + additionalProperties: false 192 + 193 + examples: 194 + - | 195 + #include <dt-bindings/interrupt-controller/irq.h> 196 + i2c { 197 + #address-cells = <1>; 198 + #size-cells = <0>; 199 + 200 + codec: da7219@1a { 201 + compatible = "dlg,da7219"; 202 + reg = <0x1a>; 203 + 204 + interrupt-parent = <&gpio6>; 205 + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; 206 + 207 + VDD-supply = <&vdd_reg>; 208 + VDDMIC-supply = <&vddmic_reg>; 209 + VDDIO-supply = <&vddio_reg>; 210 + 211 + #clock-cells = <1>; 212 + clock-output-names = "da7219-dai-wclk", "da7219-dai-bclk"; 213 + 214 + clocks = <&clks 201>; 215 + clock-names = "mclk"; 216 + 217 + dlg,micbias-lvl = <2600>; 218 + dlg,mic-amp-in-sel = "diff"; 219 + 220 + da7219_aad { 221 + dlg,btn-cfg = <50>; 222 + dlg,mic-det-thr = <500>; 223 + dlg,jack-ins-deb = <20>; 224 + dlg,jack-ins-det-pty = "low"; 225 + dlg,jack-det-rate = "32_64"; 226 + dlg,jack-rem-deb = <1>; 227 + 228 + dlg,a-d-btn-thr = <0xa>; 229 + dlg,d-b-btn-thr = <0x16>; 230 + dlg,b-c-btn-thr = <0x21>; 231 + dlg,c-mic-btn-thr = <0x3E>; 232 + 233 + dlg,btn-avg = <4>; 234 + dlg,adc-1bit-rpt = <1>; 235 + }; 236 + }; 237 + };
+6
include/sound/da7219-aad.h
··· 44 44 DA7219_AAD_JACK_INS_DEB_1S, 45 45 }; 46 46 47 + enum da7219_aad_jack_ins_det_pty { 48 + DA7219_AAD_JACK_INS_DET_PTY_LOW = 0, 49 + DA7219_AAD_JACK_INS_DET_PTY_HIGH, 50 + }; 51 + 47 52 enum da7219_aad_jack_det_rate { 48 53 DA7219_AAD_JACK_DET_RATE_32_64MS = 0, 49 54 DA7219_AAD_JACK_DET_RATE_64_128MS, ··· 85 80 enum da7219_aad_btn_cfg btn_cfg; 86 81 enum da7219_aad_mic_det_thr mic_det_thr; 87 82 enum da7219_aad_jack_ins_deb jack_ins_deb; 83 + enum da7219_aad_jack_ins_det_pty jack_ins_det_pty; 88 84 enum da7219_aad_jack_det_rate jack_det_rate; 89 85 enum da7219_aad_jack_rem_deb jack_rem_deb; 90 86
+38 -4
sound/soc/codecs/da7219-aad.c
··· 571 571 } 572 572 } 573 573 574 + static enum da7219_aad_jack_ins_det_pty 575 + da7219_aad_fw_jack_ins_det_pty(struct device *dev, const char *str) 576 + { 577 + if (!strcmp(str, "low")) { 578 + return DA7219_AAD_JACK_INS_DET_PTY_LOW; 579 + } else if (!strcmp(str, "high")) { 580 + return DA7219_AAD_JACK_INS_DET_PTY_HIGH; 581 + } else { 582 + dev_warn(dev, "Invalid jack insertion detection polarity"); 583 + return DA7219_AAD_JACK_INS_DET_PTY_LOW; 584 + } 585 + } 586 + 574 587 static enum da7219_aad_jack_det_rate 575 588 da7219_aad_fw_jack_det_rate(struct device *dev, const char *str) 576 589 { 577 - if (!strcmp(str, "32ms_64ms")) { 590 + if (!strcmp(str, "32_64")) { 578 591 return DA7219_AAD_JACK_DET_RATE_32_64MS; 579 - } else if (!strcmp(str, "64ms_128ms")) { 592 + } else if (!strcmp(str, "64_128")) { 580 593 return DA7219_AAD_JACK_DET_RATE_64_128MS; 581 - } else if (!strcmp(str, "128ms_256ms")) { 594 + } else if (!strcmp(str, "128_256")) { 582 595 return DA7219_AAD_JACK_DET_RATE_128_256MS; 583 - } else if (!strcmp(str, "256ms_512ms")) { 596 + } else if (!strcmp(str, "256_512")) { 584 597 return DA7219_AAD_JACK_DET_RATE_256_512MS; 585 598 } else { 586 599 dev_warn(dev, "Invalid jack detect rate"); ··· 700 687 da7219_aad_fw_jack_ins_deb(dev, fw_val32); 701 688 else 702 689 aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS; 690 + 691 + if (!fwnode_property_read_string(aad_np, "dlg,jack-ins-det-pty", &fw_str)) 692 + aad_pdata->jack_ins_det_pty = 693 + da7219_aad_fw_jack_ins_det_pty(dev, fw_str); 694 + else 695 + aad_pdata->jack_ins_det_pty = DA7219_AAD_JACK_INS_DET_PTY_LOW; 703 696 704 697 if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str)) 705 698 aad_pdata->jack_det_rate = ··· 868 849 mask |= DA7219_ADC_1_BIT_REPEAT_MASK; 869 850 } 870 851 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg); 852 + 853 + switch (aad_pdata->jack_ins_det_pty) { 854 + case DA7219_AAD_JACK_INS_DET_PTY_LOW: 855 + snd_soc_component_write(component, 0xF0, 0x8B); 856 + snd_soc_component_write(component, 0x75, 0x80); 857 + snd_soc_component_write(component, 0xF0, 0x00); 858 + break; 859 + case DA7219_AAD_JACK_INS_DET_PTY_HIGH: 860 + snd_soc_component_write(component, 0xF0, 0x8B); 861 + snd_soc_component_write(component, 0x75, 0x00); 862 + snd_soc_component_write(component, 0xF0, 0x00); 863 + break; 864 + default: 865 + break; 866 + } 871 867 } 872 868 } 873 869