Pull sound updates from Takashi Iwai: "It's a relatively calm development cycle, but still lots of updates in the driver side like Intel SOF. Below are some highlights: ALSA / ASoC core: - A new kselftest for ALSA control API - PCM NO_REWINDS support - Potential race fixes around control removals - Unify x86 SG-buffer memory allocation code - Cleanups and race fixes for ASoC DPCM locking ASoC: - Refinements and cleanups around the delay() APIs - Wider use of dev_err_probe(). - Continuing cleanups and improvements to the SOF code - Support for pin switches in simple-card derived cards - Support for AMD Renoir ACP, Asahi Kasei Microdevices AKM4375, Intel systems using NAU8825 and MAX98390, Mediatek MT8915, nVidia Tegra20 S/PDIF, Qualcomm systems using ALC5682I-VS and Texas Instruments TLV320ADC3xxx HD-audio / USB-audio: - Fix deadlock at HD-audio codec unbinding - Fixes for Tegra194 HD-audio, new HDA support for CS35L41 codec - Quirks for Lenovo and HP machines, Gigabyte mobo, Bose device Misc: - Fix virmidi drain behavior Note that the merge of CS35L41 codec support is still half-baked, and at least one ACPI change is missing. Although this won't hinder the kernel build itself, we're going to catch up before RC1" * tag 'sound-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (415 commits) ALSA: hda: intel-dsp-config: reorder the config table ALSA: hda: intel-dsp-config: add JasperLake support ALSA: hda: cs35l41: fix double free on error in probe() ALSA: hda: Fix dependencies of CS35L41 on SPI/I2C buses ALSA: hda: Fix dependency on ASoC cs35l41 codec ASoC: cs35l41: Add support for hibernate memory retention mode ASoC: cs35l41: Update handling of test key registers ALSA: intel_hdmi: Check for error num after setting mask ASoC: wcd9335: Keep a RX port value for each SLIM RX mux ASoC: amd: acp: acp-mach: Change default RT1019 amp dev id ALSA: virmidi: Remove duplicated code ALSA: seq: virmidi: Add a drain operation ASoC: topology: Fix typo ASoC: fsl_asrc: refine the check of available clock divider ASoC: Intel: bytcr_rt5640: Add support for external GPIO jack-detect ASoC: Intel: bytcr_rt5640: Support retrieving the codec IRQ from the AMCR0F28 ACPI dev ASoC: rt5640: Add support for boards with an external jack-detect GPIO ASoC: rt5640: Allow snd_soc_component_set_jack() to override the codec IRQ ASoC: rt5640: Change jack_work to a delayed_work ASoC: rt5640: Fix possible NULL pointer deref on resume ...
Unified · Split
| @@ -0,0 +1,57 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/ak4375.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: AK4375 DAC and headphones amplifier Device Tree Bindings | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Vincent Knecht <vincent.knecht@mailoo.org> | |
| 11 | + | |
| 12 | +properties: | |
| 13 | + compatible: | |
| 14 | + const: asahi-kasei,ak4375 | |
| 15 | + | |
| 16 | + reg: | |
| 17 | + maxItems: 1 | |
| 18 | + | |
| 19 | + '#sound-dai-cells': | |
| 20 | + const: 0 | |
| 21 | + | |
| 22 | + avdd-supply: | |
| 23 | + description: regulator phandle for the AVDD power supply. | |
| 24 | + | |
| 25 | + tvdd-supply: | |
| 26 | + description: regulator phandle for the TVDD power supply. | |
| 27 | + | |
| 28 | + pdn-gpios: | |
| 29 | + description: optional GPIO to set the PDN pin. | |
| 30 | + | |
| 31 | +required: | |
| 32 | + - compatible | |
| 33 | + - reg | |
| 34 | + - '#sound-dai-cells' | |
| 35 | + - avdd-supply | |
| 36 | + - tvdd-supply | |
| 37 | + | |
| 38 | +additionalProperties: false | |
| 39 | + | |
| 40 | +examples: | |
| 41 | + - | | |
| 42 | + #include <dt-bindings/gpio/gpio.h> | |
| 43 | + i2c { | |
| 44 | + #address-cells = <1>; | |
| 45 | + #size-cells = <0>; | |
| 46 | + | |
| 47 | + headphones: audio-codec@10 { | |
| 48 | + compatible = "asahi-kasei,ak4375"; | |
| 49 | + reg = <0x10>; | |
| 50 | + avdd-supply = <®_headphones_avdd>; | |
| 51 | + tvdd-supply = <&pm8916_l6>; | |
| 52 | + pdn-gpios = <&msmgpio 114 GPIO_ACTIVE_HIGH>; | |
| 53 | + pinctrl-names = "default"; | |
| 54 | + pinctrl-0 = <&headphones_pdn_default>; | |
| 55 | + #sound-dai-cells = <0>; | |
| 56 | + }; | |
| 57 | + }; | |
| @@ -9,6 +9,9 @@ title: Amlogic AIU audio output controller · 8 unmodified lines | ||
| 9 | 9 | maintainers: |
| 10 | 10 | - Jerome Brunet <jbrunet@baylibre.com> |
| 11 | 11 | |
| 12 | +allOf: | |
| 13 | + - $ref: name-prefix.yaml# | |
| 14 | + | |
| 12 | 15 | properties: |
| 13 | 16 | $nodename: |
| 14 | 17 | pattern: "^audio-controller@.*" |
| @@ -65,6 +68,8 @@ properties: · 50 unmodified lines | ||
| 65 | 68 | resets: |
| 66 | 69 | maxItems: 1 |
| 67 | 70 | |
| 71 | + sound-name-prefix: true | |
| 72 | + | |
| 68 | 73 | required: |
| 69 | 74 | - "#sound-dai-cells" |
| 70 | 75 | - compatible |
| @@ -9,6 +9,9 @@ title: Amlogic G12a Internal DAC Control Glue · 8 unmodified lines | ||
| 9 | 9 | maintainers: |
| 10 | 10 | - Jerome Brunet <jbrunet@baylibre.com> |
| 11 | 11 | |
| 12 | +allOf: | |
| 13 | + - $ref: name-prefix.yaml# | |
| 14 | + | |
| 12 | 15 | properties: |
| 13 | 16 | $nodename: |
| 14 | 17 | pattern: "^audio-controller@.*" |
| @@ -31,6 +34,8 @@ properties: · 16 unmodified lines | ||
| 31 | 34 | resets: |
| 32 | 35 | maxItems: 1 |
| 33 | 36 | |
| 37 | + sound-name-prefix: true | |
| 38 | + | |
| 34 | 39 | required: |
| 35 | 40 | - "#sound-dai-cells" |
| 36 | 41 | - compatible |
| @@ -9,6 +9,9 @@ title: Amlogic T9015 Internal Audio DAC · 8 unmodified lines | ||
| 9 | 9 | maintainers: |
| 10 | 10 | - Jerome Brunet <jbrunet@baylibre.com> |
| 11 | 11 | |
| 12 | +allOf: | |
| 13 | + - $ref: name-prefix.yaml# | |
| 14 | + | |
| 12 | 15 | properties: |
| 13 | 16 | $nodename: |
| 14 | 17 | pattern: "^audio-controller@.*" |
| @@ -38,6 +41,8 @@ properties: · 23 unmodified lines | ||
| 38 | 41 | description: |
| 39 | 42 | Analogue power supply. |
| 40 | 43 | |
| 44 | + sound-name-prefix: true | |
| 45 | + | |
| 41 | 46 | required: |
| 42 | 47 | - "#sound-dai-cells" |
| 43 | 48 | - compatible |
| @@ -42,10 +42,15 @@ patternProperties: · 41 unmodified lines | ||
| 42 | 42 | $ref: /schemas/types.yaml#/definitions/flag |
| 43 | 43 | frame-master: |
| 44 | 44 | description: Indicates dai-link frame master. |
| 45 | − $ref: /schemas/types.yaml#/definitions/phandle | |
| 45 | + oneOf: | |
| 46 | + - $ref: /schemas/types.yaml#/definitions/flag | |
| 47 | + - $ref: /schemas/types.yaml#/definitions/phandle | |
| 46 | 48 | bitclock-master: |
| 47 | 49 | description: Indicates dai-link bit clock master |
| 48 | − $ref: /schemas/types.yaml#/definitions/phandle | |
| 50 | + oneOf: | |
| 51 | + - $ref: /schemas/types.yaml#/definitions/flag | |
| 52 | + - $ref: /schemas/types.yaml#/definitions/phandle | |
| 53 | + | |
| 49 | 54 | dai-format: |
| 50 | 55 | description: audio format. |
| 51 | 56 | items: |
| @@ -0,0 +1,225 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/cirrus,cs42l42.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Cirrus Logic CS42L42 audio CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - patches@opensource.cirrus.com | |
| 11 | + | |
| 12 | +description: | |
| 13 | + The CS42L42 is a low-power audio codec designed for portable applications. | |
| 14 | + It provides a high-dynamic range, stereo DAC for audio playback and a mono | |
| 15 | + high-dynamic-range ADC for audio capture. There is an integrated headset | |
| 16 | + detection block. | |
| 17 | + | |
| 18 | +properties: | |
| 19 | + compatible: | |
| 20 | + enum: | |
| 21 | + - cirrus,cs42l42 | |
| 22 | + | |
| 23 | + reg: | |
| 24 | + description: | |
| 25 | + The I2C address of the CS42L42. | |
| 26 | + maxItems: 1 | |
| 27 | + | |
| 28 | + VP-supply: | |
| 29 | + description: | |
| 30 | + VP power supply. | |
| 31 | + | |
| 32 | + VCP-supply: | |
| 33 | + description: | |
| 34 | + Charge pump power supply. | |
| 35 | + | |
| 36 | + VD_FILT-supply: | |
| 37 | + description: | |
| 38 | + FILT+ power supply. | |
| 39 | + | |
| 40 | + VL-supply: | |
| 41 | + description: | |
| 42 | + Logic power supply. | |
| 43 | + | |
| 44 | + VA-supply: | |
| 45 | + description: | |
| 46 | + Analog power supply. | |
| 47 | + | |
| 48 | + reset-gpios: | |
| 49 | + description: | |
| 50 | + This pin will be asserted and then deasserted to reset the | |
| 51 | + CS42L42 before communication starts. | |
| 52 | + maxItems: 1 | |
| 53 | + | |
| 54 | + interrupts: | |
| 55 | + description: | |
| 56 | + Interrupt for CS42L42 IRQ line. | |
| 57 | + maxItems: 1 | |
| 58 | + | |
| 59 | + cirrus,ts-inv: | |
| 60 | + description: | | |
| 61 | + Sets the behaviour of the jack plug detect switch. | |
| 62 | + | |
| 63 | + 0 - (Default) Shorted to tip when unplugged, open when plugged. | |
| 64 | + This is "inverted tip sense (ITS)" in the datasheet. | |
| 65 | + | |
| 66 | + 1 - Open when unplugged, shorted to tip when plugged. | |
| 67 | + This is "normal tip sense (TS)" in the datasheet. | |
| 68 | + | |
| 69 | + The CS42L42_TS_INV_* defines are available for this. | |
| 70 | + $ref: "/schemas/types.yaml#/definitions/uint32" | |
| 71 | + minimum: 0 | |
| 72 | + maximum: 1 | |
| 73 | + | |
| 74 | + cirrus,ts-dbnc-rise: | |
| 75 | + description: | | |
| 76 | + Debounce the rising edge of TIP_SENSE_PLUG. With no | |
| 77 | + debounce, the tip sense pin might be noisy on a plug event. | |
| 78 | + | |
| 79 | + 0 - 0ms | |
| 80 | + 1 - 125ms | |
| 81 | + 2 - 250ms | |
| 82 | + 3 - 500ms | |
| 83 | + 4 - 750ms | |
| 84 | + 5 - 1s (Default) | |
| 85 | + 6 - 1.25s | |
| 86 | + 7 - 1.5s | |
| 87 | + | |
| 88 | + The CS42L42_TS_DBNCE_* defines are available for this. | |
| 89 | + $ref: "/schemas/types.yaml#/definitions/uint32" | |
| 90 | + minimum: 0 | |
| 91 | + maximum: 7 | |
| 92 | + | |
| 93 | + cirrus,ts-dbnc-fall: | |
| 94 | + description: | | |
| 95 | + Debounce the falling edge of TIP_SENSE_UNPLUG. With no | |
| 96 | + debounce, the tip sense pin might be noisy on an unplug event. | |
| 97 | + | |
| 98 | + 0 - 0ms | |
| 99 | + 1 - 125ms | |
| 100 | + 2 - 250ms | |
| 101 | + 3 - 500ms | |
| 102 | + 4 - 750ms | |
| 103 | + 5 - 1s (Default) | |
| 104 | + 6 - 1.25s | |
| 105 | + 7 - 1.5s | |
| 106 | + | |
| 107 | + The CS42L42_TS_DBNCE_* defines are available for this. | |
| 108 | + $ref: "/schemas/types.yaml#/definitions/uint32" | |
| 109 | + minimum: 0 | |
| 110 | + maximum: 7 | |
| 111 | + | |
| 112 | + cirrus,btn-det-init-dbnce: | |
| 113 | + description: | | |
| 114 | + This sets how long to wait after enabling button detection | |
| 115 | + interrupts before servicing button interrupts, to allow the | |
| 116 | + HS bias time to settle. Value is in milliseconds. | |
| 117 | + There may be erroneous button interrupts if this debounce time | |
| 118 | + is too short. | |
| 119 | + | |
| 120 | + 0ms - 200ms, | |
| 121 | + Default = 100ms | |
| 122 | + $ref: "/schemas/types.yaml#/definitions/uint32" | |
| 123 | + minimum: 0 | |
| 124 | + maximum: 200 | |
| 125 | + | |
| 126 | + cirrus,btn-det-event-dbnce: | |
| 127 | + description: | | |
| 128 | + This sets how long to wait after receiving a button press | |
| 129 | + interrupt before processing it. Allows time for the button | |
| 130 | + press to make a clean connection with the bias resistors. | |
| 131 | + Value is in milliseconds. | |
| 132 | + | |
| 133 | + 0ms - 20ms, | |
| 134 | + Default = 10ms | |
| 135 | + $ref: "/schemas/types.yaml#/definitions/uint32" | |
| 136 | + minimum: 0 | |
| 137 | + maximum: 20 | |
| 138 | + | |
| 139 | + cirrus,bias-lvls: | |
| 140 | + description: | | |
| 141 | + For a level-detect headset button scheme, each button will bias | |
| 142 | + the mic pin to a certain voltage. To determine which button was | |
| 143 | + pressed, the voltage is compared to sequential, decreasing | |
| 144 | + voltages, until the compared voltage < bias voltage. | |
| 145 | + For different hardware setups, a designer might want to tweak this. | |
| 146 | + This is an array of descending values for the comparator voltage, | |
| 147 | + given as percent of the HSBIAS voltage. | |
| 148 | + | |
| 149 | + Array of 4 values, each 0-63 | |
| 150 | + < x1 x2 x3 x4 > | |
| 151 | + Default = < 15 8 4 1 > | |
| 152 | + $ref: /schemas/types.yaml#/definitions/uint32-array | |
| 153 | + minItems: 4 | |
| 154 | + maxItems: 4 | |
| 155 | + items: | |
| 156 | + minimum: 0 | |
| 157 | + maximum: 63 | |
| 158 | + | |
| 159 | + cirrus,hs-bias-ramp-rate: | |
| 160 | + description: | | |
| 161 | + If present this sets the rate that the HS bias should rise and fall. | |
| 162 | + The actual rise and fall times depend on external hardware (the | |
| 163 | + datasheet gives several rise and fall time examples). | |
| 164 | + | |
| 165 | + 0 - Fast rise time; slow, load-dependent fall time | |
| 166 | + 1 - Fast | |
| 167 | + 2 - Slow (default) | |
| 168 | + 3 - Slowest | |
| 169 | + | |
| 170 | + The CS42L42_HSBIAS_RAMP_* defines are available for this. | |
| 171 | + $ref: "/schemas/types.yaml#/definitions/uint32" | |
| 172 | + minimum: 0 | |
| 173 | + maximum: 3 | |
| 174 | + | |
| 175 | + cirrus,hs-bias-sense-disable: | |
| 176 | + description: | | |
| 177 | + If present the HSBIAS sense is disabled. Configures HSBIAS output | |
| 178 | + current sense through the external 2.21-k resistor. HSBIAS_SENSE | |
| 179 | + is a hardware feature to reduce the potential pop noise when the | |
| 180 | + headset plug is removed slowly. But on some platforms ESD voltage | |
| 181 | + will affect it causing plug detection to fail, especially with CTIA | |
| 182 | + headset type. For different hardware setups, a designer might want | |
| 183 | + to tweak default behavior. | |
| 184 | + type: boolean | |
| 185 | + | |
| 186 | +required: | |
| 187 | + - compatible | |
| 188 | + - reg | |
| 189 | + - VP-supply | |
| 190 | + - VCP-supply | |
| 191 | + - VD_FILT-supply | |
| 192 | + - VL-supply | |
| 193 | + - VA-supply | |
| 194 | + | |
| 195 | +additionalProperties: false | |
| 196 | + | |
| 197 | +examples: | |
| 198 | + - | | |
| 199 | + #include <dt-bindings/sound/cs42l42.h> | |
| 200 | + i2c { | |
| 201 | + #address-cells = <1>; | |
| 202 | + #size-cells = <0>; | |
| 203 | + | |
| 204 | + cs42l42: cs42l42@48 { | |
| 205 | + compatible = "cirrus,cs42l42"; | |
| 206 | + reg = <0x48>; | |
| 207 | + VA-supply = <&dummy_vreg>; | |
| 208 | + VP-supply = <&dummy_vreg>; | |
| 209 | + VCP-supply = <&dummy_vreg>; | |
| 210 | + VD_FILT-supply = <&dummy_vreg>; | |
| 211 | + VL-supply = <&dummy_vreg>; | |
| 212 | + | |
| 213 | + reset-gpios = <&axi_gpio_0 1 0>; | |
| 214 | + interrupt-parent = <&gpio0>; | |
| 215 | + interrupts = <55 8>; | |
| 216 | + | |
| 217 | + cirrus,ts-inv = <CS42L42_TS_INV_DIS>; | |
| 218 | + cirrus,ts-dbnc-rise = <CS42L42_TS_DBNCE_1000>; | |
| 219 | + cirrus,ts-dbnc-fall = <CS42L42_TS_DBNCE_0>; | |
| 220 | + cirrus,btn-det-init-dbnce = <100>; | |
| 221 | + cirrus,btn-det-event-dbnce = <10>; | |
| 222 | + cirrus,bias-lvls = <0x0F 0x08 0x04 0x01>; | |
| 223 | + cirrus,hs-bias-ramp-rate = <CS42L42_HSBIAS_RAMP_SLOW>; | |
| 224 | + }; | |
| 225 | + }; | |
| @@ -1,115 +0,0 @@ | ||
| 1 | −CS42L42 audio CODEC | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | − | |
| 5 | − - compatible : "cirrus,cs42l42" | |
| 6 | − | |
| 7 | − - reg : the I2C address of the device for I2C. | |
| 8 | − | |
| 9 | − - VP-supply, VCP-supply, VD_FILT-supply, VL-supply, VA-supply : | |
| 10 | − power supplies for the device, as covered in | |
| 11 | − Documentation/devicetree/bindings/regulator/regulator.txt. | |
| 12 | − | |
| 13 | −Optional properties: | |
| 14 | − | |
| 15 | − - reset-gpios : a GPIO spec for the reset pin. If specified, it will be | |
| 16 | − deasserted before communication to the codec starts. | |
| 17 | − | |
| 18 | − - interrupts : IRQ line info CS42L42. | |
| 19 | − (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt | |
| 20 | − for further information relating to interrupt properties) | |
| 21 | − | |
| 22 | − - cirrus,ts-inv : Boolean property. Sets the behaviour of the jack plug | |
| 23 | − detect switch. | |
| 24 | − | |
| 25 | − 0 = (Default) Shorted to tip when unplugged, open when plugged. | |
| 26 | − This is "inverted tip sense (ITS)" in the datasheet. | |
| 27 | − | |
| 28 | − 1 = Open when unplugged, shorted to tip when plugged. | |
| 29 | − This is "normal tip sense (TS)" in the datasheet. | |
| 30 | − | |
| 31 | − - cirrus,ts-dbnc-rise : Debounce the rising edge of TIP_SENSE_PLUG. With no | |
| 32 | − debounce, the tip sense pin might be noisy on a plug event. | |
| 33 | − | |
| 34 | − 0 - 0ms, | |
| 35 | − 1 - 125ms, | |
| 36 | − 2 - 250ms, | |
| 37 | − 3 - 500ms, | |
| 38 | − 4 - 750ms, | |
| 39 | − 5 - (Default) 1s, | |
| 40 | − 6 - 1.25s, | |
| 41 | − 7 - 1.5s, | |
| 42 | − | |
| 43 | − - cirrus,ts-dbnc-fall : Debounce the falling edge of TIP_SENSE_UNPLUG. | |
| 44 | − With no debounce, the tip sense pin might be noisy on an unplug event. | |
| 45 | − | |
| 46 | − 0 - 0ms, | |
| 47 | − 1 - 125ms, | |
| 48 | − 2 - 250ms, | |
| 49 | − 3 - 500ms, | |
| 50 | − 4 - 750ms, | |
| 51 | − 5 - (Default) 1s, | |
| 52 | − 6 - 1.25s, | |
| 53 | − 7 - 1.5s, | |
| 54 | − | |
| 55 | − - cirrus,btn-det-init-dbnce : This sets how long the driver sleeps after | |
| 56 | − enabling button detection interrupts. After auto-detection and before | |
| 57 | − servicing button interrupts, the HS bias needs time to settle. If you | |
| 58 | − don't wait, there is possibility for erroneous button interrupt. | |
| 59 | − | |
| 60 | − 0ms - 200ms, | |
| 61 | − Default = 100ms | |
| 62 | − | |
| 63 | − - cirrus,btn-det-event-dbnce : This sets how long the driver delays after | |
| 64 | − receiving a button press interrupt. With level detect interrupts, you want | |
| 65 | − to wait a small amount of time to make sure the button press is making a | |
| 66 | − clean connection with the bias resistors. | |
| 67 | − | |
| 68 | − 0ms - 20ms, | |
| 69 | − Default = 10ms | |
| 70 | − | |
| 71 | − - cirrus,bias-lvls : For a level-detect headset button scheme, each button | |
| 72 | − will bias the mic pin to a certain voltage. To determine which button was | |
| 73 | − pressed, the driver will compare this biased voltage to sequential, | |
| 74 | − decreasing voltages and will stop when a comparator is tripped, | |
| 75 | − indicating a comparator voltage < bias voltage. This value represents a | |
| 76 | − percentage of the internally generated HS bias voltage. For different | |
| 77 | − hardware setups, a designer might want to tweak this. This is an array of | |
| 78 | − descending values for the comparator voltage. | |
| 79 | − | |
| 80 | − Array of 4 values | |
| 81 | − Each 0-63 | |
| 82 | − < x1 x2 x3 x4 > | |
| 83 | − Default = < 15 8 4 1> | |
| 84 | − | |
| 85 | − - cirrus,hs-bias-sense-disable: This is boolean property. If present the | |
| 86 | − HSBIAS sense is disabled. Configures HSBIAS output current sense through | |
| 87 | − the external 2.21-k resistor. HSBIAS_SENSE is hardware feature to reduce | |
| 88 | − the potential pop noise during the headset plug out slowly. But on some | |
| 89 | − platforms ESD voltage will affect it causing test to fail, especially | |
| 90 | − with CTIA headset type. For different hardware setups, a designer might | |
| 91 | − want to tweak default behavior. | |
| 92 | − | |
| 93 | −Example: | |
| 94 | − | |
| 95 | −cs42l42: cs42l42@48 { | |
| 96 | − compatible = "cirrus,cs42l42"; | |
| 97 | − reg = <0x48>; | |
| 98 | − VA-supply = <&dummy_vreg>; | |
| 99 | − VP-supply = <&dummy_vreg>; | |
| 100 | − VCP-supply = <&dummy_vreg>; | |
| 101 | − VD_FILT-supply = <&dummy_vreg>; | |
| 102 | − VL-supply = <&dummy_vreg>; | |
| 103 | − | |
| 104 | − reset-gpios = <&axi_gpio_0 1 0>; | |
| 105 | − interrupt-parent = <&gpio0>; | |
| 106 | − interrupts = <55 8> | |
| 107 | − | |
| 108 | − cirrus,ts-inv = <0x00>; | |
| 109 | − cirrus,ts-dbnc-rise = <0x05>; | |
| 110 | − cirrus,ts-dbnc-fall = <0x00>; | |
| 111 | − cirrus,btn-det-init-dbnce = <100>; | |
| 112 | − cirrus,btn-det-event-dbnce = <10>; | |
| 113 | − cirrus,bias-lvls = <0x0F 0x08 0x04 0x01>; | |
| 114 | − cirrus,hs-bias-ramp-rate = <0x02>; | |
| 115 | −}; | |
| @@ -9,6 +9,9 @@ title: Dummy SPDIF Transmitter Device Tree Bindings · 8 unmodified lines | ||
| 9 | 9 | maintainers: |
| 10 | 10 | - Mark Brown <broonie@kernel.org> |
| 11 | 11 | |
| 12 | +allOf: | |
| 13 | + - $ref: name-prefix.yaml# | |
| 14 | + | |
| 12 | 15 | properties: |
| 13 | 16 | compatible: |
| 14 | 17 | const: linux,spdif-dit |
| @@ -16,6 +19,8 @@ properties: · 1 unmodified line | ||
| 16 | 19 | "#sound-dai-cells": |
| 17 | 20 | const: 0 |
| 18 | 21 | |
| 22 | + sound-name-prefix: true | |
| 23 | + | |
| 19 | 24 | required: |
| 20 | 25 | - "#sound-dai-cells" |
| 21 | 26 | - compatible |
| @@ -19,6 +19,12 @@ properties: · 18 unmodified lines | ||
| 19 | 19 | interrupts: |
| 20 | 20 | maxItems: 1 |
| 21 | 21 | |
| 22 | + memory-region: | |
| 23 | + maxItems: 1 | |
| 24 | + description: | | |
| 25 | + Shared memory region for AFE memif. A "shared-dma-pool". | |
| 26 | + See ../reserved-memory/reserved-memory.txt for details. | |
| 27 | + | |
| 22 | 28 | mediatek,topckgen: |
| 23 | 29 | $ref: "/schemas/types.yaml#/definitions/phandle" |
| 24 | 30 | description: The phandle of the mediatek topckgen controller |
| @@ -125,6 +131,7 @@ required: · 100 unmodified lines | ||
| 125 | 131 | - power-domains |
| 126 | 132 | - clocks |
| 127 | 133 | - clock-names |
| 134 | + - memory-region | |
| 128 | 135 | |
| 129 | 136 | additionalProperties: false |
| 130 | 137 | |
| @@ -139,6 +146,7 @@ examples: · 8 unmodified lines | ||
| 139 | 146 | interrupts = <GIC_SPI 822 IRQ_TYPE_LEVEL_HIGH 0>; |
| 140 | 147 | mediatek,topckgen = <&topckgen>; |
| 141 | 148 | power-domains = <&spm 7>; //MT8195_POWER_DOMAIN_AUDIO |
| 149 | + memory-region = <&snd_dma_mem_reserved>; | |
| 142 | 150 | clocks = <&clk26m>, |
| 143 | 151 | <&topckgen 163>, //CLK_TOP_APLL1 |
| 144 | 152 | <&topckgen 166>, //CLK_TOP_APLL2 |
| @@ -16,6 +16,10 @@ properties: · 15 unmodified lines | ||
| 16 | 16 | compatible: |
| 17 | 17 | const: mediatek,mt8195_mt6359_rt1011_rt5682 |
| 18 | 18 | |
| 19 | + model: | |
| 20 | + $ref: /schemas/types.yaml#/definitions/string | |
| 21 | + description: User specified audio sound card name | |
| 22 | + | |
| 19 | 23 | mediatek,platform: |
| 20 | 24 | $ref: "/schemas/types.yaml#/definitions/phandle" |
| 21 | 25 | description: The phandle of MT8195 ASoC platform. |
| @@ -16,6 +16,10 @@ properties: · 15 unmodified lines | ||
| 16 | 16 | compatible: |
| 17 | 17 | const: mediatek,mt8195_mt6359_rt1019_rt5682 |
| 18 | 18 | |
| 19 | + model: | |
| 20 | + $ref: /schemas/types.yaml#/definitions/string | |
| 21 | + description: User specified audio sound card name | |
| 22 | + | |
| 19 | 23 | mediatek,platform: |
| 20 | 24 | $ref: "/schemas/types.yaml#/definitions/phandle" |
| 21 | 25 | description: The phandle of MT8195 ASoC platform. |
| @@ -28,6 +32,16 @@ properties: · 6 unmodified lines | ||
| 28 | 32 | $ref: "/schemas/types.yaml#/definitions/phandle" |
| 29 | 33 | description: The phandle of MT8195 HDMI codec node. |
| 30 | 34 | |
| 35 | + mediatek,adsp: | |
| 36 | + $ref: "/schemas/types.yaml#/definitions/phandle" | |
| 37 | + description: The phandle of MT8195 ADSP platform. | |
| 38 | + | |
| 39 | + mediatek,dai-link: | |
| 40 | + $ref: /schemas/types.yaml#/definitions/string-array | |
| 41 | + description: | |
| 42 | + A list of the desired dai-links in the sound card. Each entry is a | |
| 43 | + name defined in the machine driver. | |
| 44 | + | |
| 31 | 45 | additionalProperties: false |
| 32 | 46 | |
| 33 | 47 | required: |
| @@ -1,48 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-alc5632" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the ALC5632's pins as documented in the binding for the device | |
| 16 | − and: | |
| 17 | − | |
| 18 | − * Headset Stereophone | |
| 19 | − * Int Spk | |
| 20 | − * Headset Mic | |
| 21 | − * Digital Mic | |
| 22 | − | |
| 23 | −- nvidia,i2s-controller : The phandle of the Tegra I2S controller | |
| 24 | −- nvidia,audio-codec : The phandle of the ALC5632 audio codec | |
| 25 | − | |
| 26 | −Example: | |
| 27 | − | |
| 28 | −sound { | |
| 29 | − compatible = "nvidia,tegra-audio-alc5632-paz00", | |
| 30 | − "nvidia,tegra-audio-alc5632"; | |
| 31 | − | |
| 32 | − nvidia,model = "Compal PAZ00"; | |
| 33 | − | |
| 34 | − nvidia,audio-routing = | |
| 35 | − "Int Spk", "SPK_OUTP", | |
| 36 | − "Int Spk", "SPK_OUTN", | |
| 37 | − "Headset Mic","MICBIAS1", | |
| 38 | − "MIC1_N", "Headset Mic", | |
| 39 | − "MIC1_P", "Headset Mic", | |
| 40 | − "Headset Stereophone", "HP_OUT_R", | |
| 41 | − "Headset Stereophone", "HP_OUT_L"; | |
| 42 | − | |
| 43 | − nvidia,i2s-controller = <&tegra_i2s1>; | |
| 44 | − nvidia,audio-codec = <&alc5632>; | |
| 45 | − | |
| 46 | − clocks = <&tegra_car 112>, <&tegra_car 113>, <&tegra_car 93>; | |
| 47 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 48 | −}; | |
| @@ -0,0 +1,74 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-alc5632.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with ALC5632 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + items: | |
| 19 | + - pattern: '^[a-z0-9]+,tegra-audio-alc5632(-[a-z0-9]+)+$' | |
| 20 | + - const: nvidia,tegra-audio-alc5632 | |
| 21 | + | |
| 22 | + nvidia,audio-routing: | |
| 23 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 24 | + description: | | |
| 25 | + A list of the connections between audio components. | |
| 26 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 27 | + the second being the connection's source. Valid names for sources and | |
| 28 | + sinks are the pins (documented in the binding document), | |
| 29 | + and the jacks on the board. | |
| 30 | + minItems: 2 | |
| 31 | + items: | |
| 32 | + enum: | |
| 33 | + # Board Connectors | |
| 34 | + - "Headset Stereophone" | |
| 35 | + - "Int Spk" | |
| 36 | + - "Headset Mic" | |
| 37 | + - "Digital Mic" | |
| 38 | + | |
| 39 | + # CODEC Pins | |
| 40 | + - SPKOUT | |
| 41 | + - SPKOUTN | |
| 42 | + - MICBIAS1 | |
| 43 | + - MIC1 | |
| 44 | + - HPR | |
| 45 | + - HPL | |
| 46 | + - DMICDAT | |
| 47 | + | |
| 48 | +required: | |
| 49 | + - nvidia,i2s-controller | |
| 50 | + | |
| 51 | +unevaluatedProperties: false | |
| 52 | + | |
| 53 | +examples: | |
| 54 | + - | | |
| 55 | + sound { | |
| 56 | + compatible = "nvidia,tegra-audio-alc5632-paz00", | |
| 57 | + "nvidia,tegra-audio-alc5632"; | |
| 58 | + | |
| 59 | + nvidia,model = "Compal PAZ00"; | |
| 60 | + | |
| 61 | + nvidia,audio-routing = "Int Spk", "SPKOUT", | |
| 62 | + "Int Spk", "SPKOUTN", | |
| 63 | + "Headset Mic", "MICBIAS1", | |
| 64 | + "MIC1", "Headset Mic", | |
| 65 | + "Headset Stereophone", "HPR", | |
| 66 | + "Headset Stereophone", "HPL", | |
| 67 | + "DMICDAT", "Digital Mic"; | |
| 68 | + | |
| 69 | + nvidia,i2s-controller = <&i2s>; | |
| 70 | + nvidia,audio-codec = <&codec>; | |
| 71 | + | |
| 72 | + clocks = <&clk 112>, <&clk 113>, <&clk 93>; | |
| 73 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 74 | + }; | |
| @@ -0,0 +1,83 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: "http://devicetree.org/schemas/sound/nvidia,tegra-audio-common.yaml#" | |
| 5 | +$schema: "http://devicetree.org/meta-schemas/core.yaml#" | |
| 6 | + | |
| 7 | +title: Common properties for NVIDIA Tegra audio complexes | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +properties: | |
| 14 | + clocks: | |
| 15 | + items: | |
| 16 | + - description: PLL A clock | |
| 17 | + - description: PLL A OUT0 clock | |
| 18 | + - description: The Tegra cdev1/extern1 clock, which feeds the card's mclk | |
| 19 | + | |
| 20 | + clock-names: | |
| 21 | + items: | |
| 22 | + - const: pll_a | |
| 23 | + - const: pll_a_out0 | |
| 24 | + - const: mclk | |
| 25 | + | |
| 26 | + nvidia,model: | |
| 27 | + $ref: /schemas/types.yaml#/definitions/string | |
| 28 | + description: The user-visible name of this sound complex. | |
| 29 | + | |
| 30 | + nvidia,audio-routing: | |
| 31 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 32 | + description: | | |
| 33 | + A list of the connections between audio components. | |
| 34 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 35 | + the second being the connection's source. Valid names for sources and | |
| 36 | + sinks are the pins (documented in the binding document), | |
| 37 | + and the jacks on the board. | |
| 38 | + | |
| 39 | + nvidia,ac97-controller: | |
| 40 | + $ref: /schemas/types.yaml#/definitions/phandle | |
| 41 | + description: The phandle of the AC97 controller | |
| 42 | + | |
| 43 | + nvidia,i2s-controller: | |
| 44 | + $ref: /schemas/types.yaml#/definitions/phandle | |
| 45 | + description: The phandle of the Tegra I2S controller | |
| 46 | + | |
| 47 | + nvidia,audio-codec: | |
| 48 | + $ref: /schemas/types.yaml#/definitions/phandle | |
| 49 | + description: The phandle of audio codec | |
| 50 | + | |
| 51 | + nvidia,spkr-en-gpios: | |
| 52 | + maxItems: 1 | |
| 53 | + description: The GPIO that enables the speakers | |
| 54 | + | |
| 55 | + nvidia,hp-mute-gpios: | |
| 56 | + maxItems: 1 | |
| 57 | + description: The GPIO that mutes the headphones | |
| 58 | + | |
| 59 | + nvidia,hp-det-gpios: | |
| 60 | + maxItems: 1 | |
| 61 | + description: The GPIO that detect headphones are plugged in | |
| 62 | + | |
| 63 | + nvidia,mic-det-gpios: | |
| 64 | + maxItems: 1 | |
| 65 | + description: The GPIO that detect microphone is plugged in | |
| 66 | + | |
| 67 | + nvidia,ear-sel-gpios: | |
| 68 | + maxItems: 1 | |
| 69 | + description: The GPIO that switch between the microphones | |
| 70 | + | |
| 71 | + nvidia,int-mic-en-gpios: | |
| 72 | + maxItems: 1 | |
| 73 | + description: The GPIO that enables the internal microphone | |
| 74 | + | |
| 75 | + nvidia,ext-mic-en-gpios: | |
| 76 | + maxItems: 1 | |
| 77 | + description: The GPIO that enables the external microphone | |
| 78 | + | |
| 79 | + nvidia,headset: | |
| 80 | + type: boolean | |
| 81 | + description: The Mic Jack represents state of the headset microphone pin | |
| 82 | + | |
| 83 | +additionalProperties: true | |
| @@ -44,6 +44,16 @@ properties: · 43 unmodified lines | ||
| 44 | 44 | minItems: 1 |
| 45 | 45 | maxItems: 3 |
| 46 | 46 | |
| 47 | + interconnects: | |
| 48 | + items: | |
| 49 | + - description: APE read memory client | |
| 50 | + - description: APE write memory client | |
| 51 | + | |
| 52 | + interconnect-names: | |
| 53 | + items: | |
| 54 | + - const: dma-mem # read | |
| 55 | + - const: write | |
| 56 | + | |
| 47 | 57 | iommus: |
| 48 | 58 | maxItems: 1 |
| 49 | 59 | |
| @@ -1,53 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex, with MAX98090 CODEC | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-max98090" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the MAX98090's pins (as documented in its binding), and the jacks | |
| 16 | − on the board: | |
| 17 | − | |
| 18 | − * Headphones | |
| 19 | − * Speakers | |
| 20 | − * Mic Jack | |
| 21 | − * Int Mic | |
| 22 | − | |
| 23 | −- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's | |
| 24 | − connected to the CODEC. | |
| 25 | −- nvidia,audio-codec : The phandle of the MAX98090 audio codec. | |
| 26 | − | |
| 27 | −Optional properties: | |
| 28 | −- nvidia,hp-det-gpios : The GPIO that detect headphones are plugged in | |
| 29 | −- nvidia,mic-det-gpios : The GPIO that detect microphones are plugged in | |
| 30 | − | |
| 31 | −Example: | |
| 32 | − | |
| 33 | −sound { | |
| 34 | − compatible = "nvidia,tegra-audio-max98090-venice2", | |
| 35 | − "nvidia,tegra-audio-max98090"; | |
| 36 | − nvidia,model = "NVIDIA Tegra Venice2"; | |
| 37 | − | |
| 38 | − nvidia,audio-routing = | |
| 39 | − "Headphones", "HPR", | |
| 40 | − "Headphones", "HPL", | |
| 41 | − "Speakers", "SPKR", | |
| 42 | − "Speakers", "SPKL", | |
| 43 | − "Mic Jack", "MICBIAS", | |
| 44 | − "IN34", "Mic Jack"; | |
| 45 | − | |
| 46 | − nvidia,i2s-controller = <&tegra_i2s1>; | |
| 47 | − nvidia,audio-codec = <&acodec>; | |
| 48 | − | |
| 49 | − clocks = <&tegra_car TEGRA124_CLK_PLL_A>, | |
| 50 | − <&tegra_car TEGRA124_CLK_PLL_A_OUT0>, | |
| 51 | − <&tegra_car TEGRA124_CLK_EXTERN1>; | |
| 52 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 53 | −}; | |
| @@ -0,0 +1,97 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-max98090.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with MAX98090 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + oneOf: | |
| 19 | + - items: | |
| 20 | + - pattern: '^[a-z0-9]+,tegra-audio-max98090(-[a-z0-9]+)+$' | |
| 21 | + - const: nvidia,tegra-audio-max98090 | |
| 22 | + - items: | |
| 23 | + - enum: | |
| 24 | + - nvidia,tegra-audio-max98090-nyan-big | |
| 25 | + - nvidia,tegra-audio-max98090-nyan-blaze | |
| 26 | + - const: nvidia,tegra-audio-max98090-nyan | |
| 27 | + - const: nvidia,tegra-audio-max98090 | |
| 28 | + | |
| 29 | + nvidia,audio-routing: | |
| 30 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 31 | + description: | | |
| 32 | + A list of the connections between audio components. | |
| 33 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 34 | + the second being the connection's source. Valid names for sources and | |
| 35 | + sinks are the pins (documented in the binding document), | |
| 36 | + and the jacks on the board. | |
| 37 | + minItems: 2 | |
| 38 | + items: | |
| 39 | + enum: | |
| 40 | + # Board Connectors | |
| 41 | + - "Headphones" | |
| 42 | + - "Speakers" | |
| 43 | + - "Mic Jack" | |
| 44 | + - "Int Mic" | |
| 45 | + | |
| 46 | + # CODEC Pins | |
| 47 | + - MIC1 | |
| 48 | + - MIC2 | |
| 49 | + - DMICL | |
| 50 | + - DMICR | |
| 51 | + - IN1 | |
| 52 | + - IN2 | |
| 53 | + - IN3 | |
| 54 | + - IN4 | |
| 55 | + - IN5 | |
| 56 | + - IN6 | |
| 57 | + - IN12 | |
| 58 | + - IN34 | |
| 59 | + - IN56 | |
| 60 | + - HPL | |
| 61 | + - HPR | |
| 62 | + - SPKL | |
| 63 | + - SPKR | |
| 64 | + - RCVL | |
| 65 | + - RCVR | |
| 66 | + - MICBIAS | |
| 67 | + | |
| 68 | +required: | |
| 69 | + - nvidia,i2s-controller | |
| 70 | + | |
| 71 | +unevaluatedProperties: false | |
| 72 | + | |
| 73 | +examples: | |
| 74 | + - | | |
| 75 | + #include <dt-bindings/clock/tegra124-car.h> | |
| 76 | + | |
| 77 | + sound { | |
| 78 | + compatible = "nvidia,tegra-audio-max98090-venice2", | |
| 79 | + "nvidia,tegra-audio-max98090"; | |
| 80 | + nvidia,model = "NVIDIA Tegra Venice2"; | |
| 81 | + | |
| 82 | + nvidia,audio-routing = | |
| 83 | + "Headphones", "HPR", | |
| 84 | + "Headphones", "HPL", | |
| 85 | + "Speakers", "SPKR", | |
| 86 | + "Speakers", "SPKL", | |
| 87 | + "Mic Jack", "MICBIAS", | |
| 88 | + "IN34", "Mic Jack"; | |
| 89 | + | |
| 90 | + nvidia,i2s-controller = <&tegra_i2s1>; | |
| 91 | + nvidia,audio-codec = <&acodec>; | |
| 92 | + | |
| 93 | + clocks = <&tegra_car TEGRA124_CLK_PLL_A>, | |
| 94 | + <&tegra_car TEGRA124_CLK_PLL_A_OUT0>, | |
| 95 | + <&tegra_car TEGRA124_CLK_EXTERN1>; | |
| 96 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 97 | + }; | |
| @@ -1,52 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex, with RT5640 CODEC | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-rt5640" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the RT5640's pins (as documented in its binding), and the jacks | |
| 16 | − on the board: | |
| 17 | − | |
| 18 | − * Headphones | |
| 19 | − * Speakers | |
| 20 | − * Mic Jack | |
| 21 | − | |
| 22 | −- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's | |
| 23 | − connected to the CODEC. | |
| 24 | −- nvidia,audio-codec : The phandle of the RT5640 audio codec. This binding | |
| 25 | − assumes that AIF1 on the CODEC is connected to Tegra. | |
| 26 | − | |
| 27 | −Optional properties: | |
| 28 | −- nvidia,hp-det-gpios : The GPIO that detects headphones are plugged in | |
| 29 | − | |
| 30 | −Example: | |
| 31 | − | |
| 32 | −sound { | |
| 33 | − compatible = "nvidia,tegra-audio-rt5640-dalmore", | |
| 34 | − "nvidia,tegra-audio-rt5640"; | |
| 35 | − nvidia,model = "NVIDIA Tegra Dalmore"; | |
| 36 | − | |
| 37 | − nvidia,audio-routing = | |
| 38 | − "Headphones", "HPOR", | |
| 39 | − "Headphones", "HPOL", | |
| 40 | − "Speakers", "SPORP", | |
| 41 | − "Speakers", "SPORN", | |
| 42 | − "Speakers", "SPOLP", | |
| 43 | − "Speakers", "SPOLN"; | |
| 44 | − | |
| 45 | − nvidia,i2s-controller = <&tegra_i2s1>; | |
| 46 | − nvidia,audio-codec = <&rt5640>; | |
| 47 | − | |
| 48 | − nvidia,hp-det-gpios = <&gpio 143 0>; /* GPIO PR7 */ | |
| 49 | − | |
| 50 | − clocks = <&tegra_car 216>, <&tegra_car 217>, <&tegra_car 120>; | |
| 51 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 52 | −}; | |
| @@ -0,0 +1,85 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-rt5640.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with RT5639 or RT5640 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + items: | |
| 19 | + - pattern: '^[a-z0-9]+,tegra-audio-rt56(39|40)(-[a-z0-9]+)+$' | |
| 20 | + - const: nvidia,tegra-audio-rt5640 | |
| 21 | + | |
| 22 | + nvidia,audio-routing: | |
| 23 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 24 | + description: | | |
| 25 | + A list of the connections between audio components. | |
| 26 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 27 | + the second being the connection's source. Valid names for sources and | |
| 28 | + sinks are the pins (documented in the binding document), | |
| 29 | + and the jacks on the board. | |
| 30 | + minItems: 2 | |
| 31 | + items: | |
| 32 | + enum: | |
| 33 | + # Board Connectors | |
| 34 | + - "Headphones" | |
| 35 | + - "Speakers" | |
| 36 | + - "Mic Jack" | |
| 37 | + | |
| 38 | + # CODEC Pins | |
| 39 | + - DMIC1 | |
| 40 | + - DMIC2 | |
| 41 | + - MICBIAS1 | |
| 42 | + - IN1P | |
| 43 | + - IN1R | |
| 44 | + - IN2P | |
| 45 | + - IN2R | |
| 46 | + - HPOL | |
| 47 | + - HPOR | |
| 48 | + - LOUTL | |
| 49 | + - LOUTR | |
| 50 | + - MONOP | |
| 51 | + - MONON | |
| 52 | + - SPOLP | |
| 53 | + - SPOLN | |
| 54 | + - SPORP | |
| 55 | + - SPORN | |
| 56 | + | |
| 57 | +required: | |
| 58 | + - nvidia,i2s-controller | |
| 59 | + | |
| 60 | +unevaluatedProperties: false | |
| 61 | + | |
| 62 | +examples: | |
| 63 | + - | | |
| 64 | + sound { | |
| 65 | + compatible = "nvidia,tegra-audio-rt5640-dalmore", | |
| 66 | + "nvidia,tegra-audio-rt5640"; | |
| 67 | + nvidia,model = "NVIDIA Tegra Dalmore"; | |
| 68 | + | |
| 69 | + nvidia,audio-routing = | |
| 70 | + "Headphones", "HPOR", | |
| 71 | + "Headphones", "HPOL", | |
| 72 | + "Speakers", "SPORP", | |
| 73 | + "Speakers", "SPORN", | |
| 74 | + "Speakers", "SPOLP", | |
| 75 | + "Speakers", "SPOLN"; | |
| 76 | + | |
| 77 | + nvidia,i2s-controller = <&tegra_i2s1>; | |
| 78 | + nvidia,audio-codec = <&rt5640>; | |
| 79 | + | |
| 80 | + nvidia,hp-det-gpios = <&gpio 143 0>; | |
| 81 | + | |
| 82 | + clocks = <&clk 216>, <&clk 217>, <&clk 120>; | |
| 83 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 84 | + }; | |
| 85 | + | |
| @@ -1,67 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex, with RT5677 CODEC | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-rt5677" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the RT5677's pins (as documented in its binding), and the jacks | |
| 16 | − on the board: | |
| 17 | − | |
| 18 | − * Headphone | |
| 19 | − * Speaker | |
| 20 | − * Headset Mic | |
| 21 | − * Internal Mic 1 | |
| 22 | − * Internal Mic 2 | |
| 23 | − | |
| 24 | −- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's | |
| 25 | − connected to the CODEC. | |
| 26 | −- nvidia,audio-codec : The phandle of the RT5677 audio codec. This binding | |
| 27 | − assumes that AIF1 on the CODEC is connected to Tegra. | |
| 28 | − | |
| 29 | −Optional properties: | |
| 30 | −- nvidia,hp-det-gpios : The GPIO that detects headphones are plugged in | |
| 31 | −- nvidia,hp-en-gpios : The GPIO that enables headphone amplifier | |
| 32 | −- nvidia,mic-present-gpios: The GPIO that mic jack is plugged in | |
| 33 | −- nvidia,dmic-clk-en-gpios : The GPIO that gates DMIC clock signal | |
| 34 | − | |
| 35 | −Example: | |
| 36 | − | |
| 37 | −sound { | |
| 38 | − compatible = "nvidia,tegra-audio-rt5677-ryu", | |
| 39 | − "nvidia,tegra-audio-rt5677"; | |
| 40 | − nvidia,model = "NVIDIA Tegra Ryu"; | |
| 41 | − | |
| 42 | − nvidia,audio-routing = | |
| 43 | − "Headphone", "LOUT2", | |
| 44 | − "Headphone", "LOUT1", | |
| 45 | − "Headset Mic", "MICBIAS1", | |
| 46 | − "IN1P", "Headset Mic", | |
| 47 | − "IN1N", "Headset Mic", | |
| 48 | − "DMIC L1", "Internal Mic 1", | |
| 49 | − "DMIC R1", "Internal Mic 1", | |
| 50 | − "DMIC L2", "Internal Mic 2", | |
| 51 | − "DMIC R2", "Internal Mic 2", | |
| 52 | − "Speaker", "PDM1L", | |
| 53 | − "Speaker", "PDM1R"; | |
| 54 | − | |
| 55 | − nvidia,i2s-controller = <&tegra_i2s1>; | |
| 56 | − nvidia,audio-codec = <&rt5677>; | |
| 57 | − | |
| 58 | − nvidia,hp-det-gpios = <&gpio TEGRA_GPIO(R, 7) GPIO_ACTIVE_HIGH>; | |
| 59 | − nvidia,mic-present-gpios = <&gpio TEGRA_GPIO(O, 5) GPIO_ACTIVE_LOW>; | |
| 60 | − nvidia,hp-en-gpios = <&rt5677 1 GPIO_ACTIVE_HIGH>; | |
| 61 | − nvidia,dmic-clk-en-gpios = <&rt5677 2 GPIO_ACTIVE_HIGH>; | |
| 62 | − | |
| 63 | − clocks = <&tegra_car TEGRA124_CLK_PLL_A>, | |
| 64 | − <&tegra_car TEGRA124_CLK_PLL_A_OUT0>, | |
| 65 | − <&tegra_car TEGRA124_CLK_EXTERN1>; | |
| 66 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 67 | −}; | |
| @@ -0,0 +1,100 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-rt5677.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with RT5677 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + items: | |
| 19 | + - pattern: '^[a-z0-9]+,tegra-audio-rt5677(-[a-z0-9]+)+$' | |
| 20 | + - const: nvidia,tegra-audio-rt5677 | |
| 21 | + | |
| 22 | + nvidia,audio-routing: | |
| 23 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 24 | + description: | | |
| 25 | + A list of the connections between audio components. | |
| 26 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 27 | + the second being the connection's source. Valid names for sources and | |
| 28 | + sinks are the pins (documented in the binding document), | |
| 29 | + and the jacks on the board. | |
| 30 | + minItems: 2 | |
| 31 | + items: | |
| 32 | + enum: | |
| 33 | + # Board Connectors | |
| 34 | + - "Headphone" | |
| 35 | + - "Speaker" | |
| 36 | + - "Headset Mic" | |
| 37 | + - "Internal Mic 1" | |
| 38 | + - "Internal Mic 2" | |
| 39 | + | |
| 40 | + # CODEC Pins | |
| 41 | + - IN1P | |
| 42 | + - IN1N | |
| 43 | + - IN2P | |
| 44 | + - IN2N | |
| 45 | + - MICBIAS1 | |
| 46 | + - DMIC1 | |
| 47 | + - DMIC2 | |
| 48 | + - DMIC3 | |
| 49 | + - DMIC4 | |
| 50 | + - "DMIC L1" | |
| 51 | + - "DMIC L2" | |
| 52 | + - "DMIC L3" | |
| 53 | + - "DMIC L4" | |
| 54 | + - "DMIC R1" | |
| 55 | + - "DMIC R2" | |
| 56 | + - "DMIC R3" | |
| 57 | + - "DMIC R4" | |
| 58 | + - LOUT1 | |
| 59 | + - LOUT2 | |
| 60 | + - LOUT3 | |
| 61 | + - PDM1L | |
| 62 | + - PDM1R | |
| 63 | + - PDM2L | |
| 64 | + - PDM2R | |
| 65 | + | |
| 66 | +required: | |
| 67 | + - nvidia,i2s-controller | |
| 68 | + | |
| 69 | +unevaluatedProperties: false | |
| 70 | + | |
| 71 | +examples: | |
| 72 | + - | | |
| 73 | + sound { | |
| 74 | + compatible = "nvidia,tegra-audio-rt5677-ryu", | |
| 75 | + "nvidia,tegra-audio-rt5677"; | |
| 76 | + nvidia,model = "NVIDIA Tegra Ryu"; | |
| 77 | + | |
| 78 | + nvidia,audio-routing = | |
| 79 | + "Headphone", "LOUT2", | |
| 80 | + "Headphone", "LOUT1", | |
| 81 | + "Headset Mic", "MICBIAS1", | |
| 82 | + "IN1P", "Headset Mic", | |
| 83 | + "IN1N", "Headset Mic", | |
| 84 | + "DMIC L1", "Internal Mic 1", | |
| 85 | + "DMIC R1", "Internal Mic 1", | |
| 86 | + "DMIC L2", "Internal Mic 2", | |
| 87 | + "DMIC R2", "Internal Mic 2", | |
| 88 | + "Speaker", "PDM1L", | |
| 89 | + "Speaker", "PDM1R"; | |
| 90 | + | |
| 91 | + nvidia,i2s-controller = <&tegra_i2s1>; | |
| 92 | + nvidia,audio-codec = <&rt5677>; | |
| 93 | + | |
| 94 | + nvidia,hp-det-gpios = <&gpio 143 0>; | |
| 95 | + | |
| 96 | + clocks = <&clk 216>, | |
| 97 | + <&clk 217>, | |
| 98 | + <&clk 121>; | |
| 99 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 100 | + }; | |
| @@ -1,42 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex, with SGTL5000 CODEC | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-sgtl5000" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the SGTL5000's pins (as documented in its binding), and the jacks | |
| 16 | − on the board: | |
| 17 | − | |
| 18 | − * Headphone Jack | |
| 19 | − * Line In Jack | |
| 20 | − * Mic Jack | |
| 21 | − | |
| 22 | −- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's | |
| 23 | − connected to the CODEC. | |
| 24 | −- nvidia,audio-codec : The phandle of the SGTL5000 audio codec. | |
| 25 | − | |
| 26 | −Example: | |
| 27 | − | |
| 28 | −sound { | |
| 29 | − compatible = "toradex,tegra-audio-sgtl5000-apalis_t30", | |
| 30 | − "nvidia,tegra-audio-sgtl5000"; | |
| 31 | − nvidia,model = "Toradex Apalis T30"; | |
| 32 | − nvidia,audio-routing = | |
| 33 | − "Headphone Jack", "HP_OUT", | |
| 34 | − "LINE_IN", "Line In Jack", | |
| 35 | − "MIC_IN", "Mic Jack"; | |
| 36 | − nvidia,i2s-controller = <&tegra_i2s2>; | |
| 37 | − nvidia,audio-codec = <&sgtl5000>; | |
| 38 | − clocks = <&tegra_car TEGRA30_CLK_PLL_A>, | |
| 39 | − <&tegra_car TEGRA30_CLK_PLL_A_OUT0>, | |
| 40 | − <&tegra_car TEGRA30_CLK_EXTERN1>; | |
| 41 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 42 | −}; | |
| @@ -0,0 +1,67 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-sgtl5000.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with SGTL5000 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + items: | |
| 19 | + - pattern: '^[a-z0-9]+,tegra-audio-sgtl5000([-_][a-z0-9]+)+$' | |
| 20 | + - const: nvidia,tegra-audio-sgtl5000 | |
| 21 | + | |
| 22 | + nvidia,audio-routing: | |
| 23 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 24 | + description: | | |
| 25 | + A list of the connections between audio components. | |
| 26 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 27 | + the second being the connection's source. Valid names for sources and | |
| 28 | + sinks are the pins (documented in the binding document), | |
| 29 | + and the jacks on the board. | |
| 30 | + minItems: 2 | |
| 31 | + items: | |
| 32 | + enum: | |
| 33 | + # Board Connectors | |
| 34 | + - "Headphone Jack" | |
| 35 | + - "Line In Jack" | |
| 36 | + - "Mic Jack" | |
| 37 | + | |
| 38 | + # CODEC Pins | |
| 39 | + - HP_OUT | |
| 40 | + - LINE_OUT | |
| 41 | + - LINE_IN | |
| 42 | + - MIC_IN | |
| 43 | + | |
| 44 | +required: | |
| 45 | + - nvidia,i2s-controller | |
| 46 | + | |
| 47 | +unevaluatedProperties: false | |
| 48 | + | |
| 49 | +examples: | |
| 50 | + - | | |
| 51 | + #include <dt-bindings/clock/tegra30-car.h> | |
| 52 | + | |
| 53 | + sound { | |
| 54 | + compatible = "toradex,tegra-audio-sgtl5000-apalis_t30", | |
| 55 | + "nvidia,tegra-audio-sgtl5000"; | |
| 56 | + nvidia,model = "Toradex Apalis T30 SGTL5000"; | |
| 57 | + nvidia,audio-routing = | |
| 58 | + "Headphone Jack", "HP_OUT", | |
| 59 | + "LINE_IN", "Line In Jack", | |
| 60 | + "MIC_IN", "Mic Jack"; | |
| 61 | + nvidia,i2s-controller = <&tegra_i2s2>; | |
| 62 | + nvidia,audio-codec = <&codec>; | |
| 63 | + clocks = <&tegra_car TEGRA30_CLK_PLL_A>, | |
| 64 | + <&tegra_car TEGRA30_CLK_PLL_A_OUT0>, | |
| 65 | + <&tegra_car TEGRA30_CLK_EXTERN1>; | |
| 66 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 67 | + }; | |
| @@ -1,21 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex for TrimSlice | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-trimslice" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | −- clock-names : Must include the following entries: | |
| 7 | − "pll_a" (The Tegra clock of that name), | |
| 8 | − "pll_a_out0" (The Tegra clock of that name), | |
| 9 | − "mclk" (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 10 | −- nvidia,i2s-controller : The phandle of the Tegra I2S1 controller | |
| 11 | −- nvidia,audio-codec : The phandle of the WM8903 audio codec | |
| 12 | − | |
| 13 | −Example: | |
| 14 | − | |
| 15 | −sound { | |
| 16 | − compatible = "nvidia,tegra-audio-trimslice"; | |
| 17 | − nvidia,i2s-controller = <&tegra_i2s1>; | |
| 18 | − nvidia,audio-codec = <&codec>; | |
| 19 | − clocks = <&tegra_car 112>, <&tegra_car 113>, <&tegra_car 93>; | |
| 20 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 21 | −}; | |
| @@ -0,0 +1,33 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-trimslice.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with TrimSlice CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + const: nvidia,tegra-audio-trimslice | |
| 19 | + | |
| 20 | +required: | |
| 21 | + - nvidia,i2s-controller | |
| 22 | + | |
| 23 | +unevaluatedProperties: false | |
| 24 | + | |
| 25 | +examples: | |
| 26 | + - | | |
| 27 | + sound { | |
| 28 | + compatible = "nvidia,tegra-audio-trimslice"; | |
| 29 | + nvidia,i2s-controller = <&tegra_i2s1>; | |
| 30 | + nvidia,audio-codec = <&codec>; | |
| 31 | + clocks = <&tegra_car 112>, <&tegra_car 113>, <&tegra_car 93>; | |
| 32 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 33 | + }; | |
| @@ -1,40 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-wm8753" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the WM8753's pins as documented in the binding for the WM8753, | |
| 16 | − and the jacks on the board: | |
| 17 | − | |
| 18 | − * Headphone Jack | |
| 19 | − * Mic Jack | |
| 20 | − | |
| 21 | −- nvidia,i2s-controller : The phandle of the Tegra I2S1 controller | |
| 22 | −- nvidia,audio-codec : The phandle of the WM8753 audio codec | |
| 23 | −Example: | |
| 24 | − | |
| 25 | −sound { | |
| 26 | − compatible = "nvidia,tegra-audio-wm8753-whistler", | |
| 27 | − "nvidia,tegra-audio-wm8753" | |
| 28 | − nvidia,model = "tegra-wm8753-harmony"; | |
| 29 | − | |
| 30 | − nvidia,audio-routing = | |
| 31 | − "Headphone Jack", "LOUT1", | |
| 32 | − "Headphone Jack", "ROUT1"; | |
| 33 | − | |
| 34 | − nvidia,i2s-controller = <&i2s1>; | |
| 35 | − nvidia,audio-codec = <&wm8753>; | |
| 36 | − | |
| 37 | − clocks = <&tegra_car 112>, <&tegra_car 113>, <&tegra_car 93>; | |
| 38 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 39 | −}; | |
| 40 | − | |
| @@ -0,0 +1,79 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-wm8753.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with WM8753 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + items: | |
| 19 | + - pattern: '^[a-z0-9]+,tegra-audio-wm8753(-[a-z0-9]+)+$' | |
| 20 | + - const: nvidia,tegra-audio-wm8753 | |
| 21 | + | |
| 22 | + nvidia,audio-routing: | |
| 23 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 24 | + description: | | |
| 25 | + A list of the connections between audio components. | |
| 26 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 27 | + the second being the connection's source. Valid names for sources and | |
| 28 | + sinks are the pins (documented in the binding document), | |
| 29 | + and the jacks on the board. | |
| 30 | + minItems: 2 | |
| 31 | + items: | |
| 32 | + enum: | |
| 33 | + # Board Connectors | |
| 34 | + - "Headphone Jack" | |
| 35 | + - "Mic Jack" | |
| 36 | + | |
| 37 | + # CODEC Pins | |
| 38 | + - LOUT1 | |
| 39 | + - LOUT2 | |
| 40 | + - ROUT1 | |
| 41 | + - ROUT2 | |
| 42 | + - MONO1 | |
| 43 | + - MONO2 | |
| 44 | + - OUT3 | |
| 45 | + - OUT4 | |
| 46 | + - LINE1 | |
| 47 | + - LINE2 | |
| 48 | + - RXP | |
| 49 | + - RXN | |
| 50 | + - ACIN | |
| 51 | + - ACOP | |
| 52 | + - MIC1N | |
| 53 | + - MIC1 | |
| 54 | + - MIC2N | |
| 55 | + - MIC2 | |
| 56 | + - "Mic Bias" | |
| 57 | + | |
| 58 | +required: | |
| 59 | + - nvidia,i2s-controller | |
| 60 | + | |
| 61 | +unevaluatedProperties: false | |
| 62 | + | |
| 63 | +examples: | |
| 64 | + - | | |
| 65 | + sound { | |
| 66 | + compatible = "nvidia,tegra-audio-wm8753-whistler", | |
| 67 | + "nvidia,tegra-audio-wm8753"; | |
| 68 | + nvidia,model = "tegra-wm8753-harmony"; | |
| 69 | + | |
| 70 | + nvidia,audio-routing = | |
| 71 | + "Headphone Jack", "LOUT1", | |
| 72 | + "Headphone Jack", "ROUT1"; | |
| 73 | + | |
| 74 | + nvidia,i2s-controller = <&i2s1>; | |
| 75 | + nvidia,audio-codec = <&wm8753>; | |
| 76 | + | |
| 77 | + clocks = <&clk 112>, <&clk 113>, <&clk 93>; | |
| 78 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 79 | + }; | |
| @@ -1,62 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-wm8903" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the WM8903's pins (documented in the WM8903 binding document), | |
| 16 | − and the jacks on the board: | |
| 17 | − | |
| 18 | − * Headphone Jack | |
| 19 | − * Int Spk | |
| 20 | − * Mic Jack | |
| 21 | − * Int Mic | |
| 22 | − | |
| 23 | −- nvidia,i2s-controller : The phandle of the Tegra I2S1 controller | |
| 24 | −- nvidia,audio-codec : The phandle of the WM8903 audio codec | |
| 25 | − | |
| 26 | −Optional properties: | |
| 27 | −- nvidia,spkr-en-gpios : The GPIO that enables the speakers | |
| 28 | −- nvidia,hp-mute-gpios : The GPIO that mutes the headphones | |
| 29 | −- nvidia,hp-det-gpios : The GPIO that detect headphones are plugged in | |
| 30 | −- nvidia,int-mic-en-gpios : The GPIO that enables the internal microphone | |
| 31 | −- nvidia,ext-mic-en-gpios : The GPIO that enables the external microphone | |
| 32 | −- nvidia,headset : The Mic Jack represents state of the headset microphone pin | |
| 33 | − | |
| 34 | −Example: | |
| 35 | − | |
| 36 | −sound { | |
| 37 | − compatible = "nvidia,tegra-audio-wm8903-harmony", | |
| 38 | − "nvidia,tegra-audio-wm8903" | |
| 39 | − nvidia,model = "tegra-wm8903-harmony"; | |
| 40 | − | |
| 41 | − nvidia,audio-routing = | |
| 42 | − "Headphone Jack", "HPOUTR", | |
| 43 | − "Headphone Jack", "HPOUTL", | |
| 44 | − "Int Spk", "ROP", | |
| 45 | − "Int Spk", "RON", | |
| 46 | − "Int Spk", "LOP", | |
| 47 | − "Int Spk", "LON", | |
| 48 | − "Mic Jack", "MICBIAS", | |
| 49 | − "IN1L", "Mic Jack"; | |
| 50 | − | |
| 51 | − nvidia,i2s-controller = <&i2s1>; | |
| 52 | − nvidia,audio-codec = <&wm8903>; | |
| 53 | − | |
| 54 | − nvidia,spkr-en-gpios = <&codec 2 0>; | |
| 55 | − nvidia,hp-det-gpios = <&gpio 178 0>; /* gpio PW2 */ | |
| 56 | − nvidia,int-mic-en-gpios = <&gpio 184 0>; /*gpio PX0 */ | |
| 57 | − nvidia,ext-mic-en-gpios = <&gpio 185 0>; /* gpio PX1 */ | |
| 58 | − | |
| 59 | − clocks = <&tegra_car 112>, <&tegra_car 113>, <&tegra_car 93>; | |
| 60 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 61 | −}; | |
| 62 | − | |
| @@ -0,0 +1,93 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-wm8903.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with WM8903 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + oneOf: | |
| 19 | + - items: | |
| 20 | + - pattern: '^[a-z0-9]+,tegra-audio-wm8903(-[a-z0-9]+)+$' | |
| 21 | + - const: nvidia,tegra-audio-wm8903 | |
| 22 | + - items: | |
| 23 | + - pattern: ad,tegra-audio-plutux | |
| 24 | + - const: nvidia,tegra-audio-wm8903 | |
| 25 | + | |
| 26 | + nvidia,audio-routing: | |
| 27 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 28 | + description: | | |
| 29 | + A list of the connections between audio components. | |
| 30 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 31 | + the second being the connection's source. Valid names for sources and | |
| 32 | + sinks are the pins (documented in the binding document), | |
| 33 | + and the jacks on the board. | |
| 34 | + minItems: 2 | |
| 35 | + items: | |
| 36 | + enum: | |
| 37 | + # Board Connectors | |
| 38 | + - "Headphone Jack" | |
| 39 | + - "Int Spk" | |
| 40 | + - "Mic Jack" | |
| 41 | + - "Int Mic" | |
| 42 | + | |
| 43 | + # CODEC Pins | |
| 44 | + - IN1L | |
| 45 | + - IN1R | |
| 46 | + - IN2L | |
| 47 | + - IN2R | |
| 48 | + - IN3L | |
| 49 | + - IN3R | |
| 50 | + - DMICDAT | |
| 51 | + - HPOUTL | |
| 52 | + - HPOUTR | |
| 53 | + - LINEOUTL | |
| 54 | + - LINEOUTR | |
| 55 | + - LOP | |
| 56 | + - LON | |
| 57 | + - ROP | |
| 58 | + - RON | |
| 59 | + - MICBIAS | |
| 60 | + | |
| 61 | +required: | |
| 62 | + - nvidia,i2s-controller | |
| 63 | + | |
| 64 | +unevaluatedProperties: false | |
| 65 | + | |
| 66 | +examples: | |
| 67 | + - | | |
| 68 | + sound { | |
| 69 | + compatible = "nvidia,tegra-audio-wm8903-harmony", | |
| 70 | + "nvidia,tegra-audio-wm8903"; | |
| 71 | + nvidia,model = "tegra-wm8903-harmony"; | |
| 72 | + | |
| 73 | + nvidia,audio-routing = | |
| 74 | + "Headphone Jack", "HPOUTR", | |
| 75 | + "Headphone Jack", "HPOUTL", | |
| 76 | + "Int Spk", "ROP", | |
| 77 | + "Int Spk", "RON", | |
| 78 | + "Int Spk", "LOP", | |
| 79 | + "Int Spk", "LON", | |
| 80 | + "Mic Jack", "MICBIAS", | |
| 81 | + "IN1L", "Mic Jack"; | |
| 82 | + | |
| 83 | + nvidia,i2s-controller = <&i2s1>; | |
| 84 | + nvidia,audio-codec = <&wm8903>; | |
| 85 | + | |
| 86 | + nvidia,spkr-en-gpios = <&codec 2 0>; | |
| 87 | + nvidia,hp-det-gpios = <&gpio 178 0>; | |
| 88 | + nvidia,int-mic-en-gpios = <&gpio 184 0>; | |
| 89 | + nvidia,ext-mic-en-gpios = <&gpio 185 0>; | |
| 90 | + | |
| 91 | + clocks = <&clk 112>, <&clk 113>, <&clk 93>; | |
| 92 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 93 | + }; | |
| @@ -1,60 +0,0 @@ | ||
| 1 | −NVIDIA Tegra audio complex | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra-audio-wm9712" | |
| 5 | −- clocks : Must contain an entry for each entry in clock-names. | |
| 6 | − See ../clocks/clock-bindings.txt for details. | |
| 7 | −- clock-names : Must include the following entries: | |
| 8 | − - pll_a | |
| 9 | − - pll_a_out0 | |
| 10 | − - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | |
| 11 | −- nvidia,model : The user-visible name of this sound complex. | |
| 12 | −- nvidia,audio-routing : A list of the connections between audio components. | |
| 13 | − Each entry is a pair of strings, the first being the connection's sink, | |
| 14 | − the second being the connection's source. Valid names for sources and | |
| 15 | − sinks are the WM9712's pins, and the jacks on the board: | |
| 16 | − | |
| 17 | − WM9712 pins: | |
| 18 | − | |
| 19 | − * MONOOUT | |
| 20 | − * HPOUTL | |
| 21 | − * HPOUTR | |
| 22 | − * LOUT2 | |
| 23 | − * ROUT2 | |
| 24 | − * OUT3 | |
| 25 | − * LINEINL | |
| 26 | − * LINEINR | |
| 27 | − * PHONE | |
| 28 | − * PCBEEP | |
| 29 | − * MIC1 | |
| 30 | − * MIC2 | |
| 31 | − * Mic Bias | |
| 32 | − | |
| 33 | − Board connectors: | |
| 34 | − | |
| 35 | − * Headphone | |
| 36 | − * LineIn | |
| 37 | − * Mic | |
| 38 | − | |
| 39 | −- nvidia,ac97-controller : The phandle of the Tegra AC97 controller | |
| 40 | − | |
| 41 | − | |
| 42 | −Example: | |
| 43 | − | |
| 44 | −sound { | |
| 45 | − compatible = "nvidia,tegra-audio-wm9712-colibri_t20", | |
| 46 | − "nvidia,tegra-audio-wm9712"; | |
| 47 | − nvidia,model = "Toradex Colibri T20"; | |
| 48 | − | |
| 49 | − nvidia,audio-routing = | |
| 50 | − "Headphone", "HPOUTL", | |
| 51 | − "Headphone", "HPOUTR", | |
| 52 | − "LineIn", "LINEINL", | |
| 53 | − "LineIn", "LINEINR", | |
| 54 | − "Mic", "MIC1"; | |
| 55 | − | |
| 56 | − nvidia,ac97-controller = <&ac97>; | |
| 57 | − | |
| 58 | − clocks = <&tegra_car 112>, <&tegra_car 113>, <&tegra_car 93>; | |
| 59 | − clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 60 | −}; | |
| @@ -0,0 +1,76 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-wm9712.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra audio complex with WM9712 CODEC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 11 | + - Thierry Reding <thierry.reding@gmail.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: nvidia,tegra-audio-common.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + items: | |
| 19 | + - pattern: '^[a-z0-9]+,tegra-audio-wm9712([-_][a-z0-9]+)+$' | |
| 20 | + - const: nvidia,tegra-audio-wm9712 | |
| 21 | + | |
| 22 | + nvidia,audio-routing: | |
| 23 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 24 | + description: | | |
| 25 | + A list of the connections between audio components. | |
| 26 | + Each entry is a pair of strings, the first being the connection's sink, | |
| 27 | + the second being the connection's source. Valid names for sources and | |
| 28 | + sinks are the pins (documented in the binding document), | |
| 29 | + and the jacks on the board. | |
| 30 | + minItems: 2 | |
| 31 | + items: | |
| 32 | + enum: | |
| 33 | + # Board Connectors | |
| 34 | + - "Headphone" | |
| 35 | + - "LineIn" | |
| 36 | + - "Mic" | |
| 37 | + | |
| 38 | + # CODEC Pins | |
| 39 | + - MONOOUT | |
| 40 | + - HPOUTL | |
| 41 | + - HPOUTR | |
| 42 | + - LOUT2 | |
| 43 | + - ROUT2 | |
| 44 | + - OUT3 | |
| 45 | + - LINEINL | |
| 46 | + - LINEINR | |
| 47 | + - PHONE | |
| 48 | + - PCBEEP | |
| 49 | + - MIC1 | |
| 50 | + - MIC2 | |
| 51 | + - "Mic Bias" | |
| 52 | + | |
| 53 | +required: | |
| 54 | + - nvidia,ac97-controller | |
| 55 | + | |
| 56 | +unevaluatedProperties: false | |
| 57 | + | |
| 58 | +examples: | |
| 59 | + - | | |
| 60 | + sound { | |
| 61 | + compatible = "nvidia,tegra-audio-wm9712-colibri_t20", | |
| 62 | + "nvidia,tegra-audio-wm9712"; | |
| 63 | + nvidia,model = "Toradex Colibri T20"; | |
| 64 | + | |
| 65 | + nvidia,audio-routing = | |
| 66 | + "Headphone", "HPOUTL", | |
| 67 | + "Headphone", "HPOUTR", | |
| 68 | + "LineIn", "LINEINL", | |
| 69 | + "LineIn", "LINEINR", | |
| 70 | + "Mic", "MIC1"; | |
| 71 | + | |
| 72 | + nvidia,ac97-controller = <&ac97>; | |
| 73 | + | |
| 74 | + clocks = <&clk 112>, <&clk 113>, <&clk 93>; | |
| 75 | + clock-names = "pll_a", "pll_a_out0", "mclk"; | |
| 76 | + }; | |
| @@ -1,30 +0,0 @@ | ||
| 1 | −NVIDIA Tegra 20 I2S controller | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "nvidia,tegra20-i2s" | |
| 5 | −- reg : Should contain I2S registers location and length | |
| 6 | −- interrupts : Should contain I2S interrupt | |
| 7 | −- resets : Must contain an entry for each entry in reset-names. | |
| 8 | − See ../reset/reset.txt for details. | |
| 9 | −- reset-names : Must include the following entries: | |
| 10 | − - i2s | |
| 11 | −- dmas : Must contain an entry for each entry in clock-names. | |
| 12 | − See ../dma/dma.txt for details. | |
| 13 | −- dma-names : Must include the following entries: | |
| 14 | − - rx | |
| 15 | − - tx | |
| 16 | −- clocks : Must contain one entry, for the module clock. | |
| 17 | − See ../clocks/clock-bindings.txt for details. | |
| 18 | − | |
| 19 | −Example: | |
| 20 | − | |
| 21 | −i2s@70002800 { | |
| 22 | − compatible = "nvidia,tegra20-i2s"; | |
| 23 | − reg = <0x70002800 0x200>; | |
| 24 | − interrupts = < 45 >; | |
| 25 | − clocks = <&tegra_car 11>; | |
| 26 | − resets = <&tegra_car 11>; | |
| 27 | − reset-names = "i2s"; | |
| 28 | − dmas = <&apbdma 21>, <&apbdma 21>; | |
| 29 | − dma-names = "rx", "tx"; | |
| 30 | −}; | |
| @@ -0,0 +1,77 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra20-i2s.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra20 I2S Controller | |
| 8 | + | |
| 9 | +description: | | |
| 10 | + The I2S Controller streams synchronous serial audio data between system | |
| 11 | + memory and an external audio device. The controller supports the I2S Left | |
| 12 | + Justified Mode, Right Justified Mode, and DSP mode formats. | |
| 13 | + | |
| 14 | +maintainers: | |
| 15 | + - Thierry Reding <treding@nvidia.com> | |
| 16 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 17 | + | |
| 18 | +properties: | |
| 19 | + compatible: | |
| 20 | + const: nvidia,tegra20-i2s | |
| 21 | + | |
| 22 | + reg: | |
| 23 | + maxItems: 1 | |
| 24 | + | |
| 25 | + resets: | |
| 26 | + maxItems: 1 | |
| 27 | + | |
| 28 | + reset-names: | |
| 29 | + const: i2s | |
| 30 | + | |
| 31 | + interrupts: | |
| 32 | + maxItems: 1 | |
| 33 | + | |
| 34 | + clocks: | |
| 35 | + minItems: 1 | |
| 36 | + | |
| 37 | + dmas: | |
| 38 | + minItems: 2 | |
| 39 | + | |
| 40 | + dma-names: | |
| 41 | + items: | |
| 42 | + - const: rx | |
| 43 | + - const: tx | |
| 44 | + | |
| 45 | + nvidia,fixed-parent-rate: | |
| 46 | + description: | | |
| 47 | + Specifies whether board prefers parent clock to stay at a fixed rate. | |
| 48 | + This allows multiple Tegra20 audio components work simultaneously by | |
| 49 | + limiting number of supportable audio rates. | |
| 50 | + type: boolean | |
| 51 | + | |
| 52 | +required: | |
| 53 | + - compatible | |
| 54 | + - reg | |
| 55 | + - resets | |
| 56 | + - reset-names | |
| 57 | + - interrupts | |
| 58 | + - clocks | |
| 59 | + - dmas | |
| 60 | + - dma-names | |
| 61 | + | |
| 62 | +additionalProperties: false | |
| 63 | + | |
| 64 | +examples: | |
| 65 | + - | | |
| 66 | + i2s@70002800 { | |
| 67 | + compatible = "nvidia,tegra20-i2s"; | |
| 68 | + reg = <0x70002800 0x200>; | |
| 69 | + interrupts = <45>; | |
| 70 | + clocks = <&tegra_car 11>; | |
| 71 | + resets = <&tegra_car 11>; | |
| 72 | + reset-names = "i2s"; | |
| 73 | + dmas = <&apbdma 21>, <&apbdma 21>; | |
| 74 | + dma-names = "rx", "tx"; | |
| 75 | + }; | |
| 76 | + | |
| 77 | +... | |
| @@ -0,0 +1,85 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/nvidia,tegra20-spdif.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: NVIDIA Tegra20 S/PDIF Controller | |
| 8 | + | |
| 9 | +description: | | |
| 10 | + The S/PDIF controller supports both input and output in serial audio | |
| 11 | + digital interface format. The input controller can digitally recover | |
| 12 | + a clock from the received stream. The S/PDIF controller is also used | |
| 13 | + to generate the embedded audio for HDMI output channel. | |
| 14 | + | |
| 15 | +maintainers: | |
| 16 | + - Thierry Reding <treding@nvidia.com> | |
| 17 | + - Jon Hunter <jonathanh@nvidia.com> | |
| 18 | + | |
| 19 | +properties: | |
| 20 | + compatible: | |
| 21 | + const: nvidia,tegra20-spdif | |
| 22 | + | |
| 23 | + reg: | |
| 24 | + maxItems: 1 | |
| 25 | + | |
| 26 | + resets: | |
| 27 | + maxItems: 1 | |
| 28 | + | |
| 29 | + interrupts: | |
| 30 | + maxItems: 1 | |
| 31 | + | |
| 32 | + clocks: | |
| 33 | + minItems: 2 | |
| 34 | + | |
| 35 | + clock-names: | |
| 36 | + items: | |
| 37 | + - const: out | |
| 38 | + - const: in | |
| 39 | + | |
| 40 | + dmas: | |
| 41 | + minItems: 2 | |
| 42 | + | |
| 43 | + dma-names: | |
| 44 | + items: | |
| 45 | + - const: rx | |
| 46 | + - const: tx | |
| 47 | + | |
| 48 | + "#sound-dai-cells": | |
| 49 | + const: 0 | |
| 50 | + | |
| 51 | + nvidia,fixed-parent-rate: | |
| 52 | + description: | | |
| 53 | + Specifies whether board prefers parent clock to stay at a fixed rate. | |
| 54 | + This allows multiple Tegra20 audio components work simultaneously by | |
| 55 | + limiting number of supportable audio rates. | |
| 56 | + type: boolean | |
| 57 | + | |
| 58 | +required: | |
| 59 | + - compatible | |
| 60 | + - reg | |
| 61 | + - resets | |
| 62 | + - interrupts | |
| 63 | + - clocks | |
| 64 | + - clock-names | |
| 65 | + - dmas | |
| 66 | + - dma-names | |
| 67 | + - "#sound-dai-cells" | |
| 68 | + | |
| 69 | +additionalProperties: false | |
| 70 | + | |
| 71 | +examples: | |
| 72 | + - | | |
| 73 | + spdif@70002400 { | |
| 74 | + compatible = "nvidia,tegra20-spdif"; | |
| 75 | + reg = <0x70002400 0x200>; | |
| 76 | + interrupts = <77>; | |
| 77 | + clocks = <&clk 99>, <&clk 98>; | |
| 78 | + clock-names = "out", "in"; | |
| 79 | + resets = <&rst 10>; | |
| 80 | + dmas = <&apbdma 3>, <&apbdma 3>; | |
| 81 | + dma-names = "rx", "tx"; | |
| 82 | + #sound-dai-cells = <0>; | |
| 83 | + }; | |
| 84 | + | |
| 85 | +... | |
| @@ -50,9 +50,11 @@ properties: · 49 unmodified lines | ||
| 50 | 50 | - const: hda2codec_2x |
| 51 | 51 | |
| 52 | 52 | resets: |
| 53 | + minItems: 2 | |
| 53 | 54 | maxItems: 3 |
| 54 | 55 | |
| 55 | 56 | reset-names: |
| 57 | + minItems: 2 | |
| 56 | 58 | items: |
| 57 | 59 | - const: hda |
| 58 | 60 | - const: hda2hdmi |
| @@ -24,11 +24,23 @@ properties: · 23 unmodified lines | ||
| 24 | 24 | '#sound-dai-cells': |
| 25 | 25 | const: 0 |
| 26 | 26 | |
| 27 | + rcv-gpios: | |
| 28 | + description: optional GPIO to be asserted when receiver mode is enabled. | |
| 29 | + | |
| 27 | 30 | sound-name-prefix: true |
| 28 | 31 | |
| 29 | 32 | vddd-supply: |
| 30 | 33 | description: regulator phandle for the VDDD power supply. |
| 31 | 34 | |
| 35 | +if: | |
| 36 | + not: | |
| 37 | + properties: | |
| 38 | + compatible: | |
| 39 | + const: nxp,tfa9897 | |
| 40 | +then: | |
| 41 | + properties: | |
| 42 | + rcv-gpios: false | |
| 43 | + | |
| 32 | 44 | required: |
| 33 | 45 | - compatible |
| 34 | 46 | - reg |
| @@ -55,3 +67,32 @@ examples: · 20 unmodified lines | ||
| 55 | 67 | #sound-dai-cells = <0>; |
| 56 | 68 | }; |
| 57 | 69 | }; |
| 70 | + | |
| 71 | + - | | |
| 72 | + #include <dt-bindings/gpio/gpio.h> | |
| 73 | + i2c { | |
| 74 | + #address-cells = <1>; | |
| 75 | + #size-cells = <0>; | |
| 76 | + | |
| 77 | + speaker_codec_top: audio-codec@34 { | |
| 78 | + compatible = "nxp,tfa9897"; | |
| 79 | + reg = <0x34>; | |
| 80 | + vddd-supply = <&pm8916_l6>; | |
| 81 | + rcv-gpios = <&msmgpio 50 GPIO_ACTIVE_HIGH>; | |
| 82 | + pinctrl-names = "default"; | |
| 83 | + pinctrl-0 = <&speaker_top_default>; | |
| 84 | + sound-name-prefix = "Speaker Top"; | |
| 85 | + #sound-dai-cells = <0>; | |
| 86 | + }; | |
| 87 | + | |
| 88 | + speaker_codec_bottom: audio-codec@36 { | |
| 89 | + compatible = "nxp,tfa9897"; | |
| 90 | + reg = <0x36>; | |
| 91 | + vddd-supply = <&pm8916_l6>; | |
| 92 | + rcv-gpios = <&msmgpio 111 GPIO_ACTIVE_HIGH>; | |
| 93 | + pinctrl-names = "default"; | |
| 94 | + pinctrl-0 = <&speaker_bottom_default>; | |
| 95 | + sound-name-prefix = "Speaker Bottom"; | |
| 96 | + #sound-dai-cells = <0>; | |
| 97 | + }; | |
| 98 | + }; | |
| @@ -1,96 +0,0 @@ | ||
| 1 | −* Qualcomm Technologies APQ8016 SBC ASoC machine driver | |
| 2 | − | |
| 3 | −This node models the Qualcomm Technologies APQ8016 SBC ASoC machine driver | |
| 4 | − | |
| 5 | −Required properties: | |
| 6 | − | |
| 7 | −- compatible : "qcom,apq8016-sbc-sndcard" | |
| 8 | − | |
| 9 | −- pinctrl-N : One property must exist for each entry in | |
| 10 | − pinctrl-names. See ../pinctrl/pinctrl-bindings.txt | |
| 11 | − for details of the property values. | |
| 12 | −- pinctrl-names : Must contain a "default" entry. | |
| 13 | −- reg : Must contain an address for each entry in reg-names. | |
| 14 | −- reg-names : A list which must include the following entries: | |
| 15 | − * "mic-iomux" | |
| 16 | − * "spkr-iomux" | |
| 17 | −- qcom,model : Name of the sound card. | |
| 18 | − | |
| 19 | −- qcom,audio-routing : A list of the connections between audio components. | |
| 20 | − Each entry is a pair of strings, the first being the | |
| 21 | − connection's sink, the second being the connection's | |
| 22 | − source. Valid names could be power supplies, MicBias | |
| 23 | − of msm8x16_wcd codec and the jacks on the board: | |
| 24 | − | |
| 25 | − Power supplies: | |
| 26 | − * MIC BIAS External1 | |
| 27 | − * MIC BIAS External2 | |
| 28 | − * MIC BIAS Internal1 | |
| 29 | − * MIC BIAS Internal2 | |
| 30 | − | |
| 31 | − Board connectors: | |
| 32 | − * Headset Mic | |
| 33 | − * Secondary Mic | |
| 34 | − * DMIC | |
| 35 | − * Ext Spk | |
| 36 | − | |
| 37 | −Optional properties: | |
| 38 | − | |
| 39 | −- aux-devs : A list of phandles for auxiliary devices (e.g. analog | |
| 40 | − amplifiers) that do not appear directly within the DAI | |
| 41 | − links. Should be connected to another audio component | |
| 42 | − using "qcom,audio-routing". | |
| 43 | − | |
| 44 | −Dai-link subnode properties and subnodes: | |
| 45 | − | |
| 46 | −Required dai-link subnodes: | |
| 47 | − | |
| 48 | −- cpu : CPU sub-node | |
| 49 | −- codec : CODEC sub-node | |
| 50 | − | |
| 51 | −Required CPU/CODEC subnodes properties: | |
| 52 | − | |
| 53 | −-link-name : Name of the dai link. | |
| 54 | −-sound-dai : phandle/s and port of CPU/CODEC | |
| 55 | − | |
| 56 | −Example: | |
| 57 | − | |
| 58 | −sound: sound { | |
| 59 | − compatible = "qcom,apq8016-sbc-sndcard"; | |
| 60 | − reg = <0x07702000 0x4>, <0x07702004 0x4>; | |
| 61 | − reg-names = "mic-iomux", "spkr-iomux"; | |
| 62 | − qcom,model = "DB410c"; | |
| 63 | − | |
| 64 | − qcom,audio-routing = | |
| 65 | − "MIC BIAS External1", "Handset Mic", | |
| 66 | − "MIC BIAS Internal2", "Headset Mic", | |
| 67 | − "MIC BIAS External1", "Secondary Mic", | |
| 68 | − "AMIC1", "MIC BIAS External1", | |
| 69 | − "AMIC2", "MIC BIAS Internal2", | |
| 70 | − "AMIC3", "MIC BIAS External1", | |
| 71 | − "DMIC1", "MIC BIAS Internal1", | |
| 72 | − "MIC BIAS Internal1", "Digital Mic1", | |
| 73 | − "DMIC2", "MIC BIAS Internal1", | |
| 74 | − "MIC BIAS Internal1", "Digital Mic2"; | |
| 75 | − | |
| 76 | − /* I2S - Internal codec */ | |
| 77 | − internal-dai-link@0 { | |
| 78 | − cpu { /* PRIMARY */ | |
| 79 | − sound-dai = <&lpass MI2S_PRIMARY>; | |
| 80 | − }; | |
| 81 | − codec { | |
| 82 | − sound-dai = <&lpass_codec 0>, <&wcd_codec 0>; | |
| 83 | − }; | |
| 84 | − }; | |
| 85 | − | |
| 86 | − /* External Primary or External Secondary -ADV7533 HDMI */ | |
| 87 | − external-dai-link@0 { | |
| 88 | − link-name = "ADV7533"; | |
| 89 | − cpu { /* QUAT */ | |
| 90 | − sound-dai = <&lpass MI2S_QUATERNARY>; | |
| 91 | − }; | |
| 92 | − codec { | |
| 93 | − sound-dai = <&adv_bridge 0>; | |
| 94 | − }; | |
| 95 | − }; | |
| 96 | −}; | |
| @@ -4,18 +4,20 @@ · 3 unmodified lines | ||
| 4 | 4 | $id: http://devicetree.org/schemas/sound/qcom,sm8250.yaml# |
| 5 | 5 | $schema: http://devicetree.org/meta-schemas/core.yaml# |
| 6 | 6 | |
| 7 | −title: Qualcomm Technologies Inc. SM8250 ASoC sound card driver | |
| 7 | +title: Qualcomm Technologies Inc. ASoC sound card drivers | |
| 8 | 8 | |
| 9 | 9 | maintainers: |
| 10 | 10 | - Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
| 11 | 11 | |
| 12 | 12 | description: |
| 13 | − This bindings describes SC8250 SoC based sound cards | |
| 13 | + This bindings describes Qualcomm SoC based sound cards | |
| 14 | 14 | which uses LPASS internal codec for audio. |
| 15 | 15 | |
| 16 | 16 | properties: |
| 17 | 17 | compatible: |
| 18 | 18 | enum: |
| 19 | + - qcom,apq8016-sbc-sndcard | |
| 20 | + - qcom,msm8916-qdsp6-sndcard | |
| 19 | 21 | - qcom,sm8250-sndcard |
| 20 | 22 | - qcom,qrb5165-rb5-sndcard |
| 21 | 23 | |
| @@ -27,10 +29,28 @@ properties: · 5 unmodified lines | ||
| 27 | 29 | being the connection's source. Valid names could be power supplies, |
| 28 | 30 | MicBias of codec and the jacks on the board. |
| 29 | 31 | |
| 32 | + aux-devs: | |
| 33 | + $ref: /schemas/types.yaml#/definitions/phandle-array | |
| 34 | + description: | | |
| 35 | + List of phandles pointing to auxiliary devices, such | |
| 36 | + as amplifiers, to be added to the sound card. | |
| 37 | + | |
| 30 | 38 | model: |
| 31 | 39 | $ref: /schemas/types.yaml#/definitions/string |
| 32 | 40 | description: User visible long sound card name |
| 33 | 41 | |
| 42 | + pin-switches: | |
| 43 | + description: List of widget names for which pin switches should be created. | |
| 44 | + $ref: /schemas/types.yaml#/definitions/string-array | |
| 45 | + | |
| 46 | + widgets: | |
| 47 | + description: User specified audio sound widgets. | |
| 48 | + $ref: /schemas/types.yaml#/definitions/non-unique-string-array | |
| 49 | + | |
| 50 | + # Only valid for some compatibles (see allOf if below) | |
| 51 | + reg: true | |
| 52 | + reg-names: true | |
| 53 | + | |
| 34 | 54 | patternProperties: |
| 35 | 55 | ".*-dai-link$": |
| 36 | 56 | description: |
| @@ -73,6 +93,34 @@ required: · 36 unmodified lines | ||
| 73 | 93 | - compatible |
| 74 | 94 | - model |
| 75 | 95 | |
| 96 | +allOf: | |
| 97 | + - if: | |
| 98 | + properties: | |
| 99 | + compatible: | |
| 100 | + contains: | |
| 101 | + enum: | |
| 102 | + - qcom,apq8016-sbc-sndcard | |
| 103 | + - qcom,msm8916-qdsp6-sndcard | |
| 104 | + then: | |
| 105 | + properties: | |
| 106 | + reg: | |
| 107 | + items: | |
| 108 | + - description: Microphone I/O mux register address | |
| 109 | + - description: Speaker I/O mux register address | |
| 110 | + reg-names: | |
| 111 | + items: | |
| 112 | + - const: mic-iomux | |
| 113 | + - const: spkr-iomux | |
| 114 | + required: | |
| 115 | + - compatible | |
| 116 | + - model | |
| 117 | + - reg | |
| 118 | + - reg-names | |
| 119 | + else: | |
| 120 | + properties: | |
| 121 | + reg: false | |
| 122 | + reg-names: false | |
| 123 | + | |
| 76 | 124 | additionalProperties: false |
| 77 | 125 | |
| 78 | 126 | examples: |
| @@ -86,10 +134,7 @@ examples: · 7 unmodified lines | ||
| 86 | 134 | audio-routing = "SpkrLeft IN", "WSA_SPK1 OUT", |
| 87 | 135 | "SpkrRight IN", "WSA_SPK2 OUT", |
| 88 | 136 | "VA DMIC0", "vdd-micb", |
| 89 | − "VA DMIC1", "vdd-micb", | |
| 90 | − "MM_DL1", "MultiMedia1 Playback", | |
| 91 | − "MM_DL2", "MultiMedia2 Playback", | |
| 92 | − "MultiMedia3 Capture", "MM_UL3"; | |
| 137 | + "VA DMIC1", "vdd-micb"; | |
| 93 | 138 | |
| 94 | 139 | mm1-dai-link { |
| 95 | 140 | link-name = "MultiMedia0"; |
| @@ -157,3 +202,98 @@ examples: · 61 unmodified lines | ||
| 157 | 202 | }; |
| 158 | 203 | }; |
| 159 | 204 | }; |
| 205 | + | |
| 206 | + - | | |
| 207 | + #include <dt-bindings/sound/qcom,lpass.h> | |
| 208 | + sound@7702000 { | |
| 209 | + compatible = "qcom,apq8016-sbc-sndcard"; | |
| 210 | + reg = <0x07702000 0x4>, <0x07702004 0x4>; | |
| 211 | + reg-names = "mic-iomux", "spkr-iomux"; | |
| 212 | + | |
| 213 | + model = "DB410c"; | |
| 214 | + audio-routing = | |
| 215 | + "AMIC2", "MIC BIAS Internal2", | |
| 216 | + "AMIC3", "MIC BIAS External1"; | |
| 217 | + | |
| 218 | + pinctrl-0 = <&cdc_pdm_lines_act &ext_sec_tlmm_lines_act &ext_mclk_tlmm_lines_act>; | |
| 219 | + pinctrl-1 = <&cdc_pdm_lines_sus &ext_sec_tlmm_lines_sus &ext_mclk_tlmm_lines_sus>; | |
| 220 | + pinctrl-names = "default", "sleep"; | |
| 221 | + | |
| 222 | + quaternary-dai-link { | |
| 223 | + link-name = "ADV7533"; | |
| 224 | + cpu { | |
| 225 | + sound-dai = <&lpass MI2S_QUATERNARY>; | |
| 226 | + }; | |
| 227 | + codec { | |
| 228 | + sound-dai = <&adv_bridge 0>; | |
| 229 | + }; | |
| 230 | + }; | |
| 231 | + | |
| 232 | + primary-dai-link { | |
| 233 | + link-name = "WCD"; | |
| 234 | + cpu { | |
| 235 | + sound-dai = <&lpass MI2S_PRIMARY>; | |
| 236 | + }; | |
| 237 | + codec { | |
| 238 | + sound-dai = <&lpass_codec 0>, <&wcd_codec 0>; | |
| 239 | + }; | |
| 240 | + }; | |
| 241 | + | |
| 242 | + tertiary-dai-link { | |
| 243 | + link-name = "WCD-Capture"; | |
| 244 | + cpu { | |
| 245 | + sound-dai = <&lpass MI2S_TERTIARY>; | |
| 246 | + }; | |
| 247 | + codec { | |
| 248 | + sound-dai = <&lpass_codec 1>, <&wcd_codec 1>; | |
| 249 | + }; | |
| 250 | + }; | |
| 251 | + }; | |
| 252 | + | |
| 253 | + - | | |
| 254 | + #include <dt-bindings/sound/qcom,q6afe.h> | |
| 255 | + #include <dt-bindings/sound/qcom,q6asm.h> | |
| 256 | + sound@7702000 { | |
| 257 | + compatible = "qcom,msm8916-qdsp6-sndcard"; | |
| 258 | + reg = <0x07702000 0x4>, <0x07702004 0x4>; | |
| 259 | + reg-names = "mic-iomux", "spkr-iomux"; | |
| 260 | + | |
| 261 | + model = "msm8916"; | |
| 262 | + widgets = | |
| 263 | + "Speaker", "Speaker", | |
| 264 | + "Headphone", "Headphones"; | |
| 265 | + pin-switches = "Speaker"; | |
| 266 | + audio-routing = | |
| 267 | + "Speaker", "Speaker Amp OUT", | |
| 268 | + "Speaker Amp IN", "HPH_R", | |
| 269 | + "Headphones", "HPH_L", | |
| 270 | + "Headphones", "HPH_R", | |
| 271 | + "AMIC1", "MIC BIAS Internal1", | |
| 272 | + "AMIC2", "MIC BIAS Internal2", | |
| 273 | + "AMIC3", "MIC BIAS Internal3"; | |
| 274 | + aux-devs = <&speaker_amp>; | |
| 275 | + | |
| 276 | + pinctrl-names = "default", "sleep"; | |
| 277 | + pinctrl-0 = <&cdc_pdm_lines_act>; | |
| 278 | + pinctrl-1 = <&cdc_pdm_lines_sus>; | |
| 279 | + | |
| 280 | + mm1-dai-link { | |
| 281 | + link-name = "MultiMedia1"; | |
| 282 | + cpu { | |
| 283 | + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>; | |
| 284 | + }; | |
| 285 | + }; | |
| 286 | + | |
| 287 | + primary-dai-link { | |
| 288 | + link-name = "Primary MI2S"; | |
| 289 | + cpu { | |
| 290 | + sound-dai = <&q6afedai PRIMARY_MI2S_RX>; | |
| 291 | + }; | |
| 292 | + platform { | |
| 293 | + sound-dai = <&q6routing>; | |
| 294 | + }; | |
| 295 | + codec { | |
| 296 | + sound-dai = <&lpass_codec 0>, <&wcd_codec 0>; | |
| 297 | + }; | |
| 298 | + }; | |
| 299 | + }; | |
| @@ -61,6 +61,10 @@ properties: · 60 unmodified lines | ||
| 61 | 61 | description: | |
| 62 | 62 | Set the delay time (ms) for the requirement of the particular DMIC. |
| 63 | 63 | |
| 64 | + realtek,amic-delay-ms: | |
| 65 | + description: | | |
| 66 | + Set the delay time (ms) for the requirement of the particular platform or AMIC. | |
| 67 | + | |
| 64 | 68 | realtek,dmic-clk-driving-high: |
| 65 | 69 | type: boolean |
| 66 | 70 | description: | |
| @@ -9,6 +9,9 @@ title: Simple Audio Amplifier Device Tree Bindings · 8 unmodified lines | ||
| 9 | 9 | maintainers: |
| 10 | 10 | - Jerome Brunet <jbrunet@baylibre.com> |
| 11 | 11 | |
| 12 | +allOf: | |
| 13 | + - $ref: name-prefix.yaml# | |
| 14 | + | |
| 12 | 15 | properties: |
| 13 | 16 | compatible: |
| 14 | 17 | enum: |
| @@ -22,10 +25,7 @@ properties: · 7 unmodified lines | ||
| 22 | 25 | description: > |
| 23 | 26 | power supply for the device |
| 24 | 27 | |
| 25 | − sound-name-prefix: | |
| 26 | − $ref: /schemas/types.yaml#/definitions/string | |
| 27 | − description: > | |
| 28 | − See ./name-prefix.txt | |
| 28 | + sound-name-prefix: true | |
| 29 | 29 | |
| 30 | 30 | required: |
| 31 | 31 | - compatible |
| @@ -0,0 +1,137 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/sound/ti,tlv320adc3xxx.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Texas Instruments TLV320ADC3001/TLV320ADC3101 Stereo ADC | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Ricard Wanderlof <ricardw@axis.com> | |
| 11 | + | |
| 12 | +description: | | |
| 13 | + Texas Instruments TLV320ADC3001 and TLV320ADC3101 Stereo ADC | |
| 14 | + https://www.ti.com/product/TLV320ADC3001 | |
| 15 | + https://www.ti.com/product/TLV320ADC3101 | |
| 16 | + | |
| 17 | +properties: | |
| 18 | + compatible: | |
| 19 | + enum: | |
| 20 | + - ti,tlv320adc3001 | |
| 21 | + - ti,tlv320adc3101 | |
| 22 | + | |
| 23 | + reg: | |
| 24 | + maxItems: 1 | |
| 25 | + description: I2C address | |
| 26 | + | |
| 27 | + '#sound-dai-cells': | |
| 28 | + const: 0 | |
| 29 | + | |
| 30 | + '#gpio-cells': | |
| 31 | + const: 2 | |
| 32 | + | |
| 33 | + gpio-controller: true | |
| 34 | + | |
| 35 | + reset-gpios: | |
| 36 | + maxItems: 1 | |
| 37 | + description: GPIO pin used for codec reset (RESET pin) | |
| 38 | + | |
| 39 | + clocks: | |
| 40 | + maxItems: 1 | |
| 41 | + description: Master clock (MCLK) | |
| 42 | + | |
| 43 | + ti,dmdin-gpio1: | |
| 44 | + $ref: /schemas/types.yaml#/definitions/uint32 | |
| 45 | + enum: | |
| 46 | + - 0 # ADC3XXX_GPIO_DISABLED - I/O buffers powered down and not used | |
| 47 | + - 1 # ADC3XXX_GPIO_INPUT - Various non-GPIO input functions | |
| 48 | + - 2 # ADC3XXX_GPIO_GPI - General purpose input | |
| 49 | + - 3 # ADC3XXX_GPIO_GPO - General purpose output | |
| 50 | + - 4 # ADC3XXX_GPIO_CLKOUT - Clock source set in CLKOUT_MUX reg | |
| 51 | + - 5 # ADC3XXX_GPIO_INT1 - INT1 output | |
| 52 | + - 6 # ADC3XXX_GPIO_SECONDARY_BCLK - Codec interface secondary BCLK | |
| 53 | + - 7 # ADC3XXX_GPIO_SECONDARY_WCLK - Codec interface secondary WCLK | |
| 54 | + default: 0 | |
| 55 | + description: | | |
| 56 | + Configuration for DMDIN/GPIO1 pin. | |
| 57 | + | |
| 58 | + When ADC3XXX_GPIO_GPO is configured, this causes corresponding the | |
| 59 | + ALSA control "GPIOx Output" to appear, as a switch control. | |
| 60 | + | |
| 61 | + ti,dmclk-gpio2: | |
| 62 | + $ref: /schemas/types.yaml#/definitions/uint32 | |
| 63 | + enum: | |
| 64 | + - 0 # ADC3XXX_GPIO_DISABLED - I/O buffers powered down and not used | |
| 65 | + - 1 # ADC3XXX_GPIO_INPUT - Various non-GPIO input functions | |
| 66 | + - 2 # ADC3XXX_GPIO_GPI - General purpose input | |
| 67 | + - 3 # ADC3XXX_GPIO_GPO - General purpose output | |
| 68 | + - 4 # ADC3XXX_GPIO_CLKOUT - Clock source set in CLKOUT_MUX reg | |
| 69 | + - 5 # ADC3XXX_GPIO_INT1 - INT1 output | |
| 70 | + - 6 # ADC3XXX_GPIO_SECONDARY_BCLK - Codec interface secondary BCLK | |
| 71 | + - 7 # ADC3XXX_GPIO_SECONDARY_WCLK - Codec interface secondary WCLK | |
| 72 | + default: 0 | |
| 73 | + description: | | |
| 74 | + Configuration for DMCLK/GPIO2 pin. | |
| 75 | + | |
| 76 | + When ADC3XXX_GPIO_GPO is configured, this causes corresponding the | |
| 77 | + ALSA control "GPIOx Output" to appear, as a switch control. | |
| 78 | + | |
| 79 | + Note that there is currently no support for reading the GPIO pins as | |
| 80 | + inputs. | |
| 81 | + | |
| 82 | + ti,micbias1-vg: | |
| 83 | + $ref: /schemas/types.yaml#/definitions/uint32 | |
| 84 | + enum: | |
| 85 | + - 0 # ADC3XXX_MICBIAS_OFF - Mic bias is powered down | |
| 86 | + - 1 # ADC3XXX_MICBIAS_2_0V - Mic bias is set to 2.0V | |
| 87 | + - 2 # ADC3XXX_MICBIAS_2_5V - Mic bias is set to 2.5V | |
| 88 | + - 3 # ADC3XXX_MICBIAS_AVDD - Mic bias is same as AVDD supply | |
| 89 | + default: 0 | |
| 90 | + description: | | |
| 91 | + Mic bias voltage output on MICBIAS1 pin | |
| 92 | + | |
| 93 | + ti,micbias2-vg: | |
| 94 | + $ref: /schemas/types.yaml#/definitions/uint32 | |
| 95 | + enum: | |
| 96 | + - 0 # ADC3XXX_MICBIAS_OFF - Mic bias is powered down | |
| 97 | + - 1 # ADC3XXX_MICBIAS_2_0V - Mic bias is set to 2.0V | |
| 98 | + - 2 # ADC3XXX_MICBIAS_2_5V - Mic bias is set to 2.5V | |
| 99 | + - 3 # ADC3XXX_MICBIAS_AVDD - Mic bias is same as AVDD supply | |
| 100 | + default: 0 | |
| 101 | + description: | | |
| 102 | + Mic bias voltage output on MICBIAS2 pin | |
| 103 | + | |
| 104 | +required: | |
| 105 | + - compatible | |
| 106 | + - reg | |
| 107 | + - clocks | |
| 108 | + | |
| 109 | +additionalProperties: false | |
| 110 | + | |
| 111 | +examples: | |
| 112 | + - | | |
| 113 | + | |
| 114 | + #include <dt-bindings/gpio/gpio.h> | |
| 115 | + #include <dt-bindings/sound/tlv320adc3xxx.h> | |
| 116 | + | |
| 117 | + i2c { | |
| 118 | + #address-cells = <1>; | |
| 119 | + #size-cells = <0>; | |
| 120 | + tlv320adc3101: audio-codec@18 { | |
| 121 | + compatible = "ti,tlv320adc3101"; | |
| 122 | + reg = <0x18>; | |
| 123 | + reset-gpios = <&gpio_pc 3 GPIO_ACTIVE_LOW>; | |
| 124 | + clocks = <&audio_mclk>; | |
| 125 | + gpio-controller; | |
| 126 | + #gpio-cells = <2>; | |
| 127 | + ti,dmdin-gpio1 = <ADC3XXX_GPIO_GPO>; | |
| 128 | + ti,micbias1-vg = <ADC3XXX_MICBIAS_AVDD>; | |
| 129 | + }; | |
| 130 | + }; | |
| 131 | + | |
| 132 | + audio_mclk: clock { | |
| 133 | + compatible = "fixed-clock"; | |
| 134 | + #clock-cells = <0>; | |
| 135 | + clock-frequency = <24576000>; | |
| 136 | + }; | |
| 137 | +... | |
| @@ -0,0 +1,116 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: "http://devicetree.org/schemas/sound/wlf,wm8903.yaml#" | |
| 5 | +$schema: "http://devicetree.org/meta-schemas/core.yaml#" | |
| 6 | + | |
| 7 | +title: WM8903 audio codec | |
| 8 | + | |
| 9 | +description: | | |
| 10 | + This device supports I2C only. | |
| 11 | + Pins on the device (for linking into audio routes): | |
| 12 | + * IN1L | |
| 13 | + * IN1R | |
| 14 | + * IN2L | |
| 15 | + * IN2R | |
| 16 | + * IN3L | |
| 17 | + * IN3R | |
| 18 | + * DMICDAT | |
| 19 | + * HPOUTL | |
| 20 | + * HPOUTR | |
| 21 | + * LINEOUTL | |
| 22 | + * LINEOUTR | |
| 23 | + * LOP | |
| 24 | + * LON | |
| 25 | + * ROP | |
| 26 | + * RON | |
| 27 | + * MICBIAS | |
| 28 | + | |
| 29 | +maintainers: | |
| 30 | + - patches@opensource.cirrus.com | |
| 31 | + | |
| 32 | +properties: | |
| 33 | + compatible: | |
| 34 | + const: wlf,wm8903 | |
| 35 | + | |
| 36 | + reg: | |
| 37 | + maxItems: 1 | |
| 38 | + | |
| 39 | + gpio-controller: true | |
| 40 | + '#gpio-cells': | |
| 41 | + const: 2 | |
| 42 | + | |
| 43 | + interrupts: | |
| 44 | + maxItems: 1 | |
| 45 | + | |
| 46 | + micdet-cfg: | |
| 47 | + $ref: /schemas/types.yaml#/definitions/uint32 | |
| 48 | + default: 0 | |
| 49 | + description: Default register value for R6 (Mic Bias). | |
| 50 | + | |
| 51 | + micdet-delay: | |
| 52 | + $ref: /schemas/types.yaml#/definitions/uint32 | |
| 53 | + default: 100 | |
| 54 | + description: The debounce delay for microphone detection in mS. | |
| 55 | + | |
| 56 | + gpio-cfg: | |
| 57 | + $ref: /schemas/types.yaml#/definitions/uint32-array | |
| 58 | + description: | | |
| 59 | + minItems: 5 | |
| 60 | + maxItems: 5 | |
| 61 | + A list of GPIO configuration register values. | |
| 62 | + If absent, no configuration of these registers is performed. | |
| 63 | + If any entry has the value 0xffffffff, that GPIO's | |
| 64 | + configuration will not be modified. | |
| 65 | + | |
| 66 | + AVDD-supply: | |
| 67 | + description: Analog power supply regulator on the AVDD pin. | |
| 68 | + | |
| 69 | + CPVDD-supply: | |
| 70 | + description: Charge pump supply regulator on the CPVDD pin. | |
| 71 | + | |
| 72 | + DBVDD-supply: | |
| 73 | + description: Digital buffer supply regulator for the DBVDD pin. | |
| 74 | + | |
| 75 | + DCVDD-supply: | |
| 76 | + description: Digital core supply regulator for the DCVDD pin. | |
| 77 | + | |
| 78 | + | |
| 79 | +required: | |
| 80 | + - compatible | |
| 81 | + - reg | |
| 82 | + - gpio-controller | |
| 83 | + - '#gpio-cells' | |
| 84 | + | |
| 85 | +additionalProperties: false | |
| 86 | + | |
| 87 | +examples: | |
| 88 | + - | | |
| 89 | + i2c { | |
| 90 | + #address-cells = <1>; | |
| 91 | + #size-cells = <0>; | |
| 92 | + | |
| 93 | + wm8903: codec@1a { | |
| 94 | + compatible = "wlf,wm8903"; | |
| 95 | + reg = <0x1a>; | |
| 96 | + interrupts = <347>; | |
| 97 | + | |
| 98 | + AVDD-supply = <&fooreg_a>; | |
| 99 | + CPVDD-supply = <&fooreg_b>; | |
| 100 | + DBVDD-supply = <&fooreg_c>; | |
| 101 | + DCVDD-supply = <&fooreg_d>; | |
| 102 | + | |
| 103 | + gpio-controller; | |
| 104 | + #gpio-cells = <2>; | |
| 105 | + | |
| 106 | + micdet-cfg = <0>; | |
| 107 | + micdet-delay = <100>; | |
| 108 | + gpio-cfg = < | |
| 109 | + 0x0600 /* DMIC_LR, output */ | |
| 110 | + 0x0680 /* DMIC_DAT, input */ | |
| 111 | + 0x0000 /* GPIO, output, low */ | |
| 112 | + 0x0200 /* Interrupt, output */ | |
| 113 | + 0x01a0 /* BCLK, input, active high */ | |
| 114 | + >; | |
| 115 | + }; | |
| 116 | + }; | |
| @@ -1,82 +0,0 @@ | ||
| 1 | −WM8903 audio CODEC | |
| 2 | − | |
| 3 | −This device supports I2C only. | |
| 4 | − | |
| 5 | −Required properties: | |
| 6 | − | |
| 7 | − - compatible : "wlf,wm8903" | |
| 8 | − | |
| 9 | − - reg : the I2C address of the device. | |
| 10 | − | |
| 11 | − - gpio-controller : Indicates this device is a GPIO controller. | |
| 12 | − | |
| 13 | − - #gpio-cells : Should be two. The first cell is the pin number and the | |
| 14 | − second cell is used to specify optional parameters (currently unused). | |
| 15 | − | |
| 16 | −Optional properties: | |
| 17 | − | |
| 18 | − - interrupts : The interrupt line the codec is connected to. | |
| 19 | − | |
| 20 | − - micdet-cfg : Default register value for R6 (Mic Bias). If absent, the | |
| 21 | − default is 0. | |
| 22 | − | |
| 23 | − - micdet-delay : The debounce delay for microphone detection in mS. If | |
| 24 | − absent, the default is 100. | |
| 25 | − | |
| 26 | − - gpio-cfg : A list of GPIO configuration register values. The list must | |
| 27 | − be 5 entries long. If absent, no configuration of these registers is | |
| 28 | − performed. If any entry has the value 0xffffffff, that GPIO's | |
| 29 | − configuration will not be modified. | |
| 30 | − | |
| 31 | − - AVDD-supply : Analog power supply regulator on the AVDD pin. | |
| 32 | − | |
| 33 | − - CPVDD-supply : Charge pump supply regulator on the CPVDD pin. | |
| 34 | − | |
| 35 | − - DBVDD-supply : Digital buffer supply regulator for the DBVDD pin. | |
| 36 | − | |
| 37 | − - DCVDD-supply : Digital core supply regulator for the DCVDD pin. | |
| 38 | − | |
| 39 | −Pins on the device (for linking into audio routes): | |
| 40 | − | |
| 41 | − * IN1L | |
| 42 | − * IN1R | |
| 43 | − * IN2L | |
| 44 | − * IN2R | |
| 45 | − * IN3L | |
| 46 | − * IN3R | |
| 47 | − * DMICDAT | |
| 48 | − * HPOUTL | |
| 49 | − * HPOUTR | |
| 50 | − * LINEOUTL | |
| 51 | − * LINEOUTR | |
| 52 | − * LOP | |
| 53 | − * LON | |
| 54 | − * ROP | |
| 55 | − * RON | |
| 56 | − * MICBIAS | |
| 57 | − | |
| 58 | −Example: | |
| 59 | − | |
| 60 | −wm8903: codec@1a { | |
| 61 | − compatible = "wlf,wm8903"; | |
| 62 | − reg = <0x1a>; | |
| 63 | − interrupts = < 347 >; | |
| 64 | − | |
| 65 | − AVDD-supply = <&fooreg_a>; | |
| 66 | − CPVDD-supply = <&fooreg_b>; | |
| 67 | − DBVDD-supply = <&fooreg_c>; | |
| 68 | − DCVDC-supply = <&fooreg_d>; | |
| 69 | − | |
| 70 | − gpio-controller; | |
| 71 | − #gpio-cells = <2>; | |
| 72 | − | |
| 73 | − micdet-cfg = <0>; | |
| 74 | − micdet-delay = <100>; | |
| 75 | − gpio-cfg = < | |
| 76 | − 0x0600 /* DMIC_LR, output */ | |
| 77 | − 0x0680 /* DMIC_DAT, input */ | |
| 78 | − 0x0000 /* GPIO, output, low */ | |
| 79 | − 0x0200 /* Interrupt, output */ | |
| 80 | − 0x01a0 /* BCLK, input, active high */ | |
| 81 | − >; | |
| 82 | −}; | |
| @@ -4568,9 +4568,12 @@ F: drivers/media/cec/i2c/ch7322.c · 4567 unmodified lines | ||
| 4568 | 4568 | CIRRUS LOGIC AUDIO CODEC DRIVERS |
| 4569 | 4569 | M: James Schulman <james.schulman@cirrus.com> |
| 4570 | 4570 | M: David Rhodes <david.rhodes@cirrus.com> |
| 4571 | +M: Lucas Tanure <tanureal@opensource.cirrus.com> | |
| 4571 | 4572 | L: alsa-devel@alsa-project.org (moderated for non-subscribers) |
| 4572 | 4573 | L: patches@opensource.cirrus.com |
| 4573 | 4574 | S: Maintained |
| 4575 | +F: Documentation/devicetree/bindings/sound/cirrus,cs* | |
| 4576 | +F: sound/pci/hda/cs* | |
| 4574 | 4577 | F: sound/soc/codecs/cs* |
| 4575 | 4578 | |
| 4576 | 4579 | CIRRUS LOGIC DSP FIRMWARE DRIVER |
| @@ -17988,6 +17991,7 @@ F: Documentation/sound/ · 13411 unmodified lines | ||
| 17988 | 17991 | F: include/sound/ |
| 17989 | 17992 | F: include/uapi/sound/ |
| 17990 | 17993 | F: sound/ |
| 17994 | +F: tools/testing/selftests/alsa | |
| 17991 | 17995 | |
| 17992 | 17996 | SOUND - COMPRESSED AUDIO |
| 17993 | 17997 | M: Vinod Koul <vkoul@kernel.org> |
| @@ -18007,6 +18011,13 @@ F: include/sound/dmaengine_pcm.h · 13 unmodified lines | ||
| 18007 | 18011 | F: sound/core/pcm_dmaengine.c |
| 18008 | 18012 | F: sound/soc/soc-generic-dmaengine-pcm.c |
| 18009 | 18013 | |
| 18014 | +SOUND - ALSA SELFTESTS | |
| 18015 | +M: Mark Brown <broonie@kernel.org> | |
| 18016 | +L: alsa-devel@alsa-project.org (moderated for non-subscribers) | |
| 18017 | +L: linux-kselftest@vger.kernel.org | |
| 18018 | +S: Supported | |
| 18019 | +F: tools/testing/selftests/alsa | |
| 18020 | + | |
| 18010 | 18021 | SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC) |
| 18011 | 18022 | M: Liam Girdwood <lgirdwood@gmail.com> |
| 18012 | 18023 | M: Mark Brown <broonie@kernel.org> |
| @@ -995,9 +995,8 @@ · 994 unmodified lines | ||
| 995 | 995 | <&bpmp TEGRA194_CLK_HDA2CODEC_2X>; |
| 996 | 996 | clock-names = "hda", "hda2hdmi", "hda2codec_2x"; |
| 997 | 997 | resets = <&bpmp TEGRA194_RESET_HDA>, |
| 998 | − <&bpmp TEGRA194_RESET_HDA2HDMICODEC>, | |
| 999 | − <&bpmp TEGRA194_RESET_HDA2CODEC_2X>; | |
| 1000 | − reset-names = "hda", "hda2hdmi", "hda2codec_2x"; | |
| 998 | + <&bpmp TEGRA194_RESET_HDA2HDMICODEC>; | |
| 999 | + reset-names = "hda", "hda2hdmi"; | |
| 1001 | 1000 | power-domains = <&bpmp TEGRA194_POWER_DOMAIN_DISP>; |
| 1002 | 1001 | interconnects = <&mc TEGRA194_MEMORY_CLIENT_HDAR &emc>, |
| 1003 | 1002 | <&mc TEGRA194_MEMORY_CLIENT_HDAW &emc>; |
| @@ -727,12 +727,6 @@ static int mmp_pdma_config_write(struct dma_chan *dchan, · 726 unmodified lines | ||
| 727 | 727 | |
| 728 | 728 | chan->dir = direction; |
| 729 | 729 | chan->dev_addr = addr; |
| 730 | − /* FIXME: drivers should be ported over to use the filter | |
| 731 | − * function. Once that's done, the following two lines can | |
| 732 | − * be removed. | |
| 733 | − */ | |
| 734 | − if (cfg->slave_id) | |
| 735 | − chan->drcmr = cfg->slave_id; | |
| 736 | 730 | |
| 737 | 731 | return 0; |
| 738 | 732 | } |
| @@ -909,13 +909,6 @@ static void pxad_get_config(struct pxad_chan *chan, · 908 unmodified lines | ||
| 909 | 909 | *dcmd |= PXA_DCMD_BURST16; |
| 910 | 910 | else if (maxburst == 32) |
| 911 | 911 | *dcmd |= PXA_DCMD_BURST32; |
| 912 | − | |
| 913 | − /* FIXME: drivers should be ported over to use the filter | |
| 914 | − * function. Once that's done, the following two lines can | |
| 915 | − * be removed. | |
| 916 | − */ | |
| 917 | − if (chan->cfg.slave_id) | |
| 918 | − chan->drcmr = chan->cfg.slave_id; | |
| 919 | 912 | } |
| 920 | 913 | |
| 921 | 914 | static struct dma_async_tx_descriptor * |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #include <linux/device.h> |
| 9 | 9 | #include <linux/dmaengine.h> |
| 10 | 10 | #include <linux/dma-mapping.h> |
| 11 | +#include <linux/dma/qcom_adm.h> | |
| 11 | 12 | #include <linux/init.h> |
| 12 | 13 | #include <linux/interrupt.h> |
| 13 | 14 | #include <linux/io.h> |
| @@ -140,6 +141,8 @@ struct adm_chan { · 126 unmodified lines | ||
| 140 | 141 | |
| 141 | 142 | struct adm_async_desc *curr_txd; |
| 142 | 143 | struct dma_slave_config slave; |
| 144 | + u32 crci; | |
| 145 | + u32 mux; | |
| 143 | 146 | struct list_head node; |
| 144 | 147 | |
| 145 | 148 | int error; |
| @@ -379,8 +382,8 @@ static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan, · 233 unmodified lines | ||
| 379 | 382 | return ERR_PTR(-EINVAL); |
| 380 | 383 | } |
| 381 | 384 | |
| 382 | − crci = achan->slave.slave_id & 0xf; | |
| 383 | − if (!crci || achan->slave.slave_id > 0x1f) { | |
| 385 | + crci = achan->crci & 0xf; | |
| 386 | + if (!crci || achan->crci > 0x1f) { | |
| 384 | 387 | dev_err(adev->dev, "invalid crci value\n"); |
| 385 | 388 | return ERR_PTR(-EINVAL); |
| 386 | 389 | } |
| @@ -403,9 +406,7 @@ static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan, · 16 unmodified lines | ||
| 403 | 406 | if (!async_desc) |
| 404 | 407 | return ERR_PTR(-ENOMEM); |
| 405 | 408 | |
| 406 | − if (crci) | |
| 407 | − async_desc->mux = achan->slave.slave_id & ADM_CRCI_MUX_SEL ? | |
| 408 | − ADM_CRCI_CTL_MUX_SEL : 0; | |
| 409 | + async_desc->mux = achan->mux ? ADM_CRCI_CTL_MUX_SEL : 0; | |
| 409 | 410 | async_desc->crci = crci; |
| 410 | 411 | async_desc->blk_size = blk_size; |
| 411 | 412 | async_desc->dma_len = single_count * sizeof(struct adm_desc_hw_single) + |
| @@ -488,10 +489,13 @@ static int adm_terminate_all(struct dma_chan *chan) · 76 unmodified lines | ||
| 488 | 489 | static int adm_slave_config(struct dma_chan *chan, struct dma_slave_config *cfg) |
| 489 | 490 | { |
| 490 | 491 | struct adm_chan *achan = to_adm_chan(chan); |
| 492 | + struct qcom_adm_peripheral_config *config = cfg->peripheral_config; | |
| 491 | 493 | unsigned long flag; |
| 492 | 494 | |
| 493 | 495 | spin_lock_irqsave(&achan->vc.lock, flag); |
| 494 | 496 | memcpy(&achan->slave, cfg, sizeof(struct dma_slave_config)); |
| 497 | + if (cfg->peripheral_size == sizeof(config)) | |
| 498 | + achan->crci = config->crci; | |
| 495 | 499 | spin_unlock_irqrestore(&achan->vc.lock, flag); |
| 496 | 500 | |
| 497 | 501 | return 0; |
| @@ -694,6 +698,45 @@ static void adm_channel_init(struct adm_device *adev, struct adm_chan *achan, · 196 unmodified lines | ||
| 694 | 698 | achan->vc.desc_free = adm_dma_free_desc; |
| 695 | 699 | } |
| 696 | 700 | |
| 701 | +/** | |
| 702 | + * adm_dma_xlate | |
| 703 | + * @dma_spec: pointer to DMA specifier as found in the device tree | |
| 704 | + * @ofdma: pointer to DMA controller data | |
| 705 | + * | |
| 706 | + * This can use either 1-cell or 2-cell formats, the first cell | |
| 707 | + * identifies the slave device, while the optional second cell | |
| 708 | + * contains the crci value. | |
| 709 | + * | |
| 710 | + * Returns pointer to appropriate dma channel on success or NULL on error. | |
| 711 | + */ | |
| 712 | +static struct dma_chan *adm_dma_xlate(struct of_phandle_args *dma_spec, | |
| 713 | + struct of_dma *ofdma) | |
| 714 | +{ | |
| 715 | + struct dma_device *dev = ofdma->of_dma_data; | |
| 716 | + struct dma_chan *chan, *candidate = NULL; | |
| 717 | + struct adm_chan *achan; | |
| 718 | + | |
| 719 | + if (!dev || dma_spec->args_count > 2) | |
| 720 | + return NULL; | |
| 721 | + | |
| 722 | + list_for_each_entry(chan, &dev->channels, device_node) | |
| 723 | + if (chan->chan_id == dma_spec->args[0]) { | |
| 724 | + candidate = chan; | |
| 725 | + break; | |
| 726 | + } | |
| 727 | + | |
| 728 | + if (!candidate) | |
| 729 | + return NULL; | |
| 730 | + | |
| 731 | + achan = to_adm_chan(candidate); | |
| 732 | + if (dma_spec->args_count == 2) | |
| 733 | + achan->crci = dma_spec->args[1]; | |
| 734 | + else | |
| 735 | + achan->crci = 0; | |
| 736 | + | |
| 737 | + return dma_get_slave_channel(candidate); | |
| 738 | +} | |
| 739 | + | |
| 697 | 740 | static int adm_dma_probe(struct platform_device *pdev) |
| 698 | 741 | { |
| 699 | 742 | struct adm_device *adev; |
| @@ -838,8 +881,7 @@ static int adm_dma_probe(struct platform_device *pdev) · 138 unmodified lines | ||
| 838 | 881 | goto err_disable_clks; |
| 839 | 882 | } |
| 840 | 883 | |
| 841 | − ret = of_dma_controller_register(pdev->dev.of_node, | |
| 842 | − of_dma_xlate_by_chan_id, | |
| 884 | + ret = of_dma_controller_register(pdev->dev.of_node, adm_dma_xlate, | |
| 843 | 885 | &adev->common); |
| 844 | 886 | if (ret) |
| 845 | 887 | goto err_unregister_dma; |
| @@ -786,14 +786,6 @@ static int shdma_config(struct dma_chan *chan, · 785 unmodified lines | ||
| 786 | 786 | if (!config) |
| 787 | 787 | return -EINVAL; |
| 788 | 788 | |
| 789 | − /* | |
| 790 | − * overriding the slave_id through dma_slave_config is deprecated, | |
| 791 | − * but possibly some out-of-tree drivers still do it. | |
| 792 | − */ | |
| 793 | − if (WARN_ON_ONCE(config->slave_id && | |
| 794 | − config->slave_id != schan->real_slave_id)) | |
| 795 | − schan->real_slave_id = config->slave_id; | |
| 796 | − | |
| 797 | 789 | /* |
| 798 | 790 | * We could lock this, but you shouldn't be configuring the |
| 799 | 791 | * channel, while using it... |
| @@ -795,9 +795,6 @@ static int sprd_dma_fill_desc(struct dma_chan *chan, · 794 unmodified lines | ||
| 795 | 795 | return dst_datawidth; |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | − if (slave_cfg->slave_id) | |
| 799 | − schan->dev_id = slave_cfg->slave_id; | |
| 800 | − | |
| 801 | 798 | hw->cfg = SPRD_DMA_DONOT_WAIT_BDONE << SPRD_DMA_WAIT_BDONE_OFFSET; |
| 802 | 799 | |
| 803 | 800 | /* |
| @@ -343,12 +343,6 @@ static int tegra_dma_slave_config(struct dma_chan *dc, · 342 unmodified lines | ||
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | memcpy(&tdc->dma_sconfig, sconfig, sizeof(*sconfig)); |
| 346 | − if (tdc->slave_id == TEGRA_APBDMA_SLAVE_ID_INVALID && | |
| 347 | − sconfig->device_fc) { | |
| 348 | − if (sconfig->slave_id > TEGRA_APBDMA_CSR_REQ_SEL_MASK) | |
| 349 | − return -EINVAL; | |
| 350 | − tdc->slave_id = sconfig->slave_id; | |
| 351 | − } | |
| 352 | 346 | tdc->config_init = true; |
| 353 | 347 | |
| 354 | 348 | return 0; |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <linux/clk.h> |
| 13 | 13 | #include <linux/debugfs.h> |
| 14 | 14 | #include <linux/delay.h> |
| 15 | +#include <linux/dma/xilinx_dpdma.h> | |
| 15 | 16 | #include <linux/dmaengine.h> |
| 16 | 17 | #include <linux/dmapool.h> |
| 17 | 18 | #include <linux/interrupt.h> |
| @@ -1273,6 +1274,7 @@ static int xilinx_dpdma_config(struct dma_chan *dchan, · 1255 unmodified lines | ||
| 1273 | 1274 | struct dma_slave_config *config) |
| 1274 | 1275 | { |
| 1275 | 1276 | struct xilinx_dpdma_chan *chan = to_xilinx_chan(dchan); |
| 1277 | + struct xilinx_dpdma_peripheral_config *pconfig; | |
| 1276 | 1278 | unsigned long flags; |
| 1277 | 1279 | |
| 1278 | 1280 | /* |
| @@ -1282,15 +1284,18 @@ static int xilinx_dpdma_config(struct dma_chan *dchan, · 3 unmodified lines | ||
| 1282 | 1284 | * fixed both on the DPDMA side and on the DP controller side. |
| 1283 | 1285 | */ |
| 1284 | 1286 | |
| 1285 | − spin_lock_irqsave(&chan->lock, flags); | |
| 1286 | − | |
| 1287 | 1287 | /* |
| 1288 | − * Abuse the slave_id to indicate that the channel is part of a video | |
| 1289 | − * group. | |
| 1288 | + * Use the peripheral_config to indicate that the channel is part | |
| 1289 | + * of a video group. This requires matching use of the custom | |
| 1290 | + * structure in each driver. | |
| 1290 | 1291 | */ |
| 1291 | − if (chan->id <= ZYNQMP_DPDMA_VIDEO2) | |
| 1292 | − chan->video_group = config->slave_id != 0; | |
| 1292 | + pconfig = config->peripheral_config; | |
| 1293 | + if (WARN_ON(pconfig && config->peripheral_size != sizeof(*pconfig))) | |
| 1294 | + return -EINVAL; | |
| 1293 | 1295 | |
| 1296 | + spin_lock_irqsave(&chan->lock, flags); | |
| 1297 | + if (chan->id <= ZYNQMP_DPDMA_VIDEO2 && pconfig) | |
| 1298 | + chan->video_group = pconfig->video_group; | |
| 1294 | 1299 | spin_unlock_irqrestore(&chan->lock, flags); |
| 1295 | 1300 | |
| 1296 | 1301 | return 0; |
| @@ -12,16 +12,10 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <linux/ctype.h> |
| 13 | 13 | #include <linux/debugfs.h> |
| 14 | 14 | #include <linux/delay.h> |
| 15 | −#include <linux/device.h> | |
| 16 | −#include <linux/firmware.h> | |
| 17 | −#include <linux/interrupt.h> | |
| 18 | −#include <linux/list.h> | |
| 19 | 15 | #include <linux/module.h> |
| 20 | 16 | #include <linux/moduleparam.h> |
| 21 | −#include <linux/regmap.h> | |
| 22 | 17 | #include <linux/slab.h> |
| 23 | 18 | #include <linux/vmalloc.h> |
| 24 | −#include <linux/workqueue.h> | |
| 25 | 19 | |
| 26 | 20 | #include <linux/firmware/cirrus/cs_dsp.h> |
| 27 | 21 | #include <linux/firmware/cirrus/wmfw.h> |
| @@ -622,7 +616,8 @@ static void cs_dsp_halo_show_fw_status(struct cs_dsp *dsp) · 594 unmodified lines | ||
| 622 | 616 | offs[0], offs[1], offs[2], offs[3]); |
| 623 | 617 | } |
| 624 | 618 | |
| 625 | −static int cs_dsp_coeff_base_reg(struct cs_dsp_coeff_ctl *ctl, unsigned int *reg) | |
| 619 | +static int cs_dsp_coeff_base_reg(struct cs_dsp_coeff_ctl *ctl, unsigned int *reg, | |
| 620 | + unsigned int off) | |
| 626 | 621 | { |
| 627 | 622 | const struct cs_dsp_alg_region *alg_region = &ctl->alg_region; |
| 628 | 623 | struct cs_dsp *dsp = ctl->dsp; |
| @@ -635,7 +630,7 @@ static int cs_dsp_coeff_base_reg(struct cs_dsp_coeff_ctl *ctl, unsigned int *reg · 6 unmodified lines | ||
| 635 | 630 | return -EINVAL; |
| 636 | 631 | } |
| 637 | 632 | |
| 638 | − *reg = dsp->ops->region_to_reg(mem, ctl->alg_region.base + ctl->offset); | |
| 633 | + *reg = dsp->ops->region_to_reg(mem, ctl->alg_region.base + ctl->offset + off); | |
| 639 | 634 | |
| 640 | 635 | return 0; |
| 641 | 636 | } |
| @@ -659,10 +654,12 @@ int cs_dsp_coeff_write_acked_control(struct cs_dsp_coeff_ctl *ctl, unsigned int · 17 unmodified lines | ||
| 659 | 654 | unsigned int reg; |
| 660 | 655 | int i, ret; |
| 661 | 656 | |
| 657 | + lockdep_assert_held(&dsp->pwr_lock); | |
| 658 | + | |
| 662 | 659 | if (!dsp->running) |
| 663 | 660 | return -EPERM; |
| 664 | 661 | |
| 665 | − ret = cs_dsp_coeff_base_reg(ctl, ®); | |
| 662 | + ret = cs_dsp_coeff_base_reg(ctl, ®, 0); | |
| 666 | 663 | if (ret) |
| 667 | 664 | return ret; |
| 668 | 665 | |
| @@ -716,14 +713,14 @@ int cs_dsp_coeff_write_acked_control(struct cs_dsp_coeff_ctl *ctl, unsigned int · 47 unmodified lines | ||
| 716 | 713 | EXPORT_SYMBOL_GPL(cs_dsp_coeff_write_acked_control); |
| 717 | 714 | |
| 718 | 715 | static int cs_dsp_coeff_write_ctrl_raw(struct cs_dsp_coeff_ctl *ctl, |
| 719 | − const void *buf, size_t len) | |
| 716 | + unsigned int off, const void *buf, size_t len) | |
| 720 | 717 | { |
| 721 | 718 | struct cs_dsp *dsp = ctl->dsp; |
| 722 | 719 | void *scratch; |
| 723 | 720 | int ret; |
| 724 | 721 | unsigned int reg; |
| 725 | 722 | |
| 726 | − ret = cs_dsp_coeff_base_reg(ctl, ®); | |
| 723 | + ret = cs_dsp_coeff_base_reg(ctl, ®, off); | |
| 727 | 724 | if (ret) |
| 728 | 725 | return ret; |
| 729 | 726 | |
| @@ -749,38 +746,49 @@ static int cs_dsp_coeff_write_ctrl_raw(struct cs_dsp_coeff_ctl *ctl, · 19 unmodified lines | ||
| 749 | 746 | /** |
| 750 | 747 | * cs_dsp_coeff_write_ctrl() - Writes the given buffer to the given coefficient control |
| 751 | 748 | * @ctl: pointer to coefficient control |
| 749 | + * @off: word offset at which data should be written | |
| 752 | 750 | * @buf: the buffer to write to the given control |
| 753 | − * @len: the length of the buffer | |
| 751 | + * @len: the length of the buffer in bytes | |
| 754 | 752 | * |
| 755 | 753 | * Must be called with pwr_lock held. |
| 756 | 754 | * |
| 757 | 755 | * Return: Zero for success, a negative number on error. |
| 758 | 756 | */ |
| 759 | −int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl, const void *buf, size_t len) | |
| 757 | +int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl, | |
| 758 | + unsigned int off, const void *buf, size_t len) | |
| 760 | 759 | { |
| 761 | 760 | int ret = 0; |
| 762 | 761 | |
| 762 | + if (!ctl) | |
| 763 | + return -ENOENT; | |
| 764 | + | |
| 765 | + lockdep_assert_held(&ctl->dsp->pwr_lock); | |
| 766 | + | |
| 767 | + if (len + off * sizeof(u32) > ctl->len) | |
| 768 | + return -EINVAL; | |
| 769 | + | |
| 763 | 770 | if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) |
| 764 | 771 | ret = -EPERM; |
| 765 | 772 | else if (buf != ctl->cache) |
| 766 | − memcpy(ctl->cache, buf, len); | |
| 773 | + memcpy(ctl->cache + off * sizeof(u32), buf, len); | |
| 767 | 774 | |
| 768 | 775 | ctl->set = 1; |
| 769 | 776 | if (ctl->enabled && ctl->dsp->running) |
| 770 | − ret = cs_dsp_coeff_write_ctrl_raw(ctl, buf, len); | |
| 777 | + ret = cs_dsp_coeff_write_ctrl_raw(ctl, off, buf, len); | |
| 771 | 778 | |
| 772 | 779 | return ret; |
| 773 | 780 | } |
| 774 | 781 | EXPORT_SYMBOL_GPL(cs_dsp_coeff_write_ctrl); |
| 775 | 782 | |
| 776 | −static int cs_dsp_coeff_read_ctrl_raw(struct cs_dsp_coeff_ctl *ctl, void *buf, size_t len) | |
| 783 | +static int cs_dsp_coeff_read_ctrl_raw(struct cs_dsp_coeff_ctl *ctl, | |
| 784 | + unsigned int off, void *buf, size_t len) | |
| 777 | 785 | { |
| 778 | 786 | struct cs_dsp *dsp = ctl->dsp; |
| 779 | 787 | void *scratch; |
| 780 | 788 | int ret; |
| 781 | 789 | unsigned int reg; |
| 782 | 790 | |
| 783 | − ret = cs_dsp_coeff_base_reg(ctl, ®); | |
| 791 | + ret = cs_dsp_coeff_base_reg(ctl, ®, off); | |
| 784 | 792 | if (ret) |
| 785 | 793 | return ret; |
| 786 | 794 | |
| @@ -806,28 +814,38 @@ static int cs_dsp_coeff_read_ctrl_raw(struct cs_dsp_coeff_ctl *ctl, void *buf, s · 19 unmodified lines | ||
| 806 | 814 | /** |
| 807 | 815 | * cs_dsp_coeff_read_ctrl() - Reads the given coefficient control into the given buffer |
| 808 | 816 | * @ctl: pointer to coefficient control |
| 817 | + * @off: word offset at which data should be read | |
| 809 | 818 | * @buf: the buffer to store to the given control |
| 810 | − * @len: the length of the buffer | |
| 819 | + * @len: the length of the buffer in bytes | |
| 811 | 820 | * |
| 812 | 821 | * Must be called with pwr_lock held. |
| 813 | 822 | * |
| 814 | 823 | * Return: Zero for success, a negative number on error. |
| 815 | 824 | */ |
| 816 | −int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl, void *buf, size_t len) | |
| 825 | +int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl, | |
| 826 | + unsigned int off, void *buf, size_t len) | |
| 817 | 827 | { |
| 818 | 828 | int ret = 0; |
| 819 | 829 | |
| 830 | + if (!ctl) | |
| 831 | + return -ENOENT; | |
| 832 | + | |
| 833 | + lockdep_assert_held(&ctl->dsp->pwr_lock); | |
| 834 | + | |
| 835 | + if (len + off * sizeof(u32) > ctl->len) | |
| 836 | + return -EINVAL; | |
| 837 | + | |
| 820 | 838 | if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { |
| 821 | 839 | if (ctl->enabled && ctl->dsp->running) |
| 822 | − return cs_dsp_coeff_read_ctrl_raw(ctl, buf, len); | |
| 840 | + return cs_dsp_coeff_read_ctrl_raw(ctl, off, buf, len); | |
| 823 | 841 | else |
| 824 | 842 | return -EPERM; |
| 825 | 843 | } else { |
| 826 | 844 | if (!ctl->flags && ctl->enabled && ctl->dsp->running) |
| 827 | − ret = cs_dsp_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len); | |
| 845 | + ret = cs_dsp_coeff_read_ctrl_raw(ctl, 0, ctl->cache, ctl->len); | |
| 828 | 846 | |
| 829 | 847 | if (buf != ctl->cache) |
| 830 | − memcpy(buf, ctl->cache, len); | |
| 848 | + memcpy(buf, ctl->cache + off * sizeof(u32), len); | |
| 831 | 849 | } |
| 832 | 850 | |
| 833 | 851 | return ret; |
| @@ -851,7 +869,7 @@ static int cs_dsp_coeff_init_control_caches(struct cs_dsp *dsp) · 17 unmodified lines | ||
| 851 | 869 | * created so we don't need to do anything. |
| 852 | 870 | */ |
| 853 | 871 | if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) { |
| 854 | − ret = cs_dsp_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len); | |
| 872 | + ret = cs_dsp_coeff_read_ctrl_raw(ctl, 0, ctl->cache, ctl->len); | |
| 855 | 873 | if (ret < 0) |
| 856 | 874 | return ret; |
| 857 | 875 | } |
| @@ -869,7 +887,7 @@ static int cs_dsp_coeff_sync_controls(struct cs_dsp *dsp) · 11 unmodified lines | ||
| 869 | 887 | if (!ctl->enabled) |
| 870 | 888 | continue; |
| 871 | 889 | if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) { |
| 872 | − ret = cs_dsp_coeff_write_ctrl_raw(ctl, ctl->cache, | |
| 890 | + ret = cs_dsp_coeff_write_ctrl_raw(ctl, 0, ctl->cache, | |
| 873 | 891 | ctl->len); |
| 874 | 892 | if (ret < 0) |
| 875 | 893 | return ret; |
| @@ -1159,6 +1177,7 @@ static int cs_dsp_parse_coeff(struct cs_dsp *dsp, · 283 unmodified lines | ||
| 1159 | 1177 | return -EINVAL; |
| 1160 | 1178 | break; |
| 1161 | 1179 | case WMFW_CTL_TYPE_HOSTEVENT: |
| 1180 | + case WMFW_CTL_TYPE_FWEVENT: | |
| 1162 | 1181 | ret = cs_dsp_check_coeff_flags(dsp, &coeff_blk, |
| 1163 | 1182 | WMFW_CTL_FLAG_SYS | |
| 1164 | 1183 | WMFW_CTL_FLAG_VOLATILE | |
| @@ -1459,6 +1478,8 @@ struct cs_dsp_coeff_ctl *cs_dsp_get_ctl(struct cs_dsp *dsp, const char *name, in · 294 unmodified lines | ||
| 1459 | 1478 | { |
| 1460 | 1479 | struct cs_dsp_coeff_ctl *pos, *rslt = NULL; |
| 1461 | 1480 | |
| 1481 | + lockdep_assert_held(&dsp->pwr_lock); | |
| 1482 | + | |
| 1462 | 1483 | list_for_each_entry(pos, &dsp->ctl_list, list) { |
| 1463 | 1484 | if (!pos->subname) |
| 1464 | 1485 | continue; |
| @@ -1554,6 +1575,8 @@ struct cs_dsp_alg_region *cs_dsp_find_alg_region(struct cs_dsp *dsp, · 89 unmodified lines | ||
| 1554 | 1575 | { |
| 1555 | 1576 | struct cs_dsp_alg_region *alg_region; |
| 1556 | 1577 | |
| 1578 | + lockdep_assert_held(&dsp->pwr_lock); | |
| 1579 | + | |
| 1557 | 1580 | list_for_each_entry(alg_region, &dsp->alg_regions, list) { |
| 1558 | 1581 | if (id == alg_region->alg && type == alg_region->type) |
| 1559 | 1582 | return alg_region; |
| @@ -1565,7 +1588,7 @@ EXPORT_SYMBOL_GPL(cs_dsp_find_alg_region); · 5 unmodified lines | ||
| 1565 | 1588 | |
| 1566 | 1589 | static struct cs_dsp_alg_region *cs_dsp_create_region(struct cs_dsp *dsp, |
| 1567 | 1590 | int type, __be32 id, |
| 1568 | − __be32 base) | |
| 1591 | + __be32 ver, __be32 base) | |
| 1569 | 1592 | { |
| 1570 | 1593 | struct cs_dsp_alg_region *alg_region; |
| 1571 | 1594 | |
| @@ -1575,6 +1598,7 @@ static struct cs_dsp_alg_region *cs_dsp_create_region(struct cs_dsp *dsp, · 3 unmodified lines | ||
| 1575 | 1598 | |
| 1576 | 1599 | alg_region->type = type; |
| 1577 | 1600 | alg_region->alg = be32_to_cpu(id); |
| 1601 | + alg_region->ver = be32_to_cpu(ver); | |
| 1578 | 1602 | alg_region->base = be32_to_cpu(base); |
| 1579 | 1603 | |
| 1580 | 1604 | list_add_tail(&alg_region->list, &dsp->alg_regions); |
| @@ -1624,14 +1648,14 @@ static void cs_dsp_parse_wmfw_v3_id_header(struct cs_dsp *dsp, · 43 unmodified lines | ||
| 1624 | 1648 | nalgs); |
| 1625 | 1649 | } |
| 1626 | 1650 | |
| 1627 | −static int cs_dsp_create_regions(struct cs_dsp *dsp, __be32 id, int nregions, | |
| 1628 | − const int *type, __be32 *base) | |
| 1651 | +static int cs_dsp_create_regions(struct cs_dsp *dsp, __be32 id, __be32 ver, | |
| 1652 | + int nregions, const int *type, __be32 *base) | |
| 1629 | 1653 | { |
| 1630 | 1654 | struct cs_dsp_alg_region *alg_region; |
| 1631 | 1655 | int i; |
| 1632 | 1656 | |
| 1633 | 1657 | for (i = 0; i < nregions; i++) { |
| 1634 | − alg_region = cs_dsp_create_region(dsp, type[i], id, base[i]); | |
| 1658 | + alg_region = cs_dsp_create_region(dsp, type[i], id, ver, base[i]); | |
| 1635 | 1659 | if (IS_ERR(alg_region)) |
| 1636 | 1660 | return PTR_ERR(alg_region); |
| 1637 | 1661 | } |
| @@ -1666,12 +1690,14 @@ static int cs_dsp_adsp1_setup_algs(struct cs_dsp *dsp) · 28 unmodified lines | ||
| 1666 | 1690 | cs_dsp_parse_wmfw_id_header(dsp, &adsp1_id.fw, n_algs); |
| 1667 | 1691 | |
| 1668 | 1692 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP1_ZM, |
| 1669 | − adsp1_id.fw.id, adsp1_id.zm); | |
| 1693 | + adsp1_id.fw.id, adsp1_id.fw.ver, | |
| 1694 | + adsp1_id.zm); | |
| 1670 | 1695 | if (IS_ERR(alg_region)) |
| 1671 | 1696 | return PTR_ERR(alg_region); |
| 1672 | 1697 | |
| 1673 | 1698 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP1_DM, |
| 1674 | − adsp1_id.fw.id, adsp1_id.dm); | |
| 1699 | + adsp1_id.fw.id, adsp1_id.fw.ver, | |
| 1700 | + adsp1_id.dm); | |
| 1675 | 1701 | if (IS_ERR(alg_region)) |
| 1676 | 1702 | return PTR_ERR(alg_region); |
| 1677 | 1703 | |
| @@ -1694,6 +1720,7 @@ static int cs_dsp_adsp1_setup_algs(struct cs_dsp *dsp) · 16 unmodified lines | ||
| 1694 | 1720 | |
| 1695 | 1721 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP1_DM, |
| 1696 | 1722 | adsp1_alg[i].alg.id, |
| 1723 | + adsp1_alg[i].alg.ver, | |
| 1697 | 1724 | adsp1_alg[i].dm); |
| 1698 | 1725 | if (IS_ERR(alg_region)) { |
| 1699 | 1726 | ret = PTR_ERR(alg_region); |
| @@ -1715,6 +1742,7 @@ static int cs_dsp_adsp1_setup_algs(struct cs_dsp *dsp) · 15 unmodified lines | ||
| 1715 | 1742 | |
| 1716 | 1743 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP1_ZM, |
| 1717 | 1744 | adsp1_alg[i].alg.id, |
| 1745 | + adsp1_alg[i].alg.ver, | |
| 1718 | 1746 | adsp1_alg[i].zm); |
| 1719 | 1747 | if (IS_ERR(alg_region)) { |
| 1720 | 1748 | ret = PTR_ERR(alg_region); |
| @@ -1767,17 +1795,20 @@ static int cs_dsp_adsp2_setup_algs(struct cs_dsp *dsp) · 46 unmodified lines | ||
| 1767 | 1795 | cs_dsp_parse_wmfw_id_header(dsp, &adsp2_id.fw, n_algs); |
| 1768 | 1796 | |
| 1769 | 1797 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP2_XM, |
| 1770 | − adsp2_id.fw.id, adsp2_id.xm); | |
| 1798 | + adsp2_id.fw.id, adsp2_id.fw.ver, | |
| 1799 | + adsp2_id.xm); | |
| 1771 | 1800 | if (IS_ERR(alg_region)) |
| 1772 | 1801 | return PTR_ERR(alg_region); |
| 1773 | 1802 | |
| 1774 | 1803 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP2_YM, |
| 1775 | − adsp2_id.fw.id, adsp2_id.ym); | |
| 1804 | + adsp2_id.fw.id, adsp2_id.fw.ver, | |
| 1805 | + adsp2_id.ym); | |
| 1776 | 1806 | if (IS_ERR(alg_region)) |
| 1777 | 1807 | return PTR_ERR(alg_region); |
| 1778 | 1808 | |
| 1779 | 1809 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP2_ZM, |
| 1780 | − adsp2_id.fw.id, adsp2_id.zm); | |
| 1810 | + adsp2_id.fw.id, adsp2_id.fw.ver, | |
| 1811 | + adsp2_id.zm); | |
| 1781 | 1812 | if (IS_ERR(alg_region)) |
| 1782 | 1813 | return PTR_ERR(alg_region); |
| 1783 | 1814 | |
| @@ -1802,6 +1833,7 @@ static int cs_dsp_adsp2_setup_algs(struct cs_dsp *dsp) · 18 unmodified lines | ||
| 1802 | 1833 | |
| 1803 | 1834 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP2_XM, |
| 1804 | 1835 | adsp2_alg[i].alg.id, |
| 1836 | + adsp2_alg[i].alg.ver, | |
| 1805 | 1837 | adsp2_alg[i].xm); |
| 1806 | 1838 | if (IS_ERR(alg_region)) { |
| 1807 | 1839 | ret = PTR_ERR(alg_region); |
| @@ -1823,6 +1855,7 @@ static int cs_dsp_adsp2_setup_algs(struct cs_dsp *dsp) · 15 unmodified lines | ||
| 1823 | 1855 | |
| 1824 | 1856 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP2_YM, |
| 1825 | 1857 | adsp2_alg[i].alg.id, |
| 1858 | + adsp2_alg[i].alg.ver, | |
| 1826 | 1859 | adsp2_alg[i].ym); |
| 1827 | 1860 | if (IS_ERR(alg_region)) { |
| 1828 | 1861 | ret = PTR_ERR(alg_region); |
| @@ -1844,6 +1877,7 @@ static int cs_dsp_adsp2_setup_algs(struct cs_dsp *dsp) · 15 unmodified lines | ||
| 1844 | 1877 | |
| 1845 | 1878 | alg_region = cs_dsp_create_region(dsp, WMFW_ADSP2_ZM, |
| 1846 | 1879 | adsp2_alg[i].alg.id, |
| 1880 | + adsp2_alg[i].alg.ver, | |
| 1847 | 1881 | adsp2_alg[i].zm); |
| 1848 | 1882 | if (IS_ERR(alg_region)) { |
| 1849 | 1883 | ret = PTR_ERR(alg_region); |
| @@ -1869,7 +1903,7 @@ out: · 19 unmodified lines | ||
| 1869 | 1903 | return ret; |
| 1870 | 1904 | } |
| 1871 | 1905 | |
| 1872 | −static int cs_dsp_halo_create_regions(struct cs_dsp *dsp, __be32 id, | |
| 1906 | +static int cs_dsp_halo_create_regions(struct cs_dsp *dsp, __be32 id, __be32 ver, | |
| 1873 | 1907 | __be32 xm_base, __be32 ym_base) |
| 1874 | 1908 | { |
| 1875 | 1909 | static const int types[] = { |
| @@ -1878,7 +1912,7 @@ static int cs_dsp_halo_create_regions(struct cs_dsp *dsp, __be32 id, · 2 unmodified lines | ||
| 1878 | 1912 | }; |
| 1879 | 1913 | __be32 bases[] = { xm_base, xm_base, ym_base, ym_base }; |
| 1880 | 1914 | |
| 1881 | − return cs_dsp_create_regions(dsp, id, ARRAY_SIZE(types), types, bases); | |
| 1915 | + return cs_dsp_create_regions(dsp, id, ver, ARRAY_SIZE(types), types, bases); | |
| 1882 | 1916 | } |
| 1883 | 1917 | |
| 1884 | 1918 | static int cs_dsp_halo_setup_algs(struct cs_dsp *dsp) |
| @@ -1906,7 +1940,7 @@ static int cs_dsp_halo_setup_algs(struct cs_dsp *dsp) · 21 unmodified lines | ||
| 1906 | 1940 | |
| 1907 | 1941 | cs_dsp_parse_wmfw_v3_id_header(dsp, &halo_id.fw, n_algs); |
| 1908 | 1942 | |
| 1909 | − ret = cs_dsp_halo_create_regions(dsp, halo_id.fw.id, | |
| 1943 | + ret = cs_dsp_halo_create_regions(dsp, halo_id.fw.id, halo_id.fw.ver, | |
| 1910 | 1944 | halo_id.xm_base, halo_id.ym_base); |
| 1911 | 1945 | if (ret) |
| 1912 | 1946 | return ret; |
| @@ -1930,6 +1964,7 @@ static int cs_dsp_halo_setup_algs(struct cs_dsp *dsp) · 17 unmodified lines | ||
| 1930 | 1964 | be32_to_cpu(halo_alg[i].ym_base)); |
| 1931 | 1965 | |
| 1932 | 1966 | ret = cs_dsp_halo_create_regions(dsp, halo_alg[i].alg.id, |
| 1967 | + halo_alg[i].alg.ver, | |
| 1933 | 1968 | halo_alg[i].xm_base, |
| 1934 | 1969 | halo_alg[i].ym_base); |
| 1935 | 1970 | if (ret) |
| @@ -1951,7 +1986,8 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware · 15 unmodified lines | ||
| 1951 | 1986 | const struct cs_dsp_region *mem; |
| 1952 | 1987 | struct cs_dsp_alg_region *alg_region; |
| 1953 | 1988 | const char *region_name; |
| 1954 | − int ret, pos, blocks, type, offset, reg; | |
| 1989 | + int ret, pos, blocks, type, offset, reg, version; | |
| 1990 | + char *text = NULL; | |
| 1955 | 1991 | struct cs_dsp_buf *buf; |
| 1956 | 1992 | |
| 1957 | 1993 | if (!firmware) |
| @@ -1973,6 +2009,7 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware · 15 unmodified lines | ||
| 1973 | 2009 | |
| 1974 | 2010 | switch (be32_to_cpu(hdr->rev) & 0xff) { |
| 1975 | 2011 | case 1: |
| 2012 | + case 2: | |
| 1976 | 2013 | break; |
| 1977 | 2014 | default: |
| 1978 | 2015 | cs_dsp_err(dsp, "%s: Unsupported coefficient file format %d\n", |
| @@ -1995,6 +2032,7 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware · 16 unmodified lines | ||
| 1995 | 2032 | |
| 1996 | 2033 | type = le16_to_cpu(blk->type); |
| 1997 | 2034 | offset = le16_to_cpu(blk->offset); |
| 2035 | + version = le32_to_cpu(blk->ver) >> 8; | |
| 1998 | 2036 | |
| 1999 | 2037 | cs_dsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", |
| 2000 | 2038 | file, blocks, le32_to_cpu(blk->id), |
| @@ -2008,6 +2046,8 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware · 7 unmodified lines | ||
| 2008 | 2046 | region_name = "Unknown"; |
| 2009 | 2047 | switch (type) { |
| 2010 | 2048 | case (WMFW_NAME_TEXT << 8): |
| 2049 | + text = kzalloc(le32_to_cpu(blk->len) + 1, GFP_KERNEL); | |
| 2050 | + break; | |
| 2011 | 2051 | case (WMFW_INFO_TEXT << 8): |
| 2012 | 2052 | case (WMFW_METADATA << 8): |
| 2013 | 2053 | break; |
| @@ -2052,6 +2092,16 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware · 38 unmodified lines | ||
| 2052 | 2092 | alg_region = cs_dsp_find_alg_region(dsp, type, |
| 2053 | 2093 | le32_to_cpu(blk->id)); |
| 2054 | 2094 | if (alg_region) { |
| 2095 | + if (version != alg_region->ver) | |
| 2096 | + cs_dsp_warn(dsp, | |
| 2097 | + "Algorithm coefficient version %d.%d.%d but expected %d.%d.%d\n", | |
| 2098 | + (version >> 16) & 0xFF, | |
| 2099 | + (version >> 8) & 0xFF, | |
| 2100 | + version & 0xFF, | |
| 2101 | + (alg_region->ver >> 16) & 0xFF, | |
| 2102 | + (alg_region->ver >> 8) & 0xFF, | |
| 2103 | + alg_region->ver & 0xFF); | |
| 2104 | + | |
| 2055 | 2105 | reg = alg_region->base; |
| 2056 | 2106 | reg = dsp->ops->region_to_reg(mem, reg); |
| 2057 | 2107 | reg += offset; |
| @@ -2067,6 +2117,13 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware · 9 unmodified lines | ||
| 2067 | 2117 | break; |
| 2068 | 2118 | } |
| 2069 | 2119 | |
| 2120 | + if (text) { | |
| 2121 | + memcpy(text, blk->data, le32_to_cpu(blk->len)); | |
| 2122 | + cs_dsp_info(dsp, "%s: %s\n", dsp->fw_name, text); | |
| 2123 | + kfree(text); | |
| 2124 | + text = NULL; | |
| 2125 | + } | |
| 2126 | + | |
| 2070 | 2127 | if (reg) { |
| 2071 | 2128 | if (le32_to_cpu(blk->len) > |
| 2072 | 2129 | firmware->size - pos - sizeof(*blk)) { |
| @@ -2117,6 +2174,7 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware · 44 unmodified lines | ||
| 2117 | 2174 | out_fw: |
| 2118 | 2175 | regmap_async_complete(regmap); |
| 2119 | 2176 | cs_dsp_buf_free(&buf_list); |
| 2177 | + kfree(text); | |
| 2120 | 2178 | return ret; |
| 2121 | 2179 | } |
| 2122 | 2180 | |
| @@ -2600,6 +2658,12 @@ int cs_dsp_run(struct cs_dsp *dsp) · 477 unmodified lines | ||
| 2600 | 2658 | goto err; |
| 2601 | 2659 | } |
| 2602 | 2660 | |
| 2661 | + if (dsp->client_ops->pre_run) { | |
| 2662 | + ret = dsp->client_ops->pre_run(dsp); | |
| 2663 | + if (ret) | |
| 2664 | + goto err; | |
| 2665 | + } | |
| 2666 | + | |
| 2603 | 2667 | /* Sync set controls */ |
| 2604 | 2668 | ret = cs_dsp_coeff_sync_controls(dsp); |
| 2605 | 2669 | if (ret != 0) |
| @@ -2680,10 +2744,16 @@ EXPORT_SYMBOL_GPL(cs_dsp_stop); · 74 unmodified lines | ||
| 2680 | 2744 | |
| 2681 | 2745 | static int cs_dsp_halo_start_core(struct cs_dsp *dsp) |
| 2682 | 2746 | { |
| 2683 | − return regmap_update_bits(dsp->regmap, | |
| 2684 | − dsp->base + HALO_CCM_CORE_CONTROL, | |
| 2685 | − HALO_CORE_RESET | HALO_CORE_EN, | |
| 2686 | − HALO_CORE_RESET | HALO_CORE_EN); | |
| 2747 | + int ret; | |
| 2748 | + | |
| 2749 | + ret = regmap_update_bits(dsp->regmap, dsp->base + HALO_CCM_CORE_CONTROL, | |
| 2750 | + HALO_CORE_RESET | HALO_CORE_EN, | |
| 2751 | + HALO_CORE_RESET | HALO_CORE_EN); | |
| 2752 | + if (ret) | |
| 2753 | + return ret; | |
| 2754 | + | |
| 2755 | + return regmap_update_bits(dsp->regmap, dsp->base + HALO_CCM_CORE_CONTROL, | |
| 2756 | + HALO_CORE_RESET, 0); | |
| 2687 | 2757 | } |
| 2688 | 2758 | |
| 2689 | 2759 | static void cs_dsp_halo_stop_core(struct cs_dsp *dsp) |
| @@ -2789,6 +2859,8 @@ int cs_dsp_read_raw_data_block(struct cs_dsp *dsp, int mem_type, unsigned int me · 99 unmodified lines | ||
| 2789 | 2859 | unsigned int reg; |
| 2790 | 2860 | int ret; |
| 2791 | 2861 | |
| 2862 | + lockdep_assert_held(&dsp->pwr_lock); | |
| 2863 | + | |
| 2792 | 2864 | if (!mem) |
| 2793 | 2865 | return -EINVAL; |
| 2794 | 2866 | |
| @@ -2842,6 +2914,8 @@ int cs_dsp_write_data_word(struct cs_dsp *dsp, int mem_type, unsigned int mem_ad · 47 unmodified lines | ||
| 2842 | 2914 | __be32 val = cpu_to_be32(data & 0x00ffffffu); |
| 2843 | 2915 | unsigned int reg; |
| 2844 | 2916 | |
| 2917 | + lockdep_assert_held(&dsp->pwr_lock); | |
| 2918 | + | |
| 2845 | 2919 | if (!mem) |
| 2846 | 2920 | return -EINVAL; |
| 2847 | 2921 | |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | #include <linux/clk.h> |
| 26 | 26 | #include <linux/delay.h> |
| 27 | +#include <linux/dma/xilinx_dpdma.h> | |
| 27 | 28 | #include <linux/dma-mapping.h> |
| 28 | 29 | #include <linux/dmaengine.h> |
| 29 | 30 | #include <linux/module.h> |
| @@ -1058,14 +1059,18 @@ static void zynqmp_disp_layer_set_format(struct zynqmp_disp_layer *layer, · 1028 unmodified lines | ||
| 1058 | 1059 | zynqmp_disp_avbuf_set_format(layer->disp, layer, layer->disp_fmt); |
| 1059 | 1060 | |
| 1060 | 1061 | /* |
| 1061 | − * Set slave_id for each DMA channel to indicate they're part of a | |
| 1062 | + * Set pconfig for each DMA channel to indicate they're part of a | |
| 1062 | 1063 | * video group. |
| 1063 | 1064 | */ |
| 1064 | 1065 | for (i = 0; i < info->num_planes; i++) { |
| 1065 | 1066 | struct zynqmp_disp_layer_dma *dma = &layer->dmas[i]; |
| 1067 | + struct xilinx_dpdma_peripheral_config pconfig = { | |
| 1068 | + .video_group = true, | |
| 1069 | + }; | |
| 1066 | 1070 | struct dma_slave_config config = { |
| 1067 | 1071 | .direction = DMA_MEM_TO_DEV, |
| 1068 | − .slave_id = 1, | |
| 1072 | + .peripheral_config = &pconfig, | |
| 1073 | + .peripheral_size = sizeof(pconfig), | |
| 1069 | 1074 | }; |
| 1070 | 1075 | |
| 1071 | 1076 | dmaengine_slave_config(dma->chan, &config); |
| @@ -1293,14 +1293,12 @@ static int bcm2835_add_host(struct bcm2835_host *host) · 1292 unmodified lines | ||
| 1293 | 1293 | |
| 1294 | 1294 | host->dma_cfg_tx.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 1295 | 1295 | host->dma_cfg_tx.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 1296 | − host->dma_cfg_tx.slave_id = 13; /* DREQ channel */ | |
| 1297 | 1296 | host->dma_cfg_tx.direction = DMA_MEM_TO_DEV; |
| 1298 | 1297 | host->dma_cfg_tx.src_addr = 0; |
| 1299 | 1298 | host->dma_cfg_tx.dst_addr = host->phys_addr + SDDATA; |
| 1300 | 1299 | |
| 1301 | 1300 | host->dma_cfg_rx.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 1302 | 1301 | host->dma_cfg_rx.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 1303 | − host->dma_cfg_rx.slave_id = 13; /* DREQ channel */ | |
| 1304 | 1302 | host->dma_cfg_rx.direction = DMA_DEV_TO_MEM; |
| 1305 | 1303 | host->dma_cfg_rx.src_addr = host->phys_addr + SDDATA; |
| 1306 | 1304 | host->dma_cfg_rx.dst_addr = 0; |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | #include <linux/clk.h> |
| 7 | 7 | #include <linux/slab.h> |
| 8 | 8 | #include <linux/bitops.h> |
| 9 | +#include <linux/dma/qcom_adm.h> | |
| 9 | 10 | #include <linux/dma-mapping.h> |
| 10 | 11 | #include <linux/dmaengine.h> |
| 11 | 12 | #include <linux/module.h> |
| @@ -952,6 +953,7 @@ static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, · 940 unmodified lines | ||
| 952 | 953 | struct dma_async_tx_descriptor *dma_desc; |
| 953 | 954 | struct scatterlist *sgl; |
| 954 | 955 | struct dma_slave_config slave_conf; |
| 956 | + struct qcom_adm_peripheral_config periph_conf = {}; | |
| 955 | 957 | enum dma_transfer_direction dir_eng; |
| 956 | 958 | int ret; |
| 957 | 959 | |
| @@ -983,11 +985,19 @@ static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, · 25 unmodified lines | ||
| 983 | 985 | if (read) { |
| 984 | 986 | slave_conf.src_maxburst = 16; |
| 985 | 987 | slave_conf.src_addr = nandc->base_dma + reg_off; |
| 986 | − slave_conf.slave_id = nandc->data_crci; | |
| 988 | + if (nandc->data_crci) { | |
| 989 | + periph_conf.crci = nandc->data_crci; | |
| 990 | + slave_conf.peripheral_config = &periph_conf; | |
| 991 | + slave_conf.peripheral_size = sizeof(periph_conf); | |
| 992 | + } | |
| 987 | 993 | } else { |
| 988 | 994 | slave_conf.dst_maxburst = 16; |
| 989 | 995 | slave_conf.dst_addr = nandc->base_dma + reg_off; |
| 990 | − slave_conf.slave_id = nandc->cmd_crci; | |
| 996 | + if (nandc->cmd_crci) { | |
| 997 | + periph_conf.crci = nandc->cmd_crci; | |
| 998 | + slave_conf.peripheral_config = &periph_conf; | |
| 999 | + slave_conf.peripheral_size = sizeof(periph_conf); | |
| 1000 | + } | |
| 991 | 1001 | } |
| 992 | 1002 | |
| 993 | 1003 | ret = dmaengine_slave_config(nandc->chan, &slave_conf); |
| @@ -411,12 +411,17 @@ out: · 410 unmodified lines | ||
| 411 | 411 | return ret; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | −static void init_clks(struct platform_device *pdev, struct clk **clk) | |
| 414 | +static int init_clks(struct platform_device *pdev, struct clk **clk) | |
| 415 | 415 | { |
| 416 | 416 | int i; |
| 417 | 417 | |
| 418 | − for (i = CLK_NONE + 1; i < CLK_MAX; i++) | |
| 418 | + for (i = CLK_NONE + 1; i < CLK_MAX; i++) { | |
| 419 | 419 | clk[i] = devm_clk_get(&pdev->dev, clk_names[i]); |
| 420 | + if (IS_ERR(clk[i])) | |
| 421 | + return PTR_ERR(clk[i]); | |
| 422 | + } | |
| 423 | + | |
| 424 | + return 0; | |
| 420 | 425 | } |
| 421 | 426 | |
| 422 | 427 | static struct scp *init_scp(struct platform_device *pdev, |
| @@ -426,7 +431,7 @@ static struct scp *init_scp(struct platform_device *pdev, · 3 unmodified lines | ||
| 426 | 431 | { |
| 427 | 432 | struct genpd_onecell_data *pd_data; |
| 428 | 433 | struct resource *res; |
| 429 | − int i, j; | |
| 434 | + int i, j, ret; | |
| 430 | 435 | struct scp *scp; |
| 431 | 436 | struct clk *clk[CLK_MAX]; |
| 432 | 437 | |
| @@ -481,7 +486,9 @@ static struct scp *init_scp(struct platform_device *pdev, · 48 unmodified lines | ||
| 481 | 486 | |
| 482 | 487 | pd_data->num_domains = num; |
| 483 | 488 | |
| 484 | − init_clks(pdev, clk); | |
| 489 | + ret = init_clks(pdev, clk); | |
| 490 | + if (ret) | |
| 491 | + return ERR_PTR(ret); | |
| 485 | 492 | |
| 486 | 493 | for (i = 0; i < num; i++) { |
| 487 | 494 | struct scp_domain *scpd = &scp->domains[i]; |
| @@ -1178,9 +1178,6 @@ int sdw_cdns_pdi_init(struct sdw_cdns *cdns, · 1177 unmodified lines | ||
| 1178 | 1178 | cdns->pcm.num_bd = config.pcm_bd; |
| 1179 | 1179 | cdns->pcm.num_in = config.pcm_in; |
| 1180 | 1180 | cdns->pcm.num_out = config.pcm_out; |
| 1181 | − cdns->pdm.num_bd = config.pdm_bd; | |
| 1182 | − cdns->pdm.num_in = config.pdm_in; | |
| 1183 | − cdns->pdm.num_out = config.pdm_out; | |
| 1184 | 1181 | |
| 1185 | 1182 | /* Allocate PDIs for PCMs */ |
| 1186 | 1183 | stream = &cdns->pcm; |
| @@ -1211,32 +1208,6 @@ int sdw_cdns_pdi_init(struct sdw_cdns *cdns, · 24 unmodified lines | ||
| 1211 | 1208 | stream->num_pdi = stream->num_bd + stream->num_in + stream->num_out; |
| 1212 | 1209 | cdns->num_ports = stream->num_pdi; |
| 1213 | 1210 | |
| 1214 | − /* Allocate PDIs for PDMs */ | |
| 1215 | − stream = &cdns->pdm; | |
| 1216 | − ret = cdns_allocate_pdi(cdns, &stream->bd, | |
| 1217 | − stream->num_bd, offset); | |
| 1218 | − if (ret) | |
| 1219 | − return ret; | |
| 1220 | − | |
| 1221 | − offset += stream->num_bd; | |
| 1222 | − | |
| 1223 | − ret = cdns_allocate_pdi(cdns, &stream->in, | |
| 1224 | − stream->num_in, offset); | |
| 1225 | − if (ret) | |
| 1226 | − return ret; | |
| 1227 | − | |
| 1228 | − offset += stream->num_in; | |
| 1229 | − | |
| 1230 | − ret = cdns_allocate_pdi(cdns, &stream->out, | |
| 1231 | − stream->num_out, offset); | |
| 1232 | − | |
| 1233 | − if (ret) | |
| 1234 | − return ret; | |
| 1235 | − | |
| 1236 | − /* Update total number of PDM PDIs */ | |
| 1237 | − stream->num_pdi = stream->num_bd + stream->num_in + stream->num_out; | |
| 1238 | − cdns->num_ports += stream->num_pdi; | |
| 1239 | − | |
| 1240 | 1211 | return 0; |
| 1241 | 1212 | } |
| 1242 | 1213 | EXPORT_SYMBOL(sdw_cdns_pdi_init); |
| @@ -1681,7 +1652,7 @@ int sdw_cdns_probe(struct sdw_cdns *cdns) · 438 unmodified lines | ||
| 1681 | 1652 | EXPORT_SYMBOL(sdw_cdns_probe); |
| 1682 | 1653 | |
| 1683 | 1654 | int cdns_set_sdw_stream(struct snd_soc_dai *dai, |
| 1684 | − void *stream, bool pcm, int direction) | |
| 1655 | + void *stream, int direction) | |
| 1685 | 1656 | { |
| 1686 | 1657 | struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); |
| 1687 | 1658 | struct sdw_cdns_dma_data *dma; |
| @@ -1705,10 +1676,7 @@ int cdns_set_sdw_stream(struct snd_soc_dai *dai, · 17 unmodified lines | ||
| 1705 | 1676 | if (!dma) |
| 1706 | 1677 | return -ENOMEM; |
| 1707 | 1678 | |
| 1708 | − if (pcm) | |
| 1709 | − dma->stream_type = SDW_STREAM_PCM; | |
| 1710 | − else | |
| 1711 | − dma->stream_type = SDW_STREAM_PDM; | |
| 1679 | + dma->stream_type = SDW_STREAM_PCM; | |
| 1712 | 1680 | |
| 1713 | 1681 | dma->bus = &cdns->bus; |
| 1714 | 1682 | dma->link_id = cdns->instance; |
| @@ -17,7 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | * @h_ch_num: high channel for PDI |
| 18 | 18 | * @ch_count: total channel count for PDI |
| 19 | 19 | * @dir: data direction |
| 20 | − * @type: stream type, PDM or PCM | |
| 20 | + * @type: stream type, (only PCM supported) | |
| 21 | 21 | */ |
| 22 | 22 | struct sdw_cdns_pdi { |
| 23 | 23 | int num; |
| @@ -62,17 +62,11 @@ struct sdw_cdns_streams { · 38 unmodified lines | ||
| 62 | 62 | * @pcm_bd: number of bidirectional PCM streams supported |
| 63 | 63 | * @pcm_in: number of input PCM streams supported |
| 64 | 64 | * @pcm_out: number of output PCM streams supported |
| 65 | − * @pdm_bd: number of bidirectional PDM streams supported | |
| 66 | − * @pdm_in: number of input PDM streams supported | |
| 67 | − * @pdm_out: number of output PDM streams supported | |
| 68 | 65 | */ |
| 69 | 66 | struct sdw_cdns_stream_config { |
| 70 | 67 | unsigned int pcm_bd; |
| 71 | 68 | unsigned int pcm_in; |
| 72 | 69 | unsigned int pcm_out; |
| 73 | − unsigned int pdm_bd; | |
| 74 | − unsigned int pdm_in; | |
| 75 | − unsigned int pdm_out; | |
| 76 | 70 | }; |
| 77 | 71 | |
| 78 | 72 | /** |
| @@ -86,6 +80,7 @@ struct sdw_cdns_stream_config { · 7 unmodified lines | ||
| 86 | 80 | * @link_id: Master link id |
| 87 | 81 | * @hw_params: hw_params to be applied in .prepare step |
| 88 | 82 | * @suspended: status set when suspended, to be used in .prepare |
| 83 | + * @paused: status set in .trigger, to be used in suspend | |
| 89 | 84 | */ |
| 90 | 85 | struct sdw_cdns_dma_data { |
| 91 | 86 | char *name; |
| @@ -96,6 +91,7 @@ struct sdw_cdns_dma_data { · 4 unmodified lines | ||
| 96 | 91 | int link_id; |
| 97 | 92 | struct snd_pcm_hw_params *hw_params; |
| 98 | 93 | bool suspended; |
| 94 | + bool paused; | |
| 99 | 95 | }; |
| 100 | 96 | |
| 101 | 97 | /** |
| @@ -109,7 +105,6 @@ struct sdw_cdns_dma_data { · 7 unmodified lines | ||
| 109 | 105 | * @ports: Data ports |
| 110 | 106 | * @num_ports: Total number of data ports |
| 111 | 107 | * @pcm: PCM streams |
| 112 | − * @pdm: PDM streams | |
| 113 | 108 | * @registers: Cadence registers |
| 114 | 109 | * @link_up: Link status |
| 115 | 110 | * @msg_count: Messages sent on bus |
| @@ -127,7 +122,6 @@ struct sdw_cdns { · 11 unmodified lines | ||
| 127 | 122 | int num_ports; |
| 128 | 123 | |
| 129 | 124 | struct sdw_cdns_streams pcm; |
| 130 | − struct sdw_cdns_streams pdm; | |
| 131 | 125 | |
| 132 | 126 | int pdi_loopback_source; |
| 133 | 127 | int pdi_loopback_target; |
| @@ -186,7 +180,7 @@ cdns_xfer_msg_defer(struct sdw_bus *bus, · 52 unmodified lines | ||
| 186 | 180 | int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params); |
| 187 | 181 | |
| 188 | 182 | int cdns_set_sdw_stream(struct snd_soc_dai *dai, |
| 189 | − void *stream, bool pcm, int direction); | |
| 183 | + void *stream, int direction); | |
| 190 | 184 | |
| 191 | 185 | void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string, |
| 192 | 186 | bool initial_delay, int reset_iterations); |
| @@ -564,7 +564,7 @@ static void intel_pdi_init(struct sdw_intel *sdw, · 563 unmodified lines | ||
| 564 | 564 | { |
| 565 | 565 | void __iomem *shim = sdw->link_res->shim; |
| 566 | 566 | unsigned int link_id = sdw->instance; |
| 567 | − int pcm_cap, pdm_cap; | |
| 567 | + int pcm_cap; | |
| 568 | 568 | |
| 569 | 569 | /* PCM Stream Capability */ |
| 570 | 570 | pcm_cap = intel_readw(shim, SDW_SHIM_PCMSCAP(link_id)); |
| @@ -575,41 +575,25 @@ static void intel_pdi_init(struct sdw_intel *sdw, · 4 unmodified lines | ||
| 575 | 575 | |
| 576 | 576 | dev_dbg(sdw->cdns.dev, "PCM cap bd:%d in:%d out:%d\n", |
| 577 | 577 | config->pcm_bd, config->pcm_in, config->pcm_out); |
| 578 | − | |
| 579 | − /* PDM Stream Capability */ | |
| 580 | − pdm_cap = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id)); | |
| 581 | − | |
| 582 | − config->pdm_bd = FIELD_GET(SDW_SHIM_PDMSCAP_BSS, pdm_cap); | |
| 583 | − config->pdm_in = FIELD_GET(SDW_SHIM_PDMSCAP_ISS, pdm_cap); | |
| 584 | − config->pdm_out = FIELD_GET(SDW_SHIM_PDMSCAP_OSS, pdm_cap); | |
| 585 | − | |
| 586 | − dev_dbg(sdw->cdns.dev, "PDM cap bd:%d in:%d out:%d\n", | |
| 587 | − config->pdm_bd, config->pdm_in, config->pdm_out); | |
| 588 | 578 | } |
| 589 | 579 | |
| 590 | 580 | static int |
| 591 | −intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num, bool pcm) | |
| 581 | +intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num) | |
| 592 | 582 | { |
| 593 | 583 | void __iomem *shim = sdw->link_res->shim; |
| 594 | 584 | unsigned int link_id = sdw->instance; |
| 595 | 585 | int count; |
| 596 | 586 | |
| 597 | − if (pcm) { | |
| 598 | − count = intel_readw(shim, SDW_SHIM_PCMSYCHC(link_id, pdi_num)); | |
| 587 | + count = intel_readw(shim, SDW_SHIM_PCMSYCHC(link_id, pdi_num)); | |
| 599 | 588 | |
| 600 | − /* | |
| 601 | − * WORKAROUND: on all existing Intel controllers, pdi | |
| 602 | − * number 2 reports channel count as 1 even though it | |
| 603 | − * supports 8 channels. Performing hardcoding for pdi | |
| 604 | − * number 2. | |
| 605 | − */ | |
| 606 | − if (pdi_num == 2) | |
| 607 | − count = 7; | |
| 608 | − | |
| 609 | − } else { | |
| 610 | − count = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id)); | |
| 611 | − count = FIELD_GET(SDW_SHIM_PDMSCAP_CPSS, count); | |
| 612 | − } | |
| 589 | + /* | |
| 590 | + * WORKAROUND: on all existing Intel controllers, pdi | |
| 591 | + * number 2 reports channel count as 1 even though it | |
| 592 | + * supports 8 channels. Performing hardcoding for pdi | |
| 593 | + * number 2. | |
| 594 | + */ | |
| 595 | + if (pdi_num == 2) | |
| 596 | + count = 7; | |
| 613 | 597 | |
| 614 | 598 | /* zero based values for channel count in register */ |
| 615 | 599 | count++; |
| @@ -620,12 +604,12 @@ intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num, bool pcm) · 4 unmodified lines | ||
| 620 | 604 | static int intel_pdi_get_ch_update(struct sdw_intel *sdw, |
| 621 | 605 | struct sdw_cdns_pdi *pdi, |
| 622 | 606 | unsigned int num_pdi, |
| 623 | − unsigned int *num_ch, bool pcm) | |
| 607 | + unsigned int *num_ch) | |
| 624 | 608 | { |
| 625 | 609 | int i, ch_count = 0; |
| 626 | 610 | |
| 627 | 611 | for (i = 0; i < num_pdi; i++) { |
| 628 | − pdi->ch_count = intel_pdi_get_ch_cap(sdw, pdi->num, pcm); | |
| 612 | + pdi->ch_count = intel_pdi_get_ch_cap(sdw, pdi->num); | |
| 629 | 613 | ch_count += pdi->ch_count; |
| 630 | 614 | pdi++; |
| 631 | 615 | } |
| @@ -635,25 +619,23 @@ static int intel_pdi_get_ch_update(struct sdw_intel *sdw, · 3 unmodified lines | ||
| 635 | 619 | } |
| 636 | 620 | |
| 637 | 621 | static int intel_pdi_stream_ch_update(struct sdw_intel *sdw, |
| 638 | − struct sdw_cdns_streams *stream, bool pcm) | |
| 622 | + struct sdw_cdns_streams *stream) | |
| 639 | 623 | { |
| 640 | 624 | intel_pdi_get_ch_update(sdw, stream->bd, stream->num_bd, |
| 641 | − &stream->num_ch_bd, pcm); | |
| 625 | + &stream->num_ch_bd); | |
| 642 | 626 | |
| 643 | 627 | intel_pdi_get_ch_update(sdw, stream->in, stream->num_in, |
| 644 | − &stream->num_ch_in, pcm); | |
| 628 | + &stream->num_ch_in); | |
| 645 | 629 | |
| 646 | 630 | intel_pdi_get_ch_update(sdw, stream->out, stream->num_out, |
| 647 | − &stream->num_ch_out, pcm); | |
| 631 | + &stream->num_ch_out); | |
| 648 | 632 | |
| 649 | 633 | return 0; |
| 650 | 634 | } |
| 651 | 635 | |
| 652 | 636 | static int intel_pdi_ch_update(struct sdw_intel *sdw) |
| 653 | 637 | { |
| 654 | − /* First update PCM streams followed by PDM streams */ | |
| 655 | − intel_pdi_stream_ch_update(sdw, &sdw->cdns.pcm, true); | |
| 656 | − intel_pdi_stream_ch_update(sdw, &sdw->cdns.pdm, false); | |
| 638 | + intel_pdi_stream_ch_update(sdw, &sdw->cdns.pcm); | |
| 657 | 639 | |
| 658 | 640 | return 0; |
| 659 | 641 | } |
| @@ -711,7 +693,7 @@ intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi) · 51 unmodified lines | ||
| 711 | 693 | } |
| 712 | 694 | |
| 713 | 695 | static int intel_params_stream(struct sdw_intel *sdw, |
| 714 | − struct snd_pcm_substream *substream, | |
| 696 | + int stream, | |
| 715 | 697 | struct snd_soc_dai *dai, |
| 716 | 698 | struct snd_pcm_hw_params *hw_params, |
| 717 | 699 | int link_id, int alh_stream_id) |
| @@ -719,7 +701,7 @@ static int intel_params_stream(struct sdw_intel *sdw, · 1 unmodified line | ||
| 719 | 701 | struct sdw_intel_link_res *res = sdw->link_res; |
| 720 | 702 | struct sdw_intel_stream_params_data params_data; |
| 721 | 703 | |
| 722 | − params_data.substream = substream; | |
| 704 | + params_data.stream = stream; /* direction */ | |
| 723 | 705 | params_data.dai = dai; |
| 724 | 706 | params_data.hw_params = hw_params; |
| 725 | 707 | params_data.link_id = link_id; |
| @@ -732,14 +714,14 @@ static int intel_params_stream(struct sdw_intel *sdw, · 6 unmodified lines | ||
| 732 | 714 | } |
| 733 | 715 | |
| 734 | 716 | static int intel_free_stream(struct sdw_intel *sdw, |
| 735 | − struct snd_pcm_substream *substream, | |
| 717 | + int stream, | |
| 736 | 718 | struct snd_soc_dai *dai, |
| 737 | 719 | int link_id) |
| 738 | 720 | { |
| 739 | 721 | struct sdw_intel_link_res *res = sdw->link_res; |
| 740 | 722 | struct sdw_intel_stream_free_data free_data; |
| 741 | 723 | |
| 742 | − free_data.substream = substream; | |
| 724 | + free_data.stream = stream; /* direction */ | |
| 743 | 725 | free_data.dai = dai; |
| 744 | 726 | free_data.link_id = link_id; |
| 745 | 727 | |
| @@ -840,7 +822,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream, · 94 unmodified lines | ||
| 840 | 822 | struct sdw_port_config *pconfig; |
| 841 | 823 | int ch, dir; |
| 842 | 824 | int ret; |
| 843 | − bool pcm = true; | |
| 844 | 825 | |
| 845 | 826 | dma = snd_soc_dai_get_dma_data(dai, substream); |
| 846 | 827 | if (!dma) |
| @@ -852,13 +833,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, · 5 unmodified lines | ||
| 852 | 833 | else |
| 853 | 834 | dir = SDW_DATA_DIR_TX; |
| 854 | 835 | |
| 855 | − if (dma->stream_type == SDW_STREAM_PDM) | |
| 856 | − pcm = false; | |
| 857 | − | |
| 858 | − if (pcm) | |
| 859 | − pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id); | |
| 860 | − else | |
| 861 | − pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir, dai->id); | |
| 836 | + pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id); | |
| 862 | 837 | |
| 863 | 838 | if (!pdi) { |
| 864 | 839 | ret = -EINVAL; |
| @@ -871,12 +846,13 @@ static int intel_hw_params(struct snd_pcm_substream *substream, · 6 unmodified lines | ||
| 871 | 846 | sdw_cdns_config_stream(cdns, ch, dir, pdi); |
| 872 | 847 | |
| 873 | 848 | /* store pdi and hw_params, may be needed in prepare step */ |
| 849 | + dma->paused = false; | |
| 874 | 850 | dma->suspended = false; |
| 875 | 851 | dma->pdi = pdi; |
| 876 | 852 | dma->hw_params = params; |
| 877 | 853 | |
| 878 | 854 | /* Inform DSP about PDI stream number */ |
| 879 | − ret = intel_params_stream(sdw, substream, dai, params, | |
| 855 | + ret = intel_params_stream(sdw, substream->stream, dai, params, | |
| 880 | 856 | sdw->instance, |
| 881 | 857 | pdi->intel_alh_id); |
| 882 | 858 | if (ret) |
| @@ -887,12 +863,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, · 4 unmodified lines | ||
| 887 | 863 | sconfig.frame_rate = params_rate(params); |
| 888 | 864 | sconfig.type = dma->stream_type; |
| 889 | 865 | |
| 890 | − if (dma->stream_type == SDW_STREAM_PDM) { | |
| 891 | − sconfig.frame_rate *= 50; | |
| 892 | − sconfig.bps = 1; | |
| 893 | − } else { | |
| 894 | − sconfig.bps = snd_pcm_format_width(params_format(params)); | |
| 895 | − } | |
| 866 | + sconfig.bps = snd_pcm_format_width(params_format(params)); | |
| 896 | 867 | |
| 897 | 868 | /* Port configuration */ |
| 898 | 869 | pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); |
| @@ -953,7 +924,7 @@ static int intel_prepare(struct snd_pcm_substream *substream, · 54 unmodified lines | ||
| 953 | 924 | sdw_cdns_config_stream(cdns, ch, dir, dma->pdi); |
| 954 | 925 | |
| 955 | 926 | /* Inform DSP about PDI stream number */ |
| 956 | − ret = intel_params_stream(sdw, substream, dai, | |
| 927 | + ret = intel_params_stream(sdw, substream->stream, dai, | |
| 957 | 928 | dma->hw_params, |
| 958 | 929 | sdw->instance, |
| 959 | 930 | dma->pdi->intel_alh_id); |
| @@ -987,7 +958,7 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) · 27 unmodified lines | ||
| 987 | 958 | return ret; |
| 988 | 959 | } |
| 989 | 960 | |
| 990 | − ret = intel_free_stream(sdw, substream, dai, sdw->instance); | |
| 961 | + ret = intel_free_stream(sdw, substream->stream, dai, sdw->instance); | |
| 991 | 962 | if (ret < 0) { |
| 992 | 963 | dev_err(dai->dev, "intel_free_stream: failed %d\n", ret); |
| 993 | 964 | return ret; |
| @@ -1008,39 +979,10 @@ static void intel_shutdown(struct snd_pcm_substream *substream, · 14 unmodified lines | ||
| 1008 | 979 | pm_runtime_put_autosuspend(cdns->dev); |
| 1009 | 980 | } |
| 1010 | 981 | |
| 1011 | −static int intel_component_dais_suspend(struct snd_soc_component *component) | |
| 1012 | −{ | |
| 1013 | − struct sdw_cdns_dma_data *dma; | |
| 1014 | − struct snd_soc_dai *dai; | |
| 1015 | − | |
| 1016 | − for_each_component_dais(component, dai) { | |
| 1017 | − /* | |
| 1018 | − * we don't have a .suspend dai_ops, and we don't have access | |
| 1019 | − * to the substream, so let's mark both capture and playback | |
| 1020 | − * DMA contexts as suspended | |
| 1021 | − */ | |
| 1022 | − dma = dai->playback_dma_data; | |
| 1023 | − if (dma) | |
| 1024 | − dma->suspended = true; | |
| 1025 | − | |
| 1026 | − dma = dai->capture_dma_data; | |
| 1027 | − if (dma) | |
| 1028 | − dma->suspended = true; | |
| 1029 | − } | |
| 1030 | − | |
| 1031 | − return 0; | |
| 1032 | −} | |
| 1033 | − | |
| 1034 | 982 | static int intel_pcm_set_sdw_stream(struct snd_soc_dai *dai, |
| 1035 | 983 | void *stream, int direction) |
| 1036 | 984 | { |
| 1037 | − return cdns_set_sdw_stream(dai, stream, true, direction); | |
| 1038 | −} | |
| 1039 | − | |
| 1040 | −static int intel_pdm_set_sdw_stream(struct snd_soc_dai *dai, | |
| 1041 | − void *stream, int direction) | |
| 1042 | −{ | |
| 1043 | − return cdns_set_sdw_stream(dai, stream, false, direction); | |
| 985 | + return cdns_set_sdw_stream(dai, stream, direction); | |
| 1044 | 986 | } |
| 1045 | 987 | |
| 1046 | 988 | static void *intel_get_sdw_stream(struct snd_soc_dai *dai, |
| @@ -1059,24 +1001,100 @@ static void *intel_get_sdw_stream(struct snd_soc_dai *dai, · 12 unmodified lines | ||
| 1059 | 1001 | return dma->stream; |
| 1060 | 1002 | } |
| 1061 | 1003 | |
| 1062 | −static const struct snd_soc_dai_ops intel_pcm_dai_ops = { | |
| 1063 | − .startup = intel_startup, | |
| 1064 | − .hw_params = intel_hw_params, | |
| 1065 | − .prepare = intel_prepare, | |
| 1066 | − .hw_free = intel_hw_free, | |
| 1067 | − .shutdown = intel_shutdown, | |
| 1068 | − .set_sdw_stream = intel_pcm_set_sdw_stream, | |
| 1069 | − .get_sdw_stream = intel_get_sdw_stream, | |
| 1070 | −}; | |
| 1004 | +static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) | |
| 1005 | +{ | |
| 1006 | + struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); | |
| 1007 | + struct sdw_intel *sdw = cdns_to_intel(cdns); | |
| 1008 | + struct sdw_cdns_dma_data *dma; | |
| 1009 | + int ret = 0; | |
| 1071 | 1010 | |
| 1072 | −static const struct snd_soc_dai_ops intel_pdm_dai_ops = { | |
| 1011 | + dma = snd_soc_dai_get_dma_data(dai, substream); | |
| 1012 | + if (!dma) { | |
| 1013 | + dev_err(dai->dev, "failed to get dma data in %s\n", | |
| 1014 | + __func__); | |
| 1015 | + return -EIO; | |
| 1016 | + } | |
| 1017 | + | |
| 1018 | + switch (cmd) { | |
| 1019 | + case SNDRV_PCM_TRIGGER_SUSPEND: | |
| 1020 | + | |
| 1021 | + /* | |
| 1022 | + * The .prepare callback is used to deal with xruns and resume operations. | |
| 1023 | + * In the case of xruns, the DMAs and SHIM registers cannot be touched, | |
| 1024 | + * but for resume operations the DMAs and SHIM registers need to be initialized. | |
| 1025 | + * the .trigger callback is used to track the suspend case only. | |
| 1026 | + */ | |
| 1027 | + | |
| 1028 | + dma->suspended = true; | |
| 1029 | + | |
| 1030 | + ret = intel_free_stream(sdw, substream->stream, dai, sdw->instance); | |
| 1031 | + break; | |
| 1032 | + | |
| 1033 | + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | |
| 1034 | + dma->paused = true; | |
| 1035 | + break; | |
| 1036 | + case SNDRV_PCM_TRIGGER_STOP: | |
| 1037 | + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | |
| 1038 | + dma->paused = false; | |
| 1039 | + break; | |
| 1040 | + default: | |
| 1041 | + break; | |
| 1042 | + } | |
| 1043 | + | |
| 1044 | + return ret; | |
| 1045 | +} | |
| 1046 | + | |
| 1047 | +static int intel_component_dais_suspend(struct snd_soc_component *component) | |
| 1048 | +{ | |
| 1049 | + struct snd_soc_dai *dai; | |
| 1050 | + | |
| 1051 | + /* | |
| 1052 | + * In the corner case where a SUSPEND happens during a PAUSE, the ALSA core | |
| 1053 | + * does not throw the TRIGGER_SUSPEND. This leaves the DAIs in an unbalanced state. | |
| 1054 | + * Since the component suspend is called last, we can trap this corner case | |
| 1055 | + * and force the DAIs to release their resources. | |
| 1056 | + */ | |
| 1057 | + for_each_component_dais(component, dai) { | |
| 1058 | + struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); | |
| 1059 | + struct sdw_intel *sdw = cdns_to_intel(cdns); | |
| 1060 | + struct sdw_cdns_dma_data *dma; | |
| 1061 | + int stream; | |
| 1062 | + int ret; | |
| 1063 | + | |
| 1064 | + dma = dai->playback_dma_data; | |
| 1065 | + stream = SNDRV_PCM_STREAM_PLAYBACK; | |
| 1066 | + if (!dma) { | |
| 1067 | + dma = dai->capture_dma_data; | |
| 1068 | + stream = SNDRV_PCM_STREAM_CAPTURE; | |
| 1069 | + } | |
| 1070 | + | |
| 1071 | + if (!dma) | |
| 1072 | + continue; | |
| 1073 | + | |
| 1074 | + if (dma->suspended) | |
| 1075 | + continue; | |
| 1076 | + | |
| 1077 | + if (dma->paused) { | |
| 1078 | + dma->suspended = true; | |
| 1079 | + | |
| 1080 | + ret = intel_free_stream(sdw, stream, dai, sdw->instance); | |
| 1081 | + if (ret < 0) | |
| 1082 | + return ret; | |
| 1083 | + } | |
| 1084 | + } | |
| 1085 | + | |
| 1086 | + return 0; | |
| 1087 | +} | |
| 1088 | + | |
| 1089 | +static const struct snd_soc_dai_ops intel_pcm_dai_ops = { | |
| 1073 | 1090 | .startup = intel_startup, |
| 1074 | 1091 | .hw_params = intel_hw_params, |
| 1075 | 1092 | .prepare = intel_prepare, |
| 1076 | 1093 | .hw_free = intel_hw_free, |
| 1094 | + .trigger = intel_trigger, | |
| 1077 | 1095 | .shutdown = intel_shutdown, |
| 1078 | − .set_sdw_stream = intel_pdm_set_sdw_stream, | |
| 1079 | − .get_sdw_stream = intel_get_sdw_stream, | |
| 1096 | + .set_stream = intel_pcm_set_sdw_stream, | |
| 1097 | + .get_stream = intel_get_sdw_stream, | |
| 1080 | 1098 | }; |
| 1081 | 1099 | |
| 1082 | 1100 | static const struct snd_soc_component_driver dai_component = { |
| @@ -1087,7 +1105,7 @@ static const struct snd_soc_component_driver dai_component = { · 4 unmodified lines | ||
| 1087 | 1105 | static int intel_create_dai(struct sdw_cdns *cdns, |
| 1088 | 1106 | struct snd_soc_dai_driver *dais, |
| 1089 | 1107 | enum intel_pdi_type type, |
| 1090 | − u32 num, u32 off, u32 max_ch, bool pcm) | |
| 1108 | + u32 num, u32 off, u32 max_ch) | |
| 1091 | 1109 | { |
| 1092 | 1110 | int i; |
| 1093 | 1111 | |
| @@ -1116,10 +1134,7 @@ static int intel_create_dai(struct sdw_cdns *cdns, · 22 unmodified lines | ||
| 1116 | 1134 | dais[i].capture.formats = SNDRV_PCM_FMTBIT_S16_LE; |
| 1117 | 1135 | } |
| 1118 | 1136 | |
| 1119 | − if (pcm) | |
| 1120 | − dais[i].ops = &intel_pcm_dai_ops; | |
| 1121 | − else | |
| 1122 | − dais[i].ops = &intel_pdm_dai_ops; | |
| 1137 | + dais[i].ops = &intel_pcm_dai_ops; | |
| 1123 | 1138 | } |
| 1124 | 1139 | |
| 1125 | 1140 | return 0; |
| @@ -1133,7 +1148,7 @@ static int intel_register_dai(struct sdw_intel *sdw) · 7 unmodified lines | ||
| 1133 | 1148 | int num_dai, ret, off = 0; |
| 1134 | 1149 | |
| 1135 | 1150 | /* DAIs are created based on total number of PDIs supported */ |
| 1136 | − num_dai = cdns->pcm.num_pdi + cdns->pdm.num_pdi; | |
| 1151 | + num_dai = cdns->pcm.num_pdi; | |
| 1137 | 1152 | |
| 1138 | 1153 | dais = devm_kcalloc(cdns->dev, num_dai, sizeof(*dais), GFP_KERNEL); |
| 1139 | 1154 | if (!dais) |
| @@ -1143,39 +1158,19 @@ static int intel_register_dai(struct sdw_intel *sdw) · 3 unmodified lines | ||
| 1143 | 1158 | stream = &cdns->pcm; |
| 1144 | 1159 | |
| 1145 | 1160 | ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pcm.num_in, |
| 1146 | − off, stream->num_ch_in, true); | |
| 1161 | + off, stream->num_ch_in); | |
| 1147 | 1162 | if (ret) |
| 1148 | 1163 | return ret; |
| 1149 | 1164 | |
| 1150 | 1165 | off += cdns->pcm.num_in; |
| 1151 | 1166 | ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pcm.num_out, |
| 1152 | − off, stream->num_ch_out, true); | |
| 1167 | + off, stream->num_ch_out); | |
| 1153 | 1168 | if (ret) |
| 1154 | 1169 | return ret; |
| 1155 | 1170 | |
| 1156 | 1171 | off += cdns->pcm.num_out; |
| 1157 | 1172 | ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pcm.num_bd, |
| 1158 | − off, stream->num_ch_bd, true); | |
| 1159 | − if (ret) | |
| 1160 | − return ret; | |
| 1161 | − | |
| 1162 | − /* Create PDM DAIs */ | |
| 1163 | − stream = &cdns->pdm; | |
| 1164 | − off += cdns->pcm.num_bd; | |
| 1165 | − ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pdm.num_in, | |
| 1166 | − off, stream->num_ch_in, false); | |
| 1167 | − if (ret) | |
| 1168 | − return ret; | |
| 1169 | − | |
| 1170 | − off += cdns->pdm.num_in; | |
| 1171 | − ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pdm.num_out, | |
| 1172 | − off, stream->num_ch_out, false); | |
| 1173 | − if (ret) | |
| 1174 | − return ret; | |
| 1175 | − | |
| 1176 | − off += cdns->pdm.num_out; | |
| 1177 | − ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pdm.num_bd, | |
| 1178 | − off, stream->num_ch_bd, false); | |
| 1173 | + off, stream->num_ch_bd); | |
| 1179 | 1174 | if (ret) |
| 1180 | 1175 | return ret; |
| 1181 | 1176 | |
| @@ -1549,7 +1544,7 @@ static int __maybe_unused intel_pm_prepare(struct device *dev) · 367 unmodified lines | ||
| 1549 | 1544 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 1550 | 1545 | struct sdw_bus *bus = &cdns->bus; |
| 1551 | 1546 | u32 clock_stop_quirks; |
| 1552 | − int ret = 0; | |
| 1547 | + int ret; | |
| 1553 | 1548 | |
| 1554 | 1549 | if (bus->prop.hw_disabled || !sdw->startup_done) { |
| 1555 | 1550 | dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n", |
| @@ -1024,8 +1024,8 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream, · 1023 unmodified lines | ||
| 1024 | 1024 | ctrl->sruntime[dai->id] = sruntime; |
| 1025 | 1025 | |
| 1026 | 1026 | for_each_rtd_codec_dais(rtd, i, codec_dai) { |
| 1027 | − ret = snd_soc_dai_set_sdw_stream(codec_dai, sruntime, | |
| 1028 | − substream->stream); | |
| 1027 | + ret = snd_soc_dai_set_stream(codec_dai, sruntime, | |
| 1028 | + substream->stream); | |
| 1029 | 1029 | if (ret < 0 && ret != -ENOTSUPP) { |
| 1030 | 1030 | dev_err(dai->dev, "Failed to set sdw stream on %s\n", |
| 1031 | 1031 | codec_dai->name); |
| @@ -1051,8 +1051,8 @@ static const struct snd_soc_dai_ops qcom_swrm_pdm_dai_ops = { · 19 unmodified lines | ||
| 1051 | 1051 | .hw_free = qcom_swrm_hw_free, |
| 1052 | 1052 | .startup = qcom_swrm_startup, |
| 1053 | 1053 | .shutdown = qcom_swrm_shutdown, |
| 1054 | − .set_sdw_stream = qcom_swrm_set_sdw_stream, | |
| 1055 | − .get_sdw_stream = qcom_swrm_get_sdw_stream, | |
| 1054 | + .set_stream = qcom_swrm_set_sdw_stream, | |
| 1055 | + .get_stream = qcom_swrm_get_sdw_stream, | |
| 1056 | 1056 | }; |
| 1057 | 1057 | |
| 1058 | 1058 | static const struct snd_soc_component_driver qcom_swrm_dai_component = { |
| @@ -1863,7 +1863,7 @@ static int set_stream(struct snd_pcm_substream *substream, · 1862 unmodified lines | ||
| 1863 | 1863 | |
| 1864 | 1864 | /* Set stream pointer on all DAIs */ |
| 1865 | 1865 | for_each_rtd_dais(rtd, i, dai) { |
| 1866 | − ret = snd_soc_dai_set_sdw_stream(dai, sdw_stream, substream->stream); | |
| 1866 | + ret = snd_soc_dai_set_stream(dai, sdw_stream, substream->stream); | |
| 1867 | 1867 | if (ret < 0) { |
| 1868 | 1868 | dev_err(rtd->dev, "failed to set stream pointer on dai %s\n", dai->name); |
| 1869 | 1869 | break; |
| @@ -1934,7 +1934,7 @@ void sdw_shutdown_stream(void *sdw_substream) · 64 unmodified lines | ||
| 1934 | 1934 | /* Find stream from first CPU DAI */ |
| 1935 | 1935 | dai = asoc_rtd_to_cpu(rtd, 0); |
| 1936 | 1936 | |
| 1937 | − sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream); | |
| 1937 | + sdw_stream = snd_soc_dai_get_stream(dai, substream->stream); | |
| 1938 | 1938 | |
| 1939 | 1939 | if (IS_ERR(sdw_stream)) { |
| 1940 | 1940 | dev_err(rtd->dev, "no stream found for DAI %s\n", dai->name); |
| @@ -370,7 +370,6 @@ static int pic32_spi_dma_config(struct pic32_spi *pic32s, u32 dma_width) · 369 unmodified lines | ||
| 370 | 370 | cfg.src_addr_width = dma_width; |
| 371 | 371 | cfg.dst_addr_width = dma_width; |
| 372 | 372 | /* tx channel */ |
| 373 | − cfg.slave_id = pic32s->tx_irq; | |
| 374 | 373 | cfg.direction = DMA_MEM_TO_DEV; |
| 375 | 374 | ret = dmaengine_slave_config(master->dma_tx, &cfg); |
| 376 | 375 | if (ret) { |
| @@ -378,7 +377,6 @@ static int pic32_spi_dma_config(struct pic32_spi *pic32s, u32 dma_width) · 1 unmodified line | ||
| 378 | 377 | return ret; |
| 379 | 378 | } |
| 380 | 379 | /* rx channel */ |
| 381 | − cfg.slave_id = pic32s->rx_irq; | |
| 382 | 380 | cfg.direction = DMA_DEV_TO_MEM; |
| 383 | 381 | ret = dmaengine_slave_config(master->dma_rx, &cfg); |
| 384 | 382 | if (ret) |
| @@ -9,6 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | |
| 10 | 10 | #include <linux/kernel.h> |
| 11 | 11 | #include <linux/atomic.h> |
| 12 | +#include <linux/dma/qcom_adm.h> | |
| 12 | 13 | #include <linux/dma-mapping.h> |
| 13 | 14 | #include <linux/dmaengine.h> |
| 14 | 15 | #include <linux/module.h> |
| @@ -290,6 +291,7 @@ static void msm_request_tx_dma(struct msm_port *msm_port, resource_size_t base) · 275 unmodified lines | ||
| 290 | 291 | { |
| 291 | 292 | struct device *dev = msm_port->uart.dev; |
| 292 | 293 | struct dma_slave_config conf; |
| 294 | + struct qcom_adm_peripheral_config periph_conf = {}; | |
| 293 | 295 | struct msm_dma *dma; |
| 294 | 296 | u32 crci = 0; |
| 295 | 297 | int ret; |
| @@ -308,7 +310,11 @@ static void msm_request_tx_dma(struct msm_port *msm_port, resource_size_t base) · 12 unmodified lines | ||
| 308 | 310 | conf.device_fc = true; |
| 309 | 311 | conf.dst_addr = base + UARTDM_TF; |
| 310 | 312 | conf.dst_maxburst = UARTDM_BURST_SIZE; |
| 311 | − conf.slave_id = crci; | |
| 313 | + if (crci) { | |
| 314 | + conf.peripheral_config = &periph_conf; | |
| 315 | + conf.peripheral_size = sizeof(periph_conf); | |
| 316 | + periph_conf.crci = crci; | |
| 317 | + } | |
| 312 | 318 | |
| 313 | 319 | ret = dmaengine_slave_config(dma->chan, &conf); |
| 314 | 320 | if (ret) |
| @@ -333,6 +339,7 @@ static void msm_request_rx_dma(struct msm_port *msm_port, resource_size_t base) · 18 unmodified lines | ||
| 333 | 339 | { |
| 334 | 340 | struct device *dev = msm_port->uart.dev; |
| 335 | 341 | struct dma_slave_config conf; |
| 342 | + struct qcom_adm_peripheral_config periph_conf = {}; | |
| 336 | 343 | struct msm_dma *dma; |
| 337 | 344 | u32 crci = 0; |
| 338 | 345 | int ret; |
| @@ -355,7 +362,11 @@ static void msm_request_rx_dma(struct msm_port *msm_port, resource_size_t base) · 16 unmodified lines | ||
| 355 | 362 | conf.device_fc = true; |
| 356 | 363 | conf.src_addr = base + UARTDM_RF; |
| 357 | 364 | conf.src_maxburst = UARTDM_BURST_SIZE; |
| 358 | − conf.slave_id = crci; | |
| 365 | + if (crci) { | |
| 366 | + conf.peripheral_config = &periph_conf; | |
| 367 | + conf.peripheral_size = sizeof(periph_conf); | |
| 368 | + periph_conf.crci = crci; | |
| 369 | + } | |
| 359 | 370 | |
| 360 | 371 | ret = dmaengine_slave_config(dma->chan, &conf); |
| 361 | 372 | if (ret) |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #define RT5640_JD_SRC_GPIO2 4 |
| 17 | 17 | #define RT5640_JD_SRC_GPIO3 5 |
| 18 | 18 | #define RT5640_JD_SRC_GPIO4 6 |
| 19 | +#define RT5640_JD_SRC_HDA_HEADER 7 | |
| 19 | 20 | |
| 20 | 21 | #define RT5640_OVCD_SF_0P5 0 |
| 21 | 22 | #define RT5640_OVCD_SF_0P75 1 |
| @@ -0,0 +1,28 @@ | ||
| 1 | +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ | |
| 2 | +/* | |
| 3 | + * Devicetree bindings definitions for tlv320adc3xxx driver. | |
| 4 | + * | |
| 5 | + * Copyright (C) 2021 Axis Communications AB | |
| 6 | + */ | |
| 7 | +#ifndef __DT_TLV320ADC3XXX_H | |
| 8 | +#define __DT_TLV320ADC3XXX_H | |
| 9 | + | |
| 10 | +#define ADC3XXX_GPIO_DISABLED 0 /* I/O buffers powered down */ | |
| 11 | +#define ADC3XXX_GPIO_INPUT 1 /* Various non-GPIO inputs */ | |
| 12 | +#define ADC3XXX_GPIO_GPI 2 /* General purpose input */ | |
| 13 | +#define ADC3XXX_GPIO_GPO 3 /* General purpose output */ | |
| 14 | +#define ADC3XXX_GPIO_CLKOUT 4 /* Source set in reg. CLKOUT_MUX */ | |
| 15 | +#define ADC3XXX_GPIO_INT1 5 /* INT1 output */ | |
| 16 | +#define ADC3XXX_GPIO_INT2 6 /* INT2 output */ | |
| 17 | +/* value 7 is reserved */ | |
| 18 | +#define ADC3XXX_GPIO_SECONDARY_BCLK 8 /* Codec interface secondary BCLK */ | |
| 19 | +#define ADC3XXX_GPIO_SECONDARY_WCLK 9 /* Codec interface secondary WCLK */ | |
| 20 | +#define ADC3XXX_GPIO_ADC_MOD_CLK 10 /* Clock output for digital mics */ | |
| 21 | +/* values 11-15 reserved */ | |
| 22 | + | |
| 23 | +#define ADC3XXX_MICBIAS_OFF 0 /* Micbias pin powered off */ | |
| 24 | +#define ADC3XXX_MICBIAS_2_0V 1 /* Micbias pin set to 2.0V */ | |
| 25 | +#define ADC3XXX_MICBIAS_2_5V 2 /* Micbias pin set to 2.5V */ | |
| 26 | +#define ADC3XXX_MICBIAS_AVDD 3 /* Use AVDD voltage for micbias pin */ | |
| 27 | + | |
| 28 | +#endif /* __DT_TLV320ADC3XXX_H */ | |
| @@ -0,0 +1,12 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0-only | |
| 2 | +#ifndef __LINUX_DMA_QCOM_ADM_H | |
| 3 | +#define __LINUX_DMA_QCOM_ADM_H | |
| 4 | + | |
| 5 | +#include <linux/types.h> | |
| 6 | + | |
| 7 | +struct qcom_adm_peripheral_config { | |
| 8 | + u32 crci; | |
| 9 | + u32 mux; | |
| 10 | +}; | |
| 11 | + | |
| 12 | +#endif /* __LINUX_DMA_QCOM_ADM_H */ | |
| @@ -0,0 +1,11 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +#ifndef __LINUX_DMA_XILINX_DPDMA_H | |
| 3 | +#define __LINUX_DMA_XILINX_DPDMA_H | |
| 4 | + | |
| 5 | +#include <linux/types.h> | |
| 6 | + | |
| 7 | +struct xilinx_dpdma_peripheral_config { | |
| 8 | + bool video_group; | |
| 9 | +}; | |
| 10 | + | |
| 11 | +#endif /* __LINUX_DMA_XILINX_DPDMA_H */ | |
| @@ -418,9 +418,6 @@ enum dma_slave_buswidth { · 417 unmodified lines | ||
| 418 | 418 | * @device_fc: Flow Controller Settings. Only valid for slave channels. Fill |
| 419 | 419 | * with 'true' if peripheral should be flow controller. Direction will be |
| 420 | 420 | * selected at Runtime. |
| 421 | − * @slave_id: Slave requester id. Only valid for slave channels. The dma | |
| 422 | − * slave peripheral will have unique id as dma requester which need to be | |
| 423 | − * pass as slave config. | |
| 424 | 421 | * @peripheral_config: peripheral configuration for programming peripheral |
| 425 | 422 | * for dmaengine transfer |
| 426 | 423 | * @peripheral_size: peripheral configuration buffer size |
| @@ -448,7 +445,6 @@ struct dma_slave_config { · 21 unmodified lines | ||
| 448 | 445 | u32 src_port_window_size; |
| 449 | 446 | u32 dst_port_window_size; |
| 450 | 447 | bool device_fc; |
| 451 | − unsigned int slave_id; | |
| 452 | 448 | void *peripheral_config; |
| 453 | 449 | size_t peripheral_size; |
| 454 | 450 | }; |
| @@ -11,6 +11,11 @@ · 10 unmodified lines | ||
| 11 | 11 | #ifndef __CS_DSP_H |
| 12 | 12 | #define __CS_DSP_H |
| 13 | 13 | |
| 14 | +#include <linux/device.h> | |
| 15 | +#include <linux/firmware.h> | |
| 16 | +#include <linux/list.h> | |
| 17 | +#include <linux/regmap.h> | |
| 18 | + | |
| 14 | 19 | #define CS_ADSP2_REGION_0 BIT(0) |
| 15 | 20 | #define CS_ADSP2_REGION_1 BIT(1) |
| 16 | 21 | #define CS_ADSP2_REGION_2 BIT(2) |
| @@ -49,12 +54,14 @@ struct cs_dsp_region { · 32 unmodified lines | ||
| 49 | 54 | * struct cs_dsp_alg_region - Describes a logical algorithm region in DSP address space |
| 50 | 55 | * @list: List node for internal use |
| 51 | 56 | * @alg: Algorithm id |
| 57 | + * @ver: Expected algorithm version | |
| 52 | 58 | * @type: Memory region type |
| 53 | 59 | * @base: Address of region |
| 54 | 60 | */ |
| 55 | 61 | struct cs_dsp_alg_region { |
| 56 | 62 | struct list_head list; |
| 57 | 63 | unsigned int alg; |
| 64 | + unsigned int ver; | |
| 58 | 65 | int type; |
| 59 | 66 | unsigned int base; |
| 60 | 67 | }; |
| @@ -69,8 +76,8 @@ struct cs_dsp_alg_region { · 8 unmodified lines | ||
| 69 | 76 | * @enabled: Flag indicating whether control is enabled |
| 70 | 77 | * @list: List node for internal use |
| 71 | 78 | * @cache: Cached value of the control |
| 72 | − * @offset: Offset of control within alg_region | |
| 73 | − * @len: Length of the cached value | |
| 79 | + * @offset: Offset of control within alg_region in words | |
| 80 | + * @len: Length of the cached value in bytes | |
| 74 | 81 | * @set: Flag indicating the value has been written by the user |
| 75 | 82 | * @flags: Bitfield of WMFW_CTL_FLAG_ control flags defined in wmfw.h |
| 76 | 83 | * @type: One of the WMFW_CTL_TYPE_ control types defined in wmfw.h |
| @@ -180,7 +187,8 @@ struct cs_dsp { · 103 unmodified lines | ||
| 180 | 187 | * struct cs_dsp_client_ops - client callbacks |
| 181 | 188 | * @control_add: Called under the pwr_lock when a control is created |
| 182 | 189 | * @control_remove: Called under the pwr_lock when a control is destroyed |
| 183 | − * @post_run: Called under the pwr_lock by cs_dsp_run() | |
| 190 | + * @pre_run: Called under the pwr_lock by cs_dsp_run() before the core is started | |
| 191 | + * @post_run: Called under the pwr_lock by cs_dsp_run() after the core is started | |
| 184 | 192 | * @post_stop: Called under the pwr_lock by cs_dsp_stop() |
| 185 | 193 | * @watchdog_expired: Called when a watchdog expiry is detected |
| 186 | 194 | * |
| @@ -190,6 +198,7 @@ struct cs_dsp { · 3 unmodified lines | ||
| 190 | 198 | struct cs_dsp_client_ops { |
| 191 | 199 | int (*control_add)(struct cs_dsp_coeff_ctl *ctl); |
| 192 | 200 | void (*control_remove)(struct cs_dsp_coeff_ctl *ctl); |
| 201 | + int (*pre_run)(struct cs_dsp *dsp); | |
| 193 | 202 | int (*post_run)(struct cs_dsp *dsp); |
| 194 | 203 | void (*post_stop)(struct cs_dsp *dsp); |
| 195 | 204 | void (*watchdog_expired)(struct cs_dsp *dsp); |
| @@ -223,8 +232,10 @@ void cs_dsp_init_debugfs(struct cs_dsp *dsp, struct dentry *debugfs_root); · 27 unmodified lines | ||
| 223 | 232 | void cs_dsp_cleanup_debugfs(struct cs_dsp *dsp); |
| 224 | 233 | |
| 225 | 234 | int cs_dsp_coeff_write_acked_control(struct cs_dsp_coeff_ctl *ctl, unsigned int event_id); |
| 226 | −int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl, const void *buf, size_t len); | |
| 227 | −int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl, void *buf, size_t len); | |
| 235 | +int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl, unsigned int off, | |
| 236 | + const void *buf, size_t len); | |
| 237 | +int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl, unsigned int off, | |
| 238 | + void *buf, size_t len); | |
| 228 | 239 | struct cs_dsp_coeff_ctl *cs_dsp_get_ctl(struct cs_dsp *dsp, const char *name, int type, |
| 229 | 240 | unsigned int alg); |
| 230 | 241 | |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #define WMFW_CTL_TYPE_ACKED 0x1000 /* acked control */ |
| 30 | 30 | #define WMFW_CTL_TYPE_HOSTEVENT 0x1001 /* event control */ |
| 31 | 31 | #define WMFW_CTL_TYPE_HOST_BUFFER 0x1002 /* host buffer pointer */ |
| 32 | +#define WMFW_CTL_TYPE_FWEVENT 0x1004 /* firmware event control */ | |
| 32 | 33 | |
| 33 | 34 | struct wmfw_header { |
| 34 | 35 | char magic[4]; |
| @@ -92,7 +92,7 @@ · 91 unmodified lines | ||
| 92 | 92 | * firmware. |
| 93 | 93 | */ |
| 94 | 94 | struct sdw_intel_stream_params_data { |
| 95 | − struct snd_pcm_substream *substream; | |
| 95 | + int stream; | |
| 96 | 96 | struct snd_soc_dai *dai; |
| 97 | 97 | struct snd_pcm_hw_params *hw_params; |
| 98 | 98 | int link_id; |
| @@ -105,7 +105,7 @@ struct sdw_intel_stream_params_data { · 6 unmodified lines | ||
| 105 | 105 | * firmware. |
| 106 | 106 | */ |
| 107 | 107 | struct sdw_intel_stream_free_data { |
| 108 | − struct snd_pcm_substream *substream; | |
| 108 | + int stream; | |
| 109 | 109 | struct snd_soc_dai *dai; |
| 110 | 110 | int link_id; |
| 111 | 111 | }; |
| @@ -10,6 +10,725 @@ · 9 unmodified lines | ||
| 10 | 10 | #ifndef __CS35L41_H |
| 11 | 11 | #define __CS35L41_H |
| 12 | 12 | |
| 13 | +#include <linux/regmap.h> | |
| 14 | + | |
| 15 | +#define CS35L41_FIRSTREG 0x00000000 | |
| 16 | +#define CS35L41_LASTREG 0x03804FE8 | |
| 17 | +#define CS35L41_DEVID 0x00000000 | |
| 18 | +#define CS35L41_REVID 0x00000004 | |
| 19 | +#define CS35L41_FABID 0x00000008 | |
| 20 | +#define CS35L41_RELID 0x0000000C | |
| 21 | +#define CS35L41_OTPID 0x00000010 | |
| 22 | +#define CS35L41_SFT_RESET 0x00000020 | |
| 23 | +#define CS35L41_TEST_KEY_CTL 0x00000040 | |
| 24 | +#define CS35L41_USER_KEY_CTL 0x00000044 | |
| 25 | +#define CS35L41_OTP_MEM0 0x00000400 | |
| 26 | +#define CS35L41_OTP_MEM31 0x0000047C | |
| 27 | +#define CS35L41_OTP_CTRL0 0x00000500 | |
| 28 | +#define CS35L41_OTP_CTRL1 0x00000504 | |
| 29 | +#define CS35L41_OTP_CTRL3 0x00000508 | |
| 30 | +#define CS35L41_OTP_CTRL4 0x0000050C | |
| 31 | +#define CS35L41_OTP_CTRL5 0x00000510 | |
| 32 | +#define CS35L41_OTP_CTRL6 0x00000514 | |
| 33 | +#define CS35L41_OTP_CTRL7 0x00000518 | |
| 34 | +#define CS35L41_OTP_CTRL8 0x0000051C | |
| 35 | +#define CS35L41_PWR_CTRL1 0x00002014 | |
| 36 | +#define CS35L41_PWR_CTRL2 0x00002018 | |
| 37 | +#define CS35L41_PWR_CTRL3 0x0000201C | |
| 38 | +#define CS35L41_CTRL_OVRRIDE 0x00002020 | |
| 39 | +#define CS35L41_AMP_OUT_MUTE 0x00002024 | |
| 40 | +#define CS35L41_PROTECT_REL_ERR_IGN 0x00002034 | |
| 41 | +#define CS35L41_GPIO_PAD_CONTROL 0x0000242C | |
| 42 | +#define CS35L41_JTAG_CONTROL 0x00002438 | |
| 43 | +#define CS35L41_PWRMGT_CTL 0x00002900 | |
| 44 | +#define CS35L41_WAKESRC_CTL 0x00002904 | |
| 45 | +#define CS35L41_PWRMGT_STS 0x00002908 | |
| 46 | +#define CS35L41_PLL_CLK_CTRL 0x00002C04 | |
| 47 | +#define CS35L41_DSP_CLK_CTRL 0x00002C08 | |
| 48 | +#define CS35L41_GLOBAL_CLK_CTRL 0x00002C0C | |
| 49 | +#define CS35L41_DATA_FS_SEL 0x00002C10 | |
| 50 | +#define CS35L41_TST_FS_MON0 0x00002D10 | |
| 51 | +#define CS35L41_MDSYNC_EN 0x00003400 | |
| 52 | +#define CS35L41_MDSYNC_TX_ID 0x00003408 | |
| 53 | +#define CS35L41_MDSYNC_PWR_CTRL 0x0000340C | |
| 54 | +#define CS35L41_MDSYNC_DATA_TX 0x00003410 | |
| 55 | +#define CS35L41_MDSYNC_TX_STATUS 0x00003414 | |
| 56 | +#define CS35L41_MDSYNC_DATA_RX 0x0000341C | |
| 57 | +#define CS35L41_MDSYNC_RX_STATUS 0x00003420 | |
| 58 | +#define CS35L41_MDSYNC_ERR_STATUS 0x00003424 | |
| 59 | +#define CS35L41_MDSYNC_SYNC_PTE2 0x00003528 | |
| 60 | +#define CS35L41_MDSYNC_SYNC_PTE3 0x0000352C | |
| 61 | +#define CS35L41_MDSYNC_SYNC_MSM_STATUS 0x0000353C | |
| 62 | +#define CS35L41_BSTCVRT_VCTRL1 0x00003800 | |
| 63 | +#define CS35L41_BSTCVRT_VCTRL2 0x00003804 | |
| 64 | +#define CS35L41_BSTCVRT_PEAK_CUR 0x00003808 | |
| 65 | +#define CS35L41_BSTCVRT_SFT_RAMP 0x0000380C | |
| 66 | +#define CS35L41_BSTCVRT_COEFF 0x00003810 | |
| 67 | +#define CS35L41_BSTCVRT_SLOPE_LBST 0x00003814 | |
| 68 | +#define CS35L41_BSTCVRT_SW_FREQ 0x00003818 | |
| 69 | +#define CS35L41_BSTCVRT_DCM_CTRL 0x0000381C | |
| 70 | +#define CS35L41_BSTCVRT_DCM_MODE_FORCE 0x00003820 | |
| 71 | +#define CS35L41_BSTCVRT_OVERVOLT_CTRL 0x00003830 | |
| 72 | +#define CS35L41_VI_VOL_POL 0x00004000 | |
| 73 | +#define CS35L41_VIMON_SPKMON_RESYNC 0x00004100 | |
| 74 | +#define CS35L41_DTEMP_WARN_THLD 0x00004220 | |
| 75 | +#define CS35L41_DTEMP_CFG 0x00004224 | |
| 76 | +#define CS35L41_DTEMP_EN 0x00004308 | |
| 77 | +#define CS35L41_VPVBST_FS_SEL 0x00004400 | |
| 78 | +#define CS35L41_SP_ENABLES 0x00004800 | |
| 79 | +#define CS35L41_SP_RATE_CTRL 0x00004804 | |
| 80 | +#define CS35L41_SP_FORMAT 0x00004808 | |
| 81 | +#define CS35L41_SP_HIZ_CTRL 0x0000480C | |
| 82 | +#define CS35L41_SP_FRAME_TX_SLOT 0x00004810 | |
| 83 | +#define CS35L41_SP_FRAME_RX_SLOT 0x00004820 | |
| 84 | +#define CS35L41_SP_TX_WL 0x00004830 | |
| 85 | +#define CS35L41_SP_RX_WL 0x00004840 | |
| 86 | +#define CS35L41_ASP_CONTROL4 0x00004854 | |
| 87 | +#define CS35L41_DAC_PCM1_SRC 0x00004C00 | |
| 88 | +#define CS35L41_ASP_TX1_SRC 0x00004C20 | |
| 89 | +#define CS35L41_ASP_TX2_SRC 0x00004C24 | |
| 90 | +#define CS35L41_ASP_TX3_SRC 0x00004C28 | |
| 91 | +#define CS35L41_ASP_TX4_SRC 0x00004C2C | |
| 92 | +#define CS35L41_DSP1_RX1_SRC 0x00004C40 | |
| 93 | +#define CS35L41_DSP1_RX2_SRC 0x00004C44 | |
| 94 | +#define CS35L41_DSP1_RX3_SRC 0x00004C48 | |
| 95 | +#define CS35L41_DSP1_RX4_SRC 0x00004C4C | |
| 96 | +#define CS35L41_DSP1_RX5_SRC 0x00004C50 | |
| 97 | +#define CS35L41_DSP1_RX6_SRC 0x00004C54 | |
| 98 | +#define CS35L41_DSP1_RX7_SRC 0x00004C58 | |
| 99 | +#define CS35L41_DSP1_RX8_SRC 0x00004C5C | |
| 100 | +#define CS35L41_NGATE1_SRC 0x00004C60 | |
| 101 | +#define CS35L41_NGATE2_SRC 0x00004C64 | |
| 102 | +#define CS35L41_AMP_DIG_VOL_CTRL 0x00006000 | |
| 103 | +#define CS35L41_VPBR_CFG 0x00006404 | |
| 104 | +#define CS35L41_VBBR_CFG 0x00006408 | |
| 105 | +#define CS35L41_VPBR_STATUS 0x0000640C | |
| 106 | +#define CS35L41_VBBR_STATUS 0x00006410 | |
| 107 | +#define CS35L41_OVERTEMP_CFG 0x00006414 | |
| 108 | +#define CS35L41_AMP_ERR_VOL 0x00006418 | |
| 109 | +#define CS35L41_VOL_STATUS_TO_DSP 0x00006450 | |
| 110 | +#define CS35L41_CLASSH_CFG 0x00006800 | |
| 111 | +#define CS35L41_WKFET_CFG 0x00006804 | |
| 112 | +#define CS35L41_NG_CFG 0x00006808 | |
| 113 | +#define CS35L41_AMP_GAIN_CTRL 0x00006C04 | |
| 114 | +#define CS35L41_DAC_MSM_CFG 0x00007400 | |
| 115 | +#define CS35L41_IRQ1_CFG 0x00010000 | |
| 116 | +#define CS35L41_IRQ1_STATUS 0x00010004 | |
| 117 | +#define CS35L41_IRQ1_STATUS1 0x00010010 | |
| 118 | +#define CS35L41_IRQ1_STATUS2 0x00010014 | |
| 119 | +#define CS35L41_IRQ1_STATUS3 0x00010018 | |
| 120 | +#define CS35L41_IRQ1_STATUS4 0x0001001C | |
| 121 | +#define CS35L41_IRQ1_RAW_STATUS1 0x00010090 | |
| 122 | +#define CS35L41_IRQ1_RAW_STATUS2 0x00010094 | |
| 123 | +#define CS35L41_IRQ1_RAW_STATUS3 0x00010098 | |
| 124 | +#define CS35L41_IRQ1_RAW_STATUS4 0x0001009C | |
| 125 | +#define CS35L41_IRQ1_MASK1 0x00010110 | |
| 126 | +#define CS35L41_IRQ1_MASK2 0x00010114 | |
| 127 | +#define CS35L41_IRQ1_MASK3 0x00010118 | |
| 128 | +#define CS35L41_IRQ1_MASK4 0x0001011C | |
| 129 | +#define CS35L41_IRQ1_FRC1 0x00010190 | |
| 130 | +#define CS35L41_IRQ1_FRC2 0x00010194 | |
| 131 | +#define CS35L41_IRQ1_FRC3 0x00010198 | |
| 132 | +#define CS35L41_IRQ1_FRC4 0x0001019C | |
| 133 | +#define CS35L41_IRQ1_EDGE1 0x00010210 | |
| 134 | +#define CS35L41_IRQ1_EDGE4 0x0001021C | |
| 135 | +#define CS35L41_IRQ1_POL1 0x00010290 | |
| 136 | +#define CS35L41_IRQ1_POL2 0x00010294 | |
| 137 | +#define CS35L41_IRQ1_POL3 0x00010298 | |
| 138 | +#define CS35L41_IRQ1_POL4 0x0001029C | |
| 139 | +#define CS35L41_IRQ1_DB3 0x00010318 | |
| 140 | +#define CS35L41_IRQ2_CFG 0x00010800 | |
| 141 | +#define CS35L41_IRQ2_STATUS 0x00010804 | |
| 142 | +#define CS35L41_IRQ2_STATUS1 0x00010810 | |
| 143 | +#define CS35L41_IRQ2_STATUS2 0x00010814 | |
| 144 | +#define CS35L41_IRQ2_STATUS3 0x00010818 | |
| 145 | +#define CS35L41_IRQ2_STATUS4 0x0001081C | |
| 146 | +#define CS35L41_IRQ2_RAW_STATUS1 0x00010890 | |
| 147 | +#define CS35L41_IRQ2_RAW_STATUS2 0x00010894 | |
| 148 | +#define CS35L41_IRQ2_RAW_STATUS3 0x00010898 | |
| 149 | +#define CS35L41_IRQ2_RAW_STATUS4 0x0001089C | |
| 150 | +#define CS35L41_IRQ2_MASK1 0x00010910 | |
| 151 | +#define CS35L41_IRQ2_MASK2 0x00010914 | |
| 152 | +#define CS35L41_IRQ2_MASK3 0x00010918 | |
| 153 | +#define CS35L41_IRQ2_MASK4 0x0001091C | |
| 154 | +#define CS35L41_IRQ2_FRC1 0x00010990 | |
| 155 | +#define CS35L41_IRQ2_FRC2 0x00010994 | |
| 156 | +#define CS35L41_IRQ2_FRC3 0x00010998 | |
| 157 | +#define CS35L41_IRQ2_FRC4 0x0001099C | |
| 158 | +#define CS35L41_IRQ2_EDGE1 0x00010A10 | |
| 159 | +#define CS35L41_IRQ2_EDGE4 0x00010A1C | |
| 160 | +#define CS35L41_IRQ2_POL1 0x00010A90 | |
| 161 | +#define CS35L41_IRQ2_POL2 0x00010A94 | |
| 162 | +#define CS35L41_IRQ2_POL3 0x00010A98 | |
| 163 | +#define CS35L41_IRQ2_POL4 0x00010A9C | |
| 164 | +#define CS35L41_IRQ2_DB3 0x00010B18 | |
| 165 | +#define CS35L41_GPIO_STATUS1 0x00011000 | |
| 166 | +#define CS35L41_GPIO1_CTRL1 0x00011008 | |
| 167 | +#define CS35L41_GPIO2_CTRL1 0x0001100C | |
| 168 | +#define CS35L41_MIXER_NGATE_CFG 0x00012000 | |
| 169 | +#define CS35L41_MIXER_NGATE_CH1_CFG 0x00012004 | |
| 170 | +#define CS35L41_MIXER_NGATE_CH2_CFG 0x00012008 | |
| 171 | +#define CS35L41_DSP_MBOX_1 0x00013000 | |
| 172 | +#define CS35L41_DSP_MBOX_2 0x00013004 | |
| 173 | +#define CS35L41_DSP_MBOX_3 0x00013008 | |
| 174 | +#define CS35L41_DSP_MBOX_4 0x0001300C | |
| 175 | +#define CS35L41_DSP_MBOX_5 0x00013010 | |
| 176 | +#define CS35L41_DSP_MBOX_6 0x00013014 | |
| 177 | +#define CS35L41_DSP_MBOX_7 0x00013018 | |
| 178 | +#define CS35L41_DSP_MBOX_8 0x0001301C | |
| 179 | +#define CS35L41_DSP_VIRT1_MBOX_1 0x00013020 | |
| 180 | +#define CS35L41_DSP_VIRT1_MBOX_2 0x00013024 | |
| 181 | +#define CS35L41_DSP_VIRT1_MBOX_3 0x00013028 | |
| 182 | +#define CS35L41_DSP_VIRT1_MBOX_4 0x0001302C | |
| 183 | +#define CS35L41_DSP_VIRT1_MBOX_5 0x00013030 | |
| 184 | +#define CS35L41_DSP_VIRT1_MBOX_6 0x00013034 | |
| 185 | +#define CS35L41_DSP_VIRT1_MBOX_7 0x00013038 | |
| 186 | +#define CS35L41_DSP_VIRT1_MBOX_8 0x0001303C | |
| 187 | +#define CS35L41_DSP_VIRT2_MBOX_1 0x00013040 | |
| 188 | +#define CS35L41_DSP_VIRT2_MBOX_2 0x00013044 | |
| 189 | +#define CS35L41_DSP_VIRT2_MBOX_3 0x00013048 | |
| 190 | +#define CS35L41_DSP_VIRT2_MBOX_4 0x0001304C | |
| 191 | +#define CS35L41_DSP_VIRT2_MBOX_5 0x00013050 | |
| 192 | +#define CS35L41_DSP_VIRT2_MBOX_6 0x00013054 | |
| 193 | +#define CS35L41_DSP_VIRT2_MBOX_7 0x00013058 | |
| 194 | +#define CS35L41_DSP_VIRT2_MBOX_8 0x0001305C | |
| 195 | +#define CS35L41_CLOCK_DETECT_1 0x00014000 | |
| 196 | +#define CS35L41_TIMER1_CONTROL 0x00015000 | |
| 197 | +#define CS35L41_TIMER1_COUNT_PRESET 0x00015004 | |
| 198 | +#define CS35L41_TIMER1_START_STOP 0x0001500C | |
| 199 | +#define CS35L41_TIMER1_STATUS 0x00015010 | |
| 200 | +#define CS35L41_TIMER1_COUNT_READBACK 0x00015014 | |
| 201 | +#define CS35L41_TIMER1_DSP_CLK_CFG 0x00015018 | |
| 202 | +#define CS35L41_TIMER1_DSP_CLK_STATUS 0x0001501C | |
| 203 | +#define CS35L41_TIMER2_CONTROL 0x00015100 | |
| 204 | +#define CS35L41_TIMER2_COUNT_PRESET 0x00015104 | |
| 205 | +#define CS35L41_TIMER2_START_STOP 0x0001510C | |
| 206 | +#define CS35L41_TIMER2_STATUS 0x00015110 | |
| 207 | +#define CS35L41_TIMER2_COUNT_READBACK 0x00015114 | |
| 208 | +#define CS35L41_TIMER2_DSP_CLK_CFG 0x00015118 | |
| 209 | +#define CS35L41_TIMER2_DSP_CLK_STATUS 0x0001511C | |
| 210 | +#define CS35L41_DFT_JTAG_CONTROL 0x00016000 | |
| 211 | +#define CS35L41_DIE_STS1 0x00017040 | |
| 212 | +#define CS35L41_DIE_STS2 0x00017044 | |
| 213 | +#define CS35L41_TEMP_CAL1 0x00017048 | |
| 214 | +#define CS35L41_TEMP_CAL2 0x0001704C | |
| 215 | +#define CS35L41_DSP1_XMEM_PACK_0 0x02000000 | |
| 216 | +#define CS35L41_DSP1_XMEM_PACK_3068 0x02002FF0 | |
| 217 | +#define CS35L41_DSP1_XMEM_UNPACK32_0 0x02400000 | |
| 218 | +#define CS35L41_DSP1_XMEM_UNPACK32_2046 0x02401FF8 | |
| 219 | +#define CS35L41_DSP1_TIMESTAMP_COUNT 0x025C0800 | |
| 220 | +#define CS35L41_DSP1_SYS_ID 0x025E0000 | |
| 221 | +#define CS35L41_DSP1_SYS_VERSION 0x025E0004 | |
| 222 | +#define CS35L41_DSP1_SYS_CORE_ID 0x025E0008 | |
| 223 | +#define CS35L41_DSP1_SYS_AHB_ADDR 0x025E000C | |
| 224 | +#define CS35L41_DSP1_SYS_XSRAM_SIZE 0x025E0010 | |
| 225 | +#define CS35L41_DSP1_SYS_YSRAM_SIZE 0x025E0018 | |
| 226 | +#define CS35L41_DSP1_SYS_PSRAM_SIZE 0x025E0020 | |
| 227 | +#define CS35L41_DSP1_SYS_PM_BOOT_SIZE 0x025E0028 | |
| 228 | +#define CS35L41_DSP1_SYS_FEATURES 0x025E002C | |
| 229 | +#define CS35L41_DSP1_SYS_FIR_FILTERS 0x025E0030 | |
| 230 | +#define CS35L41_DSP1_SYS_LMS_FILTERS 0x025E0034 | |
| 231 | +#define CS35L41_DSP1_SYS_XM_BANK_SIZE 0x025E0038 | |
| 232 | +#define CS35L41_DSP1_SYS_YM_BANK_SIZE 0x025E003C | |
| 233 | +#define CS35L41_DSP1_SYS_PM_BANK_SIZE 0x025E0040 | |
| 234 | +#define CS35L41_DSP1_AHBM_WIN0_CTRL0 0x025E2000 | |
| 235 | +#define CS35L41_DSP1_AHBM_WIN0_CTRL1 0x025E2004 | |
| 236 | +#define CS35L41_DSP1_AHBM_WIN1_CTRL0 0x025E2008 | |
| 237 | +#define CS35L41_DSP1_AHBM_WIN1_CTRL1 0x025E200C | |
| 238 | +#define CS35L41_DSP1_AHBM_WIN2_CTRL0 0x025E2010 | |
| 239 | +#define CS35L41_DSP1_AHBM_WIN2_CTRL1 0x025E2014 | |
| 240 | +#define CS35L41_DSP1_AHBM_WIN3_CTRL0 0x025E2018 | |
| 241 | +#define CS35L41_DSP1_AHBM_WIN3_CTRL1 0x025E201C | |
| 242 | +#define CS35L41_DSP1_AHBM_WIN4_CTRL0 0x025E2020 | |
| 243 | +#define CS35L41_DSP1_AHBM_WIN4_CTRL1 0x025E2024 | |
| 244 | +#define CS35L41_DSP1_AHBM_WIN5_CTRL0 0x025E2028 | |
| 245 | +#define CS35L41_DSP1_AHBM_WIN5_CTRL1 0x025E202C | |
| 246 | +#define CS35L41_DSP1_AHBM_WIN6_CTRL0 0x025E2030 | |
| 247 | +#define CS35L41_DSP1_AHBM_WIN6_CTRL1 0x025E2034 | |
| 248 | +#define CS35L41_DSP1_AHBM_WIN7_CTRL0 0x025E2038 | |
| 249 | +#define CS35L41_DSP1_AHBM_WIN7_CTRL1 0x025E203C | |
| 250 | +#define CS35L41_DSP1_AHBM_WIN_DBG_CTRL0 0x025E2040 | |
| 251 | +#define CS35L41_DSP1_AHBM_WIN_DBG_CTRL1 0x025E2044 | |
| 252 | +#define CS35L41_DSP1_XMEM_UNPACK24_0 0x02800000 | |
| 253 | +#define CS35L41_DSP1_XMEM_UNPACK24_4093 0x02803FF4 | |
| 254 | +#define CS35L41_DSP1_CTRL_BASE 0x02B80000 | |
| 255 | +#define CS35L41_DSP1_CORE_SOFT_RESET 0x02B80010 | |
| 256 | +#define CS35L41_DSP1_DEBUG 0x02B80040 | |
| 257 | +#define CS35L41_DSP1_TIMER_CTRL 0x02B80048 | |
| 258 | +#define CS35L41_DSP1_STREAM_ARB_CTRL 0x02B80050 | |
| 259 | +#define CS35L41_DSP1_RX1_RATE 0x02B80080 | |
| 260 | +#define CS35L41_DSP1_RX2_RATE 0x02B80088 | |
| 261 | +#define CS35L41_DSP1_RX3_RATE 0x02B80090 | |
| 262 | +#define CS35L41_DSP1_RX4_RATE 0x02B80098 | |
| 263 | +#define CS35L41_DSP1_RX5_RATE 0x02B800A0 | |
| 264 | +#define CS35L41_DSP1_RX6_RATE 0x02B800A8 | |
| 265 | +#define CS35L41_DSP1_RX7_RATE 0x02B800B0 | |
| 266 | +#define CS35L41_DSP1_RX8_RATE 0x02B800B8 | |
| 267 | +#define CS35L41_DSP1_TX1_RATE 0x02B80280 | |
| 268 | +#define CS35L41_DSP1_TX2_RATE 0x02B80288 | |
| 269 | +#define CS35L41_DSP1_TX3_RATE 0x02B80290 | |
| 270 | +#define CS35L41_DSP1_TX4_RATE 0x02B80298 | |
| 271 | +#define CS35L41_DSP1_TX5_RATE 0x02B802A0 | |
| 272 | +#define CS35L41_DSP1_TX6_RATE 0x02B802A8 | |
| 273 | +#define CS35L41_DSP1_TX7_RATE 0x02B802B0 | |
| 274 | +#define CS35L41_DSP1_TX8_RATE 0x02B802B8 | |
| 275 | +#define CS35L41_DSP1_NMI_CTRL1 0x02B80480 | |
| 276 | +#define CS35L41_DSP1_NMI_CTRL2 0x02B80488 | |
| 277 | +#define CS35L41_DSP1_NMI_CTRL3 0x02B80490 | |
| 278 | +#define CS35L41_DSP1_NMI_CTRL4 0x02B80498 | |
| 279 | +#define CS35L41_DSP1_NMI_CTRL5 0x02B804A0 | |
| 280 | +#define CS35L41_DSP1_NMI_CTRL6 0x02B804A8 | |
| 281 | +#define CS35L41_DSP1_NMI_CTRL7 0x02B804B0 | |
| 282 | +#define CS35L41_DSP1_NMI_CTRL8 0x02B804B8 | |
| 283 | +#define CS35L41_DSP1_RESUME_CTRL 0x02B80500 | |
| 284 | +#define CS35L41_DSP1_IRQ1_CTRL 0x02B80508 | |
| 285 | +#define CS35L41_DSP1_IRQ2_CTRL 0x02B80510 | |
| 286 | +#define CS35L41_DSP1_IRQ3_CTRL 0x02B80518 | |
| 287 | +#define CS35L41_DSP1_IRQ4_CTRL 0x02B80520 | |
| 288 | +#define CS35L41_DSP1_IRQ5_CTRL 0x02B80528 | |
| 289 | +#define CS35L41_DSP1_IRQ6_CTRL 0x02B80530 | |
| 290 | +#define CS35L41_DSP1_IRQ7_CTRL 0x02B80538 | |
| 291 | +#define CS35L41_DSP1_IRQ8_CTRL 0x02B80540 | |
| 292 | +#define CS35L41_DSP1_IRQ9_CTRL 0x02B80548 | |
| 293 | +#define CS35L41_DSP1_IRQ10_CTRL 0x02B80550 | |
| 294 | +#define CS35L41_DSP1_IRQ11_CTRL 0x02B80558 | |
| 295 | +#define CS35L41_DSP1_IRQ12_CTRL 0x02B80560 | |
| 296 | +#define CS35L41_DSP1_IRQ13_CTRL 0x02B80568 | |
| 297 | +#define CS35L41_DSP1_IRQ14_CTRL 0x02B80570 | |
| 298 | +#define CS35L41_DSP1_IRQ15_CTRL 0x02B80578 | |
| 299 | +#define CS35L41_DSP1_IRQ16_CTRL 0x02B80580 | |
| 300 | +#define CS35L41_DSP1_IRQ17_CTRL 0x02B80588 | |
| 301 | +#define CS35L41_DSP1_IRQ18_CTRL 0x02B80590 | |
| 302 | +#define CS35L41_DSP1_IRQ19_CTRL 0x02B80598 | |
| 303 | +#define CS35L41_DSP1_IRQ20_CTRL 0x02B805A0 | |
| 304 | +#define CS35L41_DSP1_IRQ21_CTRL 0x02B805A8 | |
| 305 | +#define CS35L41_DSP1_IRQ22_CTRL 0x02B805B0 | |
| 306 | +#define CS35L41_DSP1_IRQ23_CTRL 0x02B805B8 | |
| 307 | +#define CS35L41_DSP1_SCRATCH1 0x02B805C0 | |
| 308 | +#define CS35L41_DSP1_SCRATCH2 0x02B805C8 | |
| 309 | +#define CS35L41_DSP1_SCRATCH3 0x02B805D0 | |
| 310 | +#define CS35L41_DSP1_SCRATCH4 0x02B805D8 | |
| 311 | +#define CS35L41_DSP1_CCM_CORE_CTRL 0x02BC1000 | |
| 312 | +#define CS35L41_DSP1_CCM_CLK_OVERRIDE 0x02BC1008 | |
| 313 | +#define CS35L41_DSP1_XM_MSTR_EN 0x02BC2000 | |
| 314 | +#define CS35L41_DSP1_XM_CORE_PRI 0x02BC2008 | |
| 315 | +#define CS35L41_DSP1_XM_AHB_PACK_PL_PRI 0x02BC2010 | |
| 316 | +#define CS35L41_DSP1_XM_AHB_UP_PL_PRI 0x02BC2018 | |
| 317 | +#define CS35L41_DSP1_XM_ACCEL_PL0_PRI 0x02BC2020 | |
| 318 | +#define CS35L41_DSP1_XM_NPL0_PRI 0x02BC2078 | |
| 319 | +#define CS35L41_DSP1_YM_MSTR_EN 0x02BC20C0 | |
| 320 | +#define CS35L41_DSP1_YM_CORE_PRI 0x02BC20C8 | |
| 321 | +#define CS35L41_DSP1_YM_AHB_PACK_PL_PRI 0x02BC20D0 | |
| 322 | +#define CS35L41_DSP1_YM_AHB_UP_PL_PRI 0x02BC20D8 | |
| 323 | +#define CS35L41_DSP1_YM_ACCEL_PL0_PRI 0x02BC20E0 | |
| 324 | +#define CS35L41_DSP1_YM_NPL0_PRI 0x02BC2138 | |
| 325 | +#define CS35L41_DSP1_PM_MSTR_EN 0x02BC2180 | |
| 326 | +#define CS35L41_DSP1_PM_PATCH0_ADDR 0x02BC2188 | |
| 327 | +#define CS35L41_DSP1_PM_PATCH0_EN 0x02BC218C | |
| 328 | +#define CS35L41_DSP1_PM_PATCH0_DATA_LO 0x02BC2190 | |
| 329 | +#define CS35L41_DSP1_PM_PATCH0_DATA_HI 0x02BC2194 | |
| 330 | +#define CS35L41_DSP1_PM_PATCH1_ADDR 0x02BC2198 | |
| 331 | +#define CS35L41_DSP1_PM_PATCH1_EN 0x02BC219C | |
| 332 | +#define CS35L41_DSP1_PM_PATCH1_DATA_LO 0x02BC21A0 | |
| 333 | +#define CS35L41_DSP1_PM_PATCH1_DATA_HI 0x02BC21A4 | |
| 334 | +#define CS35L41_DSP1_PM_PATCH2_ADDR 0x02BC21A8 | |
| 335 | +#define CS35L41_DSP1_PM_PATCH2_EN 0x02BC21AC | |
| 336 | +#define CS35L41_DSP1_PM_PATCH2_DATA_LO 0x02BC21B0 | |
| 337 | +#define CS35L41_DSP1_PM_PATCH2_DATA_HI 0x02BC21B4 | |
| 338 | +#define CS35L41_DSP1_PM_PATCH3_ADDR 0x02BC21B8 | |
| 339 | +#define CS35L41_DSP1_PM_PATCH3_EN 0x02BC21BC | |
| 340 | +#define CS35L41_DSP1_PM_PATCH3_DATA_LO 0x02BC21C0 | |
| 341 | +#define CS35L41_DSP1_PM_PATCH3_DATA_HI 0x02BC21C4 | |
| 342 | +#define CS35L41_DSP1_PM_PATCH4_ADDR 0x02BC21C8 | |
| 343 | +#define CS35L41_DSP1_PM_PATCH4_EN 0x02BC21CC | |
| 344 | +#define CS35L41_DSP1_PM_PATCH4_DATA_LO 0x02BC21D0 | |
| 345 | +#define CS35L41_DSP1_PM_PATCH4_DATA_HI 0x02BC21D4 | |
| 346 | +#define CS35L41_DSP1_PM_PATCH5_ADDR 0x02BC21D8 | |
| 347 | +#define CS35L41_DSP1_PM_PATCH5_EN 0x02BC21DC | |
| 348 | +#define CS35L41_DSP1_PM_PATCH5_DATA_LO 0x02BC21E0 | |
| 349 | +#define CS35L41_DSP1_PM_PATCH5_DATA_HI 0x02BC21E4 | |
| 350 | +#define CS35L41_DSP1_PM_PATCH6_ADDR 0x02BC21E8 | |
| 351 | +#define CS35L41_DSP1_PM_PATCH6_EN 0x02BC21EC | |
| 352 | +#define CS35L41_DSP1_PM_PATCH6_DATA_LO 0x02BC21F0 | |
| 353 | +#define CS35L41_DSP1_PM_PATCH6_DATA_HI 0x02BC21F4 | |
| 354 | +#define CS35L41_DSP1_PM_PATCH7_ADDR 0x02BC21F8 | |
| 355 | +#define CS35L41_DSP1_PM_PATCH7_EN 0x02BC21FC | |
| 356 | +#define CS35L41_DSP1_PM_PATCH7_DATA_LO 0x02BC2200 | |
| 357 | +#define CS35L41_DSP1_PM_PATCH7_DATA_HI 0x02BC2204 | |
| 358 | +#define CS35L41_DSP1_MPU_XM_ACCESS0 0x02BC3000 | |
| 359 | +#define CS35L41_DSP1_MPU_YM_ACCESS0 0x02BC3004 | |
| 360 | +#define CS35L41_DSP1_MPU_WNDW_ACCESS0 0x02BC3008 | |
| 361 | +#define CS35L41_DSP1_MPU_XREG_ACCESS0 0x02BC300C | |
| 362 | +#define CS35L41_DSP1_MPU_YREG_ACCESS0 0x02BC3014 | |
| 363 | +#define CS35L41_DSP1_MPU_XM_ACCESS1 0x02BC3018 | |
| 364 | +#define CS35L41_DSP1_MPU_YM_ACCESS1 0x02BC301C | |
| 365 | +#define CS35L41_DSP1_MPU_WNDW_ACCESS1 0x02BC3020 | |
| 366 | +#define CS35L41_DSP1_MPU_XREG_ACCESS1 0x02BC3024 | |
| 367 | +#define CS35L41_DSP1_MPU_YREG_ACCESS1 0x02BC302C | |
| 368 | +#define CS35L41_DSP1_MPU_XM_ACCESS2 0x02BC3030 | |
| 369 | +#define CS35L41_DSP1_MPU_YM_ACCESS2 0x02BC3034 | |
| 370 | +#define CS35L41_DSP1_MPU_WNDW_ACCESS2 0x02BC3038 | |
| 371 | +#define CS35L41_DSP1_MPU_XREG_ACCESS2 0x02BC303C | |
| 372 | +#define CS35L41_DSP1_MPU_YREG_ACCESS2 0x02BC3044 | |
| 373 | +#define CS35L41_DSP1_MPU_XM_ACCESS3 0x02BC3048 | |
| 374 | +#define CS35L41_DSP1_MPU_YM_ACCESS3 0x02BC304C | |
| 375 | +#define CS35L41_DSP1_MPU_WNDW_ACCESS3 0x02BC3050 | |
| 376 | +#define CS35L41_DSP1_MPU_XREG_ACCESS3 0x02BC3054 | |
| 377 | +#define CS35L41_DSP1_MPU_YREG_ACCESS3 0x02BC305C | |
| 378 | +#define CS35L41_DSP1_MPU_XM_VIO_ADDR 0x02BC3100 | |
| 379 | +#define CS35L41_DSP1_MPU_XM_VIO_STATUS 0x02BC3104 | |
| 380 | +#define CS35L41_DSP1_MPU_YM_VIO_ADDR 0x02BC3108 | |
| 381 | +#define CS35L41_DSP1_MPU_YM_VIO_STATUS 0x02BC310C | |
| 382 | +#define CS35L41_DSP1_MPU_PM_VIO_ADDR 0x02BC3110 | |
| 383 | +#define CS35L41_DSP1_MPU_PM_VIO_STATUS 0x02BC3114 | |
| 384 | +#define CS35L41_DSP1_MPU_LOCK_CONFIG 0x02BC3140 | |
| 385 | +#define CS35L41_DSP1_MPU_WDT_RST_CTRL 0x02BC3180 | |
| 386 | +#define CS35L41_DSP1_STRMARB_MSTR0_CFG0 0x02BC5000 | |
| 387 | +#define CS35L41_DSP1_STRMARB_MSTR0_CFG1 0x02BC5004 | |
| 388 | +#define CS35L41_DSP1_STRMARB_MSTR0_CFG2 0x02BC5008 | |
| 389 | +#define CS35L41_DSP1_STRMARB_MSTR1_CFG0 0x02BC5010 | |
| 390 | +#define CS35L41_DSP1_STRMARB_MSTR1_CFG1 0x02BC5014 | |
| 391 | +#define CS35L41_DSP1_STRMARB_MSTR1_CFG2 0x02BC5018 | |
| 392 | +#define CS35L41_DSP1_STRMARB_MSTR2_CFG0 0x02BC5020 | |
| 393 | +#define CS35L41_DSP1_STRMARB_MSTR2_CFG1 0x02BC5024 | |
| 394 | +#define CS35L41_DSP1_STRMARB_MSTR2_CFG2 0x02BC5028 | |
| 395 | +#define CS35L41_DSP1_STRMARB_MSTR3_CFG0 0x02BC5030 | |
| 396 | +#define CS35L41_DSP1_STRMARB_MSTR3_CFG1 0x02BC5034 | |
| 397 | +#define CS35L41_DSP1_STRMARB_MSTR3_CFG2 0x02BC5038 | |
| 398 | +#define CS35L41_DSP1_STRMARB_MSTR4_CFG0 0x02BC5040 | |
| 399 | +#define CS35L41_DSP1_STRMARB_MSTR4_CFG1 0x02BC5044 | |
| 400 | +#define CS35L41_DSP1_STRMARB_MSTR4_CFG2 0x02BC5048 | |
| 401 | +#define CS35L41_DSP1_STRMARB_MSTR5_CFG0 0x02BC5050 | |
| 402 | +#define CS35L41_DSP1_STRMARB_MSTR5_CFG1 0x02BC5054 | |
| 403 | +#define CS35L41_DSP1_STRMARB_MSTR5_CFG2 0x02BC5058 | |
| 404 | +#define CS35L41_DSP1_STRMARB_MSTR6_CFG0 0x02BC5060 | |
| 405 | +#define CS35L41_DSP1_STRMARB_MSTR6_CFG1 0x02BC5064 | |
| 406 | +#define CS35L41_DSP1_STRMARB_MSTR6_CFG2 0x02BC5068 | |
| 407 | +#define CS35L41_DSP1_STRMARB_MSTR7_CFG0 0x02BC5070 | |
| 408 | +#define CS35L41_DSP1_STRMARB_MSTR7_CFG1 0x02BC5074 | |
| 409 | +#define CS35L41_DSP1_STRMARB_MSTR7_CFG2 0x02BC5078 | |
| 410 | +#define CS35L41_DSP1_STRMARB_TX0_CFG0 0x02BC5200 | |
| 411 | +#define CS35L41_DSP1_STRMARB_TX0_CFG1 0x02BC5204 | |
| 412 | +#define CS35L41_DSP1_STRMARB_TX1_CFG0 0x02BC5208 | |
| 413 | +#define CS35L41_DSP1_STRMARB_TX1_CFG1 0x02BC520C | |
| 414 | +#define CS35L41_DSP1_STRMARB_TX2_CFG0 0x02BC5210 | |
| 415 | +#define CS35L41_DSP1_STRMARB_TX2_CFG1 0x02BC5214 | |
| 416 | +#define CS35L41_DSP1_STRMARB_TX3_CFG0 0x02BC5218 | |
| 417 | +#define CS35L41_DSP1_STRMARB_TX3_CFG1 0x02BC521C | |
| 418 | +#define CS35L41_DSP1_STRMARB_TX4_CFG0 0x02BC5220 | |
| 419 | +#define CS35L41_DSP1_STRMARB_TX4_CFG1 0x02BC5224 | |
| 420 | +#define CS35L41_DSP1_STRMARB_TX5_CFG0 0x02BC5228 | |
| 421 | +#define CS35L41_DSP1_STRMARB_TX5_CFG1 0x02BC522C | |
| 422 | +#define CS35L41_DSP1_STRMARB_TX6_CFG0 0x02BC5230 | |
| 423 | +#define CS35L41_DSP1_STRMARB_TX6_CFG1 0x02BC5234 | |
| 424 | +#define CS35L41_DSP1_STRMARB_TX7_CFG0 0x02BC5238 | |
| 425 | +#define CS35L41_DSP1_STRMARB_TX7_CFG1 0x02BC523C | |
| 426 | +#define CS35L41_DSP1_STRMARB_RX0_CFG0 0x02BC5400 | |
| 427 | +#define CS35L41_DSP1_STRMARB_RX0_CFG1 0x02BC5404 | |
| 428 | +#define CS35L41_DSP1_STRMARB_RX1_CFG0 0x02BC5408 | |
| 429 | +#define CS35L41_DSP1_STRMARB_RX1_CFG1 0x02BC540C | |
| 430 | +#define CS35L41_DSP1_STRMARB_RX2_CFG0 0x02BC5410 | |
| 431 | +#define CS35L41_DSP1_STRMARB_RX2_CFG1 0x02BC5414 | |
| 432 | +#define CS35L41_DSP1_STRMARB_RX3_CFG0 0x02BC5418 | |
| 433 | +#define CS35L41_DSP1_STRMARB_RX3_CFG1 0x02BC541C | |
| 434 | +#define CS35L41_DSP1_STRMARB_RX4_CFG0 0x02BC5420 | |
| 435 | +#define CS35L41_DSP1_STRMARB_RX4_CFG1 0x02BC5424 | |
| 436 | +#define CS35L41_DSP1_STRMARB_RX5_CFG0 0x02BC5428 | |
| 437 | +#define CS35L41_DSP1_STRMARB_RX5_CFG1 0x02BC542C | |
| 438 | +#define CS35L41_DSP1_STRMARB_RX6_CFG0 0x02BC5430 | |
| 439 | +#define CS35L41_DSP1_STRMARB_RX6_CFG1 0x02BC5434 | |
| 440 | +#define CS35L41_DSP1_STRMARB_RX7_CFG0 0x02BC5438 | |
| 441 | +#define CS35L41_DSP1_STRMARB_RX7_CFG1 0x02BC543C | |
| 442 | +#define CS35L41_DSP1_STRMARB_IRQ0_CFG0 0x02BC5600 | |
| 443 | +#define CS35L41_DSP1_STRMARB_IRQ0_CFG1 0x02BC5604 | |
| 444 | +#define CS35L41_DSP1_STRMARB_IRQ0_CFG2 0x02BC5608 | |
| 445 | +#define CS35L41_DSP1_STRMARB_IRQ1_CFG0 0x02BC5610 | |
| 446 | +#define CS35L41_DSP1_STRMARB_IRQ1_CFG1 0x02BC5614 | |
| 447 | +#define CS35L41_DSP1_STRMARB_IRQ1_CFG2 0x02BC5618 | |
| 448 | +#define CS35L41_DSP1_STRMARB_IRQ2_CFG0 0x02BC5620 | |
| 449 | +#define CS35L41_DSP1_STRMARB_IRQ2_CFG1 0x02BC5624 | |
| 450 | +#define CS35L41_DSP1_STRMARB_IRQ2_CFG2 0x02BC5628 | |
| 451 | +#define CS35L41_DSP1_STRMARB_IRQ3_CFG0 0x02BC5630 | |
| 452 | +#define CS35L41_DSP1_STRMARB_IRQ3_CFG1 0x02BC5634 | |
| 453 | +#define CS35L41_DSP1_STRMARB_IRQ3_CFG2 0x02BC5638 | |
| 454 | +#define CS35L41_DSP1_STRMARB_IRQ4_CFG0 0x02BC5640 | |
| 455 | +#define CS35L41_DSP1_STRMARB_IRQ4_CFG1 0x02BC5644 | |
| 456 | +#define CS35L41_DSP1_STRMARB_IRQ4_CFG2 0x02BC5648 | |
| 457 | +#define CS35L41_DSP1_STRMARB_IRQ5_CFG0 0x02BC5650 | |
| 458 | +#define CS35L41_DSP1_STRMARB_IRQ5_CFG1 0x02BC5654 | |
| 459 | +#define CS35L41_DSP1_STRMARB_IRQ5_CFG2 0x02BC5658 | |
| 460 | +#define CS35L41_DSP1_STRMARB_IRQ6_CFG0 0x02BC5660 | |
| 461 | +#define CS35L41_DSP1_STRMARB_IRQ6_CFG1 0x02BC5664 | |
| 462 | +#define CS35L41_DSP1_STRMARB_IRQ6_CFG2 0x02BC5668 | |
| 463 | +#define CS35L41_DSP1_STRMARB_IRQ7_CFG0 0x02BC5670 | |
| 464 | +#define CS35L41_DSP1_STRMARB_IRQ7_CFG1 0x02BC5674 | |
| 465 | +#define CS35L41_DSP1_STRMARB_IRQ7_CFG2 0x02BC5678 | |
| 466 | +#define CS35L41_DSP1_STRMARB_RESYNC_MSK 0x02BC5A00 | |
| 467 | +#define CS35L41_DSP1_STRMARB_ERR_STATUS 0x02BC5A08 | |
| 468 | +#define CS35L41_DSP1_INTPCTL_RES_STATIC 0x02BC6000 | |
| 469 | +#define CS35L41_DSP1_INTPCTL_RES_DYN 0x02BC6004 | |
| 470 | +#define CS35L41_DSP1_INTPCTL_NMI_CTRL 0x02BC6008 | |
| 471 | +#define CS35L41_DSP1_INTPCTL_IRQ_INV 0x02BC6010 | |
| 472 | +#define CS35L41_DSP1_INTPCTL_IRQ_MODE 0x02BC6014 | |
| 473 | +#define CS35L41_DSP1_INTPCTL_IRQ_EN 0x02BC6018 | |
| 474 | +#define CS35L41_DSP1_INTPCTL_IRQ_MSK 0x02BC601C | |
| 475 | +#define CS35L41_DSP1_INTPCTL_IRQ_FLUSH 0x02BC6020 | |
| 476 | +#define CS35L41_DSP1_INTPCTL_IRQ_MSKCLR 0x02BC6024 | |
| 477 | +#define CS35L41_DSP1_INTPCTL_IRQ_FRC 0x02BC6028 | |
| 478 | +#define CS35L41_DSP1_INTPCTL_IRQ_MSKSET 0x02BC602C | |
| 479 | +#define CS35L41_DSP1_INTPCTL_IRQ_ERR 0x02BC6030 | |
| 480 | +#define CS35L41_DSP1_INTPCTL_IRQ_PEND 0x02BC6034 | |
| 481 | +#define CS35L41_DSP1_INTPCTL_IRQ_GEN 0x02BC6038 | |
| 482 | +#define CS35L41_DSP1_INTPCTL_TESTBITS 0x02BC6040 | |
| 483 | +#define CS35L41_DSP1_WDT_CONTROL 0x02BC7000 | |
| 484 | +#define CS35L41_DSP1_WDT_STATUS 0x02BC7008 | |
| 485 | +#define CS35L41_DSP1_YMEM_PACK_0 0x02C00000 | |
| 486 | +#define CS35L41_DSP1_YMEM_PACK_1532 0x02C017F0 | |
| 487 | +#define CS35L41_DSP1_YMEM_UNPACK32_0 0x03000000 | |
| 488 | +#define CS35L41_DSP1_YMEM_UNPACK32_1022 0x03000FF8 | |
| 489 | +#define CS35L41_DSP1_YMEM_UNPACK24_0 0x03400000 | |
| 490 | +#define CS35L41_DSP1_YMEM_UNPACK24_2045 0x03401FF4 | |
| 491 | +#define CS35L41_DSP1_PMEM_0 0x03800000 | |
| 492 | +#define CS35L41_DSP1_PMEM_5114 0x03804FE8 | |
| 493 | + | |
| 494 | +/*test regs for emulation bringup*/ | |
| 495 | +#define CS35L41_PLL_OVR 0x00003018 | |
| 496 | +#define CS35L41_BST_TEST_DUTY 0x00003900 | |
| 497 | +#define CS35L41_DIGPWM_IOCTRL 0x0000706C | |
| 498 | + | |
| 499 | +/*registers populated by OTP*/ | |
| 500 | +#define CS35L41_OTP_TRIM_1 0x0000208c | |
| 501 | +#define CS35L41_OTP_TRIM_2 0x00002090 | |
| 502 | +#define CS35L41_OTP_TRIM_3 0x00003010 | |
| 503 | +#define CS35L41_OTP_TRIM_4 0x0000300C | |
| 504 | +#define CS35L41_OTP_TRIM_5 0x0000394C | |
| 505 | +#define CS35L41_OTP_TRIM_6 0x00003950 | |
| 506 | +#define CS35L41_OTP_TRIM_7 0x00003954 | |
| 507 | +#define CS35L41_OTP_TRIM_8 0x00003958 | |
| 508 | +#define CS35L41_OTP_TRIM_9 0x0000395C | |
| 509 | +#define CS35L41_OTP_TRIM_10 0x0000416C | |
| 510 | +#define CS35L41_OTP_TRIM_11 0x00004160 | |
| 511 | +#define CS35L41_OTP_TRIM_12 0x00004170 | |
| 512 | +#define CS35L41_OTP_TRIM_13 0x00004360 | |
| 513 | +#define CS35L41_OTP_TRIM_14 0x00004448 | |
| 514 | +#define CS35L41_OTP_TRIM_15 0x0000444C | |
| 515 | +#define CS35L41_OTP_TRIM_16 0x00006E30 | |
| 516 | +#define CS35L41_OTP_TRIM_17 0x00006E34 | |
| 517 | +#define CS35L41_OTP_TRIM_18 0x00006E38 | |
| 518 | +#define CS35L41_OTP_TRIM_19 0x00006E3C | |
| 519 | +#define CS35L41_OTP_TRIM_20 0x00006E40 | |
| 520 | +#define CS35L41_OTP_TRIM_21 0x00006E44 | |
| 521 | +#define CS35L41_OTP_TRIM_22 0x00006E48 | |
| 522 | +#define CS35L41_OTP_TRIM_23 0x00006E4C | |
| 523 | +#define CS35L41_OTP_TRIM_24 0x00006E50 | |
| 524 | +#define CS35L41_OTP_TRIM_25 0x00006E54 | |
| 525 | +#define CS35L41_OTP_TRIM_26 0x00006E58 | |
| 526 | +#define CS35L41_OTP_TRIM_27 0x00006E5C | |
| 527 | +#define CS35L41_OTP_TRIM_28 0x00006E60 | |
| 528 | +#define CS35L41_OTP_TRIM_29 0x00006E64 | |
| 529 | +#define CS35L41_OTP_TRIM_30 0x00007418 | |
| 530 | +#define CS35L41_OTP_TRIM_31 0x0000741C | |
| 531 | +#define CS35L41_OTP_TRIM_32 0x00007434 | |
| 532 | +#define CS35L41_OTP_TRIM_33 0x00007068 | |
| 533 | +#define CS35L41_OTP_TRIM_34 0x0000410C | |
| 534 | +#define CS35L41_OTP_TRIM_35 0x0000400C | |
| 535 | +#define CS35L41_OTP_TRIM_36 0x00002030 | |
| 536 | + | |
| 537 | +#define CS35L41_MAX_CACHE_REG 36 | |
| 538 | +#define CS35L41_OTP_SIZE_WORDS 32 | |
| 539 | +#define CS35L41_NUM_OTP_ELEM 100 | |
| 540 | + | |
| 541 | +#define CS35L41_VALID_PDATA 0x80000000 | |
| 542 | +#define CS35L41_NUM_SUPPLIES 2 | |
| 543 | + | |
| 544 | +#define CS35L41_SCLK_MSTR_MASK 0x10 | |
| 545 | +#define CS35L41_SCLK_MSTR_SHIFT 4 | |
| 546 | +#define CS35L41_LRCLK_MSTR_MASK 0x01 | |
| 547 | +#define CS35L41_LRCLK_MSTR_SHIFT 0 | |
| 548 | +#define CS35L41_SCLK_INV_MASK 0x40 | |
| 549 | +#define CS35L41_SCLK_INV_SHIFT 6 | |
| 550 | +#define CS35L41_LRCLK_INV_MASK 0x04 | |
| 551 | +#define CS35L41_LRCLK_INV_SHIFT 2 | |
| 552 | +#define CS35L41_SCLK_FRC_MASK 0x20 | |
| 553 | +#define CS35L41_SCLK_FRC_SHIFT 5 | |
| 554 | +#define CS35L41_LRCLK_FRC_MASK 0x02 | |
| 555 | +#define CS35L41_LRCLK_FRC_SHIFT 1 | |
| 556 | + | |
| 557 | +#define CS35L41_AMP_GAIN_PCM_MASK 0x3E0 | |
| 558 | +#define CS35L41_AMP_GAIN_ZC_MASK 0x0400 | |
| 559 | +#define CS35L41_AMP_GAIN_ZC_SHIFT 10 | |
| 560 | + | |
| 561 | +#define CS35L41_BST_CTL_MASK 0xFF | |
| 562 | +#define CS35L41_BST_CTL_SEL_MASK 0x03 | |
| 563 | +#define CS35L41_BST_CTL_SEL_REG 0x00 | |
| 564 | +#define CS35L41_BST_CTL_SEL_CLASSH 0x01 | |
| 565 | +#define CS35L41_BST_IPK_MASK 0x7F | |
| 566 | +#define CS35L41_BST_IPK_SHIFT 0 | |
| 567 | +#define CS35L41_BST_LIM_MASK 0x4 | |
| 568 | +#define CS35L41_BST_LIM_SHIFT 2 | |
| 569 | +#define CS35L41_BST_K1_MASK 0x000000FF | |
| 570 | +#define CS35L41_BST_K1_SHIFT 0 | |
| 571 | +#define CS35L41_BST_K2_MASK 0x0000FF00 | |
| 572 | +#define CS35L41_BST_K2_SHIFT 8 | |
| 573 | +#define CS35L41_BST_SLOPE_MASK 0x0000FF00 | |
| 574 | +#define CS35L41_BST_SLOPE_SHIFT 8 | |
| 575 | +#define CS35L41_BST_LBST_VAL_MASK 0x00000003 | |
| 576 | +#define CS35L41_BST_LBST_VAL_SHIFT 0 | |
| 577 | + | |
| 578 | +#define CS35L41_TEMP_THLD_MASK 0x03 | |
| 579 | +#define CS35L41_VMON_IMON_VOL_MASK 0x07FF07FF | |
| 580 | +#define CS35L41_PDM_MODE_MASK 0x01 | |
| 581 | +#define CS35L41_PDM_MODE_SHIFT 0 | |
| 582 | + | |
| 583 | +#define CS35L41_CH_MEM_DEPTH_MASK 0x07 | |
| 584 | +#define CS35L41_CH_MEM_DEPTH_SHIFT 0 | |
| 585 | +#define CS35L41_CH_HDRM_CTL_MASK 0x007F0000 | |
| 586 | +#define CS35L41_CH_HDRM_CTL_SHIFT 16 | |
| 587 | +#define CS35L41_CH_REL_RATE_MASK 0xFF00 | |
| 588 | +#define CS35L41_CH_REL_RATE_SHIFT 8 | |
| 589 | +#define CS35L41_CH_WKFET_DLY_MASK 0x001C | |
| 590 | +#define CS35L41_CH_WKFET_DLY_SHIFT 2 | |
| 591 | +#define CS35L41_CH_WKFET_THLD_MASK 0x0F00 | |
| 592 | +#define CS35L41_CH_WKFET_THLD_SHIFT 8 | |
| 593 | + | |
| 594 | +#define CS35L41_HW_NG_SEL_MASK 0x3F00 | |
| 595 | +#define CS35L41_HW_NG_SEL_SHIFT 8 | |
| 596 | +#define CS35L41_HW_NG_DLY_MASK 0x0070 | |
| 597 | +#define CS35L41_HW_NG_DLY_SHIFT 4 | |
| 598 | +#define CS35L41_HW_NG_THLD_MASK 0x0007 | |
| 599 | +#define CS35L41_HW_NG_THLD_SHIFT 0 | |
| 600 | + | |
| 601 | +#define CS35L41_DSP_NG_ENABLE_MASK 0x00010000 | |
| 602 | +#define CS35L41_DSP_NG_ENABLE_SHIFT 16 | |
| 603 | +#define CS35L41_DSP_NG_THLD_MASK 0x7 | |
| 604 | +#define CS35L41_DSP_NG_THLD_SHIFT 0 | |
| 605 | +#define CS35L41_DSP_NG_DELAY_MASK 0x0F00 | |
| 606 | +#define CS35L41_DSP_NG_DELAY_SHIFT 8 | |
| 607 | + | |
| 608 | +#define CS35L41_ASP_FMT_MASK 0x0700 | |
| 609 | +#define CS35L41_ASP_FMT_SHIFT 8 | |
| 610 | +#define CS35L41_ASP_DOUT_HIZ_MASK 0x03 | |
| 611 | +#define CS35L41_ASP_DOUT_HIZ_SHIFT 0 | |
| 612 | +#define CS35L41_ASP_WIDTH_16 0x10 | |
| 613 | +#define CS35L41_ASP_WIDTH_24 0x18 | |
| 614 | +#define CS35L41_ASP_WIDTH_32 0x20 | |
| 615 | +#define CS35L41_ASP_WIDTH_TX_MASK 0xFF0000 | |
| 616 | +#define CS35L41_ASP_WIDTH_TX_SHIFT 16 | |
| 617 | +#define CS35L41_ASP_WIDTH_RX_MASK 0xFF000000 | |
| 618 | +#define CS35L41_ASP_WIDTH_RX_SHIFT 24 | |
| 619 | +#define CS35L41_ASP_RX1_SLOT_MASK 0x3F | |
| 620 | +#define CS35L41_ASP_RX1_SLOT_SHIFT 0 | |
| 621 | +#define CS35L41_ASP_RX2_SLOT_MASK 0x3F00 | |
| 622 | +#define CS35L41_ASP_RX2_SLOT_SHIFT 8 | |
| 623 | +#define CS35L41_ASP_RX_WL_MASK 0x3F | |
| 624 | +#define CS35L41_ASP_TX_WL_MASK 0x3F | |
| 625 | +#define CS35L41_ASP_RX_WL_SHIFT 0 | |
| 626 | +#define CS35L41_ASP_TX_WL_SHIFT 0 | |
| 627 | +#define CS35L41_ASP_SOURCE_MASK 0x7F | |
| 628 | + | |
| 629 | +#define CS35L41_INPUT_SRC_ASPRX1 0x08 | |
| 630 | +#define CS35L41_INPUT_SRC_ASPRX2 0x09 | |
| 631 | +#define CS35L41_INPUT_SRC_VMON 0x18 | |
| 632 | +#define CS35L41_INPUT_SRC_IMON 0x19 | |
| 633 | +#define CS35L41_INPUT_SRC_CLASSH 0x21 | |
| 634 | +#define CS35L41_INPUT_SRC_VPMON 0x28 | |
| 635 | +#define CS35L41_INPUT_SRC_VBSTMON 0x29 | |
| 636 | +#define CS35L41_INPUT_SRC_TEMPMON 0x3A | |
| 637 | +#define CS35L41_INPUT_SRC_RSVD 0x3B | |
| 638 | +#define CS35L41_INPUT_DSP_TX1 0x32 | |
| 639 | +#define CS35L41_INPUT_DSP_TX2 0x33 | |
| 640 | + | |
| 641 | +#define CS35L41_WR_PEND_STS_MASK 0x2 | |
| 642 | + | |
| 643 | +#define CS35L41_PLL_CLK_SEL_MASK 0x07 | |
| 644 | +#define CS35L41_PLL_CLK_SEL_SHIFT 0 | |
| 645 | +#define CS35L41_PLL_CLK_EN_MASK 0x10 | |
| 646 | +#define CS35L41_PLL_CLK_EN_SHIFT 4 | |
| 647 | +#define CS35L41_PLL_OPENLOOP_MASK 0x0800 | |
| 648 | +#define CS35L41_PLL_OPENLOOP_SHIFT 11 | |
| 649 | +#define CS35L41_PLLSRC_SCLK 0 | |
| 650 | +#define CS35L41_PLLSRC_LRCLK 1 | |
| 651 | +#define CS35L41_PLLSRC_SELF 3 | |
| 652 | +#define CS35L41_PLLSRC_PDMCLK 4 | |
| 653 | +#define CS35L41_PLLSRC_MCLK 5 | |
| 654 | +#define CS35L41_PLLSRC_SWIRE 7 | |
| 655 | +#define CS35L41_REFCLK_FREQ_MASK 0x7E0 | |
| 656 | +#define CS35L41_REFCLK_FREQ_SHIFT 5 | |
| 657 | + | |
| 658 | +#define CS35L41_GLOBAL_FS_MASK 0x1F | |
| 659 | +#define CS35L41_GLOBAL_FS_SHIFT 0 | |
| 660 | + | |
| 661 | +#define CS35L41_GLOBAL_EN_MASK 0x01 | |
| 662 | +#define CS35L41_GLOBAL_EN_SHIFT 0 | |
| 663 | +#define CS35L41_BST_EN_MASK 0x0030 | |
| 664 | +#define CS35L41_BST_EN_SHIFT 4 | |
| 665 | +#define CS35L41_BST_EN_DEFAULT 0x2 | |
| 666 | +#define CS35L41_AMP_EN_SHIFT 0 | |
| 667 | +#define CS35L41_AMP_EN_MASK 1 | |
| 668 | + | |
| 669 | +#define CS35L41_PDN_DONE_MASK 0x00800000 | |
| 670 | +#define CS35L41_PDN_DONE_SHIFT 23 | |
| 671 | +#define CS35L41_PUP_DONE_MASK 0x01000000 | |
| 672 | +#define CS35L41_PUP_DONE_SHIFT 24 | |
| 673 | + | |
| 674 | +#define CS35L36_PUP_DONE_IRQ_UNMASK 0x5F | |
| 675 | +#define CS35L36_PUP_DONE_IRQ_MASK 0xBF | |
| 676 | + | |
| 677 | +#define CS35L41_AMP_SHORT_ERR 0x80000000 | |
| 678 | +#define CS35L41_BST_SHORT_ERR 0x0100 | |
| 679 | +#define CS35L41_TEMP_WARN 0x8000 | |
| 680 | +#define CS35L41_TEMP_ERR 0x00020000 | |
| 681 | +#define CS35L41_BST_OVP_ERR 0x40 | |
| 682 | +#define CS35L41_BST_DCM_UVP_ERR 0x80 | |
| 683 | +#define CS35L41_OTP_BOOT_DONE 0x02 | |
| 684 | +#define CS35L41_PLL_UNLOCK 0x10 | |
| 685 | +#define CS35L41_OTP_BOOT_ERR 0x80000000 | |
| 686 | + | |
| 687 | +#define CS35L41_AMP_SHORT_ERR_RLS 0x02 | |
| 688 | +#define CS35L41_BST_SHORT_ERR_RLS 0x04 | |
| 689 | +#define CS35L41_BST_OVP_ERR_RLS 0x08 | |
| 690 | +#define CS35L41_BST_UVP_ERR_RLS 0x10 | |
| 691 | +#define CS35L41_TEMP_WARN_ERR_RLS 0x20 | |
| 692 | +#define CS35L41_TEMP_ERR_RLS 0x40 | |
| 693 | + | |
| 694 | +#define CS35L41_INT1_MASK_DEFAULT 0x7FFCFE3F | |
| 695 | +#define CS35L41_INT1_UNMASK_PUP 0xFEFFFFFF | |
| 696 | +#define CS35L41_INT1_UNMASK_PDN 0xFF7FFFFF | |
| 697 | + | |
| 698 | +#define CS35L41_GPIO_DIR_MASK 0x80000000 | |
| 699 | +#define CS35L41_GPIO_DIR_SHIFT 31 | |
| 700 | +#define CS35L41_GPIO1_CTRL_MASK 0x00030000 | |
| 701 | +#define CS35L41_GPIO1_CTRL_SHIFT 16 | |
| 702 | +#define CS35L41_GPIO2_CTRL_MASK 0x07000000 | |
| 703 | +#define CS35L41_GPIO2_CTRL_SHIFT 24 | |
| 704 | +#define CS35L41_GPIO_CTRL_OPEN_INT 2 | |
| 705 | +#define CS35L41_GPIO_CTRL_ACTV_LO 4 | |
| 706 | +#define CS35L41_GPIO_CTRL_ACTV_HI 5 | |
| 707 | +#define CS35L41_GPIO_POL_MASK 0x1000 | |
| 708 | +#define CS35L41_GPIO_POL_SHIFT 12 | |
| 709 | + | |
| 710 | +#define CS35L41_AMP_INV_PCM_SHIFT 14 | |
| 711 | +#define CS35L41_AMP_INV_PCM_MASK BIT(CS35L41_AMP_INV_PCM_SHIFT) | |
| 712 | +#define CS35L41_AMP_PCM_VOL_SHIFT 3 | |
| 713 | +#define CS35L41_AMP_PCM_VOL_MASK (0x7FF << 3) | |
| 714 | +#define CS35L41_AMP_PCM_VOL_MUTE 0x4CF | |
| 715 | + | |
| 716 | +#define CS35L41_CHIP_ID 0x35a40 | |
| 717 | +#define CS35L41R_CHIP_ID 0x35b40 | |
| 718 | +#define CS35L41_MTLREVID_MASK 0x0F | |
| 719 | +#define CS35L41_REVID_A0 0xA0 | |
| 720 | +#define CS35L41_REVID_B0 0xB0 | |
| 721 | +#define CS35L41_REVID_B2 0xB2 | |
| 722 | + | |
| 723 | +#define CS35L41_HALO_CORE_RESET 0x00000200 | |
| 724 | + | |
| 725 | +#define CS35L41_FS1_WINDOW_MASK 0x000007FF | |
| 726 | +#define CS35L41_FS2_WINDOW_MASK 0x00FFF800 | |
| 727 | +#define CS35L41_FS2_WINDOW_SHIFT 12 | |
| 728 | + | |
| 729 | +#define CS35L41_SPI_MAX_FREQ 4000000 | |
| 730 | +#define CS35L41_REGSTRIDE 4 | |
| 731 | + | |
| 13 | 732 | enum cs35l41_clk_ids { |
| 14 | 733 | CS35L41_CLKID_SCLK = 0, |
| 15 | 734 | CS35L41_CLKID_LRCLK = 1, |
| @@ -31,4 +750,31 @@ struct cs35l41_platform_data { · 15 unmodified lines | ||
| 31 | 750 | struct cs35l41_irq_cfg irq_config2; |
| 32 | 751 | }; |
| 33 | 752 | |
| 753 | +struct cs35l41_otp_packed_element_t { | |
| 754 | + u32 reg; | |
| 755 | + u8 shift; | |
| 756 | + u8 size; | |
| 757 | +}; | |
| 758 | + | |
| 759 | +struct cs35l41_otp_map_element_t { | |
| 760 | + u32 id; | |
| 761 | + u32 num_elements; | |
| 762 | + const struct cs35l41_otp_packed_element_t *map; | |
| 763 | + u32 bit_offset; | |
| 764 | + u32 word_offset; | |
| 765 | +}; | |
| 766 | + | |
| 767 | +extern struct regmap_config cs35l41_regmap_i2c; | |
| 768 | +extern struct regmap_config cs35l41_regmap_spi; | |
| 769 | + | |
| 770 | +int cs35l41_test_key_unlock(struct device *dev, struct regmap *regmap); | |
| 771 | +int cs35l41_test_key_lock(struct device *dev, struct regmap *regmap); | |
| 772 | +int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap); | |
| 773 | +int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsigned int reg_revid); | |
| 774 | +int cs35l41_set_channels(struct device *dev, struct regmap *reg, | |
| 775 | + unsigned int tx_num, unsigned int *tx_slot, | |
| 776 | + unsigned int rx_num, unsigned int *rx_slot); | |
| 777 | +int cs35l41_boost_config(struct device *dev, struct regmap *regmap, int boost_ind, int boost_cap, | |
| 778 | + int boost_ipk); | |
| 779 | + | |
| 34 | 780 | #endif /* __CS35L41_H */ |
| @@ -60,7 +60,6 @@ struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream) · 59 unmodified lines | ||
| 60 | 60 | * @maxburst: Maximum number of words(note: words, as in units of the |
| 61 | 61 | * src_addr_width member, not bytes) that can be send to or received from the |
| 62 | 62 | * DAI in one burst. |
| 63 | − * @slave_id: Slave requester id for the DMA channel. | |
| 64 | 63 | * @filter_data: Custom DMA channel filter data, this will usually be used when |
| 65 | 64 | * requesting the DMA channel. |
| 66 | 65 | * @chan_name: Custom channel name to use when requesting DMA channel. |
| @@ -74,7 +73,6 @@ struct snd_dmaengine_dai_dma_data { · 7 unmodified lines | ||
| 74 | 73 | dma_addr_t addr; |
| 75 | 74 | enum dma_slave_buswidth addr_width; |
| 76 | 75 | u32 maxburst; |
| 77 | − unsigned int slave_id; | |
| 78 | 76 | void *filter_data; |
| 79 | 77 | const char *chan_name; |
| 80 | 78 | unsigned int fifo_size; |
| @@ -8,7 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #ifndef __SOUND_HDA_CODEC_H |
| 9 | 9 | #define __SOUND_HDA_CODEC_H |
| 10 | 10 | |
| 11 | −#include <linux/kref.h> | |
| 11 | +#include <linux/refcount.h> | |
| 12 | 12 | #include <linux/mod_devicetable.h> |
| 13 | 13 | #include <sound/info.h> |
| 14 | 14 | #include <sound/control.h> |
| @@ -166,8 +166,8 @@ struct hda_pcm { · 151 unmodified lines | ||
| 166 | 166 | bool own_chmap; /* codec driver provides own channel maps */ |
| 167 | 167 | /* private: */ |
| 168 | 168 | struct hda_codec *codec; |
| 169 | − struct kref kref; | |
| 170 | 169 | struct list_head list; |
| 170 | + unsigned int disconnected:1; | |
| 171 | 171 | }; |
| 172 | 172 | |
| 173 | 173 | /* codec information */ |
| @@ -187,6 +187,8 @@ struct hda_codec { · 13 unmodified lines | ||
| 187 | 187 | |
| 188 | 188 | /* PCM to create, set by patch_ops.build_pcms callback */ |
| 189 | 189 | struct list_head pcm_list_head; |
| 190 | + refcount_t pcm_ref; | |
| 191 | + wait_queue_head_t remove_sleep; | |
| 190 | 192 | |
| 191 | 193 | /* codec specific info */ |
| 192 | 194 | void *spec; |
| @@ -420,7 +422,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec); · 227 unmodified lines | ||
| 420 | 422 | |
| 421 | 423 | static inline void snd_hda_codec_pcm_get(struct hda_pcm *pcm) |
| 422 | 424 | { |
| 423 | − kref_get(&pcm->kref); | |
| 425 | + refcount_inc(&pcm->codec->pcm_ref); | |
| 424 | 426 | } |
| 425 | 427 | void snd_hda_codec_pcm_put(struct hda_pcm *pcm); |
| 426 | 428 | |
| @@ -558,6 +558,7 @@ int snd_hdac_stream_set_params(struct hdac_stream *azx_dev, · 557 unmodified lines | ||
| 558 | 558 | void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start); |
| 559 | 559 | void snd_hdac_stream_clear(struct hdac_stream *azx_dev); |
| 560 | 560 | void snd_hdac_stream_stop(struct hdac_stream *azx_dev); |
| 561 | +void snd_hdac_stop_streams_and_chip(struct hdac_bus *bus); | |
| 561 | 562 | void snd_hdac_stream_reset(struct hdac_stream *azx_dev); |
| 562 | 563 | void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set, |
| 563 | 564 | unsigned int streams, unsigned int reg); |
| @@ -78,36 +78,35 @@ struct hdac_ext_stream { · 77 unmodified lines | ||
| 78 | 78 | container_of(s, struct hdac_ext_stream, hstream) |
| 79 | 79 | |
| 80 | 80 | void snd_hdac_ext_stream_init(struct hdac_bus *bus, |
| 81 | − struct hdac_ext_stream *stream, int idx, | |
| 82 | − int direction, int tag); | |
| 81 | + struct hdac_ext_stream *hext_stream, int idx, | |
| 82 | + int direction, int tag); | |
| 83 | 83 | int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, |
| 84 | − int num_stream, int dir); | |
| 84 | + int num_stream, int dir); | |
| 85 | 85 | void snd_hdac_stream_free_all(struct hdac_bus *bus); |
| 86 | 86 | void snd_hdac_link_free_all(struct hdac_bus *bus); |
| 87 | 87 | struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, |
| 88 | 88 | struct snd_pcm_substream *substream, |
| 89 | 89 | int type); |
| 90 | −void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type); | |
| 90 | +void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type); | |
| 91 | 91 | void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, |
| 92 | − struct hdac_ext_stream *azx_dev, bool decouple); | |
| 92 | + struct hdac_ext_stream *hext_stream, bool decouple); | |
| 93 | 93 | void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, |
| 94 | 94 | struct hdac_ext_stream *azx_dev, bool decouple); |
| 95 | −void snd_hdac_ext_stop_streams(struct hdac_bus *bus); | |
| 96 | 95 | |
| 97 | 96 | int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, |
| 98 | − struct hdac_ext_stream *stream, u32 value); | |
| 97 | + struct hdac_ext_stream *hext_stream, u32 value); | |
| 99 | 98 | int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, |
| 100 | − struct hdac_ext_stream *stream); | |
| 99 | + struct hdac_ext_stream *hext_stream); | |
| 101 | 100 | void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus, |
| 102 | 101 | bool enable, int index); |
| 103 | 102 | int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, |
| 104 | − struct hdac_ext_stream *stream, u32 value); | |
| 105 | −int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *stream, u32 value); | |
| 103 | + struct hdac_ext_stream *hext_stream, u32 value); | |
| 104 | +int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *hext_stream, u32 value); | |
| 106 | 105 | |
| 107 | −void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream); | |
| 108 | −void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream); | |
| 109 | −void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream); | |
| 110 | −int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt); | |
| 106 | +void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hext_stream); | |
| 107 | +void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hext_stream); | |
| 108 | +void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hext_stream); | |
| 109 | +int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *hext_stream, int fmt); | |
| 111 | 110 | |
| 112 | 111 | struct hdac_ext_link { |
| 113 | 112 | struct hdac_bus *bus; |
| @@ -10,6 +10,14 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | #include <linux/acpi.h> |
| 12 | 12 | |
| 13 | +enum nhlt_link_type { | |
| 14 | + NHLT_LINK_HDA = 0, | |
| 15 | + NHLT_LINK_DSP = 1, | |
| 16 | + NHLT_LINK_DMIC = 2, | |
| 17 | + NHLT_LINK_SSP = 3, | |
| 18 | + NHLT_LINK_INVALID | |
| 19 | +}; | |
| 20 | + | |
| 13 | 21 | #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT) |
| 14 | 22 | |
| 15 | 23 | struct wav_fmt { |
| @@ -33,14 +41,6 @@ struct wav_fmt_ext { · 17 unmodified lines | ||
| 33 | 41 | u8 sub_fmt[16]; |
| 34 | 42 | } __packed; |
| 35 | 43 | |
| 36 | −enum nhlt_link_type { | |
| 37 | − NHLT_LINK_HDA = 0, | |
| 38 | − NHLT_LINK_DSP = 1, | |
| 39 | − NHLT_LINK_DMIC = 2, | |
| 40 | − NHLT_LINK_SSP = 3, | |
| 41 | − NHLT_LINK_INVALID | |
| 42 | −}; | |
| 43 | − | |
| 44 | 44 | enum nhlt_device_type { |
| 45 | 45 | NHLT_DEVICE_BT = 0, |
| 46 | 46 | NHLT_DEVICE_DMIC = 1, |
| @@ -132,6 +132,12 @@ void intel_nhlt_free(struct nhlt_acpi_table *addr); · 85 unmodified lines | ||
| 132 | 132 | |
| 133 | 133 | int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt); |
| 134 | 134 | |
| 135 | +bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type); | |
| 136 | +struct nhlt_specific_cfg * | |
| 137 | +intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, | |
| 138 | + u32 bus_id, u8 link_type, u8 vbps, u8 bps, | |
| 139 | + u8 num_ch, u32 rate, u8 dir, u8 dev_type); | |
| 140 | + | |
| 135 | 141 | #else |
| 136 | 142 | |
| 137 | 143 | struct nhlt_acpi_table; |
| @@ -150,6 +156,21 @@ static inline int intel_nhlt_get_dmic_geo(struct device *dev, · 12 unmodified lines | ||
| 150 | 156 | { |
| 151 | 157 | return 0; |
| 152 | 158 | } |
| 159 | + | |
| 160 | +static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, | |
| 161 | + u8 link_type) | |
| 162 | +{ | |
| 163 | + return false; | |
| 164 | +} | |
| 165 | + | |
| 166 | +static inline struct nhlt_specific_cfg * | |
| 167 | +intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, | |
| 168 | + u32 bus_id, u8 link_type, u8 vbps, u8 bps, | |
| 169 | + u8 num_ch, u32 rate, u8 dir, u8 dev_type) | |
| 170 | +{ | |
| 171 | + return NULL; | |
| 172 | +} | |
| 173 | + | |
| 153 | 174 | #endif |
| 154 | 175 | |
| 155 | 176 | #endif |
| @@ -36,13 +36,6 @@ struct snd_dma_device { · 35 unmodified lines | ||
| 36 | 36 | #define SNDRV_DMA_TYPE_CONTINUOUS 1 /* continuous no-DMA memory */ |
| 37 | 37 | #define SNDRV_DMA_TYPE_DEV 2 /* generic device continuous */ |
| 38 | 38 | #define SNDRV_DMA_TYPE_DEV_WC 5 /* continuous write-combined */ |
| 39 | −#ifdef CONFIG_SND_DMA_SGBUF | |
| 40 | −#define SNDRV_DMA_TYPE_DEV_SG 3 /* generic device SG-buffer */ | |
| 41 | −#define SNDRV_DMA_TYPE_DEV_WC_SG 6 /* SG write-combined */ | |
| 42 | −#else | |
| 43 | −#define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */ | |
| 44 | −#define SNDRV_DMA_TYPE_DEV_WC_SG SNDRV_DMA_TYPE_DEV_WC | |
| 45 | −#endif | |
| 46 | 39 | #ifdef CONFIG_GENERIC_ALLOCATOR |
| 47 | 40 | #define SNDRV_DMA_TYPE_DEV_IRAM 4 /* generic device iram-buffer */ |
| 48 | 41 | #else |
| @@ -51,6 +44,13 @@ struct snd_dma_device { · 2 unmodified lines | ||
| 51 | 44 | #define SNDRV_DMA_TYPE_VMALLOC 7 /* vmalloc'ed buffer */ |
| 52 | 45 | #define SNDRV_DMA_TYPE_NONCONTIG 8 /* non-coherent SG buffer */ |
| 53 | 46 | #define SNDRV_DMA_TYPE_NONCOHERENT 9 /* non-coherent buffer */ |
| 47 | +#ifdef CONFIG_SND_DMA_SGBUF | |
| 48 | +#define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_NONCONTIG | |
| 49 | +#define SNDRV_DMA_TYPE_DEV_WC_SG 6 /* SG write-combined */ | |
| 50 | +#else | |
| 51 | +#define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */ | |
| 52 | +#define SNDRV_DMA_TYPE_DEV_WC_SG SNDRV_DMA_TYPE_DEV_WC | |
| 53 | +#endif | |
| 54 | 54 | |
| 55 | 55 | /* |
| 56 | 56 | * info for buffer allocation |
| @@ -147,6 +147,9 @@ struct snd_pcm_ops { · 146 unmodified lines | ||
| 147 | 147 | #define SNDRV_PCM_FMTBIT_S24_BE _SNDRV_PCM_FMTBIT(S24_BE) |
| 148 | 148 | #define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE) |
| 149 | 149 | #define SNDRV_PCM_FMTBIT_U24_BE _SNDRV_PCM_FMTBIT(U24_BE) |
| 150 | +// For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the | |
| 151 | +// available bit count in most significant bit. It's for the case of so-called 'left-justified' or | |
| 152 | +// `right-padding` sample which has less width than 32 bit. | |
| 150 | 153 | #define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE) |
| 151 | 154 | #define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE) |
| 152 | 155 | #define SNDRV_PCM_FMTBIT_U32_LE _SNDRV_PCM_FMTBIT(U32_LE) |
| @@ -40,6 +40,7 @@ struct rt5682s_platform_data { · 39 unmodified lines | ||
| 40 | 40 | enum rt5682s_jd_src jd_src; |
| 41 | 41 | unsigned int dmic_clk_rate; |
| 42 | 42 | unsigned int dmic_delay; |
| 43 | + unsigned int amic_delay; | |
| 43 | 44 | bool dmic_clk_driving_high; |
| 44 | 45 | |
| 45 | 46 | const char *dai_clk_names[RT5682S_DAI_NUM_CLKS]; |
| @@ -148,6 +148,8 @@ struct snd_soc_component_driver { · 147 unmodified lines | ||
| 148 | 148 | struct vm_area_struct *vma); |
| 149 | 149 | int (*ack)(struct snd_soc_component *component, |
| 150 | 150 | struct snd_pcm_substream *substream); |
| 151 | + snd_pcm_sframes_t (*delay)(struct snd_soc_component *component, | |
| 152 | + struct snd_pcm_substream *substream); | |
| 151 | 153 | |
| 152 | 154 | const struct snd_compress_ops *compress_ops; |
| 153 | 155 | |
| @@ -505,5 +507,7 @@ int snd_soc_pcm_component_pm_runtime_get(struct snd_soc_pcm_runtime *rtd, · 351 unmodified lines | ||
| 505 | 507 | void snd_soc_pcm_component_pm_runtime_put(struct snd_soc_pcm_runtime *rtd, |
| 506 | 508 | void *stream, int rollback); |
| 507 | 509 | int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream); |
| 510 | +void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream, | |
| 511 | + snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay); | |
| 508 | 512 | |
| 509 | 513 | #endif /* __SOC_COMPONENT_H */ |
| @@ -208,8 +208,6 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai, · 207 unmodified lines | ||
| 208 | 208 | struct snd_pcm_substream *substream); |
| 209 | 209 | void snd_soc_dai_shutdown(struct snd_soc_dai *dai, |
| 210 | 210 | struct snd_pcm_substream *substream, int rollback); |
| 211 | −snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai, | |
| 212 | − struct snd_pcm_substream *substream); | |
| 213 | 211 | void snd_soc_dai_suspend(struct snd_soc_dai *dai); |
| 214 | 212 | void snd_soc_dai_resume(struct snd_soc_dai *dai); |
| 215 | 213 | int snd_soc_dai_compress_new(struct snd_soc_dai *dai, |
| @@ -238,6 +236,8 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd, · 22 unmodified lines | ||
| 238 | 236 | int rollback); |
| 239 | 237 | int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream, |
| 240 | 238 | int cmd); |
| 239 | +void snd_soc_pcm_dai_delay(struct snd_pcm_substream *substream, | |
| 240 | + snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay); | |
| 241 | 241 | |
| 242 | 242 | int snd_soc_dai_compr_startup(struct snd_soc_dai *dai, |
| 243 | 243 | struct snd_compr_stream *cstream); |
| @@ -295,9 +295,9 @@ struct snd_soc_dai_ops { · 51 unmodified lines | ||
| 295 | 295 | unsigned int *rx_num, unsigned int *rx_slot); |
| 296 | 296 | int (*set_tristate)(struct snd_soc_dai *dai, int tristate); |
| 297 | 297 | |
| 298 | − int (*set_sdw_stream)(struct snd_soc_dai *dai, | |
| 299 | − void *stream, int direction); | |
| 300 | − void *(*get_sdw_stream)(struct snd_soc_dai *dai, int direction); | |
| 298 | + int (*set_stream)(struct snd_soc_dai *dai, | |
| 299 | + void *stream, int direction); | |
| 300 | + void *(*get_stream)(struct snd_soc_dai *dai, int direction); | |
| 301 | 301 | |
| 302 | 302 | /* |
| 303 | 303 | * DAI digital mute - optional. |
| @@ -515,42 +515,42 @@ static inline void *snd_soc_dai_get_drvdata(struct snd_soc_dai *dai) · 211 unmodified lines | ||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
| 518 | − * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation | |
| 518 | + * snd_soc_dai_set_stream() - Configures a DAI for stream operation | |
| 519 | 519 | * @dai: DAI |
| 520 | − * @stream: STREAM | |
| 520 | + * @stream: STREAM (opaque structure depending on DAI type) | |
| 521 | 521 | * @direction: Stream direction(Playback/Capture) |
| 522 | − * SoundWire subsystem doesn't have a notion of direction and we reuse | |
| 522 | + * Some subsystems, such as SoundWire, don't have a notion of direction and we reuse | |
| 523 | 523 | * the ASoC stream direction to configure sink/source ports. |
| 524 | 524 | * Playback maps to source ports and Capture for sink ports. |
| 525 | 525 | * |
| 526 | 526 | * This should be invoked with NULL to clear the stream set previously. |
| 527 | 527 | * Returns 0 on success, a negative error code otherwise. |
| 528 | 528 | */ |
| 529 | −static inline int snd_soc_dai_set_sdw_stream(struct snd_soc_dai *dai, | |
| 530 | − void *stream, int direction) | |
| 529 | +static inline int snd_soc_dai_set_stream(struct snd_soc_dai *dai, | |
| 530 | + void *stream, int direction) | |
| 531 | 531 | { |
| 532 | − if (dai->driver->ops->set_sdw_stream) | |
| 533 | − return dai->driver->ops->set_sdw_stream(dai, stream, direction); | |
| 532 | + if (dai->driver->ops->set_stream) | |
| 533 | + return dai->driver->ops->set_stream(dai, stream, direction); | |
| 534 | 534 | else |
| 535 | 535 | return -ENOTSUPP; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
| 539 | − * snd_soc_dai_get_sdw_stream() - Retrieves SDW stream from DAI | |
| 539 | + * snd_soc_dai_get_stream() - Retrieves stream from DAI | |
| 540 | 540 | * @dai: DAI |
| 541 | 541 | * @direction: Stream direction(Playback/Capture) |
| 542 | 542 | * |
| 543 | 543 | * This routine only retrieves that was previously configured |
| 544 | − * with snd_soc_dai_get_sdw_stream() | |
| 544 | + * with snd_soc_dai_get_stream() | |
| 545 | 545 | * |
| 546 | 546 | * Returns pointer to stream or an ERR_PTR value, e.g. |
| 547 | 547 | * ERR_PTR(-ENOTSUPP) if callback is not supported; |
| 548 | 548 | */ |
| 549 | −static inline void *snd_soc_dai_get_sdw_stream(struct snd_soc_dai *dai, | |
| 550 | − int direction) | |
| 549 | +static inline void *snd_soc_dai_get_stream(struct snd_soc_dai *dai, | |
| 550 | + int direction) | |
| 551 | 551 | { |
| 552 | − if (dai->driver->ops->get_sdw_stream) | |
| 553 | − return dai->driver->ops->get_sdw_stream(dai, direction); | |
| 552 | + if (dai->driver->ops->get_stream) | |
| 553 | + return dai->driver->ops->get_stream(dai, direction); | |
| 554 | 554 | else |
| 555 | 555 | return ERR_PTR(-ENOTSUPP); |
| 556 | 556 | } |
| @@ -101,6 +101,8 @@ struct snd_soc_dpcm_runtime { · 100 unmodified lines | ||
| 101 | 101 | enum snd_soc_dpcm_state state; |
| 102 | 102 | |
| 103 | 103 | int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */ |
| 104 | + | |
| 105 | + int be_start; /* refcount protected by BE stream pcm lock */ | |
| 104 | 106 | }; |
| 105 | 107 | |
| 106 | 108 | #define for_each_dpcm_fe(be, stream, _dpcm) \ |
| @@ -893,8 +893,6 @@ struct snd_soc_card { · 892 unmodified lines | ||
| 893 | 893 | struct mutex pcm_mutex; |
| 894 | 894 | enum snd_soc_pcm_subclass pcm_subclass; |
| 895 | 895 | |
| 896 | − spinlock_t dpcm_lock; | |
| 897 | − | |
| 898 | 896 | int (*probe)(struct snd_soc_card *card); |
| 899 | 897 | int (*late_probe)(struct snd_soc_card *card); |
| 900 | 898 | int (*remove)(struct snd_soc_card *card); |
| @@ -1213,6 +1211,7 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card, · 312 unmodified lines | ||
| 1213 | 1211 | const char *propname); |
| 1214 | 1212 | int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card, |
| 1215 | 1213 | const char *propname); |
| 1214 | +int snd_soc_of_parse_pin_switches(struct snd_soc_card *card, const char *prop); | |
| 1216 | 1215 | int snd_soc_of_get_slot_mask(struct device_node *np, |
| 1217 | 1216 | const char *prop_name, |
| 1218 | 1217 | unsigned int *mask); |
| @@ -17,6 +17,28 @@ · 16 unmodified lines | ||
| 17 | 17 | |
| 18 | 18 | struct snd_sof_dsp_ops; |
| 19 | 19 | |
| 20 | +/** | |
| 21 | + * enum sof_fw_state - DSP firmware state definitions | |
| 22 | + * @SOF_FW_BOOT_NOT_STARTED: firmware boot is not yet started | |
| 23 | + * @SOF_FW_BOOT_PREPARE: preparing for boot (firmware loading for exaqmple) | |
| 24 | + * @SOF_FW_BOOT_IN_PROGRESS: firmware boot is in progress | |
| 25 | + * @SOF_FW_BOOT_FAILED: firmware boot failed | |
| 26 | + * @SOF_FW_BOOT_READY_FAILED: firmware booted but fw_ready op failed | |
| 27 | + * @SOF_FW_BOOT_READY_OK: firmware booted and fw_ready op passed | |
| 28 | + * @SOF_FW_BOOT_COMPLETE: firmware is booted up and functional | |
| 29 | + * @SOF_FW_CRASHED: firmware crashed after successful boot | |
| 30 | + */ | |
| 31 | +enum sof_fw_state { | |
| 32 | + SOF_FW_BOOT_NOT_STARTED = 0, | |
| 33 | + SOF_FW_BOOT_PREPARE, | |
| 34 | + SOF_FW_BOOT_IN_PROGRESS, | |
| 35 | + SOF_FW_BOOT_FAILED, | |
| 36 | + SOF_FW_BOOT_READY_FAILED, | |
| 37 | + SOF_FW_BOOT_READY_OK, | |
| 38 | + SOF_FW_BOOT_COMPLETE, | |
| 39 | + SOF_FW_CRASHED, | |
| 40 | +}; | |
| 41 | + | |
| 20 | 42 | /* |
| 21 | 43 | * SOF Platform data. |
| 22 | 44 | */ |
| @@ -0,0 +1,21 @@ | ||
| 1 | +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ | |
| 2 | +/* | |
| 3 | + * This file is provided under a dual BSD/GPLv2 license. When using or | |
| 4 | + * redistributing this file, you may do so under either license. | |
| 5 | + * | |
| 6 | + * Copyright(c) 2021 Advanced Micro Devices, Inc.. All rights reserved. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +#ifndef __INCLUDE_SOUND_SOF_DAI_AMD_H__ | |
| 10 | +#define __INCLUDE_SOUND_SOF_DAI_AMD_H__ | |
| 11 | + | |
| 12 | +#include <sound/sof/header.h> | |
| 13 | + | |
| 14 | +/* ACP Configuration Request - SOF_IPC_DAI_AMD_CONFIG */ | |
| 15 | +struct sof_ipc_dai_acp_params { | |
| 16 | + struct sof_ipc_hdr hdr; | |
| 17 | + | |
| 18 | + uint32_t fsync_rate; /* FSYNC frequency in Hz */ | |
| 19 | + uint32_t tdm_slots; | |
| 20 | +} __packed; | |
| 21 | +#endif | |
| @@ -0,0 +1,23 @@ | ||
| 1 | +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ | |
| 2 | +/* | |
| 3 | + * Copyright(c) 2021 Mediatek Corporation. All rights reserved. | |
| 4 | + * | |
| 5 | + * Author: Bo Pan <bo.pan@mediatek.com> | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#ifndef __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__ | |
| 9 | +#define __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__ | |
| 10 | + | |
| 11 | +#include <sound/sof/header.h> | |
| 12 | + | |
| 13 | +struct sof_ipc_dai_mtk_afe_params { | |
| 14 | + struct sof_ipc_hdr hdr; | |
| 15 | + u32 channels; | |
| 16 | + u32 rate; | |
| 17 | + u32 format; | |
| 18 | + u32 stream_id; | |
| 19 | + u32 reserved[4]; /* reserve for future */ | |
| 20 | +} __packed; | |
| 21 | + | |
| 22 | +#endif | |
| 23 | + | |
| @@ -12,6 +12,8 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <sound/sof/header.h> |
| 13 | 13 | #include <sound/sof/dai-intel.h> |
| 14 | 14 | #include <sound/sof/dai-imx.h> |
| 15 | +#include <sound/sof/dai-amd.h> | |
| 16 | +#include <sound/sof/dai-mediatek.h> | |
| 15 | 17 | |
| 16 | 18 | /* |
| 17 | 19 | * DAI Configuration. |
| @@ -50,12 +52,25 @@ · 32 unmodified lines | ||
| 50 | 52 | #define SOF_DAI_FMT_INV_MASK 0x0f00 |
| 51 | 53 | #define SOF_DAI_FMT_CLOCK_PROVIDER_MASK 0xf000 |
| 52 | 54 | |
| 53 | −/* DAI_CONFIG flags */ | |
| 54 | −#define SOF_DAI_CONFIG_FLAGS_MASK 0x3 | |
| 55 | −#define SOF_DAI_CONFIG_FLAGS_NONE (0 << 0) /**< DAI_CONFIG sent without stage information */ | |
| 56 | −#define SOF_DAI_CONFIG_FLAGS_HW_PARAMS (1 << 0) /**< DAI_CONFIG sent during hw_params stage */ | |
| 57 | −#define SOF_DAI_CONFIG_FLAGS_HW_FREE (2 << 0) /**< DAI_CONFIG sent during hw_free stage */ | |
| 58 | −#define SOF_DAI_CONFIG_FLAGS_RFU (3 << 0) /**< not used, reserved for future use */ | |
| 55 | +/* | |
| 56 | + * DAI_CONFIG flags. The 4 LSB bits are used for the commands, HW_PARAMS, HW_FREE and PAUSE | |
| 57 | + * representing when the IPC is sent. The 4 MSB bits are used to add quirks along with the above | |
| 58 | + * commands. | |
| 59 | + */ | |
| 60 | +#define SOF_DAI_CONFIG_FLAGS_CMD_MASK 0xF | |
| 61 | +#define SOF_DAI_CONFIG_FLAGS_NONE 0 /**< DAI_CONFIG sent without stage information */ | |
| 62 | +#define SOF_DAI_CONFIG_FLAGS_HW_PARAMS BIT(0) /**< DAI_CONFIG sent during hw_params stage */ | |
| 63 | +#define SOF_DAI_CONFIG_FLAGS_HW_FREE BIT(1) /**< DAI_CONFIG sent during hw_free stage */ | |
| 64 | +/**< DAI_CONFIG sent during pause trigger. Only available ABI 3.20 onwards */ | |
| 65 | +#define SOF_DAI_CONFIG_FLAGS_PAUSE BIT(2) | |
| 66 | +#define SOF_DAI_CONFIG_FLAGS_QUIRK_SHIFT 4 | |
| 67 | +#define SOF_DAI_CONFIG_FLAGS_QUIRK_MASK (0xF << SOF_DAI_CONFIG_FLAGS_QUIRK_SHIFT) | |
| 68 | +/* | |
| 69 | + * This should be used along with the SOF_DAI_CONFIG_FLAGS_HW_PARAMS to indicate that pipeline | |
| 70 | + * stop/pause and DAI DMA stop/pause should happen in two steps. This change is only available | |
| 71 | + * ABI 3.20 onwards. | |
| 72 | + */ | |
| 73 | +#define SOF_DAI_CONFIG_FLAGS_2_STEP_STOP BIT(0) | |
| 59 | 74 | |
| 60 | 75 | /** \brief Types of DAI */ |
| 61 | 76 | enum sof_ipc_dai_type { |
| @@ -66,6 +81,10 @@ enum sof_ipc_dai_type { · 4 unmodified lines | ||
| 66 | 81 | SOF_DAI_INTEL_ALH, /**< Intel ALH */ |
| 67 | 82 | SOF_DAI_IMX_SAI, /**< i.MX SAI */ |
| 68 | 83 | SOF_DAI_IMX_ESAI, /**< i.MX ESAI */ |
| 84 | + SOF_DAI_AMD_BT, /**< AMD ACP BT*/ | |
| 85 | + SOF_DAI_AMD_SP, /**< AMD ACP SP */ | |
| 86 | + SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */ | |
| 87 | + SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */ | |
| 69 | 88 | }; |
| 70 | 89 | |
| 71 | 90 | /* general purpose DAI configuration */ |
| @@ -90,6 +109,10 @@ struct sof_ipc_dai_config { · 18 unmodified lines | ||
| 90 | 109 | struct sof_ipc_dai_alh_params alh; |
| 91 | 110 | struct sof_ipc_dai_esai_params esai; |
| 92 | 111 | struct sof_ipc_dai_sai_params sai; |
| 112 | + struct sof_ipc_dai_acp_params acpbt; | |
| 113 | + struct sof_ipc_dai_acp_params acpsp; | |
| 114 | + struct sof_ipc_dai_acp_params acpdmic; | |
| 115 | + struct sof_ipc_dai_mtk_afe_params afe; | |
| 93 | 116 | }; |
| 94 | 117 | } __packed; |
| 95 | 118 | |
| @@ -19,6 +19,8 @@ enum sof_ipc_dbg_mem_zone { · 18 unmodified lines | ||
| 19 | 19 | SOF_IPC_MEM_ZONE_SYS_RUNTIME = 1, /**< System-runtime zone */ |
| 20 | 20 | SOF_IPC_MEM_ZONE_RUNTIME = 2, /**< Runtime zone */ |
| 21 | 21 | SOF_IPC_MEM_ZONE_BUFFER = 3, /**< Buffer zone */ |
| 22 | + SOF_IPC_MEM_ZONE_RUNTIME_SHARED = 4, /**< System runtime zone */ | |
| 23 | + SOF_IPC_MEM_ZONE_SYS_SHARED = 5, /**< System shared zone */ | |
| 22 | 24 | }; |
| 23 | 25 | |
| 24 | 26 | /** ABI3.18 */ |
| @@ -119,6 +119,7 @@ · 118 unmodified lines | ||
| 119 | 119 | #define SOF_IPC_TRACE_DMA_POSITION SOF_CMD_TYPE(0x002) |
| 120 | 120 | #define SOF_IPC_TRACE_DMA_PARAMS_EXT SOF_CMD_TYPE(0x003) |
| 121 | 121 | #define SOF_IPC_TRACE_FILTER_UPDATE SOF_CMD_TYPE(0x004) /**< ABI3.17 */ |
| 122 | +#define SOF_IPC_TRACE_DMA_FREE SOF_CMD_TYPE(0x005) /**< ABI3.20 */ | |
| 122 | 123 | |
| 123 | 124 | /* debug */ |
| 124 | 125 | #define SOF_IPC_DEBUG_MEM_USAGE SOF_CMD_TYPE(0x001) |
| @@ -202,6 +202,11 @@ typedef int __bitwise snd_pcm_format_t; · 201 unmodified lines | ||
| 202 | 202 | #define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) /* low three bytes */ |
| 203 | 203 | #define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) /* low three bytes */ |
| 204 | 204 | #define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) /* low three bytes */ |
| 205 | +/* | |
| 206 | + * For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the | |
| 207 | + * available bit count in most significant bit. It's for the case of so-called 'left-justified' or | |
| 208 | + * `right-padding` sample which has less width than 32 bit. | |
| 209 | + */ | |
| 205 | 210 | #define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10) |
| 206 | 211 | #define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11) |
| 207 | 212 | #define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12) |
| @@ -300,7 +305,7 @@ typedef int __bitwise snd_pcm_subformat_t; · 92 unmodified lines | ||
| 300 | 305 | #define SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME 0x04000000 /* report estimated link audio time */ |
| 301 | 306 | #define SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME 0x08000000 /* report synchronized audio/system time */ |
| 302 | 307 | #define SNDRV_PCM_INFO_EXPLICIT_SYNC 0x10000000 /* needs explicit sync of pointers and data */ |
| 303 | − | |
| 308 | +#define SNDRV_PCM_INFO_NO_REWINDS 0x20000000 /* hardware can only support monotonic changes of appl_ptr */ | |
| 304 | 309 | #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */ |
| 305 | 310 | #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */ |
| 306 | 311 | |
| @@ -140,4 +140,9 @@ · 139 unmodified lines | ||
| 140 | 140 | #define SOF_TKN_INTEL_HDA_RATE 1500 |
| 141 | 141 | #define SOF_TKN_INTEL_HDA_CH 1501 |
| 142 | 142 | |
| 143 | +/* AFE */ | |
| 144 | +#define SOF_TKN_MEDIATEK_AFE_RATE 1600 | |
| 145 | +#define SOF_TKN_MEDIATEK_AFE_CH 1601 | |
| 146 | +#define SOF_TKN_MEDIATEK_AFE_FORMAT 1602 | |
| 147 | + | |
| 143 | 148 | #endif |
| @@ -19,7 +19,6 @@ snd-$(CONFIG_SND_JACK) += ctljack.o jack.o · 18 unmodified lines | ||
| 19 | 19 | snd-pcm-y := pcm.o pcm_native.o pcm_lib.o pcm_misc.o \ |
| 20 | 20 | pcm_memory.o memalloc.o |
| 21 | 21 | snd-pcm-$(CONFIG_SND_PCM_TIMER) += pcm_timer.o |
| 22 | −snd-pcm-$(CONFIG_SND_DMA_SGBUF) += sgbuf.o | |
| 23 | 22 | snd-pcm-$(CONFIG_SND_PCM_ELD) += pcm_drm_eld.o |
| 24 | 23 | snd-pcm-$(CONFIG_SND_PCM_IEC958) += pcm_iec958.o |
| 25 | 24 | |
| @@ -509,7 +509,7 @@ static char *parse_string(char *s, char *val, size_t val_size) · 508 unmodified lines | ||
| 509 | 509 | return s; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | −static char *parse_iface(char *s, unsigned int *val) | |
| 512 | +static char *parse_iface(char *s, snd_ctl_elem_iface_t *val) | |
| 513 | 513 | { |
| 514 | 514 | if (!strncasecmp(s, "card", 4)) |
| 515 | 515 | *val = SNDRV_CTL_ELEM_IFACE_CARD; |
| @@ -32,10 +32,8 @@ int snd_oss_info_register(int dev, int num, char *string) · 31 unmodified lines | ||
| 32 | 32 | mutex_lock(&strings); |
| 33 | 33 | if (string == NULL) { |
| 34 | 34 | x = snd_sndstat_strings[num][dev]; |
| 35 | − if (x) { | |
| 36 | − kfree(x); | |
| 37 | − x = NULL; | |
| 38 | − } | |
| 35 | + kfree(x); | |
| 36 | + x = NULL; | |
| 39 | 37 | } else { |
| 40 | 38 | x = kstrdup(string, GFP_KERNEL); |
| 41 | 39 | if (x == NULL) { |
| @@ -62,10 +62,13 @@ static int snd_jack_dev_free(struct snd_device *device) · 61 unmodified lines | ||
| 62 | 62 | struct snd_card *card = device->card; |
| 63 | 63 | struct snd_jack_kctl *jack_kctl, *tmp_jack_kctl; |
| 64 | 64 | |
| 65 | + down_write(&card->controls_rwsem); | |
| 65 | 66 | list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) { |
| 66 | 67 | list_del_init(&jack_kctl->list); |
| 67 | 68 | snd_ctl_remove(card, jack_kctl->kctl); |
| 68 | 69 | } |
| 70 | + up_write(&card->controls_rwsem); | |
| 71 | + | |
| 69 | 72 | if (jack->private_free) |
| 70 | 73 | jack->private_free(jack); |
| 71 | 74 | |
| @@ -620,6 +620,52 @@ static const struct snd_malloc_ops snd_dma_noncontig_ops = { · 619 unmodified lines | ||
| 620 | 620 | .get_chunk_size = snd_dma_noncontig_get_chunk_size, |
| 621 | 621 | }; |
| 622 | 622 | |
| 623 | +/* x86-specific SG-buffer with WC pages */ | |
| 624 | +#ifdef CONFIG_SND_DMA_SGBUF | |
| 625 | +#define sg_wc_address(it) ((unsigned long)page_address(sg_page_iter_page(it))) | |
| 626 | + | |
| 627 | +static void *snd_dma_sg_wc_alloc(struct snd_dma_buffer *dmab, size_t size) | |
| 628 | +{ | |
| 629 | + void *p = snd_dma_noncontig_alloc(dmab, size); | |
| 630 | + struct sg_table *sgt = dmab->private_data; | |
| 631 | + struct sg_page_iter iter; | |
| 632 | + | |
| 633 | + if (!p) | |
| 634 | + return NULL; | |
| 635 | + for_each_sgtable_page(sgt, &iter, 0) | |
| 636 | + set_memory_wc(sg_wc_address(&iter), 1); | |
| 637 | + return p; | |
| 638 | +} | |
| 639 | + | |
| 640 | +static void snd_dma_sg_wc_free(struct snd_dma_buffer *dmab) | |
| 641 | +{ | |
| 642 | + struct sg_table *sgt = dmab->private_data; | |
| 643 | + struct sg_page_iter iter; | |
| 644 | + | |
| 645 | + for_each_sgtable_page(sgt, &iter, 0) | |
| 646 | + set_memory_wb(sg_wc_address(&iter), 1); | |
| 647 | + snd_dma_noncontig_free(dmab); | |
| 648 | +} | |
| 649 | + | |
| 650 | +static int snd_dma_sg_wc_mmap(struct snd_dma_buffer *dmab, | |
| 651 | + struct vm_area_struct *area) | |
| 652 | +{ | |
| 653 | + area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); | |
| 654 | + return dma_mmap_noncontiguous(dmab->dev.dev, area, | |
| 655 | + dmab->bytes, dmab->private_data); | |
| 656 | +} | |
| 657 | + | |
| 658 | +static const struct snd_malloc_ops snd_dma_sg_wc_ops = { | |
| 659 | + .alloc = snd_dma_sg_wc_alloc, | |
| 660 | + .free = snd_dma_sg_wc_free, | |
| 661 | + .mmap = snd_dma_sg_wc_mmap, | |
| 662 | + .sync = snd_dma_noncontig_sync, | |
| 663 | + .get_addr = snd_dma_noncontig_get_addr, | |
| 664 | + .get_page = snd_dma_noncontig_get_page, | |
| 665 | + .get_chunk_size = snd_dma_noncontig_get_chunk_size, | |
| 666 | +}; | |
| 667 | +#endif /* CONFIG_SND_DMA_SGBUF */ | |
| 668 | + | |
| 623 | 669 | /* |
| 624 | 670 | * Non-coherent pages allocator |
| 625 | 671 | */ |
| @@ -679,14 +725,13 @@ static const struct snd_malloc_ops *dma_ops[] = { · 53 unmodified lines | ||
| 679 | 725 | [SNDRV_DMA_TYPE_DEV_WC] = &snd_dma_wc_ops, |
| 680 | 726 | [SNDRV_DMA_TYPE_NONCONTIG] = &snd_dma_noncontig_ops, |
| 681 | 727 | [SNDRV_DMA_TYPE_NONCOHERENT] = &snd_dma_noncoherent_ops, |
| 728 | +#ifdef CONFIG_SND_DMA_SGBUF | |
| 729 | + [SNDRV_DMA_TYPE_DEV_WC_SG] = &snd_dma_sg_wc_ops, | |
| 730 | +#endif | |
| 682 | 731 | #ifdef CONFIG_GENERIC_ALLOCATOR |
| 683 | 732 | [SNDRV_DMA_TYPE_DEV_IRAM] = &snd_dma_iram_ops, |
| 684 | 733 | #endif /* CONFIG_GENERIC_ALLOCATOR */ |
| 685 | 734 | #endif /* CONFIG_HAS_DMA */ |
| 686 | −#ifdef CONFIG_SND_DMA_SGBUF | |
| 687 | − [SNDRV_DMA_TYPE_DEV_SG] = &snd_dma_sg_ops, | |
| 688 | − [SNDRV_DMA_TYPE_DEV_WC_SG] = &snd_dma_sg_ops, | |
| 689 | −#endif | |
| 690 | 735 | }; |
| 691 | 736 | |
| 692 | 737 | static const struct snd_malloc_ops *snd_dma_get_ops(struct snd_dma_buffer *dmab) |
| @@ -2065,7 +2065,7 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr · 2064 unmodified lines | ||
| 2065 | 2065 | int err, cmd; |
| 2066 | 2066 | |
| 2067 | 2067 | #ifdef OSS_DEBUG |
| 2068 | − pcm_dbg(substream->pcm, "pcm_oss: trigger = 0x%x\n", trigger); | |
| 2068 | + pr_debug("pcm_oss: trigger = 0x%x\n", trigger); | |
| 2069 | 2069 | #endif |
| 2070 | 2070 | |
| 2071 | 2071 | psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; |
| @@ -810,7 +810,11 @@ EXPORT_SYMBOL(snd_pcm_new_internal); · 809 unmodified lines | ||
| 810 | 810 | static void free_chmap(struct snd_pcm_str *pstr) |
| 811 | 811 | { |
| 812 | 812 | if (pstr->chmap_kctl) { |
| 813 | − snd_ctl_remove(pstr->pcm->card, pstr->chmap_kctl); | |
| 813 | + struct snd_card *card = pstr->pcm->card; | |
| 814 | + | |
| 815 | + down_write(&card->controls_rwsem); | |
| 816 | + snd_ctl_remove(card, pstr->chmap_kctl); | |
| 817 | + up_write(&card->controls_rwsem); | |
| 814 | 818 | pstr->chmap_kctl = NULL; |
| 815 | 819 | } |
| 816 | 820 | } |
| @@ -91,8 +91,8 @@ EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config); · 90 unmodified lines | ||
| 91 | 91 | * @dma_data: DAI DMA data |
| 92 | 92 | * @slave_config: DMA slave configuration |
| 93 | 93 | * |
| 94 | − * Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width and | |
| 95 | − * slave_id fields of the DMA slave config from the same fields of the DAI DMA | |
| 94 | + * Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width | |
| 95 | + * fields of the DMA slave config from the same fields of the DAI DMA | |
| 96 | 96 | * data struct. The src and dst fields will be initialized depending on the |
| 97 | 97 | * direction of the substream. If the substream is a playback stream the dst |
| 98 | 98 | * fields will be initialized, if it is a capture stream the src fields will be |
| @@ -124,7 +124,6 @@ void snd_dmaengine_pcm_set_config_from_dai_data( · 25 unmodified lines | ||
| 124 | 124 | slave_config->src_addr_width = dma_data->addr_width; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | − slave_config->slave_id = dma_data->slave_id; | |
| 128 | 127 | slave_config->peripheral_config = dma_data->peripheral_config; |
| 129 | 128 | slave_config->peripheral_size = dma_data->peripheral_size; |
| 130 | 129 | } |
| @@ -2128,11 +2128,28 @@ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream, · 2127 unmodified lines | ||
| 2128 | 2128 | { |
| 2129 | 2129 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 2130 | 2130 | snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr; |
| 2131 | + snd_pcm_sframes_t diff; | |
| 2131 | 2132 | int ret; |
| 2132 | 2133 | |
| 2133 | 2134 | if (old_appl_ptr == appl_ptr) |
| 2134 | 2135 | return 0; |
| 2135 | 2136 | |
| 2137 | + if (appl_ptr >= runtime->boundary) | |
| 2138 | + return -EINVAL; | |
| 2139 | + /* | |
| 2140 | + * check if a rewind is requested by the application | |
| 2141 | + */ | |
| 2142 | + if (substream->runtime->info & SNDRV_PCM_INFO_NO_REWINDS) { | |
| 2143 | + diff = appl_ptr - old_appl_ptr; | |
| 2144 | + if (diff >= 0) { | |
| 2145 | + if (diff > runtime->buffer_size) | |
| 2146 | + return -EINVAL; | |
| 2147 | + } else { | |
| 2148 | + if (runtime->boundary + diff > runtime->buffer_size) | |
| 2149 | + return -EINVAL; | |
| 2150 | + } | |
| 2151 | + } | |
| 2152 | + | |
| 2136 | 2153 | runtime->control->appl_ptr = appl_ptr; |
| 2137 | 2154 | if (substream->ops->ack) { |
| 2138 | 2155 | ret = substream->ops->ack(substream); |
| @@ -235,12 +235,15 @@ struct snd_seq_queue *snd_seq_queue_find_name(char *name) · 234 unmodified lines | ||
| 235 | 235 | |
| 236 | 236 | /* -------------------------------------------------------- */ |
| 237 | 237 | |
| 238 | +#define MAX_CELL_PROCESSES_IN_QUEUE 1000 | |
| 239 | + | |
| 238 | 240 | void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) |
| 239 | 241 | { |
| 240 | 242 | unsigned long flags; |
| 241 | 243 | struct snd_seq_event_cell *cell; |
| 242 | 244 | snd_seq_tick_time_t cur_tick; |
| 243 | 245 | snd_seq_real_time_t cur_time; |
| 246 | + int processed = 0; | |
| 244 | 247 | |
| 245 | 248 | if (q == NULL) |
| 246 | 249 | return; |
| @@ -263,6 +266,8 @@ void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) · 16 unmodified lines | ||
| 263 | 266 | if (!cell) |
| 264 | 267 | break; |
| 265 | 268 | snd_seq_dispatch_event(cell, atomic, hop); |
| 269 | + if (++processed >= MAX_CELL_PROCESSES_IN_QUEUE) | |
| 270 | + goto out; /* the rest processed at the next batch */ | |
| 266 | 271 | } |
| 267 | 272 | |
| 268 | 273 | /* Process time queue... */ |
| @@ -272,14 +277,19 @@ void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) · 3 unmodified lines | ||
| 272 | 277 | if (!cell) |
| 273 | 278 | break; |
| 274 | 279 | snd_seq_dispatch_event(cell, atomic, hop); |
| 280 | + if (++processed >= MAX_CELL_PROCESSES_IN_QUEUE) | |
| 281 | + goto out; /* the rest processed at the next batch */ | |
| 275 | 282 | } |
| 276 | 283 | |
| 284 | + out: | |
| 277 | 285 | /* free lock */ |
| 278 | 286 | spin_lock_irqsave(&q->check_lock, flags); |
| 279 | 287 | if (q->check_again) { |
| 280 | 288 | q->check_again = 0; |
| 281 | − spin_unlock_irqrestore(&q->check_lock, flags); | |
| 282 | − goto __again; | |
| 289 | + if (processed < MAX_CELL_PROCESSES_IN_QUEUE) { | |
| 290 | + spin_unlock_irqrestore(&q->check_lock, flags); | |
| 291 | + goto __again; | |
| 292 | + } | |
| 283 | 293 | } |
| 284 | 294 | q->check_blocked = 0; |
| 285 | 295 | spin_unlock_irqrestore(&q->check_lock, flags); |
| @@ -262,6 +262,16 @@ static int snd_virmidi_output_close(struct snd_rawmidi_substream *substream) · 261 unmodified lines | ||
| 262 | 262 | return 0; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | +/* | |
| 266 | + * drain output work queue | |
| 267 | + */ | |
| 268 | +static void snd_virmidi_output_drain(struct snd_rawmidi_substream *substream) | |
| 269 | +{ | |
| 270 | + struct snd_virmidi *vmidi = substream->runtime->private_data; | |
| 271 | + | |
| 272 | + flush_work(&vmidi->output_work); | |
| 273 | +} | |
| 274 | + | |
| 265 | 275 | /* |
| 266 | 276 | * subscribe callback - allow output to rawmidi device |
| 267 | 277 | */ |
| @@ -336,6 +346,7 @@ static const struct snd_rawmidi_ops snd_virmidi_output_ops = { · 68 unmodified lines | ||
| 336 | 346 | .open = snd_virmidi_output_open, |
| 337 | 347 | .close = snd_virmidi_output_close, |
| 338 | 348 | .trigger = snd_virmidi_output_trigger, |
| 349 | + .drain = snd_virmidi_output_drain, | |
| 339 | 350 | }; |
| 340 | 351 | |
| 341 | 352 | /* |
| @@ -1,201 +0,0 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0-or-later | |
| 2 | −/* | |
| 3 | − * Scatter-Gather buffer | |
| 4 | − * | |
| 5 | − * Copyright (c) by Takashi Iwai <tiwai@suse.de> | |
| 6 | − */ | |
| 7 | − | |
| 8 | −#include <linux/slab.h> | |
| 9 | −#include <linux/mm.h> | |
| 10 | −#include <linux/vmalloc.h> | |
| 11 | −#include <linux/export.h> | |
| 12 | −#include <sound/memalloc.h> | |
| 13 | −#include "memalloc_local.h" | |
| 14 | − | |
| 15 | −struct snd_sg_page { | |
| 16 | − void *buf; | |
| 17 | − dma_addr_t addr; | |
| 18 | −}; | |
| 19 | − | |
| 20 | −struct snd_sg_buf { | |
| 21 | − int size; /* allocated byte size */ | |
| 22 | − int pages; /* allocated pages */ | |
| 23 | − int tblsize; /* allocated table size */ | |
| 24 | − struct snd_sg_page *table; /* address table */ | |
| 25 | − struct page **page_table; /* page table (for vmap/vunmap) */ | |
| 26 | − struct device *dev; | |
| 27 | −}; | |
| 28 | − | |
| 29 | −/* table entries are align to 32 */ | |
| 30 | −#define SGBUF_TBL_ALIGN 32 | |
| 31 | −#define sgbuf_align_table(tbl) ALIGN((tbl), SGBUF_TBL_ALIGN) | |
| 32 | − | |
| 33 | −static void snd_dma_sg_free(struct snd_dma_buffer *dmab) | |
| 34 | −{ | |
| 35 | − struct snd_sg_buf *sgbuf = dmab->private_data; | |
| 36 | − struct snd_dma_buffer tmpb; | |
| 37 | − int i; | |
| 38 | − | |
| 39 | − if (!sgbuf) | |
| 40 | − return; | |
| 41 | − | |
| 42 | − vunmap(dmab->area); | |
| 43 | − dmab->area = NULL; | |
| 44 | − | |
| 45 | − tmpb.dev.type = SNDRV_DMA_TYPE_DEV; | |
| 46 | − if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) | |
| 47 | − tmpb.dev.type = SNDRV_DMA_TYPE_DEV_WC; | |
| 48 | − tmpb.dev.dev = sgbuf->dev; | |
| 49 | − for (i = 0; i < sgbuf->pages; i++) { | |
| 50 | − if (!(sgbuf->table[i].addr & ~PAGE_MASK)) | |
| 51 | − continue; /* continuous pages */ | |
| 52 | − tmpb.area = sgbuf->table[i].buf; | |
| 53 | − tmpb.addr = sgbuf->table[i].addr & PAGE_MASK; | |
| 54 | − tmpb.bytes = (sgbuf->table[i].addr & ~PAGE_MASK) << PAGE_SHIFT; | |
| 55 | − snd_dma_free_pages(&tmpb); | |
| 56 | − } | |
| 57 | − | |
| 58 | − kfree(sgbuf->table); | |
| 59 | − kfree(sgbuf->page_table); | |
| 60 | − kfree(sgbuf); | |
| 61 | − dmab->private_data = NULL; | |
| 62 | −} | |
| 63 | − | |
| 64 | −#define MAX_ALLOC_PAGES 32 | |
| 65 | − | |
| 66 | −static void *snd_dma_sg_alloc(struct snd_dma_buffer *dmab, size_t size) | |
| 67 | −{ | |
| 68 | − struct snd_sg_buf *sgbuf; | |
| 69 | − unsigned int i, pages, chunk, maxpages; | |
| 70 | − struct snd_dma_buffer tmpb; | |
| 71 | − struct snd_sg_page *table; | |
| 72 | − struct page **pgtable; | |
| 73 | − int type = SNDRV_DMA_TYPE_DEV; | |
| 74 | − pgprot_t prot = PAGE_KERNEL; | |
| 75 | − void *area; | |
| 76 | − | |
| 77 | − dmab->private_data = sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL); | |
| 78 | − if (!sgbuf) | |
| 79 | − return NULL; | |
| 80 | − if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) { | |
| 81 | − type = SNDRV_DMA_TYPE_DEV_WC; | |
| 82 | −#ifdef pgprot_noncached | |
| 83 | − prot = pgprot_noncached(PAGE_KERNEL); | |
| 84 | −#endif | |
| 85 | − } | |
| 86 | − sgbuf->dev = dmab->dev.dev; | |
| 87 | − pages = snd_sgbuf_aligned_pages(size); | |
| 88 | − sgbuf->tblsize = sgbuf_align_table(pages); | |
| 89 | − table = kcalloc(sgbuf->tblsize, sizeof(*table), GFP_KERNEL); | |
| 90 | − if (!table) | |
| 91 | − goto _failed; | |
| 92 | − sgbuf->table = table; | |
| 93 | − pgtable = kcalloc(sgbuf->tblsize, sizeof(*pgtable), GFP_KERNEL); | |
| 94 | − if (!pgtable) | |
| 95 | − goto _failed; | |
| 96 | − sgbuf->page_table = pgtable; | |
| 97 | − | |
| 98 | − /* allocate pages */ | |
| 99 | − maxpages = MAX_ALLOC_PAGES; | |
| 100 | − while (pages > 0) { | |
| 101 | − chunk = pages; | |
| 102 | − /* don't be too eager to take a huge chunk */ | |
| 103 | − if (chunk > maxpages) | |
| 104 | − chunk = maxpages; | |
| 105 | − chunk <<= PAGE_SHIFT; | |
| 106 | − if (snd_dma_alloc_pages_fallback(type, dmab->dev.dev, | |
| 107 | − chunk, &tmpb) < 0) { | |
| 108 | − if (!sgbuf->pages) | |
| 109 | − goto _failed; | |
| 110 | − size = sgbuf->pages * PAGE_SIZE; | |
| 111 | − break; | |
| 112 | − } | |
| 113 | − chunk = tmpb.bytes >> PAGE_SHIFT; | |
| 114 | − for (i = 0; i < chunk; i++) { | |
| 115 | − table->buf = tmpb.area; | |
| 116 | − table->addr = tmpb.addr; | |
| 117 | − if (!i) | |
| 118 | − table->addr |= chunk; /* mark head */ | |
| 119 | − table++; | |
| 120 | − *pgtable++ = virt_to_page(tmpb.area); | |
| 121 | − tmpb.area += PAGE_SIZE; | |
| 122 | − tmpb.addr += PAGE_SIZE; | |
| 123 | − } | |
| 124 | − sgbuf->pages += chunk; | |
| 125 | − pages -= chunk; | |
| 126 | − if (chunk < maxpages) | |
| 127 | − maxpages = chunk; | |
| 128 | − } | |
| 129 | − | |
| 130 | − sgbuf->size = size; | |
| 131 | − area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, prot); | |
| 132 | − if (!area) | |
| 133 | − goto _failed; | |
| 134 | − return area; | |
| 135 | − | |
| 136 | − _failed: | |
| 137 | − snd_dma_sg_free(dmab); /* free the table */ | |
| 138 | − return NULL; | |
| 139 | −} | |
| 140 | − | |
| 141 | −static dma_addr_t snd_dma_sg_get_addr(struct snd_dma_buffer *dmab, | |
| 142 | − size_t offset) | |
| 143 | −{ | |
| 144 | − struct snd_sg_buf *sgbuf = dmab->private_data; | |
| 145 | − dma_addr_t addr; | |
| 146 | − | |
| 147 | − addr = sgbuf->table[offset >> PAGE_SHIFT].addr; | |
| 148 | − addr &= ~((dma_addr_t)PAGE_SIZE - 1); | |
| 149 | − return addr + offset % PAGE_SIZE; | |
| 150 | −} | |
| 151 | − | |
| 152 | −static struct page *snd_dma_sg_get_page(struct snd_dma_buffer *dmab, | |
| 153 | − size_t offset) | |
| 154 | −{ | |
| 155 | − struct snd_sg_buf *sgbuf = dmab->private_data; | |
| 156 | − unsigned int idx = offset >> PAGE_SHIFT; | |
| 157 | − | |
| 158 | − if (idx >= (unsigned int)sgbuf->pages) | |
| 159 | − return NULL; | |
| 160 | − return sgbuf->page_table[idx]; | |
| 161 | −} | |
| 162 | − | |
| 163 | −static unsigned int snd_dma_sg_get_chunk_size(struct snd_dma_buffer *dmab, | |
| 164 | − unsigned int ofs, | |
| 165 | − unsigned int size) | |
| 166 | −{ | |
| 167 | − struct snd_sg_buf *sg = dmab->private_data; | |
| 168 | − unsigned int start, end, pg; | |
| 169 | − | |
| 170 | − start = ofs >> PAGE_SHIFT; | |
| 171 | − end = (ofs + size - 1) >> PAGE_SHIFT; | |
| 172 | − /* check page continuity */ | |
| 173 | − pg = sg->table[start].addr >> PAGE_SHIFT; | |
| 174 | − for (;;) { | |
| 175 | − start++; | |
| 176 | − if (start > end) | |
| 177 | − break; | |
| 178 | − pg++; | |
| 179 | − if ((sg->table[start].addr >> PAGE_SHIFT) != pg) | |
| 180 | − return (start << PAGE_SHIFT) - ofs; | |
| 181 | − } | |
| 182 | − /* ok, all on continuous pages */ | |
| 183 | − return size; | |
| 184 | −} | |
| 185 | − | |
| 186 | −static int snd_dma_sg_mmap(struct snd_dma_buffer *dmab, | |
| 187 | − struct vm_area_struct *area) | |
| 188 | −{ | |
| 189 | − if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) | |
| 190 | − area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); | |
| 191 | − return -ENOENT; /* continue with the default mmap handler */ | |
| 192 | −} | |
| 193 | − | |
| 194 | −const struct snd_malloc_ops snd_dma_sg_ops = { | |
| 195 | − .alloc = snd_dma_sg_alloc, | |
| 196 | − .free = snd_dma_sg_free, | |
| 197 | − .get_addr = snd_dma_sg_get_addr, | |
| 198 | − .get_page = snd_dma_sg_get_page, | |
| 199 | − .get_chunk_size = snd_dma_sg_get_chunk_size, | |
| 200 | − .mmap = snd_dma_sg_mmap, | |
| 201 | −}; | |
| @@ -90,15 +90,12 @@ static int snd_virmidi_probe(struct platform_device *devptr) · 89 unmodified lines | ||
| 90 | 90 | } |
| 91 | 91 | for (idx = 0; idx < midi_devs[dev]; idx++) { |
| 92 | 92 | struct snd_rawmidi *rmidi; |
| 93 | − struct snd_virmidi_dev *rdev; | |
| 94 | 93 | |
| 95 | 94 | err = snd_virmidi_new(card, idx, &rmidi); |
| 96 | 95 | if (err < 0) |
| 97 | 96 | return err; |
| 98 | − rdev = rmidi->private_data; | |
| 99 | 97 | vmidi->midi[idx] = rmidi; |
| 100 | 98 | strcpy(rmidi->name, "Virtual Raw MIDI"); |
| 101 | − rdev->seq_mode = SNDRV_VIRMIDI_SEQ_DISPATCH; | |
| 102 | 99 | } |
| 103 | 100 | |
| 104 | 101 | strcpy(card->driver, "VirMIDI"); |
| @@ -18,7 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | /** |
| 19 | 19 | * snd_hdac_ext_stream_init - initialize each stream (aka device) |
| 20 | 20 | * @bus: HD-audio core bus |
| 21 | − * @stream: HD-audio ext core stream object to initialize | |
| 21 | + * @hext_stream: HD-audio ext core stream object to initialize | |
| 22 | 22 | * @idx: stream index number |
| 23 | 23 | * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE) |
| 24 | 24 | * @tag: the tag id to assign |
| @@ -27,34 +27,34 @@ · 2 unmodified lines | ||
| 27 | 27 | * invoke hdac stream initialization routine |
| 28 | 28 | */ |
| 29 | 29 | void snd_hdac_ext_stream_init(struct hdac_bus *bus, |
| 30 | − struct hdac_ext_stream *stream, | |
| 31 | − int idx, int direction, int tag) | |
| 30 | + struct hdac_ext_stream *hext_stream, | |
| 31 | + int idx, int direction, int tag) | |
| 32 | 32 | { |
| 33 | 33 | if (bus->ppcap) { |
| 34 | − stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE + | |
| 34 | + hext_stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE + | |
| 35 | 35 | AZX_PPHC_INTERVAL * idx; |
| 36 | 36 | |
| 37 | − stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE + | |
| 37 | + hext_stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE + | |
| 38 | 38 | AZX_PPLC_MULTI * bus->num_streams + |
| 39 | 39 | AZX_PPLC_INTERVAL * idx; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | if (bus->spbcap) { |
| 43 | − stream->spib_addr = bus->spbcap + AZX_SPB_BASE + | |
| 43 | + hext_stream->spib_addr = bus->spbcap + AZX_SPB_BASE + | |
| 44 | 44 | AZX_SPB_INTERVAL * idx + |
| 45 | 45 | AZX_SPB_SPIB; |
| 46 | 46 | |
| 47 | − stream->fifo_addr = bus->spbcap + AZX_SPB_BASE + | |
| 47 | + hext_stream->fifo_addr = bus->spbcap + AZX_SPB_BASE + | |
| 48 | 48 | AZX_SPB_INTERVAL * idx + |
| 49 | 49 | AZX_SPB_MAXFIFO; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | if (bus->drsmcap) |
| 53 | − stream->dpibr_addr = bus->drsmcap + AZX_DRSM_BASE + | |
| 53 | + hext_stream->dpibr_addr = bus->drsmcap + AZX_DRSM_BASE + | |
| 54 | 54 | AZX_DRSM_INTERVAL * idx; |
| 55 | 55 | |
| 56 | − stream->decoupled = false; | |
| 57 | − snd_hdac_stream_init(bus, &stream->hstream, idx, direction, tag); | |
| 56 | + hext_stream->decoupled = false; | |
| 57 | + snd_hdac_stream_init(bus, &hext_stream->hstream, idx, direction, tag); | |
| 58 | 58 | } |
| 59 | 59 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init); |
| 60 | 60 | |
| @@ -67,18 +67,18 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init); · 6 unmodified lines | ||
| 67 | 67 | * @dir: direction of streams |
| 68 | 68 | */ |
| 69 | 69 | int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, |
| 70 | − int num_stream, int dir) | |
| 70 | + int num_stream, int dir) | |
| 71 | 71 | { |
| 72 | 72 | int stream_tag = 0; |
| 73 | 73 | int i, tag, idx = start_idx; |
| 74 | 74 | |
| 75 | 75 | for (i = 0; i < num_stream; i++) { |
| 76 | − struct hdac_ext_stream *stream = | |
| 77 | − kzalloc(sizeof(*stream), GFP_KERNEL); | |
| 78 | − if (!stream) | |
| 76 | + struct hdac_ext_stream *hext_stream = | |
| 77 | + kzalloc(sizeof(*hext_stream), GFP_KERNEL); | |
| 78 | + if (!hext_stream) | |
| 79 | 79 | return -ENOMEM; |
| 80 | 80 | tag = ++stream_tag; |
| 81 | − snd_hdac_ext_stream_init(bus, stream, idx, dir, tag); | |
| 81 | + snd_hdac_ext_stream_init(bus, hext_stream, idx, dir, tag); | |
| 82 | 82 | idx++; |
| 83 | 83 | } |
| 84 | 84 | |
| @@ -95,22 +95,22 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init_all); · 10 unmodified lines | ||
| 95 | 95 | void snd_hdac_stream_free_all(struct hdac_bus *bus) |
| 96 | 96 | { |
| 97 | 97 | struct hdac_stream *s, *_s; |
| 98 | − struct hdac_ext_stream *stream; | |
| 98 | + struct hdac_ext_stream *hext_stream; | |
| 99 | 99 | |
| 100 | 100 | list_for_each_entry_safe(s, _s, &bus->stream_list, list) { |
| 101 | − stream = stream_to_hdac_ext_stream(s); | |
| 102 | − snd_hdac_ext_stream_decouple(bus, stream, false); | |
| 101 | + hext_stream = stream_to_hdac_ext_stream(s); | |
| 102 | + snd_hdac_ext_stream_decouple(bus, hext_stream, false); | |
| 103 | 103 | list_del(&s->list); |
| 104 | − kfree(stream); | |
| 104 | + kfree(hext_stream); | |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all); |
| 108 | 108 | |
| 109 | 109 | void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, |
| 110 | − struct hdac_ext_stream *stream, | |
| 110 | + struct hdac_ext_stream *hext_stream, | |
| 111 | 111 | bool decouple) |
| 112 | 112 | { |
| 113 | − struct hdac_stream *hstream = &stream->hstream; | |
| 113 | + struct hdac_stream *hstream = &hext_stream->hstream; | |
| 114 | 114 | u32 val; |
| 115 | 115 | int mask = AZX_PPCTL_PROCEN(hstream->index); |
| 116 | 116 | |
| @@ -121,76 +121,76 @@ void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, · 4 unmodified lines | ||
| 121 | 121 | else if (!decouple && val) |
| 122 | 122 | snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, mask, 0); |
| 123 | 123 | |
| 124 | − stream->decoupled = decouple; | |
| 124 | + hext_stream->decoupled = decouple; | |
| 125 | 125 | } |
| 126 | 126 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple_locked); |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * snd_hdac_ext_stream_decouple - decouple the hdac stream |
| 130 | 130 | * @bus: HD-audio core bus |
| 131 | − * @stream: HD-audio ext core stream object to initialize | |
| 131 | + * @hext_stream: HD-audio ext core stream object to initialize | |
| 132 | 132 | * @decouple: flag to decouple |
| 133 | 133 | */ |
| 134 | 134 | void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, |
| 135 | − struct hdac_ext_stream *stream, bool decouple) | |
| 135 | + struct hdac_ext_stream *hext_stream, bool decouple) | |
| 136 | 136 | { |
| 137 | 137 | spin_lock_irq(&bus->reg_lock); |
| 138 | − snd_hdac_ext_stream_decouple_locked(bus, stream, decouple); | |
| 138 | + snd_hdac_ext_stream_decouple_locked(bus, hext_stream, decouple); | |
| 139 | 139 | spin_unlock_irq(&bus->reg_lock); |
| 140 | 140 | } |
| 141 | 141 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple); |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * snd_hdac_ext_link_stream_start - start a stream |
| 145 | − * @stream: HD-audio ext core stream to start | |
| 145 | + * @hext_stream: HD-audio ext core stream to start | |
| 146 | 146 | */ |
| 147 | −void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *stream) | |
| 147 | +void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hext_stream) | |
| 148 | 148 | { |
| 149 | − snd_hdac_updatel(stream->pplc_addr, AZX_REG_PPLCCTL, | |
| 149 | + snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, | |
| 150 | 150 | AZX_PPLCCTL_RUN, AZX_PPLCCTL_RUN); |
| 151 | 151 | } |
| 152 | 152 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_start); |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * snd_hdac_ext_link_stream_clear - stop a stream DMA |
| 156 | − * @stream: HD-audio ext core stream to stop | |
| 156 | + * @hext_stream: HD-audio ext core stream to stop | |
| 157 | 157 | */ |
| 158 | −void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *stream) | |
| 158 | +void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hext_stream) | |
| 159 | 159 | { |
| 160 | − snd_hdac_updatel(stream->pplc_addr, AZX_REG_PPLCCTL, AZX_PPLCCTL_RUN, 0); | |
| 160 | + snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, AZX_PPLCCTL_RUN, 0); | |
| 161 | 161 | } |
| 162 | 162 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_clear); |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * snd_hdac_ext_link_stream_reset - reset a stream |
| 166 | − * @stream: HD-audio ext core stream to reset | |
| 166 | + * @hext_stream: HD-audio ext core stream to reset | |
| 167 | 167 | */ |
| 168 | −void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *stream) | |
| 168 | +void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hext_stream) | |
| 169 | 169 | { |
| 170 | 170 | unsigned char val; |
| 171 | 171 | int timeout; |
| 172 | 172 | |
| 173 | − snd_hdac_ext_link_stream_clear(stream); | |
| 173 | + snd_hdac_ext_link_stream_clear(hext_stream); | |
| 174 | 174 | |
| 175 | − snd_hdac_updatel(stream->pplc_addr, AZX_REG_PPLCCTL, | |
| 175 | + snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, | |
| 176 | 176 | AZX_PPLCCTL_STRST, AZX_PPLCCTL_STRST); |
| 177 | 177 | udelay(3); |
| 178 | 178 | timeout = 50; |
| 179 | 179 | do { |
| 180 | − val = readl(stream->pplc_addr + AZX_REG_PPLCCTL) & | |
| 180 | + val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL) & | |
| 181 | 181 | AZX_PPLCCTL_STRST; |
| 182 | 182 | if (val) |
| 183 | 183 | break; |
| 184 | 184 | udelay(3); |
| 185 | 185 | } while (--timeout); |
| 186 | 186 | val &= ~AZX_PPLCCTL_STRST; |
| 187 | − writel(val, stream->pplc_addr + AZX_REG_PPLCCTL); | |
| 187 | + writel(val, hext_stream->pplc_addr + AZX_REG_PPLCCTL); | |
| 188 | 188 | udelay(3); |
| 189 | 189 | |
| 190 | 190 | timeout = 50; |
| 191 | 191 | /* waiting for hardware to report that the stream is out of reset */ |
| 192 | 192 | do { |
| 193 | − val = readl(stream->pplc_addr + AZX_REG_PPLCCTL) & AZX_PPLCCTL_STRST; | |
| 193 | + val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL) & AZX_PPLCCTL_STRST; | |
| 194 | 194 | if (!val) |
| 195 | 195 | break; |
| 196 | 196 | udelay(3); |
| @@ -201,24 +201,24 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_reset); · 4 unmodified lines | ||
| 201 | 201 | |
| 202 | 202 | /** |
| 203 | 203 | * snd_hdac_ext_link_stream_setup - set up the SD for streaming |
| 204 | − * @stream: HD-audio ext core stream to set up | |
| 204 | + * @hext_stream: HD-audio ext core stream to set up | |
| 205 | 205 | * @fmt: stream format |
| 206 | 206 | */ |
| 207 | −int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt) | |
| 207 | +int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *hext_stream, int fmt) | |
| 208 | 208 | { |
| 209 | − struct hdac_stream *hstream = &stream->hstream; | |
| 209 | + struct hdac_stream *hstream = &hext_stream->hstream; | |
| 210 | 210 | unsigned int val; |
| 211 | 211 | |
| 212 | 212 | /* make sure the run bit is zero for SD */ |
| 213 | − snd_hdac_ext_link_stream_clear(stream); | |
| 213 | + snd_hdac_ext_link_stream_clear(hext_stream); | |
| 214 | 214 | /* program the stream_tag */ |
| 215 | − val = readl(stream->pplc_addr + AZX_REG_PPLCCTL); | |
| 215 | + val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL); | |
| 216 | 216 | val = (val & ~AZX_PPLCCTL_STRM_MASK) | |
| 217 | 217 | (hstream->stream_tag << AZX_PPLCCTL_STRM_SHIFT); |
| 218 | − writel(val, stream->pplc_addr + AZX_REG_PPLCCTL); | |
| 218 | + writel(val, hext_stream->pplc_addr + AZX_REG_PPLCCTL); | |
| 219 | 219 | |
| 220 | 220 | /* program the stream format */ |
| 221 | − writew(fmt, stream->pplc_addr + AZX_REG_PPLCFMT); | |
| 221 | + writew(fmt, hext_stream->pplc_addr + AZX_REG_PPLCFMT); | |
| 222 | 222 | |
| 223 | 223 | return 0; |
| 224 | 224 | } |
| @@ -230,7 +230,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_setup); · 5 unmodified lines | ||
| 230 | 230 | * @stream: stream id |
| 231 | 231 | */ |
| 232 | 232 | void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, |
| 233 | − int stream) | |
| 233 | + int stream) | |
| 234 | 234 | { |
| 235 | 235 | snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 1 << stream); |
| 236 | 236 | } |
| @@ -250,10 +250,10 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id); · 13 unmodified lines | ||
| 250 | 250 | |
| 251 | 251 | static struct hdac_ext_stream * |
| 252 | 252 | hdac_ext_link_stream_assign(struct hdac_bus *bus, |
| 253 | − struct snd_pcm_substream *substream) | |
| 253 | + struct snd_pcm_substream *substream) | |
| 254 | 254 | { |
| 255 | 255 | struct hdac_ext_stream *res = NULL; |
| 256 | − struct hdac_stream *stream = NULL; | |
| 256 | + struct hdac_stream *hstream = NULL; | |
| 257 | 257 | |
| 258 | 258 | if (!bus->ppcap) { |
| 259 | 259 | dev_err(bus->dev, "stream type not supported\n"); |
| @@ -261,22 +261,22 @@ hdac_ext_link_stream_assign(struct hdac_bus *bus, · 1 unmodified line | ||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | spin_lock_irq(&bus->reg_lock); |
| 264 | − list_for_each_entry(stream, &bus->stream_list, list) { | |
| 265 | − struct hdac_ext_stream *hstream = container_of(stream, | |
| 266 | − struct hdac_ext_stream, | |
| 267 | − hstream); | |
| 268 | − if (stream->direction != substream->stream) | |
| 264 | + list_for_each_entry(hstream, &bus->stream_list, list) { | |
| 265 | + struct hdac_ext_stream *hext_stream = container_of(hstream, | |
| 266 | + struct hdac_ext_stream, | |
| 267 | + hstream); | |
| 268 | + if (hstream->direction != substream->stream) | |
| 269 | 269 | continue; |
| 270 | 270 | |
| 271 | 271 | /* check if decoupled stream and not in use is available */ |
| 272 | − if (hstream->decoupled && !hstream->link_locked) { | |
| 273 | − res = hstream; | |
| 272 | + if (hext_stream->decoupled && !hext_stream->link_locked) { | |
| 273 | + res = hext_stream; | |
| 274 | 274 | break; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | − if (!hstream->link_locked) { | |
| 278 | − snd_hdac_ext_stream_decouple_locked(bus, hstream, true); | |
| 279 | − res = hstream; | |
| 277 | + if (!hext_stream->link_locked) { | |
| 278 | + snd_hdac_ext_stream_decouple_locked(bus, hext_stream, true); | |
| 279 | + res = hext_stream; | |
| 280 | 280 | break; |
| 281 | 281 | } |
| 282 | 282 | } |
| @@ -290,10 +290,10 @@ hdac_ext_link_stream_assign(struct hdac_bus *bus, · 7 unmodified lines | ||
| 290 | 290 | |
| 291 | 291 | static struct hdac_ext_stream * |
| 292 | 292 | hdac_ext_host_stream_assign(struct hdac_bus *bus, |
| 293 | − struct snd_pcm_substream *substream) | |
| 293 | + struct snd_pcm_substream *substream) | |
| 294 | 294 | { |
| 295 | 295 | struct hdac_ext_stream *res = NULL; |
| 296 | − struct hdac_stream *stream = NULL; | |
| 296 | + struct hdac_stream *hstream = NULL; | |
| 297 | 297 | |
| 298 | 298 | if (!bus->ppcap) { |
| 299 | 299 | dev_err(bus->dev, "stream type not supported\n"); |
| @@ -301,17 +301,17 @@ hdac_ext_host_stream_assign(struct hdac_bus *bus, · 1 unmodified line | ||
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | spin_lock_irq(&bus->reg_lock); |
| 304 | − list_for_each_entry(stream, &bus->stream_list, list) { | |
| 305 | − struct hdac_ext_stream *hstream = container_of(stream, | |
| 306 | − struct hdac_ext_stream, | |
| 307 | − hstream); | |
| 308 | − if (stream->direction != substream->stream) | |
| 304 | + list_for_each_entry(hstream, &bus->stream_list, list) { | |
| 305 | + struct hdac_ext_stream *hext_stream = container_of(hstream, | |
| 306 | + struct hdac_ext_stream, | |
| 307 | + hstream); | |
| 308 | + if (hstream->direction != substream->stream) | |
| 309 | 309 | continue; |
| 310 | 310 | |
| 311 | − if (!stream->opened) { | |
| 312 | − if (!hstream->decoupled) | |
| 313 | − snd_hdac_ext_stream_decouple_locked(bus, hstream, true); | |
| 314 | − res = hstream; | |
| 311 | + if (!hstream->opened) { | |
| 312 | + if (!hext_stream->decoupled) | |
| 313 | + snd_hdac_ext_stream_decouple_locked(bus, hext_stream, true); | |
| 314 | + res = hext_stream; | |
| 315 | 315 | break; |
| 316 | 316 | } |
| 317 | 317 | } |
| @@ -346,16 +346,17 @@ struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, · 28 unmodified lines | ||
| 346 | 346 | struct snd_pcm_substream *substream, |
| 347 | 347 | int type) |
| 348 | 348 | { |
| 349 | − struct hdac_ext_stream *hstream = NULL; | |
| 350 | − struct hdac_stream *stream = NULL; | |
| 349 | + struct hdac_ext_stream *hext_stream = NULL; | |
| 350 | + struct hdac_stream *hstream = NULL; | |
| 351 | 351 | |
| 352 | 352 | switch (type) { |
| 353 | 353 | case HDAC_EXT_STREAM_TYPE_COUPLED: |
| 354 | − stream = snd_hdac_stream_assign(bus, substream); | |
| 355 | − if (stream) | |
| 356 | − hstream = container_of(stream, | |
| 357 | − struct hdac_ext_stream, hstream); | |
| 358 | − return hstream; | |
| 354 | + hstream = snd_hdac_stream_assign(bus, substream); | |
| 355 | + if (hstream) | |
| 356 | + hext_stream = container_of(hstream, | |
| 357 | + struct hdac_ext_stream, | |
| 358 | + hstream); | |
| 359 | + return hext_stream; | |
| 359 | 360 | |
| 360 | 361 | case HDAC_EXT_STREAM_TYPE_HOST: |
| 361 | 362 | return hdac_ext_host_stream_assign(bus, substream); |
| @@ -371,34 +372,34 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_assign); · 9 unmodified lines | ||
| 371 | 372 | |
| 372 | 373 | /** |
| 373 | 374 | * snd_hdac_ext_stream_release - release the assigned stream |
| 374 | − * @stream: HD-audio ext core stream to release | |
| 375 | + * @hext_stream: HD-audio ext core stream to release | |
| 375 | 376 | * @type: type of stream (coupled, host or link stream) |
| 376 | 377 | * |
| 377 | 378 | * Release the stream that has been assigned by snd_hdac_ext_stream_assign(). |
| 378 | 379 | */ |
| 379 | −void snd_hdac_ext_stream_release(struct hdac_ext_stream *stream, int type) | |
| 380 | +void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type) | |
| 380 | 381 | { |
| 381 | − struct hdac_bus *bus = stream->hstream.bus; | |
| 382 | + struct hdac_bus *bus = hext_stream->hstream.bus; | |
| 382 | 383 | |
| 383 | 384 | switch (type) { |
| 384 | 385 | case HDAC_EXT_STREAM_TYPE_COUPLED: |
| 385 | − snd_hdac_stream_release(&stream->hstream); | |
| 386 | + snd_hdac_stream_release(&hext_stream->hstream); | |
| 386 | 387 | break; |
| 387 | 388 | |
| 388 | 389 | case HDAC_EXT_STREAM_TYPE_HOST: |
| 389 | 390 | spin_lock_irq(&bus->reg_lock); |
| 390 | − if (stream->decoupled && !stream->link_locked) | |
| 391 | − snd_hdac_ext_stream_decouple_locked(bus, stream, false); | |
| 391 | + if (hext_stream->decoupled && !hext_stream->link_locked) | |
| 392 | + snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); | |
| 392 | 393 | spin_unlock_irq(&bus->reg_lock); |
| 393 | − snd_hdac_stream_release(&stream->hstream); | |
| 394 | + snd_hdac_stream_release(&hext_stream->hstream); | |
| 394 | 395 | break; |
| 395 | 396 | |
| 396 | 397 | case HDAC_EXT_STREAM_TYPE_LINK: |
| 397 | 398 | spin_lock_irq(&bus->reg_lock); |
| 398 | − if (stream->decoupled && !stream->hstream.opened) | |
| 399 | − snd_hdac_ext_stream_decouple_locked(bus, stream, false); | |
| 400 | − stream->link_locked = 0; | |
| 401 | − stream->link_substream = NULL; | |
| 399 | + if (hext_stream->decoupled && !hext_stream->hstream.opened) | |
| 400 | + snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); | |
| 401 | + hext_stream->link_locked = 0; | |
| 402 | + hext_stream->link_substream = NULL; | |
| 402 | 403 | spin_unlock_irq(&bus->reg_lock); |
| 403 | 404 | break; |
| 404 | 405 | |
| @@ -437,11 +438,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_spbcap_enable); · 32 unmodified lines | ||
| 437 | 438 | /** |
| 438 | 439 | * snd_hdac_ext_stream_set_spib - sets the spib value of a stream |
| 439 | 440 | * @bus: HD-audio core bus |
| 440 | − * @stream: hdac_ext_stream | |
| 441 | + * @hext_stream: hdac_ext_stream | |
| 441 | 442 | * @value: spib value to set |
| 442 | 443 | */ |
| 443 | 444 | int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, |
| 444 | − struct hdac_ext_stream *stream, u32 value) | |
| 445 | + struct hdac_ext_stream *hext_stream, u32 value) | |
| 445 | 446 | { |
| 446 | 447 | |
| 447 | 448 | if (!bus->spbcap) { |
| @@ -449,7 +450,7 @@ int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, · 1 unmodified line | ||
| 449 | 450 | return -EINVAL; |
| 450 | 451 | } |
| 451 | 452 | |
| 452 | − writel(value, stream->spib_addr); | |
| 453 | + writel(value, hext_stream->spib_addr); | |
| 453 | 454 | |
| 454 | 455 | return 0; |
| 455 | 456 | } |
| @@ -458,12 +459,12 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_spib); · 2 unmodified lines | ||
| 458 | 459 | /** |
| 459 | 460 | * snd_hdac_ext_stream_get_spbmaxfifo - gets the spib value of a stream |
| 460 | 461 | * @bus: HD-audio core bus |
| 461 | − * @stream: hdac_ext_stream | |
| 462 | + * @hext_stream: hdac_ext_stream | |
| 462 | 463 | * |
| 463 | 464 | * Return maxfifo for the stream |
| 464 | 465 | */ |
| 465 | 466 | int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, |
| 466 | − struct hdac_ext_stream *stream) | |
| 467 | + struct hdac_ext_stream *hext_stream) | |
| 467 | 468 | { |
| 468 | 469 | |
| 469 | 470 | if (!bus->spbcap) { |
| @@ -471,27 +472,10 @@ int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, · 1 unmodified line | ||
| 471 | 472 | return -EINVAL; |
| 472 | 473 | } |
| 473 | 474 | |
| 474 | − return readl(stream->fifo_addr); | |
| 475 | + return readl(hext_stream->fifo_addr); | |
| 475 | 476 | } |
| 476 | 477 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_get_spbmaxfifo); |
| 477 | 478 | |
| 478 | − | |
| 479 | −/** | |
| 480 | − * snd_hdac_ext_stop_streams - stop all stream if running | |
| 481 | − * @bus: HD-audio core bus | |
| 482 | − */ | |
| 483 | −void snd_hdac_ext_stop_streams(struct hdac_bus *bus) | |
| 484 | −{ | |
| 485 | − struct hdac_stream *stream; | |
| 486 | − | |
| 487 | − if (bus->chip_init) { | |
| 488 | − list_for_each_entry(stream, &bus->stream_list, list) | |
| 489 | − snd_hdac_stream_stop(stream); | |
| 490 | − snd_hdac_bus_stop_chip(bus); | |
| 491 | − } | |
| 492 | −} | |
| 493 | −EXPORT_SYMBOL_GPL(snd_hdac_ext_stop_streams); | |
| 494 | − | |
| 495 | 479 | /** |
| 496 | 480 | * snd_hdac_ext_stream_drsm_enable - enable DMA resume for a stream |
| 497 | 481 | * @bus: HD-audio core bus |
| @@ -520,11 +504,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_drsm_enable); · 22 unmodified lines | ||
| 520 | 504 | /** |
| 521 | 505 | * snd_hdac_ext_stream_set_dpibr - sets the dpibr value of a stream |
| 522 | 506 | * @bus: HD-audio core bus |
| 523 | − * @stream: hdac_ext_stream | |
| 507 | + * @hext_stream: hdac_ext_stream | |
| 524 | 508 | * @value: dpib value to set |
| 525 | 509 | */ |
| 526 | 510 | int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, |
| 527 | − struct hdac_ext_stream *stream, u32 value) | |
| 511 | + struct hdac_ext_stream *hext_stream, u32 value) | |
| 528 | 512 | { |
| 529 | 513 | |
| 530 | 514 | if (!bus->drsmcap) { |
| @@ -532,7 +516,7 @@ int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, · 1 unmodified line | ||
| 532 | 516 | return -EINVAL; |
| 533 | 517 | } |
| 534 | 518 | |
| 535 | − writel(value, stream->dpibr_addr); | |
| 519 | + writel(value, hext_stream->dpibr_addr); | |
| 536 | 520 | |
| 537 | 521 | return 0; |
| 538 | 522 | } |
| @@ -540,12 +524,12 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_dpibr); · 1 unmodified line | ||
| 540 | 524 | |
| 541 | 525 | /** |
| 542 | 526 | * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream |
| 543 | − * @stream: hdac_ext_stream | |
| 527 | + * @hext_stream: hdac_ext_stream | |
| 544 | 528 | * @value: lpib value to set |
| 545 | 529 | */ |
| 546 | −int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *stream, u32 value) | |
| 530 | +int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *hext_stream, u32 value) | |
| 547 | 531 | { |
| 548 | − snd_hdac_stream_writel(&stream->hstream, SD_LPIB, value); | |
| 532 | + snd_hdac_stream_writel(&hext_stream->hstream, SD_LPIB, value); | |
| 549 | 533 | |
| 550 | 534 | return 0; |
| 551 | 535 | } |
| @@ -142,6 +142,22 @@ void snd_hdac_stream_stop(struct hdac_stream *azx_dev) · 141 unmodified lines | ||
| 142 | 142 | } |
| 143 | 143 | EXPORT_SYMBOL_GPL(snd_hdac_stream_stop); |
| 144 | 144 | |
| 145 | +/** | |
| 146 | + * snd_hdac_stop_streams_and_chip - stop all streams and chip if running | |
| 147 | + * @bus: HD-audio core bus | |
| 148 | + */ | |
| 149 | +void snd_hdac_stop_streams_and_chip(struct hdac_bus *bus) | |
| 150 | +{ | |
| 151 | + struct hdac_stream *stream; | |
| 152 | + | |
| 153 | + if (bus->chip_init) { | |
| 154 | + list_for_each_entry(stream, &bus->stream_list, list) | |
| 155 | + snd_hdac_stream_stop(stream); | |
| 156 | + snd_hdac_bus_stop_chip(bus); | |
| 157 | + } | |
| 158 | +} | |
| 159 | +EXPORT_SYMBOL_GPL(snd_hdac_stop_streams_and_chip); | |
| 160 | + | |
| 145 | 161 | /** |
| 146 | 162 | * snd_hdac_stream_reset - reset a stream |
| 147 | 163 | * @azx_dev: HD-audio core stream to reset |
| @@ -534,17 +550,11 @@ static void azx_timecounter_init(struct hdac_stream *azx_dev, · 386 unmodified lines | ||
| 534 | 550 | cc->mask = CLOCKSOURCE_MASK(32); |
| 535 | 551 | |
| 536 | 552 | /* |
| 537 | − * Converting from 24 MHz to ns means applying a 125/3 factor. | |
| 538 | − * To avoid any saturation issues in intermediate operations, | |
| 539 | − * the 125 factor is applied first. The division is applied | |
| 540 | − * last after reading the timecounter value. | |
| 541 | − * Applying the 1/3 factor as part of the multiplication | |
| 542 | − * requires at least 20 bits for a decent precision, however | |
| 543 | − * overflows occur after about 4 hours or less, not a option. | |
| 553 | + * Calculate the optimal mult/shift values. The counter wraps | |
| 554 | + * around after ~178.9 seconds. | |
| 544 | 555 | */ |
| 545 | − | |
| 546 | − cc->mult = 125; /* saturation after 195 years */ | |
| 547 | − cc->shift = 0; | |
| 556 | + clocks_calc_mult_shift(&cc->mult, &cc->shift, 24000000, | |
| 557 | + NSEC_PER_SEC, 178); | |
| 548 | 558 | |
| 549 | 559 | nsec = 0; /* audio time is elapsed time since trigger */ |
| 550 | 560 | timecounter_init(tc, cc, nsec); |
| @@ -249,13 +249,13 @@ static const struct config_entry config_table[] = { · 248 unmodified lines | ||
| 249 | 249 | } |
| 250 | 250 | }, |
| 251 | 251 | { |
| 252 | − .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 252 | + .flags = FLAG_SOF, | |
| 253 | 253 | .device = 0x02c8, |
| 254 | + .codec_hid = "ESSX8336", | |
| 254 | 255 | }, |
| 255 | 256 | { |
| 256 | − .flags = FLAG_SOF, | |
| 257 | + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 257 | 258 | .device = 0x02c8, |
| 258 | − .codec_hid = "ESSX8336", | |
| 259 | 259 | }, |
| 260 | 260 | /* Cometlake-H */ |
| 261 | 261 | { |
| @@ -278,14 +278,14 @@ static const struct config_entry config_table[] = { · 16 unmodified lines | ||
| 278 | 278 | } |
| 279 | 279 | }, |
| 280 | 280 | { |
| 281 | − .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 282 | − .device = 0x06c8, | |
| 283 | − }, | |
| 284 | − { | |
| 285 | 281 | .flags = FLAG_SOF, |
| 286 | 282 | .device = 0x06c8, |
| 287 | 283 | .codec_hid = "ESSX8336", |
| 288 | 284 | }, |
| 285 | + { | |
| 286 | + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 287 | + .device = 0x06c8, | |
| 288 | + }, | |
| 289 | 289 | #endif |
| 290 | 290 | |
| 291 | 291 | /* Icelake */ |
| @@ -309,13 +309,30 @@ static const struct config_entry config_table[] = { · 17 unmodified lines | ||
| 309 | 309 | }, |
| 310 | 310 | #endif |
| 311 | 311 | |
| 312 | −/* JasperLake */ | |
| 312 | +/* Jasper Lake */ | |
| 313 | 313 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_JASPERLAKE) |
| 314 | + { | |
| 315 | + .flags = FLAG_SOF, | |
| 316 | + .device = 0x4dc8, | |
| 317 | + .dmi_table = (const struct dmi_system_id []) { | |
| 318 | + { | |
| 319 | + .ident = "Google Chromebooks", | |
| 320 | + .matches = { | |
| 321 | + DMI_MATCH(DMI_SYS_VENDOR, "Google"), | |
| 322 | + } | |
| 323 | + }, | |
| 324 | + {} | |
| 325 | + } | |
| 326 | + }, | |
| 314 | 327 | { |
| 315 | 328 | .flags = FLAG_SOF, |
| 316 | 329 | .device = 0x4dc8, |
| 317 | 330 | .codec_hid = "ESSX8336", |
| 318 | 331 | }, |
| 332 | + { | |
| 333 | + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC, | |
| 334 | + .device = 0x4dc8, | |
| 335 | + }, | |
| 319 | 336 | #endif |
| 320 | 337 | |
| 321 | 338 | /* Tigerlake */ |
| @@ -334,17 +351,17 @@ static const struct config_entry config_table[] = { · 12 unmodified lines | ||
| 334 | 351 | } |
| 335 | 352 | }, |
| 336 | 353 | { |
| 337 | − .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 354 | + .flags = FLAG_SOF, | |
| 338 | 355 | .device = 0xa0c8, |
| 356 | + .codec_hid = "ESSX8336", | |
| 339 | 357 | }, |
| 340 | 358 | { |
| 341 | 359 | .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, |
| 342 | − .device = 0x43c8, | |
| 360 | + .device = 0xa0c8, | |
| 343 | 361 | }, |
| 344 | 362 | { |
| 345 | − .flags = FLAG_SOF, | |
| 346 | − .device = 0xa0c8, | |
| 347 | − .codec_hid = "ESSX8336", | |
| 363 | + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 364 | + .device = 0x43c8, | |
| 348 | 365 | }, |
| 349 | 366 | #endif |
| 350 | 367 | |
| @@ -374,6 +391,14 @@ static const struct config_entry config_table[] = { · 23 unmodified lines | ||
| 374 | 391 | .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, |
| 375 | 392 | .device = 0x51cc, |
| 376 | 393 | }, |
| 394 | + { | |
| 395 | + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 396 | + .device = 0x51cd, | |
| 397 | + }, | |
| 398 | + { | |
| 399 | + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 400 | + .device = 0x54c8, | |
| 401 | + }, | |
| 377 | 402 | #endif |
| 378 | 403 | |
| 379 | 404 | }; |
| @@ -403,7 +428,7 @@ static int snd_intel_dsp_check_dmic(struct pci_dev *pci) · 23 unmodified lines | ||
| 403 | 428 | |
| 404 | 429 | nhlt = intel_nhlt_init(&pci->dev); |
| 405 | 430 | if (nhlt) { |
| 406 | − if (intel_nhlt_get_dmic_geo(&pci->dev, nhlt)) | |
| 431 | + if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_DMIC)) | |
| 407 | 432 | ret = 1; |
| 408 | 433 | intel_nhlt_free(nhlt); |
| 409 | 434 | } |
| @@ -110,3 +110,105 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) · 109 unmodified lines | ||
| 110 | 110 | return dmic_geo; |
| 111 | 111 | } |
| 112 | 112 | EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo); |
| 113 | + | |
| 114 | +bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type) | |
| 115 | +{ | |
| 116 | + struct nhlt_endpoint *epnt; | |
| 117 | + int i; | |
| 118 | + | |
| 119 | + if (!nhlt) | |
| 120 | + return false; | |
| 121 | + | |
| 122 | + epnt = (struct nhlt_endpoint *)nhlt->desc; | |
| 123 | + for (i = 0; i < nhlt->endpoint_count; i++) { | |
| 124 | + if (epnt->linktype == link_type) | |
| 125 | + return true; | |
| 126 | + | |
| 127 | + epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); | |
| 128 | + } | |
| 129 | + return false; | |
| 130 | +} | |
| 131 | +EXPORT_SYMBOL(intel_nhlt_has_endpoint_type); | |
| 132 | + | |
| 133 | +static struct nhlt_specific_cfg * | |
| 134 | +nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch, | |
| 135 | + u32 rate, u8 vbps, u8 bps) | |
| 136 | +{ | |
| 137 | + struct nhlt_fmt_cfg *cfg = fmt->fmt_config; | |
| 138 | + struct wav_fmt *wfmt; | |
| 139 | + u16 _bps, _vbps; | |
| 140 | + int i; | |
| 141 | + | |
| 142 | + dev_dbg(dev, "Endpoint format count=%d\n", fmt->fmt_count); | |
| 143 | + | |
| 144 | + for (i = 0; i < fmt->fmt_count; i++) { | |
| 145 | + wfmt = &cfg->fmt_ext.fmt; | |
| 146 | + _bps = wfmt->bits_per_sample; | |
| 147 | + _vbps = cfg->fmt_ext.sample.valid_bits_per_sample; | |
| 148 | + | |
| 149 | + dev_dbg(dev, "Endpoint format: ch=%d fmt=%d/%d rate=%d\n", | |
| 150 | + wfmt->channels, _vbps, _bps, wfmt->samples_per_sec); | |
| 151 | + | |
| 152 | + if (wfmt->channels == num_ch && wfmt->samples_per_sec == rate && | |
| 153 | + vbps == _vbps && bps == _bps) | |
| 154 | + return &cfg->config; | |
| 155 | + | |
| 156 | + cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size); | |
| 157 | + } | |
| 158 | + | |
| 159 | + return NULL; | |
| 160 | +} | |
| 161 | + | |
| 162 | +static bool nhlt_check_ep_match(struct device *dev, struct nhlt_endpoint *epnt, | |
| 163 | + u32 bus_id, u8 link_type, u8 dir, u8 dev_type) | |
| 164 | +{ | |
| 165 | + dev_dbg(dev, "Endpoint: vbus_id=%d link_type=%d dir=%d dev_type = %d\n", | |
| 166 | + epnt->virtual_bus_id, epnt->linktype, | |
| 167 | + epnt->direction, epnt->device_type); | |
| 168 | + | |
| 169 | + if ((epnt->virtual_bus_id != bus_id) || | |
| 170 | + (epnt->linktype != link_type) || | |
| 171 | + (epnt->direction != dir)) | |
| 172 | + return false; | |
| 173 | + | |
| 174 | + /* link of type DMIC bypasses device_type check */ | |
| 175 | + return epnt->linktype == NHLT_LINK_DMIC || | |
| 176 | + epnt->device_type == dev_type; | |
| 177 | +} | |
| 178 | + | |
| 179 | +struct nhlt_specific_cfg * | |
| 180 | +intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, | |
| 181 | + u32 bus_id, u8 link_type, u8 vbps, u8 bps, | |
| 182 | + u8 num_ch, u32 rate, u8 dir, u8 dev_type) | |
| 183 | +{ | |
| 184 | + struct nhlt_specific_cfg *cfg; | |
| 185 | + struct nhlt_endpoint *epnt; | |
| 186 | + struct nhlt_fmt *fmt; | |
| 187 | + int i; | |
| 188 | + | |
| 189 | + if (!nhlt) | |
| 190 | + return NULL; | |
| 191 | + | |
| 192 | + dev_dbg(dev, "Looking for configuration:\n"); | |
| 193 | + dev_dbg(dev, " vbus_id=%d link_type=%d dir=%d, dev_type=%d\n", | |
| 194 | + bus_id, link_type, dir, dev_type); | |
| 195 | + dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate); | |
| 196 | + dev_dbg(dev, "Endpoint count=%d\n", nhlt->endpoint_count); | |
| 197 | + | |
| 198 | + epnt = (struct nhlt_endpoint *)nhlt->desc; | |
| 199 | + | |
| 200 | + for (i = 0; i < nhlt->endpoint_count; i++) { | |
| 201 | + if (nhlt_check_ep_match(dev, epnt, bus_id, link_type, dir, dev_type)) { | |
| 202 | + fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size); | |
| 203 | + | |
| 204 | + cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate, vbps, bps); | |
| 205 | + if (cfg) | |
| 206 | + return cfg; | |
| 207 | + } | |
| 208 | + | |
| 209 | + epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); | |
| 210 | + } | |
| 211 | + | |
| 212 | + return NULL; | |
| 213 | +} | |
| 214 | +EXPORT_SYMBOL(intel_nhlt_get_endpoint_blob); | |
| @@ -24,8 +24,9 @@ void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup) · 23 unmodified lines | ||
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | −static struct snd_gf1_mem_block *snd_gf1_mem_xalloc(struct snd_gf1_mem * alloc, | |
| 28 | − struct snd_gf1_mem_block * block) | |
| 27 | +static struct snd_gf1_mem_block * | |
| 28 | +snd_gf1_mem_xalloc(struct snd_gf1_mem *alloc, struct snd_gf1_mem_block *block, | |
| 29 | + const char *name) | |
| 29 | 30 | { |
| 30 | 31 | struct snd_gf1_mem_block *pblock, *nblock; |
| 31 | 32 | |
| @@ -33,6 +34,12 @@ static struct snd_gf1_mem_block *snd_gf1_mem_xalloc(struct snd_gf1_mem * alloc, · 1 unmodified line | ||
| 33 | 34 | if (nblock == NULL) |
| 34 | 35 | return NULL; |
| 35 | 36 | *nblock = *block; |
| 37 | + nblock->name = kstrdup(name, GFP_KERNEL); | |
| 38 | + if (!nblock->name) { | |
| 39 | + kfree(nblock); | |
| 40 | + return NULL; | |
| 41 | + } | |
| 42 | + | |
| 36 | 43 | pblock = alloc->first; |
| 37 | 44 | while (pblock) { |
| 38 | 45 | if (pblock->ptr > nblock->ptr) { |
| @@ -44,7 +51,7 @@ static struct snd_gf1_mem_block *snd_gf1_mem_xalloc(struct snd_gf1_mem * alloc, · 5 unmodified lines | ||
| 44 | 51 | else |
| 45 | 52 | nblock->prev->next = nblock; |
| 46 | 53 | mutex_unlock(&alloc->memory_mutex); |
| 47 | − return NULL; | |
| 54 | + return nblock; | |
| 48 | 55 | } |
| 49 | 56 | pblock = pblock->next; |
| 50 | 57 | } |
| @@ -198,8 +205,7 @@ struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owne · 147 unmodified lines | ||
| 198 | 205 | if (share_id != NULL) |
| 199 | 206 | memcpy(&block.share_id, share_id, sizeof(block.share_id)); |
| 200 | 207 | block.owner = owner; |
| 201 | − block.name = kstrdup(name, GFP_KERNEL); | |
| 202 | − nblock = snd_gf1_mem_xalloc(alloc, &block); | |
| 208 | + nblock = snd_gf1_mem_xalloc(alloc, &block, name); | |
| 203 | 209 | snd_gf1_mem_lock(alloc, 1); |
| 204 | 210 | return nblock; |
| 205 | 211 | } |
| @@ -236,14 +242,12 @@ int snd_gf1_mem_init(struct snd_gus_card * gus) · 30 unmodified lines | ||
| 236 | 242 | if (gus->gf1.enh_mode) { |
| 237 | 243 | block.ptr = 0; |
| 238 | 244 | block.size = 1024; |
| 239 | − block.name = kstrdup("InterWave LFOs", GFP_KERNEL); | |
| 240 | − if (snd_gf1_mem_xalloc(alloc, &block) == NULL) | |
| 245 | + if (!snd_gf1_mem_xalloc(alloc, &block, "InterWave LFOs")) | |
| 241 | 246 | return -ENOMEM; |
| 242 | 247 | } |
| 243 | 248 | block.ptr = gus->gf1.default_voice_address; |
| 244 | 249 | block.size = 4; |
| 245 | − block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL); | |
| 246 | − if (snd_gf1_mem_xalloc(alloc, &block) == NULL) | |
| 250 | + if (!snd_gf1_mem_xalloc(alloc, &block, "Voice default (NULL's)")) | |
| 247 | 251 | return -ENOMEM; |
| 248 | 252 | #ifdef CONFIG_SND_DEBUG |
| 249 | 253 | snd_card_ro_proc_new(gus->card, "gusmem", gus, snd_gf1_mem_info_read); |
| @@ -231,7 +231,7 @@ static int set_spdif_rate(struct snd_ac97 *ac97, unsigned short rate) · 230 unmodified lines | ||
| 231 | 231 | * If the codec doesn't support VAR, the rate must be 48000 (except |
| 232 | 232 | * for SPDIF). |
| 233 | 233 | * |
| 234 | − * The valid registers are AC97_PMC_MIC_ADC_RATE, | |
| 234 | + * The valid registers are AC97_PCM_MIC_ADC_RATE, | |
| 235 | 235 | * AC97_PCM_FRONT_DAC_RATE, AC97_PCM_LR_ADC_RATE. |
| 236 | 236 | * AC97_PCM_SURR_DAC_RATE and AC97_PCM_LFE_DAC_RATE are accepted |
| 237 | 237 | * if the codec supports them. |
| @@ -91,6 +91,39 @@ config SND_HDA_PATCH_LOADER · 90 unmodified lines | ||
| 91 | 91 | start up. The "patch" file can be specified via patch module |
| 92 | 92 | option, such as patch=hda-init. |
| 93 | 93 | |
| 94 | +config SND_HDA_SCODEC_CS35L41 | |
| 95 | + tristate | |
| 96 | + | |
| 97 | +config SND_HDA_SCODEC_CS35L41_I2C | |
| 98 | + tristate "Build CS35L41 HD-audio side codec support for I2C Bus" | |
| 99 | + depends on I2C | |
| 100 | + depends on ACPI | |
| 101 | + depends on SND_SOC | |
| 102 | + select SND_HDA_GENERIC | |
| 103 | + select SND_SOC_CS35L41_LIB | |
| 104 | + select SND_HDA_SCODEC_CS35L41 | |
| 105 | + help | |
| 106 | + Say Y or M here to include CS35L41 I2C HD-audio side codec support | |
| 107 | + in snd-hda-intel driver, such as ALC287. | |
| 108 | + | |
| 109 | +comment "Set to Y if you want auto-loading the side codec driver" | |
| 110 | + depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_I2C=m | |
| 111 | + | |
| 112 | +config SND_HDA_SCODEC_CS35L41_SPI | |
| 113 | + tristate "Build CS35L41 HD-audio codec support for SPI Bus" | |
| 114 | + depends on SPI_MASTER | |
| 115 | + depends on ACPI | |
| 116 | + depends on SND_SOC | |
| 117 | + select SND_HDA_GENERIC | |
| 118 | + select SND_SOC_CS35L41_LIB | |
| 119 | + select SND_HDA_SCODEC_CS35L41 | |
| 120 | + help | |
| 121 | + Say Y or M here to include CS35L41 SPI HD-audio side codec support | |
| 122 | + in snd-hda-intel driver, such as ALC287. | |
| 123 | + | |
| 124 | +comment "Set to Y if you want auto-loading the side codec driver" | |
| 125 | + depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_SPI=m | |
| 126 | + | |
| 94 | 127 | config SND_HDA_CODEC_REALTEK |
| 95 | 128 | tristate "Build Realtek HD-audio codec support" |
| 96 | 129 | select SND_HDA_GENERIC |
| @@ -27,6 +27,11 @@ snd-hda-codec-conexant-objs := patch_conexant.o · 26 unmodified lines | ||
| 27 | 27 | snd-hda-codec-via-objs := patch_via.o |
| 28 | 28 | snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o |
| 29 | 29 | |
| 30 | +# side codecs | |
| 31 | +snd-hda-scodec-cs35l41-objs := cs35l41_hda.o | |
| 32 | +snd-hda-scodec-cs35l41-i2c-objs := cs35l41_hda_i2c.o | |
| 33 | +snd-hda-scodec-cs35l41-spi-objs := cs35l41_hda_spi.o | |
| 34 | + | |
| 30 | 35 | # common driver |
| 31 | 36 | obj-$(CONFIG_SND_HDA) := snd-hda-codec.o |
| 32 | 37 | |
| @@ -45,6 +50,11 @@ obj-$(CONFIG_SND_HDA_CODEC_CONEXANT) += snd-hda-codec-conexant.o · 12 unmodified lines | ||
| 45 | 50 | obj-$(CONFIG_SND_HDA_CODEC_VIA) += snd-hda-codec-via.o |
| 46 | 51 | obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o |
| 47 | 52 | |
| 53 | +# side codecs | |
| 54 | +obj-$(CONFIG_SND_HDA_SCODEC_CS35L41) += snd-hda-scodec-cs35l41.o | |
| 55 | +obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_I2C) += snd-hda-scodec-cs35l41-i2c.o | |
| 56 | +obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_SPI) += snd-hda-scodec-cs35l41-spi.o | |
| 57 | + | |
| 48 | 58 | # this must be the last entry after codec drivers; |
| 49 | 59 | # otherwise the codec patches won't be hooked before the PCI probe |
| 50 | 60 | # when built in kernel |
| @@ -0,0 +1,528 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// cs35l41.c -- CS35l41 ALSA HDA audio driver | |
| 4 | +// | |
| 5 | +// Copyright 2021 Cirrus Logic, Inc. | |
| 6 | +// | |
| 7 | +// Author: Lucas Tanure <tanureal@opensource.cirrus.com> | |
| 8 | + | |
| 9 | +#include <linux/acpi.h> | |
| 10 | +#include <linux/module.h> | |
| 11 | +#include <sound/hda_codec.h> | |
| 12 | +#include "hda_local.h" | |
| 13 | +#include "hda_auto_parser.h" | |
| 14 | +#include "hda_jack.h" | |
| 15 | +#include "hda_generic.h" | |
| 16 | +#include "hda_component.h" | |
| 17 | +#include "cs35l41_hda.h" | |
| 18 | + | |
| 19 | +static const struct reg_sequence cs35l41_hda_config[] = { | |
| 20 | + { CS35L41_PLL_CLK_CTRL, 0x00000430 }, //3200000Hz, BCLK Input, PLL_REFCLK_EN = 1 | |
| 21 | + { CS35L41_GLOBAL_CLK_CTRL, 0x00000003 }, //GLOBAL_FS = 48 kHz | |
| 22 | + { CS35L41_SP_ENABLES, 0x00010000 }, //ASP_RX1_EN = 1 | |
| 23 | + { CS35L41_SP_RATE_CTRL, 0x00000021 }, //ASP_BCLK_FREQ = 3.072 MHz | |
| 24 | + { CS35L41_SP_FORMAT, 0x20200200 }, //24 bits, I2S, BCLK Slave, FSYNC Slave | |
| 25 | + { CS35L41_DAC_PCM1_SRC, 0x00000008 }, //DACPCM1_SRC = ASPRX1 | |
| 26 | + { CS35L41_AMP_DIG_VOL_CTRL, 0x00000000 }, //AMP_VOL_PCM 0.0 dB | |
| 27 | + { CS35L41_AMP_GAIN_CTRL, 0x00000084 }, //AMP_GAIN_PCM 4.5 dB | |
| 28 | + { CS35L41_PWR_CTRL2, 0x00000001 }, //AMP_EN = 1 | |
| 29 | +}; | |
| 30 | + | |
| 31 | +static const struct reg_sequence cs35l41_hda_start_bst[] = { | |
| 32 | + { CS35L41_PWR_CTRL2, 0x00000021 }, //BST_EN = 10, AMP_EN = 1 | |
| 33 | + { CS35L41_PWR_CTRL1, 0x00000001, 3000}, // set GLOBAL_EN = 1 | |
| 34 | +}; | |
| 35 | + | |
| 36 | +static const struct reg_sequence cs35l41_hda_stop_bst[] = { | |
| 37 | + { CS35L41_PWR_CTRL1, 0x00000000, 3000}, // set GLOBAL_EN = 0 | |
| 38 | +}; | |
| 39 | + | |
| 40 | +// only on amps where GPIO1 is used to control ext. VSPK switch | |
| 41 | +static const struct reg_sequence cs35l41_start_ext_vspk[] = { | |
| 42 | + { 0x00000040, 0x00000055 }, | |
| 43 | + { 0x00000040, 0x000000AA }, | |
| 44 | + { 0x00007438, 0x00585941 }, | |
| 45 | + { 0x00007414, 0x08C82222 }, | |
| 46 | + { 0x0000742C, 0x00000009 }, | |
| 47 | + { 0x00011008, 0x00008001 }, | |
| 48 | + { 0x0000742C, 0x0000000F }, | |
| 49 | + { 0x0000742C, 0x00000079 }, | |
| 50 | + { 0x00007438, 0x00585941 }, | |
| 51 | + { CS35L41_PWR_CTRL1, 0x00000001, 3000}, // set GLOBAL_EN = 1 | |
| 52 | + { 0x0000742C, 0x000000F9 }, | |
| 53 | + { 0x00007438, 0x00580941 }, | |
| 54 | + { 0x00000040, 0x000000CC }, | |
| 55 | + { 0x00000040, 0x00000033 }, | |
| 56 | +}; | |
| 57 | + | |
| 58 | +//only on amps where GPIO1 is used to control ext. VSPK switch | |
| 59 | +static const struct reg_sequence cs35l41_stop_ext_vspk[] = { | |
| 60 | + { 0x00000040, 0x00000055 }, | |
| 61 | + { 0x00000040, 0x000000AA }, | |
| 62 | + { 0x00007438, 0x00585941 }, | |
| 63 | + { 0x00002014, 0x00000000, 3000}, //set GLOBAL_EN = 0 | |
| 64 | + { 0x0000742C, 0x00000009 }, | |
| 65 | + { 0x00007438, 0x00580941 }, | |
| 66 | + { 0x00011008, 0x00000001 }, | |
| 67 | + { 0x0000393C, 0x000000C0, 6000}, | |
| 68 | + { 0x0000393C, 0x00000000 }, | |
| 69 | + { 0x00007414, 0x00C82222 }, | |
| 70 | + { 0x0000742C, 0x00000000 }, | |
| 71 | + { 0x00000040, 0x000000CC }, | |
| 72 | + { 0x00000040, 0x00000033 }, | |
| 73 | +}; | |
| 74 | + | |
| 75 | +static const struct reg_sequence cs35l41_safe_to_active[] = { | |
| 76 | + { 0x00000040, 0x00000055 }, | |
| 77 | + { 0x00000040, 0x000000AA }, | |
| 78 | + { 0x0000742C, 0x0000000F }, | |
| 79 | + { 0x0000742C, 0x00000079 }, | |
| 80 | + { 0x00007438, 0x00585941 }, | |
| 81 | + { CS35L41_PWR_CTRL1, 0x00000001, 2000 }, //GLOBAL_EN = 1 | |
| 82 | + { 0x0000742C, 0x000000F9 }, | |
| 83 | + { 0x00007438, 0x00580941 }, | |
| 84 | + { 0x00000040, 0x000000CC }, | |
| 85 | + { 0x00000040, 0x00000033 }, | |
| 86 | +}; | |
| 87 | + | |
| 88 | +static const struct reg_sequence cs35l41_active_to_safe[] = { | |
| 89 | + { 0x00000040, 0x00000055 }, | |
| 90 | + { 0x00000040, 0x000000AA }, | |
| 91 | + { 0x00007438, 0x00585941 }, | |
| 92 | + { CS35L41_AMP_DIG_VOL_CTRL, 0x0000A678 }, //AMP_VOL_PCM Mute | |
| 93 | + { CS35L41_PWR_CTRL2, 0x00000000 }, //AMP_EN = 0 | |
| 94 | + { CS35L41_PWR_CTRL1, 0x00000000 }, | |
| 95 | + { 0x0000742C, 0x00000009, 2000 }, | |
| 96 | + { 0x00007438, 0x00580941 }, | |
| 97 | + { 0x00000040, 0x000000CC }, | |
| 98 | + { 0x00000040, 0x00000033 }, | |
| 99 | +}; | |
| 100 | + | |
| 101 | +static const struct reg_sequence cs35l41_reset_to_safe[] = { | |
| 102 | + { 0x00000040, 0x00000055 }, | |
| 103 | + { 0x00000040, 0x000000AA }, | |
| 104 | + { 0x00007438, 0x00585941 }, | |
| 105 | + { 0x00007414, 0x08C82222 }, | |
| 106 | + { 0x0000742C, 0x00000009 }, | |
| 107 | + { 0x00000040, 0x000000CC }, | |
| 108 | + { 0x00000040, 0x00000033 }, | |
| 109 | +}; | |
| 110 | + | |
| 111 | +static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_no_bst = { | |
| 112 | + .probe = cs35l41_reset_to_safe, | |
| 113 | + .num_probe = ARRAY_SIZE(cs35l41_reset_to_safe), | |
| 114 | + .open = cs35l41_hda_config, | |
| 115 | + .num_open = ARRAY_SIZE(cs35l41_hda_config), | |
| 116 | + .prepare = cs35l41_safe_to_active, | |
| 117 | + .num_prepare = ARRAY_SIZE(cs35l41_safe_to_active), | |
| 118 | + .cleanup = cs35l41_active_to_safe, | |
| 119 | + .num_cleanup = ARRAY_SIZE(cs35l41_active_to_safe), | |
| 120 | +}; | |
| 121 | + | |
| 122 | +static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_ext_bst = { | |
| 123 | + .open = cs35l41_hda_config, | |
| 124 | + .num_open = ARRAY_SIZE(cs35l41_hda_config), | |
| 125 | + .prepare = cs35l41_start_ext_vspk, | |
| 126 | + .num_prepare = ARRAY_SIZE(cs35l41_start_ext_vspk), | |
| 127 | + .cleanup = cs35l41_stop_ext_vspk, | |
| 128 | + .num_cleanup = ARRAY_SIZE(cs35l41_stop_ext_vspk), | |
| 129 | +}; | |
| 130 | + | |
| 131 | +static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_int_bst = { | |
| 132 | + .open = cs35l41_hda_config, | |
| 133 | + .num_open = ARRAY_SIZE(cs35l41_hda_config), | |
| 134 | + .prepare = cs35l41_hda_start_bst, | |
| 135 | + .num_prepare = ARRAY_SIZE(cs35l41_hda_start_bst), | |
| 136 | + .cleanup = cs35l41_hda_stop_bst, | |
| 137 | + .num_cleanup = ARRAY_SIZE(cs35l41_hda_stop_bst), | |
| 138 | +}; | |
| 139 | + | |
| 140 | +static void cs35l41_hda_playback_hook(struct device *dev, int action) | |
| 141 | +{ | |
| 142 | + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); | |
| 143 | + const struct cs35l41_hda_reg_sequence *reg_seq = cs35l41->reg_seq; | |
| 144 | + struct regmap *reg = cs35l41->regmap; | |
| 145 | + int ret = 0; | |
| 146 | + | |
| 147 | + switch (action) { | |
| 148 | + case HDA_GEN_PCM_ACT_OPEN: | |
| 149 | + if (reg_seq->open) | |
| 150 | + ret = regmap_multi_reg_write(reg, reg_seq->open, reg_seq->num_open); | |
| 151 | + break; | |
| 152 | + case HDA_GEN_PCM_ACT_PREPARE: | |
| 153 | + if (reg_seq->prepare) | |
| 154 | + ret = regmap_multi_reg_write(reg, reg_seq->prepare, reg_seq->num_prepare); | |
| 155 | + break; | |
| 156 | + case HDA_GEN_PCM_ACT_CLEANUP: | |
| 157 | + if (reg_seq->cleanup) | |
| 158 | + ret = regmap_multi_reg_write(reg, reg_seq->cleanup, reg_seq->num_cleanup); | |
| 159 | + break; | |
| 160 | + case HDA_GEN_PCM_ACT_CLOSE: | |
| 161 | + if (reg_seq->close) | |
| 162 | + ret = regmap_multi_reg_write(reg, reg_seq->close, reg_seq->num_close); | |
| 163 | + break; | |
| 164 | + } | |
| 165 | + | |
| 166 | + if (ret) | |
| 167 | + dev_warn(cs35l41->dev, "Failed to apply multi reg write: %d\n", ret); | |
| 168 | + | |
| 169 | +} | |
| 170 | + | |
| 171 | +static int cs35l41_hda_channel_map(struct device *dev, unsigned int tx_num, unsigned int *tx_slot, | |
| 172 | + unsigned int rx_num, unsigned int *rx_slot) | |
| 173 | +{ | |
| 174 | + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); | |
| 175 | + | |
| 176 | + return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_num, tx_slot, rx_num, | |
| 177 | + rx_slot); | |
| 178 | +} | |
| 179 | + | |
| 180 | +static int cs35l41_hda_bind(struct device *dev, struct device *master, void *master_data) | |
| 181 | +{ | |
| 182 | + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); | |
| 183 | + struct hda_component *comps = master_data; | |
| 184 | + | |
| 185 | + if (comps && cs35l41->index >= 0 && cs35l41->index < HDA_MAX_COMPONENTS) | |
| 186 | + comps = &comps[cs35l41->index]; | |
| 187 | + else | |
| 188 | + return -EINVAL; | |
| 189 | + | |
| 190 | + if (!comps->dev) { | |
| 191 | + comps->dev = dev; | |
| 192 | + strscpy(comps->name, dev_name(dev), sizeof(comps->name)); | |
| 193 | + comps->playback_hook = cs35l41_hda_playback_hook; | |
| 194 | + comps->set_channel_map = cs35l41_hda_channel_map; | |
| 195 | + return 0; | |
| 196 | + } | |
| 197 | + | |
| 198 | + return -EBUSY; | |
| 199 | +} | |
| 200 | + | |
| 201 | +static void cs35l41_hda_unbind(struct device *dev, struct device *master, void *master_data) | |
| 202 | +{ | |
| 203 | + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); | |
| 204 | + struct hda_component *comps = master_data; | |
| 205 | + | |
| 206 | + if (comps[cs35l41->index].dev == dev) | |
| 207 | + memset(&comps[cs35l41->index], 0, sizeof(*comps)); | |
| 208 | +} | |
| 209 | + | |
| 210 | +static const struct component_ops cs35l41_hda_comp_ops = { | |
| 211 | + .bind = cs35l41_hda_bind, | |
| 212 | + .unbind = cs35l41_hda_unbind, | |
| 213 | +}; | |
| 214 | + | |
| 215 | +static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41, | |
| 216 | + const struct cs35l41_hda_hw_config *hw_cfg) | |
| 217 | +{ | |
| 218 | + bool internal_boost = false; | |
| 219 | + int ret; | |
| 220 | + | |
| 221 | + if (!hw_cfg) { | |
| 222 | + cs35l41->reg_seq = &cs35l41_hda_reg_seq_no_bst; | |
| 223 | + return 0; | |
| 224 | + } | |
| 225 | + | |
| 226 | + if (hw_cfg->bst_ind || hw_cfg->bst_cap || hw_cfg->bst_ipk) | |
| 227 | + internal_boost = true; | |
| 228 | + | |
| 229 | + switch (hw_cfg->gpio1_func) { | |
| 230 | + case CS35l41_VSPK_SWITCH: | |
| 231 | + regmap_update_bits(cs35l41->regmap, CS35L41_GPIO_PAD_CONTROL, | |
| 232 | + CS35L41_GPIO1_CTRL_MASK, 1 << CS35L41_GPIO1_CTRL_SHIFT); | |
| 233 | + break; | |
| 234 | + case CS35l41_SYNC: | |
| 235 | + regmap_update_bits(cs35l41->regmap, CS35L41_GPIO_PAD_CONTROL, | |
| 236 | + CS35L41_GPIO1_CTRL_MASK, 2 << CS35L41_GPIO1_CTRL_SHIFT); | |
| 237 | + break; | |
| 238 | + } | |
| 239 | + | |
| 240 | + switch (hw_cfg->gpio2_func) { | |
| 241 | + case CS35L41_INTERRUPT: | |
| 242 | + regmap_update_bits(cs35l41->regmap, CS35L41_GPIO_PAD_CONTROL, | |
| 243 | + CS35L41_GPIO2_CTRL_MASK, 2 << CS35L41_GPIO2_CTRL_SHIFT); | |
| 244 | + break; | |
| 245 | + } | |
| 246 | + | |
| 247 | + if (internal_boost) { | |
| 248 | + cs35l41->reg_seq = &cs35l41_hda_reg_seq_int_bst; | |
| 249 | + if (!(hw_cfg->bst_ind && hw_cfg->bst_cap && hw_cfg->bst_ipk)) | |
| 250 | + return -EINVAL; | |
| 251 | + ret = cs35l41_boost_config(cs35l41->dev, cs35l41->regmap, | |
| 252 | + hw_cfg->bst_ind, hw_cfg->bst_cap, hw_cfg->bst_ipk); | |
| 253 | + if (ret) | |
| 254 | + return ret; | |
| 255 | + } else { | |
| 256 | + cs35l41->reg_seq = &cs35l41_hda_reg_seq_ext_bst; | |
| 257 | + } | |
| 258 | + | |
| 259 | + ret = cs35l41_hda_channel_map(cs35l41->dev, 0, NULL, 1, (unsigned int *)&hw_cfg->spk_pos); | |
| 260 | + if (ret) | |
| 261 | + return ret; | |
| 262 | + | |
| 263 | + return 0; | |
| 264 | +} | |
| 265 | + | |
| 266 | +static struct cs35l41_hda_hw_config *cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, | |
| 267 | + const char *hid, int id) | |
| 268 | +{ | |
| 269 | + struct cs35l41_hda_hw_config *hw_cfg; | |
| 270 | + u32 values[HDA_MAX_COMPONENTS]; | |
| 271 | + struct acpi_device *adev; | |
| 272 | + struct device *acpi_dev; | |
| 273 | + char *property; | |
| 274 | + size_t nval; | |
| 275 | + int i, ret; | |
| 276 | + | |
| 277 | + adev = acpi_dev_get_first_match_dev(hid, NULL, -1); | |
| 278 | + if (!adev) { | |
| 279 | + dev_err(cs35l41->dev, "Failed to find an ACPI device for %s\n", hid); | |
| 280 | + return ERR_PTR(-ENODEV); | |
| 281 | + } | |
| 282 | + | |
| 283 | + acpi_dev = get_device(acpi_get_first_physical_node(adev)); | |
| 284 | + acpi_dev_put(adev); | |
| 285 | + | |
| 286 | + property = "cirrus,dev-index"; | |
| 287 | + ret = device_property_count_u32(acpi_dev, property); | |
| 288 | + if (ret <= 0) | |
| 289 | + goto no_acpi_dsd; | |
| 290 | + | |
| 291 | + if (ret > ARRAY_SIZE(values)) { | |
| 292 | + ret = -EINVAL; | |
| 293 | + goto err; | |
| 294 | + } | |
| 295 | + nval = ret; | |
| 296 | + | |
| 297 | + ret = device_property_read_u32_array(acpi_dev, property, values, nval); | |
| 298 | + if (ret) | |
| 299 | + goto err; | |
| 300 | + | |
| 301 | + cs35l41->index = -1; | |
| 302 | + for (i = 0; i < nval; i++) { | |
| 303 | + if (values[i] == id) { | |
| 304 | + cs35l41->index = i; | |
| 305 | + break; | |
| 306 | + } | |
| 307 | + } | |
| 308 | + if (cs35l41->index == -1) { | |
| 309 | + dev_err(cs35l41->dev, "No index found in %s\n", property); | |
| 310 | + ret = -ENODEV; | |
| 311 | + goto err; | |
| 312 | + } | |
| 313 | + | |
| 314 | + /* No devm_ version as CLSA0100, in no_acpi_dsd case, can't use devm version */ | |
| 315 | + cs35l41->reset_gpio = fwnode_gpiod_get_index(&adev->fwnode, "reset", cs35l41->index, | |
| 316 | + GPIOD_OUT_LOW, "cs35l41-reset"); | |
| 317 | + | |
| 318 | + hw_cfg = kzalloc(sizeof(*hw_cfg), GFP_KERNEL); | |
| 319 | + if (!hw_cfg) { | |
| 320 | + ret = -ENOMEM; | |
| 321 | + goto err; | |
| 322 | + } | |
| 323 | + | |
| 324 | + property = "cirrus,speaker-position"; | |
| 325 | + ret = device_property_read_u32_array(acpi_dev, property, values, nval); | |
| 326 | + if (ret) | |
| 327 | + goto err_free; | |
| 328 | + hw_cfg->spk_pos = values[cs35l41->index]; | |
| 329 | + | |
| 330 | + property = "cirrus,gpio1-func"; | |
| 331 | + ret = device_property_read_u32_array(acpi_dev, property, values, nval); | |
| 332 | + if (ret) | |
| 333 | + goto err_free; | |
| 334 | + hw_cfg->gpio1_func = values[cs35l41->index]; | |
| 335 | + | |
| 336 | + property = "cirrus,gpio2-func"; | |
| 337 | + ret = device_property_read_u32_array(acpi_dev, property, values, nval); | |
| 338 | + if (ret) | |
| 339 | + goto err_free; | |
| 340 | + hw_cfg->gpio2_func = values[cs35l41->index]; | |
| 341 | + | |
| 342 | + property = "cirrus,boost-peak-milliamp"; | |
| 343 | + ret = device_property_read_u32_array(acpi_dev, property, values, nval); | |
| 344 | + if (ret == 0) | |
| 345 | + hw_cfg->bst_ipk = values[cs35l41->index]; | |
| 346 | + | |
| 347 | + property = "cirrus,boost-ind-nanohenry"; | |
| 348 | + ret = device_property_read_u32_array(acpi_dev, property, values, nval); | |
| 349 | + if (ret == 0) | |
| 350 | + hw_cfg->bst_ind = values[cs35l41->index]; | |
| 351 | + | |
| 352 | + property = "cirrus,boost-cap-microfarad"; | |
| 353 | + ret = device_property_read_u32_array(acpi_dev, property, values, nval); | |
| 354 | + if (ret == 0) | |
| 355 | + hw_cfg->bst_cap = values[cs35l41->index]; | |
| 356 | + | |
| 357 | + put_device(acpi_dev); | |
| 358 | + | |
| 359 | + return hw_cfg; | |
| 360 | + | |
| 361 | +err_free: | |
| 362 | + kfree(hw_cfg); | |
| 363 | +err: | |
| 364 | + put_device(acpi_dev); | |
| 365 | + dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret); | |
| 366 | + | |
| 367 | + return ERR_PTR(ret); | |
| 368 | + | |
| 369 | +no_acpi_dsd: | |
| 370 | + /* | |
| 371 | + * Device CLSA0100 doesn't have _DSD so a gpiod_get by the label reset won't work. | |
| 372 | + * And devices created by i2c-multi-instantiate don't have their device struct pointing to | |
| 373 | + * the correct fwnode, so acpi_dev must be used here | |
| 374 | + * And devm functions expect that the device requesting the resource has the correct | |
| 375 | + * fwnode | |
| 376 | + */ | |
| 377 | + if (strncmp(hid, "CLSA0100", 8) != 0) | |
| 378 | + return ERR_PTR(-EINVAL); | |
| 379 | + | |
| 380 | + /* check I2C address to assign the index */ | |
| 381 | + cs35l41->index = id == 0x40 ? 0 : 1; | |
| 382 | + cs35l41->reset_gpio = gpiod_get_index(acpi_dev, NULL, 0, GPIOD_OUT_HIGH); | |
| 383 | + cs35l41->vspk_always_on = true; | |
| 384 | + put_device(acpi_dev); | |
| 385 | + | |
| 386 | + return NULL; | |
| 387 | +} | |
| 388 | + | |
| 389 | +int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, | |
| 390 | + struct regmap *regmap) | |
| 391 | +{ | |
| 392 | + unsigned int int_sts, regid, reg_revid, mtl_revid, chipid, int_status; | |
| 393 | + struct cs35l41_hda_hw_config *acpi_hw_cfg; | |
| 394 | + struct cs35l41_hda *cs35l41; | |
| 395 | + int ret; | |
| 396 | + | |
| 397 | + if (IS_ERR(regmap)) | |
| 398 | + return PTR_ERR(regmap); | |
| 399 | + | |
| 400 | + cs35l41 = devm_kzalloc(dev, sizeof(*cs35l41), GFP_KERNEL); | |
| 401 | + if (!cs35l41) | |
| 402 | + return -ENOMEM; | |
| 403 | + | |
| 404 | + cs35l41->dev = dev; | |
| 405 | + cs35l41->irq = irq; | |
| 406 | + cs35l41->regmap = regmap; | |
| 407 | + dev_set_drvdata(dev, cs35l41); | |
| 408 | + | |
| 409 | + acpi_hw_cfg = cs35l41_hda_read_acpi(cs35l41, device_name, id); | |
| 410 | + if (IS_ERR(acpi_hw_cfg)) | |
| 411 | + return PTR_ERR(acpi_hw_cfg); | |
| 412 | + | |
| 413 | + if (IS_ERR(cs35l41->reset_gpio)) { | |
| 414 | + ret = PTR_ERR(cs35l41->reset_gpio); | |
| 415 | + cs35l41->reset_gpio = NULL; | |
| 416 | + if (ret == -EBUSY) { | |
| 417 | + dev_info(cs35l41->dev, "Reset line busy, assuming shared reset\n"); | |
| 418 | + } else { | |
| 419 | + if (ret != -EPROBE_DEFER) | |
| 420 | + dev_err(cs35l41->dev, "Failed to get reset GPIO: %d\n", ret); | |
| 421 | + goto err; | |
| 422 | + } | |
| 423 | + } | |
| 424 | + if (cs35l41->reset_gpio) { | |
| 425 | + usleep_range(2000, 2100); | |
| 426 | + gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); | |
| 427 | + } | |
| 428 | + | |
| 429 | + usleep_range(2000, 2100); | |
| 430 | + | |
| 431 | + ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, int_status, | |
| 432 | + int_status & CS35L41_OTP_BOOT_DONE, 1000, 100000); | |
| 433 | + if (ret) { | |
| 434 | + dev_err(cs35l41->dev, "Failed waiting for OTP_BOOT_DONE: %d\n", ret); | |
| 435 | + goto err; | |
| 436 | + } | |
| 437 | + | |
| 438 | + ret = regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_sts); | |
| 439 | + if (ret || (int_sts & CS35L41_OTP_BOOT_ERR)) { | |
| 440 | + dev_err(cs35l41->dev, "OTP Boot error\n"); | |
| 441 | + ret = -EIO; | |
| 442 | + goto err; | |
| 443 | + } | |
| 444 | + | |
| 445 | + ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, ®id); | |
| 446 | + if (ret) { | |
| 447 | + dev_err(cs35l41->dev, "Get Device ID failed: %d\n", ret); | |
| 448 | + goto err; | |
| 449 | + } | |
| 450 | + | |
| 451 | + ret = regmap_read(cs35l41->regmap, CS35L41_REVID, ®_revid); | |
| 452 | + if (ret) { | |
| 453 | + dev_err(cs35l41->dev, "Get Revision ID failed: %d\n", ret); | |
| 454 | + goto err; | |
| 455 | + } | |
| 456 | + | |
| 457 | + mtl_revid = reg_revid & CS35L41_MTLREVID_MASK; | |
| 458 | + | |
| 459 | + chipid = (mtl_revid % 2) ? CS35L41R_CHIP_ID : CS35L41_CHIP_ID; | |
| 460 | + if (regid != chipid) { | |
| 461 | + dev_err(cs35l41->dev, "CS35L41 Device ID (%X). Expected ID %X\n", regid, chipid); | |
| 462 | + ret = -ENODEV; | |
| 463 | + goto err; | |
| 464 | + } | |
| 465 | + | |
| 466 | + ret = cs35l41_register_errata_patch(cs35l41->dev, cs35l41->regmap, reg_revid); | |
| 467 | + if (ret) | |
| 468 | + goto err; | |
| 469 | + | |
| 470 | + ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); | |
| 471 | + if (ret) { | |
| 472 | + dev_err(cs35l41->dev, "OTP Unpack failed: %d\n", ret); | |
| 473 | + goto err; | |
| 474 | + } | |
| 475 | + | |
| 476 | + ret = cs35l41_hda_apply_properties(cs35l41, acpi_hw_cfg); | |
| 477 | + if (ret) | |
| 478 | + goto err; | |
| 479 | + kfree(acpi_hw_cfg); | |
| 480 | + acpi_hw_cfg = NULL; | |
| 481 | + | |
| 482 | + if (cs35l41->reg_seq->probe) { | |
| 483 | + ret = regmap_register_patch(cs35l41->regmap, cs35l41->reg_seq->probe, | |
| 484 | + cs35l41->reg_seq->num_probe); | |
| 485 | + if (ret) { | |
| 486 | + dev_err(cs35l41->dev, "Fail to apply probe reg patch: %d\n", ret); | |
| 487 | + goto err; | |
| 488 | + } | |
| 489 | + } | |
| 490 | + | |
| 491 | + ret = component_add(cs35l41->dev, &cs35l41_hda_comp_ops); | |
| 492 | + if (ret) { | |
| 493 | + dev_err(cs35l41->dev, "Register component failed: %d\n", ret); | |
| 494 | + goto err; | |
| 495 | + } | |
| 496 | + | |
| 497 | + dev_info(cs35l41->dev, "Cirrus Logic CS35L41 (%x), Revision: %02X\n", regid, reg_revid); | |
| 498 | + | |
| 499 | + return 0; | |
| 500 | + | |
| 501 | +err: | |
| 502 | + kfree(acpi_hw_cfg); | |
| 503 | + if (!cs35l41->vspk_always_on) | |
| 504 | + gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); | |
| 505 | + gpiod_put(cs35l41->reset_gpio); | |
| 506 | + | |
| 507 | + return ret; | |
| 508 | +} | |
| 509 | +EXPORT_SYMBOL_GPL(cs35l41_hda_probe); | |
| 510 | + | |
| 511 | +int cs35l41_hda_remove(struct device *dev) | |
| 512 | +{ | |
| 513 | + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); | |
| 514 | + | |
| 515 | + component_del(cs35l41->dev, &cs35l41_hda_comp_ops); | |
| 516 | + | |
| 517 | + if (!cs35l41->vspk_always_on) | |
| 518 | + gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); | |
| 519 | + gpiod_put(cs35l41->reset_gpio); | |
| 520 | + | |
| 521 | + return 0; | |
| 522 | +} | |
| 523 | +EXPORT_SYMBOL_GPL(cs35l41_hda_remove); | |
| 524 | + | |
| 525 | + | |
| 526 | +MODULE_DESCRIPTION("CS35L41 HDA Driver"); | |
| 527 | +MODULE_AUTHOR("Lucas Tanure, Cirrus Logic Inc, <tanureal@opensource.cirrus.com>"); | |
| 528 | +MODULE_LICENSE("GPL"); | |
| @@ -0,0 +1,69 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 | |
| 2 | + * | |
| 3 | + * cs35l41_hda.h -- CS35L41 ALSA HDA audio driver | |
| 4 | + * | |
| 5 | + * Copyright 2021 Cirrus Logic, Inc. | |
| 6 | + * | |
| 7 | + * Author: Lucas Tanure <tanureal@opensource.cirrus.com> | |
| 8 | + */ | |
| 9 | + | |
| 10 | +#ifndef __CS35L41_HDA_H__ | |
| 11 | +#define __CS35L41_HDA_H__ | |
| 12 | + | |
| 13 | +#include <linux/regulator/consumer.h> | |
| 14 | +#include <linux/gpio/consumer.h> | |
| 15 | +#include <linux/device.h> | |
| 16 | +#include <sound/cs35l41.h> | |
| 17 | + | |
| 18 | +enum cs35l41_hda_spk_pos { | |
| 19 | + CS35l41_LEFT, | |
| 20 | + CS35l41_RIGHT, | |
| 21 | +}; | |
| 22 | + | |
| 23 | +enum cs35l41_hda_gpio_function { | |
| 24 | + CS35L41_NOT_USED, | |
| 25 | + CS35l41_VSPK_SWITCH, | |
| 26 | + CS35L41_INTERRUPT, | |
| 27 | + CS35l41_SYNC, | |
| 28 | +}; | |
| 29 | + | |
| 30 | +struct cs35l41_hda_reg_sequence { | |
| 31 | + const struct reg_sequence *probe; | |
| 32 | + unsigned int num_probe; | |
| 33 | + const struct reg_sequence *open; | |
| 34 | + unsigned int num_open; | |
| 35 | + const struct reg_sequence *prepare; | |
| 36 | + unsigned int num_prepare; | |
| 37 | + const struct reg_sequence *cleanup; | |
| 38 | + unsigned int num_cleanup; | |
| 39 | + const struct reg_sequence *close; | |
| 40 | + unsigned int num_close; | |
| 41 | +}; | |
| 42 | + | |
| 43 | +struct cs35l41_hda_hw_config { | |
| 44 | + unsigned int spk_pos; | |
| 45 | + unsigned int gpio1_func; | |
| 46 | + unsigned int gpio2_func; | |
| 47 | + int bst_ind; | |
| 48 | + int bst_ipk; | |
| 49 | + int bst_cap; | |
| 50 | +}; | |
| 51 | + | |
| 52 | +struct cs35l41_hda { | |
| 53 | + struct device *dev; | |
| 54 | + struct regmap *regmap; | |
| 55 | + struct gpio_desc *reset_gpio; | |
| 56 | + const struct cs35l41_hda_reg_sequence *reg_seq; | |
| 57 | + | |
| 58 | + int irq; | |
| 59 | + int index; | |
| 60 | + | |
| 61 | + /* Don't put the AMP in reset of VSPK can not be turned off */ | |
| 62 | + bool vspk_always_on; | |
| 63 | +}; | |
| 64 | + | |
| 65 | +int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, | |
| 66 | + struct regmap *regmap); | |
| 67 | +int cs35l41_hda_remove(struct device *dev); | |
| 68 | + | |
| 69 | +#endif /*__CS35L41_HDA_H__*/ | |
| @@ -0,0 +1,66 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// cs35l41.c -- CS35l41 HDA I2C driver | |
| 4 | +// | |
| 5 | +// Copyright 2021 Cirrus Logic, Inc. | |
| 6 | +// | |
| 7 | +// Author: Lucas Tanure <tanureal@opensource.cirrus.com> | |
| 8 | + | |
| 9 | +#include <linux/module.h> | |
| 10 | +#include <linux/i2c.h> | |
| 11 | +#include <linux/acpi.h> | |
| 12 | + | |
| 13 | +#include "cs35l41_hda.h" | |
| 14 | + | |
| 15 | +static int cs35l41_hda_i2c_probe(struct i2c_client *clt, const struct i2c_device_id *id) | |
| 16 | +{ | |
| 17 | + const char *device_name; | |
| 18 | + | |
| 19 | + /* Compare against the device name so it works for I2C, normal ACPI | |
| 20 | + * and for ACPI by i2c-multi-instantiate matching cases | |
| 21 | + */ | |
| 22 | + if (strstr(dev_name(&clt->dev), "CLSA0100")) | |
| 23 | + device_name = "CLSA0100"; | |
| 24 | + else if (strstr(dev_name(&clt->dev), "CSC3551")) | |
| 25 | + device_name = "CSC3551"; | |
| 26 | + else | |
| 27 | + return -ENODEV; | |
| 28 | + | |
| 29 | + return cs35l41_hda_probe(&clt->dev, device_name, clt->addr, clt->irq, | |
| 30 | + devm_regmap_init_i2c(clt, &cs35l41_regmap_i2c)); | |
| 31 | +} | |
| 32 | + | |
| 33 | +static int cs35l41_hda_i2c_remove(struct i2c_client *clt) | |
| 34 | +{ | |
| 35 | + return cs35l41_hda_remove(&clt->dev); | |
| 36 | +} | |
| 37 | + | |
| 38 | +static const struct i2c_device_id cs35l41_hda_i2c_id[] = { | |
| 39 | + { "cs35l41-hda", 0 }, | |
| 40 | + {} | |
| 41 | +}; | |
| 42 | + | |
| 43 | +#ifdef CONFIG_ACPI | |
| 44 | +static const struct acpi_device_id cs35l41_acpi_hda_match[] = { | |
| 45 | + {"CLSA0100", 0 }, | |
| 46 | + {"CSC3551", 0 }, | |
| 47 | + { }, | |
| 48 | +}; | |
| 49 | +MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match); | |
| 50 | +#endif | |
| 51 | + | |
| 52 | +static struct i2c_driver cs35l41_i2c_driver = { | |
| 53 | + .driver = { | |
| 54 | + .name = "cs35l41-hda", | |
| 55 | + .acpi_match_table = ACPI_PTR(cs35l41_acpi_hda_match), | |
| 56 | + }, | |
| 57 | + .id_table = cs35l41_hda_i2c_id, | |
| 58 | + .probe = cs35l41_hda_i2c_probe, | |
| 59 | + .remove = cs35l41_hda_i2c_remove, | |
| 60 | +}; | |
| 61 | + | |
| 62 | +module_i2c_driver(cs35l41_i2c_driver); | |
| 63 | + | |
| 64 | +MODULE_DESCRIPTION("HDA CS35L41 driver"); | |
| 65 | +MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>"); | |
| 66 | +MODULE_LICENSE("GPL"); | |
| @@ -0,0 +1,63 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// cs35l41.c -- CS35l41 HDA SPI driver | |
| 4 | +// | |
| 5 | +// Copyright 2021 Cirrus Logic, Inc. | |
| 6 | +// | |
| 7 | +// Author: Lucas Tanure <tanureal@opensource.cirrus.com> | |
| 8 | + | |
| 9 | +#include <linux/acpi.h> | |
| 10 | +#include <linux/module.h> | |
| 11 | +#include <linux/spi/spi.h> | |
| 12 | + | |
| 13 | +#include "cs35l41_hda.h" | |
| 14 | + | |
| 15 | +static int cs35l41_hda_spi_probe(struct spi_device *spi) | |
| 16 | +{ | |
| 17 | + const char *device_name; | |
| 18 | + | |
| 19 | + /* Compare against the device name so it works for SPI, normal ACPI | |
| 20 | + * and for ACPI by spi-multi-instantiate matching cases | |
| 21 | + */ | |
| 22 | + if (strstr(dev_name(&spi->dev), "CSC3551")) | |
| 23 | + device_name = "CSC3551"; | |
| 24 | + else | |
| 25 | + return -ENODEV; | |
| 26 | + | |
| 27 | + return cs35l41_hda_probe(&spi->dev, device_name, spi->chip_select, spi->irq, | |
| 28 | + devm_regmap_init_spi(spi, &cs35l41_regmap_spi)); | |
| 29 | +} | |
| 30 | + | |
| 31 | +static int cs35l41_hda_spi_remove(struct spi_device *spi) | |
| 32 | +{ | |
| 33 | + return cs35l41_hda_remove(&spi->dev); | |
| 34 | +} | |
| 35 | + | |
| 36 | +static const struct spi_device_id cs35l41_hda_spi_id[] = { | |
| 37 | + { "cs35l41-hda", 0 }, | |
| 38 | + {} | |
| 39 | +}; | |
| 40 | + | |
| 41 | +#ifdef CONFIG_ACPI | |
| 42 | +static const struct acpi_device_id cs35l41_acpi_hda_match[] = { | |
| 43 | + { "CSC3551", 0 }, | |
| 44 | + {}, | |
| 45 | +}; | |
| 46 | +MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match); | |
| 47 | +#endif | |
| 48 | + | |
| 49 | +static struct spi_driver cs35l41_spi_driver = { | |
| 50 | + .driver = { | |
| 51 | + .name = "cs35l41_hda", | |
| 52 | + .acpi_match_table = ACPI_PTR(cs35l41_acpi_hda_match), | |
| 53 | + }, | |
| 54 | + .id_table = cs35l41_hda_spi_id, | |
| 55 | + .probe = cs35l41_hda_spi_probe, | |
| 56 | + .remove = cs35l41_hda_spi_remove, | |
| 57 | +}; | |
| 58 | + | |
| 59 | +module_spi_driver(cs35l41_spi_driver); | |
| 60 | + | |
| 61 | +MODULE_DESCRIPTION("HDA CS35L41 driver"); | |
| 62 | +MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>"); | |
| 63 | +MODULE_LICENSE("GPL"); | |
| @@ -92,14 +92,10 @@ static int compare_input_type(const void *ap, const void *bp) · 91 unmodified lines | ||
| 92 | 92 | */ |
| 93 | 93 | static void reorder_outputs(unsigned int nums, hda_nid_t *pins) |
| 94 | 94 | { |
| 95 | − hda_nid_t nid; | |
| 96 | − | |
| 97 | 95 | switch (nums) { |
| 98 | 96 | case 3: |
| 99 | 97 | case 4: |
| 100 | − nid = pins[1]; | |
| 101 | − pins[1] = pins[2]; | |
| 102 | − pins[2] = nid; | |
| 98 | + swap(pins[1], pins[2]); | |
| 103 | 99 | break; |
| 104 | 100 | } |
| 105 | 101 | } |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <sound/core.h> |
| 15 | 15 | #include <sound/hda_codec.h> |
| 16 | 16 | #include "hda_local.h" |
| 17 | +#include "hda_jack.h" | |
| 17 | 18 | |
| 18 | 19 | /* |
| 19 | 20 | * find a matching codec id |
| @@ -156,6 +157,12 @@ static int hda_codec_driver_remove(struct device *dev) · 136 unmodified lines | ||
| 156 | 157 | return codec->bus->core.ext_ops->hdev_detach(&codec->core); |
| 157 | 158 | } |
| 158 | 159 | |
| 160 | + refcount_dec(&codec->pcm_ref); | |
| 161 | + snd_hda_codec_disconnect_pcms(codec); | |
| 162 | + snd_hda_jack_tbl_disconnect(codec); | |
| 163 | + wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref)); | |
| 164 | + snd_power_sync_ref(codec->bus->card); | |
| 165 | + | |
| 159 | 166 | if (codec->patch_ops.free) |
| 160 | 167 | codec->patch_ops.free(codec); |
| 161 | 168 | snd_hda_codec_cleanup_for_unbind(codec); |
| @@ -703,20 +703,10 @@ get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid) · 702 unmodified lines | ||
| 703 | 703 | /* |
| 704 | 704 | * PCM device |
| 705 | 705 | */ |
| 706 | −static void release_pcm(struct kref *kref) | |
| 707 | −{ | |
| 708 | − struct hda_pcm *pcm = container_of(kref, struct hda_pcm, kref); | |
| 709 | − | |
| 710 | − if (pcm->pcm) | |
| 711 | − snd_device_free(pcm->codec->card, pcm->pcm); | |
| 712 | − clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits); | |
| 713 | − kfree(pcm->name); | |
| 714 | − kfree(pcm); | |
| 715 | −} | |
| 716 | − | |
| 717 | 706 | void snd_hda_codec_pcm_put(struct hda_pcm *pcm) |
| 718 | 707 | { |
| 719 | − kref_put(&pcm->kref, release_pcm); | |
| 708 | + if (refcount_dec_and_test(&pcm->codec->pcm_ref)) | |
| 709 | + wake_up(&pcm->codec->remove_sleep); | |
| 720 | 710 | } |
| 721 | 711 | EXPORT_SYMBOL_GPL(snd_hda_codec_pcm_put); |
| 722 | 712 | |
| @@ -731,7 +721,6 @@ struct hda_pcm *snd_hda_codec_pcm_new(struct hda_codec *codec, · 8 unmodified lines | ||
| 731 | 721 | return NULL; |
| 732 | 722 | |
| 733 | 723 | pcm->codec = codec; |
| 734 | − kref_init(&pcm->kref); | |
| 735 | 724 | va_start(args, fmt); |
| 736 | 725 | pcm->name = kvasprintf(GFP_KERNEL, fmt, args); |
| 737 | 726 | va_end(args); |
| @@ -741,6 +730,7 @@ struct hda_pcm *snd_hda_codec_pcm_new(struct hda_codec *codec, · 3 unmodified lines | ||
| 741 | 730 | } |
| 742 | 731 | |
| 743 | 732 | list_add_tail(&pcm->list, &codec->pcm_list_head); |
| 733 | + refcount_inc(&codec->pcm_ref); | |
| 744 | 734 | return pcm; |
| 745 | 735 | } |
| 746 | 736 | EXPORT_SYMBOL_GPL(snd_hda_codec_pcm_new); |
| @@ -748,15 +738,31 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_pcm_new); · 1 unmodified line | ||
| 748 | 738 | /* |
| 749 | 739 | * codec destructor |
| 750 | 740 | */ |
| 741 | +void snd_hda_codec_disconnect_pcms(struct hda_codec *codec) | |
| 742 | +{ | |
| 743 | + struct hda_pcm *pcm; | |
| 744 | + | |
| 745 | + list_for_each_entry(pcm, &codec->pcm_list_head, list) { | |
| 746 | + if (pcm->disconnected) | |
| 747 | + continue; | |
| 748 | + if (pcm->pcm) | |
| 749 | + snd_device_disconnect(codec->card, pcm->pcm); | |
| 750 | + snd_hda_codec_pcm_put(pcm); | |
| 751 | + pcm->disconnected = 1; | |
| 752 | + } | |
| 753 | +} | |
| 754 | + | |
| 751 | 755 | static void codec_release_pcms(struct hda_codec *codec) |
| 752 | 756 | { |
| 753 | 757 | struct hda_pcm *pcm, *n; |
| 754 | 758 | |
| 755 | 759 | list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list) { |
| 756 | − list_del_init(&pcm->list); | |
| 760 | + list_del(&pcm->list); | |
| 757 | 761 | if (pcm->pcm) |
| 758 | − snd_device_disconnect(codec->card, pcm->pcm); | |
| 759 | − snd_hda_codec_pcm_put(pcm); | |
| 762 | + snd_device_free(pcm->codec->card, pcm->pcm); | |
| 763 | + clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits); | |
| 764 | + kfree(pcm->name); | |
| 765 | + kfree(pcm); | |
| 760 | 766 | } |
| 761 | 767 | } |
| 762 | 768 | |
| @@ -769,6 +775,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec) · 6 unmodified lines | ||
| 769 | 775 | codec->registered = 0; |
| 770 | 776 | } |
| 771 | 777 | |
| 778 | + snd_hda_codec_disconnect_pcms(codec); | |
| 772 | 779 | cancel_delayed_work_sync(&codec->jackpoll_work); |
| 773 | 780 | if (!codec->in_freeing) |
| 774 | 781 | snd_hda_ctls_clear(codec); |
| @@ -792,6 +799,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec) · 17 unmodified lines | ||
| 792 | 799 | remove_conn_list(codec); |
| 793 | 800 | snd_hdac_regmap_exit(&codec->core); |
| 794 | 801 | codec->configured = 0; |
| 802 | + refcount_set(&codec->pcm_ref, 1); /* reset refcount */ | |
| 795 | 803 | } |
| 796 | 804 | EXPORT_SYMBOL_GPL(snd_hda_codec_cleanup_for_unbind); |
| 797 | 805 | |
| @@ -958,6 +966,8 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card, · 160 unmodified lines | ||
| 958 | 966 | snd_array_init(&codec->verbs, sizeof(struct hda_verb *), 8); |
| 959 | 967 | INIT_LIST_HEAD(&codec->conn_list); |
| 960 | 968 | INIT_LIST_HEAD(&codec->pcm_list_head); |
| 969 | + refcount_set(&codec->pcm_ref, 1); | |
| 970 | + init_waitqueue_head(&codec->remove_sleep); | |
| 961 | 971 | |
| 962 | 972 | INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); |
| 963 | 973 | codec->depop_delay = -1; |
| @@ -1727,8 +1737,11 @@ void snd_hda_ctls_clear(struct hda_codec *codec) · 763 unmodified lines | ||
| 1727 | 1737 | { |
| 1728 | 1738 | int i; |
| 1729 | 1739 | struct hda_nid_item *items = codec->mixers.list; |
| 1740 | + | |
| 1741 | + down_write(&codec->card->controls_rwsem); | |
| 1730 | 1742 | for (i = 0; i < codec->mixers.used; i++) |
| 1731 | 1743 | snd_ctl_remove(codec->card, items[i].kctl); |
| 1744 | + up_write(&codec->card->controls_rwsem); | |
| 1732 | 1745 | snd_array_free(&codec->mixers); |
| 1733 | 1746 | snd_array_free(&codec->nids); |
| 1734 | 1747 | } |
| @@ -0,0 +1,20 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | |
| 2 | +/* | |
| 3 | + * HD audio Component Binding Interface | |
| 4 | + * | |
| 5 | + * Copyright (C) 2021 Cirrus Logic, Inc. and | |
| 6 | + * Cirrus Logic International Semiconductor Ltd. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +#include <linux/component.h> | |
| 10 | + | |
| 11 | +#define HDA_MAX_COMPONENTS 4 | |
| 12 | +#define HDA_MAX_NAME_SIZE 50 | |
| 13 | + | |
| 14 | +struct hda_component { | |
| 15 | + struct device *dev; | |
| 16 | + char name[HDA_MAX_NAME_SIZE]; | |
| 17 | + void (*playback_hook)(struct device *dev, int action); | |
| 18 | + int (*set_channel_map)(struct device *dev, unsigned int rx_num, unsigned int *rx_slot, | |
| 19 | + unsigned int tx_num, unsigned int *tx_slot); | |
| 20 | +}; | |
| @@ -504,7 +504,6 @@ static int azx_get_time_info(struct snd_pcm_substream *substream, · 503 unmodified lines | ||
| 504 | 504 | snd_pcm_gettime(substream->runtime, system_ts); |
| 505 | 505 | |
| 506 | 506 | nsec = timecounter_read(&azx_dev->core.tc); |
| 507 | − nsec = div_u64(nsec, 3); /* can be optimized */ | |
| 508 | 507 | if (audio_tstamp_config->report_delay) |
| 509 | 508 | nsec = azx_adjust_codec_delay(substream, nsec); |
| 510 | 509 | |
| @@ -183,7 +183,7 @@ struct hda_gen_spec { · 182 unmodified lines | ||
| 183 | 183 | struct automic_entry am_entry[MAX_AUTO_MIC_PINS]; |
| 184 | 184 | |
| 185 | 185 | /* for pin sensing */ |
| 186 | − /* current status; set in hda_geneic.c */ | |
| 186 | + /* current status; set in hda_generic.c */ | |
| 187 | 187 | unsigned int hp_jack_present:1; |
| 188 | 188 | unsigned int line_jack_present:1; |
| 189 | 189 | unsigned int speaker_muted:1; /* current status of speaker mute */ |
| @@ -1350,8 +1350,12 @@ static void azx_free(struct azx *chip) · 1349 unmodified lines | ||
| 1350 | 1350 | if (hda->freed) |
| 1351 | 1351 | return; |
| 1352 | 1352 | |
| 1353 | − if (azx_has_pm_runtime(chip) && chip->running) | |
| 1353 | + if (azx_has_pm_runtime(chip) && chip->running) { | |
| 1354 | 1354 | pm_runtime_get_noresume(&pci->dev); |
| 1355 | + pm_runtime_forbid(&pci->dev); | |
| 1356 | + pm_runtime_dont_use_autosuspend(&pci->dev); | |
| 1357 | + } | |
| 1358 | + | |
| 1355 | 1359 | chip->running = 0; |
| 1356 | 1360 | |
| 1357 | 1361 | azx_del_card_list(chip); |
| @@ -2489,9 +2493,14 @@ static const struct pci_device_id azx_ids[] = { · 1131 unmodified lines | ||
| 2489 | 2493 | /* Alderlake-P */ |
| 2490 | 2494 | { PCI_DEVICE(0x8086, 0x51c8), |
| 2491 | 2495 | .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
| 2496 | + { PCI_DEVICE(0x8086, 0x51cd), | |
| 2497 | + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, | |
| 2492 | 2498 | /* Alderlake-M */ |
| 2493 | 2499 | { PCI_DEVICE(0x8086, 0x51cc), |
| 2494 | 2500 | .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
| 2501 | + /* Alderlake-N */ | |
| 2502 | + { PCI_DEVICE(0x8086, 0x54c8), | |
| 2503 | + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, | |
| 2495 | 2504 | /* Elkhart Lake */ |
| 2496 | 2505 | { PCI_DEVICE(0x8086, 0x4b55), |
| 2497 | 2506 | .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
| @@ -158,6 +158,17 @@ snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid, int dev_id) · 157 unmodified lines | ||
| 158 | 158 | return jack; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | +void snd_hda_jack_tbl_disconnect(struct hda_codec *codec) | |
| 162 | +{ | |
| 163 | + struct hda_jack_tbl *jack = codec->jacktbl.list; | |
| 164 | + int i; | |
| 165 | + | |
| 166 | + for (i = 0; i < codec->jacktbl.used; i++, jack++) { | |
| 167 | + if (!codec->bus->shutdown && jack->jack) | |
| 168 | + snd_device_disconnect(codec->card, jack->jack); | |
| 169 | + } | |
| 170 | +} | |
| 171 | + | |
| 161 | 172 | void snd_hda_jack_tbl_clear(struct hda_codec *codec) |
| 162 | 173 | { |
| 163 | 174 | struct hda_jack_tbl *jack = codec->jacktbl.list; |
| @@ -69,6 +69,7 @@ struct hda_jack_tbl * · 68 unmodified lines | ||
| 69 | 69 | snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, |
| 70 | 70 | unsigned char tag, int dev_id); |
| 71 | 71 | |
| 72 | +void snd_hda_jack_tbl_disconnect(struct hda_codec *codec); | |
| 72 | 73 | void snd_hda_jack_tbl_clear(struct hda_codec *codec); |
| 73 | 74 | |
| 74 | 75 | void snd_hda_jack_set_dirty_all(struct hda_codec *codec); |
| @@ -137,6 +137,7 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, · 136 unmodified lines | ||
| 137 | 137 | int snd_hda_codec_reset(struct hda_codec *codec); |
| 138 | 138 | void snd_hda_codec_register(struct hda_codec *codec); |
| 139 | 139 | void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec); |
| 140 | +void snd_hda_codec_disconnect_pcms(struct hda_codec *codec); | |
| 140 | 141 | |
| 141 | 142 | #define snd_hda_regmap_sync(codec) snd_hdac_regmap_sync(&(codec)->core) |
| 142 | 143 | |
| @@ -68,14 +68,20 @@ · 67 unmodified lines | ||
| 68 | 68 | */ |
| 69 | 69 | #define TEGRA194_NUM_SDO_LINES 4 |
| 70 | 70 | |
| 71 | +struct hda_tegra_soc { | |
| 72 | + bool has_hda2codec_2x_reset; | |
| 73 | +}; | |
| 74 | + | |
| 71 | 75 | struct hda_tegra { |
| 72 | 76 | struct azx chip; |
| 73 | 77 | struct device *dev; |
| 74 | − struct reset_control *reset; | |
| 78 | + struct reset_control_bulk_data resets[3]; | |
| 75 | 79 | struct clk_bulk_data clocks[3]; |
| 80 | + unsigned int nresets; | |
| 76 | 81 | unsigned int nclocks; |
| 77 | 82 | void __iomem *regs; |
| 78 | 83 | struct work_struct probe_work; |
| 84 | + const struct hda_tegra_soc *soc; | |
| 79 | 85 | }; |
| 80 | 86 | |
| 81 | 87 | #ifdef CONFIG_PM |
| @@ -170,7 +176,7 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) · 88 unmodified lines | ||
| 170 | 176 | int rc; |
| 171 | 177 | |
| 172 | 178 | if (!chip->running) { |
| 173 | − rc = reset_control_assert(hda->reset); | |
| 179 | + rc = reset_control_bulk_assert(hda->nresets, hda->resets); | |
| 174 | 180 | if (rc) |
| 175 | 181 | return rc; |
| 176 | 182 | } |
| @@ -187,7 +193,7 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) · 10 unmodified lines | ||
| 187 | 193 | } else { |
| 188 | 194 | usleep_range(10, 100); |
| 189 | 195 | |
| 190 | − rc = reset_control_deassert(hda->reset); | |
| 196 | + rc = reset_control_bulk_deassert(hda->nresets, hda->resets); | |
| 191 | 197 | if (rc) |
| 192 | 198 | return rc; |
| 193 | 199 | } |
| @@ -427,9 +433,17 @@ static int hda_tegra_create(struct snd_card *card, · 233 unmodified lines | ||
| 427 | 433 | return 0; |
| 428 | 434 | } |
| 429 | 435 | |
| 436 | +static const struct hda_tegra_soc tegra30_data = { | |
| 437 | + .has_hda2codec_2x_reset = true, | |
| 438 | +}; | |
| 439 | + | |
| 440 | +static const struct hda_tegra_soc tegra194_data = { | |
| 441 | + .has_hda2codec_2x_reset = false, | |
| 442 | +}; | |
| 443 | + | |
| 430 | 444 | static const struct of_device_id hda_tegra_match[] = { |
| 431 | − { .compatible = "nvidia,tegra30-hda" }, | |
| 432 | − { .compatible = "nvidia,tegra194-hda" }, | |
| 445 | + { .compatible = "nvidia,tegra30-hda", .data = &tegra30_data }, | |
| 446 | + { .compatible = "nvidia,tegra194-hda", .data = &tegra194_data }, | |
| 433 | 447 | {}, |
| 434 | 448 | }; |
| 435 | 449 | MODULE_DEVICE_TABLE(of, hda_tegra_match); |
| @@ -449,6 +463,8 @@ static int hda_tegra_probe(struct platform_device *pdev) · 13 unmodified lines | ||
| 449 | 463 | hda->dev = &pdev->dev; |
| 450 | 464 | chip = &hda->chip; |
| 451 | 465 | |
| 466 | + hda->soc = of_device_get_match_data(&pdev->dev); | |
| 467 | + | |
| 452 | 468 | err = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, |
| 453 | 469 | THIS_MODULE, 0, &card); |
| 454 | 470 | if (err < 0) { |
| @@ -456,11 +472,20 @@ static int hda_tegra_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 456 | 472 | return err; |
| 457 | 473 | } |
| 458 | 474 | |
| 459 | − hda->reset = devm_reset_control_array_get_exclusive(&pdev->dev); | |
| 460 | − if (IS_ERR(hda->reset)) { | |
| 461 | − err = PTR_ERR(hda->reset); | |
| 475 | + hda->resets[hda->nresets++].id = "hda"; | |
| 476 | + hda->resets[hda->nresets++].id = "hda2hdmi"; | |
| 477 | + /* | |
| 478 | + * "hda2codec_2x" reset is not present on Tegra194. Though DT would | |
| 479 | + * be updated to reflect this, but to have backward compatibility | |
| 480 | + * below is necessary. | |
| 481 | + */ | |
| 482 | + if (hda->soc->has_hda2codec_2x_reset) | |
| 483 | + hda->resets[hda->nresets++].id = "hda2codec_2x"; | |
| 484 | + | |
| 485 | + err = devm_reset_control_bulk_get_exclusive(&pdev->dev, hda->nresets, | |
| 486 | + hda->resets); | |
| 487 | + if (err) | |
| 462 | 488 | goto out_free; |
| 463 | − } | |
| 464 | 489 | |
| 465 | 490 | hda->clocks[hda->nclocks++].id = "hda"; |
| 466 | 491 | hda->clocks[hda->nclocks++].id = "hda2hdmi"; |
| @@ -252,6 +252,7 @@ struct sub_codec cs8409_cs42l42_codec = { · 251 unmodified lines | ||
| 252 | 252 | .init_seq_num = ARRAY_SIZE(cs42l42_init_reg_seq), |
| 253 | 253 | .hp_jack_in = 0, |
| 254 | 254 | .mic_jack_in = 0, |
| 255 | + .force_status_change = 1, | |
| 255 | 256 | .paged = 1, |
| 256 | 257 | .suspended = 1, |
| 257 | 258 | .no_type_dect = 0, |
| @@ -443,6 +444,7 @@ struct sub_codec dolphin_cs42l42_0 = { · 185 unmodified lines | ||
| 443 | 444 | .init_seq_num = ARRAY_SIZE(dolphin_c0_init_reg_seq), |
| 444 | 445 | .hp_jack_in = 0, |
| 445 | 446 | .mic_jack_in = 0, |
| 447 | + .force_status_change = 1, | |
| 446 | 448 | .paged = 1, |
| 447 | 449 | .suspended = 1, |
| 448 | 450 | .no_type_dect = 0, |
| @@ -456,6 +458,7 @@ struct sub_codec dolphin_cs42l42_1 = { · 7 unmodified lines | ||
| 456 | 458 | .init_seq_num = ARRAY_SIZE(dolphin_c1_init_reg_seq), |
| 457 | 459 | .hp_jack_in = 0, |
| 458 | 460 | .mic_jack_in = 0, |
| 461 | + .force_status_change = 1, | |
| 459 | 462 | .paged = 1, |
| 460 | 463 | .suspended = 1, |
| 461 | 464 | .no_type_dect = 1, |
| @@ -628,15 +628,17 @@ static void cs42l42_run_jack_detect(struct sub_codec *cs42l42) · 627 unmodified lines | ||
| 628 | 628 | cs8409_i2c_write(cs42l42, 0x1b74, 0x07); |
| 629 | 629 | cs8409_i2c_write(cs42l42, 0x131b, 0xFD); |
| 630 | 630 | cs8409_i2c_write(cs42l42, 0x1120, 0x80); |
| 631 | − /* Wait ~100us*/ | |
| 632 | − usleep_range(100, 200); | |
| 631 | + /* Wait ~20ms*/ | |
| 632 | + usleep_range(20000, 25000); | |
| 633 | 633 | cs8409_i2c_write(cs42l42, 0x111f, 0x77); |
| 634 | 634 | cs8409_i2c_write(cs42l42, 0x1120, 0xc0); |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | static int cs42l42_handle_tip_sense(struct sub_codec *cs42l42, unsigned int reg_ts_status) |
| 638 | 638 | { |
| 639 | − int status_changed = 0; | |
| 639 | + int status_changed = cs42l42->force_status_change; | |
| 640 | + | |
| 641 | + cs42l42->force_status_change = 0; | |
| 640 | 642 | |
| 641 | 643 | /* TIP_SENSE INSERT/REMOVE */ |
| 642 | 644 | switch (reg_ts_status) { |
| @@ -791,6 +793,7 @@ static void cs42l42_suspend(struct sub_codec *cs42l42) · 148 unmodified lines | ||
| 791 | 793 | cs42l42->last_page = 0; |
| 792 | 794 | cs42l42->hp_jack_in = 0; |
| 793 | 795 | cs42l42->mic_jack_in = 0; |
| 796 | + cs42l42->force_status_change = 1; | |
| 794 | 797 | |
| 795 | 798 | /* Put CS42L42 into Reset */ |
| 796 | 799 | gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); |
| @@ -305,6 +305,7 @@ struct sub_codec { · 304 unmodified lines | ||
| 305 | 305 | |
| 306 | 306 | unsigned int hp_jack_in:1; |
| 307 | 307 | unsigned int mic_jack_in:1; |
| 308 | + unsigned int force_status_change:1; | |
| 308 | 309 | unsigned int suspended:1; |
| 309 | 310 | unsigned int paged:1; |
| 310 | 311 | unsigned int last_page; |
| @@ -1535,7 +1535,7 @@ static void update_eld(struct hda_codec *codec, · 1534 unmodified lines | ||
| 1535 | 1535 | } |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | − if (!eld->eld_valid || eld->eld_size <= 0) { | |
| 1538 | + if (!eld->eld_valid || eld->eld_size <= 0 || eld->info.sad_count <= 0) { | |
| 1539 | 1539 | eld->eld_valid = false; |
| 1540 | 1540 | eld->eld_size = 0; |
| 1541 | 1541 | } |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "hda_auto_parser.h" |
| 26 | 26 | #include "hda_jack.h" |
| 27 | 27 | #include "hda_generic.h" |
| 28 | +#include "hda_component.h" | |
| 28 | 29 | |
| 29 | 30 | /* keep halting ALC5505 DSP, for power saving */ |
| 30 | 31 | #define HALT_REALTEK_ALC5505 |
| @@ -126,6 +127,10 @@ struct alc_spec { · 95 unmodified lines | ||
| 126 | 127 | unsigned int coef0; |
| 127 | 128 | struct input_dev *kb_dev; |
| 128 | 129 | u8 alc_mute_keycode_map[1]; |
| 130 | + | |
| 131 | + /* component binding */ | |
| 132 | + struct component_match *match; | |
| 133 | + struct hda_component comps[HDA_MAX_COMPONENTS]; | |
| 129 | 134 | }; |
| 130 | 135 | |
| 131 | 136 | /* |
| @@ -1924,6 +1929,7 @@ enum { · 1792 unmodified lines | ||
| 1924 | 1929 | ALC887_FIXUP_ASUS_BASS, |
| 1925 | 1930 | ALC887_FIXUP_BASS_CHMAP, |
| 1926 | 1931 | ALC1220_FIXUP_GB_DUAL_CODECS, |
| 1932 | + ALC1220_FIXUP_GB_X570, | |
| 1927 | 1933 | ALC1220_FIXUP_CLEVO_P950, |
| 1928 | 1934 | ALC1220_FIXUP_CLEVO_PB51ED, |
| 1929 | 1935 | ALC1220_FIXUP_CLEVO_PB51ED_PINS, |
| @@ -2113,6 +2119,29 @@ static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec, · 183 unmodified lines | ||
| 2113 | 2119 | } |
| 2114 | 2120 | } |
| 2115 | 2121 | |
| 2122 | +static void alc1220_fixup_gb_x570(struct hda_codec *codec, | |
| 2123 | + const struct hda_fixup *fix, | |
| 2124 | + int action) | |
| 2125 | +{ | |
| 2126 | + static const hda_nid_t conn1[] = { 0x0c }; | |
| 2127 | + static const struct coef_fw gb_x570_coefs[] = { | |
| 2128 | + WRITE_COEF(0x1a, 0x01c1), | |
| 2129 | + WRITE_COEF(0x1b, 0x0202), | |
| 2130 | + WRITE_COEF(0x43, 0x3005), | |
| 2131 | + {} | |
| 2132 | + }; | |
| 2133 | + | |
| 2134 | + switch (action) { | |
| 2135 | + case HDA_FIXUP_ACT_PRE_PROBE: | |
| 2136 | + snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); | |
| 2137 | + snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1); | |
| 2138 | + break; | |
| 2139 | + case HDA_FIXUP_ACT_INIT: | |
| 2140 | + alc_process_coef_fw(codec, gb_x570_coefs); | |
| 2141 | + break; | |
| 2142 | + } | |
| 2143 | +} | |
| 2144 | + | |
| 2116 | 2145 | static void alc1220_fixup_clevo_p950(struct hda_codec *codec, |
| 2117 | 2146 | const struct hda_fixup *fix, |
| 2118 | 2147 | int action) |
| @@ -2415,6 +2444,10 @@ static const struct hda_fixup alc882_fixups[] = { · 296 unmodified lines | ||
| 2415 | 2444 | .type = HDA_FIXUP_FUNC, |
| 2416 | 2445 | .v.func = alc1220_fixup_gb_dual_codecs, |
| 2417 | 2446 | }, |
| 2447 | + [ALC1220_FIXUP_GB_X570] = { | |
| 2448 | + .type = HDA_FIXUP_FUNC, | |
| 2449 | + .v.func = alc1220_fixup_gb_x570, | |
| 2450 | + }, | |
| 2418 | 2451 | [ALC1220_FIXUP_CLEVO_P950] = { |
| 2419 | 2452 | .type = HDA_FIXUP_FUNC, |
| 2420 | 2453 | .v.func = alc1220_fixup_clevo_p950, |
| @@ -2517,7 +2550,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { · 96 unmodified lines | ||
| 2517 | 2550 | SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD), |
| 2518 | 2551 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE), |
| 2519 | 2552 | SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), |
| 2520 | − SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950), | |
| 2553 | + SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570), | |
| 2521 | 2554 | SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_CLEVO_P950), |
| 2522 | 2555 | SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950), |
| 2523 | 2556 | SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950), |
| @@ -6497,6 +6530,133 @@ static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec, · 3973 unmodified lines | ||
| 6497 | 6530 | } |
| 6498 | 6531 | } |
| 6499 | 6532 | |
| 6533 | +static int comp_match_dev_name(struct device *dev, void *data) | |
| 6534 | +{ | |
| 6535 | + return strcmp(dev_name(dev), data) == 0; | |
| 6536 | +} | |
| 6537 | + | |
| 6538 | +static int find_comp_by_dev_name(struct alc_spec *spec, const char *name) | |
| 6539 | +{ | |
| 6540 | + int i; | |
| 6541 | + | |
| 6542 | + for (i = 0; i < HDA_MAX_COMPONENTS; i++) { | |
| 6543 | + if (strcmp(spec->comps[i].name, name) == 0) | |
| 6544 | + return i; | |
| 6545 | + } | |
| 6546 | + | |
| 6547 | + return -ENODEV; | |
| 6548 | +} | |
| 6549 | + | |
| 6550 | +static int comp_bind(struct device *dev) | |
| 6551 | +{ | |
| 6552 | + struct hda_codec *cdc = dev_to_hda_codec(dev); | |
| 6553 | + struct alc_spec *spec = cdc->spec; | |
| 6554 | + | |
| 6555 | + return component_bind_all(dev, spec->comps); | |
| 6556 | +} | |
| 6557 | + | |
| 6558 | +static void comp_unbind(struct device *dev) | |
| 6559 | +{ | |
| 6560 | + struct hda_codec *cdc = dev_to_hda_codec(dev); | |
| 6561 | + struct alc_spec *spec = cdc->spec; | |
| 6562 | + | |
| 6563 | + component_unbind_all(dev, spec->comps); | |
| 6564 | +} | |
| 6565 | + | |
| 6566 | +static const struct component_master_ops comp_master_ops = { | |
| 6567 | + .bind = comp_bind, | |
| 6568 | + .unbind = comp_unbind, | |
| 6569 | +}; | |
| 6570 | + | |
| 6571 | +static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_codec *cdc, | |
| 6572 | + struct snd_pcm_substream *sub, int action) | |
| 6573 | +{ | |
| 6574 | + struct alc_spec *spec = cdc->spec; | |
| 6575 | + int i; | |
| 6576 | + | |
| 6577 | + for (i = 0; i < HDA_MAX_COMPONENTS; i++) { | |
| 6578 | + if (spec->comps[i].dev) | |
| 6579 | + spec->comps[i].playback_hook(spec->comps[i].dev, action); | |
| 6580 | + } | |
| 6581 | +} | |
| 6582 | + | |
| 6583 | +static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char *bus, | |
| 6584 | + const char *hid, int count) | |
| 6585 | +{ | |
| 6586 | + struct device *dev = hda_codec_dev(cdc); | |
| 6587 | + struct alc_spec *spec = cdc->spec; | |
| 6588 | + char *name; | |
| 6589 | + int ret, i; | |
| 6590 | + | |
| 6591 | + switch (action) { | |
| 6592 | + case HDA_FIXUP_ACT_PRE_PROBE: | |
| 6593 | + for (i = 0; i < count; i++) { | |
| 6594 | + name = devm_kasprintf(dev, GFP_KERNEL, | |
| 6595 | + "%s-%s:00-cs35l41-hda.%d", bus, hid, i); | |
| 6596 | + if (!name) | |
| 6597 | + return; | |
| 6598 | + component_match_add(dev, &spec->match, comp_match_dev_name, name); | |
| 6599 | + } | |
| 6600 | + ret = component_master_add_with_match(dev, &comp_master_ops, spec->match); | |
| 6601 | + if (ret) | |
| 6602 | + codec_err(cdc, "Fail to register component aggregator %d\n", ret); | |
| 6603 | + else | |
| 6604 | + spec->gen.pcm_playback_hook = comp_generic_playback_hook; | |
| 6605 | + break; | |
| 6606 | + } | |
| 6607 | +} | |
| 6608 | + | |
| 6609 | +static void cs35l41_fixup_i2c_two(struct hda_codec *cdc, const struct hda_fixup *fix, int action) | |
| 6610 | +{ | |
| 6611 | + cs35l41_generic_fixup(cdc, action, "i2c", "CSC3551", 2); | |
| 6612 | +} | |
| 6613 | + | |
| 6614 | +static void alc287_legion_16achg6_playback_hook(struct hda_pcm_stream *hinfo, struct hda_codec *cdc, | |
| 6615 | + struct snd_pcm_substream *sub, int action) | |
| 6616 | +{ | |
| 6617 | + struct alc_spec *spec = cdc->spec; | |
| 6618 | + unsigned int rx_slot; | |
| 6619 | + int i; | |
| 6620 | + | |
| 6621 | + switch (action) { | |
| 6622 | + case HDA_GEN_PCM_ACT_PREPARE: | |
| 6623 | + rx_slot = 0; | |
| 6624 | + i = find_comp_by_dev_name(spec, "i2c-CLSA0100:00-cs35l41-hda.0"); | |
| 6625 | + if (i >= 0) | |
| 6626 | + spec->comps[i].set_channel_map(spec->comps[i].dev, 0, NULL, 1, &rx_slot); | |
| 6627 | + | |
| 6628 | + rx_slot = 1; | |
| 6629 | + i = find_comp_by_dev_name(spec, "i2c-CLSA0100:00-cs35l41-hda.1"); | |
| 6630 | + if (i >= 0) | |
| 6631 | + spec->comps[i].set_channel_map(spec->comps[i].dev, 0, NULL, 1, &rx_slot); | |
| 6632 | + break; | |
| 6633 | + } | |
| 6634 | + | |
| 6635 | + comp_generic_playback_hook(hinfo, cdc, sub, action); | |
| 6636 | +} | |
| 6637 | + | |
| 6638 | +static void alc287_fixup_legion_16achg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix, | |
| 6639 | + int action) | |
| 6640 | +{ | |
| 6641 | + struct device *dev = hda_codec_dev(cdc); | |
| 6642 | + struct alc_spec *spec = cdc->spec; | |
| 6643 | + int ret; | |
| 6644 | + | |
| 6645 | + switch (action) { | |
| 6646 | + case HDA_FIXUP_ACT_PRE_PROBE: | |
| 6647 | + component_match_add(dev, &spec->match, comp_match_dev_name, | |
| 6648 | + "i2c-CLSA0100:00-cs35l41-hda.0"); | |
| 6649 | + component_match_add(dev, &spec->match, comp_match_dev_name, | |
| 6650 | + "i2c-CLSA0100:00-cs35l41-hda.1"); | |
| 6651 | + ret = component_master_add_with_match(dev, &comp_master_ops, spec->match); | |
| 6652 | + if (ret) | |
| 6653 | + codec_err(cdc, "Fail to register component aggregator %d\n", ret); | |
| 6654 | + else | |
| 6655 | + spec->gen.pcm_playback_hook = alc287_legion_16achg6_playback_hook; | |
| 6656 | + break; | |
| 6657 | + } | |
| 6658 | +} | |
| 6659 | + | |
| 6500 | 6660 | /* for alc295_fixup_hp_top_speakers */ |
| 6501 | 6661 | #include "hp_x360_helper.c" |
| 6502 | 6662 | |
| @@ -6784,6 +6944,10 @@ enum { · 281 unmodified lines | ||
| 6784 | 6944 | ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE, |
| 6785 | 6945 | ALC233_FIXUP_NO_AUDIO_JACK, |
| 6786 | 6946 | ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME, |
| 6947 | + ALC285_FIXUP_LEGION_Y9000X_SPEAKERS, | |
| 6948 | + ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE, | |
| 6949 | + ALC287_FIXUP_LEGION_16ACHG6, | |
| 6950 | + ALC287_FIXUP_CS35L41_I2C_2, | |
| 6787 | 6951 | }; |
| 6788 | 6952 | |
| 6789 | 6953 | static const struct hda_fixup alc269_fixups[] = { |
| @@ -8380,6 +8544,18 @@ static const struct hda_fixup alc269_fixups[] = { · 1590 unmodified lines | ||
| 8380 | 8544 | .chained = true, |
| 8381 | 8545 | .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF, |
| 8382 | 8546 | }, |
| 8547 | + [ALC285_FIXUP_LEGION_Y9000X_SPEAKERS] = { | |
| 8548 | + .type = HDA_FIXUP_FUNC, | |
| 8549 | + .v.func = alc285_fixup_ideapad_s740_coef, | |
| 8550 | + .chained = true, | |
| 8551 | + .chain_id = ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE, | |
| 8552 | + }, | |
| 8553 | + [ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE] = { | |
| 8554 | + .type = HDA_FIXUP_FUNC, | |
| 8555 | + .v.func = alc287_fixup_legion_15imhg05_speakers, | |
| 8556 | + .chained = true, | |
| 8557 | + .chain_id = ALC269_FIXUP_THINKPAD_ACPI, | |
| 8558 | + }, | |
| 8383 | 8559 | [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = { |
| 8384 | 8560 | .type = HDA_FIXUP_VERBS, |
| 8385 | 8561 | //.v.verbs = legion_15imhg05_coefs, |
| @@ -8514,6 +8690,14 @@ static const struct hda_fixup alc269_fixups[] = { · 128 unmodified lines | ||
| 8514 | 8690 | .chained = true, |
| 8515 | 8691 | .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC |
| 8516 | 8692 | }, |
| 8693 | + [ALC287_FIXUP_LEGION_16ACHG6] = { | |
| 8694 | + .type = HDA_FIXUP_FUNC, | |
| 8695 | + .v.func = alc287_fixup_legion_16achg6_speakers, | |
| 8696 | + }, | |
| 8697 | + [ALC287_FIXUP_CS35L41_I2C_2] = { | |
| 8698 | + .type = HDA_FIXUP_FUNC, | |
| 8699 | + .v.func = cs35l41_fixup_i2c_two, | |
| 8700 | + }, | |
| 8517 | 8701 | }; |
| 8518 | 8702 | |
| 8519 | 8703 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
| @@ -8730,6 +8914,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 210 unmodified lines | ||
| 8730 | 8914 | SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED), |
| 8731 | 8915 | SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), |
| 8732 | 8916 | SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED), |
| 8917 | + SND_PCI_QUIRK(0x103c, 0x89c3, "HP", ALC285_FIXUP_HP_GPIO_LED), | |
| 8733 | 8918 | SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), |
| 8734 | 8919 | SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), |
| 8735 | 8920 | SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), |
| @@ -8910,6 +9095,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 174 unmodified lines | ||
| 8910 | 9095 | SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK), |
| 8911 | 9096 | SND_PCI_QUIRK(0x17aa, 0x22c1, "Thinkpad P1 Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK), |
| 8912 | 9097 | SND_PCI_QUIRK(0x17aa, 0x22c2, "Thinkpad X1 Extreme Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK), |
| 9098 | + SND_PCI_QUIRK(0x17aa, 0x22f1, "Thinkpad", ALC287_FIXUP_CS35L41_I2C_2), | |
| 9099 | + SND_PCI_QUIRK(0x17aa, 0x22f2, "Thinkpad", ALC287_FIXUP_CS35L41_I2C_2), | |
| 9100 | + SND_PCI_QUIRK(0x17aa, 0x22f3, "Thinkpad", ALC287_FIXUP_CS35L41_I2C_2), | |
| 8913 | 9101 | SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), |
| 8914 | 9102 | SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), |
| 8915 | 9103 | SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), |
| @@ -8921,13 +9109,17 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 5 unmodified lines | ||
| 8921 | 9109 | SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), |
| 8922 | 9110 | SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), |
| 8923 | 9111 | SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340), |
| 9112 | + SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS), | |
| 8924 | 9113 | SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), |
| 9114 | + SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS), | |
| 9115 | + SND_PCI_QUIRK(0x17aa, 0x3824, "Legion Y9000X 2020", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS), | |
| 8925 | 9116 | SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), |
| 9117 | + SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), | |
| 8926 | 9118 | SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP), |
| 8927 | − SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS), | |
| 9119 | + SND_PCI_QUIRK(0x17aa, 0x3847, "Legion 7 16ACHG6", ALC287_FIXUP_LEGION_16ACHG6), | |
| 9120 | + SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), | |
| 8928 | 9121 | SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), |
| 8929 | 9122 | SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), |
| 8930 | − SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS), | |
| 8931 | 9123 | SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), |
| 8932 | 9124 | SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), |
| 8933 | 9125 | SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI), |
| @@ -23,8 +23,6 @@ · 22 unmodified lines | ||
| 23 | 23 | #define MSG_DESCRIPTOR_SIZE 0x24 |
| 24 | 24 | #define MSG_HEADER_SIZE (MSG_DESCRIPTOR_SIZE + 4) |
| 25 | 25 | |
| 26 | −#define MSG_DEFAULT_SIZE 512 | |
| 27 | − | |
| 28 | 26 | #define MSG_TYPE_MASK 0x00000003 /* mask for following types */ |
| 29 | 27 | #define MSG_TYPE_NOTIFY 0 /* embedded -> driver (only notification, do not get_msg() !) */ |
| 30 | 28 | #define MSG_TYPE_COMMAND 1 /* driver <-> embedded (a command has no answer) */ |
| @@ -444,6 +442,9 @@ irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id) · 413 unmodified lines | ||
| 444 | 442 | struct mixart_timer_notify *notify; |
| 445 | 443 | notify = (struct mixart_timer_notify *)mixart_msg_data; |
| 446 | 444 | |
| 445 | + BUILD_BUG_ON(sizeof(notify) > sizeof(mixart_msg_data)); | |
| 446 | + if (snd_BUG_ON(notify->stream_count > ARRAY_SIZE(notify->streams))) | |
| 447 | + break; | |
| 447 | 448 | for(i=0; i<notify->stream_count; i++) { |
| 448 | 449 | |
| 449 | 450 | u32 buffer_id = notify->streams[i].buffer_id; |
| @@ -49,6 +49,7 @@ enum mixart_message_id { · 48 unmodified lines | ||
| 49 | 49 | MSG_CLOCK_SET_PROPERTIES = 0x200002, |
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | +#define MSG_DEFAULT_SIZE 512 | |
| 52 | 53 | |
| 53 | 54 | struct mixart_msg |
| 54 | 55 | { |
| @@ -251,10 +252,17 @@ struct mixart_sample_pos · 196 unmodified lines | ||
| 251 | 252 | u32 sample_pos_low_part; |
| 252 | 253 | } __attribute__((packed)); |
| 253 | 254 | |
| 255 | +/* | |
| 256 | + * This structure is limited by the size of MSG_DEFAULT_SIZE. Instead of | |
| 257 | + * having MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS many streams, | |
| 258 | + * this is capped to have a total size below MSG_DEFAULT_SIZE. | |
| 259 | + */ | |
| 260 | +#define MIXART_MAX_TIMER_NOTIFY_STREAMS \ | |
| 261 | + ((MSG_DEFAULT_SIZE - sizeof(u32)) / sizeof(struct mixart_sample_pos)) | |
| 254 | 262 | struct mixart_timer_notify |
| 255 | 263 | { |
| 256 | 264 | u32 stream_count; |
| 257 | − struct mixart_sample_pos streams[MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS]; | |
| 265 | + struct mixart_sample_pos streams[MIXART_MAX_TIMER_NOTIFY_STREAMS]; | |
| 258 | 266 | } __attribute__((packed)); |
| 259 | 267 | |
| 260 | 268 | |
| @@ -99,7 +99,7 @@ static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type, · 98 unmodified lines | ||
| 99 | 99 | return -1; |
| 100 | 100 | |
| 101 | 101 | switch (code) { |
| 102 | − case SND_BELL: if (hz) hz = 1000; | |
| 102 | + case SND_BELL: if (hz) hz = 1000; break; | |
| 103 | 103 | case SND_TONE: break; |
| 104 | 104 | default: return -1; |
| 105 | 105 | } |
| @@ -68,7 +68,7 @@ config SND_SOC_AMD_VANGOGH_MACH · 67 unmodified lines | ||
| 68 | 68 | tristate "AMD Vangogh support for NAU8821 CS35L41" |
| 69 | 69 | select SND_SOC_NAU8821 |
| 70 | 70 | select SND_SOC_CS35L41_SPI |
| 71 | − depends on SND_SOC_AMD_ACP5x && I2C | |
| 71 | + depends on SND_SOC_AMD_ACP5x && I2C && SPI_MASTER | |
| 72 | 72 | help |
| 73 | 73 | This option enables machine driver for Vangogh platform |
| 74 | 74 | using NAU8821 and CS35L41 codecs. |
| @@ -96,4 +96,11 @@ config SND_SOC_AMD_YC_MACH · 21 unmodified lines | ||
| 96 | 96 | Say m if you have such a device. |
| 97 | 97 | If unsure select "N". |
| 98 | 98 | |
| 99 | +config SND_AMD_ACP_CONFIG | |
| 100 | + tristate "AMD ACP configuration selection" | |
| 101 | + select SND_SOC_ACPI if ACPI | |
| 102 | + help | |
| 103 | + This option adds an auto detection to determine which ACP | |
| 104 | + driver modules to use | |
| 105 | + | |
| 99 | 106 | source "sound/soc/amd/acp/Kconfig" |
| @@ -3,6 +3,7 @@ acp_audio_dma-objs := acp-pcm-dma.o · 2 unmodified lines | ||
| 3 | 3 | snd-soc-acp-da7219mx98357-mach-objs := acp-da7219-max98357a.o |
| 4 | 4 | snd-soc-acp-rt5645-mach-objs := acp-rt5645.o |
| 5 | 5 | snd-soc-acp-rt5682-mach-objs := acp3x-rt5682-max9836.o |
| 6 | +snd-acp-config-objs := acp-config.o | |
| 6 | 7 | |
| 7 | 8 | obj-$(CONFIG_SND_SOC_AMD_ACP) += acp_audio_dma.o |
| 8 | 9 | obj-$(CONFIG_SND_SOC_AMD_CZ_DA7219MX98357_MACH) += snd-soc-acp-da7219mx98357-mach.o |
| @@ -13,3 +14,4 @@ obj-$(CONFIG_SND_SOC_AMD_RENOIR) += renoir/ · 4 unmodified lines | ||
| 13 | 14 | obj-$(CONFIG_SND_SOC_AMD_ACP5x) += vangogh/ |
| 14 | 15 | obj-$(CONFIG_SND_SOC_AMD_ACP6x) += yc/ |
| 15 | 16 | obj-$(CONFIG_SND_SOC_AMD_ACP_COMMON) += acp/ |
| 17 | +obj-$(CONFIG_SND_AMD_ACP_CONFIG) += snd-acp-config.o | |
| @@ -0,0 +1,124 @@ | ||
| 1 | +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) | |
| 2 | +// | |
| 3 | +// This file is provided under a dual BSD/GPLv2 license. When using or | |
| 4 | +// redistributing this file, you may do so under either license. | |
| 5 | +// | |
| 6 | +// Copyright(c) 2021 Advanced Micro Devices, Inc. | |
| 7 | +// | |
| 8 | +// Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> | |
| 9 | +// | |
| 10 | + | |
| 11 | +/* ACP machine configuration module */ | |
| 12 | + | |
| 13 | +#include <linux/acpi.h> | |
| 14 | +#include <linux/bits.h> | |
| 15 | +#include <linux/dmi.h> | |
| 16 | +#include <linux/module.h> | |
| 17 | +#include <linux/pci.h> | |
| 18 | + | |
| 19 | +#include "../sof/amd/acp.h" | |
| 20 | +#include "mach-config.h" | |
| 21 | + | |
| 22 | +static int acp_quirk_data; | |
| 23 | + | |
| 24 | +static const struct config_entry config_table[] = { | |
| 25 | + { | |
| 26 | + .flags = FLAG_AMD_SOF, | |
| 27 | + .device = ACP_PCI_DEV_ID, | |
| 28 | + .dmi_table = (const struct dmi_system_id []) { | |
| 29 | + { | |
| 30 | + .matches = { | |
| 31 | + DMI_MATCH(DMI_SYS_VENDOR, "AMD"), | |
| 32 | + DMI_MATCH(DMI_PRODUCT_NAME, "Majolica-CZN"), | |
| 33 | + }, | |
| 34 | + }, | |
| 35 | + {} | |
| 36 | + }, | |
| 37 | + }, | |
| 38 | + { | |
| 39 | + .flags = FLAG_AMD_SOF, | |
| 40 | + .device = ACP_PCI_DEV_ID, | |
| 41 | + .dmi_table = (const struct dmi_system_id []) { | |
| 42 | + { | |
| 43 | + .matches = { | |
| 44 | + DMI_MATCH(DMI_SYS_VENDOR, "Google"), | |
| 45 | + }, | |
| 46 | + }, | |
| 47 | + {} | |
| 48 | + }, | |
| 49 | + }, | |
| 50 | +}; | |
| 51 | + | |
| 52 | +int snd_amd_acp_find_config(struct pci_dev *pci) | |
| 53 | +{ | |
| 54 | + const struct config_entry *table = config_table; | |
| 55 | + u16 device = pci->device; | |
| 56 | + int i; | |
| 57 | + | |
| 58 | + /* Do not enable FLAGS on older platforms with Rev id zero */ | |
| 59 | + if (!pci->revision) | |
| 60 | + return 0; | |
| 61 | + | |
| 62 | + for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) { | |
| 63 | + if (table->device != device) | |
| 64 | + continue; | |
| 65 | + if (table->dmi_table && !dmi_check_system(table->dmi_table)) | |
| 66 | + continue; | |
| 67 | + acp_quirk_data = table->flags; | |
| 68 | + return table->flags; | |
| 69 | + } | |
| 70 | + | |
| 71 | + return 0; | |
| 72 | +} | |
| 73 | +EXPORT_SYMBOL(snd_amd_acp_find_config); | |
| 74 | + | |
| 75 | +static struct snd_soc_acpi_codecs amp_rt1019 = { | |
| 76 | + .num_codecs = 1, | |
| 77 | + .codecs = {"10EC1019"} | |
| 78 | +}; | |
| 79 | + | |
| 80 | +static struct snd_soc_acpi_codecs amp_max = { | |
| 81 | + .num_codecs = 1, | |
| 82 | + .codecs = {"MX98360A"} | |
| 83 | +}; | |
| 84 | + | |
| 85 | +struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = { | |
| 86 | + { | |
| 87 | + .id = "10EC5682", | |
| 88 | + .drv_name = "rt5682-rt1019", | |
| 89 | + .pdata = (void *)&acp_quirk_data, | |
| 90 | + .machine_quirk = snd_soc_acpi_codec_list, | |
| 91 | + .quirk_data = &_rt1019, | |
| 92 | + .fw_filename = "sof-rn.ri", | |
| 93 | + .sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg", | |
| 94 | + }, | |
| 95 | + { | |
| 96 | + .id = "10EC5682", | |
| 97 | + .drv_name = "rt5682-max", | |
| 98 | + .pdata = (void *)&acp_quirk_data, | |
| 99 | + .machine_quirk = snd_soc_acpi_codec_list, | |
| 100 | + .quirk_data = &_max, | |
| 101 | + .fw_filename = "sof-rn.ri", | |
| 102 | + .sof_tplg_filename = "sof-rn-rt5682-max98360.tplg", | |
| 103 | + }, | |
| 104 | + { | |
| 105 | + .id = "RTL5682", | |
| 106 | + .drv_name = "rt5682s-max", | |
| 107 | + .pdata = (void *)&acp_quirk_data, | |
| 108 | + .machine_quirk = snd_soc_acpi_codec_list, | |
| 109 | + .quirk_data = &_max, | |
| 110 | + .fw_filename = "sof-rn.ri", | |
| 111 | + .sof_tplg_filename = "sof-rn-rt5682-max98360.tplg", | |
| 112 | + }, | |
| 113 | + { | |
| 114 | + .id = "AMDI1019", | |
| 115 | + .drv_name = "renoir-dsp", | |
| 116 | + .pdata = (void *)&acp_quirk_data, | |
| 117 | + .fw_filename = "sof-rn.ri", | |
| 118 | + .sof_tplg_filename = "sof-acp.tplg", | |
| 119 | + }, | |
| 120 | + {}, | |
| 121 | +}; | |
| 122 | +EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines); | |
| 123 | + | |
| 124 | +MODULE_LICENSE("Dual BSD/GPL"); | |
| @@ -522,7 +522,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { · 521 unmodified lines | ||
| 522 | 522 | .name = "amd-da7219-play", |
| 523 | 523 | .stream_name = "Playback", |
| 524 | 524 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 525 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 525 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 526 | 526 | .init = cz_da7219_init, |
| 527 | 527 | .dpcm_playback = 1, |
| 528 | 528 | .stop_dma_first = 1, |
| @@ -533,7 +533,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { · 4 unmodified lines | ||
| 533 | 533 | .name = "amd-da7219-cap", |
| 534 | 534 | .stream_name = "Capture", |
| 535 | 535 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 536 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 536 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 537 | 537 | .dpcm_capture = 1, |
| 538 | 538 | .stop_dma_first = 1, |
| 539 | 539 | .ops = &cz_da7219_cap_ops, |
| @@ -543,7 +543,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { · 3 unmodified lines | ||
| 543 | 543 | .name = "amd-max98357-play", |
| 544 | 544 | .stream_name = "HiFi Playback", |
| 545 | 545 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 546 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 546 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 547 | 547 | .dpcm_playback = 1, |
| 548 | 548 | .stop_dma_first = 1, |
| 549 | 549 | .ops = &cz_max_play_ops, |
| @@ -554,7 +554,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { · 4 unmodified lines | ||
| 554 | 554 | .name = "dmic0", |
| 555 | 555 | .stream_name = "DMIC0 Capture", |
| 556 | 556 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 557 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 557 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 558 | 558 | .dpcm_capture = 1, |
| 559 | 559 | .stop_dma_first = 1, |
| 560 | 560 | .ops = &cz_dmic0_cap_ops, |
| @@ -565,7 +565,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { · 4 unmodified lines | ||
| 565 | 565 | .name = "dmic1", |
| 566 | 566 | .stream_name = "DMIC1 Capture", |
| 567 | 567 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 568 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 568 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 569 | 569 | .dpcm_capture = 1, |
| 570 | 570 | .stop_dma_first = 1, |
| 571 | 571 | .ops = &cz_dmic1_cap_ops, |
| @@ -578,7 +578,7 @@ static struct snd_soc_dai_link cz_dai_5682_98357[] = { · 6 unmodified lines | ||
| 578 | 578 | .name = "amd-rt5682-play", |
| 579 | 579 | .stream_name = "Playback", |
| 580 | 580 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 581 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 581 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 582 | 582 | .init = cz_rt5682_init, |
| 583 | 583 | .dpcm_playback = 1, |
| 584 | 584 | .stop_dma_first = 1, |
| @@ -589,7 +589,7 @@ static struct snd_soc_dai_link cz_dai_5682_98357[] = { · 4 unmodified lines | ||
| 589 | 589 | .name = "amd-rt5682-cap", |
| 590 | 590 | .stream_name = "Capture", |
| 591 | 591 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 592 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 592 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 593 | 593 | .dpcm_capture = 1, |
| 594 | 594 | .stop_dma_first = 1, |
| 595 | 595 | .ops = &cz_rt5682_cap_ops, |
| @@ -599,7 +599,7 @@ static struct snd_soc_dai_link cz_dai_5682_98357[] = { · 3 unmodified lines | ||
| 599 | 599 | .name = "amd-max98357-play", |
| 600 | 600 | .stream_name = "HiFi Playback", |
| 601 | 601 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 602 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 602 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 603 | 603 | .dpcm_playback = 1, |
| 604 | 604 | .stop_dma_first = 1, |
| 605 | 605 | .ops = &cz_rt5682_max_play_ops, |
| @@ -610,7 +610,7 @@ static struct snd_soc_dai_link cz_dai_5682_98357[] = { · 4 unmodified lines | ||
| 610 | 610 | .name = "dmic0", |
| 611 | 611 | .stream_name = "DMIC0 Capture", |
| 612 | 612 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 613 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 613 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 614 | 614 | .dpcm_capture = 1, |
| 615 | 615 | .stop_dma_first = 1, |
| 616 | 616 | .ops = &cz_rt5682_dmic0_cap_ops, |
| @@ -621,7 +621,7 @@ static struct snd_soc_dai_link cz_dai_5682_98357[] = { · 4 unmodified lines | ||
| 621 | 621 | .name = "dmic1", |
| 622 | 622 | .stream_name = "DMIC1 Capture", |
| 623 | 623 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 624 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 624 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 625 | 625 | .dpcm_capture = 1, |
| 626 | 626 | .stop_dma_first = 1, |
| 627 | 627 | .ops = &cz_rt5682_dmic1_cap_ops, |
| @@ -1003,6 +1003,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component, · 1002 unmodified lines | ||
| 1003 | 1003 | |
| 1004 | 1004 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 1005 | 1005 | struct audio_substream_data *rtd = runtime->private_data; |
| 1006 | + struct audio_drv_data *adata = dev_get_drvdata(component->dev); | |
| 1006 | 1007 | |
| 1007 | 1008 | if (!rtd) |
| 1008 | 1009 | return -EINVAL; |
| @@ -1023,7 +1024,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component, · 14 unmodified lines | ||
| 1023 | 1024 | } |
| 1024 | 1025 | if (bytescount > 0) { |
| 1025 | 1026 | delay = do_div(bytescount, period_bytes); |
| 1026 | − runtime->delay = bytes_to_frames(runtime, delay); | |
| 1027 | + adata->delay += bytes_to_frames(runtime, delay); | |
| 1027 | 1028 | } |
| 1028 | 1029 | } else { |
| 1029 | 1030 | buffersize = frames_to_bytes(runtime, runtime->buffer_size); |
| @@ -1035,6 +1036,17 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component, · 5 unmodified lines | ||
| 1035 | 1036 | return bytes_to_frames(runtime, pos); |
| 1036 | 1037 | } |
| 1037 | 1038 | |
| 1039 | +static snd_pcm_sframes_t acp_dma_delay(struct snd_soc_component *component, | |
| 1040 | + struct snd_pcm_substream *substream) | |
| 1041 | +{ | |
| 1042 | + struct audio_drv_data *adata = dev_get_drvdata(component->dev); | |
| 1043 | + snd_pcm_sframes_t delay = adata->delay; | |
| 1044 | + | |
| 1045 | + adata->delay = 0; | |
| 1046 | + | |
| 1047 | + return delay; | |
| 1048 | +} | |
| 1049 | + | |
| 1038 | 1050 | static int acp_dma_prepare(struct snd_soc_component *component, |
| 1039 | 1051 | struct snd_pcm_substream *substream) |
| 1040 | 1052 | { |
| @@ -1198,6 +1210,7 @@ static const struct snd_soc_component_driver acp_asoc_platform = { · 157 unmodified lines | ||
| 1198 | 1210 | .hw_params = acp_dma_hw_params, |
| 1199 | 1211 | .trigger = acp_dma_trigger, |
| 1200 | 1212 | .pointer = acp_dma_pointer, |
| 1213 | + .delay = acp_dma_delay, | |
| 1201 | 1214 | .prepare = acp_dma_prepare, |
| 1202 | 1215 | .pcm_construct = acp_dma_new, |
| 1203 | 1216 | }; |
| @@ -111,7 +111,7 @@ static struct snd_soc_dai_link cz_dai_rt5650[] = { · 110 unmodified lines | ||
| 111 | 111 | .name = "amd-rt5645-play", |
| 112 | 112 | .stream_name = "RT5645_AIF1", |
| 113 | 113 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 114 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 114 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 115 | 115 | .init = cz_init, |
| 116 | 116 | .ops = &cz_aif1_ops, |
| 117 | 117 | SND_SOC_DAILINK_REG(designware1, codec, platform), |
| @@ -120,7 +120,7 @@ static struct snd_soc_dai_link cz_dai_rt5650[] = { · 2 unmodified lines | ||
| 120 | 120 | .name = "amd-rt5645-cap", |
| 121 | 121 | .stream_name = "RT5645_AIF1", |
| 122 | 122 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 123 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 123 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 124 | 124 | .ops = &cz_aif1_ops, |
| 125 | 125 | SND_SOC_DAILINK_REG(designware2, codec, platform), |
| 126 | 126 | }, |
| @@ -151,6 +151,7 @@ struct audio_drv_data { · 150 unmodified lines | ||
| 151 | 151 | struct snd_pcm_substream *capture_i2sbt_stream; |
| 152 | 152 | void __iomem *acp_mmio; |
| 153 | 153 | u32 asic_type; |
| 154 | + snd_pcm_sframes_t delay; | |
| 154 | 155 | }; |
| 155 | 156 | |
| 156 | 157 | /* |
| @@ -32,7 +32,7 @@ config SND_AMD_ASOC_RENOIR · 31 unmodified lines | ||
| 32 | 32 | |
| 33 | 33 | config SND_SOC_AMD_MACH_COMMON |
| 34 | 34 | tristate |
| 35 | − depends on X86 && PCI && I2C | |
| 35 | + depends on X86 && PCI && I2C && GPIOLIB | |
| 36 | 36 | select CLK_FIXED_FCH |
| 37 | 37 | select SND_SOC_RT5682_I2C |
| 38 | 38 | select SND_SOC_DMIC |
| @@ -44,17 +44,15 @@ config SND_SOC_AMD_MACH_COMMON · 5 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | config SND_SOC_AMD_LEGACY_MACH |
| 46 | 46 | tristate "AMD Legacy Machine Driver Support" |
| 47 | − depends on X86 && PCI && I2C | |
| 47 | + depends on X86 && PCI && I2C && GPIOLIB | |
| 48 | 48 | select SND_SOC_AMD_MACH_COMMON |
| 49 | − depends on X86 && PCI && I2C | |
| 50 | 49 | help |
| 51 | 50 | This option enables legacy sound card support for ACP audio. |
| 52 | 51 | |
| 53 | 52 | config SND_SOC_AMD_SOF_MACH |
| 54 | 53 | tristate "AMD SOF Machine Driver Support" |
| 55 | − depends on X86 && PCI && I2C | |
| 54 | + depends on X86 && PCI && I2C && GPIOLIB | |
| 56 | 55 | select SND_SOC_AMD_MACH_COMMON |
| 57 | − depends on X86 && PCI && I2C | |
| 58 | 56 | help |
| 59 | 57 | This option enables SOF sound card support for ACP audio. |
| 60 | 58 | |
| @@ -27,6 +27,7 @@ static struct acp_card_drvdata rt5682_rt1019_data = { · 26 unmodified lines | ||
| 27 | 27 | .hs_codec_id = RT5682, |
| 28 | 28 | .amp_codec_id = RT1019, |
| 29 | 29 | .dmic_codec_id = NONE, |
| 30 | + .gpio_spkr_en = EN_SPKR_GPIO_GB, | |
| 30 | 31 | }; |
| 31 | 32 | |
| 32 | 33 | static const struct snd_kcontrol_new acp_controls[] = { |
| @@ -41,15 +42,16 @@ static const struct snd_kcontrol_new acp_controls[] = { · 8 unmodified lines | ||
| 41 | 42 | static const struct snd_soc_dapm_widget acp_widgets[] = { |
| 42 | 43 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 43 | 44 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 44 | − SND_SOC_DAPM_SPK("Spk", NULL), | |
| 45 | − SND_SOC_DAPM_SPK("Left Spk", NULL), | |
| 46 | − SND_SOC_DAPM_SPK("Right Spk", NULL), | |
| 45 | + SND_SOC_DAPM_SPK("Spk", event_spkr_handler), | |
| 46 | + SND_SOC_DAPM_SPK("Left Spk", event_spkr_handler), | |
| 47 | + SND_SOC_DAPM_SPK("Right Spk", event_spkr_handler), | |
| 47 | 48 | }; |
| 48 | 49 | |
| 49 | 50 | static int acp_asoc_probe(struct platform_device *pdev) |
| 50 | 51 | { |
| 51 | 52 | struct snd_soc_card *card = NULL; |
| 52 | 53 | struct device *dev = &pdev->dev; |
| 54 | + unsigned int spkr_gpio; | |
| 53 | 55 | int ret; |
| 54 | 56 | |
| 55 | 57 | if (!pdev->id_entry) |
| @@ -67,9 +69,20 @@ static int acp_asoc_probe(struct platform_device *pdev) · 11 unmodified lines | ||
| 67 | 69 | card->controls = acp_controls; |
| 68 | 70 | card->num_controls = ARRAY_SIZE(acp_controls); |
| 69 | 71 | card->drvdata = (struct acp_card_drvdata *)pdev->id_entry->driver_data; |
| 72 | + spkr_gpio = ((struct acp_card_drvdata *)(card->drvdata))->gpio_spkr_en; | |
| 70 | 73 | |
| 71 | 74 | acp_legacy_dai_links_create(card); |
| 72 | 75 | |
| 76 | + if (gpio_is_valid(spkr_gpio)) { | |
| 77 | + ret = devm_gpio_request(dev, spkr_gpio, "spkren"); | |
| 78 | + if (ret) { | |
| 79 | + dev_err(dev, "(%s) gpio request failed: %d\n", | |
| 80 | + __func__, ret); | |
| 81 | + return ret; | |
| 82 | + } | |
| 83 | + gpio_direction_output(spkr_gpio, 0); | |
| 84 | + } | |
| 85 | + | |
| 73 | 86 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 74 | 87 | if (ret) { |
| 75 | 88 | dev_err(&pdev->dev, |
| @@ -71,6 +71,31 @@ static const struct snd_soc_dapm_route rt5682_map[] = { · 70 unmodified lines | ||
| 71 | 71 | { "IN1P", NULL, "Headset Mic" }, |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | +int event_spkr_handler(struct snd_soc_dapm_widget *w, | |
| 75 | + struct snd_kcontrol *k, int event) | |
| 76 | +{ | |
| 77 | + struct snd_soc_dapm_context *dapm = w->dapm; | |
| 78 | + struct snd_soc_card *card = dapm->card; | |
| 79 | + struct acp_card_drvdata *drvdata = snd_soc_card_get_drvdata(card); | |
| 80 | + | |
| 81 | + if (!gpio_is_valid(drvdata->gpio_spkr_en)) | |
| 82 | + return 0; | |
| 83 | + | |
| 84 | + switch (event) { | |
| 85 | + case SND_SOC_DAPM_POST_PMU: | |
| 86 | + gpio_set_value(drvdata->gpio_spkr_en, 1); | |
| 87 | + break; | |
| 88 | + case SND_SOC_DAPM_PRE_PMD: | |
| 89 | + gpio_set_value(drvdata->gpio_spkr_en, 0); | |
| 90 | + break; | |
| 91 | + default: | |
| 92 | + dev_warn(card->dev, "%s invalid setting\n", __func__); | |
| 93 | + break; | |
| 94 | + } | |
| 95 | + return 0; | |
| 96 | +} | |
| 97 | +EXPORT_SYMBOL_NS_GPL(event_spkr_handler, SND_SOC_AMD_MACH); | |
| 98 | + | |
| 74 | 99 | /* Define card ops for RT5682 CODEC */ |
| 75 | 100 | static int acp_card_rt5682_init(struct snd_soc_pcm_runtime *rtd) |
| 76 | 101 | { |
| @@ -268,8 +293,8 @@ static const struct snd_soc_ops acp_card_rt5682s_ops = { · 191 unmodified lines | ||
| 268 | 293 | |
| 269 | 294 | /* Declare RT1019 codec components */ |
| 270 | 295 | SND_SOC_DAILINK_DEF(rt1019, |
| 271 | − DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC1019:01", "rt1019-aif"), | |
| 272 | − COMP_CODEC("i2c-10EC1019:02", "rt1019-aif"))); | |
| 296 | + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC1019:00", "rt1019-aif"), | |
| 297 | + COMP_CODEC("i2c-10EC1019:01", "rt1019-aif"))); | |
| 273 | 298 | |
| 274 | 299 | static const struct snd_soc_dapm_route rt1019_map_lr[] = { |
| 275 | 300 | { "Left Spk", NULL, "Left SPO" }, |
| @@ -278,11 +303,11 @@ static const struct snd_soc_dapm_route rt1019_map_lr[] = { · 2 unmodified lines | ||
| 278 | 303 | |
| 279 | 304 | static struct snd_soc_codec_conf rt1019_conf[] = { |
| 280 | 305 | { |
| 281 | − .dlc = COMP_CODEC_CONF("i2c-10EC1019:01"), | |
| 306 | + .dlc = COMP_CODEC_CONF("i2c-10EC1019:00"), | |
| 282 | 307 | .name_prefix = "Left", |
| 283 | 308 | }, |
| 284 | 309 | { |
| 285 | − .dlc = COMP_CODEC_CONF("i2c-10EC1019:02"), | |
| 310 | + .dlc = COMP_CODEC_CONF("i2c-10EC1019:01"), | |
| 286 | 311 | .name_prefix = "Right", |
| 287 | 312 | }, |
| 288 | 313 | }; |
| @@ -17,6 +17,12 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <linux/input.h> |
| 18 | 18 | #include <linux/module.h> |
| 19 | 19 | #include <sound/soc.h> |
| 20 | +#include <linux/gpio.h> | |
| 21 | +#include <linux/gpio/consumer.h> | |
| 22 | + | |
| 23 | +#define EN_SPKR_GPIO_GB 0x11F | |
| 24 | +#define EN_SPKR_GPIO_NK 0x146 | |
| 25 | +#define EN_SPKR_GPIO_NONE -EINVAL | |
| 20 | 26 | |
| 21 | 27 | enum be_id { |
| 22 | 28 | HEADSET_BE_ID = 0, |
| @@ -49,9 +55,11 @@ struct acp_card_drvdata { · 26 unmodified lines | ||
| 49 | 55 | unsigned int dai_fmt; |
| 50 | 56 | struct clk *wclk; |
| 51 | 57 | struct clk *bclk; |
| 58 | + unsigned int gpio_spkr_en; | |
| 52 | 59 | }; |
| 53 | 60 | |
| 54 | 61 | int acp_sofdsp_dai_links_create(struct snd_soc_card *card); |
| 55 | 62 | int acp_legacy_dai_links_create(struct snd_soc_card *card); |
| 56 | − | |
| 63 | +int event_spkr_handler(struct snd_soc_dapm_widget *w, | |
| 64 | + struct snd_kcontrol *k, int event); | |
| 57 | 65 | #endif |
| @@ -27,6 +27,7 @@ static struct acp_card_drvdata sof_rt5682_rt1019_data = { · 26 unmodified lines | ||
| 27 | 27 | .hs_codec_id = RT5682, |
| 28 | 28 | .amp_codec_id = RT1019, |
| 29 | 29 | .dmic_codec_id = DMIC, |
| 30 | + .gpio_spkr_en = EN_SPKR_GPIO_GB, | |
| 30 | 31 | }; |
| 31 | 32 | |
| 32 | 33 | static struct acp_card_drvdata sof_rt5682_max_data = { |
| @@ -36,6 +37,7 @@ static struct acp_card_drvdata sof_rt5682_max_data = { · 3 unmodified lines | ||
| 36 | 37 | .hs_codec_id = RT5682, |
| 37 | 38 | .amp_codec_id = MAX98360A, |
| 38 | 39 | .dmic_codec_id = DMIC, |
| 40 | + .gpio_spkr_en = EN_SPKR_GPIO_NK, | |
| 39 | 41 | }; |
| 40 | 42 | |
| 41 | 43 | static struct acp_card_drvdata sof_rt5682s_max_data = { |
| @@ -45,6 +47,7 @@ static struct acp_card_drvdata sof_rt5682s_max_data = { · 3 unmodified lines | ||
| 45 | 47 | .hs_codec_id = RT5682S, |
| 46 | 48 | .amp_codec_id = MAX98360A, |
| 47 | 49 | .dmic_codec_id = DMIC, |
| 50 | + .gpio_spkr_en = EN_SPKR_GPIO_NK, | |
| 48 | 51 | }; |
| 49 | 52 | |
| 50 | 53 | static const struct snd_kcontrol_new acp_controls[] = { |
| @@ -58,15 +61,16 @@ static const struct snd_kcontrol_new acp_controls[] = { · 7 unmodified lines | ||
| 58 | 61 | static const struct snd_soc_dapm_widget acp_widgets[] = { |
| 59 | 62 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 60 | 63 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 61 | − SND_SOC_DAPM_SPK("Spk", NULL), | |
| 62 | − SND_SOC_DAPM_SPK("Left Spk", NULL), | |
| 63 | − SND_SOC_DAPM_SPK("Right Spk", NULL), | |
| 64 | + SND_SOC_DAPM_SPK("Spk", event_spkr_handler), | |
| 65 | + SND_SOC_DAPM_SPK("Left Spk", event_spkr_handler), | |
| 66 | + SND_SOC_DAPM_SPK("Right Spk", event_spkr_handler), | |
| 64 | 67 | }; |
| 65 | 68 | |
| 66 | 69 | static int acp_sof_probe(struct platform_device *pdev) |
| 67 | 70 | { |
| 68 | 71 | struct snd_soc_card *card = NULL; |
| 69 | 72 | struct device *dev = &pdev->dev; |
| 73 | + unsigned int spkr_gpio; | |
| 70 | 74 | int ret; |
| 71 | 75 | |
| 72 | 76 | if (!pdev->id_entry) |
| @@ -84,9 +88,20 @@ static int acp_sof_probe(struct platform_device *pdev) · 11 unmodified lines | ||
| 84 | 88 | card->controls = acp_controls; |
| 85 | 89 | card->num_controls = ARRAY_SIZE(acp_controls); |
| 86 | 90 | card->drvdata = (struct acp_card_drvdata *)pdev->id_entry->driver_data; |
| 91 | + spkr_gpio = ((struct acp_card_drvdata *)(card->drvdata))->gpio_spkr_en; | |
| 87 | 92 | |
| 88 | 93 | acp_sofdsp_dai_links_create(card); |
| 89 | 94 | |
| 95 | + if (gpio_is_valid(spkr_gpio)) { | |
| 96 | + ret = devm_gpio_request(dev, spkr_gpio, "spkren"); | |
| 97 | + if (ret) { | |
| 98 | + dev_err(dev, "(%s) gpio request failed: %d\n", | |
| 99 | + __func__, ret); | |
| 100 | + return ret; | |
| 101 | + } | |
| 102 | + gpio_direction_output(spkr_gpio, 0); | |
| 103 | + } | |
| 104 | + | |
| 90 | 105 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 91 | 106 | if (ret) { |
| 92 | 107 | dev_err(&pdev->dev, |
| @@ -51,7 +51,7 @@ static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd) · 50 unmodified lines | ||
| 51 | 51 | /* set rt5682 dai fmt */ |
| 52 | 52 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
| 53 | 53 | | SND_SOC_DAIFMT_NB_NF |
| 54 | − | SND_SOC_DAIFMT_CBM_CFM); | |
| 54 | + | SND_SOC_DAIFMT_CBP_CFP); | |
| 55 | 55 | if (ret < 0) { |
| 56 | 56 | dev_err(rtd->card->dev, |
| 57 | 57 | "Failed to set rt5682 dai fmt: %d\n", ret); |
| @@ -302,7 +302,7 @@ static struct snd_soc_dai_link acp3x_dai[] = { · 244 unmodified lines | ||
| 302 | 302 | .name = "acp3x-5682-play", |
| 303 | 303 | .stream_name = "Playback", |
| 304 | 304 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 305 | − | SND_SOC_DAIFMT_CBM_CFM, | |
| 305 | + | SND_SOC_DAIFMT_CBP_CFP, | |
| 306 | 306 | .init = acp3x_5682_init, |
| 307 | 307 | .dpcm_playback = 1, |
| 308 | 308 | .dpcm_capture = 1, |
| @@ -313,7 +313,7 @@ static struct snd_soc_dai_link acp3x_dai[] = { · 4 unmodified lines | ||
| 313 | 313 | .name = "acp3x-max98357-play", |
| 314 | 314 | .stream_name = "HiFi Playback", |
| 315 | 315 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 316 | − | SND_SOC_DAIFMT_CBS_CFS, | |
| 316 | + | SND_SOC_DAIFMT_CBC_CFC, | |
| 317 | 317 | .dpcm_playback = 1, |
| 318 | 318 | .ops = &acp3x_max_play_ops, |
| 319 | 319 | .cpus = acp3x_bt, |
| @@ -325,7 +325,7 @@ static struct snd_soc_dai_link acp3x_dai[] = { · 5 unmodified lines | ||
| 325 | 325 | .name = "acp3x-ec-dmic0-capture", |
| 326 | 326 | .stream_name = "Capture DMIC0", |
| 327 | 327 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 328 | − | SND_SOC_DAIFMT_CBS_CFS, | |
| 328 | + | SND_SOC_DAIFMT_CBC_CFC, | |
| 329 | 329 | .dpcm_capture = 1, |
| 330 | 330 | .ops = &acp3x_ec_cap0_ops, |
| 331 | 331 | SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform), |
| @@ -0,0 +1,28 @@ | ||
| 1 | +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ | |
| 2 | +/* | |
| 3 | + * This file is provided under a dual BSD/GPLv2 license. When using or | |
| 4 | + * redistributing this file, you may do so under either license. | |
| 5 | + * | |
| 6 | + * Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. | |
| 7 | + * | |
| 8 | + * Author: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> | |
| 9 | + */ | |
| 10 | +#ifndef __AMD_MACH_CONFIG_H | |
| 11 | +#define __AMD_MACH_CONFIG_H | |
| 12 | + | |
| 13 | +#include <sound/soc-acpi.h> | |
| 14 | + | |
| 15 | +#define FLAG_AMD_SOF BIT(1) | |
| 16 | +#define FLAG_AMD_SOF_ONLY_DMIC BIT(2) | |
| 17 | + | |
| 18 | +#define ACP_PCI_DEV_ID 0x15E2 | |
| 19 | + | |
| 20 | +extern struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[]; | |
| 21 | + | |
| 22 | +struct config_entry { | |
| 23 | + u32 flags; | |
| 24 | + u16 device; | |
| 25 | + const struct dmi_system_id *dmi_table; | |
| 26 | +}; | |
| 27 | + | |
| 28 | +#endif | |
| @@ -318,7 +318,7 @@ static int acp6x_pdm_dai_trigger(struct snd_pcm_substream *substream, · 317 unmodified lines | ||
| 318 | 318 | return ret; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | −static struct snd_soc_dai_ops acp6x_pdm_dai_ops = { | |
| 321 | +static const struct snd_soc_dai_ops acp6x_pdm_dai_ops = { | |
| 322 | 322 | .trigger = acp6x_pdm_dai_trigger, |
| 323 | 323 | }; |
| 324 | 324 | |
| @@ -144,9 +144,9 @@ static int snd_proto_probe(struct platform_device *pdev) · 143 unmodified lines | ||
| 144 | 144 | of_node_put(cpu_np); |
| 145 | 145 | |
| 146 | 146 | ret = snd_soc_register_card(&snd_proto); |
| 147 | − if (ret && ret != -EPROBE_DEFER) | |
| 148 | − dev_err(&pdev->dev, | |
| 149 | − "snd_soc_register_card() failed: %d\n", ret); | |
| 147 | + if (ret) | |
| 148 | + dev_err_probe(&pdev->dev, ret, | |
| 149 | + "snd_soc_register_card() failed\n"); | |
| 150 | 150 | |
| 151 | 151 | return ret; |
| 152 | 152 | } |
| @@ -371,35 +371,27 @@ static int tse850_probe(struct platform_device *pdev) · 370 unmodified lines | ||
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | tse850->add = devm_gpiod_get(dev, "axentia,add", GPIOD_OUT_HIGH); |
| 374 | − if (IS_ERR(tse850->add)) { | |
| 375 | − if (PTR_ERR(tse850->add) != -EPROBE_DEFER) | |
| 376 | − dev_err(dev, "failed to get 'add' gpio\n"); | |
| 377 | − return PTR_ERR(tse850->add); | |
| 378 | − } | |
| 374 | + if (IS_ERR(tse850->add)) | |
| 375 | + return dev_err_probe(dev, PTR_ERR(tse850->add), | |
| 376 | + "failed to get 'add' gpio\n"); | |
| 379 | 377 | tse850->add_cache = 1; |
| 380 | 378 | |
| 381 | 379 | tse850->loop1 = devm_gpiod_get(dev, "axentia,loop1", GPIOD_OUT_HIGH); |
| 382 | − if (IS_ERR(tse850->loop1)) { | |
| 383 | − if (PTR_ERR(tse850->loop1) != -EPROBE_DEFER) | |
| 384 | − dev_err(dev, "failed to get 'loop1' gpio\n"); | |
| 385 | − return PTR_ERR(tse850->loop1); | |
| 386 | − } | |
| 380 | + if (IS_ERR(tse850->loop1)) | |
| 381 | + return dev_err_probe(dev, PTR_ERR(tse850->loop1), | |
| 382 | + "failed to get 'loop1' gpio\n"); | |
| 387 | 383 | tse850->loop1_cache = 1; |
| 388 | 384 | |
| 389 | 385 | tse850->loop2 = devm_gpiod_get(dev, "axentia,loop2", GPIOD_OUT_HIGH); |
| 390 | − if (IS_ERR(tse850->loop2)) { | |
| 391 | − if (PTR_ERR(tse850->loop2) != -EPROBE_DEFER) | |
| 392 | − dev_err(dev, "failed to get 'loop2' gpio\n"); | |
| 393 | − return PTR_ERR(tse850->loop2); | |
| 394 | − } | |
| 386 | + if (IS_ERR(tse850->loop2)) | |
| 387 | + return dev_err_probe(dev, PTR_ERR(tse850->loop2), | |
| 388 | + "failed to get 'loop2' gpio\n"); | |
| 395 | 389 | tse850->loop2_cache = 1; |
| 396 | 390 | |
| 397 | 391 | tse850->ana = devm_regulator_get(dev, "axentia,ana"); |
| 398 | − if (IS_ERR(tse850->ana)) { | |
| 399 | − if (PTR_ERR(tse850->ana) != -EPROBE_DEFER) | |
| 400 | − dev_err(dev, "failed to get 'ana' regulator\n"); | |
| 401 | − return PTR_ERR(tse850->ana); | |
| 402 | − } | |
| 392 | + if (IS_ERR(tse850->ana)) | |
| 393 | + return dev_err_probe(dev, PTR_ERR(tse850->ana), | |
| 394 | + "failed to get 'ana' regulator\n"); | |
| 403 | 395 | |
| 404 | 396 | ret = regulator_enable(tse850->ana); |
| 405 | 397 | if (ret < 0) { |
| @@ -74,7 +74,6 @@ · 73 unmodified lines | ||
| 74 | 74 | |
| 75 | 75 | struct bcm_i2s_priv { |
| 76 | 76 | struct device *dev; |
| 77 | − struct resource *r_irq; | |
| 78 | 77 | struct regmap *regmap_i2s; |
| 79 | 78 | struct clk *i2s_clk; |
| 80 | 79 | struct snd_pcm_substream *play_substream; |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | |
| 7 | 7 | #include <linux/dma-mapping.h> |
| 8 | 8 | #include <linux/io.h> |
| 9 | +#include <linux/irq.h> | |
| 9 | 10 | #include <linux/module.h> |
| 10 | 11 | #include <sound/pcm_params.h> |
| 11 | 12 | #include <linux/regmap.h> |
| @@ -387,14 +388,12 @@ int bcm63xx_soc_platform_probe(struct platform_device *pdev, · 375 unmodified lines | ||
| 387 | 388 | { |
| 388 | 389 | int ret; |
| 389 | 390 | |
| 390 | − i2s_priv->r_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | |
| 391 | − if (!i2s_priv->r_irq) { | |
| 392 | − dev_err(&pdev->dev, "Unable to get register irq resource.\n"); | |
| 393 | − return -ENODEV; | |
| 394 | − } | |
| 391 | + ret = platform_get_irq(pdev, 0); | |
| 392 | + if (ret < 0) | |
| 393 | + return ret; | |
| 395 | 394 | |
| 396 | − ret = devm_request_irq(&pdev->dev, i2s_priv->r_irq->start, i2s_dma_isr, | |
| 397 | − i2s_priv->r_irq->flags, "i2s_dma", (void *)i2s_priv); | |
| 395 | + ret = devm_request_irq(&pdev->dev, ret, i2s_dma_isr, | |
| 396 | + irq_get_trigger_type(ret), "i2s_dma", (void *)i2s_priv); | |
| 398 | 397 | if (ret) { |
| 399 | 398 | dev_err(&pdev->dev, |
| 400 | 399 | "i2s_init: failed to request interrupt.ret=%d\n", ret); |
| @@ -41,6 +41,7 @@ config SND_SOC_ALL_CODECS · 40 unmodified lines | ||
| 41 | 41 | imply SND_SOC_ADS117X |
| 42 | 42 | imply SND_SOC_AK4104 |
| 43 | 43 | imply SND_SOC_AK4118 |
| 44 | + imply SND_SOC_AK4375 | |
| 44 | 45 | imply SND_SOC_AK4458 |
| 45 | 46 | imply SND_SOC_AK4535 |
| 46 | 47 | imply SND_SOC_AK4554 |
| @@ -220,6 +221,7 @@ config SND_SOC_ALL_CODECS · 173 unmodified lines | ||
| 220 | 221 | imply SND_SOC_TDA7419 |
| 221 | 222 | imply SND_SOC_TFA9879 |
| 222 | 223 | imply SND_SOC_TFA989X |
| 224 | + imply SND_SOC_TLV320ADC3XXX | |
| 223 | 225 | imply SND_SOC_TLV320ADCX140 |
| 224 | 226 | imply SND_SOC_TLV320AIC23_I2C |
| 225 | 227 | imply SND_SOC_TLV320AIC23_SPI |
| @@ -241,8 +243,7 @@ config SND_SOC_ALL_CODECS · 15 unmodified lines | ||
| 241 | 243 | imply SND_SOC_UDA1380 |
| 242 | 244 | imply SND_SOC_WCD9335 |
| 243 | 245 | imply SND_SOC_WCD934X |
| 244 | − imply SND_SOC_WCD937X | |
| 245 | − imply SND_SOC_WCD938X | |
| 246 | + imply SND_SOC_WCD938X_SDW | |
| 246 | 247 | imply SND_SOC_LPASS_RX_MACRO |
| 247 | 248 | imply SND_SOC_LPASS_TX_MACRO |
| 248 | 249 | imply SND_SOC_WL1273 |
| @@ -343,11 +344,15 @@ config SND_SOC_WM_ADSP · 94 unmodified lines | ||
| 343 | 344 | default y if SND_SOC_WM5102=y |
| 344 | 345 | default y if SND_SOC_WM5110=y |
| 345 | 346 | default y if SND_SOC_WM2200=y |
| 347 | + default y if SND_SOC_CS35L41_SPI=y | |
| 348 | + default y if SND_SOC_CS35L41_I2C=y | |
| 346 | 349 | default m if SND_SOC_MADERA=m |
| 347 | 350 | default m if SND_SOC_CS47L24=m |
| 348 | 351 | default m if SND_SOC_WM5102=m |
| 349 | 352 | default m if SND_SOC_WM5110=m |
| 350 | 353 | default m if SND_SOC_WM2200=m |
| 354 | + default m if SND_SOC_CS35L41_SPI=m | |
| 355 | + default m if SND_SOC_CS35L41_I2C=m | |
| 351 | 356 | |
| 352 | 357 | config SND_SOC_AB8500_CODEC |
| 353 | 358 | tristate |
| @@ -519,6 +524,16 @@ config SND_SOC_AK4118 · 165 unmodified lines | ||
| 519 | 524 | depends on I2C |
| 520 | 525 | select REGMAP_I2C |
| 521 | 526 | |
| 527 | +config SND_SOC_AK4375 | |
| 528 | + tristate "AKM AK4375 CODEC" | |
| 529 | + depends on I2C | |
| 530 | + select REGMAP_I2C | |
| 531 | + help | |
| 532 | + Enable support for the Asahi-Kasei AK4375 codec. | |
| 533 | + | |
| 534 | + To compile this driver as a module, choose M here: the module | |
| 535 | + will be called snd-soc-ak4375. | |
| 536 | + | |
| 522 | 537 | config SND_SOC_AK4458 |
| 523 | 538 | tristate "AKM AK4458 CODEC" |
| 524 | 539 | depends on I2C |
| @@ -609,14 +624,24 @@ config SND_SOC_CS35L36 · 84 unmodified lines | ||
| 609 | 624 | tristate "Cirrus Logic CS35L36 CODEC" |
| 610 | 625 | depends on I2C |
| 611 | 626 | |
| 627 | +config SND_SOC_CS35L41_LIB | |
| 628 | + tristate | |
| 629 | + | |
| 630 | +config SND_SOC_CS35L41 | |
| 631 | + tristate | |
| 632 | + | |
| 612 | 633 | config SND_SOC_CS35L41_SPI |
| 613 | 634 | tristate "Cirrus Logic CS35L41 CODEC (SPI)" |
| 614 | 635 | depends on SPI_MASTER |
| 636 | + select SND_SOC_CS35L41_LIB | |
| 637 | + select SND_SOC_CS35L41 | |
| 615 | 638 | select REGMAP_SPI |
| 616 | 639 | |
| 617 | 640 | config SND_SOC_CS35L41_I2C |
| 618 | 641 | tristate "Cirrus Logic CS35L41 CODEC (I2C)" |
| 619 | 642 | depends on I2C |
| 643 | + select SND_SOC_CS35L41_LIB | |
| 644 | + select SND_SOC_CS35L41 | |
| 620 | 645 | select REGMAP_I2C |
| 621 | 646 | |
| 622 | 647 | config SND_SOC_CS42L42 |
| @@ -1486,6 +1511,13 @@ config SND_SOC_TFA989X · 863 unmodified lines | ||
| 1486 | 1511 | Note that the driver currently bypasses the built-in "CoolFlux DSP" |
| 1487 | 1512 | and does not support (hardware) volume control. |
| 1488 | 1513 | |
| 1514 | +config SND_SOC_TLV320ADC3XXX | |
| 1515 | + tristate "Texas Instruments TLV320ADC3001/3101 audio ADC" | |
| 1516 | + depends on I2C | |
| 1517 | + help | |
| 1518 | + Enable support for Texas Instruments TLV320ADC3001 and TLV320ADC3101 | |
| 1519 | + ADCs. | |
| 1520 | + | |
| 1489 | 1521 | config SND_SOC_TLV320AIC23 |
| 1490 | 1522 | tristate |
| 1491 | 1523 | |
| @@ -34,6 +34,7 @@ snd-soc-adav803-objs := adav803.o · 33 unmodified lines | ||
| 34 | 34 | snd-soc-ads117x-objs := ads117x.o |
| 35 | 35 | snd-soc-ak4104-objs := ak4104.o |
| 36 | 36 | snd-soc-ak4118-objs := ak4118.o |
| 37 | +snd-soc-ak4375-objs := ak4375.o | |
| 37 | 38 | snd-soc-ak4458-objs := ak4458.o |
| 38 | 39 | snd-soc-ak4535-objs := ak4535.o |
| 39 | 40 | snd-soc-ak4554-objs := ak4554.o |
| @@ -54,8 +55,10 @@ snd-soc-cs35l33-objs := cs35l33.o · 14 unmodified lines | ||
| 54 | 55 | snd-soc-cs35l34-objs := cs35l34.o |
| 55 | 56 | snd-soc-cs35l35-objs := cs35l35.o |
| 56 | 57 | snd-soc-cs35l36-objs := cs35l36.o |
| 57 | −snd-soc-cs35l41-spi-objs := cs35l41-spi.o cs35l41.o cs35l41-tables.o | |
| 58 | −snd-soc-cs35l41-i2c-objs := cs35l41-i2c.o cs35l41.o cs35l41-tables.o | |
| 58 | +snd-soc-cs35l41-lib-objs := cs35l41-lib.o | |
| 59 | +snd-soc-cs35l41-objs := cs35l41.o | |
| 60 | +snd-soc-cs35l41-spi-objs := cs35l41-spi.o | |
| 61 | +snd-soc-cs35l41-i2c-objs := cs35l41-i2c.o | |
| 59 | 62 | snd-soc-cs42l42-objs := cs42l42.o |
| 60 | 63 | snd-soc-cs42l51-objs := cs42l51.o |
| 61 | 64 | snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o |
| @@ -238,6 +241,7 @@ snd-soc-tda7419-objs := tda7419.o · 176 unmodified lines | ||
| 238 | 241 | snd-soc-tas2770-objs := tas2770.o |
| 239 | 242 | snd-soc-tfa9879-objs := tfa9879.o |
| 240 | 243 | snd-soc-tfa989x-objs := tfa989x.o |
| 244 | +snd-soc-tlv320adc3xxx-objs := tlv320adc3xxx.o | |
| 241 | 245 | snd-soc-tlv320aic23-objs := tlv320aic23.o |
| 242 | 246 | snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o |
| 243 | 247 | snd-soc-tlv320aic23-spi-objs := tlv320aic23-spi.o |
| @@ -369,6 +373,7 @@ obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o · 125 unmodified lines | ||
| 369 | 373 | obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o |
| 370 | 374 | obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o |
| 371 | 375 | obj-$(CONFIG_SND_SOC_AK4118) += snd-soc-ak4118.o |
| 376 | +obj-$(CONFIG_SND_SOC_AK4375) += snd-soc-ak4375.o | |
| 372 | 377 | obj-$(CONFIG_SND_SOC_AK4458) += snd-soc-ak4458.o |
| 373 | 378 | obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o |
| 374 | 379 | obj-$(CONFIG_SND_SOC_AK4554) += snd-soc-ak4554.o |
| @@ -391,6 +396,8 @@ obj-$(CONFIG_SND_SOC_CS35L33) += snd-soc-cs35l33.o · 16 unmodified lines | ||
| 391 | 396 | obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o |
| 392 | 397 | obj-$(CONFIG_SND_SOC_CS35L35) += snd-soc-cs35l35.o |
| 393 | 398 | obj-$(CONFIG_SND_SOC_CS35L36) += snd-soc-cs35l36.o |
| 399 | +obj-$(CONFIG_SND_SOC_CS35L41) += snd-soc-cs35l41.o | |
| 400 | +obj-$(CONFIG_SND_SOC_CS35L41_LIB) += snd-soc-cs35l41-lib.o | |
| 394 | 401 | obj-$(CONFIG_SND_SOC_CS35L41_SPI) += snd-soc-cs35l41-spi.o |
| 395 | 402 | obj-$(CONFIG_SND_SOC_CS35L41_I2C) += snd-soc-cs35l41-i2c.o |
| 396 | 403 | obj-$(CONFIG_SND_SOC_CS42L42) += snd-soc-cs42l42.o |
| @@ -572,6 +579,7 @@ obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o · 175 unmodified lines | ||
| 572 | 579 | obj-$(CONFIG_SND_SOC_TAS2770) += snd-soc-tas2770.o |
| 573 | 580 | obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o |
| 574 | 581 | obj-$(CONFIG_SND_SOC_TFA989X) += snd-soc-tfa989x.o |
| 582 | +obj-$(CONFIG_SND_SOC_TLV320ADC3XXX) += snd-soc-tlv320adc3xxx.o | |
| 575 | 583 | obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o |
| 576 | 584 | obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o |
| 577 | 585 | obj-$(CONFIG_SND_SOC_TLV320AIC23_SPI) += snd-soc-tlv320aic23-spi.o |
| @@ -13,8 +13,8 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <linux/delay.h> |
| 14 | 14 | #include <linux/slab.h> |
| 15 | 15 | #include <linux/of.h> |
| 16 | −#include <linux/of_gpio.h> | |
| 17 | 16 | #include <linux/of_device.h> |
| 17 | +#include <linux/gpio/consumer.h> | |
| 18 | 18 | #include <linux/regulator/consumer.h> |
| 19 | 19 | #include <linux/regmap.h> |
| 20 | 20 | #include <sound/core.h> |
| @@ -106,8 +106,8 @@ static const char * const supply_names[] = { · 85 unmodified lines | ||
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | 108 | struct adau1701 { |
| 109 | − int gpio_nreset; | |
| 110 | − int gpio_pll_mode[2]; | |
| 109 | + struct gpio_desc *gpio_nreset; | |
| 110 | + struct gpio_descs *gpio_pll_mode; | |
| 111 | 111 | unsigned int dai_fmt; |
| 112 | 112 | unsigned int pll_clkdiv; |
| 113 | 113 | unsigned int sysclk; |
| @@ -303,39 +303,41 @@ static int adau1701_reset(struct snd_soc_component *component, unsigned int clkd · 189 unmodified lines | ||
| 303 | 303 | struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); |
| 304 | 304 | int ret; |
| 305 | 305 | |
| 306 | + DECLARE_BITMAP(values, 2); | |
| 306 | 307 | sigmadsp_reset(adau1701->sigmadsp); |
| 307 | 308 | |
| 308 | − if (clkdiv != ADAU1707_CLKDIV_UNSET && | |
| 309 | − gpio_is_valid(adau1701->gpio_pll_mode[0]) && | |
| 310 | − gpio_is_valid(adau1701->gpio_pll_mode[1])) { | |
| 309 | + if (clkdiv != ADAU1707_CLKDIV_UNSET && adau1701->gpio_pll_mode) { | |
| 311 | 310 | switch (clkdiv) { |
| 312 | 311 | case 64: |
| 313 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 0); | |
| 314 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 0); | |
| 312 | + __assign_bit(0, values, 0); | |
| 313 | + __assign_bit(1, values, 0); | |
| 315 | 314 | break; |
| 316 | 315 | case 256: |
| 317 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 0); | |
| 318 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 1); | |
| 316 | + __assign_bit(0, values, 0); | |
| 317 | + __assign_bit(1, values, 1); | |
| 319 | 318 | break; |
| 320 | 319 | case 384: |
| 321 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 1); | |
| 322 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 0); | |
| 320 | + __assign_bit(0, values, 1); | |
| 321 | + __assign_bit(1, values, 0); | |
| 323 | 322 | break; |
| 324 | − case 0: /* fallback */ | |
| 323 | + case 0: /* fallback */ | |
| 325 | 324 | case 512: |
| 326 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 1); | |
| 327 | − gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 1); | |
| 325 | + __assign_bit(0, values, 1); | |
| 326 | + __assign_bit(1, values, 1); | |
| 328 | 327 | break; |
| 329 | 328 | } |
| 329 | + gpiod_set_array_value_cansleep(adau1701->gpio_pll_mode->ndescs, | |
| 330 | + adau1701->gpio_pll_mode->desc, adau1701->gpio_pll_mode->info, | |
| 331 | + values); | |
| 330 | 332 | } |
| 331 | 333 | |
| 332 | 334 | adau1701->pll_clkdiv = clkdiv; |
| 333 | 335 | |
| 334 | − if (gpio_is_valid(adau1701->gpio_nreset)) { | |
| 335 | − gpio_set_value_cansleep(adau1701->gpio_nreset, 0); | |
| 336 | + if (adau1701->gpio_nreset) { | |
| 337 | + gpiod_set_value_cansleep(adau1701->gpio_nreset, 0); | |
| 336 | 338 | /* minimum reset time is 20ns */ |
| 337 | 339 | udelay(1); |
| 338 | − gpio_set_value_cansleep(adau1701->gpio_nreset, 1); | |
| 340 | + gpiod_set_value_cansleep(adau1701->gpio_nreset, 1); | |
| 339 | 341 | /* power-up time may be as long as 85ms */ |
| 340 | 342 | mdelay(85); |
| 341 | 343 | } |
| @@ -719,8 +721,8 @@ static void adau1701_remove(struct snd_soc_component *component) · 377 unmodified lines | ||
| 719 | 721 | { |
| 720 | 722 | struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); |
| 721 | 723 | |
| 722 | − if (gpio_is_valid(adau1701->gpio_nreset)) | |
| 723 | − gpio_set_value_cansleep(adau1701->gpio_nreset, 0); | |
| 724 | + if (adau1701->gpio_nreset) | |
| 725 | + gpiod_set_value_cansleep(adau1701->gpio_nreset, 0); | |
| 724 | 726 | |
| 725 | 727 | regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); |
| 726 | 728 | } |
| @@ -788,8 +790,6 @@ static int adau1701_i2c_probe(struct i2c_client *client, · 61 unmodified lines | ||
| 788 | 790 | { |
| 789 | 791 | struct adau1701 *adau1701; |
| 790 | 792 | struct device *dev = &client->dev; |
| 791 | − int gpio_nreset = -EINVAL; | |
| 792 | − int gpio_pll_mode[2] = { -EINVAL, -EINVAL }; | |
| 793 | 793 | int ret, i; |
| 794 | 794 | |
| 795 | 795 | adau1701 = devm_kzalloc(dev, sizeof(*adau1701), GFP_KERNEL); |
| @@ -823,26 +823,6 @@ static int adau1701_i2c_probe(struct i2c_client *client, · 27 unmodified lines | ||
| 823 | 823 | |
| 824 | 824 | |
| 825 | 825 | if (dev->of_node) { |
| 826 | − gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0); | |
| 827 | − if (gpio_nreset < 0 && gpio_nreset != -ENOENT) { | |
| 828 | − ret = gpio_nreset; | |
| 829 | − goto exit_regulators_disable; | |
| 830 | − } | |
| 831 | − | |
| 832 | − gpio_pll_mode[0] = of_get_named_gpio(dev->of_node, | |
| 833 | − "adi,pll-mode-gpios", 0); | |
| 834 | − if (gpio_pll_mode[0] < 0 && gpio_pll_mode[0] != -ENOENT) { | |
| 835 | − ret = gpio_pll_mode[0]; | |
| 836 | − goto exit_regulators_disable; | |
| 837 | − } | |
| 838 | − | |
| 839 | − gpio_pll_mode[1] = of_get_named_gpio(dev->of_node, | |
| 840 | − "adi,pll-mode-gpios", 1); | |
| 841 | − if (gpio_pll_mode[1] < 0 && gpio_pll_mode[1] != -ENOENT) { | |
| 842 | − ret = gpio_pll_mode[1]; | |
| 843 | − goto exit_regulators_disable; | |
| 844 | − } | |
| 845 | − | |
| 846 | 826 | of_property_read_u32(dev->of_node, "adi,pll-clkdiv", |
| 847 | 827 | &adau1701->pll_clkdiv); |
| 848 | 828 | |
| @@ -851,32 +831,20 @@ static int adau1701_i2c_probe(struct i2c_client *client, · 2 unmodified lines | ||
| 851 | 831 | ARRAY_SIZE(adau1701->pin_config)); |
| 852 | 832 | } |
| 853 | 833 | |
| 854 | − if (gpio_is_valid(gpio_nreset)) { | |
| 855 | − ret = devm_gpio_request_one(dev, gpio_nreset, GPIOF_OUT_INIT_LOW, | |
| 856 | − "ADAU1701 Reset"); | |
| 857 | − if (ret < 0) | |
| 858 | − goto exit_regulators_disable; | |
| 834 | + adau1701->gpio_nreset = devm_gpiod_get_optional(dev, "reset", GPIOD_IN); | |
| 835 | + | |
| 836 | + if (IS_ERR(adau1701->gpio_nreset)) { | |
| 837 | + ret = PTR_ERR(adau1701->gpio_nreset); | |
| 838 | + goto exit_regulators_disable; | |
| 859 | 839 | } |
| 860 | 840 | |
| 861 | − if (gpio_is_valid(gpio_pll_mode[0]) && | |
| 862 | − gpio_is_valid(gpio_pll_mode[1])) { | |
| 863 | − ret = devm_gpio_request_one(dev, gpio_pll_mode[0], | |
| 864 | − GPIOF_OUT_INIT_LOW, | |
| 865 | − "ADAU1701 PLL mode 0"); | |
| 866 | − if (ret < 0) | |
| 867 | − goto exit_regulators_disable; | |
| 841 | + adau1701->gpio_pll_mode = devm_gpiod_get_array_optional(dev, "adi,pll-mode", GPIOD_OUT_LOW); | |
| 868 | 842 | |
| 869 | − ret = devm_gpio_request_one(dev, gpio_pll_mode[1], | |
| 870 | − GPIOF_OUT_INIT_LOW, | |
| 871 | − "ADAU1701 PLL mode 1"); | |
| 872 | − if (ret < 0) | |
| 873 | − goto exit_regulators_disable; | |
| 843 | + if (IS_ERR(adau1701->gpio_pll_mode)) { | |
| 844 | + ret = PTR_ERR(adau1701->gpio_pll_mode); | |
| 845 | + goto exit_regulators_disable; | |
| 874 | 846 | } |
| 875 | 847 | |
| 876 | − adau1701->gpio_nreset = gpio_nreset; | |
| 877 | − adau1701->gpio_pll_mode[0] = gpio_pll_mode[0]; | |
| 878 | − adau1701->gpio_pll_mode[1] = gpio_pll_mode[1]; | |
| 879 | − | |
| 880 | 848 | i2c_set_clientdata(client, adau1701); |
| 881 | 849 | |
| 882 | 850 | adau1701->sigmadsp = devm_sigmadsp_init_i2c(client, |
| @@ -374,20 +374,14 @@ static int ak4118_i2c_probe(struct i2c_client *i2c, · 373 unmodified lines | ||
| 374 | 374 | i2c_set_clientdata(i2c, ak4118); |
| 375 | 375 | |
| 376 | 376 | ak4118->reset = devm_gpiod_get(&i2c->dev, "reset", GPIOD_OUT_HIGH); |
| 377 | − if (IS_ERR(ak4118->reset)) { | |
| 378 | − ret = PTR_ERR(ak4118->reset); | |
| 379 | − if (ret != -EPROBE_DEFER) | |
| 380 | − dev_err(&i2c->dev, "Failed to get reset: %d\n", ret); | |
| 381 | − return ret; | |
| 382 | − } | |
| 377 | + if (IS_ERR(ak4118->reset)) | |
| 378 | + return dev_err_probe(&i2c->dev, PTR_ERR(ak4118->reset), | |
| 379 | + "Failed to get reset\n"); | |
| 383 | 380 | |
| 384 | 381 | ak4118->irq = devm_gpiod_get(&i2c->dev, "irq", GPIOD_IN); |
| 385 | − if (IS_ERR(ak4118->irq)) { | |
| 386 | − ret = PTR_ERR(ak4118->irq); | |
| 387 | − if (ret != -EPROBE_DEFER) | |
| 388 | − dev_err(&i2c->dev, "Failed to get IRQ: %d\n", ret); | |
| 389 | − return ret; | |
| 390 | − } | |
| 382 | + if (IS_ERR(ak4118->irq)) | |
| 383 | + return dev_err_probe(&i2c->dev, PTR_ERR(ak4118->irq), | |
| 384 | + "Failed to get IRQ\n"); | |
| 391 | 385 | |
| 392 | 386 | ret = devm_request_threaded_irq(&i2c->dev, gpiod_to_irq(ak4118->irq), |
| 393 | 387 | NULL, ak4118_irq_handler, |
| @@ -0,0 +1,610 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later | |
| 2 | + | |
| 3 | +/* | |
| 4 | + * Based on code by Hu Jin | |
| 5 | + * Copyright (C) 2014 Asahi Kasei Microdevices Corporation | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <linux/delay.h> | |
| 9 | +#include <linux/gpio/consumer.h> | |
| 10 | +#include <linux/i2c.h> | |
| 11 | +#include <linux/module.h> | |
| 12 | +#include <linux/of_device.h> | |
| 13 | +#include <linux/pm_runtime.h> | |
| 14 | +#include <linux/regulator/consumer.h> | |
| 15 | +#include <sound/soc.h> | |
| 16 | +#include <sound/tlv.h> | |
| 17 | + | |
| 18 | +/* Registers and fields */ | |
| 19 | +#define AK4375_00_POWER_MANAGEMENT1 0x00 | |
| 20 | +#define PMPLL BIT(0) /* 0: PLL off, 1: PLL on */ | |
| 21 | +#define AK4375_01_POWER_MANAGEMENT2 0x01 | |
| 22 | +#define PMCP1 BIT(0) /* Charge Pump 1: LDO1 and DAC */ | |
| 23 | +#define PMCP2 BIT(1) /* Charge Pump 2: Class-G HP Amp */ | |
| 24 | +#define PMLDO1P BIT(4) | |
| 25 | +#define PMLDO1N BIT(5) | |
| 26 | +#define PMLDO (PMLDO1P | PMLDO1N) | |
| 27 | +#define AK4375_02_POWER_MANAGEMENT3 0x02 | |
| 28 | +#define AK4375_03_POWER_MANAGEMENT4 0x03 | |
| 29 | +#define AK4375_04_OUTPUT_MODE_SETTING 0x04 | |
| 30 | +#define AK4375_05_CLOCK_MODE_SELECT 0x05 | |
| 31 | +#define FS_MASK GENMASK(4, 0) | |
| 32 | +#define FS_8KHZ 0x00 | |
| 33 | +#define FS_11_025KHZ 0x01 | |
| 34 | +#define FS_16KHZ 0x04 | |
| 35 | +#define FS_22_05KHZ 0x05 | |
| 36 | +#define FS_32KHZ 0x08 | |
| 37 | +#define FS_44_1KHZ 0x09 | |
| 38 | +#define FS_48KHZ 0x0a | |
| 39 | +#define FS_88_2KHZ 0x0d | |
| 40 | +#define FS_96KHZ 0x0e | |
| 41 | +#define FS_176_4KHZ 0x11 | |
| 42 | +#define FS_192KHZ 0x12 | |
| 43 | +#define CM_MASK GENMASK(6, 5) /* For SRC Bypass mode */ | |
| 44 | +#define CM_0 (0x0 << 5) | |
| 45 | +#define CM_1 (0x1 << 5) | |
| 46 | +#define CM_2 (0x2 << 5) | |
| 47 | +#define CM_3 (0x3 << 5) | |
| 48 | +#define AK4375_06_DIGITAL_FILTER_SELECT 0x06 | |
| 49 | +#define DADFSEL BIT(5) /* 0: in SRC Bypass mode, 1: in SRC mode */ | |
| 50 | +#define DASL BIT(6) | |
| 51 | +#define DASD BIT(7) | |
| 52 | +#define AK4375_07_DAC_MONO_MIXING 0x07 | |
| 53 | +#define DACMUTE_MASK (GENMASK(5, 4) | GENMASK(1, 0)) /* Clear to mute */ | |
| 54 | +#define AK4375_08_JITTER_CLEANER_SETTING1 0x08 | |
| 55 | +#define AK4375_09_JITTER_CLEANER_SETTING2 0x09 | |
| 56 | +#define AK4375_0A_JITTER_CLEANER_SETTING3 0x0a | |
| 57 | +#define SELDAIN BIT(1) /* 0: SRC Bypass mode, 1: SRC mode */ | |
| 58 | +#define XCKSEL BIT(6) /* 0: PLL0, 1: MCKI */ | |
| 59 | +#define XCKCPSEL BIT(7) /* Should be equal to SELDAIN and XCKSEL */ | |
| 60 | +#define AK4375_0B_LCH_OUTPUT_VOLUME 0x0b | |
| 61 | +#define AK4375_0C_RCH_OUTPUT_VOLUME 0x0c | |
| 62 | +#define AK4375_0D_HP_VOLUME_CONTROL 0x0d | |
| 63 | +#define AK4375_0E_PLL_CLK_SOURCE_SELECT 0x0e | |
| 64 | +#define PLS BIT(0) /* 0: MCKI, 1: BCLK */ | |
| 65 | +#define AK4375_0F_PLL_REF_CLK_DIVIDER1 0x0f /* Reference clock divider [15:8] bits */ | |
| 66 | +#define AK4375_10_PLL_REF_CLK_DIVIDER2 0x10 /* Reference clock divider [7:0] bis */ | |
| 67 | +#define AK4375_11_PLL_FB_CLK_DIVIDER1 0x11 /* Feedback clock divider [15:8] bits */ | |
| 68 | +#define AK4375_12_PLL_FB_CLK_DIVIDER2 0x12 /* Feedback clock divider [7:0] bits */ | |
| 69 | +#define AK4375_13_SRC_CLK_SOURCE 0x13 /* SRC Bypass: SRCCKS=XCKSEL=SELDAIN=0 */ | |
| 70 | +#define SRCCKS BIT(0) /* SRC Clock source 0: MCKI, 1: PLL0 */ | |
| 71 | +#define DIV BIT(4) | |
| 72 | +#define AK4375_14_DAC_CLK_DIVIDER 0x14 | |
| 73 | +#define AK4375_15_AUDIO_IF_FORMAT 0x15 | |
| 74 | +#define DEVICEID_MASK GENMASK(7, 5) | |
| 75 | +#define AK4375_24_MODE_CONTROL 0x24 | |
| 76 | + | |
| 77 | +#define AK4375_PLL_FREQ_OUT_112896000 112896000 /* 44.1 kHz base rate */ | |
| 78 | +#define AK4375_PLL_FREQ_OUT_122880000 122880000 /* 32 and 48 kHz base rates */ | |
| 79 | + | |
| 80 | +#define DEVICEID_AK4375 0x00 | |
| 81 | +#define DEVICEID_AK4375A 0x01 | |
| 82 | +#define DEVICEID_AK4376A 0x02 | |
| 83 | +#define DEVICEID_AK4377 0x03 | |
| 84 | +#define DEVICEID_AK4331 0x07 | |
| 85 | + | |
| 86 | +static const char * const supply_names[] = { | |
| 87 | + "avdd", "tvdd" | |
| 88 | +}; | |
| 89 | + | |
| 90 | +struct ak4375_drvdata { | |
| 91 | + struct snd_soc_dai_driver *dai_drv; | |
| 92 | + const struct snd_soc_component_driver *comp_drv; | |
| 93 | +}; | |
| 94 | + | |
| 95 | +struct ak4375_priv { | |
| 96 | + struct device *dev; | |
| 97 | + struct regmap *regmap; | |
| 98 | + struct gpio_desc *pdn_gpiod; | |
| 99 | + struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; | |
| 100 | + unsigned int rate; | |
| 101 | + unsigned int pld; | |
| 102 | + u8 mute_save; | |
| 103 | +}; | |
| 104 | + | |
| 105 | +static const struct reg_default ak4375_reg_defaults[] = { | |
| 106 | + { 0x00, 0x00 }, { 0x01, 0x00 }, { 0x02, 0x00 }, | |
| 107 | + { 0x03, 0x00 }, { 0x04, 0x00 }, { 0x05, 0x00 }, | |
| 108 | + { 0x06, 0x00 }, { 0x07, 0x00 }, { 0x08, 0x00 }, | |
| 109 | + { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x19 }, | |
| 110 | + { 0x0c, 0x19 }, { 0x0d, 0x75 }, { 0x0e, 0x01 }, | |
| 111 | + { 0x0f, 0x00 }, { 0x10, 0x00 }, { 0x11, 0x00 }, | |
| 112 | + { 0x12, 0x00 }, { 0x13, 0x00 }, { 0x14, 0x00 }, | |
| 113 | + { 0x15, 0x00 }, { 0x24, 0x00 }, | |
| 114 | +}; | |
| 115 | + | |
| 116 | +/* | |
| 117 | + * Output Digital volume control: | |
| 118 | + * from -12.5 to 3 dB in 0.5 dB steps (mute instead of -12.5 dB) | |
| 119 | + */ | |
| 120 | +static DECLARE_TLV_DB_SCALE(dac_tlv, -1250, 50, 0); | |
| 121 | + | |
| 122 | +/* | |
| 123 | + * HP-Amp Analog volume control: | |
| 124 | + * from -4.2 to 6 dB in 2 dB steps (mute instead of -4.2 dB) | |
| 125 | + */ | |
| 126 | +static DECLARE_TLV_DB_SCALE(hpg_tlv, -4200, 20, 0); | |
| 127 | + | |
| 128 | +static const char * const ak4375_ovolcn_select_texts[] = { "Dependent", "Independent" }; | |
| 129 | +static const char * const ak4375_mdac_select_texts[] = { "x1", "x1/2" }; | |
| 130 | +static const char * const ak4375_cpmode_select_texts[] = { | |
| 131 | + "Automatic Switching", | |
| 132 | + "+-VDD Operation", | |
| 133 | + "+-1/2VDD Operation" | |
| 134 | +}; | |
| 135 | + | |
| 136 | +/* | |
| 137 | + * DASD, DASL bits Digital Filter Setting | |
| 138 | + * 0, 0 : Sharp Roll-Off Filter | |
| 139 | + * 0, 1 : Slow Roll-Off Filter | |
| 140 | + * 1, 0 : Short delay Sharp Roll-Off Filter | |
| 141 | + * 1, 1 : Short delay Slow Roll-Off Filter | |
| 142 | + */ | |
| 143 | +static const char * const ak4375_digfil_select_texts[] = { | |
| 144 | + "Sharp Roll-Off Filter", | |
| 145 | + "Slow Roll-Off Filter", | |
| 146 | + "Short delay Sharp Roll-Off Filter", | |
| 147 | + "Short delay Slow Roll-Off Filter", | |
| 148 | +}; | |
| 149 | + | |
| 150 | +static const struct soc_enum ak4375_ovolcn_enum = | |
| 151 | + SOC_ENUM_SINGLE(AK4375_0B_LCH_OUTPUT_VOLUME, 7, | |
| 152 | + ARRAY_SIZE(ak4375_ovolcn_select_texts), ak4375_ovolcn_select_texts); | |
| 153 | +static const struct soc_enum ak4375_mdacl_enum = | |
| 154 | + SOC_ENUM_SINGLE(AK4375_07_DAC_MONO_MIXING, 2, | |
| 155 | + ARRAY_SIZE(ak4375_mdac_select_texts), ak4375_mdac_select_texts); | |
| 156 | +static const struct soc_enum ak4375_mdacr_enum = | |
| 157 | + SOC_ENUM_SINGLE(AK4375_07_DAC_MONO_MIXING, 6, | |
| 158 | + ARRAY_SIZE(ak4375_mdac_select_texts), ak4375_mdac_select_texts); | |
| 159 | +static const struct soc_enum ak4375_cpmode_enum = | |
| 160 | + SOC_ENUM_SINGLE(AK4375_03_POWER_MANAGEMENT4, 2, | |
| 161 | + ARRAY_SIZE(ak4375_cpmode_select_texts), ak4375_cpmode_select_texts); | |
| 162 | +static const struct soc_enum ak4375_digfil_enum = | |
| 163 | + SOC_ENUM_SINGLE(AK4375_06_DIGITAL_FILTER_SELECT, 6, | |
| 164 | + ARRAY_SIZE(ak4375_digfil_select_texts), ak4375_digfil_select_texts); | |
| 165 | + | |
| 166 | +static const struct snd_kcontrol_new ak4375_snd_controls[] = { | |
| 167 | + SOC_DOUBLE_R_TLV("Digital Output Volume", AK4375_0B_LCH_OUTPUT_VOLUME, | |
| 168 | + AK4375_0C_RCH_OUTPUT_VOLUME, 0, 0x1f, 0, dac_tlv), | |
| 169 | + SOC_SINGLE_TLV("HP-Amp Analog Volume", | |
| 170 | + AK4375_0D_HP_VOLUME_CONTROL, 0, 0x1f, 0, hpg_tlv), | |
| 171 | + | |
| 172 | + SOC_DOUBLE("DAC Signal Invert Switch", AK4375_07_DAC_MONO_MIXING, 3, 7, 1, 0), | |
| 173 | + | |
| 174 | + SOC_ENUM("Digital Volume Control", ak4375_ovolcn_enum), | |
| 175 | + SOC_ENUM("DACL Signal Level", ak4375_mdacl_enum), | |
| 176 | + SOC_ENUM("DACR Signal Level", ak4375_mdacr_enum), | |
| 177 | + SOC_ENUM("Charge Pump Mode", ak4375_cpmode_enum), | |
| 178 | + SOC_ENUM("DAC Digital Filter Mode", ak4375_digfil_enum), | |
| 179 | +}; | |
| 180 | + | |
| 181 | +static const struct snd_kcontrol_new ak4375_hpl_mixer_controls[] = { | |
| 182 | + SOC_DAPM_SINGLE("LDACL Switch", AK4375_07_DAC_MONO_MIXING, 0, 1, 0), | |
| 183 | + SOC_DAPM_SINGLE("RDACL Switch", AK4375_07_DAC_MONO_MIXING, 1, 1, 0), | |
| 184 | +}; | |
| 185 | + | |
| 186 | +static const struct snd_kcontrol_new ak4375_hpr_mixer_controls[] = { | |
| 187 | + SOC_DAPM_SINGLE("LDACR Switch", AK4375_07_DAC_MONO_MIXING, 4, 1, 0), | |
| 188 | + SOC_DAPM_SINGLE("RDACR Switch", AK4375_07_DAC_MONO_MIXING, 5, 1, 0), | |
| 189 | +}; | |
| 190 | + | |
| 191 | +static int ak4375_dac_event(struct snd_soc_dapm_widget *w, | |
| 192 | + struct snd_kcontrol *kcontrol, int event) | |
| 193 | +{ | |
| 194 | + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); | |
| 195 | + | |
| 196 | + switch (event) { | |
| 197 | + case SND_SOC_DAPM_PRE_PMU: | |
| 198 | + snd_soc_component_update_bits(component, AK4375_00_POWER_MANAGEMENT1, PMPLL, PMPLL); | |
| 199 | + snd_soc_component_update_bits(component, AK4375_01_POWER_MANAGEMENT2, PMCP1, PMCP1); | |
| 200 | + usleep_range(6500, 7000); | |
| 201 | + snd_soc_component_update_bits(component, AK4375_01_POWER_MANAGEMENT2, PMLDO, PMLDO); | |
| 202 | + usleep_range(1000, 2000); | |
| 203 | + break; | |
| 204 | + case SND_SOC_DAPM_POST_PMU: | |
| 205 | + snd_soc_component_update_bits(component, AK4375_01_POWER_MANAGEMENT2, PMCP2, PMCP2); | |
| 206 | + usleep_range(4500, 5000); | |
| 207 | + break; | |
| 208 | + case SND_SOC_DAPM_PRE_PMD: | |
| 209 | + snd_soc_component_update_bits(component, AK4375_01_POWER_MANAGEMENT2, PMCP2, 0x0); | |
| 210 | + break; | |
| 211 | + case SND_SOC_DAPM_POST_PMD: | |
| 212 | + snd_soc_component_update_bits(component, AK4375_01_POWER_MANAGEMENT2, PMLDO, 0x0); | |
| 213 | + snd_soc_component_update_bits(component, AK4375_01_POWER_MANAGEMENT2, PMCP1, 0x0); | |
| 214 | + snd_soc_component_update_bits(component, AK4375_00_POWER_MANAGEMENT1, PMPLL, 0x0); | |
| 215 | + break; | |
| 216 | + } | |
| 217 | + | |
| 218 | + return 0; | |
| 219 | +} | |
| 220 | + | |
| 221 | +static const struct snd_soc_dapm_widget ak4375_dapm_widgets[] = { | |
| 222 | + SND_SOC_DAPM_DAC_E("DAC", NULL, AK4375_02_POWER_MANAGEMENT3, 0, 0, ak4375_dac_event, | |
| 223 | + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | |
| 224 | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | |
| 225 | + | |
| 226 | + SND_SOC_DAPM_AIF_IN("SDTI", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0), | |
| 227 | + | |
| 228 | + SND_SOC_DAPM_OUTPUT("HPL"), | |
| 229 | + SND_SOC_DAPM_OUTPUT("HPR"), | |
| 230 | + | |
| 231 | + SND_SOC_DAPM_MIXER("HPR Mixer", AK4375_03_POWER_MANAGEMENT4, 1, 0, | |
| 232 | + &ak4375_hpr_mixer_controls[0], ARRAY_SIZE(ak4375_hpr_mixer_controls)), | |
| 233 | + SND_SOC_DAPM_MIXER("HPL Mixer", AK4375_03_POWER_MANAGEMENT4, 0, 0, | |
| 234 | + &ak4375_hpl_mixer_controls[0], ARRAY_SIZE(ak4375_hpl_mixer_controls)), | |
| 235 | +}; | |
| 236 | + | |
| 237 | +static const struct snd_soc_dapm_route ak4375_intercon[] = { | |
| 238 | + { "DAC", NULL, "SDTI" }, | |
| 239 | + | |
| 240 | + { "HPL Mixer", "LDACL Switch", "DAC" }, | |
| 241 | + { "HPL Mixer", "RDACL Switch", "DAC" }, | |
| 242 | + { "HPR Mixer", "LDACR Switch", "DAC" }, | |
| 243 | + { "HPR Mixer", "RDACR Switch", "DAC" }, | |
| 244 | + | |
| 245 | + { "HPL", NULL, "HPL Mixer" }, | |
| 246 | + { "HPR", NULL, "HPR Mixer" }, | |
| 247 | +}; | |
| 248 | + | |
| 249 | +static int ak4375_hw_params(struct snd_pcm_substream *substream, | |
| 250 | + struct snd_pcm_hw_params *params, | |
| 251 | + struct snd_soc_dai *dai) | |
| 252 | +{ | |
| 253 | + struct snd_soc_component *component = dai->component; | |
| 254 | + struct ak4375_priv *ak4375 = snd_soc_component_get_drvdata(component); | |
| 255 | + unsigned int freq_in, freq_out; | |
| 256 | + | |
| 257 | + ak4375->rate = params_rate(params); | |
| 258 | + | |
| 259 | + if (ak4375->rate <= 96000) | |
| 260 | + ak4375->pld = 0; | |
| 261 | + else | |
| 262 | + ak4375->pld = 1; | |
| 263 | + | |
| 264 | + freq_in = 32 * ak4375->rate / (ak4375->pld + 1); | |
| 265 | + | |
| 266 | + if ((ak4375->rate % 8000) == 0) | |
| 267 | + freq_out = AK4375_PLL_FREQ_OUT_122880000; | |
| 268 | + else | |
| 269 | + freq_out = AK4375_PLL_FREQ_OUT_112896000; | |
| 270 | + | |
| 271 | + return snd_soc_dai_set_pll(dai, 0, 0, freq_in, freq_out); | |
| 272 | +} | |
| 273 | + | |
| 274 | +static int ak4375_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, | |
| 275 | + unsigned int freq_in, unsigned int freq_out) | |
| 276 | +{ | |
| 277 | + struct snd_soc_component *component = dai->component; | |
| 278 | + struct ak4375_priv *ak4375 = snd_soc_component_get_drvdata(component); | |
| 279 | + unsigned int mclk, plm, mdiv, div; | |
| 280 | + u8 cms, fs, cm; | |
| 281 | + | |
| 282 | + cms = snd_soc_component_read(component, AK4375_05_CLOCK_MODE_SELECT); | |
| 283 | + fs = cms & ~FS_MASK; | |
| 284 | + cm = cms & ~CM_MASK; | |
| 285 | + | |
| 286 | + switch (ak4375->rate) { | |
| 287 | + case 8000: | |
| 288 | + fs |= FS_8KHZ; | |
| 289 | + break; | |
| 290 | + case 11025: | |
| 291 | + fs |= FS_11_025KHZ; | |
| 292 | + break; | |
| 293 | + case 16000: | |
| 294 | + fs |= FS_16KHZ; | |
| 295 | + break; | |
| 296 | + case 22050: | |
| 297 | + fs |= FS_22_05KHZ; | |
| 298 | + break; | |
| 299 | + case 32000: | |
| 300 | + fs |= FS_32KHZ; | |
| 301 | + break; | |
| 302 | + case 44100: | |
| 303 | + fs |= FS_44_1KHZ; | |
| 304 | + break; | |
| 305 | + case 48000: | |
| 306 | + fs |= FS_48KHZ; | |
| 307 | + break; | |
| 308 | + case 88200: | |
| 309 | + fs |= FS_88_2KHZ; | |
| 310 | + break; | |
| 311 | + case 96000: | |
| 312 | + fs |= FS_96KHZ; | |
| 313 | + break; | |
| 314 | + case 176400: | |
| 315 | + fs |= FS_176_4KHZ; | |
| 316 | + break; | |
| 317 | + case 192000: | |
| 318 | + fs |= FS_192KHZ; | |
| 319 | + break; | |
| 320 | + default: | |
| 321 | + return -EINVAL; | |
| 322 | + } | |
| 323 | + | |
| 324 | + if (ak4375->rate <= 24000) { | |
| 325 | + cm |= CM_1; | |
| 326 | + mclk = 512 * ak4375->rate; | |
| 327 | + mdiv = freq_out / mclk - 1; | |
| 328 | + div = 0; | |
| 329 | + } else if (ak4375->rate <= 96000) { | |
| 330 | + cm |= CM_0; | |
| 331 | + mclk = 256 * ak4375->rate; | |
| 332 | + mdiv = freq_out / mclk - 1; | |
| 333 | + div = 0; | |
| 334 | + } else { | |
| 335 | + cm |= CM_3; | |
| 336 | + mclk = 128 * ak4375->rate; | |
| 337 | + mdiv = 4; | |
| 338 | + div = 1; | |
| 339 | + } | |
| 340 | + | |
| 341 | + /* Writing both fields in one go seems to make playback choppy on start */ | |
| 342 | + snd_soc_component_update_bits(component, AK4375_05_CLOCK_MODE_SELECT, FS_MASK, fs); | |
| 343 | + snd_soc_component_update_bits(component, AK4375_05_CLOCK_MODE_SELECT, CM_MASK, cm); | |
| 344 | + | |
| 345 | + snd_soc_component_write(component, AK4375_0F_PLL_REF_CLK_DIVIDER1, | |
| 346 | + (ak4375->pld & 0xff00) >> 8); | |
| 347 | + snd_soc_component_write(component, AK4375_10_PLL_REF_CLK_DIVIDER2, | |
| 348 | + ak4375->pld & 0x00ff); | |
| 349 | + | |
| 350 | + plm = freq_out / freq_in - 1; | |
| 351 | + snd_soc_component_write(component, AK4375_11_PLL_FB_CLK_DIVIDER1, (plm & 0xff00) >> 8); | |
| 352 | + snd_soc_component_write(component, AK4375_12_PLL_FB_CLK_DIVIDER2, plm & 0x00ff); | |
| 353 | + | |
| 354 | + snd_soc_component_update_bits(component, AK4375_13_SRC_CLK_SOURCE, DIV, div); | |
| 355 | + | |
| 356 | + /* SRCCKS bit: force to 1 for SRC PLL source clock */ | |
| 357 | + snd_soc_component_update_bits(component, AK4375_13_SRC_CLK_SOURCE, SRCCKS, SRCCKS); | |
| 358 | + | |
| 359 | + snd_soc_component_write(component, AK4375_14_DAC_CLK_DIVIDER, mdiv); | |
| 360 | + | |
| 361 | + dev_dbg(ak4375->dev, "rate=%d mclk=%d f_in=%d f_out=%d PLD=%d PLM=%d MDIV=%d DIV=%d\n", | |
| 362 | + ak4375->rate, mclk, freq_in, freq_out, ak4375->pld, plm, mdiv, div); | |
| 363 | + | |
| 364 | + return 0; | |
| 365 | +} | |
| 366 | + | |
| 367 | +static int ak4375_mute(struct snd_soc_dai *dai, int mute, int direction) | |
| 368 | +{ | |
| 369 | + struct snd_soc_component *component = dai->component; | |
| 370 | + struct ak4375_priv *ak4375 = snd_soc_component_get_drvdata(component); | |
| 371 | + u8 val = snd_soc_component_read(component, AK4375_07_DAC_MONO_MIXING); | |
| 372 | + | |
| 373 | + dev_dbg(ak4375->dev, "mute=%d val=%d\n", mute, val); | |
| 374 | + | |
| 375 | + if (mute) { | |
| 376 | + ak4375->mute_save = val & DACMUTE_MASK; | |
| 377 | + val &= ~DACMUTE_MASK; | |
| 378 | + } else { | |
| 379 | + val |= ak4375->mute_save; | |
| 380 | + } | |
| 381 | + | |
| 382 | + snd_soc_component_write(component, AK4375_07_DAC_MONO_MIXING, val); | |
| 383 | + | |
| 384 | + return 0; | |
| 385 | +} | |
| 386 | + | |
| 387 | +#define AK4375_RATES (SNDRV_PCM_RATE_8000_48000 |\ | |
| 388 | + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |\ | |
| 389 | + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000) | |
| 390 | + | |
| 391 | +#define AK4375_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ | |
| 392 | + SNDRV_PCM_FMTBIT_S24_LE |\ | |
| 393 | + SNDRV_PCM_FMTBIT_S32_LE) | |
| 394 | + | |
| 395 | +static const struct snd_soc_dai_ops ak4375_dai_ops = { | |
| 396 | + .hw_params = ak4375_hw_params, | |
| 397 | + .mute_stream = ak4375_mute, | |
| 398 | + .set_pll = ak4375_dai_set_pll, | |
| 399 | +}; | |
| 400 | + | |
| 401 | +static struct snd_soc_dai_driver ak4375_dai = { | |
| 402 | + .name = "ak4375-hifi", | |
| 403 | + .playback = { | |
| 404 | + .stream_name = "HiFi Playback", | |
| 405 | + .channels_min = 1, | |
| 406 | + .channels_max = 2, | |
| 407 | + .rates = AK4375_RATES, | |
| 408 | + .rate_min = 8000, | |
| 409 | + .rate_max = 192000, | |
| 410 | + .formats = AK4375_FORMATS, | |
| 411 | + }, | |
| 412 | + .ops = &ak4375_dai_ops, | |
| 413 | +}; | |
| 414 | + | |
| 415 | +static void ak4375_power_off(struct ak4375_priv *ak4375) | |
| 416 | +{ | |
| 417 | + gpiod_set_value_cansleep(ak4375->pdn_gpiod, 0); | |
| 418 | + usleep_range(1000, 2000); | |
| 419 | + | |
| 420 | + regulator_bulk_disable(ARRAY_SIZE(ak4375->supplies), ak4375->supplies); | |
| 421 | +} | |
| 422 | + | |
| 423 | +static int ak4375_power_on(struct ak4375_priv *ak4375) | |
| 424 | +{ | |
| 425 | + int ret; | |
| 426 | + | |
| 427 | + ret = regulator_bulk_enable(ARRAY_SIZE(ak4375->supplies), ak4375->supplies); | |
| 428 | + if (ret < 0) { | |
| 429 | + dev_err(ak4375->dev, "Failed to enable regulators: %d\n", ret); | |
| 430 | + return ret; | |
| 431 | + } | |
| 432 | + | |
| 433 | + usleep_range(3000, 4000); | |
| 434 | + | |
| 435 | + gpiod_set_value_cansleep(ak4375->pdn_gpiod, 1); | |
| 436 | + usleep_range(1000, 2000); | |
| 437 | + | |
| 438 | + return 0; | |
| 439 | +} | |
| 440 | + | |
| 441 | +static int __maybe_unused ak4375_runtime_suspend(struct device *dev) | |
| 442 | +{ | |
| 443 | + struct ak4375_priv *ak4375 = dev_get_drvdata(dev); | |
| 444 | + | |
| 445 | + regcache_cache_only(ak4375->regmap, true); | |
| 446 | + ak4375_power_off(ak4375); | |
| 447 | + | |
| 448 | + return 0; | |
| 449 | +} | |
| 450 | + | |
| 451 | +static int __maybe_unused ak4375_runtime_resume(struct device *dev) | |
| 452 | +{ | |
| 453 | + struct ak4375_priv *ak4375 = dev_get_drvdata(dev); | |
| 454 | + int ret; | |
| 455 | + | |
| 456 | + ret = ak4375_power_on(ak4375); | |
| 457 | + if (ret < 0) | |
| 458 | + return ret; | |
| 459 | + | |
| 460 | + regcache_cache_only(ak4375->regmap, false); | |
| 461 | + regcache_mark_dirty(ak4375->regmap); | |
| 462 | + | |
| 463 | + return regcache_sync(ak4375->regmap); | |
| 464 | +} | |
| 465 | + | |
| 466 | +static const struct snd_soc_component_driver soc_codec_dev_ak4375 = { | |
| 467 | + .controls = ak4375_snd_controls, | |
| 468 | + .num_controls = ARRAY_SIZE(ak4375_snd_controls), | |
| 469 | + .dapm_widgets = ak4375_dapm_widgets, | |
| 470 | + .num_dapm_widgets = ARRAY_SIZE(ak4375_dapm_widgets), | |
| 471 | + .dapm_routes = ak4375_intercon, | |
| 472 | + .num_dapm_routes = ARRAY_SIZE(ak4375_intercon), | |
| 473 | + .idle_bias_on = 1, | |
| 474 | + .use_pmdown_time = 1, | |
| 475 | + .endianness = 1, | |
| 476 | + .non_legacy_dai_naming = 1, | |
| 477 | +}; | |
| 478 | + | |
| 479 | +static const struct regmap_config ak4375_regmap = { | |
| 480 | + .reg_bits = 8, | |
| 481 | + .val_bits = 8, | |
| 482 | + .max_register = AK4375_24_MODE_CONTROL, | |
| 483 | + .reg_defaults = ak4375_reg_defaults, | |
| 484 | + .num_reg_defaults = ARRAY_SIZE(ak4375_reg_defaults), | |
| 485 | + .cache_type = REGCACHE_RBTREE, | |
| 486 | +}; | |
| 487 | + | |
| 488 | +static const struct ak4375_drvdata ak4375_drvdata = { | |
| 489 | + .dai_drv = &ak4375_dai, | |
| 490 | + .comp_drv = &soc_codec_dev_ak4375, | |
| 491 | +}; | |
| 492 | + | |
| 493 | +static const struct dev_pm_ops ak4375_pm = { | |
| 494 | + SET_RUNTIME_PM_OPS(ak4375_runtime_suspend, ak4375_runtime_resume, NULL) | |
| 495 | + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, | |
| 496 | + pm_runtime_force_resume) | |
| 497 | +}; | |
| 498 | + | |
| 499 | +static int ak4375_i2c_probe(struct i2c_client *i2c) | |
| 500 | +{ | |
| 501 | + struct ak4375_priv *ak4375; | |
| 502 | + const struct ak4375_drvdata *drvdata; | |
| 503 | + unsigned int deviceid; | |
| 504 | + int ret, i; | |
| 505 | + | |
| 506 | + ak4375 = devm_kzalloc(&i2c->dev, sizeof(*ak4375), GFP_KERNEL); | |
| 507 | + if (!ak4375) | |
| 508 | + return -ENOMEM; | |
| 509 | + | |
| 510 | + ak4375->regmap = devm_regmap_init_i2c(i2c, &ak4375_regmap); | |
| 511 | + if (IS_ERR(ak4375->regmap)) | |
| 512 | + return PTR_ERR(ak4375->regmap); | |
| 513 | + | |
| 514 | + i2c_set_clientdata(i2c, ak4375); | |
| 515 | + ak4375->dev = &i2c->dev; | |
| 516 | + | |
| 517 | + drvdata = of_device_get_match_data(&i2c->dev); | |
| 518 | + | |
| 519 | + for (i = 0; i < ARRAY_SIZE(supply_names); i++) | |
| 520 | + ak4375->supplies[i].supply = supply_names[i]; | |
| 521 | + | |
| 522 | + ret = devm_regulator_bulk_get(ak4375->dev, ARRAY_SIZE(ak4375->supplies), ak4375->supplies); | |
| 523 | + if (ret < 0) { | |
| 524 | + dev_err(ak4375->dev, "Failed to get regulators: %d\n", ret); | |
| 525 | + return ret; | |
| 526 | + } | |
| 527 | + | |
| 528 | + ak4375->pdn_gpiod = devm_gpiod_get_optional(ak4375->dev, "pdn", GPIOD_OUT_LOW); | |
| 529 | + if (IS_ERR(ak4375->pdn_gpiod)) | |
| 530 | + return dev_err_probe(ak4375->dev, PTR_ERR(ak4375->pdn_gpiod), | |
| 531 | + "failed to get pdn\n"); | |
| 532 | + | |
| 533 | + ret = ak4375_power_on(ak4375); | |
| 534 | + if (ret < 0) | |
| 535 | + return ret; | |
| 536 | + | |
| 537 | + /* Don't read deviceid from cache */ | |
| 538 | + regcache_cache_bypass(ak4375->regmap, true); | |
| 539 | + | |
| 540 | + ret = regmap_read(ak4375->regmap, AK4375_15_AUDIO_IF_FORMAT, &deviceid); | |
| 541 | + if (ret < 0) { | |
| 542 | + dev_err(ak4375->dev, "unable to read DEVICEID!\n"); | |
| 543 | + return ret; | |
| 544 | + } | |
| 545 | + | |
| 546 | + regcache_cache_bypass(ak4375->regmap, false); | |
| 547 | + | |
| 548 | + deviceid = (deviceid & DEVICEID_MASK) >> 5; | |
| 549 | + | |
| 550 | + switch (deviceid) { | |
| 551 | + case DEVICEID_AK4331: | |
| 552 | + dev_err(ak4375->dev, "found untested AK4331\n"); | |
| 553 | + return -EINVAL; | |
| 554 | + case DEVICEID_AK4375: | |
| 555 | + dev_dbg(ak4375->dev, "found AK4375\n"); | |
| 556 | + break; | |
| 557 | + case DEVICEID_AK4375A: | |
| 558 | + dev_dbg(ak4375->dev, "found AK4375A\n"); | |
| 559 | + break; | |
| 560 | + case DEVICEID_AK4376A: | |
| 561 | + dev_err(ak4375->dev, "found unsupported AK4376/A!\n"); | |
| 562 | + return -EINVAL; | |
| 563 | + case DEVICEID_AK4377: | |
| 564 | + dev_err(ak4375->dev, "found unsupported AK4377!\n"); | |
| 565 | + return -EINVAL; | |
| 566 | + default: | |
| 567 | + dev_err(ak4375->dev, "unrecognized DEVICEID!\n"); | |
| 568 | + return -EINVAL; | |
| 569 | + } | |
| 570 | + | |
| 571 | + pm_runtime_set_active(ak4375->dev); | |
| 572 | + pm_runtime_enable(ak4375->dev); | |
| 573 | + | |
| 574 | + ret = devm_snd_soc_register_component(ak4375->dev, drvdata->comp_drv, | |
| 575 | + drvdata->dai_drv, 1); | |
| 576 | + if (ret < 0) { | |
| 577 | + dev_err(ak4375->dev, "Failed to register CODEC: %d\n", ret); | |
| 578 | + return ret; | |
| 579 | + } | |
| 580 | + | |
| 581 | + return 0; | |
| 582 | +} | |
| 583 | + | |
| 584 | +static int ak4375_i2c_remove(struct i2c_client *i2c) | |
| 585 | +{ | |
| 586 | + pm_runtime_disable(&i2c->dev); | |
| 587 | + | |
| 588 | + return 0; | |
| 589 | +} | |
| 590 | + | |
| 591 | +static const struct of_device_id ak4375_of_match[] = { | |
| 592 | + { .compatible = "asahi-kasei,ak4375", .data = &ak4375_drvdata }, | |
| 593 | + { }, | |
| 594 | +}; | |
| 595 | +MODULE_DEVICE_TABLE(of, ak4375_of_match); | |
| 596 | + | |
| 597 | +static struct i2c_driver ak4375_i2c_driver = { | |
| 598 | + .driver = { | |
| 599 | + .name = "ak4375", | |
| 600 | + .pm = &ak4375_pm, | |
| 601 | + .of_match_table = ak4375_of_match, | |
| 602 | + }, | |
| 603 | + .probe_new = ak4375_i2c_probe, | |
| 604 | + .remove = ak4375_i2c_remove, | |
| 605 | +}; | |
| 606 | +module_i2c_driver(ak4375_i2c_driver); | |
| 607 | + | |
| 608 | +MODULE_AUTHOR("Vincent Knecht <vincent.knecht@mailoo.org>"); | |
| 609 | +MODULE_DESCRIPTION("ASoC AK4375 DAC driver"); | |
| 610 | +MODULE_LICENSE("GPL"); | |
| @@ -1311,7 +1311,7 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client, · 1310 unmodified lines | ||
| 1311 | 1311 | pdata->gain_zc = of_property_read_bool(np, "cirrus,amp-gain-zc"); |
| 1312 | 1312 | |
| 1313 | 1313 | classh = of_get_child_by_name(np, "cirrus,classh-internal-algo"); |
| 1314 | − classh_config->classh_algo_enable = classh ? true : false; | |
| 1314 | + classh_config->classh_algo_enable = (classh != NULL); | |
| 1315 | 1315 | |
| 1316 | 1316 | if (classh_config->classh_algo_enable) { |
| 1317 | 1317 | classh_config->classh_bst_override = |
| @@ -17,27 +17,13 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <linux/platform_device.h> |
| 18 | 18 | #include <linux/slab.h> |
| 19 | 19 | |
| 20 | −#include <sound/cs35l41.h> | |
| 21 | 20 | #include "cs35l41.h" |
| 22 | 21 | |
| 23 | −static struct regmap_config cs35l41_regmap_i2c = { | |
| 24 | − .reg_bits = 32, | |
| 25 | − .val_bits = 32, | |
| 26 | − .reg_stride = CS35L41_REGSTRIDE, | |
| 27 | − .reg_format_endian = REGMAP_ENDIAN_BIG, | |
| 28 | − .val_format_endian = REGMAP_ENDIAN_BIG, | |
| 29 | − .max_register = CS35L41_LASTREG, | |
| 30 | − .reg_defaults = cs35l41_reg, | |
| 31 | − .num_reg_defaults = ARRAY_SIZE(cs35l41_reg), | |
| 32 | − .volatile_reg = cs35l41_volatile_reg, | |
| 33 | − .readable_reg = cs35l41_readable_reg, | |
| 34 | − .precious_reg = cs35l41_precious_reg, | |
| 35 | − .cache_type = REGCACHE_RBTREE, | |
| 36 | −}; | |
| 37 | − | |
| 38 | 22 | static const struct i2c_device_id cs35l41_id_i2c[] = { |
| 39 | 23 | { "cs35l40", 0 }, |
| 40 | 24 | { "cs35l41", 0 }, |
| 25 | + { "cs35l51", 0 }, | |
| 26 | + { "cs35l53", 0 }, | |
| 41 | 27 | {} |
| 42 | 28 | }; |
| 43 | 29 | |
| @@ -100,6 +86,7 @@ MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_match); · 56 unmodified lines | ||
| 100 | 86 | static struct i2c_driver cs35l41_i2c_driver = { |
| 101 | 87 | .driver = { |
| 102 | 88 | .name = "cs35l41", |
| 89 | + .pm = &cs35l41_pm_ops, | |
| 103 | 90 | .of_match_table = of_match_ptr(cs35l41_of_match), |
| 104 | 91 | .acpi_match_table = ACPI_PTR(cs35l41_acpi_match), |
| 105 | 92 | }, |
| @@ -1,17 +1,30 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | // |
| 3 | −// cs35l41-tables.c -- CS35L41 ALSA SoC audio driver | |
| 3 | +// cs35l41-lib.c -- CS35L41 Common functions for HDA and ASoC Audio drivers | |
| 4 | 4 | // |
| 5 | 5 | // Copyright 2017-2021 Cirrus Logic, Inc. |
| 6 | 6 | // |
| 7 | 7 | // Author: David Rhodes <david.rhodes@cirrus.com> |
| 8 | +// Author: Lucas Tanure <lucas.tanure@cirrus.com> | |
| 8 | 9 | |
| 9 | −#include "cs35l41.h" | |
| 10 | +#include <linux/dev_printk.h> | |
| 11 | +#include <linux/module.h> | |
| 12 | +#include <linux/regmap.h> | |
| 13 | +#include <linux/regulator/consumer.h> | |
| 14 | +#include <linux/slab.h> | |
| 10 | 15 | |
| 11 | −const struct reg_default cs35l41_reg[CS35L41_MAX_CACHE_REG] = { | |
| 16 | +#include <sound/cs35l41.h> | |
| 17 | + | |
| 18 | +static const struct reg_default cs35l41_reg[] = { | |
| 12 | 19 | { CS35L41_PWR_CTRL1, 0x00000000 }, |
| 20 | + { CS35L41_PWR_CTRL2, 0x00000000 }, | |
| 13 | 21 | { CS35L41_PWR_CTRL3, 0x01000010 }, |
| 14 | 22 | { CS35L41_GPIO_PAD_CONTROL, 0x00000000 }, |
| 23 | + { CS35L41_GLOBAL_CLK_CTRL, 0x00000003 }, | |
| 24 | + { CS35L41_TST_FS_MON0, 0x00020016 }, | |
| 25 | + { CS35L41_BSTCVRT_COEFF, 0x00002424 }, | |
| 26 | + { CS35L41_BSTCVRT_SLOPE_LBST, 0x00007500 }, | |
| 27 | + { CS35L41_BSTCVRT_PEAK_CUR, 0x0000004A }, | |
| 15 | 28 | { CS35L41_SP_ENABLES, 0x00000000 }, |
| 16 | 29 | { CS35L41_SP_RATE_CTRL, 0x00000028 }, |
| 17 | 30 | { CS35L41_SP_FORMAT, 0x18180200 }, |
| @@ -39,15 +52,20 @@ const struct reg_default cs35l41_reg[CS35L41_MAX_CACHE_REG] = { · 21 unmodified lines | ||
| 39 | 52 | { CS35L41_CLASSH_CFG, 0x000B0405 }, |
| 40 | 53 | { CS35L41_WKFET_CFG, 0x00000111 }, |
| 41 | 54 | { CS35L41_NG_CFG, 0x00000033 }, |
| 42 | − { CS35L41_AMP_GAIN_CTRL, 0x00000273 }, | |
| 55 | + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, | |
| 56 | + { CS35L41_IRQ1_MASK1, 0xFFFFFFFF }, | |
| 57 | + { CS35L41_IRQ1_MASK2, 0xFFFFFFFF }, | |
| 58 | + { CS35L41_IRQ1_MASK3, 0xFFFF87FF }, | |
| 59 | + { CS35L41_IRQ1_MASK4, 0xFEFFFFFF }, | |
| 43 | 60 | { CS35L41_GPIO1_CTRL1, 0xE1000001 }, |
| 44 | 61 | { CS35L41_GPIO2_CTRL1, 0xE1000001 }, |
| 45 | 62 | { CS35L41_MIXER_NGATE_CFG, 0x00000000 }, |
| 46 | 63 | { CS35L41_MIXER_NGATE_CH1_CFG, 0x00000303 }, |
| 47 | 64 | { CS35L41_MIXER_NGATE_CH2_CFG, 0x00000303 }, |
| 65 | + { CS35L41_DSP1_CCM_CORE_CTRL, 0x00000101 }, | |
| 48 | 66 | }; |
| 49 | 67 | |
| 50 | −bool cs35l41_readable_reg(struct device *dev, unsigned int reg) | |
| 68 | +static bool cs35l41_readable_reg(struct device *dev, unsigned int reg) | |
| 51 | 69 | { |
| 52 | 70 | switch (reg) { |
| 53 | 71 | case CS35L41_DEVID: |
| @@ -72,10 +90,14 @@ bool cs35l41_readable_reg(struct device *dev, unsigned int reg) · 18 unmodified lines | ||
| 72 | 90 | case CS35L41_PROTECT_REL_ERR_IGN: |
| 73 | 91 | case CS35L41_GPIO_PAD_CONTROL: |
| 74 | 92 | case CS35L41_JTAG_CONTROL: |
| 93 | + case CS35L41_PWRMGT_CTL: | |
| 94 | + case CS35L41_WAKESRC_CTL: | |
| 95 | + case CS35L41_PWRMGT_STS: | |
| 75 | 96 | case CS35L41_PLL_CLK_CTRL: |
| 76 | 97 | case CS35L41_DSP_CLK_CTRL: |
| 77 | 98 | case CS35L41_GLOBAL_CLK_CTRL: |
| 78 | 99 | case CS35L41_DATA_FS_SEL: |
| 100 | + case CS35L41_TST_FS_MON0: | |
| 79 | 101 | case CS35L41_MDSYNC_EN: |
| 80 | 102 | case CS35L41_MDSYNC_TX_ID: |
| 81 | 103 | case CS35L41_MDSYNC_PWR_CTRL: |
| @@ -200,6 +222,83 @@ bool cs35l41_readable_reg(struct device *dev, unsigned int reg) · 118 unmodified lines | ||
| 200 | 222 | case CS35L41_DIE_STS2: |
| 201 | 223 | case CS35L41_TEMP_CAL1: |
| 202 | 224 | case CS35L41_TEMP_CAL2: |
| 225 | + case CS35L41_DSP1_TIMESTAMP_COUNT: | |
| 226 | + case CS35L41_DSP1_SYS_ID: | |
| 227 | + case CS35L41_DSP1_SYS_VERSION: | |
| 228 | + case CS35L41_DSP1_SYS_CORE_ID: | |
| 229 | + case CS35L41_DSP1_SYS_AHB_ADDR: | |
| 230 | + case CS35L41_DSP1_SYS_XSRAM_SIZE: | |
| 231 | + case CS35L41_DSP1_SYS_YSRAM_SIZE: | |
| 232 | + case CS35L41_DSP1_SYS_PSRAM_SIZE: | |
| 233 | + case CS35L41_DSP1_SYS_PM_BOOT_SIZE: | |
| 234 | + case CS35L41_DSP1_SYS_FEATURES: | |
| 235 | + case CS35L41_DSP1_SYS_FIR_FILTERS: | |
| 236 | + case CS35L41_DSP1_SYS_LMS_FILTERS: | |
| 237 | + case CS35L41_DSP1_SYS_XM_BANK_SIZE: | |
| 238 | + case CS35L41_DSP1_SYS_YM_BANK_SIZE: | |
| 239 | + case CS35L41_DSP1_SYS_PM_BANK_SIZE: | |
| 240 | + case CS35L41_DSP1_RX1_RATE: | |
| 241 | + case CS35L41_DSP1_RX2_RATE: | |
| 242 | + case CS35L41_DSP1_RX3_RATE: | |
| 243 | + case CS35L41_DSP1_RX4_RATE: | |
| 244 | + case CS35L41_DSP1_RX5_RATE: | |
| 245 | + case CS35L41_DSP1_RX6_RATE: | |
| 246 | + case CS35L41_DSP1_RX7_RATE: | |
| 247 | + case CS35L41_DSP1_RX8_RATE: | |
| 248 | + case CS35L41_DSP1_TX1_RATE: | |
| 249 | + case CS35L41_DSP1_TX2_RATE: | |
| 250 | + case CS35L41_DSP1_TX3_RATE: | |
| 251 | + case CS35L41_DSP1_TX4_RATE: | |
| 252 | + case CS35L41_DSP1_TX5_RATE: | |
| 253 | + case CS35L41_DSP1_TX6_RATE: | |
| 254 | + case CS35L41_DSP1_TX7_RATE: | |
| 255 | + case CS35L41_DSP1_TX8_RATE: | |
| 256 | + case CS35L41_DSP1_SCRATCH1: | |
| 257 | + case CS35L41_DSP1_SCRATCH2: | |
| 258 | + case CS35L41_DSP1_SCRATCH3: | |
| 259 | + case CS35L41_DSP1_SCRATCH4: | |
| 260 | + case CS35L41_DSP1_CCM_CORE_CTRL: | |
| 261 | + case CS35L41_DSP1_CCM_CLK_OVERRIDE: | |
| 262 | + case CS35L41_DSP1_XM_MSTR_EN: | |
| 263 | + case CS35L41_DSP1_XM_CORE_PRI: | |
| 264 | + case CS35L41_DSP1_XM_AHB_PACK_PL_PRI: | |
| 265 | + case CS35L41_DSP1_XM_AHB_UP_PL_PRI: | |
| 266 | + case CS35L41_DSP1_XM_ACCEL_PL0_PRI: | |
| 267 | + case CS35L41_DSP1_XM_NPL0_PRI: | |
| 268 | + case CS35L41_DSP1_YM_MSTR_EN: | |
| 269 | + case CS35L41_DSP1_YM_CORE_PRI: | |
| 270 | + case CS35L41_DSP1_YM_AHB_PACK_PL_PRI: | |
| 271 | + case CS35L41_DSP1_YM_AHB_UP_PL_PRI: | |
| 272 | + case CS35L41_DSP1_YM_ACCEL_PL0_PRI: | |
| 273 | + case CS35L41_DSP1_YM_NPL0_PRI: | |
| 274 | + case CS35L41_DSP1_MPU_XM_ACCESS0: | |
| 275 | + case CS35L41_DSP1_MPU_YM_ACCESS0: | |
| 276 | + case CS35L41_DSP1_MPU_WNDW_ACCESS0: | |
| 277 | + case CS35L41_DSP1_MPU_XREG_ACCESS0: | |
| 278 | + case CS35L41_DSP1_MPU_YREG_ACCESS0: | |
| 279 | + case CS35L41_DSP1_MPU_XM_ACCESS1: | |
| 280 | + case CS35L41_DSP1_MPU_YM_ACCESS1: | |
| 281 | + case CS35L41_DSP1_MPU_WNDW_ACCESS1: | |
| 282 | + case CS35L41_DSP1_MPU_XREG_ACCESS1: | |
| 283 | + case CS35L41_DSP1_MPU_YREG_ACCESS1: | |
| 284 | + case CS35L41_DSP1_MPU_XM_ACCESS2: | |
| 285 | + case CS35L41_DSP1_MPU_YM_ACCESS2: | |
| 286 | + case CS35L41_DSP1_MPU_WNDW_ACCESS2: | |
| 287 | + case CS35L41_DSP1_MPU_XREG_ACCESS2: | |
| 288 | + case CS35L41_DSP1_MPU_YREG_ACCESS2: | |
| 289 | + case CS35L41_DSP1_MPU_XM_ACCESS3: | |
| 290 | + case CS35L41_DSP1_MPU_YM_ACCESS3: | |
| 291 | + case CS35L41_DSP1_MPU_WNDW_ACCESS3: | |
| 292 | + case CS35L41_DSP1_MPU_XREG_ACCESS3: | |
| 293 | + case CS35L41_DSP1_MPU_YREG_ACCESS3: | |
| 294 | + case CS35L41_DSP1_MPU_XM_VIO_ADDR: | |
| 295 | + case CS35L41_DSP1_MPU_XM_VIO_STATUS: | |
| 296 | + case CS35L41_DSP1_MPU_YM_VIO_ADDR: | |
| 297 | + case CS35L41_DSP1_MPU_YM_VIO_STATUS: | |
| 298 | + case CS35L41_DSP1_MPU_PM_VIO_ADDR: | |
| 299 | + case CS35L41_DSP1_MPU_PM_VIO_STATUS: | |
| 300 | + case CS35L41_DSP1_MPU_LOCK_CONFIG: | |
| 301 | + case CS35L41_DSP1_MPU_WDT_RST_CTRL: | |
| 203 | 302 | case CS35L41_OTP_TRIM_1: |
| 204 | 303 | case CS35L41_OTP_TRIM_2: |
| 205 | 304 | case CS35L41_OTP_TRIM_3: |
| @@ -237,6 +336,13 @@ bool cs35l41_readable_reg(struct device *dev, unsigned int reg) · 31 unmodified lines | ||
| 237 | 336 | case CS35L41_OTP_TRIM_35: |
| 238 | 337 | case CS35L41_OTP_TRIM_36: |
| 239 | 338 | case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31: |
| 339 | + case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068: | |
| 340 | + case CS35L41_DSP1_XMEM_UNPACK32_0 ... CS35L41_DSP1_XMEM_UNPACK32_2046: | |
| 341 | + case CS35L41_DSP1_XMEM_UNPACK24_0 ... CS35L41_DSP1_XMEM_UNPACK24_4093: | |
| 342 | + case CS35L41_DSP1_YMEM_PACK_0 ... CS35L41_DSP1_YMEM_PACK_1532: | |
| 343 | + case CS35L41_DSP1_YMEM_UNPACK32_0 ... CS35L41_DSP1_YMEM_UNPACK32_1022: | |
| 344 | + case CS35L41_DSP1_YMEM_UNPACK24_0 ... CS35L41_DSP1_YMEM_UNPACK24_2045: | |
| 345 | + case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114: | |
| 240 | 346 | /*test regs*/ |
| 241 | 347 | case CS35L41_PLL_OVR: |
| 242 | 348 | case CS35L41_BST_TEST_DUTY: |
| @@ -247,23 +353,35 @@ bool cs35l41_readable_reg(struct device *dev, unsigned int reg) · 4 unmodified lines | ||
| 247 | 353 | } |
| 248 | 354 | } |
| 249 | 355 | |
| 250 | −bool cs35l41_precious_reg(struct device *dev, unsigned int reg) | |
| 356 | +static bool cs35l41_precious_reg(struct device *dev, unsigned int reg) | |
| 251 | 357 | { |
| 252 | 358 | switch (reg) { |
| 359 | + case CS35L41_TEST_KEY_CTL: | |
| 360 | + case CS35L41_USER_KEY_CTL: | |
| 253 | 361 | case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31: |
| 362 | + case CS35L41_TST_FS_MON0: | |
| 363 | + case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068: | |
| 364 | + case CS35L41_DSP1_YMEM_PACK_0 ... CS35L41_DSP1_YMEM_PACK_1532: | |
| 365 | + case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114: | |
| 254 | 366 | return true; |
| 255 | 367 | default: |
| 256 | 368 | return false; |
| 257 | 369 | } |
| 258 | 370 | } |
| 259 | 371 | |
| 260 | −bool cs35l41_volatile_reg(struct device *dev, unsigned int reg) | |
| 372 | +static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg) | |
| 261 | 373 | { |
| 262 | 374 | switch (reg) { |
| 263 | 375 | case CS35L41_DEVID: |
| 264 | 376 | case CS35L41_SFT_RESET: |
| 265 | 377 | case CS35L41_FABID: |
| 266 | 378 | case CS35L41_REVID: |
| 379 | + case CS35L41_OTPID: | |
| 380 | + case CS35L41_TEST_KEY_CTL: | |
| 381 | + case CS35L41_USER_KEY_CTL: | |
| 382 | + case CS35L41_PWRMGT_CTL: | |
| 383 | + case CS35L41_WAKESRC_CTL: | |
| 384 | + case CS35L41_PWRMGT_STS: | |
| 267 | 385 | case CS35L41_DTEMP_EN: |
| 268 | 386 | case CS35L41_IRQ1_STATUS: |
| 269 | 387 | case CS35L41_IRQ1_STATUS1: |
| @@ -274,17 +392,6 @@ bool cs35l41_volatile_reg(struct device *dev, unsigned int reg) · 4 unmodified lines | ||
| 274 | 392 | case CS35L41_IRQ1_RAW_STATUS2: |
| 275 | 393 | case CS35L41_IRQ1_RAW_STATUS3: |
| 276 | 394 | case CS35L41_IRQ1_RAW_STATUS4: |
| 277 | − case CS35L41_IRQ1_FRC1: | |
| 278 | − case CS35L41_IRQ1_FRC2: | |
| 279 | − case CS35L41_IRQ1_FRC3: | |
| 280 | − case CS35L41_IRQ1_FRC4: | |
| 281 | − case CS35L41_IRQ1_EDGE1: | |
| 282 | − case CS35L41_IRQ1_EDGE4: | |
| 283 | − case CS35L41_IRQ1_POL1: | |
| 284 | − case CS35L41_IRQ1_POL2: | |
| 285 | − case CS35L41_IRQ1_POL3: | |
| 286 | − case CS35L41_IRQ1_POL4: | |
| 287 | − case CS35L41_IRQ1_DB3: | |
| 288 | 395 | case CS35L41_IRQ2_STATUS: |
| 289 | 396 | case CS35L41_IRQ2_STATUS1: |
| 290 | 397 | case CS35L41_IRQ2_STATUS2: |
| @@ -294,54 +401,20 @@ bool cs35l41_volatile_reg(struct device *dev, unsigned int reg) · 3 unmodified lines | ||
| 294 | 401 | case CS35L41_IRQ2_RAW_STATUS2: |
| 295 | 402 | case CS35L41_IRQ2_RAW_STATUS3: |
| 296 | 403 | case CS35L41_IRQ2_RAW_STATUS4: |
| 297 | − case CS35L41_IRQ2_FRC1: | |
| 298 | − case CS35L41_IRQ2_FRC2: | |
| 299 | − case CS35L41_IRQ2_FRC3: | |
| 300 | − case CS35L41_IRQ2_FRC4: | |
| 301 | − case CS35L41_IRQ2_EDGE1: | |
| 302 | − case CS35L41_IRQ2_EDGE4: | |
| 303 | − case CS35L41_IRQ2_POL1: | |
| 304 | − case CS35L41_IRQ2_POL2: | |
| 305 | − case CS35L41_IRQ2_POL3: | |
| 306 | − case CS35L41_IRQ2_POL4: | |
| 307 | − case CS35L41_IRQ2_DB3: | |
| 308 | 404 | case CS35L41_GPIO_STATUS1: |
| 309 | − case CS35L41_OTP_TRIM_1: | |
| 310 | − case CS35L41_OTP_TRIM_2: | |
| 311 | − case CS35L41_OTP_TRIM_3: | |
| 312 | − case CS35L41_OTP_TRIM_4: | |
| 313 | − case CS35L41_OTP_TRIM_5: | |
| 314 | − case CS35L41_OTP_TRIM_6: | |
| 315 | − case CS35L41_OTP_TRIM_7: | |
| 316 | − case CS35L41_OTP_TRIM_8: | |
| 317 | − case CS35L41_OTP_TRIM_9: | |
| 318 | − case CS35L41_OTP_TRIM_10: | |
| 319 | − case CS35L41_OTP_TRIM_11: | |
| 320 | − case CS35L41_OTP_TRIM_12: | |
| 321 | − case CS35L41_OTP_TRIM_13: | |
| 322 | − case CS35L41_OTP_TRIM_14: | |
| 323 | − case CS35L41_OTP_TRIM_15: | |
| 324 | − case CS35L41_OTP_TRIM_16: | |
| 325 | − case CS35L41_OTP_TRIM_17: | |
| 326 | − case CS35L41_OTP_TRIM_18: | |
| 327 | − case CS35L41_OTP_TRIM_19: | |
| 328 | − case CS35L41_OTP_TRIM_20: | |
| 329 | − case CS35L41_OTP_TRIM_21: | |
| 330 | − case CS35L41_OTP_TRIM_22: | |
| 331 | − case CS35L41_OTP_TRIM_23: | |
| 332 | − case CS35L41_OTP_TRIM_24: | |
| 333 | − case CS35L41_OTP_TRIM_25: | |
| 334 | − case CS35L41_OTP_TRIM_26: | |
| 335 | − case CS35L41_OTP_TRIM_27: | |
| 336 | − case CS35L41_OTP_TRIM_28: | |
| 337 | − case CS35L41_OTP_TRIM_29: | |
| 338 | − case CS35L41_OTP_TRIM_30: | |
| 339 | − case CS35L41_OTP_TRIM_31: | |
| 340 | − case CS35L41_OTP_TRIM_32: | |
| 341 | − case CS35L41_OTP_TRIM_33: | |
| 342 | − case CS35L41_OTP_TRIM_34: | |
| 343 | − case CS35L41_OTP_TRIM_35: | |
| 344 | − case CS35L41_OTP_TRIM_36: | |
| 405 | + case CS35L41_DSP_MBOX_1 ... CS35L41_DSP_VIRT2_MBOX_8: | |
| 406 | + case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068: | |
| 407 | + case CS35L41_DSP1_XMEM_UNPACK32_0 ... CS35L41_DSP1_XMEM_UNPACK32_2046: | |
| 408 | + case CS35L41_DSP1_XMEM_UNPACK24_0 ... CS35L41_DSP1_XMEM_UNPACK24_4093: | |
| 409 | + case CS35L41_DSP1_YMEM_PACK_0 ... CS35L41_DSP1_YMEM_PACK_1532: | |
| 410 | + case CS35L41_DSP1_YMEM_UNPACK32_0 ... CS35L41_DSP1_YMEM_UNPACK32_1022: | |
| 411 | + case CS35L41_DSP1_YMEM_UNPACK24_0 ... CS35L41_DSP1_YMEM_UNPACK24_2045: | |
| 412 | + case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114: | |
| 413 | + case CS35L41_DSP1_SCRATCH1: | |
| 414 | + case CS35L41_DSP1_SCRATCH2: | |
| 415 | + case CS35L41_DSP1_SCRATCH3: | |
| 416 | + case CS35L41_DSP1_SCRATCH4: | |
| 417 | + case CS35L41_DSP1_CCM_CLK_OVERRIDE ... CS35L41_DSP1_WDT_STATUS: | |
| 345 | 418 | case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31: |
| 346 | 419 | return true; |
| 347 | 420 | default: |
| @@ -555,7 +628,46 @@ static const struct cs35l41_otp_packed_element_t otp_map_2[CS35L41_NUM_OTP_ELEM] · 207 unmodified lines | ||
| 555 | 628 | { 0x00017044, 0, 24 }, /*LOT_NUMBER*/ |
| 556 | 629 | }; |
| 557 | 630 | |
| 558 | −const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS] = { | |
| 631 | +static const struct reg_sequence cs35l41_reva0_errata_patch[] = { | |
| 632 | + { 0x00003854, 0x05180240 }, | |
| 633 | + { CS35L41_VIMON_SPKMON_RESYNC, 0x00000000 }, | |
| 634 | + { 0x00004310, 0x00000000 }, | |
| 635 | + { CS35L41_VPVBST_FS_SEL, 0x00000000 }, | |
| 636 | + { CS35L41_OTP_TRIM_30, 0x9091A1C8 }, | |
| 637 | + { 0x00003014, 0x0200EE0E }, | |
| 638 | + { CS35L41_BSTCVRT_DCM_CTRL, 0x00000051 }, | |
| 639 | + { 0x00000054, 0x00000004 }, | |
| 640 | + { CS35L41_IRQ1_DB3, 0x00000000 }, | |
| 641 | + { CS35L41_IRQ2_DB3, 0x00000000 }, | |
| 642 | + { CS35L41_DSP1_YM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 643 | + { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 644 | + { CS35L41_PWR_CTRL2, 0x00000000 }, | |
| 645 | + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, | |
| 646 | +}; | |
| 647 | + | |
| 648 | +static const struct reg_sequence cs35l41_revb0_errata_patch[] = { | |
| 649 | + { CS35L41_VIMON_SPKMON_RESYNC, 0x00000000 }, | |
| 650 | + { 0x00004310, 0x00000000 }, | |
| 651 | + { CS35L41_VPVBST_FS_SEL, 0x00000000 }, | |
| 652 | + { CS35L41_BSTCVRT_DCM_CTRL, 0x00000051 }, | |
| 653 | + { CS35L41_DSP1_YM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 654 | + { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 655 | + { CS35L41_PWR_CTRL2, 0x00000000 }, | |
| 656 | + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, | |
| 657 | +}; | |
| 658 | + | |
| 659 | +static const struct reg_sequence cs35l41_revb2_errata_patch[] = { | |
| 660 | + { CS35L41_VIMON_SPKMON_RESYNC, 0x00000000 }, | |
| 661 | + { 0x00004310, 0x00000000 }, | |
| 662 | + { CS35L41_VPVBST_FS_SEL, 0x00000000 }, | |
| 663 | + { CS35L41_BSTCVRT_DCM_CTRL, 0x00000051 }, | |
| 664 | + { CS35L41_DSP1_YM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 665 | + { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 666 | + { CS35L41_PWR_CTRL2, 0x00000000 }, | |
| 667 | + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, | |
| 668 | +}; | |
| 669 | + | |
| 670 | +static const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[] = { | |
| 559 | 671 | { |
| 560 | 672 | .id = 0x01, |
| 561 | 673 | .map = otp_map_1, |
| @@ -592,3 +704,337 @@ const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS] · 30 unmodified lines | ||
| 592 | 704 | .word_offset = 2, |
| 593 | 705 | }, |
| 594 | 706 | }; |
| 707 | + | |
| 708 | +struct regmap_config cs35l41_regmap_i2c = { | |
| 709 | + .reg_bits = 32, | |
| 710 | + .val_bits = 32, | |
| 711 | + .reg_stride = CS35L41_REGSTRIDE, | |
| 712 | + .reg_format_endian = REGMAP_ENDIAN_BIG, | |
| 713 | + .val_format_endian = REGMAP_ENDIAN_BIG, | |
| 714 | + .max_register = CS35L41_LASTREG, | |
| 715 | + .reg_defaults = cs35l41_reg, | |
| 716 | + .num_reg_defaults = ARRAY_SIZE(cs35l41_reg), | |
| 717 | + .volatile_reg = cs35l41_volatile_reg, | |
| 718 | + .readable_reg = cs35l41_readable_reg, | |
| 719 | + .precious_reg = cs35l41_precious_reg, | |
| 720 | + .cache_type = REGCACHE_RBTREE, | |
| 721 | +}; | |
| 722 | +EXPORT_SYMBOL_GPL(cs35l41_regmap_i2c); | |
| 723 | + | |
| 724 | +struct regmap_config cs35l41_regmap_spi = { | |
| 725 | + .reg_bits = 32, | |
| 726 | + .val_bits = 32, | |
| 727 | + .pad_bits = 16, | |
| 728 | + .reg_stride = CS35L41_REGSTRIDE, | |
| 729 | + .reg_format_endian = REGMAP_ENDIAN_BIG, | |
| 730 | + .val_format_endian = REGMAP_ENDIAN_BIG, | |
| 731 | + .max_register = CS35L41_LASTREG, | |
| 732 | + .reg_defaults = cs35l41_reg, | |
| 733 | + .num_reg_defaults = ARRAY_SIZE(cs35l41_reg), | |
| 734 | + .volatile_reg = cs35l41_volatile_reg, | |
| 735 | + .readable_reg = cs35l41_readable_reg, | |
| 736 | + .precious_reg = cs35l41_precious_reg, | |
| 737 | + .cache_type = REGCACHE_RBTREE, | |
| 738 | +}; | |
| 739 | +EXPORT_SYMBOL_GPL(cs35l41_regmap_spi); | |
| 740 | + | |
| 741 | +static const struct cs35l41_otp_map_element_t *cs35l41_find_otp_map(u32 otp_id) | |
| 742 | +{ | |
| 743 | + int i; | |
| 744 | + | |
| 745 | + for (i = 0; i < ARRAY_SIZE(cs35l41_otp_map_map); i++) { | |
| 746 | + if (cs35l41_otp_map_map[i].id == otp_id) | |
| 747 | + return &cs35l41_otp_map_map[i]; | |
| 748 | + } | |
| 749 | + | |
| 750 | + return NULL; | |
| 751 | +} | |
| 752 | + | |
| 753 | +int cs35l41_test_key_unlock(struct device *dev, struct regmap *regmap) | |
| 754 | +{ | |
| 755 | + static const struct reg_sequence unlock[] = { | |
| 756 | + { CS35L41_TEST_KEY_CTL, 0x00000055 }, | |
| 757 | + { CS35L41_TEST_KEY_CTL, 0x000000AA }, | |
| 758 | + }; | |
| 759 | + int ret; | |
| 760 | + | |
| 761 | + ret = regmap_multi_reg_write(regmap, unlock, ARRAY_SIZE(unlock)); | |
| 762 | + if (ret) | |
| 763 | + dev_err(dev, "Failed to unlock test key: %d\n", ret); | |
| 764 | + | |
| 765 | + return ret; | |
| 766 | +} | |
| 767 | +EXPORT_SYMBOL_GPL(cs35l41_test_key_unlock); | |
| 768 | + | |
| 769 | +int cs35l41_test_key_lock(struct device *dev, struct regmap *regmap) | |
| 770 | +{ | |
| 771 | + static const struct reg_sequence unlock[] = { | |
| 772 | + { CS35L41_TEST_KEY_CTL, 0x000000CC }, | |
| 773 | + { CS35L41_TEST_KEY_CTL, 0x00000033 }, | |
| 774 | + }; | |
| 775 | + int ret; | |
| 776 | + | |
| 777 | + ret = regmap_multi_reg_write(regmap, unlock, ARRAY_SIZE(unlock)); | |
| 778 | + if (ret) | |
| 779 | + dev_err(dev, "Failed to lock test key: %d\n", ret); | |
| 780 | + | |
| 781 | + return ret; | |
| 782 | +} | |
| 783 | +EXPORT_SYMBOL_GPL(cs35l41_test_key_lock); | |
| 784 | + | |
| 785 | +/* Must be called with the TEST_KEY unlocked */ | |
| 786 | +int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap) | |
| 787 | +{ | |
| 788 | + const struct cs35l41_otp_map_element_t *otp_map_match; | |
| 789 | + const struct cs35l41_otp_packed_element_t *otp_map; | |
| 790 | + int bit_offset, word_offset, ret, i; | |
| 791 | + unsigned int bit_sum = 8; | |
| 792 | + u32 otp_val, otp_id_reg; | |
| 793 | + u32 *otp_mem; | |
| 794 | + | |
| 795 | + otp_mem = kmalloc_array(CS35L41_OTP_SIZE_WORDS, sizeof(*otp_mem), GFP_KERNEL); | |
| 796 | + if (!otp_mem) | |
| 797 | + return -ENOMEM; | |
| 798 | + | |
| 799 | + ret = regmap_read(regmap, CS35L41_OTPID, &otp_id_reg); | |
| 800 | + if (ret) { | |
| 801 | + dev_err(dev, "Read OTP ID failed: %d\n", ret); | |
| 802 | + goto err_otp_unpack; | |
| 803 | + } | |
| 804 | + | |
| 805 | + otp_map_match = cs35l41_find_otp_map(otp_id_reg); | |
| 806 | + | |
| 807 | + if (!otp_map_match) { | |
| 808 | + dev_err(dev, "OTP Map matching ID %d not found\n", otp_id_reg); | |
| 809 | + ret = -EINVAL; | |
| 810 | + goto err_otp_unpack; | |
| 811 | + } | |
| 812 | + | |
| 813 | + ret = regmap_bulk_read(regmap, CS35L41_OTP_MEM0, otp_mem, CS35L41_OTP_SIZE_WORDS); | |
| 814 | + if (ret) { | |
| 815 | + dev_err(dev, "Read OTP Mem failed: %d\n", ret); | |
| 816 | + goto err_otp_unpack; | |
| 817 | + } | |
| 818 | + | |
| 819 | + otp_map = otp_map_match->map; | |
| 820 | + | |
| 821 | + bit_offset = otp_map_match->bit_offset; | |
| 822 | + word_offset = otp_map_match->word_offset; | |
| 823 | + | |
| 824 | + for (i = 0; i < otp_map_match->num_elements; i++) { | |
| 825 | + dev_dbg(dev, "bitoffset= %d, word_offset=%d, bit_sum mod 32=%d\n", | |
| 826 | + bit_offset, word_offset, bit_sum % 32); | |
| 827 | + if (bit_offset + otp_map[i].size - 1 >= 32) { | |
| 828 | + otp_val = (otp_mem[word_offset] & | |
| 829 | + GENMASK(31, bit_offset)) >> bit_offset; | |
| 830 | + otp_val |= (otp_mem[++word_offset] & | |
| 831 | + GENMASK(bit_offset + otp_map[i].size - 33, 0)) << | |
| 832 | + (32 - bit_offset); | |
| 833 | + bit_offset += otp_map[i].size - 32; | |
| 834 | + } else { | |
| 835 | + otp_val = (otp_mem[word_offset] & | |
| 836 | + GENMASK(bit_offset + otp_map[i].size - 1, bit_offset) | |
| 837 | + ) >> bit_offset; | |
| 838 | + bit_offset += otp_map[i].size; | |
| 839 | + } | |
| 840 | + bit_sum += otp_map[i].size; | |
| 841 | + | |
| 842 | + if (bit_offset == 32) { | |
| 843 | + bit_offset = 0; | |
| 844 | + word_offset++; | |
| 845 | + } | |
| 846 | + | |
| 847 | + if (otp_map[i].reg != 0) { | |
| 848 | + ret = regmap_update_bits(regmap, otp_map[i].reg, | |
| 849 | + GENMASK(otp_map[i].shift + otp_map[i].size - 1, | |
| 850 | + otp_map[i].shift), | |
| 851 | + otp_val << otp_map[i].shift); | |
| 852 | + if (ret < 0) { | |
| 853 | + dev_err(dev, "Write OTP val failed: %d\n", ret); | |
| 854 | + goto err_otp_unpack; | |
| 855 | + } | |
| 856 | + } | |
| 857 | + } | |
| 858 | + | |
| 859 | + ret = 0; | |
| 860 | + | |
| 861 | +err_otp_unpack: | |
| 862 | + kfree(otp_mem); | |
| 863 | + | |
| 864 | + return ret; | |
| 865 | +} | |
| 866 | +EXPORT_SYMBOL_GPL(cs35l41_otp_unpack); | |
| 867 | + | |
| 868 | +/* Must be called with the TEST_KEY unlocked */ | |
| 869 | +int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsigned int reg_revid) | |
| 870 | +{ | |
| 871 | + char *rev; | |
| 872 | + int ret; | |
| 873 | + | |
| 874 | + switch (reg_revid) { | |
| 875 | + case CS35L41_REVID_A0: | |
| 876 | + ret = regmap_register_patch(reg, cs35l41_reva0_errata_patch, | |
| 877 | + ARRAY_SIZE(cs35l41_reva0_errata_patch)); | |
| 878 | + rev = "A0"; | |
| 879 | + break; | |
| 880 | + case CS35L41_REVID_B0: | |
| 881 | + ret = regmap_register_patch(reg, cs35l41_revb0_errata_patch, | |
| 882 | + ARRAY_SIZE(cs35l41_revb0_errata_patch)); | |
| 883 | + rev = "B0"; | |
| 884 | + break; | |
| 885 | + case CS35L41_REVID_B2: | |
| 886 | + ret = regmap_register_patch(reg, cs35l41_revb2_errata_patch, | |
| 887 | + ARRAY_SIZE(cs35l41_revb2_errata_patch)); | |
| 888 | + rev = "B2"; | |
| 889 | + break; | |
| 890 | + default: | |
| 891 | + ret = -EINVAL; | |
| 892 | + rev = "XX"; | |
| 893 | + break; | |
| 894 | + } | |
| 895 | + | |
| 896 | + if (ret) | |
| 897 | + dev_err(dev, "Failed to apply %s errata patch: %d\n", rev, ret); | |
| 898 | + | |
| 899 | + ret = regmap_write(reg, CS35L41_DSP1_CCM_CORE_CTRL, 0); | |
| 900 | + if (ret < 0) | |
| 901 | + dev_err(dev, "Write CCM_CORE_CTRL failed: %d\n", ret); | |
| 902 | + | |
| 903 | + return ret; | |
| 904 | +} | |
| 905 | +EXPORT_SYMBOL_GPL(cs35l41_register_errata_patch); | |
| 906 | + | |
| 907 | +int cs35l41_set_channels(struct device *dev, struct regmap *reg, | |
| 908 | + unsigned int tx_num, unsigned int *tx_slot, | |
| 909 | + unsigned int rx_num, unsigned int *rx_slot) | |
| 910 | +{ | |
| 911 | + unsigned int val, mask; | |
| 912 | + int i; | |
| 913 | + | |
| 914 | + if (tx_num > 4 || rx_num > 2) | |
| 915 | + return -EINVAL; | |
| 916 | + | |
| 917 | + val = 0; | |
| 918 | + mask = 0; | |
| 919 | + for (i = 0; i < rx_num; i++) { | |
| 920 | + dev_dbg(dev, "rx slot %d position = %d\n", i, rx_slot[i]); | |
| 921 | + val |= rx_slot[i] << (i * 8); | |
| 922 | + mask |= 0x3F << (i * 8); | |
| 923 | + } | |
| 924 | + regmap_update_bits(reg, CS35L41_SP_FRAME_RX_SLOT, mask, val); | |
| 925 | + | |
| 926 | + val = 0; | |
| 927 | + mask = 0; | |
| 928 | + for (i = 0; i < tx_num; i++) { | |
| 929 | + dev_dbg(dev, "tx slot %d position = %d\n", i, tx_slot[i]); | |
| 930 | + val |= tx_slot[i] << (i * 8); | |
| 931 | + mask |= 0x3F << (i * 8); | |
| 932 | + } | |
| 933 | + regmap_update_bits(reg, CS35L41_SP_FRAME_TX_SLOT, mask, val); | |
| 934 | + | |
| 935 | + return 0; | |
| 936 | +} | |
| 937 | +EXPORT_SYMBOL_GPL(cs35l41_set_channels); | |
| 938 | + | |
| 939 | +static const unsigned char cs35l41_bst_k1_table[4][5] = { | |
| 940 | + { 0x24, 0x32, 0x32, 0x4F, 0x57 }, | |
| 941 | + { 0x24, 0x32, 0x32, 0x4F, 0x57 }, | |
| 942 | + { 0x40, 0x32, 0x32, 0x4F, 0x57 }, | |
| 943 | + { 0x40, 0x32, 0x32, 0x4F, 0x57 } | |
| 944 | +}; | |
| 945 | + | |
| 946 | +static const unsigned char cs35l41_bst_k2_table[4][5] = { | |
| 947 | + { 0x24, 0x49, 0x66, 0xA3, 0xEA }, | |
| 948 | + { 0x24, 0x49, 0x66, 0xA3, 0xEA }, | |
| 949 | + { 0x48, 0x49, 0x66, 0xA3, 0xEA }, | |
| 950 | + { 0x48, 0x49, 0x66, 0xA3, 0xEA } | |
| 951 | +}; | |
| 952 | + | |
| 953 | +static const unsigned char cs35l41_bst_slope_table[4] = { | |
| 954 | + 0x75, 0x6B, 0x3B, 0x28 | |
| 955 | +}; | |
| 956 | + | |
| 957 | + | |
| 958 | +int cs35l41_boost_config(struct device *dev, struct regmap *regmap, int boost_ind, int boost_cap, | |
| 959 | + int boost_ipk) | |
| 960 | +{ | |
| 961 | + unsigned char bst_lbst_val, bst_cbst_range, bst_ipk_scaled; | |
| 962 | + int ret; | |
| 963 | + | |
| 964 | + switch (boost_ind) { | |
| 965 | + case 1000: /* 1.0 uH */ | |
| 966 | + bst_lbst_val = 0; | |
| 967 | + break; | |
| 968 | + case 1200: /* 1.2 uH */ | |
| 969 | + bst_lbst_val = 1; | |
| 970 | + break; | |
| 971 | + case 1500: /* 1.5 uH */ | |
| 972 | + bst_lbst_val = 2; | |
| 973 | + break; | |
| 974 | + case 2200: /* 2.2 uH */ | |
| 975 | + bst_lbst_val = 3; | |
| 976 | + break; | |
| 977 | + default: | |
| 978 | + dev_err(dev, "Invalid boost inductor value: %d nH\n", boost_ind); | |
| 979 | + return -EINVAL; | |
| 980 | + } | |
| 981 | + | |
| 982 | + switch (boost_cap) { | |
| 983 | + case 0 ... 19: | |
| 984 | + bst_cbst_range = 0; | |
| 985 | + break; | |
| 986 | + case 20 ... 50: | |
| 987 | + bst_cbst_range = 1; | |
| 988 | + break; | |
| 989 | + case 51 ... 100: | |
| 990 | + bst_cbst_range = 2; | |
| 991 | + break; | |
| 992 | + case 101 ... 200: | |
| 993 | + bst_cbst_range = 3; | |
| 994 | + break; | |
| 995 | + default: /* 201 uF and greater */ | |
| 996 | + bst_cbst_range = 4; | |
| 997 | + } | |
| 998 | + | |
| 999 | + ret = regmap_update_bits(regmap, CS35L41_BSTCVRT_COEFF, | |
| 1000 | + CS35L41_BST_K1_MASK | CS35L41_BST_K2_MASK, | |
| 1001 | + cs35l41_bst_k1_table[bst_lbst_val][bst_cbst_range] | |
| 1002 | + << CS35L41_BST_K1_SHIFT | | |
| 1003 | + cs35l41_bst_k2_table[bst_lbst_val][bst_cbst_range] | |
| 1004 | + << CS35L41_BST_K2_SHIFT); | |
| 1005 | + if (ret) { | |
| 1006 | + dev_err(dev, "Failed to write boost coefficients: %d\n", ret); | |
| 1007 | + return ret; | |
| 1008 | + } | |
| 1009 | + | |
| 1010 | + ret = regmap_update_bits(regmap, CS35L41_BSTCVRT_SLOPE_LBST, | |
| 1011 | + CS35L41_BST_SLOPE_MASK | CS35L41_BST_LBST_VAL_MASK, | |
| 1012 | + cs35l41_bst_slope_table[bst_lbst_val] | |
| 1013 | + << CS35L41_BST_SLOPE_SHIFT | | |
| 1014 | + bst_lbst_val << CS35L41_BST_LBST_VAL_SHIFT); | |
| 1015 | + if (ret) { | |
| 1016 | + dev_err(dev, "Failed to write boost slope/inductor value: %d\n", ret); | |
| 1017 | + return ret; | |
| 1018 | + } | |
| 1019 | + | |
| 1020 | + if (boost_ipk < 1600 || boost_ipk > 4500) { | |
| 1021 | + dev_err(dev, "Invalid boost inductor peak current: %d mA\n", boost_ipk); | |
| 1022 | + return -EINVAL; | |
| 1023 | + } | |
| 1024 | + bst_ipk_scaled = ((boost_ipk - 1600) / 50) + 0x10; | |
| 1025 | + | |
| 1026 | + ret = regmap_update_bits(regmap, CS35L41_BSTCVRT_PEAK_CUR, CS35L41_BST_IPK_MASK, | |
| 1027 | + bst_ipk_scaled << CS35L41_BST_IPK_SHIFT); | |
| 1028 | + if (ret) { | |
| 1029 | + dev_err(dev, "Failed to write boost inductor peak current: %d\n", ret); | |
| 1030 | + return ret; | |
| 1031 | + } | |
| 1032 | + | |
| 1033 | + return 0; | |
| 1034 | +} | |
| 1035 | +EXPORT_SYMBOL_GPL(cs35l41_boost_config); | |
| 1036 | + | |
| 1037 | +MODULE_DESCRIPTION("CS35L41 library"); | |
| 1038 | +MODULE_AUTHOR("David Rhodes, Cirrus Logic Inc, <david.rhodes@cirrus.com>"); | |
| 1039 | +MODULE_AUTHOR("Lucas Tanure, Cirrus Logic Inc, <tanureal@opensource.cirrus.com>"); | |
| 1040 | +MODULE_LICENSE("GPL"); | |
| @@ -15,28 +15,13 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <linux/platform_device.h> |
| 16 | 16 | #include <linux/spi/spi.h> |
| 17 | 17 | |
| 18 | −#include <sound/cs35l41.h> | |
| 19 | 18 | #include "cs35l41.h" |
| 20 | 19 | |
| 21 | −static struct regmap_config cs35l41_regmap_spi = { | |
| 22 | − .reg_bits = 32, | |
| 23 | − .val_bits = 32, | |
| 24 | − .pad_bits = 16, | |
| 25 | − .reg_stride = CS35L41_REGSTRIDE, | |
| 26 | − .reg_format_endian = REGMAP_ENDIAN_BIG, | |
| 27 | − .val_format_endian = REGMAP_ENDIAN_BIG, | |
| 28 | − .max_register = CS35L41_LASTREG, | |
| 29 | − .reg_defaults = cs35l41_reg, | |
| 30 | − .num_reg_defaults = ARRAY_SIZE(cs35l41_reg), | |
| 31 | − .volatile_reg = cs35l41_volatile_reg, | |
| 32 | − .readable_reg = cs35l41_readable_reg, | |
| 33 | − .precious_reg = cs35l41_precious_reg, | |
| 34 | − .cache_type = REGCACHE_RBTREE, | |
| 35 | −}; | |
| 36 | − | |
| 37 | 20 | static const struct spi_device_id cs35l41_id_spi[] = { |
| 38 | 21 | { "cs35l40", 0 }, |
| 39 | 22 | { "cs35l41", 0 }, |
| 23 | + { "cs35l51", 0 }, | |
| 24 | + { "cs35l53", 0 }, | |
| 40 | 25 | {} |
| 41 | 26 | }; |
| 42 | 27 | |
| @@ -99,6 +84,7 @@ MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_match); · 56 unmodified lines | ||
| 99 | 84 | static struct spi_driver cs35l41_spi_driver = { |
| 100 | 85 | .driver = { |
| 101 | 86 | .name = "cs35l41", |
| 87 | + .pm = &cs35l41_pm_ops, | |
| 102 | 88 | .of_match_table = of_match_ptr(cs35l41_of_match), |
| 103 | 89 | .acpi_match_table = ACPI_PTR(cs35l41_acpi_match), |
| 104 | 90 | }, |
| @@ -13,8 +13,8 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <linux/module.h> |
| 14 | 14 | #include <linux/moduleparam.h> |
| 15 | 15 | #include <linux/of_device.h> |
| 16 | +#include <linux/pm_runtime.h> | |
| 16 | 17 | #include <linux/property.h> |
| 17 | −#include <linux/slab.h> | |
| 18 | 18 | #include <sound/initval.h> |
| 19 | 19 | #include <sound/pcm.h> |
| 20 | 20 | #include <sound/pcm_params.h> |
| @@ -151,24 +151,6 @@ static const struct cs35l41_fs_mon_config cs35l41_fs_mon[] = { · 130 unmodified lines | ||
| 151 | 151 | { 6144000, 16, 24 }, |
| 152 | 152 | }; |
| 153 | 153 | |
| 154 | −static const unsigned char cs35l41_bst_k1_table[4][5] = { | |
| 155 | − { 0x24, 0x32, 0x32, 0x4F, 0x57 }, | |
| 156 | − { 0x24, 0x32, 0x32, 0x4F, 0x57 }, | |
| 157 | − { 0x40, 0x32, 0x32, 0x4F, 0x57 }, | |
| 158 | − { 0x40, 0x32, 0x32, 0x4F, 0x57 } | |
| 159 | −}; | |
| 160 | − | |
| 161 | −static const unsigned char cs35l41_bst_k2_table[4][5] = { | |
| 162 | − { 0x24, 0x49, 0x66, 0xA3, 0xEA }, | |
| 163 | − { 0x24, 0x49, 0x66, 0xA3, 0xEA }, | |
| 164 | − { 0x48, 0x49, 0x66, 0xA3, 0xEA }, | |
| 165 | − { 0x48, 0x49, 0x66, 0xA3, 0xEA } | |
| 166 | −}; | |
| 167 | − | |
| 168 | −static const unsigned char cs35l41_bst_slope_table[4] = { | |
| 169 | − 0x75, 0x6B, 0x3B, 0x28 | |
| 170 | −}; | |
| 171 | − | |
| 172 | 154 | static int cs35l41_get_fs_mon_config_index(int freq) |
| 173 | 155 | { |
| 174 | 156 | int i; |
| @@ -197,6 +179,134 @@ static SOC_ENUM_SINGLE_DECL(pcm_sft_ramp, · 22 unmodified lines | ||
| 197 | 179 | CS35L41_AMP_DIG_VOL_CTRL, 0, |
| 198 | 180 | cs35l41_pcm_sftramp_text); |
| 199 | 181 | |
| 182 | +static int cs35l41_dsp_preload_ev(struct snd_soc_dapm_widget *w, | |
| 183 | + struct snd_kcontrol *kcontrol, int event) | |
| 184 | +{ | |
| 185 | + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); | |
| 186 | + struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); | |
| 187 | + int ret; | |
| 188 | + | |
| 189 | + switch (event) { | |
| 190 | + case SND_SOC_DAPM_PRE_PMU: | |
| 191 | + if (cs35l41->dsp.cs_dsp.booted) | |
| 192 | + return 0; | |
| 193 | + | |
| 194 | + return wm_adsp_early_event(w, kcontrol, event); | |
| 195 | + case SND_SOC_DAPM_PRE_PMD: | |
| 196 | + if (cs35l41->dsp.preloaded) | |
| 197 | + return 0; | |
| 198 | + | |
| 199 | + if (cs35l41->dsp.cs_dsp.running) { | |
| 200 | + ret = wm_adsp_event(w, kcontrol, event); | |
| 201 | + if (ret) | |
| 202 | + return ret; | |
| 203 | + } | |
| 204 | + | |
| 205 | + return wm_adsp_early_event(w, kcontrol, event); | |
| 206 | + default: | |
| 207 | + return 0; | |
| 208 | + } | |
| 209 | +} | |
| 210 | + | |
| 211 | +static bool cs35l41_check_cspl_mbox_sts(enum cs35l41_cspl_mbox_cmd cmd, | |
| 212 | + enum cs35l41_cspl_mbox_status sts) | |
| 213 | +{ | |
| 214 | + switch (cmd) { | |
| 215 | + case CSPL_MBOX_CMD_NONE: | |
| 216 | + case CSPL_MBOX_CMD_UNKNOWN_CMD: | |
| 217 | + return true; | |
| 218 | + case CSPL_MBOX_CMD_PAUSE: | |
| 219 | + case CSPL_MBOX_CMD_OUT_OF_HIBERNATE: | |
| 220 | + return (sts == CSPL_MBOX_STS_PAUSED); | |
| 221 | + case CSPL_MBOX_CMD_RESUME: | |
| 222 | + return (sts == CSPL_MBOX_STS_RUNNING); | |
| 223 | + case CSPL_MBOX_CMD_REINIT: | |
| 224 | + return (sts == CSPL_MBOX_STS_RUNNING); | |
| 225 | + case CSPL_MBOX_CMD_STOP_PRE_REINIT: | |
| 226 | + return (sts == CSPL_MBOX_STS_RDY_FOR_REINIT); | |
| 227 | + default: | |
| 228 | + return false; | |
| 229 | + } | |
| 230 | +} | |
| 231 | + | |
| 232 | +static int cs35l41_set_cspl_mbox_cmd(struct cs35l41_private *cs35l41, | |
| 233 | + enum cs35l41_cspl_mbox_cmd cmd) | |
| 234 | +{ | |
| 235 | + unsigned int sts = 0, i; | |
| 236 | + int ret; | |
| 237 | + | |
| 238 | + // Set mailbox cmd | |
| 239 | + ret = regmap_write(cs35l41->regmap, CS35L41_DSP_VIRT1_MBOX_1, cmd); | |
| 240 | + if (ret < 0) { | |
| 241 | + if (cmd != CSPL_MBOX_CMD_OUT_OF_HIBERNATE) | |
| 242 | + dev_err(cs35l41->dev, "Failed to write MBOX: %d\n", ret); | |
| 243 | + return ret; | |
| 244 | + } | |
| 245 | + | |
| 246 | + // Read mailbox status and verify it is appropriate for the given cmd | |
| 247 | + for (i = 0; i < 5; i++) { | |
| 248 | + usleep_range(1000, 1100); | |
| 249 | + | |
| 250 | + ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &sts); | |
| 251 | + if (ret < 0) { | |
| 252 | + dev_err(cs35l41->dev, "Failed to read MBOX STS: %d\n", ret); | |
| 253 | + continue; | |
| 254 | + } | |
| 255 | + | |
| 256 | + if (!cs35l41_check_cspl_mbox_sts(cmd, sts)) { | |
| 257 | + dev_dbg(cs35l41->dev, | |
| 258 | + "[%u] cmd %u returned invalid sts %u", | |
| 259 | + i, cmd, sts); | |
| 260 | + } else { | |
| 261 | + return 0; | |
| 262 | + } | |
| 263 | + } | |
| 264 | + | |
| 265 | + dev_err(cs35l41->dev, | |
| 266 | + "Failed to set mailbox cmd %u (status %u)\n", | |
| 267 | + cmd, sts); | |
| 268 | + | |
| 269 | + return -ENOMSG; | |
| 270 | +} | |
| 271 | + | |
| 272 | +static int cs35l41_dsp_audio_ev(struct snd_soc_dapm_widget *w, | |
| 273 | + struct snd_kcontrol *kcontrol, int event) | |
| 274 | +{ | |
| 275 | + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); | |
| 276 | + struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); | |
| 277 | + unsigned int fw_status; | |
| 278 | + int ret; | |
| 279 | + | |
| 280 | + switch (event) { | |
| 281 | + case SND_SOC_DAPM_POST_PMU: | |
| 282 | + if (!cs35l41->dsp.cs_dsp.running) | |
| 283 | + return wm_adsp_event(w, kcontrol, event); | |
| 284 | + | |
| 285 | + ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status); | |
| 286 | + if (ret < 0) { | |
| 287 | + dev_err(cs35l41->dev, | |
| 288 | + "Failed to read firmware status: %d\n", ret); | |
| 289 | + return ret; | |
| 290 | + } | |
| 291 | + | |
| 292 | + switch (fw_status) { | |
| 293 | + case CSPL_MBOX_STS_RUNNING: | |
| 294 | + case CSPL_MBOX_STS_PAUSED: | |
| 295 | + break; | |
| 296 | + default: | |
| 297 | + dev_err(cs35l41->dev, "Firmware status is invalid: %u\n", | |
| 298 | + fw_status); | |
| 299 | + return -EINVAL; | |
| 300 | + } | |
| 301 | + | |
| 302 | + return cs35l41_set_cspl_mbox_cmd(cs35l41, CSPL_MBOX_CMD_RESUME); | |
| 303 | + case SND_SOC_DAPM_PRE_PMD: | |
| 304 | + return cs35l41_set_cspl_mbox_cmd(cs35l41, CSPL_MBOX_CMD_PAUSE); | |
| 305 | + default: | |
| 306 | + return 0; | |
| 307 | + } | |
| 308 | +} | |
| 309 | + | |
| 200 | 310 | static const char * const cs35l41_pcm_source_texts[] = {"ASP", "DSP"}; |
| 201 | 311 | static const unsigned int cs35l41_pcm_source_values[] = {0x08, 0x32}; |
| 202 | 312 | static SOC_VALUE_ENUM_SINGLE_DECL(cs35l41_pcm_source_enum, |
| @@ -255,6 +365,24 @@ static SOC_VALUE_ENUM_SINGLE_DECL(cs35l41_asptx4_enum, · 52 unmodified lines | ||
| 255 | 365 | static const struct snd_kcontrol_new asp_tx4_mux = |
| 256 | 366 | SOC_DAPM_ENUM("ASPTX4 SRC", cs35l41_asptx4_enum); |
| 257 | 367 | |
| 368 | +static SOC_VALUE_ENUM_SINGLE_DECL(cs35l41_dsprx1_enum, | |
| 369 | + CS35L41_DSP1_RX1_SRC, | |
| 370 | + 0, CS35L41_ASP_SOURCE_MASK, | |
| 371 | + cs35l41_tx_input_texts, | |
| 372 | + cs35l41_tx_input_values); | |
| 373 | + | |
| 374 | +static const struct snd_kcontrol_new dsp_rx1_mux = | |
| 375 | + SOC_DAPM_ENUM("DSPRX1 SRC", cs35l41_dsprx1_enum); | |
| 376 | + | |
| 377 | +static SOC_VALUE_ENUM_SINGLE_DECL(cs35l41_dsprx2_enum, | |
| 378 | + CS35L41_DSP1_RX2_SRC, | |
| 379 | + 0, CS35L41_ASP_SOURCE_MASK, | |
| 380 | + cs35l41_tx_input_texts, | |
| 381 | + cs35l41_tx_input_values); | |
| 382 | + | |
| 383 | +static const struct snd_kcontrol_new dsp_rx2_mux = | |
| 384 | + SOC_DAPM_ENUM("DSPRX2 SRC", cs35l41_dsprx2_enum); | |
| 385 | + | |
| 258 | 386 | static const struct snd_kcontrol_new cs35l41_aud_controls[] = { |
| 259 | 387 | SOC_SINGLE_SX_TLV("Digital PCM Volume", CS35L41_AMP_DIG_VOL_CTRL, |
| 260 | 388 | 3, 0x4CF, 0x391, dig_vol_tlv), |
| @@ -282,130 +410,10 @@ static const struct snd_kcontrol_new cs35l41_aud_controls[] = { · 21 unmodified lines | ||
| 282 | 410 | CS35L41_AMP_INV_PCM_SHIFT, 1, 0), |
| 283 | 411 | SOC_SINGLE("Amp Gain ZC", CS35L41_AMP_GAIN_CTRL, |
| 284 | 412 | CS35L41_AMP_GAIN_ZC_SHIFT, 1, 0), |
| 413 | + WM_ADSP2_PRELOAD_SWITCH("DSP1", 1), | |
| 414 | + WM_ADSP_FW_CONTROL("DSP1", 0), | |
| 285 | 415 | }; |
| 286 | 416 | |
| 287 | −static const struct cs35l41_otp_map_element_t *cs35l41_find_otp_map(u32 otp_id) | |
| 288 | −{ | |
| 289 | − int i; | |
| 290 | − | |
| 291 | − for (i = 0; i < ARRAY_SIZE(cs35l41_otp_map_map); i++) { | |
| 292 | − if (cs35l41_otp_map_map[i].id == otp_id) | |
| 293 | − return &cs35l41_otp_map_map[i]; | |
| 294 | − } | |
| 295 | − | |
| 296 | − return NULL; | |
| 297 | −} | |
| 298 | − | |
| 299 | −static int cs35l41_otp_unpack(void *data) | |
| 300 | −{ | |
| 301 | − const struct cs35l41_otp_map_element_t *otp_map_match; | |
| 302 | − const struct cs35l41_otp_packed_element_t *otp_map; | |
| 303 | − struct cs35l41_private *cs35l41 = data; | |
| 304 | − int bit_offset, word_offset, ret, i; | |
| 305 | − unsigned int bit_sum = 8; | |
| 306 | − u32 otp_val, otp_id_reg; | |
| 307 | − u32 *otp_mem; | |
| 308 | − | |
| 309 | − otp_mem = kmalloc_array(CS35L41_OTP_SIZE_WORDS, sizeof(*otp_mem), GFP_KERNEL); | |
| 310 | − if (!otp_mem) | |
| 311 | − return -ENOMEM; | |
| 312 | − | |
| 313 | − ret = regmap_read(cs35l41->regmap, CS35L41_OTPID, &otp_id_reg); | |
| 314 | − if (ret < 0) { | |
| 315 | − dev_err(cs35l41->dev, "Read OTP ID failed: %d\n", ret); | |
| 316 | − goto err_otp_unpack; | |
| 317 | − } | |
| 318 | − | |
| 319 | − otp_map_match = cs35l41_find_otp_map(otp_id_reg); | |
| 320 | − | |
| 321 | − if (!otp_map_match) { | |
| 322 | − dev_err(cs35l41->dev, "OTP Map matching ID %d not found\n", | |
| 323 | − otp_id_reg); | |
| 324 | − ret = -EINVAL; | |
| 325 | − goto err_otp_unpack; | |
| 326 | − } | |
| 327 | − | |
| 328 | − ret = regmap_bulk_read(cs35l41->regmap, CS35L41_OTP_MEM0, otp_mem, | |
| 329 | − CS35L41_OTP_SIZE_WORDS); | |
| 330 | − if (ret < 0) { | |
| 331 | − dev_err(cs35l41->dev, "Read OTP Mem failed: %d\n", ret); | |
| 332 | − goto err_otp_unpack; | |
| 333 | − } | |
| 334 | − | |
| 335 | − otp_map = otp_map_match->map; | |
| 336 | − | |
| 337 | − bit_offset = otp_map_match->bit_offset; | |
| 338 | − word_offset = otp_map_match->word_offset; | |
| 339 | − | |
| 340 | − ret = regmap_write(cs35l41->regmap, CS35L41_TEST_KEY_CTL, 0x00000055); | |
| 341 | − if (ret < 0) { | |
| 342 | − dev_err(cs35l41->dev, "Write Unlock key failed 1/2: %d\n", ret); | |
| 343 | − goto err_otp_unpack; | |
| 344 | − } | |
| 345 | − ret = regmap_write(cs35l41->regmap, CS35L41_TEST_KEY_CTL, 0x000000AA); | |
| 346 | − if (ret < 0) { | |
| 347 | − dev_err(cs35l41->dev, "Write Unlock key failed 2/2: %d\n", ret); | |
| 348 | − goto err_otp_unpack; | |
| 349 | − } | |
| 350 | − | |
| 351 | − for (i = 0; i < otp_map_match->num_elements; i++) { | |
| 352 | − dev_dbg(cs35l41->dev, | |
| 353 | − "bitoffset= %d, word_offset=%d, bit_sum mod 32=%d\n", | |
| 354 | − bit_offset, word_offset, bit_sum % 32); | |
| 355 | − if (bit_offset + otp_map[i].size - 1 >= 32) { | |
| 356 | − otp_val = (otp_mem[word_offset] & | |
| 357 | − GENMASK(31, bit_offset)) >> | |
| 358 | − bit_offset; | |
| 359 | − otp_val |= (otp_mem[++word_offset] & | |
| 360 | − GENMASK(bit_offset + | |
| 361 | − otp_map[i].size - 33, 0)) << | |
| 362 | − (32 - bit_offset); | |
| 363 | − bit_offset += otp_map[i].size - 32; | |
| 364 | − } else { | |
| 365 | − otp_val = (otp_mem[word_offset] & | |
| 366 | − GENMASK(bit_offset + otp_map[i].size - 1, | |
| 367 | − bit_offset)) >> bit_offset; | |
| 368 | − bit_offset += otp_map[i].size; | |
| 369 | − } | |
| 370 | − bit_sum += otp_map[i].size; | |
| 371 | − | |
| 372 | − if (bit_offset == 32) { | |
| 373 | − bit_offset = 0; | |
| 374 | − word_offset++; | |
| 375 | − } | |
| 376 | − | |
| 377 | − if (otp_map[i].reg != 0) { | |
| 378 | − ret = regmap_update_bits(cs35l41->regmap, | |
| 379 | − otp_map[i].reg, | |
| 380 | − GENMASK(otp_map[i].shift + | |
| 381 | − otp_map[i].size - 1, | |
| 382 | − otp_map[i].shift), | |
| 383 | − otp_val << otp_map[i].shift); | |
| 384 | − if (ret < 0) { | |
| 385 | − dev_err(cs35l41->dev, "Write OTP val failed: %d\n", | |
| 386 | − ret); | |
| 387 | − goto err_otp_unpack; | |
| 388 | − } | |
| 389 | − } | |
| 390 | − } | |
| 391 | − | |
| 392 | − ret = regmap_write(cs35l41->regmap, CS35L41_TEST_KEY_CTL, 0x000000CC); | |
| 393 | − if (ret < 0) { | |
| 394 | − dev_err(cs35l41->dev, "Write Lock key failed 1/2: %d\n", ret); | |
| 395 | − goto err_otp_unpack; | |
| 396 | − } | |
| 397 | − ret = regmap_write(cs35l41->regmap, CS35L41_TEST_KEY_CTL, 0x00000033); | |
| 398 | − if (ret < 0) { | |
| 399 | − dev_err(cs35l41->dev, "Write Lock key failed 2/2: %d\n", ret); | |
| 400 | − goto err_otp_unpack; | |
| 401 | − } | |
| 402 | − ret = 0; | |
| 403 | − | |
| 404 | −err_otp_unpack: | |
| 405 | − kfree(otp_mem); | |
| 406 | − return ret; | |
| 407 | −} | |
| 408 | − | |
| 409 | 417 | static irqreturn_t cs35l41_irq(int irq, void *data) |
| 410 | 418 | { |
| 411 | 419 | struct cs35l41_private *cs35l41 = data; |
| @@ -414,6 +422,8 @@ static irqreturn_t cs35l41_irq(int irq, void *data) · 2 unmodified lines | ||
| 414 | 422 | int ret = IRQ_NONE; |
| 415 | 423 | unsigned int i; |
| 416 | 424 | |
| 425 | + pm_runtime_get_sync(cs35l41->dev); | |
| 426 | + | |
| 417 | 427 | for (i = 0; i < ARRAY_SIZE(status); i++) { |
| 418 | 428 | regmap_read(cs35l41->regmap, |
| 419 | 429 | CS35L41_IRQ1_STATUS1 + (i * CS35L41_REGSTRIDE), |
| @@ -426,7 +436,7 @@ static irqreturn_t cs35l41_irq(int irq, void *data) · 6 unmodified lines | ||
| 426 | 436 | /* Check to see if unmasked bits are active */ |
| 427 | 437 | if (!(status[0] & ~masks[0]) && !(status[1] & ~masks[1]) && |
| 428 | 438 | !(status[2] & ~masks[2]) && !(status[3] & ~masks[3])) |
| 429 | − return IRQ_NONE; | |
| 439 | + goto done; | |
| 430 | 440 | |
| 431 | 441 | if (status[3] & CS35L41_OTP_BOOT_DONE) { |
| 432 | 442 | regmap_update_bits(cs35l41->regmap, CS35L41_IRQ1_MASK4, |
| @@ -531,23 +541,27 @@ static irqreturn_t cs35l41_irq(int irq, void *data) · 98 unmodified lines | ||
| 531 | 541 | ret = IRQ_HANDLED; |
| 532 | 542 | } |
| 533 | 543 | |
| 544 | +done: | |
| 545 | + pm_runtime_mark_last_busy(cs35l41->dev); | |
| 546 | + pm_runtime_put_autosuspend(cs35l41->dev); | |
| 547 | + | |
| 534 | 548 | return ret; |
| 535 | 549 | } |
| 536 | 550 | |
| 537 | 551 | static const struct reg_sequence cs35l41_pup_patch[] = { |
| 538 | − { 0x00000040, 0x00000055 }, | |
| 539 | − { 0x00000040, 0x000000AA }, | |
| 552 | + { CS35L41_TEST_KEY_CTL, 0x00000055 }, | |
| 553 | + { CS35L41_TEST_KEY_CTL, 0x000000AA }, | |
| 540 | 554 | { 0x00002084, 0x002F1AA0 }, |
| 541 | − { 0x00000040, 0x000000CC }, | |
| 542 | − { 0x00000040, 0x00000033 }, | |
| 555 | + { CS35L41_TEST_KEY_CTL, 0x000000CC }, | |
| 556 | + { CS35L41_TEST_KEY_CTL, 0x00000033 }, | |
| 543 | 557 | }; |
| 544 | 558 | |
| 545 | 559 | static const struct reg_sequence cs35l41_pdn_patch[] = { |
| 546 | − { 0x00000040, 0x00000055 }, | |
| 547 | − { 0x00000040, 0x000000AA }, | |
| 560 | + { CS35L41_TEST_KEY_CTL, 0x00000055 }, | |
| 561 | + { CS35L41_TEST_KEY_CTL, 0x000000AA }, | |
| 548 | 562 | { 0x00002084, 0x002F1AA3 }, |
| 549 | − { 0x00000040, 0x000000CC }, | |
| 550 | − { 0x00000040, 0x00000033 }, | |
| 563 | + { CS35L41_TEST_KEY_CTL, 0x000000CC }, | |
| 564 | + { CS35L41_TEST_KEY_CTL, 0x00000033 }, | |
| 551 | 565 | }; |
| 552 | 566 | |
| 553 | 567 | static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w, |
| @@ -596,6 +610,14 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w, · 42 unmodified lines | ||
| 596 | 610 | } |
| 597 | 611 | |
| 598 | 612 | static const struct snd_soc_dapm_widget cs35l41_dapm_widgets[] = { |
| 613 | + SND_SOC_DAPM_SPK("DSP1 Preload", NULL), | |
| 614 | + SND_SOC_DAPM_SUPPLY_S("DSP1 Preloader", 100, SND_SOC_NOPM, 0, 0, | |
| 615 | + cs35l41_dsp_preload_ev, | |
| 616 | + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), | |
| 617 | + SND_SOC_DAPM_OUT_DRV_E("DSP1", SND_SOC_NOPM, 0, 0, NULL, 0, | |
| 618 | + cs35l41_dsp_audio_ev, | |
| 619 | + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), | |
| 620 | + | |
| 599 | 621 | SND_SOC_DAPM_OUTPUT("SPK"), |
| 600 | 622 | |
| 601 | 623 | SND_SOC_DAPM_AIF_IN("ASPRX1", NULL, 0, CS35L41_SP_ENABLES, 16, 0), |
| @@ -611,11 +633,18 @@ static const struct snd_soc_dapm_widget cs35l41_dapm_widgets[] = { · 9 unmodified lines | ||
| 611 | 633 | SND_SOC_DAPM_SIGGEN("VBST"), |
| 612 | 634 | SND_SOC_DAPM_SIGGEN("TEMP"), |
| 613 | 635 | |
| 614 | − SND_SOC_DAPM_ADC("VMON ADC", NULL, CS35L41_PWR_CTRL2, 12, 0), | |
| 615 | − SND_SOC_DAPM_ADC("IMON ADC", NULL, CS35L41_PWR_CTRL2, 13, 0), | |
| 616 | − SND_SOC_DAPM_ADC("VPMON ADC", NULL, CS35L41_PWR_CTRL2, 8, 0), | |
| 617 | − SND_SOC_DAPM_ADC("VBSTMON ADC", NULL, CS35L41_PWR_CTRL2, 9, 0), | |
| 618 | − SND_SOC_DAPM_ADC("TEMPMON ADC", NULL, CS35L41_PWR_CTRL2, 10, 0), | |
| 636 | + SND_SOC_DAPM_SUPPLY("VMON", CS35L41_PWR_CTRL2, 12, 0, NULL, 0), | |
| 637 | + SND_SOC_DAPM_SUPPLY("IMON", CS35L41_PWR_CTRL2, 13, 0, NULL, 0), | |
| 638 | + SND_SOC_DAPM_SUPPLY("VPMON", CS35L41_PWR_CTRL2, 8, 0, NULL, 0), | |
| 639 | + SND_SOC_DAPM_SUPPLY("VBSTMON", CS35L41_PWR_CTRL2, 9, 0, NULL, 0), | |
| 640 | + SND_SOC_DAPM_SUPPLY("TEMPMON", CS35L41_PWR_CTRL2, 10, 0, NULL, 0), | |
| 641 | + | |
| 642 | + SND_SOC_DAPM_ADC("VMON ADC", NULL, SND_SOC_NOPM, 0, 0), | |
| 643 | + SND_SOC_DAPM_ADC("IMON ADC", NULL, SND_SOC_NOPM, 0, 0), | |
| 644 | + SND_SOC_DAPM_ADC("VPMON ADC", NULL, SND_SOC_NOPM, 0, 0), | |
| 645 | + SND_SOC_DAPM_ADC("VBSTMON ADC", NULL, SND_SOC_NOPM, 0, 0), | |
| 646 | + SND_SOC_DAPM_ADC("TEMPMON ADC", NULL, SND_SOC_NOPM, 0, 0), | |
| 647 | + | |
| 619 | 648 | SND_SOC_DAPM_ADC("CLASS H", NULL, CS35L41_PWR_CTRL3, 4, 0), |
| 620 | 649 | |
| 621 | 650 | SND_SOC_DAPM_OUT_DRV_E("Main AMP", CS35L41_PWR_CTRL2, 0, 0, NULL, 0, |
| @@ -626,33 +655,51 @@ static const struct snd_soc_dapm_widget cs35l41_dapm_widgets[] = { · 4 unmodified lines | ||
| 626 | 655 | SND_SOC_DAPM_MUX("ASP TX2 Source", SND_SOC_NOPM, 0, 0, &asp_tx2_mux), |
| 627 | 656 | SND_SOC_DAPM_MUX("ASP TX3 Source", SND_SOC_NOPM, 0, 0, &asp_tx3_mux), |
| 628 | 657 | SND_SOC_DAPM_MUX("ASP TX4 Source", SND_SOC_NOPM, 0, 0, &asp_tx4_mux), |
| 658 | + SND_SOC_DAPM_MUX("DSP RX1 Source", SND_SOC_NOPM, 0, 0, &dsp_rx1_mux), | |
| 659 | + SND_SOC_DAPM_MUX("DSP RX2 Source", SND_SOC_NOPM, 0, 0, &dsp_rx2_mux), | |
| 629 | 660 | SND_SOC_DAPM_MUX("PCM Source", SND_SOC_NOPM, 0, 0, &pcm_source_mux), |
| 630 | 661 | SND_SOC_DAPM_SWITCH("DRE", SND_SOC_NOPM, 0, 0, &dre_ctrl), |
| 631 | 662 | }; |
| 632 | 663 | |
| 633 | 664 | static const struct snd_soc_dapm_route cs35l41_audio_map[] = { |
| 665 | + {"DSP RX1 Source", "ASPRX1", "ASPRX1"}, | |
| 666 | + {"DSP RX1 Source", "ASPRX2", "ASPRX2"}, | |
| 667 | + {"DSP RX2 Source", "ASPRX1", "ASPRX1"}, | |
| 668 | + {"DSP RX2 Source", "ASPRX2", "ASPRX2"}, | |
| 669 | + | |
| 670 | + {"DSP1", NULL, "DSP RX1 Source"}, | |
| 671 | + {"DSP1", NULL, "DSP RX2 Source"}, | |
| 672 | + | |
| 634 | 673 | {"ASP TX1 Source", "VMON", "VMON ADC"}, |
| 635 | 674 | {"ASP TX1 Source", "IMON", "IMON ADC"}, |
| 636 | 675 | {"ASP TX1 Source", "VPMON", "VPMON ADC"}, |
| 637 | 676 | {"ASP TX1 Source", "VBSTMON", "VBSTMON ADC"}, |
| 677 | + {"ASP TX1 Source", "DSPTX1", "DSP1"}, | |
| 678 | + {"ASP TX1 Source", "DSPTX2", "DSP1"}, | |
| 638 | 679 | {"ASP TX1 Source", "ASPRX1", "ASPRX1" }, |
| 639 | 680 | {"ASP TX1 Source", "ASPRX2", "ASPRX2" }, |
| 640 | 681 | {"ASP TX2 Source", "VMON", "VMON ADC"}, |
| 641 | 682 | {"ASP TX2 Source", "IMON", "IMON ADC"}, |
| 642 | 683 | {"ASP TX2 Source", "VPMON", "VPMON ADC"}, |
| 643 | 684 | {"ASP TX2 Source", "VBSTMON", "VBSTMON ADC"}, |
| 685 | + {"ASP TX2 Source", "DSPTX1", "DSP1"}, | |
| 686 | + {"ASP TX2 Source", "DSPTX2", "DSP1"}, | |
| 644 | 687 | {"ASP TX2 Source", "ASPRX1", "ASPRX1" }, |
| 645 | 688 | {"ASP TX2 Source", "ASPRX2", "ASPRX2" }, |
| 646 | 689 | {"ASP TX3 Source", "VMON", "VMON ADC"}, |
| 647 | 690 | {"ASP TX3 Source", "IMON", "IMON ADC"}, |
| 648 | 691 | {"ASP TX3 Source", "VPMON", "VPMON ADC"}, |
| 649 | 692 | {"ASP TX3 Source", "VBSTMON", "VBSTMON ADC"}, |
| 693 | + {"ASP TX3 Source", "DSPTX1", "DSP1"}, | |
| 694 | + {"ASP TX3 Source", "DSPTX2", "DSP1"}, | |
| 650 | 695 | {"ASP TX3 Source", "ASPRX1", "ASPRX1" }, |
| 651 | 696 | {"ASP TX3 Source", "ASPRX2", "ASPRX2" }, |
| 652 | 697 | {"ASP TX4 Source", "VMON", "VMON ADC"}, |
| 653 | 698 | {"ASP TX4 Source", "IMON", "IMON ADC"}, |
| 654 | 699 | {"ASP TX4 Source", "VPMON", "VPMON ADC"}, |
| 655 | 700 | {"ASP TX4 Source", "VBSTMON", "VBSTMON ADC"}, |
| 701 | + {"ASP TX4 Source", "DSPTX1", "DSP1"}, | |
| 702 | + {"ASP TX4 Source", "DSPTX2", "DSP1"}, | |
| 656 | 703 | {"ASP TX4 Source", "ASPRX1", "ASPRX1" }, |
| 657 | 704 | {"ASP TX4 Source", "ASPRX2", "ASPRX2" }, |
| 658 | 705 | {"ASPTX1", NULL, "ASP TX1 Source"}, |
| @@ -664,12 +711,27 @@ static const struct snd_soc_dapm_route cs35l41_audio_map[] = { · 5 unmodified lines | ||
| 664 | 711 | {"AMP Capture", NULL, "ASPTX3"}, |
| 665 | 712 | {"AMP Capture", NULL, "ASPTX4"}, |
| 666 | 713 | |
| 714 | + {"DSP1", NULL, "VMON"}, | |
| 715 | + {"DSP1", NULL, "IMON"}, | |
| 716 | + {"DSP1", NULL, "VPMON"}, | |
| 717 | + {"DSP1", NULL, "VBSTMON"}, | |
| 718 | + {"DSP1", NULL, "TEMPMON"}, | |
| 719 | + | |
| 720 | + {"VMON ADC", NULL, "VMON"}, | |
| 721 | + {"IMON ADC", NULL, "IMON"}, | |
| 722 | + {"VPMON ADC", NULL, "VPMON"}, | |
| 723 | + {"VBSTMON ADC", NULL, "VBSTMON"}, | |
| 724 | + {"TEMPMON ADC", NULL, "TEMPMON"}, | |
| 725 | + | |
| 667 | 726 | {"VMON ADC", NULL, "VSENSE"}, |
| 668 | 727 | {"IMON ADC", NULL, "ISENSE"}, |
| 669 | 728 | {"VPMON ADC", NULL, "VP"}, |
| 670 | 729 | {"VBSTMON ADC", NULL, "VBST"}, |
| 671 | 730 | {"TEMPMON ADC", NULL, "TEMP"}, |
| 672 | 731 | |
| 732 | + {"DSP1 Preload", NULL, "DSP1 Preloader"}, | |
| 733 | + {"DSP1", NULL, "DSP1 Preloader"}, | |
| 734 | + | |
| 673 | 735 | {"ASPRX1", NULL, "AMP Playback"}, |
| 674 | 736 | {"ASPRX2", NULL, "AMP Playback"}, |
| 675 | 737 | {"DRE", "Switch", "CLASS H"}, |
| @@ -678,39 +740,24 @@ static const struct snd_soc_dapm_route cs35l41_audio_map[] = { · 2 unmodified lines | ||
| 678 | 740 | {"SPK", NULL, "Main AMP"}, |
| 679 | 741 | |
| 680 | 742 | {"PCM Source", "ASP", "ASPRX1"}, |
| 743 | + {"PCM Source", "DSP", "DSP1"}, | |
| 681 | 744 | {"CLASS H", NULL, "PCM Source"}, |
| 682 | 745 | }; |
| 683 | 746 | |
| 684 | −static int cs35l41_set_channel_map(struct snd_soc_dai *dai, unsigned int tx_num, | |
| 685 | − unsigned int *tx_slot, unsigned int rx_num, | |
| 686 | − unsigned int *rx_slot) | |
| 747 | +static const struct cs_dsp_region cs35l41_dsp1_regions[] = { | |
| 748 | + { .type = WMFW_HALO_PM_PACKED, .base = CS35L41_DSP1_PMEM_0 }, | |
| 749 | + { .type = WMFW_HALO_XM_PACKED, .base = CS35L41_DSP1_XMEM_PACK_0 }, | |
| 750 | + { .type = WMFW_HALO_YM_PACKED, .base = CS35L41_DSP1_YMEM_PACK_0 }, | |
| 751 | + {. type = WMFW_ADSP2_XM, .base = CS35L41_DSP1_XMEM_UNPACK24_0}, | |
| 752 | + {. type = WMFW_ADSP2_YM, .base = CS35L41_DSP1_YMEM_UNPACK24_0}, | |
| 753 | +}; | |
| 754 | + | |
| 755 | +static int cs35l41_set_channel_map(struct snd_soc_dai *dai, unsigned int tx_n, | |
| 756 | + unsigned int *tx_slot, unsigned int rx_n, unsigned int *rx_slot) | |
| 687 | 757 | { |
| 688 | 758 | struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); |
| 689 | − unsigned int val, mask; | |
| 690 | − int i; | |
| 691 | 759 | |
| 692 | − if (tx_num > 4 || rx_num > 2) | |
| 693 | − return -EINVAL; | |
| 694 | − | |
| 695 | − val = 0; | |
| 696 | − mask = 0; | |
| 697 | − for (i = 0; i < rx_num; i++) { | |
| 698 | − dev_dbg(cs35l41->dev, "rx slot %d position = %d\n", i, rx_slot[i]); | |
| 699 | − val |= rx_slot[i] << (i * 8); | |
| 700 | − mask |= 0x3F << (i * 8); | |
| 701 | − } | |
| 702 | − regmap_update_bits(cs35l41->regmap, CS35L41_SP_FRAME_RX_SLOT, mask, val); | |
| 703 | − | |
| 704 | − val = 0; | |
| 705 | − mask = 0; | |
| 706 | − for (i = 0; i < tx_num; i++) { | |
| 707 | − dev_dbg(cs35l41->dev, "tx slot %d position = %d\n", i, tx_slot[i]); | |
| 708 | − val |= tx_slot[i] << (i * 8); | |
| 709 | − mask |= 0x3F << (i * 8); | |
| 710 | − } | |
| 711 | − regmap_update_bits(cs35l41->regmap, CS35L41_SP_FRAME_TX_SLOT, mask, val); | |
| 712 | − | |
| 713 | − return 0; | |
| 760 | + return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_n, tx_slot, rx_n, rx_slot); | |
| 714 | 761 | } |
| 715 | 762 | |
| 716 | 763 | static int cs35l41_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
| @@ -946,88 +993,6 @@ static int cs35l41_dai_set_sysclk(struct snd_soc_dai *dai, · 229 unmodified lines | ||
| 946 | 993 | return 0; |
| 947 | 994 | } |
| 948 | 995 | |
| 949 | −static int cs35l41_boost_config(struct cs35l41_private *cs35l41, | |
| 950 | − int boost_ind, int boost_cap, int boost_ipk) | |
| 951 | −{ | |
| 952 | − unsigned char bst_lbst_val, bst_cbst_range, bst_ipk_scaled; | |
| 953 | − struct regmap *regmap = cs35l41->regmap; | |
| 954 | − struct device *dev = cs35l41->dev; | |
| 955 | − int ret; | |
| 956 | − | |
| 957 | − switch (boost_ind) { | |
| 958 | − case 1000: /* 1.0 uH */ | |
| 959 | − bst_lbst_val = 0; | |
| 960 | − break; | |
| 961 | − case 1200: /* 1.2 uH */ | |
| 962 | − bst_lbst_val = 1; | |
| 963 | − break; | |
| 964 | − case 1500: /* 1.5 uH */ | |
| 965 | − bst_lbst_val = 2; | |
| 966 | − break; | |
| 967 | − case 2200: /* 2.2 uH */ | |
| 968 | − bst_lbst_val = 3; | |
| 969 | − break; | |
| 970 | − default: | |
| 971 | − dev_err(dev, "Invalid boost inductor value: %d nH\n", boost_ind); | |
| 972 | − return -EINVAL; | |
| 973 | − } | |
| 974 | − | |
| 975 | − switch (boost_cap) { | |
| 976 | − case 0 ... 19: | |
| 977 | − bst_cbst_range = 0; | |
| 978 | − break; | |
| 979 | − case 20 ... 50: | |
| 980 | − bst_cbst_range = 1; | |
| 981 | − break; | |
| 982 | − case 51 ... 100: | |
| 983 | − bst_cbst_range = 2; | |
| 984 | − break; | |
| 985 | − case 101 ... 200: | |
| 986 | − bst_cbst_range = 3; | |
| 987 | − break; | |
| 988 | − default: /* 201 uF and greater */ | |
| 989 | − bst_cbst_range = 4; | |
| 990 | − } | |
| 991 | − | |
| 992 | − ret = regmap_update_bits(regmap, CS35L41_BSTCVRT_COEFF, | |
| 993 | − CS35L41_BST_K1_MASK | CS35L41_BST_K2_MASK, | |
| 994 | − cs35l41_bst_k1_table[bst_lbst_val][bst_cbst_range] | |
| 995 | − << CS35L41_BST_K1_SHIFT | | |
| 996 | − cs35l41_bst_k2_table[bst_lbst_val][bst_cbst_range] | |
| 997 | − << CS35L41_BST_K2_SHIFT); | |
| 998 | − if (ret) { | |
| 999 | − dev_err(dev, "Failed to write boost coefficients: %d\n", ret); | |
| 1000 | − return ret; | |
| 1001 | − } | |
| 1002 | − | |
| 1003 | − ret = regmap_update_bits(regmap, CS35L41_BSTCVRT_SLOPE_LBST, | |
| 1004 | − CS35L41_BST_SLOPE_MASK | CS35L41_BST_LBST_VAL_MASK, | |
| 1005 | − cs35l41_bst_slope_table[bst_lbst_val] | |
| 1006 | − << CS35L41_BST_SLOPE_SHIFT | | |
| 1007 | − bst_lbst_val << CS35L41_BST_LBST_VAL_SHIFT); | |
| 1008 | − if (ret) { | |
| 1009 | − dev_err(dev, "Failed to write boost slope/inductor value: %d\n", ret); | |
| 1010 | − return ret; | |
| 1011 | − } | |
| 1012 | − | |
| 1013 | − if (boost_ipk < 1600 || boost_ipk > 4500) { | |
| 1014 | − dev_err(dev, "Invalid boost inductor peak current: %d mA\n", | |
| 1015 | − boost_ipk); | |
| 1016 | − return -EINVAL; | |
| 1017 | − } | |
| 1018 | − bst_ipk_scaled = ((boost_ipk - 1600) / 50) + 0x10; | |
| 1019 | − | |
| 1020 | − ret = regmap_update_bits(regmap, CS35L41_BSTCVRT_PEAK_CUR, | |
| 1021 | − CS35L41_BST_IPK_MASK, | |
| 1022 | − bst_ipk_scaled << CS35L41_BST_IPK_SHIFT); | |
| 1023 | − if (ret) { | |
| 1024 | − dev_err(dev, "Failed to write boost inductor peak current: %d\n", ret); | |
| 1025 | − return ret; | |
| 1026 | − } | |
| 1027 | − | |
| 1028 | − return 0; | |
| 1029 | −} | |
| 1030 | − | |
| 1031 | 996 | static int cs35l41_set_pdata(struct cs35l41_private *cs35l41) |
| 1032 | 997 | { |
| 1033 | 998 | int ret; |
| @@ -1036,9 +1001,8 @@ static int cs35l41_set_pdata(struct cs35l41_private *cs35l41) · 2 unmodified lines | ||
| 1036 | 1001 | /* Required */ |
| 1037 | 1002 | if (cs35l41->pdata.bst_ipk && |
| 1038 | 1003 | cs35l41->pdata.bst_ind && cs35l41->pdata.bst_cap) { |
| 1039 | − ret = cs35l41_boost_config(cs35l41, cs35l41->pdata.bst_ind, | |
| 1040 | − cs35l41->pdata.bst_cap, | |
| 1041 | − cs35l41->pdata.bst_ipk); | |
| 1004 | + ret = cs35l41_boost_config(cs35l41->dev, cs35l41->regmap, cs35l41->pdata.bst_ind, | |
| 1005 | + cs35l41->pdata.bst_cap, cs35l41->pdata.bst_ipk); | |
| 1042 | 1006 | if (ret) { |
| 1043 | 1007 | dev_err(cs35l41->dev, "Error in Boost DT config: %d\n", ret); |
| 1044 | 1008 | return ret; |
| @@ -1091,6 +1055,20 @@ static int cs35l41_irq_gpio_config(struct cs35l41_private *cs35l41) · 46 unmodified lines | ||
| 1091 | 1055 | return irq_pol; |
| 1092 | 1056 | } |
| 1093 | 1057 | |
| 1058 | +static int cs35l41_component_probe(struct snd_soc_component *component) | |
| 1059 | +{ | |
| 1060 | + struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); | |
| 1061 | + | |
| 1062 | + return wm_adsp2_component_probe(&cs35l41->dsp, component); | |
| 1063 | +} | |
| 1064 | + | |
| 1065 | +static void cs35l41_component_remove(struct snd_soc_component *component) | |
| 1066 | +{ | |
| 1067 | + struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); | |
| 1068 | + | |
| 1069 | + wm_adsp2_component_remove(&cs35l41->dsp, component); | |
| 1070 | +} | |
| 1071 | + | |
| 1094 | 1072 | static const struct snd_soc_dai_ops cs35l41_ops = { |
| 1095 | 1073 | .startup = cs35l41_pcm_startup, |
| 1096 | 1074 | .set_fmt = cs35l41_set_dai_fmt, |
| @@ -1124,6 +1102,8 @@ static struct snd_soc_dai_driver cs35l41_dai[] = { · 27 unmodified lines | ||
| 1124 | 1102 | |
| 1125 | 1103 | static const struct snd_soc_component_driver soc_component_dev_cs35l41 = { |
| 1126 | 1104 | .name = "cs35l41-codec", |
| 1105 | + .probe = cs35l41_component_probe, | |
| 1106 | + .remove = cs35l41_component_remove, | |
| 1127 | 1107 | |
| 1128 | 1108 | .dapm_widgets = cs35l41_dapm_widgets, |
| 1129 | 1109 | .num_dapm_widgets = ARRAY_SIZE(cs35l41_dapm_widgets), |
| @@ -1185,50 +1165,90 @@ static int cs35l41_handle_pdata(struct device *dev, · 55 unmodified lines | ||
| 1185 | 1165 | return 0; |
| 1186 | 1166 | } |
| 1187 | 1167 | |
| 1188 | −static const struct reg_sequence cs35l41_reva0_errata_patch[] = { | |
| 1189 | − { 0x00000040, 0x00005555 }, | |
| 1190 | − { 0x00000040, 0x0000AAAA }, | |
| 1191 | − { 0x00003854, 0x05180240 }, | |
| 1192 | − { CS35L41_VIMON_SPKMON_RESYNC, 0x00000000 }, | |
| 1193 | − { 0x00004310, 0x00000000 }, | |
| 1194 | − { CS35L41_VPVBST_FS_SEL, 0x00000000 }, | |
| 1195 | − { CS35L41_OTP_TRIM_30, 0x9091A1C8 }, | |
| 1196 | − { 0x00003014, 0x0200EE0E }, | |
| 1197 | − { CS35L41_BSTCVRT_DCM_CTRL, 0x00000051 }, | |
| 1198 | − { 0x00000054, 0x00000004 }, | |
| 1199 | − { CS35L41_IRQ1_DB3, 0x00000000 }, | |
| 1200 | − { CS35L41_IRQ2_DB3, 0x00000000 }, | |
| 1201 | − { CS35L41_DSP1_YM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 1202 | − { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 1203 | − { 0x00000040, 0x0000CCCC }, | |
| 1204 | − { 0x00000040, 0x00003333 }, | |
| 1168 | +static const struct reg_sequence cs35l41_fs_errata_patch[] = { | |
| 1169 | + { CS35L41_DSP1_RX1_RATE, 0x00000001 }, | |
| 1170 | + { CS35L41_DSP1_RX2_RATE, 0x00000001 }, | |
| 1171 | + { CS35L41_DSP1_RX3_RATE, 0x00000001 }, | |
| 1172 | + { CS35L41_DSP1_RX4_RATE, 0x00000001 }, | |
| 1173 | + { CS35L41_DSP1_RX5_RATE, 0x00000001 }, | |
| 1174 | + { CS35L41_DSP1_RX6_RATE, 0x00000001 }, | |
| 1175 | + { CS35L41_DSP1_RX7_RATE, 0x00000001 }, | |
| 1176 | + { CS35L41_DSP1_RX8_RATE, 0x00000001 }, | |
| 1177 | + { CS35L41_DSP1_TX1_RATE, 0x00000001 }, | |
| 1178 | + { CS35L41_DSP1_TX2_RATE, 0x00000001 }, | |
| 1179 | + { CS35L41_DSP1_TX3_RATE, 0x00000001 }, | |
| 1180 | + { CS35L41_DSP1_TX4_RATE, 0x00000001 }, | |
| 1181 | + { CS35L41_DSP1_TX5_RATE, 0x00000001 }, | |
| 1182 | + { CS35L41_DSP1_TX6_RATE, 0x00000001 }, | |
| 1183 | + { CS35L41_DSP1_TX7_RATE, 0x00000001 }, | |
| 1184 | + { CS35L41_DSP1_TX8_RATE, 0x00000001 }, | |
| 1205 | 1185 | }; |
| 1206 | 1186 | |
| 1207 | −static const struct reg_sequence cs35l41_revb0_errata_patch[] = { | |
| 1208 | − { 0x00000040, 0x00005555 }, | |
| 1209 | − { 0x00000040, 0x0000AAAA }, | |
| 1210 | − { CS35L41_VIMON_SPKMON_RESYNC, 0x00000000 }, | |
| 1211 | − { 0x00004310, 0x00000000 }, | |
| 1212 | − { CS35L41_VPVBST_FS_SEL, 0x00000000 }, | |
| 1213 | − { CS35L41_BSTCVRT_DCM_CTRL, 0x00000051 }, | |
| 1214 | − { CS35L41_DSP1_YM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 1215 | − { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 1216 | − { 0x00000040, 0x0000CCCC }, | |
| 1217 | − { 0x00000040, 0x00003333 }, | |
| 1218 | −}; | |
| 1187 | +static int cs35l41_dsp_init(struct cs35l41_private *cs35l41) | |
| 1188 | +{ | |
| 1189 | + struct wm_adsp *dsp; | |
| 1190 | + int ret; | |
| 1219 | 1191 | |
| 1220 | −static const struct reg_sequence cs35l41_revb2_errata_patch[] = { | |
| 1221 | − { 0x00000040, 0x00005555 }, | |
| 1222 | − { 0x00000040, 0x0000AAAA }, | |
| 1223 | − { CS35L41_VIMON_SPKMON_RESYNC, 0x00000000 }, | |
| 1224 | − { 0x00004310, 0x00000000 }, | |
| 1225 | − { CS35L41_VPVBST_FS_SEL, 0x00000000 }, | |
| 1226 | − { CS35L41_BSTCVRT_DCM_CTRL, 0x00000051 }, | |
| 1227 | − { CS35L41_DSP1_YM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 1228 | − { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, | |
| 1229 | − { 0x00000040, 0x0000CCCC }, | |
| 1230 | − { 0x00000040, 0x00003333 }, | |
| 1231 | −}; | |
| 1192 | + dsp = &cs35l41->dsp; | |
| 1193 | + dsp->part = "cs35l41"; | |
| 1194 | + dsp->cs_dsp.num = 1; | |
| 1195 | + dsp->cs_dsp.type = WMFW_HALO; | |
| 1196 | + dsp->cs_dsp.rev = 0; | |
| 1197 | + dsp->fw = 9; /* 9 is WM_ADSP_FW_SPK_PROT in wm_adsp.c */ | |
| 1198 | + dsp->toggle_preload = true; | |
| 1199 | + dsp->cs_dsp.dev = cs35l41->dev; | |
| 1200 | + dsp->cs_dsp.regmap = cs35l41->regmap; | |
| 1201 | + dsp->cs_dsp.base = CS35L41_DSP1_CTRL_BASE; | |
| 1202 | + dsp->cs_dsp.base_sysinfo = CS35L41_DSP1_SYS_ID; | |
| 1203 | + dsp->cs_dsp.mem = cs35l41_dsp1_regions; | |
| 1204 | + dsp->cs_dsp.num_mems = ARRAY_SIZE(cs35l41_dsp1_regions); | |
| 1205 | + dsp->cs_dsp.lock_regions = 0xFFFFFFFF; | |
| 1206 | + | |
| 1207 | + ret = regmap_multi_reg_write(cs35l41->regmap, cs35l41_fs_errata_patch, | |
| 1208 | + ARRAY_SIZE(cs35l41_fs_errata_patch)); | |
| 1209 | + if (ret < 0) { | |
| 1210 | + dev_err(cs35l41->dev, "Failed to write fs errata: %d\n", ret); | |
| 1211 | + return ret; | |
| 1212 | + } | |
| 1213 | + | |
| 1214 | + ret = wm_halo_init(dsp); | |
| 1215 | + if (ret) { | |
| 1216 | + dev_err(cs35l41->dev, "wm_halo_init failed: %d\n", ret); | |
| 1217 | + return ret; | |
| 1218 | + } | |
| 1219 | + | |
| 1220 | + ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX5_SRC, | |
| 1221 | + CS35L41_INPUT_SRC_VPMON); | |
| 1222 | + if (ret < 0) { | |
| 1223 | + dev_err(cs35l41->dev, "Write INPUT_SRC_VPMON failed: %d\n", ret); | |
| 1224 | + goto err_dsp; | |
| 1225 | + } | |
| 1226 | + ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX6_SRC, | |
| 1227 | + CS35L41_INPUT_SRC_CLASSH); | |
| 1228 | + if (ret < 0) { | |
| 1229 | + dev_err(cs35l41->dev, "Write INPUT_SRC_CLASSH failed: %d\n", ret); | |
| 1230 | + goto err_dsp; | |
| 1231 | + } | |
| 1232 | + ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX7_SRC, | |
| 1233 | + CS35L41_INPUT_SRC_TEMPMON); | |
| 1234 | + if (ret < 0) { | |
| 1235 | + dev_err(cs35l41->dev, "Write INPUT_SRC_TEMPMON failed: %d\n", ret); | |
| 1236 | + goto err_dsp; | |
| 1237 | + } | |
| 1238 | + ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX8_SRC, | |
| 1239 | + CS35L41_INPUT_SRC_RSVD); | |
| 1240 | + if (ret < 0) { | |
| 1241 | + dev_err(cs35l41->dev, "Write INPUT_SRC_RSVD failed: %d\n", ret); | |
| 1242 | + goto err_dsp; | |
| 1243 | + } | |
| 1244 | + | |
| 1245 | + return 0; | |
| 1246 | + | |
| 1247 | +err_dsp: | |
| 1248 | + wm_adsp2_remove(dsp); | |
| 1249 | + | |
| 1250 | + return ret; | |
| 1251 | +} | |
| 1232 | 1252 | |
| 1233 | 1253 | int cs35l41_probe(struct cs35l41_private *cs35l41, |
| 1234 | 1254 | struct cs35l41_platform_data *pdata) |
| @@ -1325,39 +1345,20 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, · 90 unmodified lines | ||
| 1325 | 1345 | goto err; |
| 1326 | 1346 | } |
| 1327 | 1347 | |
| 1328 | − switch (reg_revid) { | |
| 1329 | − case CS35L41_REVID_A0: | |
| 1330 | − ret = regmap_register_patch(cs35l41->regmap, | |
| 1331 | − cs35l41_reva0_errata_patch, | |
| 1332 | − ARRAY_SIZE(cs35l41_reva0_errata_patch)); | |
| 1333 | − if (ret < 0) { | |
| 1334 | − dev_err(cs35l41->dev, | |
| 1335 | − "Failed to apply A0 errata patch: %d\n", ret); | |
| 1336 | − goto err; | |
| 1337 | − } | |
| 1338 | − break; | |
| 1339 | − case CS35L41_REVID_B0: | |
| 1340 | − ret = regmap_register_patch(cs35l41->regmap, | |
| 1341 | − cs35l41_revb0_errata_patch, | |
| 1342 | − ARRAY_SIZE(cs35l41_revb0_errata_patch)); | |
| 1343 | − if (ret < 0) { | |
| 1344 | − dev_err(cs35l41->dev, | |
| 1345 | − "Failed to apply B0 errata patch: %d\n", ret); | |
| 1346 | − goto err; | |
| 1347 | − } | |
| 1348 | − break; | |
| 1349 | − case CS35L41_REVID_B2: | |
| 1350 | − ret = regmap_register_patch(cs35l41->regmap, | |
| 1351 | − cs35l41_revb2_errata_patch, | |
| 1352 | − ARRAY_SIZE(cs35l41_revb2_errata_patch)); | |
| 1353 | − if (ret < 0) { | |
| 1354 | − dev_err(cs35l41->dev, | |
| 1355 | − "Failed to apply B2 errata patch: %d\n", ret); | |
| 1356 | − goto err; | |
| 1357 | − } | |
| 1358 | − break; | |
| 1348 | + cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); | |
| 1349 | + | |
| 1350 | + ret = cs35l41_register_errata_patch(cs35l41->dev, cs35l41->regmap, reg_revid); | |
| 1351 | + if (ret) | |
| 1352 | + goto err; | |
| 1353 | + | |
| 1354 | + ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); | |
| 1355 | + if (ret < 0) { | |
| 1356 | + dev_err(cs35l41->dev, "OTP Unpack failed: %d\n", ret); | |
| 1357 | + goto err; | |
| 1359 | 1358 | } |
| 1360 | 1359 | |
| 1360 | + cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); | |
| 1361 | + | |
| 1361 | 1362 | irq_pol = cs35l41_irq_gpio_config(cs35l41); |
| 1362 | 1363 | |
| 1363 | 1364 | /* Set interrupt masks for critical errors */ |
| @@ -1367,71 +1368,229 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, · 3 unmodified lines | ||
| 1367 | 1368 | ret = devm_request_threaded_irq(cs35l41->dev, cs35l41->irq, NULL, cs35l41_irq, |
| 1368 | 1369 | IRQF_ONESHOT | IRQF_SHARED | irq_pol, |
| 1369 | 1370 | "cs35l41", cs35l41); |
| 1370 | − | |
| 1371 | − /* CS35L41 needs INT for PDN_DONE */ | |
| 1372 | 1371 | if (ret != 0) { |
| 1373 | 1372 | dev_err(cs35l41->dev, "Failed to request IRQ: %d\n", ret); |
| 1374 | 1373 | goto err; |
| 1375 | 1374 | } |
| 1376 | 1375 | |
| 1377 | − ret = cs35l41_otp_unpack(cs35l41); | |
| 1378 | − if (ret < 0) { | |
| 1379 | − dev_err(cs35l41->dev, "OTP Unpack failed: %d\n", ret); | |
| 1380 | − goto err; | |
| 1381 | − } | |
| 1382 | − | |
| 1383 | − ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_CCM_CORE_CTRL, 0); | |
| 1384 | − if (ret < 0) { | |
| 1385 | − dev_err(cs35l41->dev, "Write CCM_CORE_CTRL failed: %d\n", ret); | |
| 1386 | − goto err; | |
| 1387 | − } | |
| 1388 | − | |
| 1389 | − ret = regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, | |
| 1390 | − CS35L41_AMP_EN_MASK, 0); | |
| 1376 | + ret = cs35l41_set_pdata(cs35l41); | |
| 1391 | 1377 | if (ret < 0) { |
| 1392 | − dev_err(cs35l41->dev, "Write CS35L41_PWR_CTRL2 failed: %d\n", ret); | |
| 1378 | + dev_err(cs35l41->dev, "Set pdata failed: %d\n", ret); | |
| 1393 | 1379 | goto err; |
| 1394 | 1380 | } |
| 1395 | 1381 | |
| 1396 | − ret = regmap_update_bits(cs35l41->regmap, CS35L41_AMP_GAIN_CTRL, | |
| 1397 | − CS35L41_AMP_GAIN_PCM_MASK, 0); | |
| 1398 | − if (ret < 0) { | |
| 1399 | − dev_err(cs35l41->dev, "Write CS35L41_AMP_GAIN_CTRL failed: %d\n", ret); | |
| 1382 | + ret = cs35l41_dsp_init(cs35l41); | |
| 1383 | + if (ret < 0) | |
| 1400 | 1384 | goto err; |
| 1401 | − } | |
| 1402 | 1385 | |
| 1403 | − ret = cs35l41_set_pdata(cs35l41); | |
| 1404 | − if (ret < 0) { | |
| 1405 | − dev_err(cs35l41->dev, "Set pdata failed: %d\n", ret); | |
| 1406 | − goto err; | |
| 1407 | − } | |
| 1386 | + pm_runtime_set_autosuspend_delay(cs35l41->dev, 3000); | |
| 1387 | + pm_runtime_use_autosuspend(cs35l41->dev); | |
| 1388 | + pm_runtime_mark_last_busy(cs35l41->dev); | |
| 1389 | + pm_runtime_set_active(cs35l41->dev); | |
| 1390 | + pm_runtime_get_noresume(cs35l41->dev); | |
| 1391 | + pm_runtime_enable(cs35l41->dev); | |
| 1408 | 1392 | |
| 1409 | 1393 | ret = devm_snd_soc_register_component(cs35l41->dev, |
| 1410 | 1394 | &soc_component_dev_cs35l41, |
| 1411 | 1395 | cs35l41_dai, ARRAY_SIZE(cs35l41_dai)); |
| 1412 | 1396 | if (ret < 0) { |
| 1413 | 1397 | dev_err(cs35l41->dev, "Register codec failed: %d\n", ret); |
| 1414 | − goto err; | |
| 1398 | + goto err_pm; | |
| 1415 | 1399 | } |
| 1416 | 1400 | |
| 1401 | + pm_runtime_put_autosuspend(cs35l41->dev); | |
| 1402 | + | |
| 1417 | 1403 | dev_info(cs35l41->dev, "Cirrus Logic CS35L41 (%x), Revision: %02X\n", |
| 1418 | 1404 | regid, reg_revid); |
| 1419 | 1405 | |
| 1420 | 1406 | return 0; |
| 1421 | 1407 | |
| 1408 | +err_pm: | |
| 1409 | + pm_runtime_disable(cs35l41->dev); | |
| 1410 | + pm_runtime_put_noidle(cs35l41->dev); | |
| 1411 | + | |
| 1412 | + wm_adsp2_remove(&cs35l41->dsp); | |
| 1422 | 1413 | err: |
| 1423 | 1414 | regulator_bulk_disable(CS35L41_NUM_SUPPLIES, cs35l41->supplies); |
| 1424 | 1415 | gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); |
| 1425 | 1416 | |
| 1426 | 1417 | return ret; |
| 1427 | 1418 | } |
| 1419 | +EXPORT_SYMBOL_GPL(cs35l41_probe); | |
| 1428 | 1420 | |
| 1429 | 1421 | void cs35l41_remove(struct cs35l41_private *cs35l41) |
| 1430 | 1422 | { |
| 1423 | + pm_runtime_get_sync(cs35l41->dev); | |
| 1424 | + pm_runtime_disable(cs35l41->dev); | |
| 1425 | + | |
| 1431 | 1426 | regmap_write(cs35l41->regmap, CS35L41_IRQ1_MASK1, 0xFFFFFFFF); |
| 1427 | + wm_adsp2_remove(&cs35l41->dsp); | |
| 1428 | + | |
| 1429 | + pm_runtime_put_noidle(cs35l41->dev); | |
| 1430 | + | |
| 1432 | 1431 | regulator_bulk_disable(CS35L41_NUM_SUPPLIES, cs35l41->supplies); |
| 1433 | 1432 | gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); |
| 1434 | 1433 | } |
| 1434 | +EXPORT_SYMBOL_GPL(cs35l41_remove); | |
| 1435 | + | |
| 1436 | +static int __maybe_unused cs35l41_runtime_suspend(struct device *dev) | |
| 1437 | +{ | |
| 1438 | + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); | |
| 1439 | + | |
| 1440 | + dev_dbg(cs35l41->dev, "Runtime suspend\n"); | |
| 1441 | + | |
| 1442 | + if (!cs35l41->dsp.preloaded || !cs35l41->dsp.cs_dsp.running) | |
| 1443 | + return 0; | |
| 1444 | + | |
| 1445 | + dev_dbg(cs35l41->dev, "Enter hibernate\n"); | |
| 1446 | + | |
| 1447 | + regmap_write(cs35l41->regmap, CS35L41_WAKESRC_CTL, 0x0088); | |
| 1448 | + regmap_write(cs35l41->regmap, CS35L41_WAKESRC_CTL, 0x0188); | |
| 1449 | + | |
| 1450 | + // Don't wait for ACK since bus activity would wake the device | |
| 1451 | + regmap_write(cs35l41->regmap, CS35L41_DSP_VIRT1_MBOX_1, | |
| 1452 | + CSPL_MBOX_CMD_HIBERNATE); | |
| 1453 | + | |
| 1454 | + regcache_cache_only(cs35l41->regmap, true); | |
| 1455 | + regcache_mark_dirty(cs35l41->regmap); | |
| 1456 | + | |
| 1457 | + return 0; | |
| 1458 | +} | |
| 1459 | + | |
| 1460 | +static void cs35l41_wait_for_pwrmgt_sts(struct cs35l41_private *cs35l41) | |
| 1461 | +{ | |
| 1462 | + const int pwrmgt_retries = 10; | |
| 1463 | + unsigned int sts; | |
| 1464 | + int i, ret; | |
| 1465 | + | |
| 1466 | + for (i = 0; i < pwrmgt_retries; i++) { | |
| 1467 | + ret = regmap_read(cs35l41->regmap, CS35L41_PWRMGT_STS, &sts); | |
| 1468 | + if (ret) | |
| 1469 | + dev_err(cs35l41->dev, "Failed to read PWRMGT_STS: %d\n", ret); | |
| 1470 | + else if (!(sts & CS35L41_WR_PEND_STS_MASK)) | |
| 1471 | + return; | |
| 1472 | + | |
| 1473 | + udelay(20); | |
| 1474 | + } | |
| 1475 | + | |
| 1476 | + dev_err(cs35l41->dev, "Timed out reading PWRMGT_STS\n"); | |
| 1477 | +} | |
| 1478 | + | |
| 1479 | +static int cs35l41_exit_hibernate(struct cs35l41_private *cs35l41) | |
| 1480 | +{ | |
| 1481 | + const int wake_retries = 20; | |
| 1482 | + const int sleep_retries = 5; | |
| 1483 | + int ret, i, j; | |
| 1484 | + | |
| 1485 | + for (i = 0; i < sleep_retries; i++) { | |
| 1486 | + dev_dbg(cs35l41->dev, "Exit hibernate\n"); | |
| 1487 | + | |
| 1488 | + for (j = 0; j < wake_retries; j++) { | |
| 1489 | + ret = cs35l41_set_cspl_mbox_cmd(cs35l41, | |
| 1490 | + CSPL_MBOX_CMD_OUT_OF_HIBERNATE); | |
| 1491 | + if (!ret) | |
| 1492 | + break; | |
| 1493 | + | |
| 1494 | + usleep_range(100, 200); | |
| 1495 | + } | |
| 1496 | + | |
| 1497 | + if (j < wake_retries) { | |
| 1498 | + dev_dbg(cs35l41->dev, "Wake success at cycle: %d\n", j); | |
| 1499 | + return 0; | |
| 1500 | + } | |
| 1501 | + | |
| 1502 | + dev_err(cs35l41->dev, "Wake failed, re-enter hibernate: %d\n", ret); | |
| 1503 | + | |
| 1504 | + cs35l41_wait_for_pwrmgt_sts(cs35l41); | |
| 1505 | + regmap_write(cs35l41->regmap, CS35L41_WAKESRC_CTL, 0x0088); | |
| 1506 | + | |
| 1507 | + cs35l41_wait_for_pwrmgt_sts(cs35l41); | |
| 1508 | + regmap_write(cs35l41->regmap, CS35L41_WAKESRC_CTL, 0x0188); | |
| 1509 | + | |
| 1510 | + cs35l41_wait_for_pwrmgt_sts(cs35l41); | |
| 1511 | + regmap_write(cs35l41->regmap, CS35L41_PWRMGT_CTL, 0x3); | |
| 1512 | + } | |
| 1513 | + | |
| 1514 | + dev_err(cs35l41->dev, "Timed out waking device\n"); | |
| 1515 | + | |
| 1516 | + return -ETIMEDOUT; | |
| 1517 | +} | |
| 1518 | + | |
| 1519 | +static int __maybe_unused cs35l41_runtime_resume(struct device *dev) | |
| 1520 | +{ | |
| 1521 | + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); | |
| 1522 | + int ret; | |
| 1523 | + | |
| 1524 | + dev_dbg(cs35l41->dev, "Runtime resume\n"); | |
| 1525 | + | |
| 1526 | + if (!cs35l41->dsp.preloaded || !cs35l41->dsp.cs_dsp.running) | |
| 1527 | + return 0; | |
| 1528 | + | |
| 1529 | + regcache_cache_only(cs35l41->regmap, false); | |
| 1530 | + | |
| 1531 | + ret = cs35l41_exit_hibernate(cs35l41); | |
| 1532 | + if (ret) | |
| 1533 | + return ret; | |
| 1534 | + | |
| 1535 | + /* Test key needs to be unlocked to allow the OTP settings to re-apply */ | |
| 1536 | + cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); | |
| 1537 | + ret = regcache_sync(cs35l41->regmap); | |
| 1538 | + cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); | |
| 1539 | + if (ret) { | |
| 1540 | + dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); | |
| 1541 | + return ret; | |
| 1542 | + } | |
| 1543 | + | |
| 1544 | + return 0; | |
| 1545 | +} | |
| 1546 | + | |
| 1547 | +static int __maybe_unused cs35l41_sys_suspend(struct device *dev) | |
| 1548 | +{ | |
| 1549 | + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); | |
| 1550 | + | |
| 1551 | + dev_dbg(cs35l41->dev, "System suspend, disabling IRQ\n"); | |
| 1552 | + disable_irq(cs35l41->irq); | |
| 1553 | + | |
| 1554 | + return 0; | |
| 1555 | +} | |
| 1556 | + | |
| 1557 | +static int __maybe_unused cs35l41_sys_suspend_noirq(struct device *dev) | |
| 1558 | +{ | |
| 1559 | + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); | |
| 1560 | + | |
| 1561 | + dev_dbg(cs35l41->dev, "Late system suspend, reenabling IRQ\n"); | |
| 1562 | + enable_irq(cs35l41->irq); | |
| 1563 | + | |
| 1564 | + return 0; | |
| 1565 | +} | |
| 1566 | + | |
| 1567 | +static int __maybe_unused cs35l41_sys_resume_noirq(struct device *dev) | |
| 1568 | +{ | |
| 1569 | + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); | |
| 1570 | + | |
| 1571 | + dev_dbg(cs35l41->dev, "Early system resume, disabling IRQ\n"); | |
| 1572 | + disable_irq(cs35l41->irq); | |
| 1573 | + | |
| 1574 | + return 0; | |
| 1575 | +} | |
| 1576 | + | |
| 1577 | +static int __maybe_unused cs35l41_sys_resume(struct device *dev) | |
| 1578 | +{ | |
| 1579 | + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); | |
| 1580 | + | |
| 1581 | + dev_dbg(cs35l41->dev, "System resume, reenabling IRQ\n"); | |
| 1582 | + enable_irq(cs35l41->irq); | |
| 1583 | + | |
| 1584 | + return 0; | |
| 1585 | +} | |
| 1586 | + | |
| 1587 | +const struct dev_pm_ops cs35l41_pm_ops = { | |
| 1588 | + SET_RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL) | |
| 1589 | + | |
| 1590 | + SET_SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend, cs35l41_sys_resume) | |
| 1591 | + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend_noirq, cs35l41_sys_resume_noirq) | |
| 1592 | +}; | |
| 1593 | +EXPORT_SYMBOL_GPL(cs35l41_pm_ops); | |
| 1435 | 1594 | |
| 1436 | 1595 | MODULE_DESCRIPTION("ASoC CS35L41 driver"); |
| 1437 | 1596 | MODULE_AUTHOR("David Rhodes, Cirrus Logic Inc, <david.rhodes@cirrus.com>"); |
| @@ -11,751 +11,38 @@ · 10 unmodified lines | ||
| 11 | 11 | #define __CS35L41_H__ |
| 12 | 12 | |
| 13 | 13 | #include <linux/gpio/consumer.h> |
| 14 | −#include <linux/regmap.h> | |
| 15 | 14 | #include <linux/regulator/consumer.h> |
| 15 | +#include <linux/firmware.h> | |
| 16 | 16 | #include <sound/core.h> |
| 17 | 17 | #include <sound/cs35l41.h> |
| 18 | 18 | |
| 19 | −#define CS35L41_FIRSTREG 0x00000000 | |
| 20 | −#define CS35L41_LASTREG 0x03804FE8 | |
| 21 | −#define CS35L41_DEVID 0x00000000 | |
| 22 | −#define CS35L41_REVID 0x00000004 | |
| 23 | −#define CS35L41_FABID 0x00000008 | |
| 24 | −#define CS35L41_RELID 0x0000000C | |
| 25 | −#define CS35L41_OTPID 0x00000010 | |
| 26 | −#define CS35L41_SFT_RESET 0x00000020 | |
| 27 | −#define CS35L41_TEST_KEY_CTL 0x00000040 | |
| 28 | −#define CS35L41_USER_KEY_CTL 0x00000044 | |
| 29 | −#define CS35L41_OTP_MEM0 0x00000400 | |
| 30 | −#define CS35L41_OTP_MEM31 0x0000047C | |
| 31 | −#define CS35L41_OTP_CTRL0 0x00000500 | |
| 32 | −#define CS35L41_OTP_CTRL1 0x00000504 | |
| 33 | −#define CS35L41_OTP_CTRL3 0x00000508 | |
| 34 | −#define CS35L41_OTP_CTRL4 0x0000050C | |
| 35 | −#define CS35L41_OTP_CTRL5 0x00000510 | |
| 36 | −#define CS35L41_OTP_CTRL6 0x00000514 | |
| 37 | −#define CS35L41_OTP_CTRL7 0x00000518 | |
| 38 | −#define CS35L41_OTP_CTRL8 0x0000051C | |
| 39 | −#define CS35L41_PWR_CTRL1 0x00002014 | |
| 40 | −#define CS35L41_PWR_CTRL2 0x00002018 | |
| 41 | −#define CS35L41_PWR_CTRL3 0x0000201C | |
| 42 | −#define CS35L41_CTRL_OVRRIDE 0x00002020 | |
| 43 | −#define CS35L41_AMP_OUT_MUTE 0x00002024 | |
| 44 | −#define CS35L41_PROTECT_REL_ERR_IGN 0x00002034 | |
| 45 | −#define CS35L41_GPIO_PAD_CONTROL 0x0000242C | |
| 46 | −#define CS35L41_JTAG_CONTROL 0x00002438 | |
| 47 | −#define CS35L41_PLL_CLK_CTRL 0x00002C04 | |
| 48 | −#define CS35L41_DSP_CLK_CTRL 0x00002C08 | |
| 49 | −#define CS35L41_GLOBAL_CLK_CTRL 0x00002C0C | |
| 50 | −#define CS35L41_DATA_FS_SEL 0x00002C10 | |
| 51 | −#define CS35L41_TST_FS_MON0 0x00002D10 | |
| 52 | −#define CS35L41_MDSYNC_EN 0x00003400 | |
| 53 | −#define CS35L41_MDSYNC_TX_ID 0x00003408 | |
| 54 | −#define CS35L41_MDSYNC_PWR_CTRL 0x0000340C | |
| 55 | −#define CS35L41_MDSYNC_DATA_TX 0x00003410 | |
| 56 | −#define CS35L41_MDSYNC_TX_STATUS 0x00003414 | |
| 57 | −#define CS35L41_MDSYNC_DATA_RX 0x0000341C | |
| 58 | −#define CS35L41_MDSYNC_RX_STATUS 0x00003420 | |
| 59 | −#define CS35L41_MDSYNC_ERR_STATUS 0x00003424 | |
| 60 | −#define CS35L41_MDSYNC_SYNC_PTE2 0x00003528 | |
| 61 | −#define CS35L41_MDSYNC_SYNC_PTE3 0x0000352C | |
| 62 | −#define CS35L41_MDSYNC_SYNC_MSM_STATUS 0x0000353C | |
| 63 | −#define CS35L41_BSTCVRT_VCTRL1 0x00003800 | |
| 64 | −#define CS35L41_BSTCVRT_VCTRL2 0x00003804 | |
| 65 | −#define CS35L41_BSTCVRT_PEAK_CUR 0x00003808 | |
| 66 | −#define CS35L41_BSTCVRT_SFT_RAMP 0x0000380C | |
| 67 | −#define CS35L41_BSTCVRT_COEFF 0x00003810 | |
| 68 | −#define CS35L41_BSTCVRT_SLOPE_LBST 0x00003814 | |
| 69 | −#define CS35L41_BSTCVRT_SW_FREQ 0x00003818 | |
| 70 | −#define CS35L41_BSTCVRT_DCM_CTRL 0x0000381C | |
| 71 | −#define CS35L41_BSTCVRT_DCM_MODE_FORCE 0x00003820 | |
| 72 | −#define CS35L41_BSTCVRT_OVERVOLT_CTRL 0x00003830 | |
| 73 | −#define CS35L41_VI_VOL_POL 0x00004000 | |
| 74 | −#define CS35L41_VIMON_SPKMON_RESYNC 0x00004100 | |
| 75 | −#define CS35L41_DTEMP_WARN_THLD 0x00004220 | |
| 76 | −#define CS35L41_DTEMP_CFG 0x00004224 | |
| 77 | −#define CS35L41_DTEMP_EN 0x00004308 | |
| 78 | −#define CS35L41_VPVBST_FS_SEL 0x00004400 | |
| 79 | −#define CS35L41_SP_ENABLES 0x00004800 | |
| 80 | −#define CS35L41_SP_RATE_CTRL 0x00004804 | |
| 81 | −#define CS35L41_SP_FORMAT 0x00004808 | |
| 82 | −#define CS35L41_SP_HIZ_CTRL 0x0000480C | |
| 83 | −#define CS35L41_SP_FRAME_TX_SLOT 0x00004810 | |
| 84 | −#define CS35L41_SP_FRAME_RX_SLOT 0x00004820 | |
| 85 | −#define CS35L41_SP_TX_WL 0x00004830 | |
| 86 | −#define CS35L41_SP_RX_WL 0x00004840 | |
| 87 | −#define CS35L41_ASP_CONTROL4 0x00004854 | |
| 88 | −#define CS35L41_DAC_PCM1_SRC 0x00004C00 | |
| 89 | −#define CS35L41_ASP_TX1_SRC 0x00004C20 | |
| 90 | −#define CS35L41_ASP_TX2_SRC 0x00004C24 | |
| 91 | −#define CS35L41_ASP_TX3_SRC 0x00004C28 | |
| 92 | −#define CS35L41_ASP_TX4_SRC 0x00004C2C | |
| 93 | −#define CS35L41_DSP1_RX1_SRC 0x00004C40 | |
| 94 | −#define CS35L41_DSP1_RX2_SRC 0x00004C44 | |
| 95 | −#define CS35L41_DSP1_RX3_SRC 0x00004C48 | |
| 96 | −#define CS35L41_DSP1_RX4_SRC 0x00004C4C | |
| 97 | −#define CS35L41_DSP1_RX5_SRC 0x00004C50 | |
| 98 | −#define CS35L41_DSP1_RX6_SRC 0x00004C54 | |
| 99 | −#define CS35L41_DSP1_RX7_SRC 0x00004C58 | |
| 100 | −#define CS35L41_DSP1_RX8_SRC 0x00004C5C | |
| 101 | −#define CS35L41_NGATE1_SRC 0x00004C60 | |
| 102 | −#define CS35L41_NGATE2_SRC 0x00004C64 | |
| 103 | −#define CS35L41_AMP_DIG_VOL_CTRL 0x00006000 | |
| 104 | −#define CS35L41_VPBR_CFG 0x00006404 | |
| 105 | −#define CS35L41_VBBR_CFG 0x00006408 | |
| 106 | −#define CS35L41_VPBR_STATUS 0x0000640C | |
| 107 | −#define CS35L41_VBBR_STATUS 0x00006410 | |
| 108 | −#define CS35L41_OVERTEMP_CFG 0x00006414 | |
| 109 | −#define CS35L41_AMP_ERR_VOL 0x00006418 | |
| 110 | −#define CS35L41_VOL_STATUS_TO_DSP 0x00006450 | |
| 111 | −#define CS35L41_CLASSH_CFG 0x00006800 | |
| 112 | −#define CS35L41_WKFET_CFG 0x00006804 | |
| 113 | −#define CS35L41_NG_CFG 0x00006808 | |
| 114 | −#define CS35L41_AMP_GAIN_CTRL 0x00006C04 | |
| 115 | −#define CS35L41_DAC_MSM_CFG 0x00007400 | |
| 116 | −#define CS35L41_IRQ1_CFG 0x00010000 | |
| 117 | −#define CS35L41_IRQ1_STATUS 0x00010004 | |
| 118 | −#define CS35L41_IRQ1_STATUS1 0x00010010 | |
| 119 | −#define CS35L41_IRQ1_STATUS2 0x00010014 | |
| 120 | −#define CS35L41_IRQ1_STATUS3 0x00010018 | |
| 121 | −#define CS35L41_IRQ1_STATUS4 0x0001001C | |
| 122 | −#define CS35L41_IRQ1_RAW_STATUS1 0x00010090 | |
| 123 | −#define CS35L41_IRQ1_RAW_STATUS2 0x00010094 | |
| 124 | −#define CS35L41_IRQ1_RAW_STATUS3 0x00010098 | |
| 125 | −#define CS35L41_IRQ1_RAW_STATUS4 0x0001009C | |
| 126 | −#define CS35L41_IRQ1_MASK1 0x00010110 | |
| 127 | −#define CS35L41_IRQ1_MASK2 0x00010114 | |
| 128 | −#define CS35L41_IRQ1_MASK3 0x00010118 | |
| 129 | −#define CS35L41_IRQ1_MASK4 0x0001011C | |
| 130 | −#define CS35L41_IRQ1_FRC1 0x00010190 | |
| 131 | −#define CS35L41_IRQ1_FRC2 0x00010194 | |
| 132 | −#define CS35L41_IRQ1_FRC3 0x00010198 | |
| 133 | −#define CS35L41_IRQ1_FRC4 0x0001019C | |
| 134 | −#define CS35L41_IRQ1_EDGE1 0x00010210 | |
| 135 | −#define CS35L41_IRQ1_EDGE4 0x0001021C | |
| 136 | −#define CS35L41_IRQ1_POL1 0x00010290 | |
| 137 | −#define CS35L41_IRQ1_POL2 0x00010294 | |
| 138 | −#define CS35L41_IRQ1_POL3 0x00010298 | |
| 139 | −#define CS35L41_IRQ1_POL4 0x0001029C | |
| 140 | −#define CS35L41_IRQ1_DB3 0x00010318 | |
| 141 | −#define CS35L41_IRQ2_CFG 0x00010800 | |
| 142 | −#define CS35L41_IRQ2_STATUS 0x00010804 | |
| 143 | −#define CS35L41_IRQ2_STATUS1 0x00010810 | |
| 144 | −#define CS35L41_IRQ2_STATUS2 0x00010814 | |
| 145 | −#define CS35L41_IRQ2_STATUS3 0x00010818 | |
| 146 | −#define CS35L41_IRQ2_STATUS4 0x0001081C | |
| 147 | −#define CS35L41_IRQ2_RAW_STATUS1 0x00010890 | |
| 148 | −#define CS35L41_IRQ2_RAW_STATUS2 0x00010894 | |
| 149 | −#define CS35L41_IRQ2_RAW_STATUS3 0x00010898 | |
| 150 | −#define CS35L41_IRQ2_RAW_STATUS4 0x0001089C | |
| 151 | −#define CS35L41_IRQ2_MASK1 0x00010910 | |
| 152 | −#define CS35L41_IRQ2_MASK2 0x00010914 | |
| 153 | −#define CS35L41_IRQ2_MASK3 0x00010918 | |
| 154 | −#define CS35L41_IRQ2_MASK4 0x0001091C | |
| 155 | −#define CS35L41_IRQ2_FRC1 0x00010990 | |
| 156 | −#define CS35L41_IRQ2_FRC2 0x00010994 | |
| 157 | −#define CS35L41_IRQ2_FRC3 0x00010998 | |
| 158 | −#define CS35L41_IRQ2_FRC4 0x0001099C | |
| 159 | −#define CS35L41_IRQ2_EDGE1 0x00010A10 | |
| 160 | −#define CS35L41_IRQ2_EDGE4 0x00010A1C | |
| 161 | −#define CS35L41_IRQ2_POL1 0x00010A90 | |
| 162 | −#define CS35L41_IRQ2_POL2 0x00010A94 | |
| 163 | −#define CS35L41_IRQ2_POL3 0x00010A98 | |
| 164 | −#define CS35L41_IRQ2_POL4 0x00010A9C | |
| 165 | −#define CS35L41_IRQ2_DB3 0x00010B18 | |
| 166 | −#define CS35L41_GPIO_STATUS1 0x00011000 | |
| 167 | −#define CS35L41_GPIO1_CTRL1 0x00011008 | |
| 168 | −#define CS35L41_GPIO2_CTRL1 0x0001100C | |
| 169 | −#define CS35L41_MIXER_NGATE_CFG 0x00012000 | |
| 170 | −#define CS35L41_MIXER_NGATE_CH1_CFG 0x00012004 | |
| 171 | −#define CS35L41_MIXER_NGATE_CH2_CFG 0x00012008 | |
| 172 | −#define CS35L41_DSP_MBOX_1 0x00013000 | |
| 173 | −#define CS35L41_DSP_MBOX_2 0x00013004 | |
| 174 | −#define CS35L41_DSP_MBOX_3 0x00013008 | |
| 175 | −#define CS35L41_DSP_MBOX_4 0x0001300C | |
| 176 | −#define CS35L41_DSP_MBOX_5 0x00013010 | |
| 177 | −#define CS35L41_DSP_MBOX_6 0x00013014 | |
| 178 | −#define CS35L41_DSP_MBOX_7 0x00013018 | |
| 179 | −#define CS35L41_DSP_MBOX_8 0x0001301C | |
| 180 | −#define CS35L41_DSP_VIRT1_MBOX_1 0x00013020 | |
| 181 | −#define CS35L41_DSP_VIRT1_MBOX_2 0x00013024 | |
| 182 | −#define CS35L41_DSP_VIRT1_MBOX_3 0x00013028 | |
| 183 | −#define CS35L41_DSP_VIRT1_MBOX_4 0x0001302C | |
| 184 | −#define CS35L41_DSP_VIRT1_MBOX_5 0x00013030 | |
| 185 | −#define CS35L41_DSP_VIRT1_MBOX_6 0x00013034 | |
| 186 | −#define CS35L41_DSP_VIRT1_MBOX_7 0x00013038 | |
| 187 | −#define CS35L41_DSP_VIRT1_MBOX_8 0x0001303C | |
| 188 | −#define CS35L41_DSP_VIRT2_MBOX_1 0x00013040 | |
| 189 | −#define CS35L41_DSP_VIRT2_MBOX_2 0x00013044 | |
| 190 | −#define CS35L41_DSP_VIRT2_MBOX_3 0x00013048 | |
| 191 | −#define CS35L41_DSP_VIRT2_MBOX_4 0x0001304C | |
| 192 | −#define CS35L41_DSP_VIRT2_MBOX_5 0x00013050 | |
| 193 | −#define CS35L41_DSP_VIRT2_MBOX_6 0x00013054 | |
| 194 | −#define CS35L41_DSP_VIRT2_MBOX_7 0x00013058 | |
| 195 | −#define CS35L41_DSP_VIRT2_MBOX_8 0x0001305C | |
| 196 | −#define CS35L41_CLOCK_DETECT_1 0x00014000 | |
| 197 | −#define CS35L41_TIMER1_CONTROL 0x00015000 | |
| 198 | −#define CS35L41_TIMER1_COUNT_PRESET 0x00015004 | |
| 199 | −#define CS35L41_TIMER1_START_STOP 0x0001500C | |
| 200 | −#define CS35L41_TIMER1_STATUS 0x00015010 | |
| 201 | −#define CS35L41_TIMER1_COUNT_READBACK 0x00015014 | |
| 202 | −#define CS35L41_TIMER1_DSP_CLK_CFG 0x00015018 | |
| 203 | −#define CS35L41_TIMER1_DSP_CLK_STATUS 0x0001501C | |
| 204 | −#define CS35L41_TIMER2_CONTROL 0x00015100 | |
| 205 | −#define CS35L41_TIMER2_COUNT_PRESET 0x00015104 | |
| 206 | −#define CS35L41_TIMER2_START_STOP 0x0001510C | |
| 207 | −#define CS35L41_TIMER2_STATUS 0x00015110 | |
| 208 | −#define CS35L41_TIMER2_COUNT_READBACK 0x00015114 | |
| 209 | −#define CS35L41_TIMER2_DSP_CLK_CFG 0x00015118 | |
| 210 | −#define CS35L41_TIMER2_DSP_CLK_STATUS 0x0001511C | |
| 211 | −#define CS35L41_DFT_JTAG_CONTROL 0x00016000 | |
| 212 | −#define CS35L41_DIE_STS1 0x00017040 | |
| 213 | −#define CS35L41_DIE_STS2 0x00017044 | |
| 214 | −#define CS35L41_TEMP_CAL1 0x00017048 | |
| 215 | −#define CS35L41_TEMP_CAL2 0x0001704C | |
| 216 | −#define CS35L41_DSP1_XMEM_PACK_0 0x02000000 | |
| 217 | −#define CS35L41_DSP1_XMEM_PACK_3068 0x02002FF0 | |
| 218 | −#define CS35L41_DSP1_XMEM_UNPACK32_0 0x02400000 | |
| 219 | −#define CS35L41_DSP1_XMEM_UNPACK32_2046 0x02401FF8 | |
| 220 | −#define CS35L41_DSP1_TIMESTAMP_COUNT 0x025C0800 | |
| 221 | −#define CS35L41_DSP1_SYS_ID 0x025E0000 | |
| 222 | −#define CS35L41_DSP1_SYS_VERSION 0x025E0004 | |
| 223 | −#define CS35L41_DSP1_SYS_CORE_ID 0x025E0008 | |
| 224 | −#define CS35L41_DSP1_SYS_AHB_ADDR 0x025E000C | |
| 225 | −#define CS35L41_DSP1_SYS_XSRAM_SIZE 0x025E0010 | |
| 226 | −#define CS35L41_DSP1_SYS_YSRAM_SIZE 0x025E0018 | |
| 227 | −#define CS35L41_DSP1_SYS_PSRAM_SIZE 0x025E0020 | |
| 228 | −#define CS35L41_DSP1_SYS_PM_BOOT_SIZE 0x025E0028 | |
| 229 | −#define CS35L41_DSP1_SYS_FEATURES 0x025E002C | |
| 230 | −#define CS35L41_DSP1_SYS_FIR_FILTERS 0x025E0030 | |
| 231 | −#define CS35L41_DSP1_SYS_LMS_FILTERS 0x025E0034 | |
| 232 | −#define CS35L41_DSP1_SYS_XM_BANK_SIZE 0x025E0038 | |
| 233 | −#define CS35L41_DSP1_SYS_YM_BANK_SIZE 0x025E003C | |
| 234 | −#define CS35L41_DSP1_SYS_PM_BANK_SIZE 0x025E0040 | |
| 235 | −#define CS35L41_DSP1_AHBM_WIN0_CTRL0 0x025E2000 | |
| 236 | −#define CS35L41_DSP1_AHBM_WIN0_CTRL1 0x025E2004 | |
| 237 | −#define CS35L41_DSP1_AHBM_WIN1_CTRL0 0x025E2008 | |
| 238 | −#define CS35L41_DSP1_AHBM_WIN1_CTRL1 0x025E200C | |
| 239 | −#define CS35L41_DSP1_AHBM_WIN2_CTRL0 0x025E2010 | |
| 240 | −#define CS35L41_DSP1_AHBM_WIN2_CTRL1 0x025E2014 | |
| 241 | −#define CS35L41_DSP1_AHBM_WIN3_CTRL0 0x025E2018 | |
| 242 | −#define CS35L41_DSP1_AHBM_WIN3_CTRL1 0x025E201C | |
| 243 | −#define CS35L41_DSP1_AHBM_WIN4_CTRL0 0x025E2020 | |
| 244 | −#define CS35L41_DSP1_AHBM_WIN4_CTRL1 0x025E2024 | |
| 245 | −#define CS35L41_DSP1_AHBM_WIN5_CTRL0 0x025E2028 | |
| 246 | −#define CS35L41_DSP1_AHBM_WIN5_CTRL1 0x025E202C | |
| 247 | −#define CS35L41_DSP1_AHBM_WIN6_CTRL0 0x025E2030 | |
| 248 | −#define CS35L41_DSP1_AHBM_WIN6_CTRL1 0x025E2034 | |
| 249 | −#define CS35L41_DSP1_AHBM_WIN7_CTRL0 0x025E2038 | |
| 250 | −#define CS35L41_DSP1_AHBM_WIN7_CTRL1 0x025E203C | |
| 251 | −#define CS35L41_DSP1_AHBM_WIN_DBG_CTRL0 0x025E2040 | |
| 252 | −#define CS35L41_DSP1_AHBM_WIN_DBG_CTRL1 0x025E2044 | |
| 253 | −#define CS35L41_DSP1_XMEM_UNPACK24_0 0x02800000 | |
| 254 | −#define CS35L41_DSP1_XMEM_UNPACK24_4093 0x02803FF4 | |
| 255 | −#define CS35L41_DSP1_CTRL_BASE 0x02B80000 | |
| 256 | −#define CS35L41_DSP1_CORE_SOFT_RESET 0x02B80010 | |
| 257 | −#define CS35L41_DSP1_DEBUG 0x02B80040 | |
| 258 | −#define CS35L41_DSP1_TIMER_CTRL 0x02B80048 | |
| 259 | −#define CS35L41_DSP1_STREAM_ARB_CTRL 0x02B80050 | |
| 260 | −#define CS35L41_DSP1_RX1_RATE 0x02B80080 | |
| 261 | −#define CS35L41_DSP1_RX2_RATE 0x02B80088 | |
| 262 | −#define CS35L41_DSP1_RX3_RATE 0x02B80090 | |
| 263 | −#define CS35L41_DSP1_RX4_RATE 0x02B80098 | |
| 264 | −#define CS35L41_DSP1_RX5_RATE 0x02B800A0 | |
| 265 | −#define CS35L41_DSP1_RX6_RATE 0x02B800A8 | |
| 266 | −#define CS35L41_DSP1_RX7_RATE 0x02B800B0 | |
| 267 | −#define CS35L41_DSP1_RX8_RATE 0x02B800B8 | |
| 268 | −#define CS35L41_DSP1_TX1_RATE 0x02B80280 | |
| 269 | −#define CS35L41_DSP1_TX2_RATE 0x02B80288 | |
| 270 | −#define CS35L41_DSP1_TX3_RATE 0x02B80290 | |
| 271 | −#define CS35L41_DSP1_TX4_RATE 0x02B80298 | |
| 272 | −#define CS35L41_DSP1_TX5_RATE 0x02B802A0 | |
| 273 | −#define CS35L41_DSP1_TX6_RATE 0x02B802A8 | |
| 274 | −#define CS35L41_DSP1_TX7_RATE 0x02B802B0 | |
| 275 | −#define CS35L41_DSP1_TX8_RATE 0x02B802B8 | |
| 276 | −#define CS35L41_DSP1_NMI_CTRL1 0x02B80480 | |
| 277 | −#define CS35L41_DSP1_NMI_CTRL2 0x02B80488 | |
| 278 | −#define CS35L41_DSP1_NMI_CTRL3 0x02B80490 | |
| 279 | −#define CS35L41_DSP1_NMI_CTRL4 0x02B80498 | |
| 280 | −#define CS35L41_DSP1_NMI_CTRL5 0x02B804A0 | |
| 281 | −#define CS35L41_DSP1_NMI_CTRL6 0x02B804A8 | |
| 282 | −#define CS35L41_DSP1_NMI_CTRL7 0x02B804B0 | |
| 283 | −#define CS35L41_DSP1_NMI_CTRL8 0x02B804B8 | |
| 284 | −#define CS35L41_DSP1_RESUME_CTRL 0x02B80500 | |
| 285 | −#define CS35L41_DSP1_IRQ1_CTRL 0x02B80508 | |
| 286 | −#define CS35L41_DSP1_IRQ2_CTRL 0x02B80510 | |
| 287 | −#define CS35L41_DSP1_IRQ3_CTRL 0x02B80518 | |
| 288 | −#define CS35L41_DSP1_IRQ4_CTRL 0x02B80520 | |
| 289 | −#define CS35L41_DSP1_IRQ5_CTRL 0x02B80528 | |
| 290 | −#define CS35L41_DSP1_IRQ6_CTRL 0x02B80530 | |
| 291 | −#define CS35L41_DSP1_IRQ7_CTRL 0x02B80538 | |
| 292 | −#define CS35L41_DSP1_IRQ8_CTRL 0x02B80540 | |
| 293 | −#define CS35L41_DSP1_IRQ9_CTRL 0x02B80548 | |
| 294 | −#define CS35L41_DSP1_IRQ10_CTRL 0x02B80550 | |
| 295 | −#define CS35L41_DSP1_IRQ11_CTRL 0x02B80558 | |
| 296 | −#define CS35L41_DSP1_IRQ12_CTRL 0x02B80560 | |
| 297 | −#define CS35L41_DSP1_IRQ13_CTRL 0x02B80568 | |
| 298 | −#define CS35L41_DSP1_IRQ14_CTRL 0x02B80570 | |
| 299 | −#define CS35L41_DSP1_IRQ15_CTRL 0x02B80578 | |
| 300 | −#define CS35L41_DSP1_IRQ16_CTRL 0x02B80580 | |
| 301 | −#define CS35L41_DSP1_IRQ17_CTRL 0x02B80588 | |
| 302 | −#define CS35L41_DSP1_IRQ18_CTRL 0x02B80590 | |
| 303 | −#define CS35L41_DSP1_IRQ19_CTRL 0x02B80598 | |
| 304 | −#define CS35L41_DSP1_IRQ20_CTRL 0x02B805A0 | |
| 305 | −#define CS35L41_DSP1_IRQ21_CTRL 0x02B805A8 | |
| 306 | −#define CS35L41_DSP1_IRQ22_CTRL 0x02B805B0 | |
| 307 | −#define CS35L41_DSP1_IRQ23_CTRL 0x02B805B8 | |
| 308 | −#define CS35L41_DSP1_SCRATCH1 0x02B805C0 | |
| 309 | −#define CS35L41_DSP1_SCRATCH2 0x02B805C8 | |
| 310 | −#define CS35L41_DSP1_SCRATCH3 0x02B805D0 | |
| 311 | −#define CS35L41_DSP1_SCRATCH4 0x02B805D8 | |
| 312 | −#define CS35L41_DSP1_CCM_CORE_CTRL 0x02BC1000 | |
| 313 | −#define CS35L41_DSP1_CCM_CLK_OVERRIDE 0x02BC1008 | |
| 314 | −#define CS35L41_DSP1_XM_MSTR_EN 0x02BC2000 | |
| 315 | −#define CS35L41_DSP1_XM_CORE_PRI 0x02BC2008 | |
| 316 | −#define CS35L41_DSP1_XM_AHB_PACK_PL_PRI 0x02BC2010 | |
| 317 | −#define CS35L41_DSP1_XM_AHB_UP_PL_PRI 0x02BC2018 | |
| 318 | −#define CS35L41_DSP1_XM_ACCEL_PL0_PRI 0x02BC2020 | |
| 319 | −#define CS35L41_DSP1_XM_NPL0_PRI 0x02BC2078 | |
| 320 | −#define CS35L41_DSP1_YM_MSTR_EN 0x02BC20C0 | |
| 321 | −#define CS35L41_DSP1_YM_CORE_PRI 0x02BC20C8 | |
| 322 | −#define CS35L41_DSP1_YM_AHB_PACK_PL_PRI 0x02BC20D0 | |
| 323 | −#define CS35L41_DSP1_YM_AHB_UP_PL_PRI 0x02BC20D8 | |
| 324 | −#define CS35L41_DSP1_YM_ACCEL_PL0_PRI 0x02BC20E0 | |
| 325 | −#define CS35L41_DSP1_YM_NPL0_PRI 0x02BC2138 | |
| 326 | −#define CS35L41_DSP1_PM_MSTR_EN 0x02BC2180 | |
| 327 | −#define CS35L41_DSP1_PM_PATCH0_ADDR 0x02BC2188 | |
| 328 | −#define CS35L41_DSP1_PM_PATCH0_EN 0x02BC218C | |
| 329 | −#define CS35L41_DSP1_PM_PATCH0_DATA_LO 0x02BC2190 | |
| 330 | −#define CS35L41_DSP1_PM_PATCH0_DATA_HI 0x02BC2194 | |
| 331 | −#define CS35L41_DSP1_PM_PATCH1_ADDR 0x02BC2198 | |
| 332 | −#define CS35L41_DSP1_PM_PATCH1_EN 0x02BC219C | |
| 333 | −#define CS35L41_DSP1_PM_PATCH1_DATA_LO 0x02BC21A0 | |
| 334 | −#define CS35L41_DSP1_PM_PATCH1_DATA_HI 0x02BC21A4 | |
| 335 | −#define CS35L41_DSP1_PM_PATCH2_ADDR 0x02BC21A8 | |
| 336 | −#define CS35L41_DSP1_PM_PATCH2_EN 0x02BC21AC | |
| 337 | −#define CS35L41_DSP1_PM_PATCH2_DATA_LO 0x02BC21B0 | |
| 338 | −#define CS35L41_DSP1_PM_PATCH2_DATA_HI 0x02BC21B4 | |
| 339 | −#define CS35L41_DSP1_PM_PATCH3_ADDR 0x02BC21B8 | |
| 340 | −#define CS35L41_DSP1_PM_PATCH3_EN 0x02BC21BC | |
| 341 | −#define CS35L41_DSP1_PM_PATCH3_DATA_LO 0x02BC21C0 | |
| 342 | −#define CS35L41_DSP1_PM_PATCH3_DATA_HI 0x02BC21C4 | |
| 343 | −#define CS35L41_DSP1_PM_PATCH4_ADDR 0x02BC21C8 | |
| 344 | −#define CS35L41_DSP1_PM_PATCH4_EN 0x02BC21CC | |
| 345 | −#define CS35L41_DSP1_PM_PATCH4_DATA_LO 0x02BC21D0 | |
| 346 | −#define CS35L41_DSP1_PM_PATCH4_DATA_HI 0x02BC21D4 | |
| 347 | −#define CS35L41_DSP1_PM_PATCH5_ADDR 0x02BC21D8 | |
| 348 | −#define CS35L41_DSP1_PM_PATCH5_EN 0x02BC21DC | |
| 349 | −#define CS35L41_DSP1_PM_PATCH5_DATA_LO 0x02BC21E0 | |
| 350 | −#define CS35L41_DSP1_PM_PATCH5_DATA_HI 0x02BC21E4 | |
| 351 | −#define CS35L41_DSP1_PM_PATCH6_ADDR 0x02BC21E8 | |
| 352 | −#define CS35L41_DSP1_PM_PATCH6_EN 0x02BC21EC | |
| 353 | −#define CS35L41_DSP1_PM_PATCH6_DATA_LO 0x02BC21F0 | |
| 354 | −#define CS35L41_DSP1_PM_PATCH6_DATA_HI 0x02BC21F4 | |
| 355 | −#define CS35L41_DSP1_PM_PATCH7_ADDR 0x02BC21F8 | |
| 356 | −#define CS35L41_DSP1_PM_PATCH7_EN 0x02BC21FC | |
| 357 | −#define CS35L41_DSP1_PM_PATCH7_DATA_LO 0x02BC2200 | |
| 358 | −#define CS35L41_DSP1_PM_PATCH7_DATA_HI 0x02BC2204 | |
| 359 | −#define CS35L41_DSP1_MPU_XM_ACCESS0 0x02BC3000 | |
| 360 | −#define CS35L41_DSP1_MPU_YM_ACCESS0 0x02BC3004 | |
| 361 | −#define CS35L41_DSP1_MPU_WNDW_ACCESS0 0x02BC3008 | |
| 362 | −#define CS35L41_DSP1_MPU_XREG_ACCESS0 0x02BC300C | |
| 363 | −#define CS35L41_DSP1_MPU_YREG_ACCESS0 0x02BC3014 | |
| 364 | −#define CS35L41_DSP1_MPU_XM_ACCESS1 0x02BC3018 | |
| 365 | −#define CS35L41_DSP1_MPU_YM_ACCESS1 0x02BC301C | |
| 366 | −#define CS35L41_DSP1_MPU_WNDW_ACCESS1 0x02BC3020 | |
| 367 | −#define CS35L41_DSP1_MPU_XREG_ACCESS1 0x02BC3024 | |
| 368 | −#define CS35L41_DSP1_MPU_YREG_ACCESS1 0x02BC302C | |
| 369 | −#define CS35L41_DSP1_MPU_XM_ACCESS2 0x02BC3030 | |
| 370 | −#define CS35L41_DSP1_MPU_YM_ACCESS2 0x02BC3034 | |
| 371 | −#define CS35L41_DSP1_MPU_WNDW_ACCESS2 0x02BC3038 | |
| 372 | −#define CS35L41_DSP1_MPU_XREG_ACCESS2 0x02BC303C | |
| 373 | −#define CS35L41_DSP1_MPU_YREG_ACCESS2 0x02BC3044 | |
| 374 | −#define CS35L41_DSP1_MPU_XM_ACCESS3 0x02BC3048 | |
| 375 | −#define CS35L41_DSP1_MPU_YM_ACCESS3 0x02BC304C | |
| 376 | −#define CS35L41_DSP1_MPU_WNDW_ACCESS3 0x02BC3050 | |
| 377 | −#define CS35L41_DSP1_MPU_XREG_ACCESS3 0x02BC3054 | |
| 378 | −#define CS35L41_DSP1_MPU_YREG_ACCESS3 0x02BC305C | |
| 379 | −#define CS35L41_DSP1_MPU_XM_VIO_ADDR 0x02BC3100 | |
| 380 | −#define CS35L41_DSP1_MPU_XM_VIO_STATUS 0x02BC3104 | |
| 381 | −#define CS35L41_DSP1_MPU_YM_VIO_ADDR 0x02BC3108 | |
| 382 | −#define CS35L41_DSP1_MPU_YM_VIO_STATUS 0x02BC310C | |
| 383 | −#define CS35L41_DSP1_MPU_PM_VIO_ADDR 0x02BC3110 | |
| 384 | −#define CS35L41_DSP1_MPU_PM_VIO_STATUS 0x02BC3114 | |
| 385 | −#define CS35L41_DSP1_MPU_LOCK_CONFIG 0x02BC3140 | |
| 386 | −#define CS35L41_DSP1_MPU_WDT_RST_CTRL 0x02BC3180 | |
| 387 | −#define CS35L41_DSP1_STRMARB_MSTR0_CFG0 0x02BC5000 | |
| 388 | −#define CS35L41_DSP1_STRMARB_MSTR0_CFG1 0x02BC5004 | |
| 389 | −#define CS35L41_DSP1_STRMARB_MSTR0_CFG2 0x02BC5008 | |
| 390 | −#define CS35L41_DSP1_STRMARB_MSTR1_CFG0 0x02BC5010 | |
| 391 | −#define CS35L41_DSP1_STRMARB_MSTR1_CFG1 0x02BC5014 | |
| 392 | −#define CS35L41_DSP1_STRMARB_MSTR1_CFG2 0x02BC5018 | |
| 393 | −#define CS35L41_DSP1_STRMARB_MSTR2_CFG0 0x02BC5020 | |
| 394 | −#define CS35L41_DSP1_STRMARB_MSTR2_CFG1 0x02BC5024 | |
| 395 | −#define CS35L41_DSP1_STRMARB_MSTR2_CFG2 0x02BC5028 | |
| 396 | −#define CS35L41_DSP1_STRMARB_MSTR3_CFG0 0x02BC5030 | |
| 397 | −#define CS35L41_DSP1_STRMARB_MSTR3_CFG1 0x02BC5034 | |
| 398 | −#define CS35L41_DSP1_STRMARB_MSTR3_CFG2 0x02BC5038 | |
| 399 | −#define CS35L41_DSP1_STRMARB_MSTR4_CFG0 0x02BC5040 | |
| 400 | −#define CS35L41_DSP1_STRMARB_MSTR4_CFG1 0x02BC5044 | |
| 401 | −#define CS35L41_DSP1_STRMARB_MSTR4_CFG2 0x02BC5048 | |
| 402 | −#define CS35L41_DSP1_STRMARB_MSTR5_CFG0 0x02BC5050 | |
| 403 | −#define CS35L41_DSP1_STRMARB_MSTR5_CFG1 0x02BC5054 | |
| 404 | −#define CS35L41_DSP1_STRMARB_MSTR5_CFG2 0x02BC5058 | |
| 405 | −#define CS35L41_DSP1_STRMARB_MSTR6_CFG0 0x02BC5060 | |
| 406 | −#define CS35L41_DSP1_STRMARB_MSTR6_CFG1 0x02BC5064 | |
| 407 | −#define CS35L41_DSP1_STRMARB_MSTR6_CFG2 0x02BC5068 | |
| 408 | −#define CS35L41_DSP1_STRMARB_MSTR7_CFG0 0x02BC5070 | |
| 409 | −#define CS35L41_DSP1_STRMARB_MSTR7_CFG1 0x02BC5074 | |
| 410 | −#define CS35L41_DSP1_STRMARB_MSTR7_CFG2 0x02BC5078 | |
| 411 | −#define CS35L41_DSP1_STRMARB_TX0_CFG0 0x02BC5200 | |
| 412 | −#define CS35L41_DSP1_STRMARB_TX0_CFG1 0x02BC5204 | |
| 413 | −#define CS35L41_DSP1_STRMARB_TX1_CFG0 0x02BC5208 | |
| 414 | −#define CS35L41_DSP1_STRMARB_TX1_CFG1 0x02BC520C | |
| 415 | −#define CS35L41_DSP1_STRMARB_TX2_CFG0 0x02BC5210 | |
| 416 | −#define CS35L41_DSP1_STRMARB_TX2_CFG1 0x02BC5214 | |
| 417 | −#define CS35L41_DSP1_STRMARB_TX3_CFG0 0x02BC5218 | |
| 418 | −#define CS35L41_DSP1_STRMARB_TX3_CFG1 0x02BC521C | |
| 419 | −#define CS35L41_DSP1_STRMARB_TX4_CFG0 0x02BC5220 | |
| 420 | −#define CS35L41_DSP1_STRMARB_TX4_CFG1 0x02BC5224 | |
| 421 | −#define CS35L41_DSP1_STRMARB_TX5_CFG0 0x02BC5228 | |
| 422 | −#define CS35L41_DSP1_STRMARB_TX5_CFG1 0x02BC522C | |
| 423 | −#define CS35L41_DSP1_STRMARB_TX6_CFG0 0x02BC5230 | |
| 424 | −#define CS35L41_DSP1_STRMARB_TX6_CFG1 0x02BC5234 | |
| 425 | −#define CS35L41_DSP1_STRMARB_TX7_CFG0 0x02BC5238 | |
| 426 | −#define CS35L41_DSP1_STRMARB_TX7_CFG1 0x02BC523C | |
| 427 | −#define CS35L41_DSP1_STRMARB_RX0_CFG0 0x02BC5400 | |
| 428 | −#define CS35L41_DSP1_STRMARB_RX0_CFG1 0x02BC5404 | |
| 429 | −#define CS35L41_DSP1_STRMARB_RX1_CFG0 0x02BC5408 | |
| 430 | −#define CS35L41_DSP1_STRMARB_RX1_CFG1 0x02BC540C | |
| 431 | −#define CS35L41_DSP1_STRMARB_RX2_CFG0 0x02BC5410 | |
| 432 | −#define CS35L41_DSP1_STRMARB_RX2_CFG1 0x02BC5414 | |
| 433 | −#define CS35L41_DSP1_STRMARB_RX3_CFG0 0x02BC5418 | |
| 434 | −#define CS35L41_DSP1_STRMARB_RX3_CFG1 0x02BC541C | |
| 435 | −#define CS35L41_DSP1_STRMARB_RX4_CFG0 0x02BC5420 | |
| 436 | −#define CS35L41_DSP1_STRMARB_RX4_CFG1 0x02BC5424 | |
| 437 | −#define CS35L41_DSP1_STRMARB_RX5_CFG0 0x02BC5428 | |
| 438 | −#define CS35L41_DSP1_STRMARB_RX5_CFG1 0x02BC542C | |
| 439 | −#define CS35L41_DSP1_STRMARB_RX6_CFG0 0x02BC5430 | |
| 440 | −#define CS35L41_DSP1_STRMARB_RX6_CFG1 0x02BC5434 | |
| 441 | −#define CS35L41_DSP1_STRMARB_RX7_CFG0 0x02BC5438 | |
| 442 | −#define CS35L41_DSP1_STRMARB_RX7_CFG1 0x02BC543C | |
| 443 | −#define CS35L41_DSP1_STRMARB_IRQ0_CFG0 0x02BC5600 | |
| 444 | −#define CS35L41_DSP1_STRMARB_IRQ0_CFG1 0x02BC5604 | |
| 445 | −#define CS35L41_DSP1_STRMARB_IRQ0_CFG2 0x02BC5608 | |
| 446 | −#define CS35L41_DSP1_STRMARB_IRQ1_CFG0 0x02BC5610 | |
| 447 | −#define CS35L41_DSP1_STRMARB_IRQ1_CFG1 0x02BC5614 | |
| 448 | −#define CS35L41_DSP1_STRMARB_IRQ1_CFG2 0x02BC5618 | |
| 449 | −#define CS35L41_DSP1_STRMARB_IRQ2_CFG0 0x02BC5620 | |
| 450 | −#define CS35L41_DSP1_STRMARB_IRQ2_CFG1 0x02BC5624 | |
| 451 | −#define CS35L41_DSP1_STRMARB_IRQ2_CFG2 0x02BC5628 | |
| 452 | −#define CS35L41_DSP1_STRMARB_IRQ3_CFG0 0x02BC5630 | |
| 453 | −#define CS35L41_DSP1_STRMARB_IRQ3_CFG1 0x02BC5634 | |
| 454 | −#define CS35L41_DSP1_STRMARB_IRQ3_CFG2 0x02BC5638 | |
| 455 | −#define CS35L41_DSP1_STRMARB_IRQ4_CFG0 0x02BC5640 | |
| 456 | −#define CS35L41_DSP1_STRMARB_IRQ4_CFG1 0x02BC5644 | |
| 457 | −#define CS35L41_DSP1_STRMARB_IRQ4_CFG2 0x02BC5648 | |
| 458 | −#define CS35L41_DSP1_STRMARB_IRQ5_CFG0 0x02BC5650 | |
| 459 | −#define CS35L41_DSP1_STRMARB_IRQ5_CFG1 0x02BC5654 | |
| 460 | −#define CS35L41_DSP1_STRMARB_IRQ5_CFG2 0x02BC5658 | |
| 461 | −#define CS35L41_DSP1_STRMARB_IRQ6_CFG0 0x02BC5660 | |
| 462 | −#define CS35L41_DSP1_STRMARB_IRQ6_CFG1 0x02BC5664 | |
| 463 | −#define CS35L41_DSP1_STRMARB_IRQ6_CFG2 0x02BC5668 | |
| 464 | −#define CS35L41_DSP1_STRMARB_IRQ7_CFG0 0x02BC5670 | |
| 465 | −#define CS35L41_DSP1_STRMARB_IRQ7_CFG1 0x02BC5674 | |
| 466 | −#define CS35L41_DSP1_STRMARB_IRQ7_CFG2 0x02BC5678 | |
| 467 | −#define CS35L41_DSP1_STRMARB_RESYNC_MSK 0x02BC5A00 | |
| 468 | −#define CS35L41_DSP1_STRMARB_ERR_STATUS 0x02BC5A08 | |
| 469 | −#define CS35L41_DSP1_INTPCTL_RES_STATIC 0x02BC6000 | |
| 470 | −#define CS35L41_DSP1_INTPCTL_RES_DYN 0x02BC6004 | |
| 471 | −#define CS35L41_DSP1_INTPCTL_NMI_CTRL 0x02BC6008 | |
| 472 | −#define CS35L41_DSP1_INTPCTL_IRQ_INV 0x02BC6010 | |
| 473 | −#define CS35L41_DSP1_INTPCTL_IRQ_MODE 0x02BC6014 | |
| 474 | −#define CS35L41_DSP1_INTPCTL_IRQ_EN 0x02BC6018 | |
| 475 | −#define CS35L41_DSP1_INTPCTL_IRQ_MSK 0x02BC601C | |
| 476 | −#define CS35L41_DSP1_INTPCTL_IRQ_FLUSH 0x02BC6020 | |
| 477 | −#define CS35L41_DSP1_INTPCTL_IRQ_MSKCLR 0x02BC6024 | |
| 478 | −#define CS35L41_DSP1_INTPCTL_IRQ_FRC 0x02BC6028 | |
| 479 | −#define CS35L41_DSP1_INTPCTL_IRQ_MSKSET 0x02BC602C | |
| 480 | −#define CS35L41_DSP1_INTPCTL_IRQ_ERR 0x02BC6030 | |
| 481 | −#define CS35L41_DSP1_INTPCTL_IRQ_PEND 0x02BC6034 | |
| 482 | −#define CS35L41_DSP1_INTPCTL_IRQ_GEN 0x02BC6038 | |
| 483 | −#define CS35L41_DSP1_INTPCTL_TESTBITS 0x02BC6040 | |
| 484 | −#define CS35L41_DSP1_WDT_CONTROL 0x02BC7000 | |
| 485 | −#define CS35L41_DSP1_WDT_STATUS 0x02BC7008 | |
| 486 | −#define CS35L41_DSP1_YMEM_PACK_0 0x02C00000 | |
| 487 | −#define CS35L41_DSP1_YMEM_PACK_1532 0x02C017F0 | |
| 488 | −#define CS35L41_DSP1_YMEM_UNPACK32_0 0x03000000 | |
| 489 | −#define CS35L41_DSP1_YMEM_UNPACK32_1022 0x03000FF8 | |
| 490 | −#define CS35L41_DSP1_YMEM_UNPACK24_0 0x03400000 | |
| 491 | −#define CS35L41_DSP1_YMEM_UNPACK24_2045 0x03401FF4 | |
| 492 | −#define CS35L41_DSP1_PMEM_0 0x03800000 | |
| 493 | −#define CS35L41_DSP1_PMEM_5114 0x03804FE8 | |
| 494 | − | |
| 495 | −/*test regs for emulation bringup*/ | |
| 496 | −#define CS35L41_PLL_OVR 0x00003018 | |
| 497 | −#define CS35L41_BST_TEST_DUTY 0x00003900 | |
| 498 | −#define CS35L41_DIGPWM_IOCTRL 0x0000706C | |
| 499 | − | |
| 500 | −/*registers populated by OTP*/ | |
| 501 | −#define CS35L41_OTP_TRIM_1 0x0000208c | |
| 502 | −#define CS35L41_OTP_TRIM_2 0x00002090 | |
| 503 | −#define CS35L41_OTP_TRIM_3 0x00003010 | |
| 504 | −#define CS35L41_OTP_TRIM_4 0x0000300C | |
| 505 | −#define CS35L41_OTP_TRIM_5 0x0000394C | |
| 506 | −#define CS35L41_OTP_TRIM_6 0x00003950 | |
| 507 | −#define CS35L41_OTP_TRIM_7 0x00003954 | |
| 508 | −#define CS35L41_OTP_TRIM_8 0x00003958 | |
| 509 | −#define CS35L41_OTP_TRIM_9 0x0000395C | |
| 510 | −#define CS35L41_OTP_TRIM_10 0x0000416C | |
| 511 | −#define CS35L41_OTP_TRIM_11 0x00004160 | |
| 512 | −#define CS35L41_OTP_TRIM_12 0x00004170 | |
| 513 | −#define CS35L41_OTP_TRIM_13 0x00004360 | |
| 514 | −#define CS35L41_OTP_TRIM_14 0x00004448 | |
| 515 | −#define CS35L41_OTP_TRIM_15 0x0000444C | |
| 516 | −#define CS35L41_OTP_TRIM_16 0x00006E30 | |
| 517 | −#define CS35L41_OTP_TRIM_17 0x00006E34 | |
| 518 | −#define CS35L41_OTP_TRIM_18 0x00006E38 | |
| 519 | −#define CS35L41_OTP_TRIM_19 0x00006E3C | |
| 520 | −#define CS35L41_OTP_TRIM_20 0x00006E40 | |
| 521 | −#define CS35L41_OTP_TRIM_21 0x00006E44 | |
| 522 | −#define CS35L41_OTP_TRIM_22 0x00006E48 | |
| 523 | −#define CS35L41_OTP_TRIM_23 0x00006E4C | |
| 524 | −#define CS35L41_OTP_TRIM_24 0x00006E50 | |
| 525 | −#define CS35L41_OTP_TRIM_25 0x00006E54 | |
| 526 | −#define CS35L41_OTP_TRIM_26 0x00006E58 | |
| 527 | −#define CS35L41_OTP_TRIM_27 0x00006E5C | |
| 528 | −#define CS35L41_OTP_TRIM_28 0x00006E60 | |
| 529 | −#define CS35L41_OTP_TRIM_29 0x00006E64 | |
| 530 | −#define CS35L41_OTP_TRIM_30 0x00007418 | |
| 531 | −#define CS35L41_OTP_TRIM_31 0x0000741C | |
| 532 | −#define CS35L41_OTP_TRIM_32 0x00007434 | |
| 533 | −#define CS35L41_OTP_TRIM_33 0x00007068 | |
| 534 | −#define CS35L41_OTP_TRIM_34 0x0000410C | |
| 535 | −#define CS35L41_OTP_TRIM_35 0x0000400C | |
| 536 | −#define CS35L41_OTP_TRIM_36 0x00002030 | |
| 537 | − | |
| 538 | −#define CS35L41_MAX_CACHE_REG 36 | |
| 539 | −#define CS35L41_OTP_SIZE_WORDS 32 | |
| 540 | −#define CS35L41_NUM_OTP_ELEM 100 | |
| 541 | −#define CS35L41_NUM_OTP_MAPS 5 | |
| 542 | − | |
| 543 | −#define CS35L41_VALID_PDATA 0x80000000 | |
| 544 | −#define CS35L41_NUM_SUPPLIES 2 | |
| 545 | − | |
| 546 | −#define CS35L41_SCLK_MSTR_MASK 0x10 | |
| 547 | −#define CS35L41_SCLK_MSTR_SHIFT 4 | |
| 548 | −#define CS35L41_LRCLK_MSTR_MASK 0x01 | |
| 549 | −#define CS35L41_LRCLK_MSTR_SHIFT 0 | |
| 550 | −#define CS35L41_SCLK_INV_MASK 0x40 | |
| 551 | −#define CS35L41_SCLK_INV_SHIFT 6 | |
| 552 | −#define CS35L41_LRCLK_INV_MASK 0x04 | |
| 553 | −#define CS35L41_LRCLK_INV_SHIFT 2 | |
| 554 | −#define CS35L41_SCLK_FRC_MASK 0x20 | |
| 555 | −#define CS35L41_SCLK_FRC_SHIFT 5 | |
| 556 | −#define CS35L41_LRCLK_FRC_MASK 0x02 | |
| 557 | −#define CS35L41_LRCLK_FRC_SHIFT 1 | |
| 558 | − | |
| 559 | −#define CS35L41_AMP_GAIN_PCM_MASK 0x3E0 | |
| 560 | −#define CS35L41_AMP_GAIN_ZC_MASK 0x0400 | |
| 561 | −#define CS35L41_AMP_GAIN_ZC_SHIFT 10 | |
| 562 | − | |
| 563 | −#define CS35L41_BST_CTL_MASK 0xFF | |
| 564 | −#define CS35L41_BST_CTL_SEL_MASK 0x03 | |
| 565 | −#define CS35L41_BST_CTL_SEL_REG 0x00 | |
| 566 | −#define CS35L41_BST_CTL_SEL_CLASSH 0x01 | |
| 567 | −#define CS35L41_BST_IPK_MASK 0x7F | |
| 568 | −#define CS35L41_BST_IPK_SHIFT 0 | |
| 569 | −#define CS35L41_BST_LIM_MASK 0x4 | |
| 570 | −#define CS35L41_BST_LIM_SHIFT 2 | |
| 571 | −#define CS35L41_BST_K1_MASK 0x000000FF | |
| 572 | −#define CS35L41_BST_K1_SHIFT 0 | |
| 573 | −#define CS35L41_BST_K2_MASK 0x0000FF00 | |
| 574 | −#define CS35L41_BST_K2_SHIFT 8 | |
| 575 | −#define CS35L41_BST_SLOPE_MASK 0x0000FF00 | |
| 576 | −#define CS35L41_BST_SLOPE_SHIFT 8 | |
| 577 | −#define CS35L41_BST_LBST_VAL_MASK 0x00000003 | |
| 578 | −#define CS35L41_BST_LBST_VAL_SHIFT 0 | |
| 579 | − | |
| 580 | −#define CS35L41_TEMP_THLD_MASK 0x03 | |
| 581 | −#define CS35L41_VMON_IMON_VOL_MASK 0x07FF07FF | |
| 582 | −#define CS35L41_PDM_MODE_MASK 0x01 | |
| 583 | −#define CS35L41_PDM_MODE_SHIFT 0 | |
| 584 | − | |
| 585 | −#define CS35L41_CH_MEM_DEPTH_MASK 0x07 | |
| 586 | −#define CS35L41_CH_MEM_DEPTH_SHIFT 0 | |
| 587 | −#define CS35L41_CH_HDRM_CTL_MASK 0x007F0000 | |
| 588 | −#define CS35L41_CH_HDRM_CTL_SHIFT 16 | |
| 589 | −#define CS35L41_CH_REL_RATE_MASK 0xFF00 | |
| 590 | −#define CS35L41_CH_REL_RATE_SHIFT 8 | |
| 591 | −#define CS35L41_CH_WKFET_DLY_MASK 0x001C | |
| 592 | −#define CS35L41_CH_WKFET_DLY_SHIFT 2 | |
| 593 | −#define CS35L41_CH_WKFET_THLD_MASK 0x0F00 | |
| 594 | −#define CS35L41_CH_WKFET_THLD_SHIFT 8 | |
| 595 | − | |
| 596 | −#define CS35L41_HW_NG_SEL_MASK 0x3F00 | |
| 597 | −#define CS35L41_HW_NG_SEL_SHIFT 8 | |
| 598 | −#define CS35L41_HW_NG_DLY_MASK 0x0070 | |
| 599 | −#define CS35L41_HW_NG_DLY_SHIFT 4 | |
| 600 | −#define CS35L41_HW_NG_THLD_MASK 0x0007 | |
| 601 | −#define CS35L41_HW_NG_THLD_SHIFT 0 | |
| 602 | − | |
| 603 | −#define CS35L41_DSP_NG_ENABLE_MASK 0x00010000 | |
| 604 | −#define CS35L41_DSP_NG_ENABLE_SHIFT 16 | |
| 605 | −#define CS35L41_DSP_NG_THLD_MASK 0x7 | |
| 606 | −#define CS35L41_DSP_NG_THLD_SHIFT 0 | |
| 607 | −#define CS35L41_DSP_NG_DELAY_MASK 0x0F00 | |
| 608 | −#define CS35L41_DSP_NG_DELAY_SHIFT 8 | |
| 609 | − | |
| 610 | −#define CS35L41_ASP_FMT_MASK 0x0700 | |
| 611 | −#define CS35L41_ASP_FMT_SHIFT 8 | |
| 612 | −#define CS35L41_ASP_DOUT_HIZ_MASK 0x03 | |
| 613 | −#define CS35L41_ASP_DOUT_HIZ_SHIFT 0 | |
| 614 | −#define CS35L41_ASP_WIDTH_16 0x10 | |
| 615 | −#define CS35L41_ASP_WIDTH_24 0x18 | |
| 616 | −#define CS35L41_ASP_WIDTH_32 0x20 | |
| 617 | −#define CS35L41_ASP_WIDTH_TX_MASK 0xFF0000 | |
| 618 | −#define CS35L41_ASP_WIDTH_TX_SHIFT 16 | |
| 619 | −#define CS35L41_ASP_WIDTH_RX_MASK 0xFF000000 | |
| 620 | −#define CS35L41_ASP_WIDTH_RX_SHIFT 24 | |
| 621 | −#define CS35L41_ASP_RX1_SLOT_MASK 0x3F | |
| 622 | −#define CS35L41_ASP_RX1_SLOT_SHIFT 0 | |
| 623 | −#define CS35L41_ASP_RX2_SLOT_MASK 0x3F00 | |
| 624 | −#define CS35L41_ASP_RX2_SLOT_SHIFT 8 | |
| 625 | −#define CS35L41_ASP_RX_WL_MASK 0x3F | |
| 626 | −#define CS35L41_ASP_TX_WL_MASK 0x3F | |
| 627 | −#define CS35L41_ASP_RX_WL_SHIFT 0 | |
| 628 | −#define CS35L41_ASP_TX_WL_SHIFT 0 | |
| 629 | −#define CS35L41_ASP_SOURCE_MASK 0x7F | |
| 630 | − | |
| 631 | −#define CS35L41_INPUT_SRC_ASPRX1 0x08 | |
| 632 | −#define CS35L41_INPUT_SRC_ASPRX2 0x09 | |
| 633 | −#define CS35L41_INPUT_SRC_VMON 0x18 | |
| 634 | −#define CS35L41_INPUT_SRC_IMON 0x19 | |
| 635 | −#define CS35L41_INPUT_SRC_CLASSH 0x21 | |
| 636 | −#define CS35L41_INPUT_SRC_VPMON 0x28 | |
| 637 | −#define CS35L41_INPUT_SRC_VBSTMON 0x29 | |
| 638 | −#define CS35L41_INPUT_SRC_TEMPMON 0x3A | |
| 639 | −#define CS35L41_INPUT_SRC_RSVD 0x3B | |
| 640 | −#define CS35L41_INPUT_DSP_TX1 0x32 | |
| 641 | −#define CS35L41_INPUT_DSP_TX2 0x33 | |
| 642 | − | |
| 643 | −#define CS35L41_PLL_CLK_SEL_MASK 0x07 | |
| 644 | −#define CS35L41_PLL_CLK_SEL_SHIFT 0 | |
| 645 | −#define CS35L41_PLL_CLK_EN_MASK 0x10 | |
| 646 | −#define CS35L41_PLL_CLK_EN_SHIFT 4 | |
| 647 | −#define CS35L41_PLL_OPENLOOP_MASK 0x0800 | |
| 648 | −#define CS35L41_PLL_OPENLOOP_SHIFT 11 | |
| 649 | −#define CS35L41_PLLSRC_SCLK 0 | |
| 650 | −#define CS35L41_PLLSRC_LRCLK 1 | |
| 651 | −#define CS35L41_PLLSRC_SELF 3 | |
| 652 | −#define CS35L41_PLLSRC_PDMCLK 4 | |
| 653 | −#define CS35L41_PLLSRC_MCLK 5 | |
| 654 | −#define CS35L41_PLLSRC_SWIRE 7 | |
| 655 | −#define CS35L41_REFCLK_FREQ_MASK 0x7E0 | |
| 656 | −#define CS35L41_REFCLK_FREQ_SHIFT 5 | |
| 657 | − | |
| 658 | −#define CS35L41_GLOBAL_FS_MASK 0x1F | |
| 659 | −#define CS35L41_GLOBAL_FS_SHIFT 0 | |
| 660 | − | |
| 661 | −#define CS35L41_GLOBAL_EN_MASK 0x01 | |
| 662 | −#define CS35L41_GLOBAL_EN_SHIFT 0 | |
| 663 | −#define CS35L41_BST_EN_MASK 0x0030 | |
| 664 | −#define CS35L41_BST_EN_SHIFT 4 | |
| 665 | −#define CS35L41_BST_EN_DEFAULT 0x2 | |
| 666 | −#define CS35L41_AMP_EN_SHIFT 0 | |
| 667 | −#define CS35L41_AMP_EN_MASK 1 | |
| 668 | − | |
| 669 | −#define CS35L41_PDN_DONE_MASK 0x00800000 | |
| 670 | −#define CS35L41_PDN_DONE_SHIFT 23 | |
| 671 | −#define CS35L41_PUP_DONE_MASK 0x01000000 | |
| 672 | −#define CS35L41_PUP_DONE_SHIFT 24 | |
| 673 | − | |
| 674 | −#define CS35L36_PUP_DONE_IRQ_UNMASK 0x5F | |
| 675 | −#define CS35L36_PUP_DONE_IRQ_MASK 0xBF | |
| 676 | − | |
| 677 | −#define CS35L41_AMP_SHORT_ERR 0x80000000 | |
| 678 | −#define CS35L41_BST_SHORT_ERR 0x0100 | |
| 679 | −#define CS35L41_TEMP_WARN 0x8000 | |
| 680 | −#define CS35L41_TEMP_ERR 0x00020000 | |
| 681 | −#define CS35L41_BST_OVP_ERR 0x40 | |
| 682 | −#define CS35L41_BST_DCM_UVP_ERR 0x80 | |
| 683 | −#define CS35L41_OTP_BOOT_DONE 0x02 | |
| 684 | −#define CS35L41_PLL_UNLOCK 0x10 | |
| 685 | −#define CS35L41_OTP_BOOT_ERR 0x80000000 | |
| 686 | − | |
| 687 | −#define CS35L41_AMP_SHORT_ERR_RLS 0x02 | |
| 688 | −#define CS35L41_BST_SHORT_ERR_RLS 0x04 | |
| 689 | −#define CS35L41_BST_OVP_ERR_RLS 0x08 | |
| 690 | −#define CS35L41_BST_UVP_ERR_RLS 0x10 | |
| 691 | −#define CS35L41_TEMP_WARN_ERR_RLS 0x20 | |
| 692 | −#define CS35L41_TEMP_ERR_RLS 0x40 | |
| 693 | − | |
| 694 | −#define CS35L41_INT1_MASK_DEFAULT 0x7FFCFE3F | |
| 695 | −#define CS35L41_INT1_UNMASK_PUP 0xFEFFFFFF | |
| 696 | −#define CS35L41_INT1_UNMASK_PDN 0xFF7FFFFF | |
| 697 | − | |
| 698 | −#define CS35L41_GPIO_DIR_MASK 0x80000000 | |
| 699 | −#define CS35L41_GPIO_DIR_SHIFT 31 | |
| 700 | −#define CS35L41_GPIO1_CTRL_MASK 0x00030000 | |
| 701 | −#define CS35L41_GPIO1_CTRL_SHIFT 16 | |
| 702 | −#define CS35L41_GPIO2_CTRL_MASK 0x07000000 | |
| 703 | −#define CS35L41_GPIO2_CTRL_SHIFT 24 | |
| 704 | −#define CS35L41_GPIO_CTRL_OPEN_INT 2 | |
| 705 | −#define CS35L41_GPIO_CTRL_ACTV_LO 4 | |
| 706 | −#define CS35L41_GPIO_CTRL_ACTV_HI 5 | |
| 707 | −#define CS35L41_GPIO_POL_MASK 0x1000 | |
| 708 | −#define CS35L41_GPIO_POL_SHIFT 12 | |
| 709 | − | |
| 710 | −#define CS35L41_AMP_INV_PCM_SHIFT 14 | |
| 711 | −#define CS35L41_AMP_INV_PCM_MASK BIT(CS35L41_AMP_INV_PCM_SHIFT) | |
| 712 | −#define CS35L41_AMP_PCM_VOL_SHIFT 3 | |
| 713 | −#define CS35L41_AMP_PCM_VOL_MASK (0x7FF << 3) | |
| 714 | −#define CS35L41_AMP_PCM_VOL_MUTE 0x4CF | |
| 715 | − | |
| 716 | −#define CS35L41_CHIP_ID 0x35a40 | |
| 717 | −#define CS35L41R_CHIP_ID 0x35b40 | |
| 718 | −#define CS35L41_MTLREVID_MASK 0x0F | |
| 719 | −#define CS35L41_REVID_A0 0xA0 | |
| 720 | −#define CS35L41_REVID_B0 0xB0 | |
| 721 | −#define CS35L41_REVID_B2 0xB2 | |
| 722 | − | |
| 723 | −#define CS35L41_HALO_CORE_RESET 0x00000200 | |
| 724 | − | |
| 725 | −#define CS35L41_FS1_WINDOW_MASK 0x000007FF | |
| 726 | −#define CS35L41_FS2_WINDOW_MASK 0x00FFF800 | |
| 727 | −#define CS35L41_FS2_WINDOW_SHIFT 12 | |
| 728 | − | |
| 729 | −#define CS35L41_SPI_MAX_FREQ 4000000 | |
| 19 | +#include "wm_adsp.h" | |
| 730 | 20 | |
| 731 | 21 | #define CS35L41_RX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) |
| 732 | 22 | #define CS35L41_TX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) |
| 733 | 23 | |
| 734 | −bool cs35l41_readable_reg(struct device *dev, unsigned int reg); | |
| 735 | −bool cs35l41_precious_reg(struct device *dev, unsigned int reg); | |
| 736 | −bool cs35l41_volatile_reg(struct device *dev, unsigned int reg); | |
| 24 | +extern const struct dev_pm_ops cs35l41_pm_ops; | |
| 737 | 25 | |
| 738 | −struct cs35l41_otp_packed_element_t { | |
| 739 | − u32 reg; | |
| 740 | − u8 shift; | |
| 741 | − u8 size; | |
| 26 | +enum cs35l41_cspl_mbox_status { | |
| 27 | + CSPL_MBOX_STS_RUNNING = 0, | |
| 28 | + CSPL_MBOX_STS_PAUSED = 1, | |
| 29 | + CSPL_MBOX_STS_RDY_FOR_REINIT = 2, | |
| 742 | 30 | }; |
| 743 | 31 | |
| 744 | −struct cs35l41_otp_map_element_t { | |
| 745 | − u32 id; | |
| 746 | − u32 num_elements; | |
| 747 | − const struct cs35l41_otp_packed_element_t *map; | |
| 748 | − u32 bit_offset; | |
| 749 | − u32 word_offset; | |
| 32 | +enum cs35l41_cspl_mbox_cmd { | |
| 33 | + CSPL_MBOX_CMD_NONE = 0, | |
| 34 | + CSPL_MBOX_CMD_PAUSE = 1, | |
| 35 | + CSPL_MBOX_CMD_RESUME = 2, | |
| 36 | + CSPL_MBOX_CMD_REINIT = 3, | |
| 37 | + CSPL_MBOX_CMD_STOP_PRE_REINIT = 4, | |
| 38 | + CSPL_MBOX_CMD_HIBERNATE = 5, | |
| 39 | + CSPL_MBOX_CMD_OUT_OF_HIBERNATE = 6, | |
| 40 | + CSPL_MBOX_CMD_UNKNOWN_CMD = -1, | |
| 41 | + CSPL_MBOX_CMD_INVALID_SEQUENCE = -2, | |
| 750 | 42 | }; |
| 751 | 43 | |
| 752 | −extern const struct reg_default cs35l41_reg[CS35L41_MAX_CACHE_REG]; | |
| 753 | −extern const struct cs35l41_otp_map_element_t | |
| 754 | − cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS]; | |
| 755 | − | |
| 756 | −#define CS35L41_REGSTRIDE 4 | |
| 757 | − | |
| 758 | 44 | struct cs35l41_private { |
| 45 | + struct wm_adsp dsp; /* needs to be first member */ | |
| 759 | 46 | struct snd_soc_codec *codec; |
| 760 | 47 | struct cs35l41_platform_data pdata; |
| 761 | 48 | struct device *dev; |
| @@ -611,8 +611,8 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client, · 610 unmodified lines | ||
| 611 | 611 | if (devid != CS4265_CHIP_ID_VAL) { |
| 612 | 612 | ret = -ENODEV; |
| 613 | 613 | dev_err(&i2c_client->dev, |
| 614 | − "CS4265 Device ID (%X). Expected %X\n", | |
| 615 | − devid, CS4265_CHIP_ID); | |
| 614 | + "CS4265 Part Number ID: 0x%x Expected: 0x%x\n", | |
| 615 | + devid >> 4, CS4265_CHIP_ID_VAL >> 4); | |
| 616 | 616 | return ret; |
| 617 | 617 | } |
| 618 | 618 | dev_info(&i2c_client->dev, |
| @@ -626,6 +626,16 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client, · 7 unmodified lines | ||
| 626 | 626 | ARRAY_SIZE(cs4265_dai)); |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | +static int cs4265_i2c_remove(struct i2c_client *i2c) | |
| 630 | +{ | |
| 631 | + struct cs4265_private *cs4265 = i2c_get_clientdata(i2c); | |
| 632 | + | |
| 633 | + if (cs4265->reset_gpio) | |
| 634 | + gpiod_set_value_cansleep(cs4265->reset_gpio, 0); | |
| 635 | + | |
| 636 | + return 0; | |
| 637 | +} | |
| 638 | + | |
| 629 | 639 | static const struct of_device_id cs4265_of_match[] = { |
| 630 | 640 | { .compatible = "cirrus,cs4265", }, |
| 631 | 641 | { } |
| @@ -645,6 +655,7 @@ static struct i2c_driver cs4265_i2c_driver = { · 13 unmodified lines | ||
| 645 | 655 | }, |
| 646 | 656 | .id_table = cs4265_id, |
| 647 | 657 | .probe = cs4265_i2c_probe, |
| 658 | + .remove = cs4265_i2c_remove, | |
| 648 | 659 | }; |
| 649 | 660 | |
| 650 | 661 | module_i2c_driver(cs4265_i2c_driver); |
| @@ -42,6 +42,7 @@ static const struct reg_default cs42l42_reg_defaults[] = { · 41 unmodified lines | ||
| 42 | 42 | { CS42L42_SRC_CTL, 0x10 }, |
| 43 | 43 | { CS42L42_MCLK_CTL, 0x02 }, |
| 44 | 44 | { CS42L42_SFTRAMP_RATE, 0xA4 }, |
| 45 | + { CS42L42_SLOW_START_ENABLE, 0x70 }, | |
| 45 | 46 | { CS42L42_I2C_DEBOUNCE, 0x88 }, |
| 46 | 47 | { CS42L42_I2C_STRETCH, 0x03 }, |
| 47 | 48 | { CS42L42_I2C_TIMEOUT, 0xB7 }, |
| @@ -177,6 +178,7 @@ static bool cs42l42_readable_register(struct device *dev, unsigned int reg) · 129 unmodified lines | ||
| 177 | 178 | case CS42L42_MCLK_STATUS: |
| 178 | 179 | case CS42L42_MCLK_CTL: |
| 179 | 180 | case CS42L42_SFTRAMP_RATE: |
| 181 | + case CS42L42_SLOW_START_ENABLE: | |
| 180 | 182 | case CS42L42_I2C_DEBOUNCE: |
| 181 | 183 | case CS42L42_I2C_STRETCH: |
| 182 | 184 | case CS42L42_I2C_TIMEOUT: |
| @@ -387,6 +389,28 @@ static const struct regmap_config cs42l42_regmap = { · 204 unmodified lines | ||
| 387 | 389 | static DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 100, true); |
| 388 | 390 | static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true); |
| 389 | 391 | |
| 392 | +static int cs42l42_slow_start_put(struct snd_kcontrol *kcontrol, | |
| 393 | + struct snd_ctl_elem_value *ucontrol) | |
| 394 | +{ | |
| 395 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); | |
| 396 | + u8 val; | |
| 397 | + | |
| 398 | + /* all bits of SLOW_START_EN much change together */ | |
| 399 | + switch (ucontrol->value.integer.value[0]) { | |
| 400 | + case 0: | |
| 401 | + val = 0; | |
| 402 | + break; | |
| 403 | + case 1: | |
| 404 | + val = CS42L42_SLOW_START_EN_MASK; | |
| 405 | + break; | |
| 406 | + default: | |
| 407 | + return -EINVAL; | |
| 408 | + } | |
| 409 | + | |
| 410 | + return snd_soc_component_update_bits(component, CS42L42_SLOW_START_ENABLE, | |
| 411 | + CS42L42_SLOW_START_EN_MASK, val); | |
| 412 | +} | |
| 413 | + | |
| 390 | 414 | static const char * const cs42l42_hpf_freq_text[] = { |
| 391 | 415 | "1.86Hz", "120Hz", "235Hz", "466Hz" |
| 392 | 416 | }; |
| @@ -431,7 +455,11 @@ static const struct snd_kcontrol_new cs42l42_snd_controls[] = { · 38 unmodified lines | ||
| 431 | 455 | CS42L42_DAC_HPF_EN_SHIFT, true, false), |
| 432 | 456 | SOC_DOUBLE_R_TLV("Mixer Volume", CS42L42_MIXER_CHA_VOL, |
| 433 | 457 | CS42L42_MIXER_CHB_VOL, CS42L42_MIXER_CH_VOL_SHIFT, |
| 434 | − 0x3f, 1, mixer_tlv) | |
| 458 | + 0x3f, 1, mixer_tlv), | |
| 459 | + | |
| 460 | + SOC_SINGLE_EXT("Slow Start Switch", CS42L42_SLOW_START_ENABLE, | |
| 461 | + CS42L42_SLOW_START_EN_SHIFT, true, false, | |
| 462 | + snd_soc_get_volsw, cs42l42_slow_start_put), | |
| 435 | 463 | }; |
| 436 | 464 | |
| 437 | 465 | static int cs42l42_hp_adc_ev(struct snd_soc_dapm_widget *w, |
| @@ -521,8 +549,25 @@ static int cs42l42_set_jack(struct snd_soc_component *component, struct snd_soc_ · 83 unmodified lines | ||
| 521 | 549 | { |
| 522 | 550 | struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); |
| 523 | 551 | |
| 552 | + /* Prevent race with interrupt handler */ | |
| 553 | + mutex_lock(&cs42l42->jack_detect_mutex); | |
| 524 | 554 | cs42l42->jack = jk; |
| 525 | 555 | |
| 556 | + if (jk) { | |
| 557 | + switch (cs42l42->hs_type) { | |
| 558 | + case CS42L42_PLUG_CTIA: | |
| 559 | + case CS42L42_PLUG_OMTP: | |
| 560 | + snd_soc_jack_report(jk, SND_JACK_HEADSET, SND_JACK_HEADSET); | |
| 561 | + break; | |
| 562 | + case CS42L42_PLUG_HEADPHONE: | |
| 563 | + snd_soc_jack_report(jk, SND_JACK_HEADPHONE, SND_JACK_HEADPHONE); | |
| 564 | + break; | |
| 565 | + default: | |
| 566 | + break; | |
| 567 | + } | |
| 568 | + } | |
| 569 | + mutex_unlock(&cs42l42->jack_detect_mutex); | |
| 570 | + | |
| 526 | 571 | return 0; |
| 527 | 572 | } |
| 528 | 573 | |
| @@ -706,10 +751,6 @@ static int cs42l42_pll_config(struct snd_soc_component *component) · 177 unmodified lines | ||
| 706 | 751 | CS42L42_PLL_DIVOUT_MASK, |
| 707 | 752 | (pll_ratio_table[i].pll_divout * pll_ratio_table[i].n) |
| 708 | 753 | << CS42L42_PLL_DIVOUT_SHIFT); |
| 709 | − if (pll_ratio_table[i].n != 1) | |
| 710 | − cs42l42->pll_divout = pll_ratio_table[i].pll_divout; | |
| 711 | − else | |
| 712 | − cs42l42->pll_divout = 0; | |
| 713 | 754 | snd_soc_component_update_bits(component, |
| 714 | 755 | CS42L42_PLL_CAL_RATIO, |
| 715 | 756 | CS42L42_PLL_CAL_RATIO_MASK, |
| @@ -976,12 +1017,13 @@ static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stream) · 260 unmodified lines | ||
| 976 | 1017 | snd_soc_component_update_bits(component, CS42L42_PLL_CTL1, |
| 977 | 1018 | CS42L42_PLL_START_MASK, 1); |
| 978 | 1019 | |
| 979 | − if (cs42l42->pll_divout) { | |
| 1020 | + if (pll_ratio_table[cs42l42->pll_config].n > 1) { | |
| 980 | 1021 | usleep_range(CS42L42_PLL_DIVOUT_TIME_US, |
| 981 | 1022 | CS42L42_PLL_DIVOUT_TIME_US * 2); |
| 1023 | + regval = pll_ratio_table[cs42l42->pll_config].pll_divout; | |
| 982 | 1024 | snd_soc_component_update_bits(component, CS42L42_PLL_CTL3, |
| 983 | 1025 | CS42L42_PLL_DIVOUT_MASK, |
| 984 | − cs42l42->pll_divout << | |
| 1026 | + regval << | |
| 985 | 1027 | CS42L42_PLL_DIVOUT_SHIFT); |
| 986 | 1028 | } |
| 987 | 1029 | |
| @@ -1242,10 +1284,8 @@ static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42) · 254 unmodified lines | ||
| 1242 | 1284 | /* Turn on level detect circuitry */ |
| 1243 | 1285 | regmap_update_bits(cs42l42->regmap, |
| 1244 | 1286 | CS42L42_MISC_DET_CTL, |
| 1245 | − CS42L42_DETECT_MODE_MASK | | |
| 1246 | 1287 | CS42L42_HSBIAS_CTL_MASK | |
| 1247 | 1288 | CS42L42_PDN_MIC_LVL_DET_MASK, |
| 1248 | − (0 << CS42L42_DETECT_MODE_SHIFT) | | |
| 1249 | 1289 | (3 << CS42L42_HSBIAS_CTL_SHIFT) | |
| 1250 | 1290 | (0 << CS42L42_PDN_MIC_LVL_DET_SHIFT)); |
| 1251 | 1291 | |
| @@ -1272,10 +1312,8 @@ static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42) · 20 unmodified lines | ||
| 1272 | 1312 | /* Make sure button detect and HS bias circuits are off */ |
| 1273 | 1313 | regmap_update_bits(cs42l42->regmap, |
| 1274 | 1314 | CS42L42_MISC_DET_CTL, |
| 1275 | − CS42L42_DETECT_MODE_MASK | | |
| 1276 | 1315 | CS42L42_HSBIAS_CTL_MASK | |
| 1277 | 1316 | CS42L42_PDN_MIC_LVL_DET_MASK, |
| 1278 | − (0 << CS42L42_DETECT_MODE_SHIFT) | | |
| 1279 | 1317 | (1 << CS42L42_HSBIAS_CTL_SHIFT) | |
| 1280 | 1318 | (1 << CS42L42_PDN_MIC_LVL_DET_SHIFT)); |
| 1281 | 1319 | } |
| @@ -1296,12 +1334,8 @@ static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42) · 14 unmodified lines | ||
| 1296 | 1334 | /* Unmask tip sense interrupts */ |
| 1297 | 1335 | regmap_update_bits(cs42l42->regmap, |
| 1298 | 1336 | CS42L42_TSRS_PLUG_INT_MASK, |
| 1299 | − CS42L42_RS_PLUG_MASK | | |
| 1300 | − CS42L42_RS_UNPLUG_MASK | | |
| 1301 | 1337 | CS42L42_TS_PLUG_MASK | |
| 1302 | 1338 | CS42L42_TS_UNPLUG_MASK, |
| 1303 | − (1 << CS42L42_RS_PLUG_SHIFT) | | |
| 1304 | − (1 << CS42L42_RS_UNPLUG_SHIFT) | | |
| 1305 | 1339 | (0 << CS42L42_TS_PLUG_SHIFT) | |
| 1306 | 1340 | (0 << CS42L42_TS_UNPLUG_SHIFT)); |
| 1307 | 1341 | } |
| @@ -1311,22 +1345,16 @@ static void cs42l42_init_hs_type_detect(struct cs42l42_private *cs42l42) · 3 unmodified lines | ||
| 1311 | 1345 | /* Mask tip sense interrupts */ |
| 1312 | 1346 | regmap_update_bits(cs42l42->regmap, |
| 1313 | 1347 | CS42L42_TSRS_PLUG_INT_MASK, |
| 1314 | − CS42L42_RS_PLUG_MASK | | |
| 1315 | − CS42L42_RS_UNPLUG_MASK | | |
| 1316 | 1348 | CS42L42_TS_PLUG_MASK | |
| 1317 | 1349 | CS42L42_TS_UNPLUG_MASK, |
| 1318 | − (1 << CS42L42_RS_PLUG_SHIFT) | | |
| 1319 | − (1 << CS42L42_RS_UNPLUG_SHIFT) | | |
| 1320 | 1350 | (1 << CS42L42_TS_PLUG_SHIFT) | |
| 1321 | 1351 | (1 << CS42L42_TS_UNPLUG_SHIFT)); |
| 1322 | 1352 | |
| 1323 | 1353 | /* Make sure button detect and HS bias circuits are off */ |
| 1324 | 1354 | regmap_update_bits(cs42l42->regmap, |
| 1325 | 1355 | CS42L42_MISC_DET_CTL, |
| 1326 | − CS42L42_DETECT_MODE_MASK | | |
| 1327 | 1356 | CS42L42_HSBIAS_CTL_MASK | |
| 1328 | 1357 | CS42L42_PDN_MIC_LVL_DET_MASK, |
| 1329 | − (0 << CS42L42_DETECT_MODE_SHIFT) | | |
| 1330 | 1358 | (1 << CS42L42_HSBIAS_CTL_SHIFT) | |
| 1331 | 1359 | (1 << CS42L42_PDN_MIC_LVL_DET_SHIFT)); |
| 1332 | 1360 | |
| @@ -1370,10 +1398,8 @@ static void cs42l42_init_hs_type_detect(struct cs42l42_private *cs42l42) · 37 unmodified lines | ||
| 1370 | 1398 | /* Power up HS bias to 2.7V */ |
| 1371 | 1399 | regmap_update_bits(cs42l42->regmap, |
| 1372 | 1400 | CS42L42_MISC_DET_CTL, |
| 1373 | − CS42L42_DETECT_MODE_MASK | | |
| 1374 | 1401 | CS42L42_HSBIAS_CTL_MASK | |
| 1375 | 1402 | CS42L42_PDN_MIC_LVL_DET_MASK, |
| 1376 | − (0 << CS42L42_DETECT_MODE_SHIFT) | | |
| 1377 | 1403 | (3 << CS42L42_HSBIAS_CTL_SHIFT) | |
| 1378 | 1404 | (1 << CS42L42_PDN_MIC_LVL_DET_SHIFT)); |
| 1379 | 1405 | |
| @@ -1420,10 +1446,8 @@ static void cs42l42_cancel_hs_type_detect(struct cs42l42_private *cs42l42) · 40 unmodified lines | ||
| 1420 | 1446 | /* Ground HS bias */ |
| 1421 | 1447 | regmap_update_bits(cs42l42->regmap, |
| 1422 | 1448 | CS42L42_MISC_DET_CTL, |
| 1423 | − CS42L42_DETECT_MODE_MASK | | |
| 1424 | 1449 | CS42L42_HSBIAS_CTL_MASK | |
| 1425 | 1450 | CS42L42_PDN_MIC_LVL_DET_MASK, |
| 1426 | − (0 << CS42L42_DETECT_MODE_SHIFT) | | |
| 1427 | 1451 | (1 << CS42L42_HSBIAS_CTL_SHIFT) | |
| 1428 | 1452 | (1 << CS42L42_PDN_MIC_LVL_DET_SHIFT)); |
| 1429 | 1453 | |
| @@ -1611,6 +1635,8 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) · 181 unmodified lines | ||
| 1611 | 1635 | CS42L42_M_DETECT_FT_MASK | |
| 1612 | 1636 | CS42L42_M_HSBIAS_HIZ_MASK); |
| 1613 | 1637 | |
| 1638 | + mutex_lock(&cs42l42->jack_detect_mutex); | |
| 1639 | + | |
| 1614 | 1640 | /* Check auto-detect status */ |
| 1615 | 1641 | if ((~masks[5]) & irq_params_table[5].mask) { |
| 1616 | 1642 | if (stickies[5] & CS42L42_HSDET_AUTO_DONE_MASK) { |
| @@ -1647,18 +1673,8 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) · 30 unmodified lines | ||
| 1647 | 1673 | cs42l42->plug_state = CS42L42_TS_UNPLUG; |
| 1648 | 1674 | cs42l42_cancel_hs_type_detect(cs42l42); |
| 1649 | 1675 | |
| 1650 | − switch (cs42l42->hs_type) { | |
| 1651 | − case CS42L42_PLUG_CTIA: | |
| 1652 | − case CS42L42_PLUG_OMTP: | |
| 1653 | − snd_soc_jack_report(cs42l42->jack, 0, SND_JACK_HEADSET); | |
| 1654 | − break; | |
| 1655 | − case CS42L42_PLUG_HEADPHONE: | |
| 1656 | − snd_soc_jack_report(cs42l42->jack, 0, SND_JACK_HEADPHONE); | |
| 1657 | − break; | |
| 1658 | − default: | |
| 1659 | − break; | |
| 1660 | − } | |
| 1661 | 1676 | snd_soc_jack_report(cs42l42->jack, 0, |
| 1677 | + SND_JACK_HEADSET | | |
| 1662 | 1678 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
| 1663 | 1679 | SND_JACK_BTN_2 | SND_JACK_BTN_3); |
| 1664 | 1680 | |
| @@ -1689,6 +1705,8 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) · 24 unmodified lines | ||
| 1689 | 1705 | } |
| 1690 | 1706 | } |
| 1691 | 1707 | |
| 1708 | + mutex_unlock(&cs42l42->jack_detect_mutex); | |
| 1709 | + | |
| 1692 | 1710 | return IRQ_HANDLED; |
| 1693 | 1711 | } |
| 1694 | 1712 | |
| @@ -1801,6 +1819,9 @@ static void cs42l42_setup_hs_type_detect(struct cs42l42_private *cs42l42) · 106 unmodified lines | ||
| 1801 | 1819 | |
| 1802 | 1820 | cs42l42->hs_type = CS42L42_PLUG_INVALID; |
| 1803 | 1821 | |
| 1822 | + regmap_update_bits(cs42l42->regmap, CS42L42_MISC_DET_CTL, | |
| 1823 | + CS42L42_DETECT_MODE_MASK, 0); | |
| 1824 | + | |
| 1804 | 1825 | /* Latch analog controls to VP power domain */ |
| 1805 | 1826 | regmap_update_bits(cs42l42->regmap, CS42L42_MIC_DET_CTL1, |
| 1806 | 1827 | CS42L42_LATCH_TO_VP_MASK | |
| @@ -2033,6 +2054,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, · 226 unmodified lines | ||
| 2033 | 2054 | |
| 2034 | 2055 | cs42l42->dev = &i2c_client->dev; |
| 2035 | 2056 | i2c_set_clientdata(i2c_client, cs42l42); |
| 2057 | + mutex_init(&cs42l42->jack_detect_mutex); | |
| 2036 | 2058 | |
| 2037 | 2059 | cs42l42->regmap = devm_regmap_init_i2c(i2c_client, &cs42l42_regmap); |
| 2038 | 2060 | if (IS_ERR(cs42l42->regmap)) { |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | #ifndef __CS42L42_H__ |
| 13 | 13 | #define __CS42L42_H__ |
| 14 | 14 | |
| 15 | +#include <linux/mutex.h> | |
| 15 | 16 | #include <sound/jack.h> |
| 16 | 17 | |
| 17 | 18 | #define CS42L42_PAGE_REGISTER 0x00 /* Page Select Register */ |
| @@ -62,6 +63,9 @@ · 44 unmodified lines | ||
| 62 | 63 | #define CS42L42_INTERNAL_FS_MASK (1 << CS42L42_INTERNAL_FS_SHIFT) |
| 63 | 64 | |
| 64 | 65 | #define CS42L42_SFTRAMP_RATE (CS42L42_PAGE_10 + 0x0A) |
| 66 | +#define CS42L42_SLOW_START_ENABLE (CS42L42_PAGE_10 + 0x0B) | |
| 67 | +#define CS42L42_SLOW_START_EN_MASK GENMASK(6, 4) | |
| 68 | +#define CS42L42_SLOW_START_EN_SHIFT 4 | |
| 65 | 69 | #define CS42L42_I2C_DEBOUNCE (CS42L42_PAGE_10 + 0x0E) |
| 66 | 70 | #define CS42L42_I2C_STRETCH (CS42L42_PAGE_10 + 0x0F) |
| 67 | 71 | #define CS42L42_I2C_TIMEOUT (CS42L42_PAGE_10 + 0x10) |
| @@ -838,11 +842,11 @@ struct cs42l42_private { · 770 unmodified lines | ||
| 838 | 842 | struct gpio_desc *reset_gpio; |
| 839 | 843 | struct completion pdn_done; |
| 840 | 844 | struct snd_soc_jack *jack; |
| 845 | + struct mutex jack_detect_mutex; | |
| 841 | 846 | int pll_config; |
| 842 | 847 | int bclk; |
| 843 | 848 | u32 sclk; |
| 844 | 849 | u32 srate; |
| 845 | − u8 pll_divout; | |
| 846 | 850 | u8 plug_state; |
| 847 | 851 | u8 hs_type; |
| 848 | 852 | u8 ts_inv; |
| @@ -255,7 +255,6 @@ static int es7241_probe(struct platform_device *pdev) · 254 unmodified lines | ||
| 255 | 255 | { |
| 256 | 256 | struct device *dev = &pdev->dev; |
| 257 | 257 | struct es7241_data *priv; |
| 258 | − int err; | |
| 259 | 258 | |
| 260 | 259 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 261 | 260 | if (!priv) |
| @@ -271,28 +270,19 @@ static int es7241_probe(struct platform_device *pdev) · 9 unmodified lines | ||
| 271 | 270 | es7241_parse_fmt(dev, priv); |
| 272 | 271 | |
| 273 | 272 | priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
| 274 | − if (IS_ERR(priv->reset)) { | |
| 275 | − err = PTR_ERR(priv->reset); | |
| 276 | − if (err != -EPROBE_DEFER) | |
| 277 | − dev_err(dev, "Failed to get 'reset' gpio: %d", err); | |
| 278 | − return err; | |
| 279 | − } | |
| 273 | + if (IS_ERR(priv->reset)) | |
| 274 | + return dev_err_probe(dev, PTR_ERR(priv->reset), | |
| 275 | + "Failed to get 'reset' gpio"); | |
| 280 | 276 | |
| 281 | 277 | priv->m0 = devm_gpiod_get_optional(dev, "m0", GPIOD_OUT_LOW); |
| 282 | − if (IS_ERR(priv->m0)) { | |
| 283 | − err = PTR_ERR(priv->m0); | |
| 284 | − if (err != -EPROBE_DEFER) | |
| 285 | − dev_err(dev, "Failed to get 'm0' gpio: %d", err); | |
| 286 | − return err; | |
| 287 | − } | |
| 278 | + if (IS_ERR(priv->m0)) | |
| 279 | + return dev_err_probe(dev, PTR_ERR(priv->m0), | |
| 280 | + "Failed to get 'm0' gpio"); | |
| 288 | 281 | |
| 289 | 282 | priv->m1 = devm_gpiod_get_optional(dev, "m1", GPIOD_OUT_LOW); |
| 290 | − if (IS_ERR(priv->m1)) { | |
| 291 | − err = PTR_ERR(priv->m1); | |
| 292 | − if (err != -EPROBE_DEFER) | |
| 293 | − dev_err(dev, "Failed to get 'm1' gpio: %d", err); | |
| 294 | − return err; | |
| 295 | − } | |
| 283 | + if (IS_ERR(priv->m1)) | |
| 284 | + return dev_err_probe(dev, PTR_ERR(priv->m1), | |
| 285 | + "Failed to get 'm1' gpio"); | |
| 296 | 286 | |
| 297 | 287 | return devm_snd_soc_register_component(&pdev->dev, |
| 298 | 288 | &es7241_component_driver, |
| @@ -46,9 +46,8 @@ static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream, · 45 unmodified lines | ||
| 46 | 46 | struct snd_soc_dai *dai); |
| 47 | 47 | static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream, |
| 48 | 48 | struct snd_soc_dai *dai); |
| 49 | −static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, | |
| 50 | − unsigned int tx_mask, unsigned int rx_mask, | |
| 51 | − int slots, int slot_width); | |
| 49 | +static int hdac_hda_dai_set_stream(struct snd_soc_dai *dai, void *stream, | |
| 50 | + int direction); | |
| 52 | 51 | static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt, |
| 53 | 52 | struct snd_soc_dai *dai); |
| 54 | 53 | |
| @@ -58,7 +57,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = { · 3 unmodified lines | ||
| 58 | 57 | .prepare = hdac_hda_dai_prepare, |
| 59 | 58 | .hw_params = hdac_hda_dai_hw_params, |
| 60 | 59 | .hw_free = hdac_hda_dai_hw_free, |
| 61 | − .set_tdm_slot = hdac_hda_dai_set_tdm_slot, | |
| 60 | + .set_stream = hdac_hda_dai_set_stream, | |
| 62 | 61 | }; |
| 63 | 62 | |
| 64 | 63 | static struct snd_soc_dai_driver hdac_hda_dais[] = { |
| @@ -180,21 +179,22 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = { · 115 unmodified lines | ||
| 180 | 179 | |
| 181 | 180 | }; |
| 182 | 181 | |
| 183 | −static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, | |
| 184 | − unsigned int tx_mask, unsigned int rx_mask, | |
| 185 | − int slots, int slot_width) | |
| 182 | +static int hdac_hda_dai_set_stream(struct snd_soc_dai *dai, | |
| 183 | + void *stream, int direction) | |
| 186 | 184 | { |
| 187 | 185 | struct snd_soc_component *component = dai->component; |
| 188 | 186 | struct hdac_hda_priv *hda_pvt; |
| 189 | 187 | struct hdac_hda_pcm *pcm; |
| 188 | + struct hdac_stream *hstream; | |
| 189 | + | |
| 190 | + if (!stream) | |
| 191 | + return -EINVAL; | |
| 190 | 192 | |
| 191 | 193 | hda_pvt = snd_soc_component_get_drvdata(component); |
| 192 | 194 | pcm = &hda_pvt->pcm[dai->id]; |
| 195 | + hstream = (struct hdac_stream *)stream; | |
| 193 | 196 | |
| 194 | − if (tx_mask) | |
| 195 | − pcm->stream_tag[SNDRV_PCM_STREAM_PLAYBACK] = tx_mask; | |
| 196 | − else | |
| 197 | − pcm->stream_tag[SNDRV_PCM_STREAM_CAPTURE] = rx_mask; | |
| 197 | + pcm->stream_tag[direction] = hstream->stream_tag; | |
| 198 | 198 | |
| 199 | 199 | return 0; |
| 200 | 200 | } |
| @@ -307,6 +307,7 @@ static const DECLARE_TLV_DB_MINMAX_MUTE(dac_tlv, -3100, 0); · 306 unmodified lines | ||
| 307 | 307 | static const DECLARE_TLV_DB_SCALE(adc_tlv, 0, 100, 0); |
| 308 | 308 | static const DECLARE_TLV_DB_MINMAX(out_tlv, -2500, 600); |
| 309 | 309 | static const DECLARE_TLV_DB_SCALE(linein_tlv, -2500, 100, 0); |
| 310 | +static const DECLARE_TLV_DB_MINMAX(mixer_tlv, -3100, 0); | |
| 310 | 311 | |
| 311 | 312 | /* Unconditional controls. */ |
| 312 | 313 | static const struct snd_kcontrol_new jz4770_codec_snd_controls[] = { |
| @@ -319,6 +320,14 @@ static const struct snd_kcontrol_new jz4770_codec_snd_controls[] = { · 6 unmodified lines | ||
| 319 | 320 | SOC_DOUBLE_R_TLV("Line In Bypass Playback Volume", |
| 320 | 321 | JZ4770_CODEC_REG_GCR_LIBYL, JZ4770_CODEC_REG_GCR_LIBYR, |
| 321 | 322 | REG_GCR_GAIN_OFFSET, REG_GCR_GAIN_MAX, 1, linein_tlv), |
| 323 | + | |
| 324 | + SOC_SINGLE_TLV("Mixer Capture Volume", | |
| 325 | + JZ4770_CODEC_REG_GCR_MIXADC, | |
| 326 | + REG_GCR_GAIN_OFFSET, REG_GCR_GAIN_MAX, 1, mixer_tlv), | |
| 327 | + | |
| 328 | + SOC_SINGLE_TLV("Mixer Playback Volume", | |
| 329 | + JZ4770_CODEC_REG_GCR_MIXDAC, | |
| 330 | + REG_GCR_GAIN_OFFSET, REG_GCR_GAIN_MAX, 1, mixer_tlv), | |
| 322 | 331 | }; |
| 323 | 332 | |
| 324 | 333 | static const struct snd_kcontrol_new jz4770_codec_pcm_playback_controls[] = { |
| @@ -140,7 +140,6 @@ static int max9759_probe(struct platform_device *pdev) · 139 unmodified lines | ||
| 140 | 140 | { |
| 141 | 141 | struct device *dev = &pdev->dev; |
| 142 | 142 | struct max9759 *priv; |
| 143 | − int err; | |
| 144 | 143 | |
| 145 | 144 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 146 | 145 | if (!priv) |
| @@ -149,29 +148,20 @@ static int max9759_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 149 | 148 | platform_set_drvdata(pdev, priv); |
| 150 | 149 | |
| 151 | 150 | priv->gpiod_shutdown = devm_gpiod_get(dev, "shutdown", GPIOD_OUT_HIGH); |
| 152 | − if (IS_ERR(priv->gpiod_shutdown)) { | |
| 153 | − err = PTR_ERR(priv->gpiod_shutdown); | |
| 154 | − if (err != -EPROBE_DEFER) | |
| 155 | − dev_err(dev, "Failed to get 'shutdown' gpio: %d", err); | |
| 156 | − return err; | |
| 157 | − } | |
| 151 | + if (IS_ERR(priv->gpiod_shutdown)) | |
| 152 | + return dev_err_probe(dev, PTR_ERR(priv->gpiod_shutdown), | |
| 153 | + "Failed to get 'shutdown' gpio"); | |
| 158 | 154 | |
| 159 | 155 | priv->gpiod_mute = devm_gpiod_get(dev, "mute", GPIOD_OUT_HIGH); |
| 160 | − if (IS_ERR(priv->gpiod_mute)) { | |
| 161 | − err = PTR_ERR(priv->gpiod_mute); | |
| 162 | − if (err != -EPROBE_DEFER) | |
| 163 | − dev_err(dev, "Failed to get 'mute' gpio: %d", err); | |
| 164 | − return err; | |
| 165 | − } | |
| 156 | + if (IS_ERR(priv->gpiod_mute)) | |
| 157 | + return dev_err_probe(dev, PTR_ERR(priv->gpiod_mute), | |
| 158 | + "Failed to get 'mute' gpio"); | |
| 166 | 159 | priv->is_mute = true; |
| 167 | 160 | |
| 168 | 161 | priv->gpiod_gain = devm_gpiod_get_array(dev, "gain", GPIOD_OUT_HIGH); |
| 169 | − if (IS_ERR(priv->gpiod_gain)) { | |
| 170 | − err = PTR_ERR(priv->gpiod_gain); | |
| 171 | − if (err != -EPROBE_DEFER) | |
| 172 | − dev_err(dev, "Failed to get 'gain' gpios: %d", err); | |
| 173 | − return err; | |
| 174 | − } | |
| 162 | + if (IS_ERR(priv->gpiod_gain)) | |
| 163 | + return dev_err_probe(dev, PTR_ERR(priv->gpiod_gain), | |
| 164 | + "Failed to get 'gain' gpios"); | |
| 175 | 165 | priv->gain = 0; |
| 176 | 166 | |
| 177 | 167 | if (priv->gpiod_gain->ndescs != 2) { |
| @@ -741,7 +741,7 @@ static int max98373_sdw_set_tdm_slot(struct snd_soc_dai *dai, · 740 unmodified lines | ||
| 741 | 741 | static const struct snd_soc_dai_ops max98373_dai_sdw_ops = { |
| 742 | 742 | .hw_params = max98373_sdw_dai_hw_params, |
| 743 | 743 | .hw_free = max98373_pcm_hw_free, |
| 744 | − .set_sdw_stream = max98373_set_sdw_stream, | |
| 744 | + .set_stream = max98373_set_sdw_stream, | |
| 745 | 745 | .shutdown = max98373_shutdown, |
| 746 | 746 | .set_tdm_slot = max98373_sdw_set_tdm_slot, |
| 747 | 747 | }; |
| @@ -606,12 +606,9 @@ static int max9860_probe(struct i2c_client *i2c) · 605 unmodified lines | ||
| 606 | 606 | return -ENOMEM; |
| 607 | 607 | |
| 608 | 608 | max9860->dvddio = devm_regulator_get(dev, "DVDDIO"); |
| 609 | − if (IS_ERR(max9860->dvddio)) { | |
| 610 | − ret = PTR_ERR(max9860->dvddio); | |
| 611 | − if (ret != -EPROBE_DEFER) | |
| 612 | − dev_err(dev, "Failed to get DVDDIO supply: %d\n", ret); | |
| 613 | − return ret; | |
| 614 | − } | |
| 609 | + if (IS_ERR(max9860->dvddio)) | |
| 610 | + return dev_err_probe(dev, PTR_ERR(max9860->dvddio), | |
| 611 | + "Failed to get DVDDIO supply\n"); | |
| 615 | 612 | |
| 616 | 613 | max9860->dvddio_nb.notifier_call = max9860_dvddio_event; |
| 617 | 614 | |
| @@ -643,8 +640,7 @@ static int max9860_probe(struct i2c_client *i2c) · 25 unmodified lines | ||
| 643 | 640 | |
| 644 | 641 | if (IS_ERR(mclk)) { |
| 645 | 642 | ret = PTR_ERR(mclk); |
| 646 | − if (ret != -EPROBE_DEFER) | |
| 647 | − dev_err(dev, "Failed to get MCLK: %d\n", ret); | |
| 643 | + dev_err_probe(dev, ret, "Failed to get MCLK\n"); | |
| 648 | 644 | goto err_regulator; |
| 649 | 645 | } |
| 650 | 646 | |
| @@ -822,8 +822,8 @@ static const struct snd_soc_dapm_route pm8916_wcd_analog_audio_map[] = { · 821 unmodified lines | ||
| 822 | 822 | {"EAR PA", NULL, "EAR CP"}, |
| 823 | 823 | |
| 824 | 824 | /* Headset (RX MIX1 and RX MIX2) */ |
| 825 | − {"HEADPHONE", NULL, "HPHL PA"}, | |
| 826 | − {"HEADPHONE", NULL, "HPHR PA"}, | |
| 825 | + {"HPH_L", NULL, "HPHL PA"}, | |
| 826 | + {"HPH_R", NULL, "HPHR PA"}, | |
| 827 | 827 | |
| 828 | 828 | {"HPHL DAC", NULL, "EAR_HPHL_CLK"}, |
| 829 | 829 | {"HPHR DAC", NULL, "EAR_HPHR_CLK"}, |
| @@ -870,7 +870,8 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { · 40 unmodified lines | ||
| 870 | 870 | SND_SOC_DAPM_INPUT("AMIC3"), |
| 871 | 871 | SND_SOC_DAPM_INPUT("AMIC2"), |
| 872 | 872 | SND_SOC_DAPM_OUTPUT("EAR"), |
| 873 | − SND_SOC_DAPM_OUTPUT("HEADPHONE"), | |
| 873 | + SND_SOC_DAPM_OUTPUT("HPH_L"), | |
| 874 | + SND_SOC_DAPM_OUTPUT("HPH_R"), | |
| 874 | 875 | |
| 875 | 876 | /* RX stuff */ |
| 876 | 877 | SND_SOC_DAPM_SUPPLY("INT_LDO_H", SND_SOC_NOPM, 1, 0, NULL, 0), |
| @@ -47,13 +47,12 @@ static int mt6660_reg_write(void *context, unsigned int reg, unsigned int val) · 46 unmodified lines | ||
| 47 | 47 | struct mt6660_chip *chip = context; |
| 48 | 48 | int size = mt6660_get_reg_size(reg); |
| 49 | 49 | u8 reg_data[4]; |
| 50 | − int i, ret; | |
| 50 | + int i; | |
| 51 | 51 | |
| 52 | 52 | for (i = 0; i < size; i++) |
| 53 | 53 | reg_data[size - i - 1] = (val >> (8 * i)) & 0xff; |
| 54 | 54 | |
| 55 | − ret = i2c_smbus_write_i2c_block_data(chip->i2c, reg, size, reg_data); | |
| 56 | − return ret; | |
| 55 | + return i2c_smbus_write_i2c_block_data(chip->i2c, reg, size, reg_data); | |
| 57 | 56 | } |
| 58 | 57 | |
| 59 | 58 | static int mt6660_reg_read(void *context, unsigned int reg, unsigned int *val) |
| @@ -751,21 +751,14 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) · 750 unmodified lines | ||
| 751 | 751 | pcm3168a->gpio_rst = devm_gpiod_get_optional(dev, "reset", |
| 752 | 752 | GPIOD_OUT_LOW | |
| 753 | 753 | GPIOD_FLAGS_BIT_NONEXCLUSIVE); |
| 754 | − if (IS_ERR(pcm3168a->gpio_rst)) { | |
| 755 | − ret = PTR_ERR(pcm3168a->gpio_rst); | |
| 756 | − if (ret != -EPROBE_DEFER ) | |
| 757 | − dev_err(dev, "failed to acquire RST gpio: %d\n", ret); | |
| 758 | − | |
| 759 | − return ret; | |
| 760 | − } | |
| 754 | + if (IS_ERR(pcm3168a->gpio_rst)) | |
| 755 | + return dev_err_probe(dev, PTR_ERR(pcm3168a->gpio_rst), | |
| 756 | + "failed to acquire RST gpio\n"); | |
| 761 | 757 | |
| 762 | 758 | pcm3168a->scki = devm_clk_get(dev, "scki"); |
| 763 | − if (IS_ERR(pcm3168a->scki)) { | |
| 764 | − ret = PTR_ERR(pcm3168a->scki); | |
| 765 | − if (ret != -EPROBE_DEFER) | |
| 766 | − dev_err(dev, "failed to acquire clock 'scki': %d\n", ret); | |
| 767 | − return ret; | |
| 768 | − } | |
| 759 | + if (IS_ERR(pcm3168a->scki)) | |
| 760 | + return dev_err_probe(dev, PTR_ERR(pcm3168a->scki), | |
| 761 | + "failed to acquire clock 'scki'\n"); | |
| 769 | 762 | |
| 770 | 763 | ret = clk_prepare_enable(pcm3168a->scki); |
| 771 | 764 | if (ret) { |
| @@ -781,8 +774,7 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) · 9 unmodified lines | ||
| 781 | 774 | ret = devm_regulator_bulk_get(dev, |
| 782 | 775 | ARRAY_SIZE(pcm3168a->supplies), pcm3168a->supplies); |
| 783 | 776 | if (ret) { |
| 784 | − if (ret != -EPROBE_DEFER) | |
| 785 | − dev_err(dev, "failed to request supplies: %d\n", ret); | |
| 777 | + dev_err_probe(dev, ret, "failed to request supplies\n"); | |
| 786 | 778 | goto err_clk; |
| 787 | 779 | } |
| 788 | 780 | |
| @@ -613,7 +613,7 @@ static const struct snd_soc_component_driver soc_component_sdw_rt1308 = { · 612 unmodified lines | ||
| 613 | 613 | static const struct snd_soc_dai_ops rt1308_aif_dai_ops = { |
| 614 | 614 | .hw_params = rt1308_sdw_hw_params, |
| 615 | 615 | .hw_free = rt1308_sdw_pcm_hw_free, |
| 616 | − .set_sdw_stream = rt1308_set_sdw_stream, | |
| 616 | + .set_stream = rt1308_set_sdw_stream, | |
| 617 | 617 | .shutdown = rt1308_sdw_shutdown, |
| 618 | 618 | .set_tdm_slot = rt1308_sdw_set_tdm_slot, |
| 619 | 619 | }; |
| @@ -602,7 +602,7 @@ static const struct snd_soc_component_driver soc_component_sdw_rt1316 = { · 601 unmodified lines | ||
| 602 | 602 | static const struct snd_soc_dai_ops rt1316_aif_dai_ops = { |
| 603 | 603 | .hw_params = rt1316_sdw_hw_params, |
| 604 | 604 | .hw_free = rt1316_sdw_pcm_hw_free, |
| 605 | − .set_sdw_stream = rt1316_set_sdw_stream, | |
| 605 | + .set_stream = rt1316_set_sdw_stream, | |
| 606 | 606 | .shutdown = rt1316_sdw_shutdown, |
| 607 | 607 | }; |
| 608 | 608 | |
| @@ -195,6 +195,7 @@ static bool rt5640_volatile_register(struct device *dev, unsigned int reg) · 194 unmodified lines | ||
| 195 | 195 | case RT5640_PRIV_DATA: |
| 196 | 196 | case RT5640_PGM_REG_ARR1: |
| 197 | 197 | case RT5640_PGM_REG_ARR3: |
| 198 | + case RT5640_DUMMY2: | |
| 198 | 199 | case RT5640_VENDOR_ID: |
| 199 | 200 | case RT5640_VENDOR_ID1: |
| 200 | 201 | case RT5640_VENDOR_ID2: |
| @@ -1972,7 +1973,7 @@ static int rt5640_set_bias_level(struct snd_soc_component *component, · 1771 unmodified lines | ||
| 1972 | 1973 | RT5640_PWR_FV1 | RT5640_PWR_FV2, |
| 1973 | 1974 | RT5640_PWR_FV1 | RT5640_PWR_FV2); |
| 1974 | 1975 | snd_soc_component_update_bits(component, RT5640_DUMMY1, |
| 1975 | − 0x0301, 0x0301); | |
| 1976 | + 0x1, 0x1); | |
| 1976 | 1977 | snd_soc_component_update_bits(component, RT5640_MICBIAS, |
| 1977 | 1978 | 0x0030, 0x0030); |
| 1978 | 1979 | } |
| @@ -2159,7 +2160,11 @@ static bool rt5640_jack_inserted(struct snd_soc_component *component) · 180 unmodified lines | ||
| 2159 | 2160 | struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); |
| 2160 | 2161 | int val; |
| 2161 | 2162 | |
| 2162 | − val = snd_soc_component_read(component, RT5640_INT_IRQ_ST); | |
| 2163 | + if (rt5640->jd_gpio) | |
| 2164 | + val = gpiod_get_value(rt5640->jd_gpio) ? RT5640_JD_STATUS : 0; | |
| 2165 | + else | |
| 2166 | + val = snd_soc_component_read(component, RT5640_INT_IRQ_ST); | |
| 2167 | + | |
| 2163 | 2168 | dev_dbg(component->dev, "irq status %#04x\n", val); |
| 2164 | 2169 | |
| 2165 | 2170 | if (rt5640->jd_inverted) |
| @@ -2297,10 +2302,42 @@ EXPORT_SYMBOL_GPL(rt5640_detect_headset); · 131 unmodified lines | ||
| 2297 | 2302 | static void rt5640_jack_work(struct work_struct *work) |
| 2298 | 2303 | { |
| 2299 | 2304 | struct rt5640_priv *rt5640 = |
| 2300 | − container_of(work, struct rt5640_priv, jack_work); | |
| 2305 | + container_of(work, struct rt5640_priv, jack_work.work); | |
| 2301 | 2306 | struct snd_soc_component *component = rt5640->component; |
| 2302 | 2307 | int status; |
| 2303 | 2308 | |
| 2309 | + if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) { | |
| 2310 | + int val, jack_type = 0, hda_mic_plugged, hda_hp_plugged; | |
| 2311 | + | |
| 2312 | + /* mic jack */ | |
| 2313 | + val = snd_soc_component_read(component, RT5640_INT_IRQ_ST); | |
| 2314 | + hda_mic_plugged = !(val & RT5640_JD_STATUS); | |
| 2315 | + dev_dbg(component->dev, "mic jack status %d\n", | |
| 2316 | + hda_mic_plugged); | |
| 2317 | + | |
| 2318 | + snd_soc_component_update_bits(component, RT5640_IRQ_CTRL1, | |
| 2319 | + RT5640_JD_P_MASK, !hda_mic_plugged << RT5640_JD_P_SFT); | |
| 2320 | + | |
| 2321 | + if (hda_mic_plugged) | |
| 2322 | + jack_type |= SND_JACK_MICROPHONE; | |
| 2323 | + | |
| 2324 | + /* headphone jack */ | |
| 2325 | + val = snd_soc_component_read(component, RT5640_DUMMY2); | |
| 2326 | + hda_hp_plugged = !(val & (0x1 << 11)); | |
| 2327 | + dev_dbg(component->dev, "headphone jack status %d\n", | |
| 2328 | + hda_hp_plugged); | |
| 2329 | + | |
| 2330 | + snd_soc_component_update_bits(component, RT5640_DUMMY2, | |
| 2331 | + (0x1 << 10), !hda_hp_plugged << 10); | |
| 2332 | + | |
| 2333 | + if (hda_hp_plugged) | |
| 2334 | + jack_type |= SND_JACK_HEADPHONE; | |
| 2335 | + | |
| 2336 | + snd_soc_jack_report(rt5640->jack, jack_type, SND_JACK_HEADSET); | |
| 2337 | + | |
| 2338 | + return; | |
| 2339 | + } | |
| 2340 | + | |
| 2304 | 2341 | if (!rt5640_jack_inserted(component)) { |
| 2305 | 2342 | /* Jack removed, or spurious IRQ? */ |
| 2306 | 2343 | if (rt5640->jack->status & SND_JACK_HEADPHONE) { |
| @@ -2348,7 +2385,7 @@ static void rt5640_jack_work(struct work_struct *work) · 41 unmodified lines | ||
| 2348 | 2385 | * disabled the OVCD IRQ, the IRQ pin will stay high and as |
| 2349 | 2386 | * we react to edges, we miss the unplug event -> recheck. |
| 2350 | 2387 | */ |
| 2351 | − queue_work(system_long_wq, &rt5640->jack_work); | |
| 2388 | + queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); | |
| 2352 | 2389 | } |
| 2353 | 2390 | } |
| 2354 | 2391 | |
| @@ -2357,7 +2394,17 @@ static irqreturn_t rt5640_irq(int irq, void *data) · 2 unmodified lines | ||
| 2357 | 2394 | struct rt5640_priv *rt5640 = data; |
| 2358 | 2395 | |
| 2359 | 2396 | if (rt5640->jack) |
| 2360 | − queue_work(system_long_wq, &rt5640->jack_work); | |
| 2397 | + queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); | |
| 2398 | + | |
| 2399 | + return IRQ_HANDLED; | |
| 2400 | +} | |
| 2401 | + | |
| 2402 | +static irqreturn_t rt5640_jd_gpio_irq(int irq, void *data) | |
| 2403 | +{ | |
| 2404 | + struct rt5640_priv *rt5640 = data; | |
| 2405 | + | |
| 2406 | + queue_delayed_work(system_long_wq, &rt5640->jack_work, | |
| 2407 | + msecs_to_jiffies(JACK_SETTLE_TIME)); | |
| 2361 | 2408 | |
| 2362 | 2409 | return IRQ_HANDLED; |
| 2363 | 2410 | } |
| @@ -2366,7 +2413,7 @@ static void rt5640_cancel_work(void *data) · 2 unmodified lines | ||
| 2366 | 2413 | { |
| 2367 | 2414 | struct rt5640_priv *rt5640 = data; |
| 2368 | 2415 | |
| 2369 | − cancel_work_sync(&rt5640->jack_work); | |
| 2416 | + cancel_delayed_work_sync(&rt5640->jack_work); | |
| 2370 | 2417 | cancel_delayed_work_sync(&rt5640->bp_work); |
| 2371 | 2418 | } |
| 2372 | 2419 | |
| @@ -2406,7 +2453,12 @@ static void rt5640_disable_jack_detect(struct snd_soc_component *component) · 33 unmodified lines | ||
| 2406 | 2453 | if (!rt5640->jack) |
| 2407 | 2454 | return; |
| 2408 | 2455 | |
| 2409 | − free_irq(rt5640->irq, rt5640); | |
| 2456 | + if (rt5640->jd_gpio_irq_requested) | |
| 2457 | + free_irq(rt5640->jd_gpio_irq, rt5640); | |
| 2458 | + | |
| 2459 | + if (rt5640->irq_requested) | |
| 2460 | + free_irq(rt5640->irq, rt5640); | |
| 2461 | + | |
| 2410 | 2462 | rt5640_cancel_work(rt5640); |
| 2411 | 2463 | |
| 2412 | 2464 | if (rt5640->jack->status & SND_JACK_MICROPHONE) { |
| @@ -2415,11 +2467,15 @@ static void rt5640_disable_jack_detect(struct snd_soc_component *component) · 2 unmodified lines | ||
| 2415 | 2467 | snd_soc_jack_report(rt5640->jack, 0, SND_JACK_BTN_0); |
| 2416 | 2468 | } |
| 2417 | 2469 | |
| 2470 | + rt5640->jd_gpio_irq_requested = false; | |
| 2471 | + rt5640->irq_requested = false; | |
| 2472 | + rt5640->jd_gpio = NULL; | |
| 2418 | 2473 | rt5640->jack = NULL; |
| 2419 | 2474 | } |
| 2420 | 2475 | |
| 2421 | 2476 | static void rt5640_enable_jack_detect(struct snd_soc_component *component, |
| 2422 | − struct snd_soc_jack *jack) | |
| 2477 | + struct snd_soc_jack *jack, | |
| 2478 | + struct rt5640_set_jack_data *jack_data) | |
| 2423 | 2479 | { |
| 2424 | 2480 | struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); |
| 2425 | 2481 | int ret; |
| @@ -2463,28 +2519,90 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component, · 37 unmodified lines | ||
| 2463 | 2519 | rt5640_enable_micbias1_ovcd_irq(component); |
| 2464 | 2520 | } |
| 2465 | 2521 | |
| 2522 | + if (jack_data && jack_data->codec_irq_override) | |
| 2523 | + rt5640->irq = jack_data->codec_irq_override; | |
| 2524 | + | |
| 2525 | + if (jack_data && jack_data->jd_gpio) { | |
| 2526 | + rt5640->jd_gpio = jack_data->jd_gpio; | |
| 2527 | + rt5640->jd_gpio_irq = gpiod_to_irq(rt5640->jd_gpio); | |
| 2528 | + | |
| 2529 | + ret = request_irq(rt5640->jd_gpio_irq, rt5640_jd_gpio_irq, | |
| 2530 | + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | |
| 2531 | + "rt5640-jd-gpio", rt5640); | |
| 2532 | + if (ret) { | |
| 2533 | + dev_warn(component->dev, "Failed to request jd GPIO IRQ %d: %d\n", | |
| 2534 | + rt5640->jd_gpio_irq, ret); | |
| 2535 | + rt5640_disable_jack_detect(component); | |
| 2536 | + return; | |
| 2537 | + } | |
| 2538 | + rt5640->jd_gpio_irq_requested = true; | |
| 2539 | + } | |
| 2540 | + | |
| 2466 | 2541 | ret = request_irq(rt5640->irq, rt5640_irq, |
| 2467 | 2542 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
| 2468 | 2543 | "rt5640", rt5640); |
| 2469 | 2544 | if (ret) { |
| 2470 | 2545 | dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret); |
| 2471 | − rt5640->irq = -ENXIO; | |
| 2472 | − /* Undo above settings */ | |
| 2473 | 2546 | rt5640_disable_jack_detect(component); |
| 2474 | 2547 | return; |
| 2475 | 2548 | } |
| 2549 | + rt5640->irq_requested = true; | |
| 2550 | + | |
| 2551 | + /* sync initial jack state */ | |
| 2552 | + queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); | |
| 2553 | +} | |
| 2554 | + | |
| 2555 | +static void rt5640_enable_hda_jack_detect( | |
| 2556 | + struct snd_soc_component *component, struct snd_soc_jack *jack) | |
| 2557 | +{ | |
| 2558 | + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); | |
| 2559 | + int ret; | |
| 2560 | + | |
| 2561 | + /* Select JD1 for Mic */ | |
| 2562 | + snd_soc_component_update_bits(component, RT5640_JD_CTRL, | |
| 2563 | + RT5640_JD_MASK, RT5640_JD_JD1_IN4P); | |
| 2564 | + snd_soc_component_write(component, RT5640_IRQ_CTRL1, RT5640_IRQ_JD_NOR); | |
| 2565 | + | |
| 2566 | + /* Select JD2 for Headphone */ | |
| 2567 | + snd_soc_component_update_bits(component, RT5640_DUMMY2, 0x1100, 0x1100); | |
| 2568 | + | |
| 2569 | + /* Selecting GPIO01 as an interrupt */ | |
| 2570 | + snd_soc_component_update_bits(component, RT5640_GPIO_CTRL1, | |
| 2571 | + RT5640_GP1_PIN_MASK, RT5640_GP1_PIN_IRQ); | |
| 2572 | + | |
| 2573 | + /* Set GPIO1 output */ | |
| 2574 | + snd_soc_component_update_bits(component, RT5640_GPIO_CTRL3, | |
| 2575 | + RT5640_GP1_PF_MASK, RT5640_GP1_PF_OUT); | |
| 2576 | + | |
| 2577 | + snd_soc_component_update_bits(component, RT5640_DUMMY1, 0x400, 0x0); | |
| 2578 | + | |
| 2579 | + rt5640->jack = jack; | |
| 2580 | + | |
| 2581 | + ret = request_irq(rt5640->irq, rt5640_irq, | |
| 2582 | + IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5640", rt5640); | |
| 2583 | + if (ret) { | |
| 2584 | + dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret); | |
| 2585 | + rt5640->irq = -ENXIO; | |
| 2586 | + return; | |
| 2587 | + } | |
| 2476 | 2588 | |
| 2477 | 2589 | /* sync initial jack state */ |
| 2478 | − queue_work(system_long_wq, &rt5640->jack_work); | |
| 2590 | + queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); | |
| 2479 | 2591 | } |
| 2480 | 2592 | |
| 2481 | 2593 | static int rt5640_set_jack(struct snd_soc_component *component, |
| 2482 | 2594 | struct snd_soc_jack *jack, void *data) |
| 2483 | 2595 | { |
| 2484 | − if (jack) | |
| 2485 | − rt5640_enable_jack_detect(component, jack); | |
| 2486 | − else | |
| 2596 | + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); | |
| 2597 | + | |
| 2598 | + if (jack) { | |
| 2599 | + if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) | |
| 2600 | + rt5640_enable_hda_jack_detect(component, jack); | |
| 2601 | + else | |
| 2602 | + rt5640_enable_jack_detect(component, jack, data); | |
| 2603 | + } else { | |
| 2487 | 2604 | rt5640_disable_jack_detect(component); |
| 2605 | + } | |
| 2488 | 2606 | |
| 2489 | 2607 | return 0; |
| 2490 | 2608 | } |
| @@ -2574,11 +2692,16 @@ static int rt5640_probe(struct snd_soc_component *component) · 83 unmodified lines | ||
| 2574 | 2692 | |
| 2575 | 2693 | if (device_property_read_u32(component->dev, |
| 2576 | 2694 | "realtek,jack-detect-source", &val) == 0) { |
| 2577 | − if (val <= RT5640_JD_SRC_GPIO4) | |
| 2695 | + if (val <= RT5640_JD_SRC_GPIO4) { | |
| 2578 | 2696 | rt5640->jd_src = val << RT5640_JD_SFT; |
| 2579 | − else | |
| 2697 | + } else if (val == RT5640_JD_SRC_HDA_HEADER) { | |
| 2698 | + rt5640->jd_src = RT5640_JD_SRC_HDA_HEADER; | |
| 2699 | + snd_soc_component_update_bits(component, RT5640_DUMMY1, | |
| 2700 | + 0x0300, 0x0); | |
| 2701 | + } else { | |
| 2580 | 2702 | dev_warn(component->dev, "Warning: Invalid jack-detect-source value: %d, leaving jack-detect disabled\n", |
| 2581 | 2703 | val); |
| 2704 | + } | |
| 2582 | 2705 | } |
| 2583 | 2706 | |
| 2584 | 2707 | if (!device_property_read_bool(component->dev, "realtek,jack-detect-not-inverted")) |
| @@ -2632,6 +2755,7 @@ static int rt5640_suspend(struct snd_soc_component *component) · 47 unmodified lines | ||
| 2632 | 2755 | { |
| 2633 | 2756 | struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); |
| 2634 | 2757 | |
| 2758 | + rt5640_cancel_work(rt5640); | |
| 2635 | 2759 | snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); |
| 2636 | 2760 | rt5640_reset(component); |
| 2637 | 2761 | regcache_cache_only(rt5640->regmap, true); |
| @@ -2654,6 +2778,17 @@ static int rt5640_resume(struct snd_soc_component *component) · 16 unmodified lines | ||
| 2654 | 2778 | regcache_cache_only(rt5640->regmap, false); |
| 2655 | 2779 | regcache_sync(rt5640->regmap); |
| 2656 | 2780 | |
| 2781 | + if (rt5640->jack) { | |
| 2782 | + if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) | |
| 2783 | + snd_soc_component_update_bits(component, | |
| 2784 | + RT5640_DUMMY2, 0x1100, 0x1100); | |
| 2785 | + else | |
| 2786 | + snd_soc_component_write(component, RT5640_DUMMY2, | |
| 2787 | + 0x4001); | |
| 2788 | + | |
| 2789 | + queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); | |
| 2790 | + } | |
| 2791 | + | |
| 2657 | 2792 | return 0; |
| 2658 | 2793 | } |
| 2659 | 2794 | #else |
| @@ -2856,7 +2991,7 @@ static int rt5640_i2c_probe(struct i2c_client *i2c, · 196 unmodified lines | ||
| 2856 | 2991 | rt5640->hp_mute = true; |
| 2857 | 2992 | rt5640->irq = i2c->irq; |
| 2858 | 2993 | INIT_DELAYED_WORK(&rt5640->bp_work, rt5640_button_press_work); |
| 2859 | − INIT_WORK(&rt5640->jack_work, rt5640_jack_work); | |
| 2994 | + INIT_DELAYED_WORK(&rt5640->jack_work, rt5640_jack_work); | |
| 2860 | 2995 | |
| 2861 | 2996 | /* Make sure work is stopped on probe-error / remove */ |
| 2862 | 2997 | ret = devm_add_action_or_reset(&i2c->dev, rt5640_cancel_work, rt5640); |
| @@ -2124,6 +2124,7 @@ struct rt5640_priv { · 2123 unmodified lines | ||
| 2124 | 2124 | |
| 2125 | 2125 | int ldo1_en; /* GPIO for LDO1_EN */ |
| 2126 | 2126 | int irq; |
| 2127 | + int jd_gpio_irq; | |
| 2127 | 2128 | int sysclk; |
| 2128 | 2129 | int sysclk_src; |
| 2129 | 2130 | int lrck[RT5640_AIFS]; |
| @@ -2136,6 +2137,8 @@ struct rt5640_priv { · 6 unmodified lines | ||
| 2136 | 2137 | |
| 2137 | 2138 | bool hp_mute; |
| 2138 | 2139 | bool asrc_en; |
| 2140 | + bool irq_requested; | |
| 2141 | + bool jd_gpio_irq_requested; | |
| 2139 | 2142 | |
| 2140 | 2143 | /* Jack and button detect data */ |
| 2141 | 2144 | bool ovcd_irq_enabled; |
| @@ -2145,14 +2148,20 @@ struct rt5640_priv { · 3 unmodified lines | ||
| 2145 | 2148 | int release_count; |
| 2146 | 2149 | int poll_count; |
| 2147 | 2150 | struct delayed_work bp_work; |
| 2148 | − struct work_struct jack_work; | |
| 2151 | + struct delayed_work jack_work; | |
| 2149 | 2152 | struct snd_soc_jack *jack; |
| 2153 | + struct gpio_desc *jd_gpio; | |
| 2150 | 2154 | unsigned int jd_src; |
| 2151 | 2155 | bool jd_inverted; |
| 2152 | 2156 | unsigned int ovcd_th; |
| 2153 | 2157 | unsigned int ovcd_sf; |
| 2154 | 2158 | }; |
| 2155 | 2159 | |
| 2160 | +struct rt5640_set_jack_data { | |
| 2161 | + int codec_irq_override; | |
| 2162 | + struct gpio_desc *jd_gpio; | |
| 2163 | +}; | |
| 2164 | + | |
| 2156 | 2165 | int rt5640_dmic_enable(struct snd_soc_component *component, |
| 2157 | 2166 | bool dmic1_data_pin, bool dmic2_data_pin); |
| 2158 | 2167 | int rt5640_sel_asrc_clk_src(struct snd_soc_component *component, |
| @@ -3461,6 +3461,7 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663) · 3460 unmodified lines | ||
| 3461 | 3461 | static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev) |
| 3462 | 3462 | { |
| 3463 | 3463 | int table_size; |
| 3464 | + int ret; | |
| 3464 | 3465 | |
| 3465 | 3466 | device_property_read_u32(dev, "realtek,dc_offset_l_manual", |
| 3466 | 3467 | &rt5663->pdata.dc_offset_l_manual); |
| @@ -3477,9 +3478,11 @@ static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev) · 10 unmodified lines | ||
| 3477 | 3478 | table_size = sizeof(struct impedance_mapping_table) * |
| 3478 | 3479 | rt5663->pdata.impedance_sensing_num; |
| 3479 | 3480 | rt5663->imp_table = devm_kzalloc(dev, table_size, GFP_KERNEL); |
| 3480 | − device_property_read_u32_array(dev, | |
| 3481 | + ret = device_property_read_u32_array(dev, | |
| 3481 | 3482 | "realtek,impedance_sensing_table", |
| 3482 | 3483 | (u32 *)rt5663->imp_table, table_size); |
| 3484 | + if (ret) | |
| 3485 | + return ret; | |
| 3483 | 3486 | } |
| 3484 | 3487 | |
| 3485 | 3488 | return 0; |
| @@ -3504,8 +3507,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, · 18 unmodified lines | ||
| 3504 | 3507 | |
| 3505 | 3508 | if (pdata) |
| 3506 | 3509 | rt5663->pdata = *pdata; |
| 3507 | − else | |
| 3508 | − rt5663_parse_dp(rt5663, &i2c->dev); | |
| 3510 | + else { | |
| 3511 | + ret = rt5663_parse_dp(rt5663, &i2c->dev); | |
| 3512 | + if (ret) | |
| 3513 | + return ret; | |
| 3514 | + } | |
| 3509 | 3515 | |
| 3510 | 3516 | for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++) |
| 3511 | 3517 | rt5663->supplies[i].supply = rt5663_supply_names[i]; |
| @@ -272,7 +272,7 @@ static int rt5682_sdw_hw_free(struct snd_pcm_substream *substream, · 271 unmodified lines | ||
| 272 | 272 | static const struct snd_soc_dai_ops rt5682_sdw_ops = { |
| 273 | 273 | .hw_params = rt5682_sdw_hw_params, |
| 274 | 274 | .hw_free = rt5682_sdw_hw_free, |
| 275 | − .set_sdw_stream = rt5682_set_sdw_stream, | |
| 275 | + .set_stream = rt5682_set_sdw_stream, | |
| 276 | 276 | .shutdown = rt5682_sdw_shutdown, |
| 277 | 277 | }; |
| 278 | 278 | |
| @@ -2862,7 +2862,6 @@ int rt5682_register_dai_clks(struct rt5682_priv *rt5682) · 2861 unmodified lines | ||
| 2862 | 2862 | |
| 2863 | 2863 | for (i = 0; i < RT5682_DAI_NUM_CLKS; ++i) { |
| 2864 | 2864 | struct clk_init_data init = { }; |
| 2865 | − struct clk_parent_data parent_data; | |
| 2866 | 2865 | const struct clk_hw *parent; |
| 2867 | 2866 | |
| 2868 | 2867 | dai_clk_hw = &rt5682->dai_clks_hw[i]; |
| @@ -2871,10 +2870,8 @@ int rt5682_register_dai_clks(struct rt5682_priv *rt5682) · 2 unmodified lines | ||
| 2871 | 2870 | case RT5682_DAI_WCLK_IDX: |
| 2872 | 2871 | /* Make MCLK the parent of WCLK */ |
| 2873 | 2872 | if (rt5682->mclk) { |
| 2874 | − parent_data = (struct clk_parent_data){ | |
| 2875 | − .fw_name = "mclk", | |
| 2876 | − }; | |
| 2877 | − init.parent_data = &parent_data; | |
| 2873 | + parent = __clk_get_hw(rt5682->mclk); | |
| 2874 | + init.parent_hws = &parent; | |
| 2878 | 2875 | init.num_parents = 1; |
| 2879 | 2876 | } |
| 2880 | 2877 | break; |
| @@ -1367,6 +1367,31 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w, · 1366 unmodified lines | ||
| 1367 | 1367 | return 0; |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | +static int rt5682s_stereo1_adc_mixl_event(struct snd_soc_dapm_widget *w, | |
| 1371 | + struct snd_kcontrol *kcontrol, int event) | |
| 1372 | +{ | |
| 1373 | + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); | |
| 1374 | + struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); | |
| 1375 | + unsigned int delay = 0; | |
| 1376 | + | |
| 1377 | + if (rt5682s->pdata.amic_delay) | |
| 1378 | + delay = rt5682s->pdata.amic_delay; | |
| 1379 | + | |
| 1380 | + switch (event) { | |
| 1381 | + case SND_SOC_DAPM_POST_PMU: | |
| 1382 | + msleep(delay); | |
| 1383 | + snd_soc_component_update_bits(component, RT5682S_STO1_ADC_DIG_VOL, | |
| 1384 | + RT5682S_L_MUTE, 0); | |
| 1385 | + break; | |
| 1386 | + case SND_SOC_DAPM_PRE_PMD: | |
| 1387 | + snd_soc_component_update_bits(component, RT5682S_STO1_ADC_DIG_VOL, | |
| 1388 | + RT5682S_L_MUTE, RT5682S_L_MUTE); | |
| 1389 | + break; | |
| 1390 | + } | |
| 1391 | + | |
| 1392 | + return 0; | |
| 1393 | +} | |
| 1394 | + | |
| 1370 | 1395 | static int sar_power_event(struct snd_soc_dapm_widget *w, |
| 1371 | 1396 | struct snd_kcontrol *kcontrol, int event) |
| 1372 | 1397 | { |
| @@ -1680,9 +1705,10 @@ static const struct snd_soc_dapm_widget rt5682s_dapm_widgets[] = { · 307 unmodified lines | ||
| 1680 | 1705 | /* ADC Mixer */ |
| 1681 | 1706 | SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5682S_PWR_DIG_2, |
| 1682 | 1707 | RT5682S_PWR_ADC_S1F_BIT, 0, set_filter_clk, SND_SOC_DAPM_PRE_PMU), |
| 1683 | − SND_SOC_DAPM_MIXER("Stereo1 ADC MIXL", RT5682S_STO1_ADC_DIG_VOL, | |
| 1684 | − RT5682S_L_MUTE_SFT, 1, rt5682s_sto1_adc_l_mix, | |
| 1685 | − ARRAY_SIZE(rt5682s_sto1_adc_l_mix)), | |
| 1708 | + SND_SOC_DAPM_MIXER_E("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, | |
| 1709 | + rt5682s_sto1_adc_l_mix, ARRAY_SIZE(rt5682s_sto1_adc_l_mix), | |
| 1710 | + rt5682s_stereo1_adc_mixl_event, | |
| 1711 | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | |
| 1686 | 1712 | SND_SOC_DAPM_MIXER("Stereo1 ADC MIXR", RT5682S_STO1_ADC_DIG_VOL, |
| 1687 | 1713 | RT5682S_R_MUTE_SFT, 1, rt5682s_sto1_adc_r_mix, |
| 1688 | 1714 | ARRAY_SIZE(rt5682s_sto1_adc_r_mix)), |
| @@ -2885,6 +2911,8 @@ static int rt5682s_parse_dt(struct rt5682s_priv *rt5682s, struct device *dev) · 1196 unmodified lines | ||
| 2885 | 2911 | &rt5682s->pdata.dmic_clk_rate); |
| 2886 | 2912 | device_property_read_u32(dev, "realtek,dmic-delay-ms", |
| 2887 | 2913 | &rt5682s->pdata.dmic_delay); |
| 2914 | + device_property_read_u32(dev, "realtek,amic-delay-ms", | |
| 2915 | + &rt5682s->pdata.amic_delay); | |
| 2888 | 2916 | |
| 2889 | 2917 | rt5682s->pdata.ldo1_en = of_get_named_gpio(dev->of_node, |
| 2890 | 2918 | "realtek,ldo1-en-gpios", 0); |
| @@ -1005,7 +1005,7 @@ static int rt700_pcm_hw_free(struct snd_pcm_substream *substream, · 1004 unmodified lines | ||
| 1005 | 1005 | static const struct snd_soc_dai_ops rt700_ops = { |
| 1006 | 1006 | .hw_params = rt700_pcm_hw_params, |
| 1007 | 1007 | .hw_free = rt700_pcm_hw_free, |
| 1008 | − .set_sdw_stream = rt700_set_sdw_stream, | |
| 1008 | + .set_stream = rt700_set_sdw_stream, | |
| 1009 | 1009 | .shutdown = rt700_shutdown, |
| 1010 | 1010 | }; |
| 1011 | 1011 | |
| @@ -1358,7 +1358,7 @@ static int rt711_sdca_pcm_hw_free(struct snd_pcm_substream *substream, · 1357 unmodified lines | ||
| 1358 | 1358 | static const struct snd_soc_dai_ops rt711_sdca_ops = { |
| 1359 | 1359 | .hw_params = rt711_sdca_pcm_hw_params, |
| 1360 | 1360 | .hw_free = rt711_sdca_pcm_hw_free, |
| 1361 | − .set_sdw_stream = rt711_sdca_set_sdw_stream, | |
| 1361 | + .set_stream = rt711_sdca_set_sdw_stream, | |
| 1362 | 1362 | .shutdown = rt711_sdca_shutdown, |
| 1363 | 1363 | }; |
| 1364 | 1364 | |
| @@ -1089,7 +1089,7 @@ static int rt711_pcm_hw_free(struct snd_pcm_substream *substream, · 1088 unmodified lines | ||
| 1089 | 1089 | static const struct snd_soc_dai_ops rt711_ops = { |
| 1090 | 1090 | .hw_params = rt711_pcm_hw_params, |
| 1091 | 1091 | .hw_free = rt711_pcm_hw_free, |
| 1092 | − .set_sdw_stream = rt711_set_sdw_stream, | |
| 1092 | + .set_stream = rt711_set_sdw_stream, | |
| 1093 | 1093 | .shutdown = rt711_shutdown, |
| 1094 | 1094 | }; |
| 1095 | 1095 | |
| @@ -938,7 +938,7 @@ static int rt715_sdca_pcm_hw_free(struct snd_pcm_substream *substream, · 937 unmodified lines | ||
| 938 | 938 | static const struct snd_soc_dai_ops rt715_sdca_ops = { |
| 939 | 939 | .hw_params = rt715_sdca_pcm_hw_params, |
| 940 | 940 | .hw_free = rt715_sdca_pcm_hw_free, |
| 941 | − .set_sdw_stream = rt715_sdca_set_sdw_stream, | |
| 941 | + .set_stream = rt715_sdca_set_sdw_stream, | |
| 942 | 942 | .shutdown = rt715_sdca_shutdown, |
| 943 | 943 | }; |
| 944 | 944 | |
| @@ -909,7 +909,7 @@ static int rt715_pcm_hw_free(struct snd_pcm_substream *substream, · 908 unmodified lines | ||
| 909 | 909 | static const struct snd_soc_dai_ops rt715_ops = { |
| 910 | 910 | .hw_params = rt715_pcm_hw_params, |
| 911 | 911 | .hw_free = rt715_pcm_hw_free, |
| 912 | − .set_sdw_stream = rt715_set_sdw_stream, | |
| 912 | + .set_stream = rt715_set_sdw_stream, | |
| 913 | 913 | .shutdown = rt715_shutdown, |
| 914 | 914 | }; |
| 915 | 915 | |
| @@ -138,7 +138,7 @@ static int sdw_mockup_pcm_hw_free(struct snd_pcm_substream *substream, · 137 unmodified lines | ||
| 138 | 138 | static const struct snd_soc_dai_ops sdw_mockup_ops = { |
| 139 | 139 | .hw_params = sdw_mockup_pcm_hw_params, |
| 140 | 140 | .hw_free = sdw_mockup_pcm_hw_free, |
| 141 | − .set_sdw_stream = sdw_mockup_set_sdw_stream, | |
| 141 | + .set_stream = sdw_mockup_set_sdw_stream, | |
| 142 | 142 | .shutdown = sdw_mockup_shutdown, |
| 143 | 143 | }; |
| 144 | 144 | |
| @@ -1612,9 +1612,8 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, · 1611 unmodified lines | ||
| 1612 | 1612 | if (ret == -ENOENT) |
| 1613 | 1613 | ret = -EPROBE_DEFER; |
| 1614 | 1614 | |
| 1615 | − if (ret != -EPROBE_DEFER) | |
| 1616 | − dev_err(&client->dev, "Failed to get mclock: %d\n", | |
| 1617 | − ret); | |
| 1615 | + dev_err_probe(&client->dev, ret, "Failed to get mclock\n"); | |
| 1616 | + | |
| 1618 | 1617 | goto disable_regs; |
| 1619 | 1618 | } |
| 1620 | 1619 | |
| @@ -69,7 +69,6 @@ static int simple_amp_probe(struct platform_device *pdev) · 68 unmodified lines | ||
| 69 | 69 | { |
| 70 | 70 | struct device *dev = &pdev->dev; |
| 71 | 71 | struct simple_amp *priv; |
| 72 | − int err; | |
| 73 | 72 | |
| 74 | 73 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 75 | 74 | if (priv == NULL) |
| @@ -78,12 +77,9 @@ static int simple_amp_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 78 | 77 | |
| 79 | 78 | priv->gpiod_enable = devm_gpiod_get_optional(dev, "enable", |
| 80 | 79 | GPIOD_OUT_LOW); |
| 81 | − if (IS_ERR(priv->gpiod_enable)) { | |
| 82 | − err = PTR_ERR(priv->gpiod_enable); | |
| 83 | − if (err != -EPROBE_DEFER) | |
| 84 | − dev_err(dev, "Failed to get 'enable' gpio: %d", err); | |
| 85 | − return err; | |
| 86 | − } | |
| 80 | + if (IS_ERR(priv->gpiod_enable)) | |
| 81 | + return dev_err_probe(dev, PTR_ERR(priv->gpiod_enable), | |
| 82 | + "Failed to get 'enable' gpio"); | |
| 87 | 83 | |
| 88 | 84 | return devm_snd_soc_register_component(dev, |
| 89 | 85 | &simple_amp_component_driver, |
| @@ -82,7 +82,6 @@ static int simple_mux_probe(struct platform_device *pdev) · 81 unmodified lines | ||
| 82 | 82 | { |
| 83 | 83 | struct device *dev = &pdev->dev; |
| 84 | 84 | struct simple_mux *priv; |
| 85 | − int err; | |
| 86 | 85 | |
| 87 | 86 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 88 | 87 | if (!priv) |
| @@ -91,12 +90,9 @@ static int simple_mux_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 91 | 90 | dev_set_drvdata(dev, priv); |
| 92 | 91 | |
| 93 | 92 | priv->gpiod_mux = devm_gpiod_get(dev, "mux", GPIOD_OUT_LOW); |
| 94 | − if (IS_ERR(priv->gpiod_mux)) { | |
| 95 | − err = PTR_ERR(priv->gpiod_mux); | |
| 96 | − if (err != -EPROBE_DEFER) | |
| 97 | − dev_err(dev, "Failed to get 'mux' gpio: %d", err); | |
| 98 | − return err; | |
| 99 | − } | |
| 93 | + if (IS_ERR(priv->gpiod_mux)) | |
| 94 | + return dev_err_probe(dev, PTR_ERR(priv->gpiod_mux), | |
| 95 | + "Failed to get 'mux' gpio"); | |
| 100 | 96 | |
| 101 | 97 | return devm_snd_soc_register_component(dev, &simple_mux_component_driver, NULL, 0); |
| 102 | 98 | } |
| @@ -57,7 +57,6 @@ static int ssm2305_probe(struct platform_device *pdev) · 56 unmodified lines | ||
| 57 | 57 | { |
| 58 | 58 | struct device *dev = &pdev->dev; |
| 59 | 59 | struct ssm2305 *priv; |
| 60 | − int err; | |
| 61 | 60 | |
| 62 | 61 | /* Allocate the private data */ |
| 63 | 62 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| @@ -69,13 +68,9 @@ static int ssm2305_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 69 | 68 | /* Get shutdown gpio */ |
| 70 | 69 | priv->gpiod_shutdown = devm_gpiod_get(dev, "shutdown", |
| 71 | 70 | GPIOD_OUT_LOW); |
| 72 | − if (IS_ERR(priv->gpiod_shutdown)) { | |
| 73 | − err = PTR_ERR(priv->gpiod_shutdown); | |
| 74 | − if (err != -EPROBE_DEFER) | |
| 75 | − dev_err(dev, "Failed to get 'shutdown' gpio: %d\n", | |
| 76 | − err); | |
| 77 | − return err; | |
| 78 | − } | |
| 71 | + if (IS_ERR(priv->gpiod_shutdown)) | |
| 72 | + return dev_err_probe(dev, PTR_ERR(priv->gpiod_shutdown), | |
| 73 | + "Failed to get 'shutdown' gpio\n"); | |
| 79 | 74 | |
| 80 | 75 | return devm_snd_soc_register_component(dev, &ssm2305_component_driver, |
| 81 | 76 | NULL, 0); |
| @@ -14,7 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #ifndef _ASOC_STA_350_H |
| 15 | 15 | #define _ASOC_STA_350_H |
| 16 | 16 | |
| 17 | −/* STA50 register addresses */ | |
| 17 | +/* STA350 register addresses */ | |
| 18 | 18 | |
| 19 | 19 | #define STA350_REGISTER_COUNT 0x4D |
| 20 | 20 | #define STA350_COEF_COUNT 62 |
| @@ -7,6 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | * Copyright (C) 2013 Sony Mobile Communications Inc. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | +#include <linux/gpio/consumer.h> | |
| 10 | 11 | #include <linux/i2c.h> |
| 11 | 12 | #include <linux/module.h> |
| 12 | 13 | #include <linux/regmap.h> |
| @@ -56,6 +57,7 @@ struct tfa989x_rev { · 43 unmodified lines | ||
| 56 | 57 | struct tfa989x { |
| 57 | 58 | const struct tfa989x_rev *rev; |
| 58 | 59 | struct regulator *vddd_supply; |
| 60 | + struct gpio_desc *rcv_gpiod; | |
| 59 | 61 | }; |
| 60 | 62 | |
| 61 | 63 | static bool tfa989x_writeable_reg(struct device *dev, unsigned int reg) |
| @@ -99,10 +101,20 @@ static const struct snd_soc_dapm_route tfa989x_dapm_routes[] = { · 37 unmodified lines | ||
| 99 | 101 | {"Amp Input", "Right", "AIFINR"}, |
| 100 | 102 | }; |
| 101 | 103 | |
| 104 | +static int tfa989x_put_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | |
| 105 | +{ | |
| 106 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); | |
| 107 | + struct tfa989x *tfa989x = snd_soc_component_get_drvdata(component); | |
| 108 | + | |
| 109 | + gpiod_set_value_cansleep(tfa989x->rcv_gpiod, ucontrol->value.enumerated.item[0]); | |
| 110 | + | |
| 111 | + return snd_soc_put_enum_double(kcontrol, ucontrol); | |
| 112 | +} | |
| 113 | + | |
| 102 | 114 | static const char * const mode_text[] = { "Speaker", "Receiver" }; |
| 103 | 115 | static SOC_ENUM_SINGLE_DECL(mode_enum, TFA989X_I2SREG, TFA989X_I2SREG_RCV, mode_text); |
| 104 | 116 | static const struct snd_kcontrol_new tfa989x_mode_controls[] = { |
| 105 | − SOC_ENUM("Mode", mode_enum), | |
| 117 | + SOC_ENUM_EXT("Mode", mode_enum, snd_soc_get_enum_double, tfa989x_put_mode), | |
| 106 | 118 | }; |
| 107 | 119 | |
| 108 | 120 | static int tfa989x_probe(struct snd_soc_component *component) |
| @@ -301,6 +313,12 @@ static int tfa989x_i2c_probe(struct i2c_client *i2c) · 192 unmodified lines | ||
| 301 | 313 | return dev_err_probe(dev, PTR_ERR(tfa989x->vddd_supply), |
| 302 | 314 | "Failed to get vddd regulator\n"); |
| 303 | 315 | |
| 316 | + if (tfa989x->rev->rev == TFA9897_REVISION) { | |
| 317 | + tfa989x->rcv_gpiod = devm_gpiod_get_optional(dev, "rcv", GPIOD_OUT_LOW); | |
| 318 | + if (IS_ERR(tfa989x->rcv_gpiod)) | |
| 319 | + return PTR_ERR(tfa989x->rcv_gpiod); | |
| 320 | + } | |
| 321 | + | |
| 304 | 322 | regmap = devm_regmap_init_i2c(i2c, &tfa989x_regmap); |
| 305 | 323 | if (IS_ERR(regmap)) |
| 306 | 324 | return PTR_ERR(regmap); |
| @@ -0,0 +1,1317 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0-only | |
| 2 | +// | |
| 3 | +// Based on sound/soc/codecs/tlv320aic3x.c by Vladimir Barinov | |
| 4 | +// | |
| 5 | +// Copyright (C) 2010 Mistral Solutions Pvt Ltd. | |
| 6 | +// Author: Shahina Shaik <shahina.s@mistralsolutions.com> | |
| 7 | +// | |
| 8 | +// Copyright (C) 2014-2018, Ambarella, Inc. | |
| 9 | +// Author: Dongge wu <dgwu@ambarella.com> | |
| 10 | +// | |
| 11 | +// Copyright (C) 2021 Axis Communications AB | |
| 12 | +// Author: Ricard Wanderlof <ricardw@axis.com> | |
| 13 | +// | |
| 14 | + | |
| 15 | +#include <dt-bindings/sound/tlv320adc3xxx.h> | |
| 16 | +#include <linux/clk.h> | |
| 17 | +#include <linux/module.h> | |
| 18 | +#include <linux/moduleparam.h> | |
| 19 | +#include <linux/io.h> | |
| 20 | +#include <linux/init.h> | |
| 21 | +#include <linux/delay.h> | |
| 22 | +#include <linux/gpio/driver.h> | |
| 23 | +#include <linux/pm.h> | |
| 24 | +#include <linux/i2c.h> | |
| 25 | +#include <linux/platform_device.h> | |
| 26 | +#include <linux/cdev.h> | |
| 27 | +#include <linux/of_gpio.h> | |
| 28 | +#include <linux/slab.h> | |
| 29 | +#include <sound/core.h> | |
| 30 | +#include <sound/pcm.h> | |
| 31 | +#include <sound/pcm_params.h> | |
| 32 | +#include <sound/soc.h> | |
| 33 | +#include <sound/soc-dapm.h> | |
| 34 | +#include <sound/tlv.h> | |
| 35 | +#include <sound/initval.h> | |
| 36 | + | |
| 37 | +/* | |
| 38 | + * General definitions defining exported functionality. | |
| 39 | + */ | |
| 40 | + | |
| 41 | +#define ADC3XXX_MICBIAS_PINS 2 | |
| 42 | + | |
| 43 | +/* Number of GPIO pins exposed via the gpiolib interface */ | |
| 44 | +#define ADC3XXX_GPIOS_MAX 2 | |
| 45 | + | |
| 46 | +#define ADC3XXX_RATES SNDRV_PCM_RATE_8000_96000 | |
| 47 | +#define ADC3XXX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ | |
| 48 | + SNDRV_PCM_FMTBIT_S20_3LE | \ | |
| 49 | + SNDRV_PCM_FMTBIT_S24_3LE | \ | |
| 50 | + SNDRV_PCM_FMTBIT_S32_LE) | |
| 51 | + | |
| 52 | +/* | |
| 53 | + * PLL modes, to be used for clk_id for set_sysclk callback. | |
| 54 | + * | |
| 55 | + * The default behavior (AUTO) is to take the first matching entry in the clock | |
| 56 | + * table, which is intended to be the PLL based one if there is more than one. | |
| 57 | + * | |
| 58 | + * Setting the clock source using simple-card (clocks or | |
| 59 | + * system-clock-frequency property) sets clk_id = 0 = ADC3XXX_PLL_AUTO. | |
| 60 | + */ | |
| 61 | +#define ADC3XXX_PLL_AUTO 0 /* Use first available mode */ | |
| 62 | +#define ADC3XXX_PLL_ENABLE 1 /* Use PLL for clock generation */ | |
| 63 | +#define ADC3XXX_PLL_BYPASS 2 /* Don't use PLL for clock generation */ | |
| 64 | + | |
| 65 | +/* Register definitions. */ | |
| 66 | + | |
| 67 | +#define ADC3XXX_PAGE_SIZE 128 | |
| 68 | +#define ADC3XXX_REG(page, reg) ((page * ADC3XXX_PAGE_SIZE) + reg) | |
| 69 | + | |
| 70 | +/* | |
| 71 | + * Page 0 registers. | |
| 72 | + */ | |
| 73 | + | |
| 74 | +#define ADC3XXX_PAGE_SELECT ADC3XXX_REG(0, 0) | |
| 75 | +#define ADC3XXX_RESET ADC3XXX_REG(0, 1) | |
| 76 | + | |
| 77 | +/* 2-3 Reserved */ | |
| 78 | + | |
| 79 | +#define ADC3XXX_CLKGEN_MUX ADC3XXX_REG(0, 4) | |
| 80 | +#define ADC3XXX_PLL_PROG_PR ADC3XXX_REG(0, 5) | |
| 81 | +#define ADC3XXX_PLL_PROG_J ADC3XXX_REG(0, 6) | |
| 82 | +#define ADC3XXX_PLL_PROG_D_MSB ADC3XXX_REG(0, 7) | |
| 83 | +#define ADC3XXX_PLL_PROG_D_LSB ADC3XXX_REG(0, 8) | |
| 84 | + | |
| 85 | +/* 9-17 Reserved */ | |
| 86 | + | |
| 87 | +#define ADC3XXX_ADC_NADC ADC3XXX_REG(0, 18) | |
| 88 | +#define ADC3XXX_ADC_MADC ADC3XXX_REG(0, 19) | |
| 89 | +#define ADC3XXX_ADC_AOSR ADC3XXX_REG(0, 20) | |
| 90 | +#define ADC3XXX_ADC_IADC ADC3XXX_REG(0, 21) | |
| 91 | + | |
| 92 | +/* 23-24 Reserved */ | |
| 93 | + | |
| 94 | +#define ADC3XXX_CLKOUT_MUX ADC3XXX_REG(0, 25) | |
| 95 | +#define ADC3XXX_CLKOUT_M_DIV ADC3XXX_REG(0, 26) | |
| 96 | +#define ADC3XXX_INTERFACE_CTRL_1 ADC3XXX_REG(0, 27) | |
| 97 | +#define ADC3XXX_CH_OFFSET_1 ADC3XXX_REG(0, 28) | |
| 98 | +#define ADC3XXX_INTERFACE_CTRL_2 ADC3XXX_REG(0, 29) | |
| 99 | +#define ADC3XXX_BCLK_N_DIV ADC3XXX_REG(0, 30) | |
| 100 | +#define ADC3XXX_INTERFACE_CTRL_3 ADC3XXX_REG(0, 31) | |
| 101 | +#define ADC3XXX_INTERFACE_CTRL_4 ADC3XXX_REG(0, 32) | |
| 102 | +#define ADC3XXX_INTERFACE_CTRL_5 ADC3XXX_REG(0, 33) | |
| 103 | +#define ADC3XXX_I2S_SYNC ADC3XXX_REG(0, 34) | |
| 104 | +/* 35 Reserved */ | |
| 105 | +#define ADC3XXX_ADC_FLAG ADC3XXX_REG(0, 36) | |
| 106 | +#define ADC3XXX_CH_OFFSET_2 ADC3XXX_REG(0, 37) | |
| 107 | +#define ADC3XXX_I2S_TDM_CTRL ADC3XXX_REG(0, 38) | |
| 108 | +/* 39-41 Reserved */ | |
| 109 | +#define ADC3XXX_INTR_FLAG_1 ADC3XXX_REG(0, 42) | |
| 110 | +#define ADC3XXX_INTR_FLAG_2 ADC3XXX_REG(0, 43) | |
| 111 | +/* 44 Reserved */ | |
| 112 | +#define ADC3XXX_INTR_FLAG_ADC1 ADC3XXX_REG(0, 45) | |
| 113 | +/* 46 Reserved */ | |
| 114 | +#define ADC3XXX_INTR_FLAG_ADC2 ADC3XXX_REG(0, 47) | |
| 115 | +#define ADC3XXX_INT1_CTRL ADC3XXX_REG(0, 48) | |
| 116 | +#define ADC3XXX_INT2_CTRL ADC3XXX_REG(0, 49) | |
| 117 | +/* 50 Reserved */ | |
| 118 | +#define ADC3XXX_GPIO2_CTRL ADC3XXX_REG(0, 51) | |
| 119 | +#define ADC3XXX_GPIO1_CTRL ADC3XXX_REG(0, 52) | |
| 120 | +#define ADC3XXX_DOUT_CTRL ADC3XXX_REG(0, 53) | |
| 121 | +/* 54-56 Reserved */ | |
| 122 | +#define ADC3XXX_SYNC_CTRL_1 ADC3XXX_REG(0, 57) | |
| 123 | +#define ADC3XXX_SYNC_CTRL_2 ADC3XXX_REG(0, 58) | |
| 124 | +#define ADC3XXX_CIC_GAIN_CTRL ADC3XXX_REG(0, 59) | |
| 125 | +/* 60 Reserved */ | |
| 126 | +#define ADC3XXX_PRB_SELECT ADC3XXX_REG(0, 61) | |
| 127 | +#define ADC3XXX_INST_MODE_CTRL ADC3XXX_REG(0, 62) | |
| 128 | +/* 63-79 Reserved */ | |
| 129 | +#define ADC3XXX_MIC_POLARITY_CTRL ADC3XXX_REG(0, 80) | |
| 130 | +#define ADC3XXX_ADC_DIGITAL ADC3XXX_REG(0, 81) | |
| 131 | +#define ADC3XXX_ADC_FGA ADC3XXX_REG(0, 82) | |
| 132 | +#define ADC3XXX_LADC_VOL ADC3XXX_REG(0, 83) | |
| 133 | +#define ADC3XXX_RADC_VOL ADC3XXX_REG(0, 84) | |
| 134 | +#define ADC3XXX_ADC_PHASE_COMP ADC3XXX_REG(0, 85) | |
| 135 | +#define ADC3XXX_LEFT_CHN_AGC_1 ADC3XXX_REG(0, 86) | |
| 136 | +#define ADC3XXX_LEFT_CHN_AGC_2 ADC3XXX_REG(0, 87) | |
| 137 | +#define ADC3XXX_LEFT_CHN_AGC_3 ADC3XXX_REG(0, 88) | |
| 138 | +#define ADC3XXX_LEFT_CHN_AGC_4 ADC3XXX_REG(0, 89) | |
| 139 | +#define ADC3XXX_LEFT_CHN_AGC_5 ADC3XXX_REG(0, 90) | |
| 140 | +#define ADC3XXX_LEFT_CHN_AGC_6 ADC3XXX_REG(0, 91) | |
| 141 | +#define ADC3XXX_LEFT_CHN_AGC_7 ADC3XXX_REG(0, 92) | |
| 142 | +#define ADC3XXX_LEFT_AGC_GAIN ADC3XXX_REG(0, 93) | |
| 143 | +#define ADC3XXX_RIGHT_CHN_AGC_1 ADC3XXX_REG(0, 94) | |
| 144 | +#define ADC3XXX_RIGHT_CHN_AGC_2 ADC3XXX_REG(0, 95) | |
| 145 | +#define ADC3XXX_RIGHT_CHN_AGC_3 ADC3XXX_REG(0, 96) | |
| 146 | +#define ADC3XXX_RIGHT_CHN_AGC_4 ADC3XXX_REG(0, 97) | |
| 147 | +#define ADC3XXX_RIGHT_CHN_AGC_5 ADC3XXX_REG(0, 98) | |
| 148 | +#define ADC3XXX_RIGHT_CHN_AGC_6 ADC3XXX_REG(0, 99) | |
| 149 | +#define ADC3XXX_RIGHT_CHN_AGC_7 ADC3XXX_REG(0, 100) | |
| 150 | +#define ADC3XXX_RIGHT_AGC_GAIN ADC3XXX_REG(0, 101) | |
| 151 | +/* 102-127 Reserved */ | |
| 152 | + | |
| 153 | +/* | |
| 154 | + * Page 1 registers. | |
| 155 | + */ | |
| 156 | + | |
| 157 | +/* 1-25 Reserved */ | |
| 158 | +#define ADC3XXX_DITHER_CTRL ADC3XXX_REG(1, 26) | |
| 159 | +/* 27-50 Reserved */ | |
| 160 | +#define ADC3XXX_MICBIAS_CTRL ADC3XXX_REG(1, 51) | |
| 161 | +#define ADC3XXX_LEFT_PGA_SEL_1 ADC3XXX_REG(1, 52) | |
| 162 | +/* 53 Reserved */ | |
| 163 | +#define ADC3XXX_LEFT_PGA_SEL_2 ADC3XXX_REG(1, 54) | |
| 164 | +#define ADC3XXX_RIGHT_PGA_SEL_1 ADC3XXX_REG(1, 55) | |
| 165 | +#define ADC3XXX_RIGHT_PGA_SEL_2 ADC3XXX_REG(1, 57) | |
| 166 | +#define ADC3XXX_LEFT_APGA_CTRL ADC3XXX_REG(1, 59) | |
| 167 | +#define ADC3XXX_RIGHT_APGA_CTRL ADC3XXX_REG(1, 60) | |
| 168 | +#define ADC3XXX_LOW_CURRENT_MODES ADC3XXX_REG(1, 61) | |
| 169 | +#define ADC3XXX_ANALOG_PGA_FLAGS ADC3XXX_REG(1, 62) | |
| 170 | +/* 63-127 Reserved */ | |
| 171 | + | |
| 172 | +/* | |
| 173 | + * Register bits. | |
| 174 | + */ | |
| 175 | + | |
| 176 | +/* PLL Enable bits */ | |
| 177 | +#define ADC3XXX_ENABLE_PLL_SHIFT 7 | |
| 178 | +#define ADC3XXX_ENABLE_PLL (1 << ADC3XXX_ENABLE_PLL_SHIFT) | |
| 179 | +#define ADC3XXX_ENABLE_NADC_SHIFT 7 | |
| 180 | +#define ADC3XXX_ENABLE_NADC (1 << ADC3XXX_ENABLE_NADC_SHIFT) | |
| 181 | +#define ADC3XXX_ENABLE_MADC_SHIFT 7 | |
| 182 | +#define ADC3XXX_ENABLE_MADC (1 << ADC3XXX_ENABLE_MADC_SHIFT) | |
| 183 | +#define ADC3XXX_ENABLE_BCLK_SHIFT 7 | |
| 184 | +#define ADC3XXX_ENABLE_BCLK (1 << ADC3XXX_ENABLE_BCLK_SHIFT) | |
| 185 | + | |
| 186 | +/* Power bits */ | |
| 187 | +#define ADC3XXX_LADC_PWR_ON 0x80 | |
| 188 | +#define ADC3XXX_RADC_PWR_ON 0x40 | |
| 189 | + | |
| 190 | +#define ADC3XXX_SOFT_RESET 0x01 | |
| 191 | +#define ADC3XXX_BCLK_MASTER 0x08 | |
| 192 | +#define ADC3XXX_WCLK_MASTER 0x04 | |
| 193 | + | |
| 194 | +/* Interface register masks */ | |
| 195 | +#define ADC3XXX_FORMAT_MASK 0xc0 | |
| 196 | +#define ADC3XXX_FORMAT_SHIFT 6 | |
| 197 | +#define ADC3XXX_WLENGTH_MASK 0x30 | |
| 198 | +#define ADC3XXX_WLENGTH_SHIFT 4 | |
| 199 | +#define ADC3XXX_CLKDIR_MASK 0x0c | |
| 200 | +#define ADC3XXX_CLKDIR_SHIFT 2 | |
| 201 | + | |
| 202 | +/* Interface register bit patterns */ | |
| 203 | +#define ADC3XXX_FORMAT_I2S (0 << ADC3XXX_FORMAT_SHIFT) | |
| 204 | +#define ADC3XXX_FORMAT_DSP (1 << ADC3XXX_FORMAT_SHIFT) | |
| 205 | +#define ADC3XXX_FORMAT_RJF (2 << ADC3XXX_FORMAT_SHIFT) | |
| 206 | +#define ADC3XXX_FORMAT_LJF (3 << ADC3XXX_FORMAT_SHIFT) | |
| 207 | + | |
| 208 | +#define ADC3XXX_IFACE_16BITS (0 << ADC3XXX_WLENGTH_SHIFT) | |
| 209 | +#define ADC3XXX_IFACE_20BITS (1 << ADC3XXX_WLENGTH_SHIFT) | |
| 210 | +#define ADC3XXX_IFACE_24BITS (2 << ADC3XXX_WLENGTH_SHIFT) | |
| 211 | +#define ADC3XXX_IFACE_32BITS (3 << ADC3XXX_WLENGTH_SHIFT) | |
| 212 | + | |
| 213 | +/* PLL P/R bit offsets */ | |
| 214 | +#define ADC3XXX_PLLP_SHIFT 4 | |
| 215 | +#define ADC3XXX_PLLR_SHIFT 0 | |
| 216 | +#define ADC3XXX_PLL_PR_MASK 0x7f | |
| 217 | +#define ADC3XXX_PLLJ_MASK 0x3f | |
| 218 | +#define ADC3XXX_PLLD_MSB_MASK 0x3f | |
| 219 | +#define ADC3XXX_PLLD_LSB_MASK 0xff | |
| 220 | +#define ADC3XXX_NADC_MASK 0x7f | |
| 221 | +#define ADC3XXX_MADC_MASK 0x7f | |
| 222 | +#define ADC3XXX_AOSR_MASK 0xff | |
| 223 | +#define ADC3XXX_IADC_MASK 0xff | |
| 224 | +#define ADC3XXX_BDIV_MASK 0x7f | |
| 225 | + | |
| 226 | +/* PLL_CLKIN bits */ | |
| 227 | +#define ADC3XXX_PLL_CLKIN_SHIFT 2 | |
| 228 | +#define ADC3XXX_PLL_CLKIN_MCLK 0x0 | |
| 229 | +#define ADC3XXX_PLL_CLKIN_BCLK 0x1 | |
| 230 | +#define ADC3XXX_PLL_CLKIN_ZERO 0x3 | |
| 231 | + | |
| 232 | +/* CODEC_CLKIN bits */ | |
| 233 | +#define ADC3XXX_CODEC_CLKIN_SHIFT 0 | |
| 234 | +#define ADC3XXX_CODEC_CLKIN_MCLK 0x0 | |
| 235 | +#define ADC3XXX_CODEC_CLKIN_BCLK 0x1 | |
| 236 | +#define ADC3XXX_CODEC_CLKIN_PLL_CLK 0x3 | |
| 237 | + | |
| 238 | +#define ADC3XXX_USE_PLL ((ADC3XXX_PLL_CLKIN_MCLK << ADC3XXX_PLL_CLKIN_SHIFT) | \ | |
| 239 | + (ADC3XXX_CODEC_CLKIN_PLL_CLK << ADC3XXX_CODEC_CLKIN_SHIFT)) | |
| 240 | +#define ADC3XXX_NO_PLL ((ADC3XXX_PLL_CLKIN_ZERO << ADC3XXX_PLL_CLKIN_SHIFT) | \ | |
| 241 | + (ADC3XXX_CODEC_CLKIN_MCLK << ADC3XXX_CODEC_CLKIN_SHIFT)) | |
| 242 | + | |
| 243 | +/* Analog PGA control bits */ | |
| 244 | +#define ADC3XXX_LPGA_MUTE 0x80 | |
| 245 | +#define ADC3XXX_RPGA_MUTE 0x80 | |
| 246 | + | |
| 247 | +#define ADC3XXX_LPGA_GAIN_MASK 0x7f | |
| 248 | +#define ADC3XXX_RPGA_GAIN_MASK 0x7f | |
| 249 | + | |
| 250 | +/* ADC current modes */ | |
| 251 | +#define ADC3XXX_ADC_LOW_CURR_MODE 0x01 | |
| 252 | + | |
| 253 | +/* Left ADC Input selection bits */ | |
| 254 | +#define ADC3XXX_LCH_SEL1_SHIFT 0 | |
| 255 | +#define ADC3XXX_LCH_SEL2_SHIFT 2 | |
| 256 | +#define ADC3XXX_LCH_SEL3_SHIFT 4 | |
| 257 | +#define ADC3XXX_LCH_SEL4_SHIFT 6 | |
| 258 | + | |
| 259 | +#define ADC3XXX_LCH_SEL1X_SHIFT 0 | |
| 260 | +#define ADC3XXX_LCH_SEL2X_SHIFT 2 | |
| 261 | +#define ADC3XXX_LCH_SEL3X_SHIFT 4 | |
| 262 | +#define ADC3XXX_LCH_COMMON_MODE 0x40 | |
| 263 | +#define ADC3XXX_BYPASS_LPGA 0x80 | |
| 264 | + | |
| 265 | +/* Right ADC Input selection bits */ | |
| 266 | +#define ADC3XXX_RCH_SEL1_SHIFT 0 | |
| 267 | +#define ADC3XXX_RCH_SEL2_SHIFT 2 | |
| 268 | +#define ADC3XXX_RCH_SEL3_SHIFT 4 | |
| 269 | +#define ADC3XXX_RCH_SEL4_SHIFT 6 | |
| 270 | + | |
| 271 | +#define ADC3XXX_RCH_SEL1X_SHIFT 0 | |
| 272 | +#define ADC3XXX_RCH_SEL2X_SHIFT 2 | |
| 273 | +#define ADC3XXX_RCH_SEL3X_SHIFT 4 | |
| 274 | +#define ADC3XXX_RCH_COMMON_MODE 0x40 | |
| 275 | +#define ADC3XXX_BYPASS_RPGA 0x80 | |
| 276 | + | |
| 277 | +/* MICBIAS control bits */ | |
| 278 | +#define ADC3XXX_MICBIAS_MASK 0x2 | |
| 279 | +#define ADC3XXX_MICBIAS1_SHIFT 5 | |
| 280 | +#define ADC3XXX_MICBIAS2_SHIFT 3 | |
| 281 | + | |
| 282 | +#define ADC3XXX_ADC_MAX_VOLUME 64 | |
| 283 | +#define ADC3XXX_ADC_POS_VOL 24 | |
| 284 | + | |
| 285 | +/* GPIO control bits (GPIO1_CTRL and GPIO2_CTRL) */ | |
| 286 | +#define ADC3XXX_GPIO_CTRL_CFG_MASK 0x3c | |
| 287 | +#define ADC3XXX_GPIO_CTRL_CFG_SHIFT 2 | |
| 288 | +#define ADC3XXX_GPIO_CTRL_OUTPUT_CTRL_MASK 0x01 | |
| 289 | +#define ADC3XXX_GPIO_CTRL_OUTPUT_CTRL_SHIFT 0 | |
| 290 | +#define ADC3XXX_GPIO_CTRL_INPUT_VALUE_MASK 0x02 | |
| 291 | +#define ADC3XXX_GPIO_CTRL_INPUT_VALUE_SHIFT 1 | |
| 292 | + | |
| 293 | +enum adc3xxx_type { | |
| 294 | + ADC3001 = 0, | |
| 295 | + ADC3101 | |
| 296 | +}; | |
| 297 | + | |
| 298 | +struct adc3xxx { | |
| 299 | + struct device *dev; | |
| 300 | + enum adc3xxx_type type; | |
| 301 | + struct clk *mclk; | |
| 302 | + struct regmap *regmap; | |
| 303 | + struct gpio_desc *rst_pin; | |
| 304 | + unsigned int pll_mode; | |
| 305 | + unsigned int sysclk; | |
| 306 | + unsigned int gpio_cfg[ADC3XXX_GPIOS_MAX]; /* value+1 (0 => not set) */ | |
| 307 | + unsigned int micbias_vg[ADC3XXX_MICBIAS_PINS]; | |
| 308 | + int master; | |
| 309 | + u8 page_no; | |
| 310 | + int use_pll; | |
| 311 | + struct gpio_chip gpio_chip; | |
| 312 | +}; | |
| 313 | + | |
| 314 | +static const unsigned int adc3xxx_gpio_ctrl_reg[ADC3XXX_GPIOS_MAX] = { | |
| 315 | + ADC3XXX_GPIO1_CTRL, | |
| 316 | + ADC3XXX_GPIO2_CTRL | |
| 317 | +}; | |
| 318 | + | |
| 319 | +static const unsigned int adc3xxx_micbias_shift[ADC3XXX_MICBIAS_PINS] = { | |
| 320 | + ADC3XXX_MICBIAS1_SHIFT, | |
| 321 | + ADC3XXX_MICBIAS2_SHIFT | |
| 322 | +}; | |
| 323 | + | |
| 324 | +static const struct reg_default adc3xxx_defaults[] = { | |
| 325 | + /* Page 0 */ | |
| 326 | + { 0, 0x00 }, { 1, 0x00 }, { 2, 0x00 }, { 3, 0x00 }, | |
| 327 | + { 4, 0x00 }, { 5, 0x11 }, { 6, 0x04 }, { 7, 0x00 }, | |
| 328 | + { 8, 0x00 }, { 9, 0x00 }, { 10, 0x00 }, { 11, 0x00 }, | |
| 329 | + { 12, 0x00 }, { 13, 0x00 }, { 14, 0x00 }, { 15, 0x00 }, | |
| 330 | + { 16, 0x00 }, { 17, 0x00 }, { 18, 0x01 }, { 19, 0x01 }, | |
| 331 | + { 20, 0x80 }, { 21, 0x80 }, { 22, 0x04 }, { 23, 0x00 }, | |
| 332 | + { 24, 0x00 }, { 25, 0x00 }, { 26, 0x01 }, { 27, 0x00 }, | |
| 333 | + { 28, 0x00 }, { 29, 0x02 }, { 30, 0x01 }, { 31, 0x00 }, | |
| 334 | + { 32, 0x00 }, { 33, 0x10 }, { 34, 0x00 }, { 35, 0x00 }, | |
| 335 | + { 36, 0x00 }, { 37, 0x00 }, { 38, 0x02 }, { 39, 0x00 }, | |
| 336 | + { 40, 0x00 }, { 41, 0x00 }, { 42, 0x00 }, { 43, 0x00 }, | |
| 337 | + { 44, 0x00 }, { 45, 0x00 }, { 46, 0x00 }, { 47, 0x00 }, | |
| 338 | + { 48, 0x00 }, { 49, 0x00 }, { 50, 0x00 }, { 51, 0x00 }, | |
| 339 | + { 52, 0x00 }, { 53, 0x12 }, { 54, 0x00 }, { 55, 0x00 }, | |
| 340 | + { 56, 0x00 }, { 57, 0x00 }, { 58, 0x00 }, { 59, 0x44 }, | |
| 341 | + { 60, 0x00 }, { 61, 0x01 }, { 62, 0x00 }, { 63, 0x00 }, | |
| 342 | + { 64, 0x00 }, { 65, 0x00 }, { 66, 0x00 }, { 67, 0x00 }, | |
| 343 | + { 68, 0x00 }, { 69, 0x00 }, { 70, 0x00 }, { 71, 0x00 }, | |
| 344 | + { 72, 0x00 }, { 73, 0x00 }, { 74, 0x00 }, { 75, 0x00 }, | |
| 345 | + { 76, 0x00 }, { 77, 0x00 }, { 78, 0x00 }, { 79, 0x00 }, | |
| 346 | + { 80, 0x00 }, { 81, 0x00 }, { 82, 0x88 }, { 83, 0x00 }, | |
| 347 | + { 84, 0x00 }, { 85, 0x00 }, { 86, 0x00 }, { 87, 0x00 }, | |
| 348 | + { 88, 0x7f }, { 89, 0x00 }, { 90, 0x00 }, { 91, 0x00 }, | |
| 349 | + { 92, 0x00 }, { 93, 0x00 }, { 94, 0x00 }, { 95, 0x00 }, | |
| 350 | + { 96, 0x7f }, { 97, 0x00 }, { 98, 0x00 }, { 99, 0x00 }, | |
| 351 | + { 100, 0x00 }, { 101, 0x00 }, { 102, 0x00 }, { 103, 0x00 }, | |
| 352 | + { 104, 0x00 }, { 105, 0x00 }, { 106, 0x00 }, { 107, 0x00 }, | |
| 353 | + { 108, 0x00 }, { 109, 0x00 }, { 110, 0x00 }, { 111, 0x00 }, | |
| 354 | + { 112, 0x00 }, { 113, 0x00 }, { 114, 0x00 }, { 115, 0x00 }, | |
| 355 | + { 116, 0x00 }, { 117, 0x00 }, { 118, 0x00 }, { 119, 0x00 }, | |
| 356 | + { 120, 0x00 }, { 121, 0x00 }, { 122, 0x00 }, { 123, 0x00 }, | |
| 357 | + { 124, 0x00 }, { 125, 0x00 }, { 126, 0x00 }, { 127, 0x00 }, | |
| 358 | + | |
| 359 | + /* Page 1 */ | |
| 360 | + { 128, 0x00 }, { 129, 0x00 }, { 130, 0x00 }, { 131, 0x00 }, | |
| 361 | + { 132, 0x00 }, { 133, 0x00 }, { 134, 0x00 }, { 135, 0x00 }, | |
| 362 | + { 136, 0x00 }, { 137, 0x00 }, { 138, 0x00 }, { 139, 0x00 }, | |
| 363 | + { 140, 0x00 }, { 141, 0x00 }, { 142, 0x00 }, { 143, 0x00 }, | |
| 364 | + { 144, 0x00 }, { 145, 0x00 }, { 146, 0x00 }, { 147, 0x00 }, | |
| 365 | + { 148, 0x00 }, { 149, 0x00 }, { 150, 0x00 }, { 151, 0x00 }, | |
| 366 | + { 152, 0x00 }, { 153, 0x00 }, { 154, 0x00 }, { 155, 0x00 }, | |
| 367 | + { 156, 0x00 }, { 157, 0x00 }, { 158, 0x00 }, { 159, 0x00 }, | |
| 368 | + { 160, 0x00 }, { 161, 0x00 }, { 162, 0x00 }, { 163, 0x00 }, | |
| 369 | + { 164, 0x00 }, { 165, 0x00 }, { 166, 0x00 }, { 167, 0x00 }, | |
| 370 | + { 168, 0x00 }, { 169, 0x00 }, { 170, 0x00 }, { 171, 0x00 }, | |
| 371 | + { 172, 0x00 }, { 173, 0x00 }, { 174, 0x00 }, { 175, 0x00 }, | |
| 372 | + { 176, 0x00 }, { 177, 0x00 }, { 178, 0x00 }, { 179, 0x00 }, | |
| 373 | + { 180, 0xff }, { 181, 0x00 }, { 182, 0x3f }, { 183, 0xff }, | |
| 374 | + { 184, 0x00 }, { 185, 0x3f }, { 186, 0x00 }, { 187, 0x80 }, | |
| 375 | + { 188, 0x80 }, { 189, 0x00 }, { 190, 0x00 }, { 191, 0x00 }, | |
| 376 | +}; | |
| 377 | + | |
| 378 | +static bool adc3xxx_volatile_reg(struct device *dev, unsigned int reg) | |
| 379 | +{ | |
| 380 | + switch (reg) { | |
| 381 | + case ADC3XXX_RESET: | |
| 382 | + return true; | |
| 383 | + default: | |
| 384 | + return false; | |
| 385 | + } | |
| 386 | +} | |
| 387 | + | |
| 388 | +static const struct regmap_range_cfg adc3xxx_ranges[] = { | |
| 389 | + { | |
| 390 | + .range_min = 0, | |
| 391 | + .range_max = 2 * ADC3XXX_PAGE_SIZE, | |
| 392 | + .selector_reg = ADC3XXX_PAGE_SELECT, | |
| 393 | + .selector_mask = 0xff, | |
| 394 | + .selector_shift = 0, | |
| 395 | + .window_start = 0, | |
| 396 | + .window_len = ADC3XXX_PAGE_SIZE, | |
| 397 | + } | |
| 398 | +}; | |
| 399 | + | |
| 400 | +static const struct regmap_config adc3xxx_regmap = { | |
| 401 | + .reg_bits = 8, | |
| 402 | + .val_bits = 8, | |
| 403 | + | |
| 404 | + .reg_defaults = adc3xxx_defaults, | |
| 405 | + .num_reg_defaults = ARRAY_SIZE(adc3xxx_defaults), | |
| 406 | + | |
| 407 | + .volatile_reg = adc3xxx_volatile_reg, | |
| 408 | + | |
| 409 | + .cache_type = REGCACHE_RBTREE, | |
| 410 | + | |
| 411 | + .ranges = adc3xxx_ranges, | |
| 412 | + .num_ranges = ARRAY_SIZE(adc3xxx_ranges), | |
| 413 | + .max_register = 2 * ADC3XXX_PAGE_SIZE, | |
| 414 | +}; | |
| 415 | + | |
| 416 | +struct adc3xxx_rate_divs { | |
| 417 | + u32 mclk; | |
| 418 | + u32 rate; | |
| 419 | + u8 pll_p; | |
| 420 | + u8 pll_r; | |
| 421 | + u8 pll_j; | |
| 422 | + u16 pll_d; | |
| 423 | + u8 nadc; | |
| 424 | + u8 madc; | |
| 425 | + u8 aosr; | |
| 426 | +}; | |
| 427 | + | |
| 428 | +/* | |
| 429 | + * PLL and Clock settings. | |
| 430 | + * If p member is 0, PLL is not used. | |
| 431 | + * The order of the entries in this table have the PLL entries before | |
| 432 | + * the non-PLL entries, so that the PLL modes are preferred unless | |
| 433 | + * the PLL mode setting says otherwise. | |
| 434 | + */ | |
| 435 | +static const struct adc3xxx_rate_divs adc3xxx_divs[] = { | |
| 436 | + /* mclk, rate, p, r, j, d, nadc, madc, aosr */ | |
| 437 | + /* 8k rate */ | |
| 438 | + { 12000000, 8000, 1, 1, 7, 1680, 42, 2, 128 }, | |
| 439 | + { 12288000, 8000, 1, 1, 7, 0000, 42, 2, 128 }, | |
| 440 | + /* 11.025k rate */ | |
| 441 | + { 12000000, 11025, 1, 1, 6, 8208, 29, 2, 128 }, | |
| 442 | + /* 16k rate */ | |
| 443 | + { 12000000, 16000, 1, 1, 7, 1680, 21, 2, 128 }, | |
| 444 | + { 12288000, 16000, 1, 1, 7, 0000, 21, 2, 128 }, | |
| 445 | + /* 22.05k rate */ | |
| 446 | + { 12000000, 22050, 1, 1, 7, 560, 15, 2, 128 }, | |
| 447 | + /* 32k rate */ | |
| 448 | + { 12000000, 32000, 1, 1, 8, 1920, 12, 2, 128 }, | |
| 449 | + { 12288000, 32000, 1, 1, 8, 0000, 12, 2, 128 }, | |
| 450 | + /* 44.1k rate */ | |
| 451 | + { 12000000, 44100, 1, 1, 7, 5264, 8, 2, 128 }, | |
| 452 | + /* 48k rate */ | |
| 453 | + { 12000000, 48000, 1, 1, 7, 1680, 7, 2, 128 }, | |
| 454 | + { 12288000, 48000, 1, 1, 7, 0000, 7, 2, 128 }, | |
| 455 | + { 24576000, 48000, 1, 1, 3, 5000, 7, 2, 128 }, /* With PLL */ | |
| 456 | + { 24576000, 48000, 0, 0, 0, 0000, 2, 2, 128 }, /* Without PLL */ | |
| 457 | + /* 88.2k rate */ | |
| 458 | + { 12000000, 88200, 1, 1, 7, 5264, 4, 4, 64 }, | |
| 459 | + /* 96k rate */ | |
| 460 | + { 12000000, 96000, 1, 1, 8, 1920, 4, 4, 64 }, | |
| 461 | +}; | |
| 462 | + | |
| 463 | +static int adc3xxx_get_divs(struct device *dev, int mclk, int rate, int pll_mode) | |
| 464 | +{ | |
| 465 | + int i; | |
| 466 | + | |
| 467 | + dev_dbg(dev, "mclk = %d, rate = %d, clock mode %u\n", | |
| 468 | + mclk, rate, pll_mode); | |
| 469 | + for (i = 0; i < ARRAY_SIZE(adc3xxx_divs); i++) { | |
| 470 | + const struct adc3xxx_rate_divs *mode = &adc3xxx_divs[i]; | |
| 471 | + | |
| 472 | + /* Skip this entry if it doesn't fulfill the intended clock | |
| 473 | + * mode requirement. We consider anything besides the two | |
| 474 | + * modes below to be the same as ADC3XXX_PLL_AUTO. | |
| 475 | + */ | |
| 476 | + if ((pll_mode == ADC3XXX_PLL_BYPASS && mode->pll_p) || | |
| 477 | + (pll_mode == ADC3XXX_PLL_ENABLE && !mode->pll_p)) | |
| 478 | + continue; | |
| 479 | + | |
| 480 | + if (mode->rate == rate && mode->mclk == mclk) | |
| 481 | + return i; | |
| 482 | + } | |
| 483 | + | |
| 484 | + dev_info(dev, "Master clock rate %d and sample rate %d is not supported\n", | |
| 485 | + mclk, rate); | |
| 486 | + return -EINVAL; | |
| 487 | +} | |
| 488 | + | |
| 489 | +static int adc3xxx_pll_delay(struct snd_soc_dapm_widget *w, | |
| 490 | + struct snd_kcontrol *kcontrol, int event) | |
| 491 | +{ | |
| 492 | + /* 10msec delay needed after PLL power-up to allow | |
| 493 | + * PLL and dividers to stabilize (datasheet p13). | |
| 494 | + */ | |
| 495 | + usleep_range(10000, 20000); | |
| 496 | + | |
| 497 | + return 0; | |
| 498 | +} | |
| 499 | + | |
| 500 | +static const char * const adc_softstepping_text[] = { "1 step", "2 step", "off" }; | |
| 501 | +static SOC_ENUM_SINGLE_DECL(adc_softstepping_enum, ADC3XXX_ADC_DIGITAL, 0, | |
| 502 | + adc_softstepping_text); | |
| 503 | + | |
| 504 | +static const char * const multiplier_text[] = { "1", "2", "4", "8", "16", "32", "64", "128" }; | |
| 505 | +static SOC_ENUM_SINGLE_DECL(left_agc_attack_mult_enum, | |
| 506 | + ADC3XXX_LEFT_CHN_AGC_4, 0, multiplier_text); | |
| 507 | +static SOC_ENUM_SINGLE_DECL(right_agc_attack_mult_enum, | |
| 508 | + ADC3XXX_RIGHT_CHN_AGC_4, 0, multiplier_text); | |
| 509 | +static SOC_ENUM_SINGLE_DECL(left_agc_decay_mult_enum, | |
| 510 | + ADC3XXX_LEFT_CHN_AGC_5, 0, multiplier_text); | |
| 511 | +static SOC_ENUM_SINGLE_DECL(right_agc_decay_mult_enum, | |
| 512 | + ADC3XXX_RIGHT_CHN_AGC_5, 0, multiplier_text); | |
| 513 | + | |
| 514 | +static const char * const dither_dc_offset_text[] = { | |
| 515 | + "0mV", "15mV", "30mV", "45mV", "60mV", "75mV", "90mV", "105mV", | |
| 516 | + "-15mV", "-30mV", "-45mV", "-60mV", "-75mV", "-90mV", "-105mV" | |
| 517 | +}; | |
| 518 | +static const unsigned int dither_dc_offset_values[] = { | |
| 519 | + 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15 | |
| 520 | +}; | |
| 521 | +static SOC_VALUE_ENUM_DOUBLE_DECL(dither_dc_offset_enum, | |
| 522 | + ADC3XXX_DITHER_CTRL, | |
| 523 | + 4, 0, 0xf, dither_dc_offset_text, | |
| 524 | + dither_dc_offset_values); | |
| 525 | + | |
| 526 | +static const DECLARE_TLV_DB_SCALE(pga_tlv, 0, 50, 0); | |
| 527 | +static const DECLARE_TLV_DB_SCALE(adc_tlv, -1200, 50, 0); | |
| 528 | +static const DECLARE_TLV_DB_SCALE(adc_fine_tlv, -40, 10, 0); | |
| 529 | +/* AGC target: 8 values: -5.5, -8, -10, -12, -14, -17, -20, -24 dB */ | |
| 530 | +/* It would be nice to declare these in the order above, but empirically | |
| 531 | + * TLV_DB_SCALE_ITEM doesn't take lightly to the increment (second) parameter | |
| 532 | + * being negative, despite there being examples to the contrary in other | |
| 533 | + * drivers. So declare these in the order from lowest to highest, and | |
| 534 | + * set the invert flag in the SOC_DOUBLE_R_TLV declaration instead. | |
| 535 | + */ | |
| 536 | +static const DECLARE_TLV_DB_RANGE(agc_target_tlv, | |
| 537 | + 0, 0, TLV_DB_SCALE_ITEM(-2400, 0, 0), | |
| 538 | + 1, 3, TLV_DB_SCALE_ITEM(-2000, 300, 0), | |
| 539 | + 4, 6, TLV_DB_SCALE_ITEM(-1200, 200, 0), | |
| 540 | + 7, 7, TLV_DB_SCALE_ITEM(-550, 0, 0)); | |
| 541 | +/* Since the 'disabled' value (mute) is at the highest value in the dB | |
| 542 | + * range (i.e. just before -32 dB) rather than the lowest, we need to resort | |
| 543 | + * to using a TLV_DB_RANGE in order to get the mute value in the right place. | |
| 544 | + */ | |
| 545 | +static const DECLARE_TLV_DB_RANGE(agc_thresh_tlv, | |
| 546 | + 0, 30, TLV_DB_SCALE_ITEM(-9000, 200, 0), | |
| 547 | + 31, 31, TLV_DB_SCALE_ITEM(0, 0, 1)); /* disabled = mute */ | |
| 548 | +/* AGC hysteresis: 4 values: 1, 2, 4 dB, disabled (= mute) */ | |
| 549 | +static const DECLARE_TLV_DB_RANGE(agc_hysteresis_tlv, | |
| 550 | + 0, 1, TLV_DB_SCALE_ITEM(100, 100, 0), | |
| 551 | + 2, 2, TLV_DB_SCALE_ITEM(400, 0, 0), | |
| 552 | + 3, 3, TLV_DB_SCALE_ITEM(0, 0, 1)); /* disabled = mute */ | |
| 553 | +static const DECLARE_TLV_DB_SCALE(agc_max_tlv, 0, 50, 0); | |
| 554 | +/* Input attenuation: -6 dB or 0 dB */ | |
| 555 | +static const DECLARE_TLV_DB_SCALE(input_attenuation_tlv, -600, 600, 0); | |
| 556 | + | |
| 557 | +static const struct snd_kcontrol_new adc3xxx_snd_controls[] = { | |
| 558 | + SOC_DOUBLE_R_TLV("PGA Capture Volume", ADC3XXX_LEFT_APGA_CTRL, | |
| 559 | + ADC3XXX_RIGHT_APGA_CTRL, 0, 80, 0, pga_tlv), | |
| 560 | + SOC_DOUBLE("PGA Capture Switch", ADC3XXX_ADC_FGA, 7, 3, 1, 1), | |
| 561 | + SOC_DOUBLE_R("AGC Capture Switch", ADC3XXX_LEFT_CHN_AGC_1, | |
| 562 | + ADC3XXX_RIGHT_CHN_AGC_1, 7, 1, 0), | |
| 563 | + SOC_DOUBLE_R_TLV("AGC Target Level Capture Volume", ADC3XXX_LEFT_CHN_AGC_1, | |
| 564 | + ADC3XXX_RIGHT_CHN_AGC_2, 4, 0x07, 1, agc_target_tlv), | |
| 565 | + SOC_DOUBLE_R_TLV("AGC Noise Threshold Capture Volume", ADC3XXX_LEFT_CHN_AGC_2, | |
| 566 | + ADC3XXX_RIGHT_CHN_AGC_2, 1, 0x1f, 1, agc_thresh_tlv), | |
| 567 | + SOC_DOUBLE_R_TLV("AGC Hysteresis Capture Volume", ADC3XXX_LEFT_CHN_AGC_2, | |
| 568 | + ADC3XXX_RIGHT_CHN_AGC_2, 6, 3, 0, agc_hysteresis_tlv), | |
| 569 | + SOC_DOUBLE_R("AGC Clip Stepping Capture Switch", ADC3XXX_LEFT_CHN_AGC_2, | |
| 570 | + ADC3XXX_RIGHT_CHN_AGC_2, 0, 1, 0), | |
| 571 | + /* | |
| 572 | + * Oddly enough, the data sheet says the default value | |
| 573 | + * for the left/right AGC maximum gain register field | |
| 574 | + * (ADC3XXX_LEFT/RIGHT_CHN_AGC_3 bits 0..6) is 0x7f = 127 | |
| 575 | + * (verified empirically) even though this value (indeed, above | |
| 576 | + * 0x50) is specified as 'Reserved. Do not use.' in the accompanying | |
| 577 | + * table in the data sheet. | |
| 578 | + */ | |
| 579 | + SOC_DOUBLE_R_TLV("AGC Maximum Capture Volume", ADC3XXX_LEFT_CHN_AGC_3, | |
| 580 | + ADC3XXX_RIGHT_CHN_AGC_3, 0, 0x50, 0, agc_max_tlv), | |
| 581 | + SOC_DOUBLE_R("AGC Attack Time", ADC3XXX_LEFT_CHN_AGC_4, | |
| 582 | + ADC3XXX_RIGHT_CHN_AGC_4, 3, 0x1f, 0), | |
| 583 | + /* Would like to have the multipliers as LR pairs, but there is | |
| 584 | + * no SOC_ENUM_foo which accepts two values in separate registers. | |
| 585 | + */ | |
| 586 | + SOC_ENUM("AGC Left Attack Time Multiplier", left_agc_attack_mult_enum), | |
| 587 | + SOC_ENUM("AGC Right Attack Time Multiplier", right_agc_attack_mult_enum), | |
| 588 | + SOC_DOUBLE_R("AGC Decay Time", ADC3XXX_LEFT_CHN_AGC_5, | |
| 589 | + ADC3XXX_RIGHT_CHN_AGC_5, 3, 0x1f, 0), | |
| 590 | + SOC_ENUM("AGC Left Decay Time Multiplier", left_agc_decay_mult_enum), | |
| 591 | + SOC_ENUM("AGC Right Decay Time Multiplier", right_agc_decay_mult_enum), | |
| 592 | + SOC_DOUBLE_R("AGC Noise Debounce", ADC3XXX_LEFT_CHN_AGC_6, | |
| 593 | + ADC3XXX_RIGHT_CHN_AGC_6, 0, 0x1f, 0), | |
| 594 | + SOC_DOUBLE_R("AGC Signal Debounce", ADC3XXX_LEFT_CHN_AGC_7, | |
| 595 | + ADC3XXX_RIGHT_CHN_AGC_7, 0, 0x0f, 0), | |
| 596 | + /* Read only register */ | |
| 597 | + SOC_DOUBLE_R_S_TLV("AGC Applied Capture Volume", ADC3XXX_LEFT_AGC_GAIN, | |
| 598 | + ADC3XXX_RIGHT_AGC_GAIN, 0, -24, 40, 6, 0, adc_tlv), | |
| 599 | + /* ADC soft stepping */ | |
| 600 | + SOC_ENUM("ADC Soft Stepping", adc_softstepping_enum), | |
| 601 | + /* Left/Right Input attenuation */ | |
| 602 | + SOC_SINGLE_TLV("Left Input IN_1L Capture Volume", | |
| 603 | + ADC3XXX_LEFT_PGA_SEL_1, 0, 1, 1, input_attenuation_tlv), | |
| 604 | + SOC_SINGLE_TLV("Left Input IN_2L Capture Volume", | |
| 605 | + ADC3XXX_LEFT_PGA_SEL_1, 2, 1, 1, input_attenuation_tlv), | |
| 606 | + SOC_SINGLE_TLV("Left Input IN_3L Capture Volume", | |
| 607 | + ADC3XXX_LEFT_PGA_SEL_1, 4, 1, 1, input_attenuation_tlv), | |
| 608 | + SOC_SINGLE_TLV("Left Input IN_1R Capture Volume", | |
| 609 | + ADC3XXX_LEFT_PGA_SEL_2, 0, 1, 1, input_attenuation_tlv), | |
| 610 | + SOC_SINGLE_TLV("Left Input DIF_2L_3L Capture Volume", | |
| 611 | + ADC3XXX_LEFT_PGA_SEL_1, 6, 1, 1, input_attenuation_tlv), | |
| 612 | + SOC_SINGLE_TLV("Left Input DIF_1L_1R Capture Volume", | |
| 613 | + ADC3XXX_LEFT_PGA_SEL_2, 4, 1, 1, input_attenuation_tlv), | |
| 614 | + SOC_SINGLE_TLV("Left Input DIF_2R_3R Capture Volume", | |
| 615 | + ADC3XXX_LEFT_PGA_SEL_2, 2, 1, 1, input_attenuation_tlv), | |
| 616 | + SOC_SINGLE_TLV("Right Input IN_1R Capture Volume", | |
| 617 | + ADC3XXX_RIGHT_PGA_SEL_1, 0, 1, 1, input_attenuation_tlv), | |
| 618 | + SOC_SINGLE_TLV("Right Input IN_2R Capture Volume", | |
| 619 | + ADC3XXX_RIGHT_PGA_SEL_1, 2, 1, 1, input_attenuation_tlv), | |
| 620 | + SOC_SINGLE_TLV("Right Input IN_3R Capture Volume", | |
| 621 | + ADC3XXX_RIGHT_PGA_SEL_1, 4, 1, 1, input_attenuation_tlv), | |
| 622 | + SOC_SINGLE_TLV("Right Input IN_1L Capture Volume", | |
| 623 | + ADC3XXX_RIGHT_PGA_SEL_2, 0, 1, 1, input_attenuation_tlv), | |
| 624 | + SOC_SINGLE_TLV("Right Input DIF_2R_3R Capture Volume", | |
| 625 | + ADC3XXX_RIGHT_PGA_SEL_1, 6, 1, 1, input_attenuation_tlv), | |
| 626 | + SOC_SINGLE_TLV("Right Input DIF_1L_1R Capture Volume", | |
| 627 | + ADC3XXX_RIGHT_PGA_SEL_2, 4, 1, 1, input_attenuation_tlv), | |
| 628 | + SOC_SINGLE_TLV("Right Input DIF_2L_3L Capture Volume", | |
| 629 | + ADC3XXX_RIGHT_PGA_SEL_2, 2, 1, 1, input_attenuation_tlv), | |
| 630 | + SOC_DOUBLE_R_S_TLV("ADC Volume Control Capture Volume", ADC3XXX_LADC_VOL, | |
| 631 | + ADC3XXX_RADC_VOL, 0, -24, 40, 6, 0, adc_tlv), | |
| 632 | + /* Empirically, the following doesn't work the way it's supposed | |
| 633 | + * to. Values 0, -0.1, -0.2 and -0.3 dB result in the same level, and | |
| 634 | + * -0.4 dB drops about 0.12 dB on a specific chip. | |
| 635 | + */ | |
| 636 | + SOC_DOUBLE_TLV("ADC Fine Volume Control Capture Volume", ADC3XXX_ADC_FGA, | |
| 637 | + 4, 0, 4, 1, adc_fine_tlv), | |
| 638 | + SOC_SINGLE("Left ADC Unselected CM Bias Capture Switch", | |
| 639 | + ADC3XXX_LEFT_PGA_SEL_2, 6, 1, 0), | |
| 640 | + SOC_SINGLE("Right ADC Unselected CM Bias Capture Switch", | |
| 641 | + ADC3XXX_RIGHT_PGA_SEL_2, 6, 1, 0), | |
| 642 | + SOC_ENUM("Dither Control DC Offset", dither_dc_offset_enum), | |
| 643 | +}; | |
| 644 | + | |
| 645 | +/* Left input selection, Single Ended inputs and Differential inputs */ | |
| 646 | +static const struct snd_kcontrol_new left_input_mixer_controls[] = { | |
| 647 | + SOC_DAPM_SINGLE("IN_1L Capture Switch", | |
| 648 | + ADC3XXX_LEFT_PGA_SEL_1, 1, 0x1, 1), | |
| 649 | + SOC_DAPM_SINGLE("IN_2L Capture Switch", | |
| 650 | + ADC3XXX_LEFT_PGA_SEL_1, 3, 0x1, 1), | |
| 651 | + SOC_DAPM_SINGLE("IN_3L Capture Switch", | |
| 652 | + ADC3XXX_LEFT_PGA_SEL_1, 5, 0x1, 1), | |
| 653 | + SOC_DAPM_SINGLE("DIF_2L_3L Capture Switch", | |
| 654 | + ADC3XXX_LEFT_PGA_SEL_1, 7, 0x1, 1), | |
| 655 | + SOC_DAPM_SINGLE("DIF_1L_1R Capture Switch", | |
| 656 | + ADC3XXX_LEFT_PGA_SEL_2, 5, 0x1, 1), | |
| 657 | + SOC_DAPM_SINGLE("DIF_2R_3R Capture Switch", | |
| 658 | + ADC3XXX_LEFT_PGA_SEL_2, 3, 0x1, 1), | |
| 659 | + SOC_DAPM_SINGLE("IN_1R Capture Switch", | |
| 660 | + ADC3XXX_LEFT_PGA_SEL_2, 1, 0x1, 1), | |
| 661 | +}; | |
| 662 | + | |
| 663 | +/* Right input selection, Single Ended inputs and Differential inputs */ | |
| 664 | +static const struct snd_kcontrol_new right_input_mixer_controls[] = { | |
| 665 | + SOC_DAPM_SINGLE("IN_1R Capture Switch", | |
| 666 | + ADC3XXX_RIGHT_PGA_SEL_1, 1, 0x1, 1), | |
| 667 | + SOC_DAPM_SINGLE("IN_2R Capture Switch", | |
| 668 | + ADC3XXX_RIGHT_PGA_SEL_1, 3, 0x1, 1), | |
| 669 | + SOC_DAPM_SINGLE("IN_3R Capture Switch", | |
| 670 | + ADC3XXX_RIGHT_PGA_SEL_1, 5, 0x1, 1), | |
| 671 | + SOC_DAPM_SINGLE("DIF_2R_3R Capture Switch", | |
| 672 | + ADC3XXX_RIGHT_PGA_SEL_1, 7, 0x1, 1), | |
| 673 | + SOC_DAPM_SINGLE("DIF_1L_1R Capture Switch", | |
| 674 | + ADC3XXX_RIGHT_PGA_SEL_2, 5, 0x1, 1), | |
| 675 | + SOC_DAPM_SINGLE("DIF_2L_3L Capture Switch", | |
| 676 | + ADC3XXX_RIGHT_PGA_SEL_2, 3, 0x1, 1), | |
| 677 | + SOC_DAPM_SINGLE("IN_1L Capture Switch", | |
| 678 | + ADC3XXX_RIGHT_PGA_SEL_2, 1, 0x1, 1), | |
| 679 | +}; | |
| 680 | + | |
| 681 | +/* Left Digital Mic input for left ADC */ | |
| 682 | +static const struct snd_kcontrol_new left_input_dmic_controls[] = { | |
| 683 | + SOC_DAPM_SINGLE("Left ADC Capture Switch", | |
| 684 | + ADC3XXX_ADC_DIGITAL, 3, 0x1, 0), | |
| 685 | +}; | |
| 686 | + | |
| 687 | +/* Right Digital Mic input for Right ADC */ | |
| 688 | +static const struct snd_kcontrol_new right_input_dmic_controls[] = { | |
| 689 | + SOC_DAPM_SINGLE("Right ADC Capture Switch", | |
| 690 | + ADC3XXX_ADC_DIGITAL, 2, 0x1, 0), | |
| 691 | +}; | |
| 692 | + | |
| 693 | +/* DAPM widgets */ | |
| 694 | +static const struct snd_soc_dapm_widget adc3xxx_dapm_widgets[] = { | |
| 695 | + | |
| 696 | + /* Left Input Selection */ | |
| 697 | + SND_SOC_DAPM_MIXER("Left Input", SND_SOC_NOPM, 0, 0, | |
| 698 | + &left_input_mixer_controls[0], | |
| 699 | + ARRAY_SIZE(left_input_mixer_controls)), | |
| 700 | + /* Right Input Selection */ | |
| 701 | + SND_SOC_DAPM_MIXER("Right Input", SND_SOC_NOPM, 0, 0, | |
| 702 | + &right_input_mixer_controls[0], | |
| 703 | + ARRAY_SIZE(right_input_mixer_controls)), | |
| 704 | + /* PGA selection */ | |
| 705 | + SND_SOC_DAPM_PGA("Left PGA", ADC3XXX_LEFT_APGA_CTRL, 7, 1, NULL, 0), | |
| 706 | + SND_SOC_DAPM_PGA("Right PGA", ADC3XXX_RIGHT_APGA_CTRL, 7, 1, NULL, 0), | |
| 707 | + | |
| 708 | + /* Digital Microphone Input Control for Left/Right ADC */ | |
| 709 | + SND_SOC_DAPM_MIXER("Left DMic Input", SND_SOC_NOPM, 0, 0, | |
| 710 | + &left_input_dmic_controls[0], | |
| 711 | + ARRAY_SIZE(left_input_dmic_controls)), | |
| 712 | + SND_SOC_DAPM_MIXER("Right DMic Input", SND_SOC_NOPM, 0, 0, | |
| 713 | + &right_input_dmic_controls[0], | |
| 714 | + ARRAY_SIZE(right_input_dmic_controls)), | |
| 715 | + | |
| 716 | + /* Left/Right ADC */ | |
| 717 | + SND_SOC_DAPM_ADC("Left ADC", "Left Capture", ADC3XXX_ADC_DIGITAL, 7, 0), | |
| 718 | + SND_SOC_DAPM_ADC("Right ADC", "Right Capture", ADC3XXX_ADC_DIGITAL, 6, 0), | |
| 719 | + | |
| 720 | + /* Inputs */ | |
| 721 | + SND_SOC_DAPM_INPUT("IN_1L"), | |
| 722 | + SND_SOC_DAPM_INPUT("IN_1R"), | |
| 723 | + SND_SOC_DAPM_INPUT("IN_2L"), | |
| 724 | + SND_SOC_DAPM_INPUT("IN_2R"), | |
| 725 | + SND_SOC_DAPM_INPUT("IN_3L"), | |
| 726 | + SND_SOC_DAPM_INPUT("IN_3R"), | |
| 727 | + SND_SOC_DAPM_INPUT("DIFL_1L_1R"), | |
| 728 | + SND_SOC_DAPM_INPUT("DIFL_2L_3L"), | |
| 729 | + SND_SOC_DAPM_INPUT("DIFL_2R_3R"), | |
| 730 | + SND_SOC_DAPM_INPUT("DIFR_1L_1R"), | |
| 731 | + SND_SOC_DAPM_INPUT("DIFR_2L_3L"), | |
| 732 | + SND_SOC_DAPM_INPUT("DIFR_2R_3R"), | |
| 733 | + SND_SOC_DAPM_INPUT("DMic_L"), | |
| 734 | + SND_SOC_DAPM_INPUT("DMic_R"), | |
| 735 | + | |
| 736 | + /* Digital audio interface output */ | |
| 737 | + SND_SOC_DAPM_AIF_OUT("AIF_OUT", "Capture", 0, SND_SOC_NOPM, 0, 0), | |
| 738 | + | |
| 739 | + /* Clocks */ | |
| 740 | + SND_SOC_DAPM_SUPPLY("PLL_CLK", ADC3XXX_PLL_PROG_PR, ADC3XXX_ENABLE_PLL_SHIFT, | |
| 741 | + 0, adc3xxx_pll_delay, SND_SOC_DAPM_POST_PMU), | |
| 742 | + | |
| 743 | + SND_SOC_DAPM_SUPPLY("ADC_CLK", ADC3XXX_ADC_NADC, ADC3XXX_ENABLE_NADC_SHIFT, | |
| 744 | + 0, NULL, 0), | |
| 745 | + SND_SOC_DAPM_SUPPLY("ADC_MOD_CLK", ADC3XXX_ADC_MADC, ADC3XXX_ENABLE_MADC_SHIFT, | |
| 746 | + 0, NULL, 0), | |
| 747 | + | |
| 748 | + /* This refers to the generated BCLK in master mode. */ | |
| 749 | + SND_SOC_DAPM_SUPPLY("BCLK", ADC3XXX_BCLK_N_DIV, ADC3XXX_ENABLE_BCLK_SHIFT, | |
| 750 | + 0, NULL, 0), | |
| 751 | +}; | |
| 752 | + | |
| 753 | +static const struct snd_soc_dapm_route adc3xxx_intercon[] = { | |
| 754 | + /* Left input selection from switches */ | |
| 755 | + { "Left Input", "IN_1L Capture Switch", "IN_1L" }, | |
| 756 | + { "Left Input", "IN_2L Capture Switch", "IN_2L" }, | |
| 757 | + { "Left Input", "IN_3L Capture Switch", "IN_3L" }, | |
| 758 | + { "Left Input", "DIF_2L_3L Capture Switch", "DIFL_2L_3L" }, | |
| 759 | + { "Left Input", "DIF_1L_1R Capture Switch", "DIFL_1L_1R" }, | |
| 760 | + { "Left Input", "DIF_2R_3R Capture Switch", "DIFL_2R_3R" }, | |
| 761 | + { "Left Input", "IN_1R Capture Switch", "IN_1R" }, | |
| 762 | + | |
| 763 | + /* Left input selection to left PGA */ | |
| 764 | + { "Left PGA", NULL, "Left Input" }, | |
| 765 | + | |
| 766 | + /* Left PGA to left ADC */ | |
| 767 | + { "Left ADC", NULL, "Left PGA" }, | |
| 768 | + | |
| 769 | + /* Right input selection from switches */ | |
| 770 | + { "Right Input", "IN_1R Capture Switch", "IN_1R" }, | |
| 771 | + { "Right Input", "IN_2R Capture Switch", "IN_2R" }, | |
| 772 | + { "Right Input", "IN_3R Capture Switch", "IN_3R" }, | |
| 773 | + { "Right Input", "DIF_2R_3R Capture Switch", "DIFR_2R_3R" }, | |
| 774 | + { "Right Input", "DIF_1L_1R Capture Switch", "DIFR_1L_1R" }, | |
| 775 | + { "Right Input", "DIF_2L_3L Capture Switch", "DIFR_2L_3L" }, | |
| 776 | + { "Right Input", "IN_1L Capture Switch", "IN_1L" }, | |
| 777 | + | |
| 778 | + /* Right input selection to right PGA */ | |
| 779 | + { "Right PGA", NULL, "Right Input" }, | |
| 780 | + | |
| 781 | + /* Right PGA to right ADC */ | |
| 782 | + { "Right ADC", NULL, "Right PGA" }, | |
| 783 | + | |
| 784 | + /* Left DMic Input selection from switch */ | |
| 785 | + { "Left DMic Input", "Left ADC Capture Switch", "DMic_L" }, | |
| 786 | + | |
| 787 | + /* Left DMic to left ADC */ | |
| 788 | + { "Left ADC", NULL, "Left DMic Input" }, | |
| 789 | + | |
| 790 | + /* Right DMic Input selection from switch */ | |
| 791 | + { "Right DMic Input", "Right ADC Capture Switch", "DMic_R" }, | |
| 792 | + | |
| 793 | + /* Right DMic to right ADC */ | |
| 794 | + { "Right ADC", NULL, "Right DMic Input" }, | |
| 795 | + | |
| 796 | + /* ADC to AIF output */ | |
| 797 | + { "AIF_OUT", NULL, "Left ADC" }, | |
| 798 | + { "AIF_OUT", NULL, "Right ADC" }, | |
| 799 | + | |
| 800 | + /* Clocking */ | |
| 801 | + { "ADC_MOD_CLK", NULL, "ADC_CLK" }, | |
| 802 | + { "Left ADC", NULL, "ADC_MOD_CLK" }, | |
| 803 | + { "Right ADC", NULL, "ADC_MOD_CLK" }, | |
| 804 | + | |
| 805 | + { "BCLK", NULL, "ADC_CLK" }, | |
| 806 | +}; | |
| 807 | + | |
| 808 | +static const struct snd_soc_dapm_route adc3xxx_pll_intercon[] = { | |
| 809 | + { "ADC_CLK", NULL, "PLL_CLK" }, | |
| 810 | +}; | |
| 811 | + | |
| 812 | +static const struct snd_soc_dapm_route adc3xxx_bclk_out_intercon[] = { | |
| 813 | + { "AIF_OUT", NULL, "BCLK" } | |
| 814 | +}; | |
| 815 | + | |
| 816 | +static int adc3xxx_gpio_request(struct gpio_chip *chip, unsigned int offset) | |
| 817 | +{ | |
| 818 | + struct adc3xxx *adc3xxx = gpiochip_get_data(chip); | |
| 819 | + | |
| 820 | + if (offset >= ADC3XXX_GPIOS_MAX) | |
| 821 | + return -EINVAL; | |
| 822 | + | |
| 823 | + /* GPIO1 is offset 0, GPIO2 is offset 1 */ | |
| 824 | + /* We check here that the GPIO pins are either not configured in the | |
| 825 | + * DT, or that they purposely are set as outputs. | |
| 826 | + * (Input mode not yet implemented). | |
| 827 | + */ | |
| 828 | + if (adc3xxx->gpio_cfg[offset] != 0 && | |
| 829 | + adc3xxx->gpio_cfg[offset] != ADC3XXX_GPIO_GPO + 1) | |
| 830 | + return -EINVAL; | |
| 831 | + | |
| 832 | + return 0; | |
| 833 | +} | |
| 834 | + | |
| 835 | +static int adc3xxx_gpio_direction_out(struct gpio_chip *chip, | |
| 836 | + unsigned int offset, int value) | |
| 837 | +{ | |
| 838 | + struct adc3xxx *adc3xxx = gpiochip_get_data(chip); | |
| 839 | + | |
| 840 | + /* Set GPIO output function. */ | |
| 841 | + return regmap_update_bits(adc3xxx->regmap, | |
| 842 | + adc3xxx_gpio_ctrl_reg[offset], | |
| 843 | + ADC3XXX_GPIO_CTRL_CFG_MASK | | |
| 844 | + ADC3XXX_GPIO_CTRL_OUTPUT_CTRL_MASK, | |
| 845 | + ADC3XXX_GPIO_GPO << ADC3XXX_GPIO_CTRL_CFG_SHIFT | | |
| 846 | + !!value << ADC3XXX_GPIO_CTRL_OUTPUT_CTRL_SHIFT); | |
| 847 | +} | |
| 848 | + | |
| 849 | +/* With only GPIO outputs configured, we never get the .direction_out call, | |
| 850 | + * so we set the output mode and output value in the same call. Hence | |
| 851 | + * .set in practice does the same thing as .direction_out . | |
| 852 | + */ | |
| 853 | +static void adc3xxx_gpio_set(struct gpio_chip *chip, unsigned int offset, | |
| 854 | + int value) | |
| 855 | +{ | |
| 856 | + (void) adc3xxx_gpio_direction_out(chip, offset, value); | |
| 857 | +} | |
| 858 | + | |
| 859 | +/* Even though we only support GPIO output for now, some GPIO clients | |
| 860 | + * want to read the current pin state using the .get callback. | |
| 861 | + */ | |
| 862 | +static int adc3xxx_gpio_get(struct gpio_chip *chip, unsigned int offset) | |
| 863 | +{ | |
| 864 | + struct adc3xxx *adc3xxx = gpiochip_get_data(chip); | |
| 865 | + unsigned int regval; | |
| 866 | + int ret; | |
| 867 | + | |
| 868 | + /* We only allow output pins, so just read the value set in the output | |
| 869 | + * pin register field. | |
| 870 | + */ | |
| 871 | + ret = regmap_read(adc3xxx->regmap, adc3xxx_gpio_ctrl_reg[offset], ®val); | |
| 872 | + if (ret) | |
| 873 | + return ret; | |
| 874 | + return !!(regval & ADC3XXX_GPIO_CTRL_OUTPUT_CTRL_MASK); | |
| 875 | +} | |
| 876 | + | |
| 877 | +static const struct gpio_chip adc3xxx_gpio_chip = { | |
| 878 | + .label = "adc3xxx", | |
| 879 | + .owner = THIS_MODULE, | |
| 880 | + .request = adc3xxx_gpio_request, | |
| 881 | + .direction_output = adc3xxx_gpio_direction_out, | |
| 882 | + .set = adc3xxx_gpio_set, | |
| 883 | + .get = adc3xxx_gpio_get, | |
| 884 | + .can_sleep = 1, | |
| 885 | +}; | |
| 886 | + | |
| 887 | +static void adc3xxx_free_gpio(struct adc3xxx *adc3xxx) | |
| 888 | +{ | |
| 889 | + gpiochip_remove(&adc3xxx->gpio_chip); | |
| 890 | +} | |
| 891 | + | |
| 892 | +static void adc3xxx_init_gpio(struct adc3xxx *adc3xxx) | |
| 893 | +{ | |
| 894 | + int gpio, micbias; | |
| 895 | + int ret; | |
| 896 | + | |
| 897 | + adc3xxx->gpio_chip = adc3xxx_gpio_chip; | |
| 898 | + adc3xxx->gpio_chip.ngpio = ADC3XXX_GPIOS_MAX; | |
| 899 | + adc3xxx->gpio_chip.parent = adc3xxx->dev; | |
| 900 | + adc3xxx->gpio_chip.base = -1; | |
| 901 | + | |
| 902 | + ret = gpiochip_add_data(&adc3xxx->gpio_chip, adc3xxx); | |
| 903 | + if (ret) | |
| 904 | + dev_err(adc3xxx->dev, "Failed to add gpios: %d\n", ret); | |
| 905 | + | |
| 906 | + /* Set up potential GPIO configuration from the devicetree. | |
| 907 | + * This allows us to set up things which are not software | |
| 908 | + * controllable GPIOs, such as PDM microphone I/O, | |
| 909 | + */ | |
| 910 | + for (gpio = 0; gpio < ADC3XXX_GPIOS_MAX; gpio++) { | |
| 911 | + unsigned int cfg = adc3xxx->gpio_cfg[gpio]; | |
| 912 | + | |
| 913 | + if (cfg) { | |
| 914 | + cfg--; /* actual value to use is stored +1 */ | |
| 915 | + regmap_update_bits(adc3xxx->regmap, | |
| 916 | + adc3xxx_gpio_ctrl_reg[gpio], | |
| 917 | + ADC3XXX_GPIO_CTRL_CFG_MASK, | |
| 918 | + cfg << ADC3XXX_GPIO_CTRL_CFG_SHIFT); | |
| 919 | + } | |
| 920 | + } | |
| 921 | + | |
| 922 | + /* Set up micbias voltage */ | |
| 923 | + for (micbias = 0; micbias < ADC3XXX_MICBIAS_PINS; micbias++) { | |
| 924 | + unsigned int vg = adc3xxx->micbias_vg[micbias]; | |
| 925 | + | |
| 926 | + regmap_update_bits(adc3xxx->regmap, | |
| 927 | + ADC3XXX_MICBIAS_CTRL, | |
| 928 | + ADC3XXX_MICBIAS_MASK << adc3xxx_micbias_shift[micbias], | |
| 929 | + vg << adc3xxx_micbias_shift[micbias]); | |
| 930 | + } | |
| 931 | +} | |
| 932 | + | |
| 933 | +static int adc3xxx_parse_dt_gpio(struct adc3xxx *adc3xxx, | |
| 934 | + const char *propname, unsigned int *cfg) | |
| 935 | +{ | |
| 936 | + struct device *dev = adc3xxx->dev; | |
| 937 | + struct device_node *np = dev->of_node; | |
| 938 | + unsigned int val; | |
| 939 | + | |
| 940 | + if (!of_property_read_u32(np, propname, &val)) { | |
| 941 | + if (val & ~15 || val == 7 || val >= 11) { | |
| 942 | + dev_err(dev, "Invalid property value for '%s'\n", propname); | |
| 943 | + return -EINVAL; | |
| 944 | + } | |
| 945 | + if (val == ADC3XXX_GPIO_GPI) | |
| 946 | + dev_warn(dev, "GPIO Input read not yet implemented\n"); | |
| 947 | + *cfg = val + 1; /* 0 => not set up, all others shifted +1 */ | |
| 948 | + } | |
| 949 | + return 0; | |
| 950 | +} | |
| 951 | + | |
| 952 | +static int adc3xxx_parse_dt_micbias(struct adc3xxx *adc3xxx, | |
| 953 | + const char *propname, unsigned int *vg) | |
| 954 | +{ | |
| 955 | + struct device *dev = adc3xxx->dev; | |
| 956 | + struct device_node *np = dev->of_node; | |
| 957 | + unsigned int val; | |
| 958 | + | |
| 959 | + if (!of_property_read_u32(np, propname, &val)) { | |
| 960 | + if (val >= ADC3XXX_MICBIAS_AVDD) { | |
| 961 | + dev_err(dev, "Invalid property value for '%s'\n", propname); | |
| 962 | + return -EINVAL; | |
| 963 | + } | |
| 964 | + *vg = val; | |
| 965 | + } | |
| 966 | + return 0; | |
| 967 | +} | |
| 968 | + | |
| 969 | +static int adc3xxx_parse_pll_mode(uint32_t val, unsigned int *pll_mode) | |
| 970 | +{ | |
| 971 | + if (val != ADC3XXX_PLL_ENABLE && val != ADC3XXX_PLL_BYPASS && | |
| 972 | + val != ADC3XXX_PLL_AUTO) | |
| 973 | + return -EINVAL; | |
| 974 | + | |
| 975 | + *pll_mode = val; | |
| 976 | + | |
| 977 | + return 0; | |
| 978 | +} | |
| 979 | + | |
| 980 | +static void adc3xxx_setup_pll(struct snd_soc_component *component, | |
| 981 | + int div_entry) | |
| 982 | +{ | |
| 983 | + int i = div_entry; | |
| 984 | + | |
| 985 | + /* P & R values */ | |
| 986 | + snd_soc_component_write(component, ADC3XXX_PLL_PROG_PR, | |
| 987 | + (adc3xxx_divs[i].pll_p << ADC3XXX_PLLP_SHIFT) | | |
| 988 | + (adc3xxx_divs[i].pll_r << ADC3XXX_PLLR_SHIFT)); | |
| 989 | + /* J value */ | |
| 990 | + snd_soc_component_write(component, ADC3XXX_PLL_PROG_J, | |
| 991 | + adc3xxx_divs[i].pll_j & ADC3XXX_PLLJ_MASK); | |
| 992 | + /* D value */ | |
| 993 | + snd_soc_component_write(component, ADC3XXX_PLL_PROG_D_LSB, | |
| 994 | + adc3xxx_divs[i].pll_d & ADC3XXX_PLLD_LSB_MASK); | |
| 995 | + snd_soc_component_write(component, ADC3XXX_PLL_PROG_D_MSB, | |
| 996 | + (adc3xxx_divs[i].pll_d >> 8) & ADC3XXX_PLLD_MSB_MASK); | |
| 997 | +} | |
| 998 | + | |
| 999 | +static int adc3xxx_hw_params(struct snd_pcm_substream *substream, | |
| 1000 | + struct snd_pcm_hw_params *params, | |
| 1001 | + struct snd_soc_dai *dai) | |
| 1002 | +{ | |
| 1003 | + struct snd_soc_component *component = dai->component; | |
| 1004 | + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(dai->component); | |
| 1005 | + struct adc3xxx *adc3xxx = snd_soc_component_get_drvdata(component); | |
| 1006 | + int i, width = 16; | |
| 1007 | + u8 iface_len, bdiv; | |
| 1008 | + | |
| 1009 | + i = adc3xxx_get_divs(component->dev, adc3xxx->sysclk, | |
| 1010 | + params_rate(params), adc3xxx->pll_mode); | |
| 1011 | + | |
| 1012 | + if (i < 0) | |
| 1013 | + return i; | |
| 1014 | + | |
| 1015 | + /* select data word length */ | |
| 1016 | + switch (params_format(params)) { | |
| 1017 | + case SNDRV_PCM_FORMAT_S16_LE: | |
| 1018 | + iface_len = ADC3XXX_IFACE_16BITS; | |
| 1019 | + width = 16; | |
| 1020 | + break; | |
| 1021 | + case SNDRV_PCM_FORMAT_S20_3LE: | |
| 1022 | + iface_len = ADC3XXX_IFACE_20BITS; | |
| 1023 | + width = 20; | |
| 1024 | + break; | |
| 1025 | + case SNDRV_PCM_FORMAT_S24_LE: | |
| 1026 | + iface_len = ADC3XXX_IFACE_24BITS; | |
| 1027 | + width = 24; | |
| 1028 | + break; | |
| 1029 | + case SNDRV_PCM_FORMAT_S32_LE: | |
| 1030 | + iface_len = ADC3XXX_IFACE_32BITS; | |
| 1031 | + width = 32; | |
| 1032 | + break; | |
| 1033 | + default: | |
| 1034 | + dev_err(component->dev, "Unsupported serial data format\n"); | |
| 1035 | + return -EINVAL; | |
| 1036 | + } | |
| 1037 | + snd_soc_component_update_bits(component, ADC3XXX_INTERFACE_CTRL_1, | |
| 1038 | + ADC3XXX_WLENGTH_MASK, iface_len); | |
| 1039 | + if (adc3xxx_divs[i].pll_p) { /* If PLL used for this mode */ | |
| 1040 | + adc3xxx_setup_pll(component, i); | |
| 1041 | + snd_soc_component_write(component, ADC3XXX_CLKGEN_MUX, ADC3XXX_USE_PLL); | |
| 1042 | + if (!adc3xxx->use_pll) { | |
| 1043 | + snd_soc_dapm_add_routes(dapm, adc3xxx_pll_intercon, | |
| 1044 | + ARRAY_SIZE(adc3xxx_pll_intercon)); | |
| 1045 | + adc3xxx->use_pll = 1; | |
| 1046 | + } | |
| 1047 | + } else { | |
| 1048 | + snd_soc_component_write(component, ADC3XXX_CLKGEN_MUX, ADC3XXX_NO_PLL); | |
| 1049 | + if (adc3xxx->use_pll) { | |
| 1050 | + snd_soc_dapm_del_routes(dapm, adc3xxx_pll_intercon, | |
| 1051 | + ARRAY_SIZE(adc3xxx_pll_intercon)); | |
| 1052 | + adc3xxx->use_pll = 0; | |
| 1053 | + } | |
| 1054 | + } | |
| 1055 | + | |
| 1056 | + /* NADC */ | |
| 1057 | + snd_soc_component_update_bits(component, ADC3XXX_ADC_NADC, | |
| 1058 | + ADC3XXX_NADC_MASK, adc3xxx_divs[i].nadc); | |
| 1059 | + /* MADC */ | |
| 1060 | + snd_soc_component_update_bits(component, ADC3XXX_ADC_MADC, | |
| 1061 | + ADC3XXX_MADC_MASK, adc3xxx_divs[i].madc); | |
| 1062 | + /* AOSR */ | |
| 1063 | + snd_soc_component_update_bits(component, ADC3XXX_ADC_AOSR, | |
| 1064 | + ADC3XXX_AOSR_MASK, adc3xxx_divs[i].aosr); | |
| 1065 | + /* BDIV N Value */ | |
| 1066 | + /* BCLK is (by default) set up to be derived from ADC_CLK */ | |
| 1067 | + bdiv = (adc3xxx_divs[i].aosr * adc3xxx_divs[i].madc) / (2 * width); | |
| 1068 | + snd_soc_component_update_bits(component, ADC3XXX_BCLK_N_DIV, | |
| 1069 | + ADC3XXX_BDIV_MASK, bdiv); | |
| 1070 | + | |
| 1071 | + return 0; | |
| 1072 | +} | |
| 1073 | + | |
| 1074 | +static const char *adc3xxx_pll_mode_text(int pll_mode) | |
| 1075 | +{ | |
| 1076 | + switch (pll_mode) { | |
| 1077 | + case ADC3XXX_PLL_AUTO: | |
| 1078 | + return "PLL auto"; | |
| 1079 | + case ADC3XXX_PLL_ENABLE: | |
| 1080 | + return "PLL enable"; | |
| 1081 | + case ADC3XXX_PLL_BYPASS: | |
| 1082 | + return "PLL bypass"; | |
| 1083 | + default: | |
| 1084 | + break; | |
| 1085 | + } | |
| 1086 | + | |
| 1087 | + return "PLL unknown"; | |
| 1088 | +} | |
| 1089 | + | |
| 1090 | +static int adc3xxx_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |
| 1091 | + int clk_id, unsigned int freq, int dir) | |
| 1092 | +{ | |
| 1093 | + struct snd_soc_component *component = codec_dai->component; | |
| 1094 | + struct adc3xxx *adc3xxx = snd_soc_component_get_drvdata(component); | |
| 1095 | + int ret; | |
| 1096 | + | |
| 1097 | + ret = adc3xxx_parse_pll_mode(clk_id, &adc3xxx->pll_mode); | |
| 1098 | + if (ret < 0) | |
| 1099 | + return ret; | |
| 1100 | + | |
| 1101 | + adc3xxx->sysclk = freq; | |
| 1102 | + dev_dbg(component->dev, "Set sysclk to %u Hz, %s\n", | |
| 1103 | + freq, adc3xxx_pll_mode_text(adc3xxx->pll_mode)); | |
| 1104 | + return 0; | |
| 1105 | +} | |
| 1106 | + | |
| 1107 | +static int adc3xxx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |
| 1108 | +{ | |
| 1109 | + struct snd_soc_component *component = codec_dai->component; | |
| 1110 | + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); | |
| 1111 | + struct adc3xxx *adc3xxx = snd_soc_component_get_drvdata(component); | |
| 1112 | + u8 clkdir = 0, format = 0; | |
| 1113 | + int master = 0; | |
| 1114 | + | |
| 1115 | + /* set master/slave audio interface */ | |
| 1116 | + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | |
| 1117 | + case SND_SOC_DAIFMT_CBP_CFP: | |
| 1118 | + master = 1; | |
| 1119 | + clkdir = ADC3XXX_BCLK_MASTER | ADC3XXX_WCLK_MASTER; | |
| 1120 | + break; | |
| 1121 | + case SND_SOC_DAIFMT_CBC_CFC: | |
| 1122 | + master = 0; | |
| 1123 | + break; | |
| 1124 | + default: | |
| 1125 | + dev_err(component->dev, "Invalid DAI clock setup\n"); | |
| 1126 | + return -EINVAL; | |
| 1127 | + } | |
| 1128 | + | |
| 1129 | + /* | |
| 1130 | + * match both interface format and signal polarities since they | |
| 1131 | + * are fixed | |
| 1132 | + */ | |
| 1133 | + switch (fmt & (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK)) { | |
| 1134 | + case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF: | |
| 1135 | + format = ADC3XXX_FORMAT_I2S; | |
| 1136 | + break; | |
| 1137 | + case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF: | |
| 1138 | + format = ADC3XXX_FORMAT_DSP; | |
| 1139 | + break; | |
| 1140 | + case SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF: | |
| 1141 | + format = ADC3XXX_FORMAT_DSP; | |
| 1142 | + break; | |
| 1143 | + case SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_NB_NF: | |
| 1144 | + format = ADC3XXX_FORMAT_RJF; | |
| 1145 | + break; | |
| 1146 | + case SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF: | |
| 1147 | + format = ADC3XXX_FORMAT_LJF; | |
| 1148 | + break; | |
| 1149 | + default: | |
| 1150 | + dev_err(component->dev, "Invalid DAI format\n"); | |
| 1151 | + return -EINVAL; | |
| 1152 | + } | |
| 1153 | + | |
| 1154 | + /* Add/del route enabling BCLK output as applicable */ | |
| 1155 | + if (master && !adc3xxx->master) | |
| 1156 | + snd_soc_dapm_add_routes(dapm, adc3xxx_bclk_out_intercon, | |
| 1157 | + ARRAY_SIZE(adc3xxx_bclk_out_intercon)); | |
| 1158 | + else if (!master && adc3xxx->master) | |
| 1159 | + snd_soc_dapm_del_routes(dapm, adc3xxx_bclk_out_intercon, | |
| 1160 | + ARRAY_SIZE(adc3xxx_bclk_out_intercon)); | |
| 1161 | + adc3xxx->master = master; | |
| 1162 | + | |
| 1163 | + /* set clock direction and format */ | |
| 1164 | + return snd_soc_component_update_bits(component, | |
| 1165 | + ADC3XXX_INTERFACE_CTRL_1, | |
| 1166 | + ADC3XXX_CLKDIR_MASK | ADC3XXX_FORMAT_MASK, | |
| 1167 | + clkdir | format); | |
| 1168 | +} | |
| 1169 | + | |
| 1170 | +static const struct snd_soc_dai_ops adc3xxx_dai_ops = { | |
| 1171 | + .hw_params = adc3xxx_hw_params, | |
| 1172 | + .set_sysclk = adc3xxx_set_dai_sysclk, | |
| 1173 | + .set_fmt = adc3xxx_set_dai_fmt, | |
| 1174 | +}; | |
| 1175 | + | |
| 1176 | +static struct snd_soc_dai_driver adc3xxx_dai = { | |
| 1177 | + .name = "tlv320adc3xxx-hifi", | |
| 1178 | + .capture = { | |
| 1179 | + .stream_name = "Capture", | |
| 1180 | + .channels_min = 1, | |
| 1181 | + .channels_max = 2, | |
| 1182 | + .rates = ADC3XXX_RATES, | |
| 1183 | + .formats = ADC3XXX_FORMATS, | |
| 1184 | + }, | |
| 1185 | + .ops = &adc3xxx_dai_ops, | |
| 1186 | +}; | |
| 1187 | + | |
| 1188 | +static const struct snd_soc_component_driver soc_component_dev_adc3xxx = { | |
| 1189 | + .controls = adc3xxx_snd_controls, | |
| 1190 | + .num_controls = ARRAY_SIZE(adc3xxx_snd_controls), | |
| 1191 | + .dapm_widgets = adc3xxx_dapm_widgets, | |
| 1192 | + .num_dapm_widgets = ARRAY_SIZE(adc3xxx_dapm_widgets), | |
| 1193 | + .dapm_routes = adc3xxx_intercon, | |
| 1194 | + .num_dapm_routes = ARRAY_SIZE(adc3xxx_intercon), | |
| 1195 | +}; | |
| 1196 | + | |
| 1197 | +static int adc3xxx_i2c_probe(struct i2c_client *i2c, | |
| 1198 | + const struct i2c_device_id *id) | |
| 1199 | +{ | |
| 1200 | + struct device *dev = &i2c->dev; | |
| 1201 | + struct adc3xxx *adc3xxx = NULL; | |
| 1202 | + int ret; | |
| 1203 | + | |
| 1204 | + adc3xxx = devm_kzalloc(dev, sizeof(struct adc3xxx), GFP_KERNEL); | |
| 1205 | + if (!adc3xxx) | |
| 1206 | + return -ENOMEM; | |
| 1207 | + adc3xxx->dev = dev; | |
| 1208 | + | |
| 1209 | + adc3xxx->rst_pin = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); | |
| 1210 | + if (IS_ERR(adc3xxx->rst_pin)) { | |
| 1211 | + return dev_err_probe(dev, PTR_ERR(adc3xxx->rst_pin), | |
| 1212 | + "Failed to request rst_pin\n"); | |
| 1213 | + } | |
| 1214 | + | |
| 1215 | + adc3xxx->mclk = devm_clk_get(dev, NULL); | |
| 1216 | + if (IS_ERR(adc3xxx->mclk)) { | |
| 1217 | + /* | |
| 1218 | + * The chip itself supports running off the BCLK either | |
| 1219 | + * directly or via the PLL, but the driver does not (yet), so | |
| 1220 | + * having a specified mclk is required. Otherwise, we could | |
| 1221 | + * use the lack of a clocks property to indicate when BCLK is | |
| 1222 | + * intended as the clock source. | |
| 1223 | + */ | |
| 1224 | + return dev_err_probe(dev, PTR_ERR(adc3xxx->mclk), | |
| 1225 | + "Failed to acquire MCLK\n"); | |
| 1226 | + } else if (adc3xxx->mclk) { | |
| 1227 | + ret = clk_prepare_enable(adc3xxx->mclk); | |
| 1228 | + if (ret < 0) | |
| 1229 | + return ret; | |
| 1230 | + dev_dbg(dev, "Enabled MCLK, freq %lu Hz\n", clk_get_rate(adc3xxx->mclk)); | |
| 1231 | + } | |
| 1232 | + | |
| 1233 | + ret = adc3xxx_parse_dt_gpio(adc3xxx, "ti,dmdin-gpio1", &adc3xxx->gpio_cfg[0]); | |
| 1234 | + if (ret < 0) | |
| 1235 | + goto err_unprepare_mclk; | |
| 1236 | + ret = adc3xxx_parse_dt_gpio(adc3xxx, "ti,dmclk-gpio2", &adc3xxx->gpio_cfg[1]); | |
| 1237 | + if (ret < 0) | |
| 1238 | + goto err_unprepare_mclk; | |
| 1239 | + ret = adc3xxx_parse_dt_micbias(adc3xxx, "ti,micbias1-vg", &adc3xxx->micbias_vg[0]); | |
| 1240 | + if (ret < 0) | |
| 1241 | + goto err_unprepare_mclk; | |
| 1242 | + ret = adc3xxx_parse_dt_micbias(adc3xxx, "ti,micbias2-vg", &adc3xxx->micbias_vg[1]); | |
| 1243 | + if (ret < 0) | |
| 1244 | + goto err_unprepare_mclk; | |
| 1245 | + | |
| 1246 | + adc3xxx->regmap = devm_regmap_init_i2c(i2c, &adc3xxx_regmap); | |
| 1247 | + if (IS_ERR(adc3xxx->regmap)) { | |
| 1248 | + ret = PTR_ERR(adc3xxx->regmap); | |
| 1249 | + goto err_unprepare_mclk; | |
| 1250 | + } | |
| 1251 | + | |
| 1252 | + i2c_set_clientdata(i2c, adc3xxx); | |
| 1253 | + | |
| 1254 | + adc3xxx->type = id->driver_data; | |
| 1255 | + | |
| 1256 | + /* Reset codec chip */ | |
| 1257 | + gpiod_set_value_cansleep(adc3xxx->rst_pin, 1); | |
| 1258 | + usleep_range(2000, 100000); /* Requirement: > 10 ns (datasheet p13) */ | |
| 1259 | + gpiod_set_value_cansleep(adc3xxx->rst_pin, 0); | |
| 1260 | + | |
| 1261 | + /* Potentially set up pins used as GPIOs */ | |
| 1262 | + adc3xxx_init_gpio(adc3xxx); | |
| 1263 | + | |
| 1264 | + ret = snd_soc_register_component(dev, | |
| 1265 | + &soc_component_dev_adc3xxx, &adc3xxx_dai, 1); | |
| 1266 | + if (ret < 0) { | |
| 1267 | + dev_err(dev, "Failed to register codec: %d\n", ret); | |
| 1268 | + goto err_unprepare_mclk; | |
| 1269 | + } | |
| 1270 | + | |
| 1271 | + return 0; | |
| 1272 | + | |
| 1273 | +err_unprepare_mclk: | |
| 1274 | + clk_disable_unprepare(adc3xxx->mclk); | |
| 1275 | + return ret; | |
| 1276 | +} | |
| 1277 | + | |
| 1278 | +static int __exit adc3xxx_i2c_remove(struct i2c_client *client) | |
| 1279 | +{ | |
| 1280 | + struct adc3xxx *adc3xxx = i2c_get_clientdata(client); | |
| 1281 | + | |
| 1282 | + if (adc3xxx->mclk) | |
| 1283 | + clk_disable_unprepare(adc3xxx->mclk); | |
| 1284 | + adc3xxx_free_gpio(adc3xxx); | |
| 1285 | + snd_soc_unregister_component(&client->dev); | |
| 1286 | + return 0; | |
| 1287 | +} | |
| 1288 | + | |
| 1289 | +static const struct of_device_id tlv320adc3xxx_of_match[] = { | |
| 1290 | + { .compatible = "ti,tlv320adc3001", }, | |
| 1291 | + { .compatible = "ti,tlv320adc3101", }, | |
| 1292 | + {}, | |
| 1293 | +}; | |
| 1294 | +MODULE_DEVICE_TABLE(of, tlv320adc3xxx_of_match); | |
| 1295 | + | |
| 1296 | +static const struct i2c_device_id adc3xxx_i2c_id[] = { | |
| 1297 | + { "tlv320adc3001", ADC3001 }, | |
| 1298 | + { "tlv320adc3101", ADC3101 }, | |
| 1299 | + {} | |
| 1300 | +}; | |
| 1301 | +MODULE_DEVICE_TABLE(i2c, adc3xxx_i2c_id); | |
| 1302 | + | |
| 1303 | +static struct i2c_driver adc3xxx_i2c_driver = { | |
| 1304 | + .driver = { | |
| 1305 | + .name = "tlv320adc3xxx-codec", | |
| 1306 | + .of_match_table = tlv320adc3xxx_of_match, | |
| 1307 | + }, | |
| 1308 | + .probe = adc3xxx_i2c_probe, | |
| 1309 | + .remove = adc3xxx_i2c_remove, | |
| 1310 | + .id_table = adc3xxx_i2c_id, | |
| 1311 | +}; | |
| 1312 | + | |
| 1313 | +module_i2c_driver(adc3xxx_i2c_driver); | |
| 1314 | + | |
| 1315 | +MODULE_DESCRIPTION("ASoC TLV320ADC3xxx codec driver"); | |
| 1316 | +MODULE_AUTHOR("shahina.s@mistralsolutions.com"); | |
| 1317 | +MODULE_LICENSE("GPL v2"); | |
| @@ -6,8 +6,8 @@ · 5 unmodified lines | ||
| 6 | 6 | * Copyright (C) 2008 Secret Lab Technologies Ltd. |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | −#ifndef _TLV320AIC16_H_ | |
| 10 | −#define _TLV320AIC16_H_ | |
| 9 | +#ifndef _TLV320AIC26_H_ | |
| 10 | +#define _TLV320AIC26_H_ | |
| 11 | 11 | |
| 12 | 12 | /* AIC26 Registers */ |
| 13 | 13 | #define AIC26_PAGE_ADDR(page, offset) ((page << 11) | offset << 5) |
| @@ -88,4 +88,4 @@ enum aic26_wlen { · 74 unmodified lines | ||
| 88 | 88 | AIC26_WLEN_32 = 3 << 10, |
| 89 | 89 | }; |
| 90 | 90 | |
| 91 | −#endif /* _TLV320AIC16_H_ */ | |
| 91 | +#endif /* _TLV320AIC26_H_ */ | |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <linux/module.h> |
| 16 | 16 | #include <linux/moduleparam.h> |
| 17 | 17 | #include <linux/init.h> |
| 18 | +#include <linux/clk.h> | |
| 18 | 19 | #include <linux/delay.h> |
| 19 | 20 | #include <linux/pm.h> |
| 20 | 21 | #include <linux/i2c.h> |
| @@ -169,6 +170,7 @@ struct aic31xx_priv { · 148 unmodified lines | ||
| 169 | 170 | struct regulator_bulk_data supplies[AIC31XX_NUM_SUPPLIES]; |
| 170 | 171 | struct aic31xx_disable_nb disable_nb[AIC31XX_NUM_SUPPLIES]; |
| 171 | 172 | struct snd_soc_jack *jack; |
| 173 | + u32 sysclk_id; | |
| 172 | 174 | unsigned int sysclk; |
| 173 | 175 | u8 p_div; |
| 174 | 176 | int rate_div_line; |
| @@ -180,6 +182,7 @@ struct aic31xx_priv { · 5 unmodified lines | ||
| 180 | 182 | struct aic31xx_rate_divs { |
| 181 | 183 | u32 mclk_p; |
| 182 | 184 | u32 rate; |
| 185 | + u8 pll_r; | |
| 183 | 186 | u8 pll_j; |
| 184 | 187 | u16 pll_d; |
| 185 | 188 | u16 dosr; |
| @@ -192,51 +195,71 @@ struct aic31xx_rate_divs { · 6 unmodified lines | ||
| 192 | 195 | |
| 193 | 196 | /* ADC dividers can be disabled by configuring them to 0 */ |
| 194 | 197 | static const struct aic31xx_rate_divs aic31xx_divs[] = { |
| 195 | − /* mclk/p rate pll: j d dosr ndac mdac aors nadc madc */ | |
| 198 | + /* mclk/p rate pll: r j d dosr ndac mdac aors nadc madc */ | |
| 196 | 199 | /* 8k rate */ |
| 197 | − {12000000, 8000, 8, 1920, 128, 48, 2, 128, 48, 2}, | |
| 198 | − {12000000, 8000, 8, 1920, 128, 32, 3, 128, 32, 3}, | |
| 199 | − {12500000, 8000, 7, 8643, 128, 48, 2, 128, 48, 2}, | |
| 200 | + { 512000, 8000, 4, 48, 0, 128, 48, 2, 128, 48, 2}, | |
| 201 | + {12000000, 8000, 1, 8, 1920, 128, 48, 2, 128, 48, 2}, | |
| 202 | + {12000000, 8000, 1, 8, 1920, 128, 32, 3, 128, 32, 3}, | |
| 203 | + {12500000, 8000, 1, 7, 8643, 128, 48, 2, 128, 48, 2}, | |
| 200 | 204 | /* 11.025k rate */ |
| 201 | − {12000000, 11025, 7, 5264, 128, 32, 2, 128, 32, 2}, | |
| 202 | − {12000000, 11025, 8, 4672, 128, 24, 3, 128, 24, 3}, | |
| 203 | − {12500000, 11025, 7, 2253, 128, 32, 2, 128, 32, 2}, | |
| 205 | + { 705600, 11025, 3, 48, 0, 128, 24, 3, 128, 24, 3}, | |
| 206 | + {12000000, 11025, 1, 7, 5264, 128, 32, 2, 128, 32, 2}, | |
| 207 | + {12000000, 11025, 1, 8, 4672, 128, 24, 3, 128, 24, 3}, | |
| 208 | + {12500000, 11025, 1, 7, 2253, 128, 32, 2, 128, 32, 2}, | |
| 204 | 209 | /* 16k rate */ |
| 205 | − {12000000, 16000, 8, 1920, 128, 24, 2, 128, 24, 2}, | |
| 206 | − {12000000, 16000, 8, 1920, 128, 16, 3, 128, 16, 3}, | |
| 207 | − {12500000, 16000, 7, 8643, 128, 24, 2, 128, 24, 2}, | |
| 210 | + { 512000, 16000, 4, 48, 0, 128, 16, 3, 128, 16, 3}, | |
| 211 | + { 1024000, 16000, 2, 48, 0, 128, 16, 3, 128, 16, 3}, | |
| 212 | + {12000000, 16000, 1, 8, 1920, 128, 24, 2, 128, 24, 2}, | |
| 213 | + {12000000, 16000, 1, 8, 1920, 128, 16, 3, 128, 16, 3}, | |
| 214 | + {12500000, 16000, 1, 7, 8643, 128, 24, 2, 128, 24, 2}, | |
| 208 | 215 | /* 22.05k rate */ |
| 209 | − {12000000, 22050, 7, 5264, 128, 16, 2, 128, 16, 2}, | |
| 210 | − {12000000, 22050, 8, 4672, 128, 12, 3, 128, 12, 3}, | |
| 211 | − {12500000, 22050, 7, 2253, 128, 16, 2, 128, 16, 2}, | |
| 216 | + { 705600, 22050, 4, 36, 0, 128, 12, 3, 128, 12, 3}, | |
| 217 | + { 1411200, 22050, 2, 36, 0, 128, 12, 3, 128, 12, 3}, | |
| 218 | + {12000000, 22050, 1, 7, 5264, 128, 16, 2, 128, 16, 2}, | |
| 219 | + {12000000, 22050, 1, 8, 4672, 128, 12, 3, 128, 12, 3}, | |
| 220 | + {12500000, 22050, 1, 7, 2253, 128, 16, 2, 128, 16, 2}, | |
| 212 | 221 | /* 32k rate */ |
| 213 | − {12000000, 32000, 8, 1920, 128, 12, 2, 128, 12, 2}, | |
| 214 | − {12000000, 32000, 8, 1920, 128, 8, 3, 128, 8, 3}, | |
| 215 | − {12500000, 32000, 7, 8643, 128, 12, 2, 128, 12, 2}, | |
| 222 | + { 1024000, 32000, 2, 48, 0, 128, 12, 2, 128, 12, 2}, | |
| 223 | + { 2048000, 32000, 1, 48, 0, 128, 12, 2, 128, 12, 2}, | |
| 224 | + {12000000, 32000, 1, 8, 1920, 128, 12, 2, 128, 12, 2}, | |
| 225 | + {12000000, 32000, 1, 8, 1920, 128, 8, 3, 128, 8, 3}, | |
| 226 | + {12500000, 32000, 1, 7, 8643, 128, 12, 2, 128, 12, 2}, | |
| 216 | 227 | /* 44.1k rate */ |
| 217 | − {12000000, 44100, 7, 5264, 128, 8, 2, 128, 8, 2}, | |
| 218 | − {12000000, 44100, 8, 4672, 128, 6, 3, 128, 6, 3}, | |
| 219 | − {12500000, 44100, 7, 2253, 128, 8, 2, 128, 8, 2}, | |
| 228 | + { 1411200, 44100, 2, 32, 0, 128, 8, 2, 128, 8, 2}, | |
| 229 | + { 2822400, 44100, 1, 32, 0, 128, 8, 2, 128, 8, 2}, | |
| 230 | + {12000000, 44100, 1, 7, 5264, 128, 8, 2, 128, 8, 2}, | |
| 231 | + {12000000, 44100, 1, 8, 4672, 128, 6, 3, 128, 6, 3}, | |
| 232 | + {12500000, 44100, 1, 7, 2253, 128, 8, 2, 128, 8, 2}, | |
| 220 | 233 | /* 48k rate */ |
| 221 | − {12000000, 48000, 8, 1920, 128, 8, 2, 128, 8, 2}, | |
| 222 | − {12000000, 48000, 7, 6800, 96, 5, 4, 96, 5, 4}, | |
| 223 | − {12500000, 48000, 7, 8643, 128, 8, 2, 128, 8, 2}, | |
| 234 | + { 1536000, 48000, 2, 32, 0, 128, 8, 2, 128, 8, 2}, | |
| 235 | + { 3072000, 48000, 1, 32, 0, 128, 8, 2, 128, 8, 2}, | |
| 236 | + {12000000, 48000, 1, 8, 1920, 128, 8, 2, 128, 8, 2}, | |
| 237 | + {12000000, 48000, 1, 7, 6800, 96, 5, 4, 96, 5, 4}, | |
| 238 | + {12500000, 48000, 1, 7, 8643, 128, 8, 2, 128, 8, 2}, | |
| 224 | 239 | /* 88.2k rate */ |
| 225 | − {12000000, 88200, 7, 5264, 64, 8, 2, 64, 8, 2}, | |
| 226 | − {12000000, 88200, 8, 4672, 64, 6, 3, 64, 6, 3}, | |
| 227 | − {12500000, 88200, 7, 2253, 64, 8, 2, 64, 8, 2}, | |
| 240 | + { 2822400, 88200, 2, 16, 0, 64, 8, 2, 64, 8, 2}, | |
| 241 | + { 5644800, 88200, 1, 16, 0, 64, 8, 2, 64, 8, 2}, | |
| 242 | + {12000000, 88200, 1, 7, 5264, 64, 8, 2, 64, 8, 2}, | |
| 243 | + {12000000, 88200, 1, 8, 4672, 64, 6, 3, 64, 6, 3}, | |
| 244 | + {12500000, 88200, 1, 7, 2253, 64, 8, 2, 64, 8, 2}, | |
| 228 | 245 | /* 96k rate */ |
| 229 | − {12000000, 96000, 8, 1920, 64, 8, 2, 64, 8, 2}, | |
| 230 | − {12000000, 96000, 7, 6800, 48, 5, 4, 48, 5, 4}, | |
| 231 | − {12500000, 96000, 7, 8643, 64, 8, 2, 64, 8, 2}, | |
| 246 | + { 3072000, 96000, 2, 16, 0, 64, 8, 2, 64, 8, 2}, | |
| 247 | + { 6144000, 96000, 1, 16, 0, 64, 8, 2, 64, 8, 2}, | |
| 248 | + {12000000, 96000, 1, 8, 1920, 64, 8, 2, 64, 8, 2}, | |
| 249 | + {12000000, 96000, 1, 7, 6800, 48, 5, 4, 48, 5, 4}, | |
| 250 | + {12500000, 96000, 1, 7, 8643, 64, 8, 2, 64, 8, 2}, | |
| 232 | 251 | /* 176.4k rate */ |
| 233 | − {12000000, 176400, 7, 5264, 32, 8, 2, 32, 8, 2}, | |
| 234 | − {12000000, 176400, 8, 4672, 32, 6, 3, 32, 6, 3}, | |
| 235 | − {12500000, 176400, 7, 2253, 32, 8, 2, 32, 8, 2}, | |
| 252 | + { 5644800, 176400, 2, 8, 0, 32, 8, 2, 32, 8, 2}, | |
| 253 | + {11289600, 176400, 1, 8, 0, 32, 8, 2, 32, 8, 2}, | |
| 254 | + {12000000, 176400, 1, 7, 5264, 32, 8, 2, 32, 8, 2}, | |
| 255 | + {12000000, 176400, 1, 8, 4672, 32, 6, 3, 32, 6, 3}, | |
| 256 | + {12500000, 176400, 1, 7, 2253, 32, 8, 2, 32, 8, 2}, | |
| 236 | 257 | /* 192k rate */ |
| 237 | − {12000000, 192000, 8, 1920, 32, 8, 2, 32, 8, 2}, | |
| 238 | − {12000000, 192000, 7, 6800, 24, 5, 4, 24, 5, 4}, | |
| 239 | − {12500000, 192000, 7, 8643, 32, 8, 2, 32, 8, 2}, | |
| 258 | + { 6144000, 192000, 2, 8, 0, 32, 8, 2, 32, 8, 2}, | |
| 259 | + {12288000, 192000, 1, 8, 0, 32, 8, 2, 32, 8, 2}, | |
| 260 | + {12000000, 192000, 1, 8, 1920, 32, 8, 2, 32, 8, 2}, | |
| 261 | + {12000000, 192000, 1, 7, 6800, 24, 5, 4, 24, 5, 4}, | |
| 262 | + {12500000, 192000, 1, 7, 8643, 32, 8, 2, 32, 8, 2}, | |
| 240 | 263 | }; |
| 241 | 264 | |
| 242 | 265 | static const char * const ldac_in_text[] = { |
| @@ -888,7 +911,7 @@ static int aic31xx_setup_pll(struct snd_soc_component *component, · 645 unmodified lines | ||
| 888 | 911 | |
| 889 | 912 | /* PLL configuration */ |
| 890 | 913 | snd_soc_component_update_bits(component, AIC31XX_PLLPR, AIC31XX_PLL_MASK, |
| 891 | − (aic31xx->p_div << 4) | 0x01); | |
| 914 | + (aic31xx->p_div << 4) | aic31xx_divs[i].pll_r); | |
| 892 | 915 | snd_soc_component_write(component, AIC31XX_PLLJ, aic31xx_divs[i].pll_j); |
| 893 | 916 | |
| 894 | 917 | snd_soc_component_write(component, AIC31XX_PLLDMSB, |
| @@ -941,6 +964,7 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, · 46 unmodified lines | ||
| 941 | 964 | struct snd_soc_dai *dai) |
| 942 | 965 | { |
| 943 | 966 | struct snd_soc_component *component = dai->component; |
| 967 | + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); | |
| 944 | 968 | u8 data = 0; |
| 945 | 969 | |
| 946 | 970 | dev_dbg(component->dev, "## %s: width %d rate %d\n", |
| @@ -972,6 +996,16 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, · 25 unmodified lines | ||
| 972 | 996 | AIC31XX_IFACE1_DATALEN_MASK, |
| 973 | 997 | data); |
| 974 | 998 | |
| 999 | + /* | |
| 1000 | + * If BCLK is used as PLL input, the sysclk is determined by the hw | |
| 1001 | + * params. So it must be updated here to match the input frequency. | |
| 1002 | + */ | |
| 1003 | + if (aic31xx->sysclk_id == AIC31XX_PLL_CLKIN_BCLK) { | |
| 1004 | + aic31xx->sysclk = params_rate(params) * params_width(params) * | |
| 1005 | + params_channels(params); | |
| 1006 | + aic31xx->p_div = 1; | |
| 1007 | + } | |
| 1008 | + | |
| 975 | 1009 | return aic31xx_setup_pll(component, params); |
| 976 | 1010 | } |
| 977 | 1011 | |
| @@ -1156,6 +1190,7 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, · 178 unmodified lines | ||
| 1156 | 1190 | snd_soc_component_update_bits(component, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK, |
| 1157 | 1191 | clk_id << AIC31XX_PLL_CLKIN_SHIFT); |
| 1158 | 1192 | |
| 1193 | + aic31xx->sysclk_id = clk_id; | |
| 1159 | 1194 | aic31xx->sysclk = freq; |
| 1160 | 1195 | |
| 1161 | 1196 | return 0; |
| @@ -1645,11 +1680,9 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, · 483 unmodified lines | ||
| 1645 | 1680 | |
| 1646 | 1681 | aic31xx->gpio_reset = devm_gpiod_get_optional(aic31xx->dev, "reset", |
| 1647 | 1682 | GPIOD_OUT_LOW); |
| 1648 | − if (IS_ERR(aic31xx->gpio_reset)) { | |
| 1649 | − if (PTR_ERR(aic31xx->gpio_reset) != -EPROBE_DEFER) | |
| 1650 | − dev_err(aic31xx->dev, "not able to acquire gpio\n"); | |
| 1651 | − return PTR_ERR(aic31xx->gpio_reset); | |
| 1652 | − } | |
| 1683 | + if (IS_ERR(aic31xx->gpio_reset)) | |
| 1684 | + return dev_err_probe(aic31xx->dev, PTR_ERR(aic31xx->gpio_reset), | |
| 1685 | + "not able to acquire gpio\n"); | |
| 1653 | 1686 | |
| 1654 | 1687 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) |
| 1655 | 1688 | aic31xx->supplies[i].supply = aic31xx_supply_names[i]; |
| @@ -1657,12 +1690,8 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, · 1 unmodified line | ||
| 1657 | 1690 | ret = devm_regulator_bulk_get(aic31xx->dev, |
| 1658 | 1691 | ARRAY_SIZE(aic31xx->supplies), |
| 1659 | 1692 | aic31xx->supplies); |
| 1660 | − if (ret) { | |
| 1661 | − if (ret != -EPROBE_DEFER) | |
| 1662 | − dev_err(aic31xx->dev, | |
| 1663 | − "Failed to request supplies: %d\n", ret); | |
| 1664 | − return ret; | |
| 1665 | − } | |
| 1693 | + if (ret) | |
| 1694 | + return dev_err_probe(aic31xx->dev, ret, "Failed to request supplies\n"); | |
| 1666 | 1695 | |
| 1667 | 1696 | aic31xx_configure_ocmv(aic31xx); |
| 1668 | 1697 | |
| @@ -118,7 +118,7 @@ struct aic31xx_pdata { · 117 unmodified lines | ||
| 118 | 118 | #define AIC31XX_PLL_CLKIN_MASK GENMASK(3, 2) |
| 119 | 119 | #define AIC31XX_PLL_CLKIN_SHIFT (2) |
| 120 | 120 | #define AIC31XX_PLL_CLKIN_MCLK 0x00 |
| 121 | −#define AIC31XX_PLL_CLKIN_BCKL 0x01 | |
| 121 | +#define AIC31XX_PLL_CLKIN_BCLK 0x01 | |
| 122 | 122 | #define AIC31XX_PLL_CLKIN_GPIO1 0x02 |
| 123 | 123 | #define AIC31XX_PLL_CLKIN_DIN 0x03 |
| 124 | 124 | #define AIC31XX_CODEC_CLKIN_MASK GENMASK(1, 0) |
| @@ -1022,6 +1022,52 @@ static int wcd_mbhc_get_plug_from_adc(struct wcd_mbhc *mbhc, int adc_result) · 1021 unmodified lines | ||
| 1022 | 1022 | return plug_type; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | +static int wcd_mbhc_get_spl_hs_thres(struct wcd_mbhc *mbhc) | |
| 1026 | +{ | |
| 1027 | + int hs_threshold, micbias_mv; | |
| 1028 | + | |
| 1029 | + micbias_mv = wcd_mbhc_get_micbias(mbhc); | |
| 1030 | + if (mbhc->cfg->hs_thr && mbhc->cfg->micb_mv != WCD_MBHC_ADC_MICBIAS_MV) { | |
| 1031 | + if (mbhc->cfg->micb_mv == micbias_mv) | |
| 1032 | + hs_threshold = mbhc->cfg->hs_thr; | |
| 1033 | + else | |
| 1034 | + hs_threshold = (mbhc->cfg->hs_thr * micbias_mv) / mbhc->cfg->micb_mv; | |
| 1035 | + } else { | |
| 1036 | + hs_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV * micbias_mv) / | |
| 1037 | + WCD_MBHC_ADC_MICBIAS_MV); | |
| 1038 | + } | |
| 1039 | + return hs_threshold; | |
| 1040 | +} | |
| 1041 | + | |
| 1042 | +static bool wcd_mbhc_check_for_spl_headset(struct wcd_mbhc *mbhc) | |
| 1043 | +{ | |
| 1044 | + bool is_spl_hs = false; | |
| 1045 | + int output_mv, hs_threshold, hph_threshold; | |
| 1046 | + | |
| 1047 | + if (!mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) | |
| 1048 | + return false; | |
| 1049 | + | |
| 1050 | + /* Bump up MIC_BIAS2 to 2.7V */ | |
| 1051 | + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, MIC_BIAS_2, true); | |
| 1052 | + usleep_range(10000, 10100); | |
| 1053 | + | |
| 1054 | + output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P); | |
| 1055 | + hs_threshold = wcd_mbhc_get_spl_hs_thres(mbhc); | |
| 1056 | + hph_threshold = wcd_mbhc_adc_get_hph_thres(mbhc); | |
| 1057 | + | |
| 1058 | + if (!(output_mv > hs_threshold || output_mv < hph_threshold)) | |
| 1059 | + is_spl_hs = true; | |
| 1060 | + | |
| 1061 | + /* Back MIC_BIAS2 to 1.8v if the type is not special headset */ | |
| 1062 | + if (!is_spl_hs) { | |
| 1063 | + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, MIC_BIAS_2, false); | |
| 1064 | + /* Add 10ms delay for micbias to settle */ | |
| 1065 | + usleep_range(10000, 10100); | |
| 1066 | + } | |
| 1067 | + | |
| 1068 | + return is_spl_hs; | |
| 1069 | +} | |
| 1070 | + | |
| 1025 | 1071 | static void wcd_correct_swch_plug(struct work_struct *work) |
| 1026 | 1072 | { |
| 1027 | 1073 | struct wcd_mbhc *mbhc; |
| @@ -1029,12 +1075,14 @@ static void wcd_correct_swch_plug(struct work_struct *work) · 1 unmodified line | ||
| 1029 | 1075 | enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID; |
| 1030 | 1076 | unsigned long timeout; |
| 1031 | 1077 | int pt_gnd_mic_swap_cnt = 0; |
| 1032 | − int output_mv, cross_conn, hs_threshold, try = 0; | |
| 1078 | + int output_mv, cross_conn, hs_threshold, try = 0, micbias_mv; | |
| 1079 | + bool is_spl_hs = false; | |
| 1033 | 1080 | bool is_pa_on; |
| 1034 | 1081 | |
| 1035 | 1082 | mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch); |
| 1036 | 1083 | component = mbhc->component; |
| 1037 | 1084 | |
| 1085 | + micbias_mv = wcd_mbhc_get_micbias(mbhc); | |
| 1038 | 1086 | hs_threshold = wcd_mbhc_adc_get_hs_thres(mbhc); |
| 1039 | 1087 | |
| 1040 | 1088 | /* Mask ADC COMPLETE interrupt */ |
| @@ -1097,6 +1145,16 @@ correct_plug_type: · 56 unmodified lines | ||
| 1097 | 1145 | plug_type = wcd_mbhc_get_plug_from_adc(mbhc, output_mv); |
| 1098 | 1146 | is_pa_on = wcd_mbhc_read_field(mbhc, WCD_MBHC_HPH_PA_EN); |
| 1099 | 1147 | |
| 1148 | + if (output_mv > hs_threshold && !is_spl_hs) { | |
| 1149 | + is_spl_hs = wcd_mbhc_check_for_spl_headset(mbhc); | |
| 1150 | + output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P); | |
| 1151 | + | |
| 1152 | + if (is_spl_hs) { | |
| 1153 | + hs_threshold *= wcd_mbhc_get_micbias(mbhc); | |
| 1154 | + hs_threshold /= micbias_mv; | |
| 1155 | + } | |
| 1156 | + } | |
| 1157 | + | |
| 1100 | 1158 | if ((output_mv <= hs_threshold) && !is_pa_on) { |
| 1101 | 1159 | /* Check for cross connection*/ |
| 1102 | 1160 | cross_conn = wcd_check_cross_conn(mbhc); |
| @@ -1122,14 +1180,19 @@ correct_plug_type: · 19 unmodified lines | ||
| 1122 | 1180 | } |
| 1123 | 1181 | } |
| 1124 | 1182 | |
| 1125 | − if (output_mv > hs_threshold) /* cable is extension cable */ | |
| 1183 | + /* cable is extension cable */ | |
| 1184 | + if (output_mv > hs_threshold || mbhc->force_linein) | |
| 1126 | 1185 | plug_type = MBHC_PLUG_TYPE_HIGH_HPH; |
| 1127 | 1186 | } |
| 1128 | 1187 | |
| 1129 | 1188 | wcd_mbhc_bcs_enable(mbhc, plug_type, true); |
| 1130 | 1189 | |
| 1131 | − if (plug_type == MBHC_PLUG_TYPE_HIGH_HPH) | |
| 1132 | − wcd_mbhc_write_field(mbhc, WCD_MBHC_ELECT_ISRC_EN, 1); | |
| 1190 | + if (plug_type == MBHC_PLUG_TYPE_HIGH_HPH) { | |
| 1191 | + if (is_spl_hs) | |
| 1192 | + plug_type = MBHC_PLUG_TYPE_HEADSET; | |
| 1193 | + else | |
| 1194 | + wcd_mbhc_write_field(mbhc, WCD_MBHC_ELECT_ISRC_EN, 1); | |
| 1195 | + } | |
| 1133 | 1196 | |
| 1134 | 1197 | wcd_mbhc_write_field(mbhc, WCD_MBHC_ADC_MODE, 0); |
| 1135 | 1198 | wcd_mbhc_write_field(mbhc, WCD_MBHC_ADC_EN, 0); |
| @@ -1176,7 +1239,6 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data) · 40 unmodified lines | ||
| 1176 | 1239 | struct wcd_mbhc *mbhc = data; |
| 1177 | 1240 | unsigned long timeout; |
| 1178 | 1241 | int adc_threshold, output_mv, retry = 0; |
| 1179 | − bool hphpa_on = false; | |
| 1180 | 1242 | |
| 1181 | 1243 | mutex_lock(&mbhc->lock); |
| 1182 | 1244 | timeout = jiffies + msecs_to_jiffies(WCD_FAKE_REMOVAL_MIN_PERIOD_MS); |
| @@ -1210,10 +1272,6 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data) · 27 unmodified lines | ||
| 1210 | 1272 | wcd_mbhc_elec_hs_report_unplug(mbhc); |
| 1211 | 1273 | wcd_mbhc_write_field(mbhc, WCD_MBHC_BTN_ISRC_CTL, 0); |
| 1212 | 1274 | |
| 1213 | − if (hphpa_on) { | |
| 1214 | − hphpa_on = false; | |
| 1215 | − wcd_mbhc_write_field(mbhc, WCD_MBHC_HPH_PA_EN, 3); | |
| 1216 | − } | |
| 1217 | 1275 | exit: |
| 1218 | 1276 | mutex_unlock(&mbhc->lock); |
| 1219 | 1277 | return IRQ_HANDLED; |
| @@ -341,7 +341,7 @@ struct wcd9335_codec { · 340 unmodified lines | ||
| 341 | 341 | int reset_gpio; |
| 342 | 342 | struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY]; |
| 343 | 343 | |
| 344 | − unsigned int rx_port_value; | |
| 344 | + unsigned int rx_port_value[WCD9335_RX_MAX]; | |
| 345 | 345 | unsigned int tx_port_value; |
| 346 | 346 | int hph_l_gain; |
| 347 | 347 | int hph_r_gain; |
| @@ -1269,10 +1269,11 @@ static const struct snd_kcontrol_new sb_tx8_mux = · 921 unmodified lines | ||
| 1269 | 1269 | static int slim_rx_mux_get(struct snd_kcontrol *kc, |
| 1270 | 1270 | struct snd_ctl_elem_value *ucontrol) |
| 1271 | 1271 | { |
| 1272 | − struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); | |
| 1273 | − struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); | |
| 1272 | + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc); | |
| 1273 | + struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); | |
| 1274 | + u32 port_id = w->shift; | |
| 1274 | 1275 | |
| 1275 | − ucontrol->value.enumerated.item[0] = wcd->rx_port_value; | |
| 1276 | + ucontrol->value.enumerated.item[0] = wcd->rx_port_value[port_id]; | |
| 1276 | 1277 | |
| 1277 | 1278 | return 0; |
| 1278 | 1279 | } |
| @@ -1286,9 +1287,9 @@ static int slim_rx_mux_put(struct snd_kcontrol *kc, · 7 unmodified lines | ||
| 1286 | 1287 | struct snd_soc_dapm_update *update = NULL; |
| 1287 | 1288 | u32 port_id = w->shift; |
| 1288 | 1289 | |
| 1289 | − wcd->rx_port_value = ucontrol->value.enumerated.item[0]; | |
| 1290 | + wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0]; | |
| 1290 | 1291 | |
| 1291 | − switch (wcd->rx_port_value) { | |
| 1292 | + switch (wcd->rx_port_value[port_id]) { | |
| 1292 | 1293 | case 0: |
| 1293 | 1294 | list_del_init(&wcd->rx_chs[port_id].list); |
| 1294 | 1295 | break; |
| @@ -1309,11 +1310,11 @@ static int slim_rx_mux_put(struct snd_kcontrol *kc, · 14 unmodified lines | ||
| 1309 | 1310 | &wcd->dai[AIF4_PB].slim_ch_list); |
| 1310 | 1311 | break; |
| 1311 | 1312 | default: |
| 1312 | − dev_err(wcd->dev, "Unknown AIF %d\n", wcd->rx_port_value); | |
| 1313 | + dev_err(wcd->dev, "Unknown AIF %d\n", wcd->rx_port_value[port_id]); | |
| 1313 | 1314 | goto err; |
| 1314 | 1315 | } |
| 1315 | 1316 | |
| 1316 | − snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value, | |
| 1317 | + snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id], | |
| 1317 | 1318 | e, update); |
| 1318 | 1319 | |
| 1319 | 1320 | return 0; |
| @@ -3423,7 +3423,7 @@ static int wcd934x_int_dem_inp_mux_put(struct snd_kcontrol *kc, · 3422 unmodified lines | ||
| 3423 | 3423 | { |
| 3424 | 3424 | struct soc_enum *e = (struct soc_enum *)kc->private_value; |
| 3425 | 3425 | struct snd_soc_component *component; |
| 3426 | − int reg, val, ret; | |
| 3426 | + int reg, val; | |
| 3427 | 3427 | |
| 3428 | 3428 | component = snd_soc_dapm_kcontrol_component(kc); |
| 3429 | 3429 | val = ucontrol->value.enumerated.item[0]; |
| @@ -3446,9 +3446,7 @@ static int wcd934x_int_dem_inp_mux_put(struct snd_kcontrol *kc, · 16 unmodified lines | ||
| 3446 | 3446 | WCD934X_RX_DLY_ZN_EN_MASK, |
| 3447 | 3447 | WCD934X_RX_DLY_ZN_DISABLE); |
| 3448 | 3448 | |
| 3449 | − ret = snd_soc_dapm_put_enum_double(kc, ucontrol); | |
| 3450 | − | |
| 3451 | − return ret; | |
| 3449 | + return snd_soc_dapm_put_enum_double(kc, ucontrol); | |
| 3452 | 3450 | } |
| 3453 | 3451 | |
| 3454 | 3452 | static int wcd934x_dec_enum_put(struct snd_kcontrol *kcontrol, |
| @@ -3086,7 +3086,7 @@ static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *compon · 3085 unmodified lines | ||
| 3086 | 3086 | int micb_num, bool req_en) |
| 3087 | 3087 | { |
| 3088 | 3088 | struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); |
| 3089 | − int rc, micb_mv; | |
| 3089 | + int micb_mv; | |
| 3090 | 3090 | |
| 3091 | 3091 | if (micb_num != MIC_BIAS_2) |
| 3092 | 3092 | return -EINVAL; |
| @@ -3100,9 +3100,7 @@ static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *compon · 7 unmodified lines | ||
| 3100 | 3100 | |
| 3101 | 3101 | micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : wcd938x->micb2_mv; |
| 3102 | 3102 | |
| 3103 | − rc = wcd938x_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2); | |
| 3104 | − | |
| 3105 | − return rc; | |
| 3103 | + return wcd938x_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2); | |
| 3106 | 3104 | } |
| 3107 | 3105 | |
| 3108 | 3106 | static inline void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x, |
| @@ -4287,7 +4285,7 @@ static int wcd938x_codec_set_sdw_stream(struct snd_soc_dai *dai, · 1178 unmodified lines | ||
| 4287 | 4285 | static const struct snd_soc_dai_ops wcd938x_sdw_dai_ops = { |
| 4288 | 4286 | .hw_params = wcd938x_codec_hw_params, |
| 4289 | 4287 | .hw_free = wcd938x_codec_free, |
| 4290 | − .set_sdw_stream = wcd938x_codec_set_sdw_stream, | |
| 4288 | + .set_stream = wcd938x_codec_set_sdw_stream, | |
| 4291 | 4289 | }; |
| 4292 | 4290 | |
| 4293 | 4291 | static struct snd_soc_dai_driver wcd938x_dais[] = { |
| @@ -401,7 +401,7 @@ static int wm_coeff_put(struct snd_kcontrol *kctl, · 400 unmodified lines | ||
| 401 | 401 | int ret = 0; |
| 402 | 402 | |
| 403 | 403 | mutex_lock(&cs_ctl->dsp->pwr_lock); |
| 404 | − ret = cs_dsp_coeff_write_ctrl(cs_ctl, p, cs_ctl->len); | |
| 404 | + ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, p, cs_ctl->len); | |
| 405 | 405 | mutex_unlock(&cs_ctl->dsp->pwr_lock); |
| 406 | 406 | |
| 407 | 407 | return ret; |
| @@ -421,7 +421,7 @@ static int wm_coeff_tlv_put(struct snd_kcontrol *kctl, · 13 unmodified lines | ||
| 421 | 421 | if (copy_from_user(cs_ctl->cache, bytes, size)) |
| 422 | 422 | ret = -EFAULT; |
| 423 | 423 | else |
| 424 | − ret = cs_dsp_coeff_write_ctrl(cs_ctl, cs_ctl->cache, size); | |
| 424 | + ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, cs_ctl->cache, size); | |
| 425 | 425 | |
| 426 | 426 | mutex_unlock(&cs_ctl->dsp->pwr_lock); |
| 427 | 427 | |
| @@ -464,7 +464,7 @@ static int wm_coeff_get(struct snd_kcontrol *kctl, · 36 unmodified lines | ||
| 464 | 464 | int ret; |
| 465 | 465 | |
| 466 | 466 | mutex_lock(&cs_ctl->dsp->pwr_lock); |
| 467 | − ret = cs_dsp_coeff_read_ctrl(cs_ctl, p, cs_ctl->len); | |
| 467 | + ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, p, cs_ctl->len); | |
| 468 | 468 | mutex_unlock(&cs_ctl->dsp->pwr_lock); |
| 469 | 469 | |
| 470 | 470 | return ret; |
| @@ -481,7 +481,7 @@ static int wm_coeff_tlv_get(struct snd_kcontrol *kctl, · 10 unmodified lines | ||
| 481 | 481 | |
| 482 | 482 | mutex_lock(&cs_ctl->dsp->pwr_lock); |
| 483 | 483 | |
| 484 | − ret = cs_dsp_coeff_read_ctrl(cs_ctl, cs_ctl->cache, size); | |
| 484 | + ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, cs_ctl->cache, size); | |
| 485 | 485 | |
| 486 | 486 | if (!ret && copy_to_user(bytes, cs_ctl->cache, size)) |
| 487 | 487 | ret = -EFAULT; |
| @@ -537,15 +537,20 @@ static unsigned int wmfw_convert_flags(unsigned int in, unsigned int len) · 49 unmodified lines | ||
| 537 | 537 | return out; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | −static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) | |
| 540 | +static void wm_adsp_ctl_work(struct work_struct *work) | |
| 541 | 541 | { |
| 542 | + struct wm_coeff_ctl *ctl = container_of(work, | |
| 543 | + struct wm_coeff_ctl, | |
| 544 | + work); | |
| 542 | 545 | struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; |
| 546 | + struct wm_adsp *dsp = container_of(cs_ctl->dsp, | |
| 547 | + struct wm_adsp, | |
| 548 | + cs_dsp); | |
| 543 | 549 | struct snd_kcontrol_new *kcontrol; |
| 544 | − int ret; | |
| 545 | 550 | |
| 546 | 551 | kcontrol = kzalloc(sizeof(*kcontrol), GFP_KERNEL); |
| 547 | 552 | if (!kcontrol) |
| 548 | − return -ENOMEM; | |
| 553 | + return; | |
| 549 | 554 | |
| 550 | 555 | kcontrol->name = ctl->name; |
| 551 | 556 | kcontrol->info = wm_coeff_info; |
| @@ -571,29 +576,9 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) · 19 unmodified lines | ||
| 571 | 576 | break; |
| 572 | 577 | } |
| 573 | 578 | |
| 574 | − ret = snd_soc_add_component_controls(dsp->component, kcontrol, 1); | |
| 575 | − if (ret < 0) | |
| 576 | − goto err_kcontrol; | |
| 577 | − | |
| 578 | − kfree(kcontrol); | |
| 579 | − | |
| 580 | − return 0; | |
| 579 | + snd_soc_add_component_controls(dsp->component, kcontrol, 1); | |
| 581 | 580 | |
| 582 | −err_kcontrol: | |
| 583 | 581 | kfree(kcontrol); |
| 584 | − return ret; | |
| 585 | −} | |
| 586 | − | |
| 587 | −static void wm_adsp_ctl_work(struct work_struct *work) | |
| 588 | −{ | |
| 589 | − struct wm_coeff_ctl *ctl = container_of(work, | |
| 590 | − struct wm_coeff_ctl, | |
| 591 | − work); | |
| 592 | − struct wm_adsp *dsp = container_of(ctl->cs_ctl->dsp, | |
| 593 | − struct wm_adsp, | |
| 594 | − cs_dsp); | |
| 595 | − | |
| 596 | − wmfw_add_ctl(dsp, ctl); | |
| 597 | 582 | } |
| 598 | 583 | |
| 599 | 584 | static int wm_adsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl) |
| @@ -700,7 +685,7 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, · 100 unmodified lines | ||
| 700 | 685 | if (len > cs_ctl->len) |
| 701 | 686 | return -EINVAL; |
| 702 | 687 | |
| 703 | − ret = cs_dsp_coeff_write_ctrl(cs_ctl, buf, len); | |
| 688 | + ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len); | |
| 704 | 689 | if (ret) |
| 705 | 690 | return ret; |
| 706 | 691 | |
| @@ -739,7 +724,7 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type, · 32 unmodified lines | ||
| 739 | 724 | if (len > cs_ctl->len) |
| 740 | 725 | return -EINVAL; |
| 741 | 726 | |
| 742 | − return cs_dsp_coeff_read_ctrl(cs_ctl, buf, len); | |
| 727 | + return cs_dsp_coeff_read_ctrl(cs_ctl, 0, buf, len); | |
| 743 | 728 | } |
| 744 | 729 | EXPORT_SYMBOL_GPL(wm_adsp_read_ctl); |
| 745 | 730 | |
| @@ -911,11 +896,12 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, · 165 unmodified lines | ||
| 911 | 896 | struct wm_adsp *dsp = &dsps[mc->shift - 1]; |
| 912 | 897 | char preload[32]; |
| 913 | 898 | |
| 914 | − snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name); | |
| 899 | + if (dsp->preloaded == ucontrol->value.integer.value[0]) | |
| 900 | + return 0; | |
| 915 | 901 | |
| 916 | − dsp->preloaded = ucontrol->value.integer.value[0]; | |
| 902 | + snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name); | |
| 917 | 903 | |
| 918 | − if (ucontrol->value.integer.value[0]) | |
| 904 | + if (ucontrol->value.integer.value[0] || dsp->toggle_preload) | |
| 919 | 905 | snd_soc_component_force_enable_pin(component, preload); |
| 920 | 906 | else |
| 921 | 907 | snd_soc_component_disable_pin(component, preload); |
| @@ -924,6 +910,13 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, · 2 unmodified lines | ||
| 924 | 910 | |
| 925 | 911 | flush_work(&dsp->boot_work); |
| 926 | 912 | |
| 913 | + dsp->preloaded = ucontrol->value.integer.value[0]; | |
| 914 | + | |
| 915 | + if (dsp->toggle_preload) { | |
| 916 | + snd_soc_component_disable_pin(component, preload); | |
| 917 | + snd_soc_dapm_sync(dapm); | |
| 918 | + } | |
| 919 | + | |
| 927 | 920 | return 0; |
| 928 | 921 | } |
| 929 | 922 | EXPORT_SYMBOL_GPL(wm_adsp2_preloader_put); |
| @@ -1448,7 +1441,7 @@ static int wm_adsp_buffer_parse_coeff(struct cs_dsp_coeff_ctl *cs_ctl) · 518 unmodified lines | ||
| 1448 | 1441 | int ret, i; |
| 1449 | 1442 | |
| 1450 | 1443 | for (i = 0; i < 5; ++i) { |
| 1451 | − ret = cs_dsp_coeff_read_ctrl(cs_ctl, &coeff_v1, sizeof(coeff_v1)); | |
| 1444 | + ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, &coeff_v1, sizeof(coeff_v1)); | |
| 1452 | 1445 | if (ret < 0) |
| 1453 | 1446 | return ret; |
| 1454 | 1447 | |
| @@ -41,6 +41,14 @@ struct wm_adsp { · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | struct list_head compr_list; |
| 43 | 43 | struct list_head buffer_list; |
| 44 | + | |
| 45 | + /* | |
| 46 | + * Flag indicating the preloader widget only needs power toggled | |
| 47 | + * on state change rather than held on for the duration of the | |
| 48 | + * preload, useful for devices that can retain firmware memory | |
| 49 | + * across power down. | |
| 50 | + */ | |
| 51 | + bool toggle_preload; | |
| 44 | 52 | }; |
| 45 | 53 | |
| 46 | 54 | #define WM_ADSP1(wname, num) \ |
| @@ -1026,7 +1026,7 @@ static const struct snd_soc_dai_ops wsa881x_dai_ops = { · 1025 unmodified lines | ||
| 1026 | 1026 | .hw_params = wsa881x_hw_params, |
| 1027 | 1027 | .hw_free = wsa881x_hw_free, |
| 1028 | 1028 | .mute_stream = wsa881x_digital_mute, |
| 1029 | − .set_sdw_stream = wsa881x_set_sdw_stream, | |
| 1029 | + .set_stream = wsa881x_set_sdw_stream, | |
| 1030 | 1030 | }; |
| 1031 | 1031 | |
| 1032 | 1032 | static struct snd_soc_dai_driver wsa881x_dais[] = { |
| @@ -589,9 +589,7 @@ static int zl38_spi_probe(struct spi_device *spi) · 588 unmodified lines | ||
| 589 | 589 | sizeof(template_chip), GFP_KERNEL); |
| 590 | 590 | if (!priv->gpio_chip) |
| 591 | 591 | return -ENOMEM; |
| 592 | −#ifdef CONFIG_OF_GPIO | |
| 593 | − priv->gpio_chip->of_node = dev->of_node; | |
| 594 | −#endif | |
| 592 | + priv->gpio_chip->parent = dev; | |
| 595 | 593 | err = devm_gpiochip_add_data(dev, priv->gpio_chip, priv->regmap); |
| 596 | 594 | if (err) |
| 597 | 595 | return err; |
| @@ -311,6 +311,7 @@ config SND_SOC_FSL_ASOC_CARD · 310 unmodified lines | ||
| 311 | 311 | select SND_SOC_FSL_ESAI |
| 312 | 312 | select SND_SOC_FSL_SAI |
| 313 | 313 | select SND_SOC_FSL_SSI |
| 314 | + select SND_SOC_TLV320AIC31XX | |
| 314 | 315 | select SND_SOC_WM8994 |
| 315 | 316 | select MFD_WM8994 |
| 316 | 317 | help |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "../codecs/wm8962.h" |
| 27 | 27 | #include "../codecs/wm8960.h" |
| 28 | 28 | #include "../codecs/wm8994.h" |
| 29 | +#include "../codecs/tlv320aic31xx.h" | |
| 29 | 30 | |
| 30 | 31 | #define CS427x_SYSCLK_MCLK 0 |
| 31 | 32 | |
| @@ -629,6 +630,16 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) · 597 unmodified lines | ||
| 629 | 630 | } else if (of_device_is_compatible(np, "fsl,imx-audio-tlv320aic32x4")) { |
| 630 | 631 | codec_dai_name = "tlv320aic32x4-hifi"; |
| 631 | 632 | priv->dai_fmt |= SND_SOC_DAIFMT_CBP_CFP; |
| 633 | + } else if (of_device_is_compatible(np, "fsl,imx-audio-tlv320aic31xx")) { | |
| 634 | + codec_dai_name = "tlv320dac31xx-hifi"; | |
| 635 | + priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; | |
| 636 | + priv->dai_link[1].dpcm_capture = 0; | |
| 637 | + priv->dai_link[2].dpcm_capture = 0; | |
| 638 | + priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT; | |
| 639 | + priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_OUT; | |
| 640 | + priv->codec_priv.mclk_id = AIC31XX_PLL_CLKIN_BCLK; | |
| 641 | + priv->card.dapm_routes = audio_map_tx; | |
| 642 | + priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx); | |
| 632 | 643 | } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8962")) { |
| 633 | 644 | codec_dai_name = "wm8962"; |
| 634 | 645 | priv->codec_priv.mclk_id = WM8962_SYSCLK_MCLK; |
| @@ -842,8 +853,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) · 207 unmodified lines | ||
| 842 | 853 | |
| 843 | 854 | ret = devm_snd_soc_register_card(&pdev->dev, &priv->card); |
| 844 | 855 | if (ret) { |
| 845 | − if (ret != -EPROBE_DEFER) | |
| 846 | − dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | |
| 856 | + dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n"); | |
| 847 | 857 | goto asrc_fail; |
| 848 | 858 | } |
| 849 | 859 | |
| @@ -888,6 +898,7 @@ static const struct of_device_id fsl_asoc_card_dt_ids[] = { · 38 unmodified lines | ||
| 888 | 898 | { .compatible = "fsl,imx-audio-cs42888", }, |
| 889 | 899 | { .compatible = "fsl,imx-audio-cs427x", }, |
| 890 | 900 | { .compatible = "fsl,imx-audio-tlv320aic32x4", }, |
| 901 | + { .compatible = "fsl,imx-audio-tlv320aic31xx", }, | |
| 891 | 902 | { .compatible = "fsl,imx-audio-sgtl5000", }, |
| 892 | 903 | { .compatible = "fsl,imx-audio-wm8962", }, |
| 893 | 904 | { .compatible = "fsl,imx-audio-wm8960", }, |
| @@ -19,6 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | #include "fsl_asrc.h" |
| 20 | 20 | |
| 21 | 21 | #define IDEAL_RATIO_DECIMAL_DEPTH 26 |
| 22 | +#define DIVIDER_NUM 64 | |
| 22 | 23 | |
| 23 | 24 | #define pair_err(fmt, ...) \ |
| 24 | 25 | dev_err(&asrc->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__) |
| @@ -101,6 +102,55 @@ static unsigned char clk_map_imx8qxp[2][ASRC_CLK_MAP_LEN] = { · 76 unmodified lines | ||
| 101 | 102 | }, |
| 102 | 103 | }; |
| 103 | 104 | |
| 105 | +/* | |
| 106 | + * According to RM, the divider range is 1 ~ 8, | |
| 107 | + * prescaler is power of 2 from 1 ~ 128. | |
| 108 | + */ | |
| 109 | +static int asrc_clk_divider[DIVIDER_NUM] = { | |
| 110 | + 1, 2, 4, 8, 16, 32, 64, 128, /* divider = 1 */ | |
| 111 | + 2, 4, 8, 16, 32, 64, 128, 256, /* divider = 2 */ | |
| 112 | + 3, 6, 12, 24, 48, 96, 192, 384, /* divider = 3 */ | |
| 113 | + 4, 8, 16, 32, 64, 128, 256, 512, /* divider = 4 */ | |
| 114 | + 5, 10, 20, 40, 80, 160, 320, 640, /* divider = 5 */ | |
| 115 | + 6, 12, 24, 48, 96, 192, 384, 768, /* divider = 6 */ | |
| 116 | + 7, 14, 28, 56, 112, 224, 448, 896, /* divider = 7 */ | |
| 117 | + 8, 16, 32, 64, 128, 256, 512, 1024, /* divider = 8 */ | |
| 118 | +}; | |
| 119 | + | |
| 120 | +/* | |
| 121 | + * Check if the divider is available for internal ratio mode | |
| 122 | + */ | |
| 123 | +static bool fsl_asrc_divider_avail(int clk_rate, int rate, int *div) | |
| 124 | +{ | |
| 125 | + u32 rem, i; | |
| 126 | + u64 n; | |
| 127 | + | |
| 128 | + if (div) | |
| 129 | + *div = 0; | |
| 130 | + | |
| 131 | + if (clk_rate == 0 || rate == 0) | |
| 132 | + return false; | |
| 133 | + | |
| 134 | + n = clk_rate; | |
| 135 | + rem = do_div(n, rate); | |
| 136 | + | |
| 137 | + if (div) | |
| 138 | + *div = n; | |
| 139 | + | |
| 140 | + if (rem != 0) | |
| 141 | + return false; | |
| 142 | + | |
| 143 | + for (i = 0; i < DIVIDER_NUM; i++) { | |
| 144 | + if (n == asrc_clk_divider[i]) | |
| 145 | + break; | |
| 146 | + } | |
| 147 | + | |
| 148 | + if (i == DIVIDER_NUM) | |
| 149 | + return false; | |
| 150 | + | |
| 151 | + return true; | |
| 152 | +} | |
| 153 | + | |
| 104 | 154 | /** |
| 105 | 155 | * fsl_asrc_sel_proc - Select the pre-processing and post-processing options |
| 106 | 156 | * @inrate: input sample rate |
| @@ -330,12 +380,12 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate) · 223 unmodified lines | ||
| 330 | 380 | enum asrc_word_width input_word_width; |
| 331 | 381 | enum asrc_word_width output_word_width; |
| 332 | 382 | u32 inrate, outrate, indiv, outdiv; |
| 333 | − u32 clk_index[2], div[2], rem[2]; | |
| 383 | + u32 clk_index[2], div[2]; | |
| 334 | 384 | u64 clk_rate; |
| 335 | 385 | int in, out, channels; |
| 336 | 386 | int pre_proc, post_proc; |
| 337 | 387 | struct clk *clk; |
| 338 | − bool ideal; | |
| 388 | + bool ideal, div_avail; | |
| 339 | 389 | |
| 340 | 390 | if (!config) { |
| 341 | 391 | pair_err("invalid pair config\n"); |
| @@ -415,8 +465,7 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate) · 73 unmodified lines | ||
| 415 | 465 | clk = asrc_priv->asrck_clk[clk_index[ideal ? OUT : IN]]; |
| 416 | 466 | |
| 417 | 467 | clk_rate = clk_get_rate(clk); |
| 418 | − rem[IN] = do_div(clk_rate, inrate); | |
| 419 | − div[IN] = (u32)clk_rate; | |
| 468 | + div_avail = fsl_asrc_divider_avail(clk_rate, inrate, &div[IN]); | |
| 420 | 469 | |
| 421 | 470 | /* |
| 422 | 471 | * The divider range is [1, 1024], defined by the hardware. For non- |
| @@ -425,7 +474,7 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate) · 2 unmodified lines | ||
| 425 | 474 | * only result in different converting speeds. So remainder does not |
| 426 | 475 | * matter, as long as we keep the divider within its valid range. |
| 427 | 476 | */ |
| 428 | − if (div[IN] == 0 || (!ideal && (div[IN] > 1024 || rem[IN] != 0))) { | |
| 477 | + if (div[IN] == 0 || (!ideal && !div_avail)) { | |
| 429 | 478 | pair_err("failed to support input sample rate %dHz by asrck_%x\n", |
| 430 | 479 | inrate, clk_index[ideal ? OUT : IN]); |
| 431 | 480 | return -EINVAL; |
| @@ -436,13 +485,12 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate) · 4 unmodified lines | ||
| 436 | 485 | clk = asrc_priv->asrck_clk[clk_index[OUT]]; |
| 437 | 486 | clk_rate = clk_get_rate(clk); |
| 438 | 487 | if (ideal && use_ideal_rate) |
| 439 | − rem[OUT] = do_div(clk_rate, IDEAL_RATIO_RATE); | |
| 488 | + div_avail = fsl_asrc_divider_avail(clk_rate, IDEAL_RATIO_RATE, &div[OUT]); | |
| 440 | 489 | else |
| 441 | − rem[OUT] = do_div(clk_rate, outrate); | |
| 442 | − div[OUT] = clk_rate; | |
| 490 | + div_avail = fsl_asrc_divider_avail(clk_rate, outrate, &div[OUT]); | |
| 443 | 491 | |
| 444 | 492 | /* Output divider has the same limitation as the input one */ |
| 445 | − if (div[OUT] == 0 || (!ideal && (div[OUT] > 1024 || rem[OUT] != 0))) { | |
| 493 | + if (div[OUT] == 0 || (!ideal && !div_avail)) { | |
| 446 | 494 | pair_err("failed to support output sample rate %dHz by asrck_%x\n", |
| 447 | 495 | outrate, clk_index[OUT]); |
| 448 | 496 | return -EINVAL; |
| @@ -621,8 +669,7 @@ static void fsl_asrc_select_clk(struct fsl_asrc_priv *asrc_priv, · 172 unmodified lines | ||
| 621 | 669 | clk_index = asrc_priv->clk_map[j][i]; |
| 622 | 670 | clk_rate = clk_get_rate(asrc_priv->asrck_clk[clk_index]); |
| 623 | 671 | /* Only match a perfect clock source with no remainder */ |
| 624 | − if (clk_rate != 0 && (clk_rate / rate[j]) <= 1024 && | |
| 625 | − (clk_rate % rate[j]) == 0) | |
| 672 | + if (fsl_asrc_divider_avail(clk_rate, rate[j], NULL)) | |
| 626 | 673 | break; |
| 627 | 674 | } |
| 628 | 675 | |
| @@ -337,4 +337,4 @@ module_platform_driver(fsl_mqs_driver); · 336 unmodified lines | ||
| 337 | 337 | MODULE_AUTHOR("Shengjiu Wang <Shengjiu.Wang@nxp.com>"); |
| 338 | 338 | MODULE_DESCRIPTION("MQS codec driver"); |
| 339 | 339 | MODULE_LICENSE("GPL v2"); |
| 340 | −MODULE_ALIAS("platform: fsl-mqs"); | |
| 340 | +MODULE_ALIAS("platform:fsl-mqs"); | |
| @@ -120,7 +120,7 @@ struct imx_card_data { · 119 unmodified lines | ||
| 120 | 120 | |
| 121 | 121 | static struct imx_akcodec_fs_mul ak4458_fs_mul[] = { |
| 122 | 122 | /* Normal, < 32kHz */ |
| 123 | − { .rmin = 8000, .rmax = 24000, .wmin = 1024, .wmax = 1024, }, | |
| 123 | + { .rmin = 8000, .rmax = 24000, .wmin = 256, .wmax = 1024, }, | |
| 124 | 124 | /* Normal, 32kHz */ |
| 125 | 125 | { .rmin = 32000, .rmax = 32000, .wmin = 256, .wmax = 1024, }, |
| 126 | 126 | /* Normal */ |
| @@ -151,8 +151,8 @@ static struct imx_akcodec_fs_mul ak4497_fs_mul[] = { · 24 unmodified lines | ||
| 151 | 151 | * Table 7 - mapping multiplier and speed mode |
| 152 | 152 | * Tables 8 & 9 - mapping speed mode and LRCK fs |
| 153 | 153 | */ |
| 154 | − { .rmin = 8000, .rmax = 32000, .wmin = 1024, .wmax = 1024, }, /* Normal, <= 32kHz */ | |
| 155 | − { .rmin = 44100, .rmax = 48000, .wmin = 512, .wmax = 512, }, /* Normal */ | |
| 154 | + { .rmin = 8000, .rmax = 32000, .wmin = 256, .wmax = 1024, }, /* Normal, <= 32kHz */ | |
| 155 | + { .rmin = 44100, .rmax = 48000, .wmin = 256, .wmax = 512, }, /* Normal */ | |
| 156 | 156 | { .rmin = 88200, .rmax = 96000, .wmin = 256, .wmax = 256, }, /* Double */ |
| 157 | 157 | { .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 128, }, /* Quad */ |
| 158 | 158 | { .rmin = 352800, .rmax = 384000, .wmin = 128, .wmax = 128, }, /* Oct */ |
| @@ -164,7 +164,7 @@ static struct imx_akcodec_fs_mul ak4497_fs_mul[] = { · 5 unmodified lines | ||
| 164 | 164 | * (Table 4 from datasheet) |
| 165 | 165 | */ |
| 166 | 166 | static struct imx_akcodec_fs_mul ak5558_fs_mul[] = { |
| 167 | − { .rmin = 8000, .rmax = 32000, .wmin = 1024, .wmax = 1024, }, | |
| 167 | + { .rmin = 8000, .rmax = 32000, .wmin = 512, .wmax = 1024, }, | |
| 168 | 168 | { .rmin = 44100, .rmax = 48000, .wmin = 512, .wmax = 512, }, |
| 169 | 169 | { .rmin = 88200, .rmax = 96000, .wmin = 256, .wmax = 256, }, |
| 170 | 170 | { .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 128, }, |
| @@ -247,13 +247,14 @@ static bool codec_is_akcodec(unsigned int type) · 76 unmodified lines | ||
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | static unsigned long akcodec_get_mclk_rate(struct snd_pcm_substream *substream, |
| 250 | − struct snd_pcm_hw_params *params) | |
| 250 | + struct snd_pcm_hw_params *params, | |
| 251 | + int slots, int slot_width) | |
| 251 | 252 | { |
| 252 | 253 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 253 | 254 | struct imx_card_data *data = snd_soc_card_get_drvdata(rtd->card); |
| 254 | 255 | const struct imx_card_plat_data *plat_data = data->plat_data; |
| 255 | 256 | struct dai_link_data *link_data = &data->link_data[rtd->num]; |
| 256 | − unsigned int width = link_data->slots * link_data->slot_width; | |
| 257 | + unsigned int width = slots * slot_width; | |
| 257 | 258 | unsigned int rate = params_rate(params); |
| 258 | 259 | int i; |
| 259 | 260 | |
| @@ -349,7 +350,7 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream, · 89 unmodified lines | ||
| 349 | 350 | |
| 350 | 351 | /* Set MCLK freq */ |
| 351 | 352 | if (codec_is_akcodec(plat_data->type)) |
| 352 | − mclk_freq = akcodec_get_mclk_rate(substream, params); | |
| 353 | + mclk_freq = akcodec_get_mclk_rate(substream, params, slots, slot_width); | |
| 353 | 354 | else |
| 354 | 355 | mclk_freq = params_rate(params) * slots * slot_width; |
| 355 | 356 | /* Use the maximum freq from DSD512 (512*44100 = 22579200) */ |
| @@ -553,8 +554,23 @@ static int imx_card_parse_of(struct imx_card_data *data) · 197 unmodified lines | ||
| 553 | 554 | link_data->cpu_sysclk_id = FSL_SAI_CLK_MAST1; |
| 554 | 555 | |
| 555 | 556 | /* sai may support mclk/bclk = 1 */ |
| 556 | − if (of_find_property(np, "fsl,mclk-equal-bclk", NULL)) | |
| 557 | + if (of_find_property(np, "fsl,mclk-equal-bclk", NULL)) { | |
| 557 | 558 | link_data->one2one_ratio = true; |
| 559 | + } else { | |
| 560 | + int i; | |
| 561 | + | |
| 562 | + /* | |
| 563 | + * i.MX8MQ don't support one2one ratio, then | |
| 564 | + * with ak4497 only 16bit case is supported. | |
| 565 | + */ | |
| 566 | + for (i = 0; i < ARRAY_SIZE(ak4497_fs_mul); i++) { | |
| 567 | + if (ak4497_fs_mul[i].rmin == 705600 && | |
| 568 | + ak4497_fs_mul[i].rmax == 768000) { | |
| 569 | + ak4497_fs_mul[i].wmin = 32; | |
| 570 | + ak4497_fs_mul[i].wmax = 32; | |
| 571 | + } | |
| 572 | + } | |
| 573 | + } | |
| 558 | 574 | } |
| 559 | 575 | |
| 560 | 576 | link->cpus->of_node = args.np; |
| @@ -563,9 +579,8 @@ static int imx_card_parse_of(struct imx_card_data *data) · 2 unmodified lines | ||
| 563 | 579 | |
| 564 | 580 | ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name); |
| 565 | 581 | if (ret) { |
| 566 | − if (ret != -EPROBE_DEFER) | |
| 567 | − dev_err(card->dev, "%s: error getting cpu dai name: %d\n", | |
| 568 | − link->name, ret); | |
| 582 | + dev_err_probe(card->dev, ret, | |
| 583 | + "%s: error getting cpu dai name\n", link->name); | |
| 569 | 584 | goto err; |
| 570 | 585 | } |
| 571 | 586 | |
| @@ -573,9 +588,8 @@ static int imx_card_parse_of(struct imx_card_data *data) · 1 unmodified line | ||
| 573 | 588 | if (codec) { |
| 574 | 589 | ret = snd_soc_of_get_dai_link_codecs(dev, codec, link); |
| 575 | 590 | if (ret < 0) { |
| 576 | − if (ret != -EPROBE_DEFER) | |
| 577 | − dev_err(dev, "%s: codec dai not found: %d\n", | |
| 578 | − link->name, ret); | |
| 591 | + dev_err_probe(dev, ret, "%s: codec dai not found\n", | |
| 592 | + link->name); | |
| 579 | 593 | goto err; |
| 580 | 594 | } |
| 581 | 595 | |
| @@ -814,11 +828,8 @@ static int imx_card_probe(struct platform_device *pdev) · 232 unmodified lines | ||
| 814 | 828 | } |
| 815 | 829 | |
| 816 | 830 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); |
| 817 | − if (ret) { | |
| 818 | − if (ret != -EPROBE_DEFER) | |
| 819 | − dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | |
| 820 | − return ret; | |
| 821 | − } | |
| 831 | + if (ret) | |
| 832 | + return dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n"); | |
| 822 | 833 | |
| 823 | 834 | return 0; |
| 824 | 835 | } |
| @@ -145,6 +145,8 @@ static int imx_hdmi_probe(struct platform_device *pdev) · 144 unmodified lines | ||
| 145 | 145 | data->dai.capture_only = false; |
| 146 | 146 | data->dai.init = imx_hdmi_init; |
| 147 | 147 | |
| 148 | + put_device(&cpu_pdev->dev); | |
| 149 | + | |
| 148 | 150 | if (of_node_name_eq(cpu_np, "sai")) { |
| 149 | 151 | data->cpu_priv.sysclk_id[1] = FSL_SAI_CLK_MAST1; |
| 150 | 152 | data->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1; |
| @@ -173,9 +173,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) · 172 unmodified lines | ||
| 173 | 173 | |
| 174 | 174 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); |
| 175 | 175 | if (ret) { |
| 176 | − if (ret != -EPROBE_DEFER) | |
| 177 | − dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", | |
| 178 | − ret); | |
| 176 | + dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n"); | |
| 179 | 177 | goto fail; |
| 180 | 178 | } |
| 181 | 179 | |
| @@ -70,8 +70,8 @@ static int imx_spdif_audio_probe(struct platform_device *pdev) · 69 unmodified lines | ||
| 70 | 70 | goto end; |
| 71 | 71 | |
| 72 | 72 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); |
| 73 | − if (ret && ret != -EPROBE_DEFER) | |
| 74 | − dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); | |
| 73 | + if (ret) | |
| 74 | + dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n"); | |
| 75 | 75 | |
| 76 | 76 | end: |
| 77 | 77 | of_node_put(spdif_np); |
| @@ -593,10 +593,7 @@ int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev) · 592 unmodified lines | ||
| 593 | 593 | err: |
| 594 | 594 | asoc_simple_clean_reference(card); |
| 595 | 595 | |
| 596 | − if (ret != -EPROBE_DEFER) | |
| 597 | − dev_err(dev, "parse error %d\n", ret); | |
| 598 | − | |
| 599 | − return ret; | |
| 596 | + return dev_err_probe(dev, ret, "parse error\n"); | |
| 600 | 597 | } |
| 601 | 598 | EXPORT_SYMBOL_GPL(audio_graph_parse_of); |
| 602 | 599 | |
| @@ -1238,8 +1238,8 @@ int audio_graph2_parse_of(struct asoc_simple_priv *priv, struct device *dev, · 1237 unmodified lines | ||
| 1238 | 1238 | err: |
| 1239 | 1239 | devm_kfree(dev, li); |
| 1240 | 1240 | |
| 1241 | − if ((ret < 0) && (ret != -EPROBE_DEFER)) | |
| 1242 | − dev_err(dev, "parse error %d\n", ret); | |
| 1241 | + if (ret < 0) | |
| 1242 | + dev_err_probe(dev, ret, "parse error\n"); | |
| 1243 | 1243 | |
| 1244 | 1244 | return ret; |
| 1245 | 1245 | } |
| @@ -499,57 +499,14 @@ EXPORT_SYMBOL_GPL(asoc_simple_parse_widgets); · 498 unmodified lines | ||
| 499 | 499 | int asoc_simple_parse_pin_switches(struct snd_soc_card *card, |
| 500 | 500 | char *prefix) |
| 501 | 501 | { |
| 502 | − const unsigned int nb_controls_max = 16; | |
| 503 | − const char **strings, *control_name; | |
| 504 | − struct snd_kcontrol_new *controls; | |
| 505 | − struct device *dev = card->dev; | |
| 506 | − unsigned int i, nb_controls; | |
| 507 | 502 | char prop[128]; |
| 508 | − int ret; | |
| 509 | 503 | |
| 510 | 504 | if (!prefix) |
| 511 | 505 | prefix = ""; |
| 512 | 506 | |
| 513 | 507 | snprintf(prop, sizeof(prop), "%s%s", prefix, "pin-switches"); |
| 514 | 508 | |
| 515 | − if (!of_property_read_bool(dev->of_node, prop)) | |
| 516 | − return 0; | |
| 517 | − | |
| 518 | − strings = devm_kcalloc(dev, nb_controls_max, | |
| 519 | − sizeof(*strings), GFP_KERNEL); | |
| 520 | − if (!strings) | |
| 521 | − return -ENOMEM; | |
| 522 | − | |
| 523 | − ret = of_property_read_string_array(dev->of_node, prop, | |
| 524 | − strings, nb_controls_max); | |
| 525 | − if (ret < 0) | |
| 526 | − return ret; | |
| 527 | − | |
| 528 | − nb_controls = (unsigned int)ret; | |
| 529 | − | |
| 530 | − controls = devm_kcalloc(dev, nb_controls, | |
| 531 | − sizeof(*controls), GFP_KERNEL); | |
| 532 | − if (!controls) | |
| 533 | − return -ENOMEM; | |
| 534 | − | |
| 535 | − for (i = 0; i < nb_controls; i++) { | |
| 536 | − control_name = devm_kasprintf(dev, GFP_KERNEL, | |
| 537 | − "%s Switch", strings[i]); | |
| 538 | − if (!control_name) | |
| 539 | − return -ENOMEM; | |
| 540 | − | |
| 541 | − controls[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; | |
| 542 | − controls[i].name = control_name; | |
| 543 | − controls[i].info = snd_soc_dapm_info_pin_switch; | |
| 544 | − controls[i].get = snd_soc_dapm_get_pin_switch; | |
| 545 | − controls[i].put = snd_soc_dapm_put_pin_switch; | |
| 546 | − controls[i].private_value = (unsigned long)strings[i]; | |
| 547 | − } | |
| 548 | − | |
| 549 | − card->controls = controls; | |
| 550 | − card->num_controls = nb_controls; | |
| 551 | − | |
| 552 | − return 0; | |
| 509 | + return snd_soc_of_parse_pin_switches(card, prop); | |
| 553 | 510 | } |
| 554 | 511 | EXPORT_SYMBOL_GPL(asoc_simple_parse_pin_switches); |
| 555 | 512 | |
| @@ -642,8 +642,7 @@ static int asoc_simple_probe(struct platform_device *pdev) · 641 unmodified lines | ||
| 642 | 642 | |
| 643 | 643 | ret = simple_parse_of(priv, li); |
| 644 | 644 | if (ret < 0) { |
| 645 | − if (ret != -EPROBE_DEFER) | |
| 646 | − dev_err(dev, "parse error %d\n", ret); | |
| 645 | + dev_err_probe(dev, ret, "parse error\n"); | |
| 647 | 646 | goto err; |
| 648 | 647 | } |
| 649 | 648 | |
| @@ -531,8 +531,7 @@ static int test_driver_probe(struct platform_device *pdev) · 530 unmodified lines | ||
| 531 | 531 | struct device *dev = &pdev->dev; |
| 532 | 532 | struct device_node *node = dev->of_node; |
| 533 | 533 | struct device_node *ep; |
| 534 | − const struct of_device_id *of_id = of_match_device(test_of_match, &pdev->dev); | |
| 535 | − const struct test_adata *adata = of_id->data; | |
| 534 | + const struct test_adata *adata = of_device_get_match_data(&pdev->dev); | |
| 536 | 535 | struct snd_soc_component_driver *cdriv; |
| 537 | 536 | struct snd_soc_dai_driver *ddriv; |
| 538 | 537 | struct test_dai_name *dname; |
| @@ -549,7 +548,7 @@ static int test_driver_probe(struct platform_device *pdev) · 10 unmodified lines | ||
| 549 | 548 | cdriv = devm_kzalloc(dev, sizeof(*cdriv), GFP_KERNEL); |
| 550 | 549 | ddriv = devm_kzalloc(dev, sizeof(*ddriv) * num, GFP_KERNEL); |
| 551 | 550 | dname = devm_kzalloc(dev, sizeof(*dname) * num, GFP_KERNEL); |
| 552 | − if (!priv || !cdriv || !ddriv || !dname) | |
| 551 | + if (!priv || !cdriv || !ddriv || !dname || !adata) | |
| 553 | 552 | return -EINVAL; |
| 554 | 553 | |
| 555 | 554 | priv->dev = dev; |
| @@ -451,11 +451,9 @@ static int img_i2s_in_probe(struct platform_device *pdev) · 450 unmodified lines | ||
| 451 | 451 | i2s->channel_base = base + (max_i2s_chan_pow_2 * 0x20); |
| 452 | 452 | |
| 453 | 453 | i2s->clk_sys = devm_clk_get(dev, "sys"); |
| 454 | − if (IS_ERR(i2s->clk_sys)) { | |
| 455 | − if (PTR_ERR(i2s->clk_sys) != -EPROBE_DEFER) | |
| 456 | − dev_err(dev, "Failed to acquire clock 'sys'\n"); | |
| 457 | − return PTR_ERR(i2s->clk_sys); | |
| 458 | − } | |
| 454 | + if (IS_ERR(i2s->clk_sys)) | |
| 455 | + return dev_err_probe(dev, PTR_ERR(i2s->clk_sys), | |
| 456 | + "Failed to acquire clock 'sys'\n"); | |
| 459 | 457 | |
| 460 | 458 | pm_runtime_enable(&pdev->dev); |
| 461 | 459 | if (!pm_runtime_enabled(&pdev->dev)) { |
| @@ -457,25 +457,19 @@ static int img_i2s_out_probe(struct platform_device *pdev) · 456 unmodified lines | ||
| 457 | 457 | i2s->channel_base = base + (max_i2s_chan_pow_2 * 0x20); |
| 458 | 458 | |
| 459 | 459 | i2s->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); |
| 460 | − if (IS_ERR(i2s->rst)) { | |
| 461 | − if (PTR_ERR(i2s->rst) != -EPROBE_DEFER) | |
| 462 | − dev_err(&pdev->dev, "No top level reset found\n"); | |
| 463 | − return PTR_ERR(i2s->rst); | |
| 464 | − } | |
| 460 | + if (IS_ERR(i2s->rst)) | |
| 461 | + return dev_err_probe(&pdev->dev, PTR_ERR(i2s->rst), | |
| 462 | + "No top level reset found\n"); | |
| 465 | 463 | |
| 466 | 464 | i2s->clk_sys = devm_clk_get(&pdev->dev, "sys"); |
| 467 | − if (IS_ERR(i2s->clk_sys)) { | |
| 468 | − if (PTR_ERR(i2s->clk_sys) != -EPROBE_DEFER) | |
| 469 | − dev_err(dev, "Failed to acquire clock 'sys'\n"); | |
| 470 | − return PTR_ERR(i2s->clk_sys); | |
| 471 | − } | |
| 465 | + if (IS_ERR(i2s->clk_sys)) | |
| 466 | + return dev_err_probe(dev, PTR_ERR(i2s->clk_sys), | |
| 467 | + "Failed to acquire clock 'sys'\n"); | |
| 472 | 468 | |
| 473 | 469 | i2s->clk_ref = devm_clk_get(&pdev->dev, "ref"); |
| 474 | − if (IS_ERR(i2s->clk_ref)) { | |
| 475 | − if (PTR_ERR(i2s->clk_ref) != -EPROBE_DEFER) | |
| 476 | − dev_err(dev, "Failed to acquire clock 'ref'\n"); | |
| 477 | − return PTR_ERR(i2s->clk_ref); | |
| 478 | − } | |
| 470 | + if (IS_ERR(i2s->clk_ref)) | |
| 471 | + return dev_err_probe(dev, PTR_ERR(i2s->clk_ref), | |
| 472 | + "Failed to acquire clock 'ref'\n"); | |
| 479 | 473 | |
| 480 | 474 | i2s->suspend_ch_ctl = devm_kcalloc(dev, |
| 481 | 475 | i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL); |
| @@ -229,25 +229,19 @@ static int img_prl_out_probe(struct platform_device *pdev) · 228 unmodified lines | ||
| 229 | 229 | prl->base = base; |
| 230 | 230 | |
| 231 | 231 | prl->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); |
| 232 | − if (IS_ERR(prl->rst)) { | |
| 233 | − if (PTR_ERR(prl->rst) != -EPROBE_DEFER) | |
| 234 | − dev_err(&pdev->dev, "No top level reset found\n"); | |
| 235 | − return PTR_ERR(prl->rst); | |
| 236 | − } | |
| 232 | + if (IS_ERR(prl->rst)) | |
| 233 | + return dev_err_probe(&pdev->dev, PTR_ERR(prl->rst), | |
| 234 | + "No top level reset found\n"); | |
| 237 | 235 | |
| 238 | 236 | prl->clk_sys = devm_clk_get(&pdev->dev, "sys"); |
| 239 | − if (IS_ERR(prl->clk_sys)) { | |
| 240 | − if (PTR_ERR(prl->clk_sys) != -EPROBE_DEFER) | |
| 241 | − dev_err(dev, "Failed to acquire clock 'sys'\n"); | |
| 242 | − return PTR_ERR(prl->clk_sys); | |
| 243 | − } | |
| 237 | + if (IS_ERR(prl->clk_sys)) | |
| 238 | + return dev_err_probe(dev, PTR_ERR(prl->clk_sys), | |
| 239 | + "Failed to acquire clock 'sys'\n"); | |
| 244 | 240 | |
| 245 | 241 | prl->clk_ref = devm_clk_get(&pdev->dev, "ref"); |
| 246 | − if (IS_ERR(prl->clk_ref)) { | |
| 247 | − if (PTR_ERR(prl->clk_ref) != -EPROBE_DEFER) | |
| 248 | − dev_err(dev, "Failed to acquire clock 'ref'\n"); | |
| 249 | − return PTR_ERR(prl->clk_ref); | |
| 250 | − } | |
| 242 | + if (IS_ERR(prl->clk_ref)) | |
| 243 | + return dev_err_probe(dev, PTR_ERR(prl->clk_ref), | |
| 244 | + "Failed to acquire clock 'ref'\n"); | |
| 251 | 245 | |
| 252 | 246 | ret = clk_prepare_enable(prl->clk_sys); |
| 253 | 247 | if (ret) |
| @@ -739,11 +739,9 @@ static int img_spdif_in_probe(struct platform_device *pdev) · 738 unmodified lines | ||
| 739 | 739 | spdif->base = base; |
| 740 | 740 | |
| 741 | 741 | spdif->clk_sys = devm_clk_get(dev, "sys"); |
| 742 | − if (IS_ERR(spdif->clk_sys)) { | |
| 743 | − if (PTR_ERR(spdif->clk_sys) != -EPROBE_DEFER) | |
| 744 | − dev_err(dev, "Failed to acquire clock 'sys'\n"); | |
| 745 | − return PTR_ERR(spdif->clk_sys); | |
| 746 | − } | |
| 742 | + if (IS_ERR(spdif->clk_sys)) | |
| 743 | + return dev_err_probe(dev, PTR_ERR(spdif->clk_sys), | |
| 744 | + "Failed to acquire clock 'sys'\n"); | |
| 747 | 745 | |
| 748 | 746 | pm_runtime_enable(&pdev->dev); |
| 749 | 747 | if (!pm_runtime_enabled(&pdev->dev)) { |
| @@ -342,25 +342,19 @@ static int img_spdif_out_probe(struct platform_device *pdev) · 341 unmodified lines | ||
| 342 | 342 | spdif->base = base; |
| 343 | 343 | |
| 344 | 344 | spdif->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); |
| 345 | − if (IS_ERR(spdif->rst)) { | |
| 346 | − if (PTR_ERR(spdif->rst) != -EPROBE_DEFER) | |
| 347 | − dev_err(&pdev->dev, "No top level reset found\n"); | |
| 348 | − return PTR_ERR(spdif->rst); | |
| 349 | − } | |
| 345 | + if (IS_ERR(spdif->rst)) | |
| 346 | + return dev_err_probe(&pdev->dev, PTR_ERR(spdif->rst), | |
| 347 | + "No top level reset found\n"); | |
| 350 | 348 | |
| 351 | 349 | spdif->clk_sys = devm_clk_get(&pdev->dev, "sys"); |
| 352 | − if (IS_ERR(spdif->clk_sys)) { | |
| 353 | − if (PTR_ERR(spdif->clk_sys) != -EPROBE_DEFER) | |
| 354 | − dev_err(dev, "Failed to acquire clock 'sys'\n"); | |
| 355 | − return PTR_ERR(spdif->clk_sys); | |
| 356 | − } | |
| 350 | + if (IS_ERR(spdif->clk_sys)) | |
| 351 | + return dev_err_probe(dev, PTR_ERR(spdif->clk_sys), | |
| 352 | + "Failed to acquire clock 'sys'\n"); | |
| 357 | 353 | |
| 358 | 354 | spdif->clk_ref = devm_clk_get(&pdev->dev, "ref"); |
| 359 | − if (IS_ERR(spdif->clk_ref)) { | |
| 360 | − if (PTR_ERR(spdif->clk_ref) != -EPROBE_DEFER) | |
| 361 | − dev_err(dev, "Failed to acquire clock 'ref'\n"); | |
| 362 | − return PTR_ERR(spdif->clk_ref); | |
| 363 | − } | |
| 355 | + if (IS_ERR(spdif->clk_ref)) | |
| 356 | + return dev_err_probe(dev, PTR_ERR(spdif->clk_ref), | |
| 357 | + "Failed to acquire clock 'ref'\n"); | |
| 364 | 358 | |
| 365 | 359 | pm_runtime_enable(&pdev->dev); |
| 366 | 360 | if (!pm_runtime_enabled(&pdev->dev)) { |
| @@ -161,12 +161,9 @@ static int pistachio_internal_dac_probe(struct platform_device *pdev) · 160 unmodified lines | ||
| 161 | 161 | return PTR_ERR(dac->regmap); |
| 162 | 162 | |
| 163 | 163 | dac->supply = devm_regulator_get(dev, "VDD"); |
| 164 | − if (IS_ERR(dac->supply)) { | |
| 165 | − ret = PTR_ERR(dac->supply); | |
| 166 | − if (ret != -EPROBE_DEFER) | |
| 167 | − dev_err(dev, "failed to acquire supply 'VDD-supply': %d\n", ret); | |
| 168 | − return ret; | |
| 169 | − } | |
| 164 | + if (IS_ERR(dac->supply)) | |
| 165 | + return dev_err_probe(dev, PTR_ERR(dac->supply), | |
| 166 | + "failed to acquire supply 'VDD-supply'\n"); | |
| 170 | 167 | |
| 171 | 168 | ret = regulator_enable(dac->supply); |
| 172 | 169 | if (ret) { |
| @@ -653,10 +653,21 @@ static snd_pcm_uframes_t sst_soc_pointer(struct snd_soc_component *component, · 652 unmodified lines | ||
| 653 | 653 | dev_err(rtd->dev, "sst: error code = %d\n", ret_val); |
| 654 | 654 | return ret_val; |
| 655 | 655 | } |
| 656 | − substream->runtime->delay = str_info->pcm_delay; | |
| 657 | 656 | return str_info->buffer_ptr; |
| 658 | 657 | } |
| 659 | 658 | |
| 659 | +static snd_pcm_sframes_t sst_soc_delay(struct snd_soc_component *component, | |
| 660 | + struct snd_pcm_substream *substream) | |
| 661 | +{ | |
| 662 | + struct sst_runtime_stream *stream = substream->runtime->private_data; | |
| 663 | + struct pcm_stream_info *str_info = &stream->stream_info; | |
| 664 | + | |
| 665 | + if (sst_get_stream_status(stream) == SST_PLATFORM_INIT) | |
| 666 | + return 0; | |
| 667 | + | |
| 668 | + return str_info->pcm_delay; | |
| 669 | +} | |
| 670 | + | |
| 660 | 671 | static int sst_soc_pcm_new(struct snd_soc_component *component, |
| 661 | 672 | struct snd_soc_pcm_runtime *rtd) |
| 662 | 673 | { |
| @@ -695,6 +706,7 @@ static const struct snd_soc_component_driver sst_soc_platform_drv = { · 32 unmodified lines | ||
| 695 | 706 | .open = sst_soc_open, |
| 696 | 707 | .trigger = sst_soc_trigger, |
| 697 | 708 | .pointer = sst_soc_pointer, |
| 709 | + .delay = sst_soc_delay, | |
| 698 | 710 | .compress_ops = &sst_platform_compress_ops, |
| 699 | 711 | .pcm_construct = sst_soc_pcm_new, |
| 700 | 712 | }; |
| @@ -467,6 +467,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH · 466 unmodified lines | ||
| 467 | 467 | (MFD_INTEL_LPSS || COMPILE_TEST)) ||\ |
| 468 | 468 | (SND_SOC_SOF_BAYTRAIL && (X86_INTEL_LPSS || COMPILE_TEST)) |
| 469 | 469 | select SND_SOC_MAX98373_I2C |
| 470 | + select SND_SOC_MAX98390 | |
| 470 | 471 | select SND_SOC_RT1011 |
| 471 | 472 | select SND_SOC_RT1015 |
| 472 | 473 | select SND_SOC_RT1015P |
| @@ -527,6 +528,25 @@ config SND_SOC_INTEL_SOF_ES8336_MACH · 54 unmodified lines | ||
| 527 | 528 | Say Y if you have such a device. |
| 528 | 529 | If unsure select "N". |
| 529 | 530 | |
| 531 | +config SND_SOC_INTEL_SOF_NAU8825_MACH | |
| 532 | + tristate "SOF with nau8825 codec in I2S Mode" | |
| 533 | + depends on I2C && ACPI && GPIOLIB | |
| 534 | + depends on ((SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC) &&\ | |
| 535 | + (MFD_INTEL_LPSS || COMPILE_TEST)) | |
| 536 | + select SND_SOC_NAU8825 | |
| 537 | + select SND_SOC_RT1015P | |
| 538 | + select SND_SOC_MAX98373_I2C | |
| 539 | + select SND_SOC_MAX98357A | |
| 540 | + select SND_SOC_DMIC | |
| 541 | + select SND_SOC_HDAC_HDMI | |
| 542 | + select SND_SOC_INTEL_HDA_DSP_COMMON | |
| 543 | + select SND_SOC_INTEL_SOF_MAXIM_COMMON | |
| 544 | + help | |
| 545 | + This adds support for ASoC machine driver for SOF platforms | |
| 546 | + with nau8825 codec. | |
| 547 | + Say Y if you have such a device. | |
| 548 | + If unsure select "N". | |
| 549 | + | |
| 530 | 550 | endif ## SND_SOC_SOF_HDA_LINK || SND_SOC_SOF_BAYTRAIL |
| 531 | 551 | |
| 532 | 552 | if (SND_SOC_SOF_COMETLAKE && SND_SOC_SOF_HDA_LINK) |
| @@ -22,6 +22,7 @@ snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o · 21 unmodified lines | ||
| 22 | 22 | snd-soc-sof_rt5682-objs := sof_rt5682.o sof_realtek_common.o |
| 23 | 23 | snd-soc-sof_cs42l42-objs := sof_cs42l42.o |
| 24 | 24 | snd-soc-sof_es8336-objs := sof_es8336.o |
| 25 | +snd-soc-sof_nau8825-objs := sof_nau8825.o sof_realtek_common.o | |
| 25 | 26 | snd-soc-cml_rt1011_rt5682-objs := cml_rt1011_rt5682.o |
| 26 | 27 | snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.o |
| 27 | 28 | snd-soc-kbl_da7219_max98927-objs := kbl_da7219_max98927.o |
| @@ -44,6 +45,7 @@ snd-soc-sof-sdw-objs += sof_sdw.o \ · 16 unmodified lines | ||
| 44 | 45 | obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o |
| 45 | 46 | obj-$(CONFIG_SND_SOC_INTEL_SOF_CS42L42_MACH) += snd-soc-sof_cs42l42.o |
| 46 | 47 | obj-$(CONFIG_SND_SOC_INTEL_SOF_ES8336_MACH) += snd-soc-sof_es8336.o |
| 48 | +obj-$(CONFIG_SND_SOC_INTEL_SOF_NAU8825_MACH) += snd-soc-sof_nau8825.o | |
| 47 | 49 | obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o |
| 48 | 50 | obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da7219_max98357a.o |
| 49 | 51 | obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o |
| @@ -147,7 +147,7 @@ static int byt_cht_cx2072x_aif1_startup(struct snd_pcm_substream *substream) · 146 unmodified lines | ||
| 147 | 147 | SNDRV_PCM_HW_PARAM_RATE, 48000); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | −static struct snd_soc_ops byt_cht_cx2072x_aif1_ops = { | |
| 150 | +static const struct snd_soc_ops byt_cht_cx2072x_aif1_ops = { | |
| 151 | 151 | .startup = byt_cht_cx2072x_aif1_startup, |
| 152 | 152 | }; |
| 153 | 153 | |
| @@ -93,7 +93,7 @@ static int aif1_startup(struct snd_pcm_substream *substream) · 92 unmodified lines | ||
| 93 | 93 | &constraints_48000); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | −static struct snd_soc_ops aif1_ops = { | |
| 96 | +static const struct snd_soc_ops aif1_ops = { | |
| 97 | 97 | .startup = aif1_startup, |
| 98 | 98 | }; |
| 99 | 99 | |
| @@ -40,6 +40,8 @@ enum { · 39 unmodified lines | ||
| 40 | 40 | BYT_RT5640_NO_INTERNAL_MIC_MAP, |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | +#define RT5640_JD_SRC_EXT_GPIO 0x0f | |
| 44 | + | |
| 43 | 45 | enum { |
| 44 | 46 | BYT_RT5640_JD_SRC_GPIO1 = (RT5640_JD_SRC_GPIO1 << 4), |
| 45 | 47 | BYT_RT5640_JD_SRC_JD1_IN4P = (RT5640_JD_SRC_JD1_IN4P << 4), |
| @@ -47,6 +49,7 @@ enum { · 1 unmodified line | ||
| 47 | 49 | BYT_RT5640_JD_SRC_GPIO2 = (RT5640_JD_SRC_GPIO2 << 4), |
| 48 | 50 | BYT_RT5640_JD_SRC_GPIO3 = (RT5640_JD_SRC_GPIO3 << 4), |
| 49 | 51 | BYT_RT5640_JD_SRC_GPIO4 = (RT5640_JD_SRC_GPIO4 << 4), |
| 52 | + BYT_RT5640_JD_SRC_EXT_GPIO = (RT5640_JD_SRC_EXT_GPIO << 4) | |
| 50 | 53 | }; |
| 51 | 54 | |
| 52 | 55 | enum { |
| @@ -79,6 +82,7 @@ enum { · 26 unmodified lines | ||
| 79 | 82 | #define BYT_RT5640_LINEOUT_AS_HP2 BIT(26) |
| 80 | 83 | #define BYT_RT5640_HSMIC2_ON_IN1 BIT(27) |
| 81 | 84 | #define BYT_RT5640_JD_HP_ELITEP_1000G2 BIT(28) |
| 85 | +#define BYT_RT5640_USE_AMCR0F28 BIT(29) | |
| 82 | 86 | |
| 83 | 87 | #define BYTCR_INPUT_DEFAULTS \ |
| 84 | 88 | (BYT_RT5640_IN3_MAP | \ |
| @@ -93,6 +97,7 @@ enum { · 8 unmodified lines | ||
| 93 | 97 | struct byt_rt5640_private { |
| 94 | 98 | struct snd_soc_jack jack; |
| 95 | 99 | struct snd_soc_jack jack2; |
| 100 | + struct rt5640_set_jack_data jack_data; | |
| 96 | 101 | struct gpio_desc *hsmic_detect; |
| 97 | 102 | struct clk *mclk; |
| 98 | 103 | struct device *codec_dev; |
| @@ -597,7 +602,8 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { · 498 unmodified lines | ||
| 597 | 602 | BYT_RT5640_OVCD_TH_2000UA | |
| 598 | 603 | BYT_RT5640_OVCD_SF_0P75 | |
| 599 | 604 | BYT_RT5640_SSP0_AIF1 | |
| 600 | − BYT_RT5640_MCLK_EN), | |
| 605 | + BYT_RT5640_MCLK_EN | | |
| 606 | + BYT_RT5640_USE_AMCR0F28), | |
| 601 | 607 | }, |
| 602 | 608 | { |
| 603 | 609 | .matches = { |
| @@ -624,6 +630,19 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { · 20 unmodified lines | ||
| 624 | 630 | BYT_RT5640_SSP0_AIF2 | |
| 625 | 631 | BYT_RT5640_MCLK_EN), |
| 626 | 632 | }, |
| 633 | + { | |
| 634 | + .matches = { | |
| 635 | + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), | |
| 636 | + DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"), | |
| 637 | + }, | |
| 638 | + .driver_data = (void *)(BYT_RT5640_IN1_MAP | | |
| 639 | + BYT_RT5640_JD_SRC_EXT_GPIO | | |
| 640 | + BYT_RT5640_OVCD_TH_2000UA | | |
| 641 | + BYT_RT5640_OVCD_SF_0P75 | | |
| 642 | + BYT_RT5640_SSP0_AIF1 | | |
| 643 | + BYT_RT5640_MCLK_EN | | |
| 644 | + BYT_RT5640_USE_AMCR0F28), | |
| 645 | + }, | |
| 627 | 646 | { /* Chuwi Vi8 (CWI506) */ |
| 628 | 647 | .matches = { |
| 629 | 648 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| @@ -1080,9 +1099,11 @@ static int byt_rt5640_add_codec_device_props(struct device *i2c_dev, · 450 unmodified lines | ||
| 1080 | 1099 | } |
| 1081 | 1100 | |
| 1082 | 1101 | if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) { |
| 1083 | − props[cnt++] = PROPERTY_ENTRY_U32( | |
| 1084 | − "realtek,jack-detect-source", | |
| 1085 | − BYT_RT5640_JDSRC(byt_rt5640_quirk)); | |
| 1102 | + if (BYT_RT5640_JDSRC(byt_rt5640_quirk) != RT5640_JD_SRC_EXT_GPIO) { | |
| 1103 | + props[cnt++] = PROPERTY_ENTRY_U32( | |
| 1104 | + "realtek,jack-detect-source", | |
| 1105 | + BYT_RT5640_JDSRC(byt_rt5640_quirk)); | |
| 1106 | + } | |
| 1086 | 1107 | |
| 1087 | 1108 | props[cnt++] = PROPERTY_ENTRY_U32( |
| 1088 | 1109 | "realtek,over-current-threshold-microamp", |
| @@ -1109,6 +1130,51 @@ static int byt_rt5640_add_codec_device_props(struct device *i2c_dev, · 20 unmodified lines | ||
| 1109 | 1130 | return ret; |
| 1110 | 1131 | } |
| 1111 | 1132 | |
| 1133 | +/* Some Android devs specify IRQs/GPIOS in a special AMCR0F28 ACPI device */ | |
| 1134 | +static const struct acpi_gpio_params amcr0f28_jd_gpio = { 1, 0, false }; | |
| 1135 | + | |
| 1136 | +static const struct acpi_gpio_mapping amcr0f28_gpios[] = { | |
| 1137 | + { "rt5640-jd-gpios", &amcr0f28_jd_gpio, 1 }, | |
| 1138 | + { } | |
| 1139 | +}; | |
| 1140 | + | |
| 1141 | +static int byt_rt5640_get_amcr0f28_settings(struct snd_soc_card *card) | |
| 1142 | +{ | |
| 1143 | + struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); | |
| 1144 | + struct rt5640_set_jack_data *data = &priv->jack_data; | |
| 1145 | + struct acpi_device *adev; | |
| 1146 | + int ret = 0; | |
| 1147 | + | |
| 1148 | + adev = acpi_dev_get_first_match_dev("AMCR0F28", "1", -1); | |
| 1149 | + if (!adev) { | |
| 1150 | + dev_err(card->dev, "error cannot find AMCR0F28 adev\n"); | |
| 1151 | + return -ENOENT; | |
| 1152 | + } | |
| 1153 | + | |
| 1154 | + data->codec_irq_override = acpi_dev_gpio_irq_get(adev, 0); | |
| 1155 | + if (data->codec_irq_override < 0) { | |
| 1156 | + ret = data->codec_irq_override; | |
| 1157 | + dev_err(card->dev, "error %d getting codec IRQ\n", ret); | |
| 1158 | + goto put_adev; | |
| 1159 | + } | |
| 1160 | + | |
| 1161 | + if (BYT_RT5640_JDSRC(byt_rt5640_quirk) == RT5640_JD_SRC_EXT_GPIO) { | |
| 1162 | + acpi_dev_add_driver_gpios(adev, amcr0f28_gpios); | |
| 1163 | + data->jd_gpio = devm_fwnode_gpiod_get(card->dev, acpi_fwnode_handle(adev), | |
| 1164 | + "rt5640-jd", GPIOD_IN, "rt5640-jd"); | |
| 1165 | + acpi_dev_remove_driver_gpios(adev); | |
| 1166 | + | |
| 1167 | + if (IS_ERR(data->jd_gpio)) { | |
| 1168 | + ret = PTR_ERR(data->jd_gpio); | |
| 1169 | + dev_err(card->dev, "error %d getting jd GPIO\n", ret); | |
| 1170 | + } | |
| 1171 | + } | |
| 1172 | + | |
| 1173 | +put_adev: | |
| 1174 | + acpi_dev_put(adev); | |
| 1175 | + return ret; | |
| 1176 | +} | |
| 1177 | + | |
| 1112 | 1178 | static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) |
| 1113 | 1179 | { |
| 1114 | 1180 | struct snd_soc_card *card = runtime->card; |
| @@ -1244,7 +1310,14 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) · 129 unmodified lines | ||
| 1244 | 1310 | } |
| 1245 | 1311 | snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, |
| 1246 | 1312 | KEY_PLAYPAUSE); |
| 1247 | − snd_soc_component_set_jack(component, &priv->jack, NULL); | |
| 1313 | + | |
| 1314 | + if (byt_rt5640_quirk & BYT_RT5640_USE_AMCR0F28) { | |
| 1315 | + ret = byt_rt5640_get_amcr0f28_settings(card); | |
| 1316 | + if (ret) | |
| 1317 | + return ret; | |
| 1318 | + } | |
| 1319 | + | |
| 1320 | + snd_soc_component_set_jack(component, &priv->jack, &priv->jack_data); | |
| 1248 | 1321 | } |
| 1249 | 1322 | |
| 1250 | 1323 | if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2) { |
| @@ -1448,7 +1521,8 @@ static int byt_rt5640_resume(struct snd_soc_card *card) · 197 unmodified lines | ||
| 1448 | 1521 | for_each_card_components(card, component) { |
| 1449 | 1522 | if (!strcmp(component->name, byt_rt5640_codec_name)) { |
| 1450 | 1523 | dev_dbg(component->dev, "re-enabling jack detect after resume\n"); |
| 1451 | − snd_soc_component_set_jack(component, &priv->jack, NULL); | |
| 1524 | + snd_soc_component_set_jack(component, &priv->jack, | |
| 1525 | + &priv->jack_data); | |
| 1452 | 1526 | break; |
| 1453 | 1527 | } |
| 1454 | 1528 | } |
| @@ -68,7 +68,7 @@ int hda_dsp_hdmi_build_controls(struct snd_soc_card *card, · 67 unmodified lines | ||
| 68 | 68 | hpcm->pcm = NULL; |
| 69 | 69 | hpcm->device = SNDRV_PCM_INVALID_DEVICE; |
| 70 | 70 | dev_warn(card->dev, |
| 71 | − "%s: no PCM in topology for HDMI converter %d\n\n", | |
| 71 | + "%s: no PCM in topology for HDMI converter %d\n", | |
| 72 | 72 | __func__, i); |
| 73 | 73 | } |
| 74 | 74 | i++; |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | #include <linux/string.h> |
| 6 | 6 | #include <sound/pcm.h> |
| 7 | 7 | #include <sound/soc.h> |
| 8 | +#include <sound/soc-acpi.h> | |
| 8 | 9 | #include <sound/soc-dai.h> |
| 9 | 10 | #include <sound/soc-dapm.h> |
| 10 | 11 | #include <uapi/sound/asound.h> |
| @@ -133,6 +134,185 @@ void max_98373_set_codec_conf(struct snd_soc_card *card) · 122 unmodified lines | ||
| 133 | 134 | } |
| 134 | 135 | EXPORT_SYMBOL_NS(max_98373_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON); |
| 135 | 136 | |
| 137 | +/* | |
| 138 | + * Maxim MAX98390 | |
| 139 | + */ | |
| 140 | +static const struct snd_soc_dapm_route max_98390_dapm_routes[] = { | |
| 141 | + /* speaker */ | |
| 142 | + { "Left Spk", NULL, "Left BE_OUT" }, | |
| 143 | + { "Right Spk", NULL, "Right BE_OUT" }, | |
| 144 | +}; | |
| 145 | + | |
| 146 | +static const struct snd_kcontrol_new max_98390_tt_kcontrols[] = { | |
| 147 | + SOC_DAPM_PIN_SWITCH("TL Spk"), | |
| 148 | + SOC_DAPM_PIN_SWITCH("TR Spk"), | |
| 149 | +}; | |
| 150 | + | |
| 151 | +static const struct snd_soc_dapm_widget max_98390_tt_dapm_widgets[] = { | |
| 152 | + SND_SOC_DAPM_SPK("TL Spk", NULL), | |
| 153 | + SND_SOC_DAPM_SPK("TR Spk", NULL), | |
| 154 | +}; | |
| 155 | + | |
| 156 | +static const struct snd_soc_dapm_route max_98390_tt_dapm_routes[] = { | |
| 157 | + /* Tweeter speaker */ | |
| 158 | + { "TL Spk", NULL, "Tweeter Left BE_OUT" }, | |
| 159 | + { "TR Spk", NULL, "Tweeter Right BE_OUT" }, | |
| 160 | +}; | |
| 161 | + | |
| 162 | +static struct snd_soc_codec_conf max_98390_codec_conf[] = { | |
| 163 | + { | |
| 164 | + .dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME), | |
| 165 | + .name_prefix = "Right", | |
| 166 | + }, | |
| 167 | + { | |
| 168 | + .dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME), | |
| 169 | + .name_prefix = "Left", | |
| 170 | + }, | |
| 171 | +}; | |
| 172 | + | |
| 173 | +static struct snd_soc_codec_conf max_98390_4spk_codec_conf[] = { | |
| 174 | + { | |
| 175 | + .dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME), | |
| 176 | + .name_prefix = "Right", | |
| 177 | + }, | |
| 178 | + { | |
| 179 | + .dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME), | |
| 180 | + .name_prefix = "Left", | |
| 181 | + }, | |
| 182 | + { | |
| 183 | + .dlc = COMP_CODEC_CONF(MAX_98390_DEV2_NAME), | |
| 184 | + .name_prefix = "Tweeter Right", | |
| 185 | + }, | |
| 186 | + { | |
| 187 | + .dlc = COMP_CODEC_CONF(MAX_98390_DEV3_NAME), | |
| 188 | + .name_prefix = "Tweeter Left", | |
| 189 | + }, | |
| 190 | +}; | |
| 191 | + | |
| 192 | +struct snd_soc_dai_link_component max_98390_components[] = { | |
| 193 | + { | |
| 194 | + .name = MAX_98390_DEV0_NAME, | |
| 195 | + .dai_name = MAX_98390_CODEC_DAI, | |
| 196 | + }, | |
| 197 | + { | |
| 198 | + .name = MAX_98390_DEV1_NAME, | |
| 199 | + .dai_name = MAX_98390_CODEC_DAI, | |
| 200 | + }, | |
| 201 | +}; | |
| 202 | +EXPORT_SYMBOL_NS(max_98390_components, SND_SOC_INTEL_SOF_MAXIM_COMMON); | |
| 203 | + | |
| 204 | +struct snd_soc_dai_link_component max_98390_4spk_components[] = { | |
| 205 | + { | |
| 206 | + .name = MAX_98390_DEV0_NAME, | |
| 207 | + .dai_name = MAX_98390_CODEC_DAI, | |
| 208 | + }, | |
| 209 | + { | |
| 210 | + .name = MAX_98390_DEV1_NAME, | |
| 211 | + .dai_name = MAX_98390_CODEC_DAI, | |
| 212 | + }, | |
| 213 | + { | |
| 214 | + .name = MAX_98390_DEV2_NAME, | |
| 215 | + .dai_name = MAX_98390_CODEC_DAI, | |
| 216 | + }, | |
| 217 | + { | |
| 218 | + .name = MAX_98390_DEV3_NAME, | |
| 219 | + .dai_name = MAX_98390_CODEC_DAI, | |
| 220 | + }, | |
| 221 | +}; | |
| 222 | +EXPORT_SYMBOL_NS(max_98390_4spk_components, SND_SOC_INTEL_SOF_MAXIM_COMMON); | |
| 223 | + | |
| 224 | +static int max_98390_hw_params(struct snd_pcm_substream *substream, | |
| 225 | + struct snd_pcm_hw_params *params) | |
| 226 | +{ | |
| 227 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); | |
| 228 | + struct snd_soc_dai *codec_dai; | |
| 229 | + int i; | |
| 230 | + | |
| 231 | + for_each_rtd_codec_dais(rtd, i, codec_dai) { | |
| 232 | + if (i >= ARRAY_SIZE(max_98390_4spk_components)) { | |
| 233 | + dev_err(codec_dai->dev, "invalid codec index %d\n", i); | |
| 234 | + return -ENODEV; | |
| 235 | + } | |
| 236 | + | |
| 237 | + if (!strcmp(codec_dai->component->name, MAX_98390_DEV0_NAME)) { | |
| 238 | + /* DEV0 tdm slot configuration Right */ | |
| 239 | + snd_soc_dai_set_tdm_slot(codec_dai, 0x01, 3, 4, 32); | |
| 240 | + } | |
| 241 | + if (!strcmp(codec_dai->component->name, MAX_98390_DEV1_NAME)) { | |
| 242 | + /* DEV1 tdm slot configuration Left */ | |
| 243 | + snd_soc_dai_set_tdm_slot(codec_dai, 0x02, 3, 4, 32); | |
| 244 | + } | |
| 245 | + | |
| 246 | + if (!strcmp(codec_dai->component->name, MAX_98390_DEV2_NAME)) { | |
| 247 | + /* DEVi2 tdm slot configuration Tweeter Right */ | |
| 248 | + snd_soc_dai_set_tdm_slot(codec_dai, 0x04, 3, 4, 32); | |
| 249 | + } | |
| 250 | + if (!strcmp(codec_dai->component->name, MAX_98390_DEV3_NAME)) { | |
| 251 | + /* DEV3 tdm slot configuration Tweeter Left */ | |
| 252 | + snd_soc_dai_set_tdm_slot(codec_dai, 0x08, 3, 4, 32); | |
| 253 | + } | |
| 254 | + } | |
| 255 | + return 0; | |
| 256 | +} | |
| 257 | + | |
| 258 | +int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd) | |
| 259 | +{ | |
| 260 | + struct snd_soc_card *card = rtd->card; | |
| 261 | + int ret; | |
| 262 | + | |
| 263 | + /* add regular speakers dapm route */ | |
| 264 | + ret = snd_soc_dapm_add_routes(&card->dapm, max_98390_dapm_routes, | |
| 265 | + ARRAY_SIZE(max_98390_dapm_routes)); | |
| 266 | + if (ret) { | |
| 267 | + dev_err(rtd->dev, "unable to add Left/Right Speaker dapm, ret %d\n", ret); | |
| 268 | + return ret; | |
| 269 | + } | |
| 270 | + | |
| 271 | + /* add widgets/controls/dapm for tweeter speakers */ | |
| 272 | + if (acpi_dev_present("MX98390", "3", -1)) { | |
| 273 | + ret = snd_soc_dapm_new_controls(&card->dapm, max_98390_tt_dapm_widgets, | |
| 274 | + ARRAY_SIZE(max_98390_tt_dapm_widgets)); | |
| 275 | + | |
| 276 | + if (ret) { | |
| 277 | + dev_err(rtd->dev, "unable to add tweeter dapm controls, ret %d\n", ret); | |
| 278 | + /* Don't need to add routes if widget addition failed */ | |
| 279 | + return ret; | |
| 280 | + } | |
| 281 | + | |
| 282 | + ret = snd_soc_add_card_controls(card, max_98390_tt_kcontrols, | |
| 283 | + ARRAY_SIZE(max_98390_tt_kcontrols)); | |
| 284 | + if (ret) { | |
| 285 | + dev_err(rtd->dev, "unable to add tweeter card controls, ret %d\n", ret); | |
| 286 | + return ret; | |
| 287 | + } | |
| 288 | + | |
| 289 | + ret = snd_soc_dapm_add_routes(&card->dapm, max_98390_tt_dapm_routes, | |
| 290 | + ARRAY_SIZE(max_98390_tt_dapm_routes)); | |
| 291 | + if (ret) | |
| 292 | + dev_err(rtd->dev, | |
| 293 | + "unable to add Tweeter Left/Right Speaker dapm, ret %d\n", ret); | |
| 294 | + } | |
| 295 | + return ret; | |
| 296 | +} | |
| 297 | +EXPORT_SYMBOL_NS(max_98390_spk_codec_init, SND_SOC_INTEL_SOF_MAXIM_COMMON); | |
| 298 | + | |
| 299 | +const struct snd_soc_ops max_98390_ops = { | |
| 300 | + .hw_params = max_98390_hw_params, | |
| 301 | +}; | |
| 302 | +EXPORT_SYMBOL_NS(max_98390_ops, SND_SOC_INTEL_SOF_MAXIM_COMMON); | |
| 303 | + | |
| 304 | +void max_98390_set_codec_conf(struct snd_soc_card *card, int ch) | |
| 305 | +{ | |
| 306 | + if (ch == ARRAY_SIZE(max_98390_4spk_codec_conf)) { | |
| 307 | + card->codec_conf = max_98390_4spk_codec_conf; | |
| 308 | + card->num_configs = ARRAY_SIZE(max_98390_4spk_codec_conf); | |
| 309 | + } else { | |
| 310 | + card->codec_conf = max_98390_codec_conf; | |
| 311 | + card->num_configs = ARRAY_SIZE(max_98390_codec_conf); | |
| 312 | + } | |
| 313 | +} | |
| 314 | +EXPORT_SYMBOL_NS(max_98390_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON); | |
| 315 | + | |
| 136 | 316 | /* |
| 137 | 317 | * Maxim MAX98357A/MAX98360A |
| 138 | 318 | */ |
| @@ -24,6 +24,22 @@ int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd); · 23 unmodified lines | ||
| 24 | 24 | void max_98373_set_codec_conf(struct snd_soc_card *card); |
| 25 | 25 | int max_98373_trigger(struct snd_pcm_substream *substream, int cmd); |
| 26 | 26 | |
| 27 | +/* | |
| 28 | + * Maxim MAX98390 | |
| 29 | + */ | |
| 30 | +#define MAX_98390_CODEC_DAI "max98390-aif1" | |
| 31 | +#define MAX_98390_DEV0_NAME "i2c-MX98390:00" | |
| 32 | +#define MAX_98390_DEV1_NAME "i2c-MX98390:01" | |
| 33 | +#define MAX_98390_DEV2_NAME "i2c-MX98390:02" | |
| 34 | +#define MAX_98390_DEV3_NAME "i2c-MX98390:03" | |
| 35 | + | |
| 36 | +extern struct snd_soc_dai_link_component max_98390_components[2]; | |
| 37 | +extern struct snd_soc_dai_link_component max_98390_4spk_components[4]; | |
| 38 | +extern const struct snd_soc_ops max_98390_ops; | |
| 39 | + | |
| 40 | +void max_98390_set_codec_conf(struct snd_soc_card *card, int ch); | |
| 41 | +int max_98390_spk_codec_init(struct snd_soc_pcm_runtime *rtd); | |
| 42 | + | |
| 27 | 43 | /* |
| 28 | 44 | * Maxim MAX98357A/MAX98360A |
| 29 | 45 | */ |
| @@ -0,0 +1,651 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0-only | |
| 2 | +// Copyright(c) 2021 Intel Corporation. | |
| 3 | +// Copyright(c) 2021 Nuvoton Corporation. | |
| 4 | + | |
| 5 | +/* | |
| 6 | + * Intel SOF Machine Driver with Nuvoton headphone codec NAU8825 | |
| 7 | + * and speaker codec RT1019P MAX98360a or MAX98373 | |
| 8 | + */ | |
| 9 | +#include <linux/i2c.h> | |
| 10 | +#include <linux/input.h> | |
| 11 | +#include <linux/module.h> | |
| 12 | +#include <linux/platform_device.h> | |
| 13 | +#include <linux/dmi.h> | |
| 14 | +#include <sound/core.h> | |
| 15 | +#include <sound/jack.h> | |
| 16 | +#include <sound/pcm.h> | |
| 17 | +#include <sound/pcm_params.h> | |
| 18 | +#include <sound/soc.h> | |
| 19 | +#include <sound/sof.h> | |
| 20 | +#include <sound/soc-acpi.h> | |
| 21 | +#include "../../codecs/nau8825.h" | |
| 22 | +#include "../common/soc-intel-quirks.h" | |
| 23 | +#include "hda_dsp_common.h" | |
| 24 | +#include "sof_realtek_common.h" | |
| 25 | +#include "sof_maxim_common.h" | |
| 26 | + | |
| 27 | +#define NAME_SIZE 32 | |
| 28 | + | |
| 29 | +#define SOF_NAU8825_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) | |
| 30 | +#define SOF_NAU8825_SSP_CODEC_MASK (GENMASK(2, 0)) | |
| 31 | +#define SOF_SPEAKER_AMP_PRESENT BIT(3) | |
| 32 | +#define SOF_NAU8825_SSP_AMP_SHIFT 4 | |
| 33 | +#define SOF_NAU8825_SSP_AMP_MASK (GENMASK(6, 4)) | |
| 34 | +#define SOF_NAU8825_SSP_AMP(quirk) \ | |
| 35 | + (((quirk) << SOF_NAU8825_SSP_AMP_SHIFT) & SOF_NAU8825_SSP_AMP_MASK) | |
| 36 | +#define SOF_NAU8825_NUM_HDMIDEV_SHIFT 7 | |
| 37 | +#define SOF_NAU8825_NUM_HDMIDEV_MASK (GENMASK(9, 7)) | |
| 38 | +#define SOF_NAU8825_NUM_HDMIDEV(quirk) \ | |
| 39 | + (((quirk) << SOF_NAU8825_NUM_HDMIDEV_SHIFT) & SOF_NAU8825_NUM_HDMIDEV_MASK) | |
| 40 | + | |
| 41 | +/* BT audio offload: reserve 3 bits for future */ | |
| 42 | +#define SOF_BT_OFFLOAD_SSP_SHIFT 10 | |
| 43 | +#define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(12, 10)) | |
| 44 | +#define SOF_BT_OFFLOAD_SSP(quirk) \ | |
| 45 | + (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) | |
| 46 | +#define SOF_SSP_BT_OFFLOAD_PRESENT BIT(13) | |
| 47 | +#define SOF_RT1019P_SPEAKER_AMP_PRESENT BIT(14) | |
| 48 | +#define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(15) | |
| 49 | +#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(16) | |
| 50 | + | |
| 51 | +static unsigned long sof_nau8825_quirk = SOF_NAU8825_SSP_CODEC(0); | |
| 52 | + | |
| 53 | +struct sof_hdmi_pcm { | |
| 54 | + struct list_head head; | |
| 55 | + struct snd_soc_dai *codec_dai; | |
| 56 | + int device; | |
| 57 | +}; | |
| 58 | + | |
| 59 | +struct sof_card_private { | |
| 60 | + struct clk *mclk; | |
| 61 | + struct snd_soc_jack sof_headset; | |
| 62 | + struct list_head hdmi_pcm_list; | |
| 63 | +}; | |
| 64 | + | |
| 65 | +static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) | |
| 66 | +{ | |
| 67 | + struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); | |
| 68 | + struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); | |
| 69 | + struct sof_hdmi_pcm *pcm; | |
| 70 | + | |
| 71 | + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); | |
| 72 | + if (!pcm) | |
| 73 | + return -ENOMEM; | |
| 74 | + | |
| 75 | + /* dai_link id is 1:1 mapped to the PCM device */ | |
| 76 | + pcm->device = rtd->dai_link->id; | |
| 77 | + pcm->codec_dai = dai; | |
| 78 | + | |
| 79 | + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); | |
| 80 | + | |
| 81 | + return 0; | |
| 82 | +} | |
| 83 | + | |
| 84 | +static int sof_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) | |
| 85 | +{ | |
| 86 | + struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); | |
| 87 | + struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; | |
| 88 | + | |
| 89 | + struct snd_soc_jack *jack; | |
| 90 | + int ret; | |
| 91 | + | |
| 92 | + /* | |
| 93 | + * Headset buttons map to the google Reference headset. | |
| 94 | + * These can be configured by userspace. | |
| 95 | + */ | |
| 96 | + ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", | |
| 97 | + SND_JACK_HEADSET | SND_JACK_BTN_0 | | |
| 98 | + SND_JACK_BTN_1 | SND_JACK_BTN_2 | | |
| 99 | + SND_JACK_BTN_3, | |
| 100 | + &ctx->sof_headset, NULL, 0); | |
| 101 | + if (ret) { | |
| 102 | + dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); | |
| 103 | + return ret; | |
| 104 | + } | |
| 105 | + | |
| 106 | + jack = &ctx->sof_headset; | |
| 107 | + | |
| 108 | + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); | |
| 109 | + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); | |
| 110 | + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); | |
| 111 | + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); | |
| 112 | + ret = snd_soc_component_set_jack(component, jack, NULL); | |
| 113 | + | |
| 114 | + if (ret) { | |
| 115 | + dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); | |
| 116 | + return ret; | |
| 117 | + } | |
| 118 | + | |
| 119 | + return ret; | |
| 120 | +}; | |
| 121 | + | |
| 122 | +static void sof_nau8825_codec_exit(struct snd_soc_pcm_runtime *rtd) | |
| 123 | +{ | |
| 124 | + struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; | |
| 125 | + | |
| 126 | + snd_soc_component_set_jack(component, NULL, NULL); | |
| 127 | +} | |
| 128 | + | |
| 129 | +static int sof_nau8825_hw_params(struct snd_pcm_substream *substream, | |
| 130 | + struct snd_pcm_hw_params *params) | |
| 131 | +{ | |
| 132 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); | |
| 133 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); | |
| 134 | + int clk_freq, ret; | |
| 135 | + | |
| 136 | + clk_freq = sof_dai_get_bclk(rtd); /* BCLK freq */ | |
| 137 | + | |
| 138 | + if (clk_freq <= 0) { | |
| 139 | + dev_err(rtd->dev, "get bclk freq failed: %d\n", clk_freq); | |
| 140 | + return -EINVAL; | |
| 141 | + } | |
| 142 | + | |
| 143 | + /* Configure clock for codec */ | |
| 144 | + ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_BLK, 0, | |
| 145 | + SND_SOC_CLOCK_IN); | |
| 146 | + if (ret < 0) { | |
| 147 | + dev_err(codec_dai->dev, "can't set BCLK clock %d\n", ret); | |
| 148 | + return ret; | |
| 149 | + } | |
| 150 | + | |
| 151 | + /* Configure pll for codec */ | |
| 152 | + ret = snd_soc_dai_set_pll(codec_dai, 0, 0, clk_freq, | |
| 153 | + params_rate(params) * 256); | |
| 154 | + if (ret < 0) { | |
| 155 | + dev_err(codec_dai->dev, "can't set BCLK: %d\n", ret); | |
| 156 | + return ret; | |
| 157 | + } | |
| 158 | + | |
| 159 | + return ret; | |
| 160 | +} | |
| 161 | + | |
| 162 | +static struct snd_soc_ops sof_nau8825_ops = { | |
| 163 | + .hw_params = sof_nau8825_hw_params, | |
| 164 | +}; | |
| 165 | + | |
| 166 | +static struct snd_soc_dai_link_component platform_component[] = { | |
| 167 | + { | |
| 168 | + /* name might be overridden during probe */ | |
| 169 | + .name = "0000:00:1f.3" | |
| 170 | + } | |
| 171 | +}; | |
| 172 | + | |
| 173 | +static int sof_card_late_probe(struct snd_soc_card *card) | |
| 174 | +{ | |
| 175 | + struct sof_card_private *ctx = snd_soc_card_get_drvdata(card); | |
| 176 | + struct snd_soc_dapm_context *dapm = &card->dapm; | |
| 177 | + struct sof_hdmi_pcm *pcm; | |
| 178 | + int err; | |
| 179 | + | |
| 180 | + if (list_empty(&ctx->hdmi_pcm_list)) | |
| 181 | + return -EINVAL; | |
| 182 | + | |
| 183 | + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm, head); | |
| 184 | + | |
| 185 | + if (sof_nau8825_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { | |
| 186 | + /* Disable Left and Right Spk pin after boot */ | |
| 187 | + snd_soc_dapm_disable_pin(dapm, "Left Spk"); | |
| 188 | + snd_soc_dapm_disable_pin(dapm, "Right Spk"); | |
| 189 | + err = snd_soc_dapm_sync(dapm); | |
| 190 | + if (err < 0) | |
| 191 | + return err; | |
| 192 | + } | |
| 193 | + | |
| 194 | + return hda_dsp_hdmi_build_controls(card, pcm->codec_dai->component); | |
| 195 | +} | |
| 196 | + | |
| 197 | +static const struct snd_kcontrol_new sof_controls[] = { | |
| 198 | + SOC_DAPM_PIN_SWITCH("Headphone Jack"), | |
| 199 | + SOC_DAPM_PIN_SWITCH("Headset Mic"), | |
| 200 | + SOC_DAPM_PIN_SWITCH("Left Spk"), | |
| 201 | + SOC_DAPM_PIN_SWITCH("Right Spk"), | |
| 202 | +}; | |
| 203 | + | |
| 204 | +static const struct snd_kcontrol_new speaker_controls[] = { | |
| 205 | + SOC_DAPM_PIN_SWITCH("Spk"), | |
| 206 | +}; | |
| 207 | + | |
| 208 | +static const struct snd_soc_dapm_widget sof_widgets[] = { | |
| 209 | + SND_SOC_DAPM_HP("Headphone Jack", NULL), | |
| 210 | + SND_SOC_DAPM_MIC("Headset Mic", NULL), | |
| 211 | + SND_SOC_DAPM_SPK("Left Spk", NULL), | |
| 212 | + SND_SOC_DAPM_SPK("Right Spk", NULL), | |
| 213 | +}; | |
| 214 | + | |
| 215 | +static const struct snd_soc_dapm_widget speaker_widgets[] = { | |
| 216 | + SND_SOC_DAPM_SPK("Spk", NULL), | |
| 217 | +}; | |
| 218 | + | |
| 219 | +static const struct snd_soc_dapm_widget dmic_widgets[] = { | |
| 220 | + SND_SOC_DAPM_MIC("SoC DMIC", NULL), | |
| 221 | +}; | |
| 222 | + | |
| 223 | +static const struct snd_soc_dapm_route sof_map[] = { | |
| 224 | + /* HP jack connectors - unknown if we have jack detection */ | |
| 225 | + { "Headphone Jack", NULL, "HPOL" }, | |
| 226 | + { "Headphone Jack", NULL, "HPOR" }, | |
| 227 | + | |
| 228 | + /* other jacks */ | |
| 229 | + { "MIC", NULL, "Headset Mic" }, | |
| 230 | +}; | |
| 231 | + | |
| 232 | +static const struct snd_soc_dapm_route speaker_map[] = { | |
| 233 | + /* speaker */ | |
| 234 | + { "Spk", NULL, "Speaker" }, | |
| 235 | +}; | |
| 236 | + | |
| 237 | +static const struct snd_soc_dapm_route dmic_map[] = { | |
| 238 | + /* digital mics */ | |
| 239 | + {"DMic", NULL, "SoC DMIC"}, | |
| 240 | +}; | |
| 241 | + | |
| 242 | +static int speaker_codec_init(struct snd_soc_pcm_runtime *rtd) | |
| 243 | +{ | |
| 244 | + struct snd_soc_card *card = rtd->card; | |
| 245 | + int ret; | |
| 246 | + | |
| 247 | + ret = snd_soc_dapm_new_controls(&card->dapm, speaker_widgets, | |
| 248 | + ARRAY_SIZE(speaker_widgets)); | |
| 249 | + if (ret) { | |
| 250 | + dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret); | |
| 251 | + /* Don't need to add routes if widget addition failed */ | |
| 252 | + return ret; | |
| 253 | + } | |
| 254 | + | |
| 255 | + ret = snd_soc_add_card_controls(card, speaker_controls, | |
| 256 | + ARRAY_SIZE(speaker_controls)); | |
| 257 | + if (ret) { | |
| 258 | + dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret); | |
| 259 | + return ret; | |
| 260 | + } | |
| 261 | + | |
| 262 | + ret = snd_soc_dapm_add_routes(&card->dapm, speaker_map, | |
| 263 | + ARRAY_SIZE(speaker_map)); | |
| 264 | + | |
| 265 | + if (ret) | |
| 266 | + dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret); | |
| 267 | + return ret; | |
| 268 | +} | |
| 269 | + | |
| 270 | +static int dmic_init(struct snd_soc_pcm_runtime *rtd) | |
| 271 | +{ | |
| 272 | + struct snd_soc_card *card = rtd->card; | |
| 273 | + int ret; | |
| 274 | + | |
| 275 | + ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, | |
| 276 | + ARRAY_SIZE(dmic_widgets)); | |
| 277 | + if (ret) { | |
| 278 | + dev_err(card->dev, "DMic widget addition failed: %d\n", ret); | |
| 279 | + /* Don't need to add routes if widget addition failed */ | |
| 280 | + return ret; | |
| 281 | + } | |
| 282 | + | |
| 283 | + ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, | |
| 284 | + ARRAY_SIZE(dmic_map)); | |
| 285 | + | |
| 286 | + if (ret) | |
| 287 | + dev_err(card->dev, "DMic map addition failed: %d\n", ret); | |
| 288 | + | |
| 289 | + return ret; | |
| 290 | +} | |
| 291 | + | |
| 292 | +/* sof audio machine driver for nau8825 codec */ | |
| 293 | +static struct snd_soc_card sof_audio_card_nau8825 = { | |
| 294 | + .name = "nau8825", /* the sof- prefix is added by the core */ | |
| 295 | + .owner = THIS_MODULE, | |
| 296 | + .controls = sof_controls, | |
| 297 | + .num_controls = ARRAY_SIZE(sof_controls), | |
| 298 | + .dapm_widgets = sof_widgets, | |
| 299 | + .num_dapm_widgets = ARRAY_SIZE(sof_widgets), | |
| 300 | + .dapm_routes = sof_map, | |
| 301 | + .num_dapm_routes = ARRAY_SIZE(sof_map), | |
| 302 | + .fully_routed = true, | |
| 303 | + .late_probe = sof_card_late_probe, | |
| 304 | +}; | |
| 305 | + | |
| 306 | +static struct snd_soc_dai_link_component nau8825_component[] = { | |
| 307 | + { | |
| 308 | + .name = "i2c-10508825:00", | |
| 309 | + .dai_name = "nau8825-hifi", | |
| 310 | + } | |
| 311 | +}; | |
| 312 | + | |
| 313 | +static struct snd_soc_dai_link_component dmic_component[] = { | |
| 314 | + { | |
| 315 | + .name = "dmic-codec", | |
| 316 | + .dai_name = "dmic-hifi", | |
| 317 | + } | |
| 318 | +}; | |
| 319 | + | |
| 320 | +static struct snd_soc_dai_link_component rt1019p_component[] = { | |
| 321 | + { | |
| 322 | + .name = "RTL1019:00", | |
| 323 | + .dai_name = "HiFi", | |
| 324 | + } | |
| 325 | +}; | |
| 326 | + | |
| 327 | +static struct snd_soc_dai_link_component dummy_component[] = { | |
| 328 | + { | |
| 329 | + .name = "snd-soc-dummy", | |
| 330 | + .dai_name = "snd-soc-dummy-dai", | |
| 331 | + } | |
| 332 | +}; | |
| 333 | + | |
| 334 | +static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, | |
| 335 | + int ssp_codec, | |
| 336 | + int ssp_amp, | |
| 337 | + int dmic_be_num, | |
| 338 | + int hdmi_num) | |
| 339 | +{ | |
| 340 | + struct snd_soc_dai_link_component *idisp_components; | |
| 341 | + struct snd_soc_dai_link_component *cpus; | |
| 342 | + struct snd_soc_dai_link *links; | |
| 343 | + int i, id = 0; | |
| 344 | + | |
| 345 | + links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) * | |
| 346 | + sof_audio_card_nau8825.num_links, GFP_KERNEL); | |
| 347 | + cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component) * | |
| 348 | + sof_audio_card_nau8825.num_links, GFP_KERNEL); | |
| 349 | + if (!links || !cpus) | |
| 350 | + goto devm_err; | |
| 351 | + | |
| 352 | + /* codec SSP */ | |
| 353 | + links[id].name = devm_kasprintf(dev, GFP_KERNEL, | |
| 354 | + "SSP%d-Codec", ssp_codec); | |
| 355 | + if (!links[id].name) | |
| 356 | + goto devm_err; | |
| 357 | + | |
| 358 | + links[id].id = id; | |
| 359 | + links[id].codecs = nau8825_component; | |
| 360 | + links[id].num_codecs = ARRAY_SIZE(nau8825_component); | |
| 361 | + links[id].platforms = platform_component; | |
| 362 | + links[id].num_platforms = ARRAY_SIZE(platform_component); | |
| 363 | + links[id].init = sof_nau8825_codec_init; | |
| 364 | + links[id].exit = sof_nau8825_codec_exit; | |
| 365 | + links[id].ops = &sof_nau8825_ops; | |
| 366 | + links[id].dpcm_playback = 1; | |
| 367 | + links[id].dpcm_capture = 1; | |
| 368 | + links[id].no_pcm = 1; | |
| 369 | + links[id].cpus = &cpus[id]; | |
| 370 | + links[id].num_cpus = 1; | |
| 371 | + | |
| 372 | + links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, | |
| 373 | + "SSP%d Pin", | |
| 374 | + ssp_codec); | |
| 375 | + if (!links[id].cpus->dai_name) | |
| 376 | + goto devm_err; | |
| 377 | + | |
| 378 | + id++; | |
| 379 | + | |
| 380 | + /* dmic */ | |
| 381 | + if (dmic_be_num > 0) { | |
| 382 | + /* at least we have dmic01 */ | |
| 383 | + links[id].name = "dmic01"; | |
| 384 | + links[id].cpus = &cpus[id]; | |
| 385 | + links[id].cpus->dai_name = "DMIC01 Pin"; | |
| 386 | + links[id].init = dmic_init; | |
| 387 | + if (dmic_be_num > 1) { | |
| 388 | + /* set up 2 BE links at most */ | |
| 389 | + links[id + 1].name = "dmic16k"; | |
| 390 | + links[id + 1].cpus = &cpus[id + 1]; | |
| 391 | + links[id + 1].cpus->dai_name = "DMIC16k Pin"; | |
| 392 | + dmic_be_num = 2; | |
| 393 | + } | |
| 394 | + } | |
| 395 | + | |
| 396 | + for (i = 0; i < dmic_be_num; i++) { | |
| 397 | + links[id].id = id; | |
| 398 | + links[id].num_cpus = 1; | |
| 399 | + links[id].codecs = dmic_component; | |
| 400 | + links[id].num_codecs = ARRAY_SIZE(dmic_component); | |
| 401 | + links[id].platforms = platform_component; | |
| 402 | + links[id].num_platforms = ARRAY_SIZE(platform_component); | |
| 403 | + links[id].ignore_suspend = 1; | |
| 404 | + links[id].dpcm_capture = 1; | |
| 405 | + links[id].no_pcm = 1; | |
| 406 | + id++; | |
| 407 | + } | |
| 408 | + | |
| 409 | + /* HDMI */ | |
| 410 | + if (hdmi_num > 0) { | |
| 411 | + idisp_components = devm_kzalloc(dev, | |
| 412 | + sizeof(struct snd_soc_dai_link_component) * | |
| 413 | + hdmi_num, GFP_KERNEL); | |
| 414 | + if (!idisp_components) | |
| 415 | + goto devm_err; | |
| 416 | + } | |
| 417 | + for (i = 1; i <= hdmi_num; i++) { | |
| 418 | + links[id].name = devm_kasprintf(dev, GFP_KERNEL, | |
| 419 | + "iDisp%d", i); | |
| 420 | + if (!links[id].name) | |
| 421 | + goto devm_err; | |
| 422 | + | |
| 423 | + links[id].id = id; | |
| 424 | + links[id].cpus = &cpus[id]; | |
| 425 | + links[id].num_cpus = 1; | |
| 426 | + links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, | |
| 427 | + "iDisp%d Pin", i); | |
| 428 | + if (!links[id].cpus->dai_name) | |
| 429 | + goto devm_err; | |
| 430 | + | |
| 431 | + idisp_components[i - 1].name = "ehdaudio0D2"; | |
| 432 | + idisp_components[i - 1].dai_name = devm_kasprintf(dev, | |
| 433 | + GFP_KERNEL, | |
| 434 | + "intel-hdmi-hifi%d", | |
| 435 | + i); | |
| 436 | + if (!idisp_components[i - 1].dai_name) | |
| 437 | + goto devm_err; | |
| 438 | + | |
| 439 | + links[id].codecs = &idisp_components[i - 1]; | |
| 440 | + links[id].num_codecs = 1; | |
| 441 | + links[id].platforms = platform_component; | |
| 442 | + links[id].num_platforms = ARRAY_SIZE(platform_component); | |
| 443 | + links[id].init = sof_hdmi_init; | |
| 444 | + links[id].dpcm_playback = 1; | |
| 445 | + links[id].no_pcm = 1; | |
| 446 | + id++; | |
| 447 | + } | |
| 448 | + | |
| 449 | + /* speaker amp */ | |
| 450 | + if (sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) { | |
| 451 | + links[id].name = devm_kasprintf(dev, GFP_KERNEL, | |
| 452 | + "SSP%d-Codec", ssp_amp); | |
| 453 | + if (!links[id].name) | |
| 454 | + goto devm_err; | |
| 455 | + | |
| 456 | + links[id].id = id; | |
| 457 | + if (sof_nau8825_quirk & SOF_RT1019P_SPEAKER_AMP_PRESENT) { | |
| 458 | + links[id].codecs = rt1019p_component; | |
| 459 | + links[id].num_codecs = ARRAY_SIZE(rt1019p_component); | |
| 460 | + links[id].init = speaker_codec_init; | |
| 461 | + } else if (sof_nau8825_quirk & | |
| 462 | + SOF_MAX98373_SPEAKER_AMP_PRESENT) { | |
| 463 | + links[id].codecs = max_98373_components; | |
| 464 | + links[id].num_codecs = ARRAY_SIZE(max_98373_components); | |
| 465 | + links[id].init = max_98373_spk_codec_init; | |
| 466 | + links[id].ops = &max_98373_ops; | |
| 467 | + /* feedback stream */ | |
| 468 | + links[id].dpcm_capture = 1; | |
| 469 | + } else if (sof_nau8825_quirk & | |
| 470 | + SOF_MAX98360A_SPEAKER_AMP_PRESENT) { | |
| 471 | + max_98360a_dai_link(&links[id]); | |
| 472 | + } else { | |
| 473 | + goto devm_err; | |
| 474 | + } | |
| 475 | + | |
| 476 | + links[id].platforms = platform_component; | |
| 477 | + links[id].num_platforms = ARRAY_SIZE(platform_component); | |
| 478 | + links[id].dpcm_playback = 1; | |
| 479 | + links[id].no_pcm = 1; | |
| 480 | + links[id].cpus = &cpus[id]; | |
| 481 | + links[id].num_cpus = 1; | |
| 482 | + links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, | |
| 483 | + "SSP%d Pin", | |
| 484 | + ssp_amp); | |
| 485 | + if (!links[id].cpus->dai_name) | |
| 486 | + goto devm_err; | |
| 487 | + id++; | |
| 488 | + } | |
| 489 | + | |
| 490 | + /* BT audio offload */ | |
| 491 | + if (sof_nau8825_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) { | |
| 492 | + int port = (sof_nau8825_quirk & SOF_BT_OFFLOAD_SSP_MASK) >> | |
| 493 | + SOF_BT_OFFLOAD_SSP_SHIFT; | |
| 494 | + | |
| 495 | + links[id].id = id; | |
| 496 | + links[id].cpus = &cpus[id]; | |
| 497 | + links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, | |
| 498 | + "SSP%d Pin", port); | |
| 499 | + if (!links[id].cpus->dai_name) | |
| 500 | + goto devm_err; | |
| 501 | + links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port); | |
| 502 | + if (!links[id].name) | |
| 503 | + goto devm_err; | |
| 504 | + links[id].codecs = dummy_component; | |
| 505 | + links[id].num_codecs = ARRAY_SIZE(dummy_component); | |
| 506 | + links[id].platforms = platform_component; | |
| 507 | + links[id].num_platforms = ARRAY_SIZE(platform_component); | |
| 508 | + links[id].dpcm_playback = 1; | |
| 509 | + links[id].dpcm_capture = 1; | |
| 510 | + links[id].no_pcm = 1; | |
| 511 | + links[id].num_cpus = 1; | |
| 512 | + } | |
| 513 | + | |
| 514 | + return links; | |
| 515 | +devm_err: | |
| 516 | + return NULL; | |
| 517 | +} | |
| 518 | + | |
| 519 | +static int sof_audio_probe(struct platform_device *pdev) | |
| 520 | +{ | |
| 521 | + struct snd_soc_dai_link *dai_links; | |
| 522 | + struct snd_soc_acpi_mach *mach; | |
| 523 | + struct sof_card_private *ctx; | |
| 524 | + int dmic_be_num, hdmi_num; | |
| 525 | + int ret, ssp_amp, ssp_codec; | |
| 526 | + | |
| 527 | + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); | |
| 528 | + if (!ctx) | |
| 529 | + return -ENOMEM; | |
| 530 | + | |
| 531 | + if (pdev->id_entry && pdev->id_entry->driver_data) | |
| 532 | + sof_nau8825_quirk = (unsigned long)pdev->id_entry->driver_data; | |
| 533 | + | |
| 534 | + mach = pdev->dev.platform_data; | |
| 535 | + | |
| 536 | + /* A speaker amp might not be present when the quirk claims one is. | |
| 537 | + * Detect this via whether the machine driver match includes quirk_data. | |
| 538 | + */ | |
| 539 | + if ((sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data) | |
| 540 | + sof_nau8825_quirk &= ~SOF_SPEAKER_AMP_PRESENT; | |
| 541 | + | |
| 542 | + dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk); | |
| 543 | + | |
| 544 | + /* default number of DMIC DAI's */ | |
| 545 | + dmic_be_num = 2; | |
| 546 | + hdmi_num = (sof_nau8825_quirk & SOF_NAU8825_NUM_HDMIDEV_MASK) >> | |
| 547 | + SOF_NAU8825_NUM_HDMIDEV_SHIFT; | |
| 548 | + /* default number of HDMI DAI's */ | |
| 549 | + if (!hdmi_num) | |
| 550 | + hdmi_num = 3; | |
| 551 | + | |
| 552 | + ssp_amp = (sof_nau8825_quirk & SOF_NAU8825_SSP_AMP_MASK) >> | |
| 553 | + SOF_NAU8825_SSP_AMP_SHIFT; | |
| 554 | + | |
| 555 | + ssp_codec = sof_nau8825_quirk & SOF_NAU8825_SSP_CODEC_MASK; | |
| 556 | + | |
| 557 | + /* compute number of dai links */ | |
| 558 | + sof_audio_card_nau8825.num_links = 1 + dmic_be_num + hdmi_num; | |
| 559 | + | |
| 560 | + if (sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) | |
| 561 | + sof_audio_card_nau8825.num_links++; | |
| 562 | + | |
| 563 | + if (sof_nau8825_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) | |
| 564 | + max_98373_set_codec_conf(&sof_audio_card_nau8825); | |
| 565 | + | |
| 566 | + if (sof_nau8825_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) | |
| 567 | + sof_audio_card_nau8825.num_links++; | |
| 568 | + | |
| 569 | + dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp, | |
| 570 | + dmic_be_num, hdmi_num); | |
| 571 | + if (!dai_links) | |
| 572 | + return -ENOMEM; | |
| 573 | + | |
| 574 | + sof_audio_card_nau8825.dai_link = dai_links; | |
| 575 | + | |
| 576 | + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); | |
| 577 | + | |
| 578 | + sof_audio_card_nau8825.dev = &pdev->dev; | |
| 579 | + | |
| 580 | + /* set platform name for each dailink */ | |
| 581 | + ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_nau8825, | |
| 582 | + mach->mach_params.platform); | |
| 583 | + if (ret) | |
| 584 | + return ret; | |
| 585 | + | |
| 586 | + snd_soc_card_set_drvdata(&sof_audio_card_nau8825, ctx); | |
| 587 | + | |
| 588 | + return devm_snd_soc_register_card(&pdev->dev, | |
| 589 | + &sof_audio_card_nau8825); | |
| 590 | +} | |
| 591 | + | |
| 592 | +static const struct platform_device_id board_ids[] = { | |
| 593 | + { | |
| 594 | + .name = "sof_nau8825", | |
| 595 | + .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | | |
| 596 | + SOF_NAU8825_NUM_HDMIDEV(4) | | |
| 597 | + SOF_BT_OFFLOAD_SSP(2) | | |
| 598 | + SOF_SSP_BT_OFFLOAD_PRESENT), | |
| 599 | + | |
| 600 | + }, | |
| 601 | + { | |
| 602 | + .name = "adl_rt1019p_nau8825", | |
| 603 | + .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | | |
| 604 | + SOF_SPEAKER_AMP_PRESENT | | |
| 605 | + SOF_RT1019P_SPEAKER_AMP_PRESENT | | |
| 606 | + SOF_NAU8825_SSP_AMP(2) | | |
| 607 | + SOF_NAU8825_NUM_HDMIDEV(4)), | |
| 608 | + }, | |
| 609 | + { | |
| 610 | + .name = "adl_max98373_nau8825", | |
| 611 | + .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | | |
| 612 | + SOF_SPEAKER_AMP_PRESENT | | |
| 613 | + SOF_MAX98373_SPEAKER_AMP_PRESENT | | |
| 614 | + SOF_NAU8825_SSP_AMP(1) | | |
| 615 | + SOF_NAU8825_NUM_HDMIDEV(4) | | |
| 616 | + SOF_BT_OFFLOAD_SSP(2) | | |
| 617 | + SOF_SSP_BT_OFFLOAD_PRESENT), | |
| 618 | + }, | |
| 619 | + { | |
| 620 | + /* The limitation of length of char array, shorten the name */ | |
| 621 | + .name = "adl_mx98360a_nau8825", | |
| 622 | + .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | | |
| 623 | + SOF_SPEAKER_AMP_PRESENT | | |
| 624 | + SOF_MAX98360A_SPEAKER_AMP_PRESENT | | |
| 625 | + SOF_NAU8825_SSP_AMP(1) | | |
| 626 | + SOF_NAU8825_NUM_HDMIDEV(4) | | |
| 627 | + SOF_BT_OFFLOAD_SSP(2) | | |
| 628 | + SOF_SSP_BT_OFFLOAD_PRESENT), | |
| 629 | + | |
| 630 | + }, | |
| 631 | + { } | |
| 632 | +}; | |
| 633 | +MODULE_DEVICE_TABLE(platform, board_ids); | |
| 634 | + | |
| 635 | +static struct platform_driver sof_audio = { | |
| 636 | + .probe = sof_audio_probe, | |
| 637 | + .driver = { | |
| 638 | + .name = "sof_nau8825", | |
| 639 | + .pm = &snd_soc_pm_ops, | |
| 640 | + }, | |
| 641 | + .id_table = board_ids, | |
| 642 | +}; | |
| 643 | +module_platform_driver(sof_audio) | |
| 644 | + | |
| 645 | +/* Module information */ | |
| 646 | +MODULE_DESCRIPTION("SOF Audio Machine driver for NAU8825"); | |
| 647 | +MODULE_AUTHOR("David Lin <ctlin0@nuvoton.com>"); | |
| 648 | +MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>"); | |
| 649 | +MODULE_LICENSE("GPL"); | |
| 650 | +MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); | |
| 651 | +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); | |
| @@ -12,12 +12,13 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <sound/soc-dapm.h> |
| 13 | 13 | #include <uapi/sound/asound.h> |
| 14 | 14 | #include "../../codecs/rt1011.h" |
| 15 | +#include "../../codecs/rt1015.h" | |
| 15 | 16 | #include "sof_realtek_common.h" |
| 16 | 17 | |
| 17 | 18 | /* |
| 18 | 19 | * Current only 2-amp configuration is supported for rt1011 |
| 19 | 20 | */ |
| 20 | −static const struct snd_soc_dapm_route rt1011_dapm_routes[] = { | |
| 21 | +static const struct snd_soc_dapm_route speaker_map_lr[] = { | |
| 21 | 22 | /* speaker */ |
| 22 | 23 | { "Left Spk", NULL, "Left SPO" }, |
| 23 | 24 | { "Right Spk", NULL, "Right SPO" }, |
| @@ -117,8 +118,8 @@ static int rt1011_init(struct snd_soc_pcm_runtime *rtd) · 93 unmodified lines | ||
| 117 | 118 | struct snd_soc_card *card = rtd->card; |
| 118 | 119 | int ret; |
| 119 | 120 | |
| 120 | − ret = snd_soc_dapm_add_routes(&card->dapm, rt1011_dapm_routes, | |
| 121 | − ARRAY_SIZE(rt1011_dapm_routes)); | |
| 121 | + ret = snd_soc_dapm_add_routes(&card->dapm, speaker_map_lr, | |
| 122 | + ARRAY_SIZE(speaker_map_lr)); | |
| 122 | 123 | if (ret) |
| 123 | 124 | dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret); |
| 124 | 125 | return ret; |
| @@ -241,3 +242,115 @@ void sof_rt1015p_codec_conf(struct snd_soc_card *card) · 116 unmodified lines | ||
| 241 | 242 | card->codec_conf = rt1015p_codec_confs; |
| 242 | 243 | card->num_configs = ARRAY_SIZE(rt1015p_codec_confs); |
| 243 | 244 | } |
| 245 | + | |
| 246 | +/* | |
| 247 | + * RT1015 audio amplifier | |
| 248 | + */ | |
| 249 | + | |
| 250 | +static int rt1015_hw_params(struct snd_pcm_substream *substream, | |
| 251 | + struct snd_pcm_hw_params *params) | |
| 252 | +{ | |
| 253 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); | |
| 254 | + struct snd_soc_dai *codec_dai; | |
| 255 | + int i, fs = 64, ret; | |
| 256 | + | |
| 257 | + for_each_rtd_codec_dais(rtd, i, codec_dai) { | |
| 258 | + ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK, | |
| 259 | + params_rate(params) * fs, | |
| 260 | + params_rate(params) * 256); | |
| 261 | + if (ret) | |
| 262 | + return ret; | |
| 263 | + | |
| 264 | + ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL, | |
| 265 | + params_rate(params) * 256, | |
| 266 | + SND_SOC_CLOCK_IN); | |
| 267 | + if (ret) | |
| 268 | + return ret; | |
| 269 | + } | |
| 270 | + | |
| 271 | + return 0; | |
| 272 | +} | |
| 273 | + | |
| 274 | +static int rt1015_hw_params_pll_and_tdm(struct snd_pcm_substream *substream, | |
| 275 | + struct snd_pcm_hw_params *params) | |
| 276 | +{ | |
| 277 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); | |
| 278 | + struct snd_soc_dai *codec_dai; | |
| 279 | + int i, fs = 100, ret; | |
| 280 | + | |
| 281 | + for_each_rtd_codec_dais(rtd, i, codec_dai) { | |
| 282 | + ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK, | |
| 283 | + params_rate(params) * fs, | |
| 284 | + params_rate(params) * 256); | |
| 285 | + if (ret) | |
| 286 | + return ret; | |
| 287 | + | |
| 288 | + ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL, | |
| 289 | + params_rate(params) * 256, | |
| 290 | + SND_SOC_CLOCK_IN); | |
| 291 | + if (ret) | |
| 292 | + return ret; | |
| 293 | + } | |
| 294 | + /* rx slot 1 for RT1015_DEV0_NAME */ | |
| 295 | + ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 0), | |
| 296 | + 0x0, 0x1, 4, 24); | |
| 297 | + if (ret) | |
| 298 | + return ret; | |
| 299 | + | |
| 300 | + /* rx slot 2 for RT1015_DEV1_NAME */ | |
| 301 | + ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 1), | |
| 302 | + 0x0, 0x2, 4, 24); | |
| 303 | + if (ret) | |
| 304 | + return ret; | |
| 305 | + | |
| 306 | + return 0; | |
| 307 | +} | |
| 308 | + | |
| 309 | +static struct snd_soc_ops rt1015_ops = { | |
| 310 | + .hw_params = rt1015_hw_params, | |
| 311 | +}; | |
| 312 | + | |
| 313 | +static struct snd_soc_codec_conf rt1015_amp_conf[] = { | |
| 314 | + { | |
| 315 | + .dlc = COMP_CODEC_CONF(RT1015_DEV0_NAME), | |
| 316 | + .name_prefix = "Left", | |
| 317 | + }, | |
| 318 | + { | |
| 319 | + .dlc = COMP_CODEC_CONF(RT1015_DEV1_NAME), | |
| 320 | + .name_prefix = "Right", | |
| 321 | + }, | |
| 322 | +}; | |
| 323 | + | |
| 324 | +static struct snd_soc_dai_link_component rt1015_components[] = { | |
| 325 | + { | |
| 326 | + .name = RT1015_DEV0_NAME, | |
| 327 | + .dai_name = RT1015_CODEC_DAI, | |
| 328 | + }, | |
| 329 | + { | |
| 330 | + .name = RT1015_DEV1_NAME, | |
| 331 | + .dai_name = RT1015_CODEC_DAI, | |
| 332 | + }, | |
| 333 | +}; | |
| 334 | + | |
| 335 | +static int speaker_codec_init_lr(struct snd_soc_pcm_runtime *rtd) | |
| 336 | +{ | |
| 337 | + return snd_soc_dapm_add_routes(&rtd->card->dapm, speaker_map_lr, | |
| 338 | + ARRAY_SIZE(speaker_map_lr)); | |
| 339 | +} | |
| 340 | + | |
| 341 | +void sof_rt1015_codec_conf(struct snd_soc_card *card) | |
| 342 | +{ | |
| 343 | + card->codec_conf = rt1015_amp_conf; | |
| 344 | + card->num_configs = ARRAY_SIZE(rt1015_amp_conf); | |
| 345 | +} | |
| 346 | + | |
| 347 | +void sof_rt1015_dai_link(struct snd_soc_dai_link *link, unsigned int fs) | |
| 348 | +{ | |
| 349 | + link->codecs = rt1015_components; | |
| 350 | + link->num_codecs = ARRAY_SIZE(rt1015_components); | |
| 351 | + link->init = speaker_codec_init_lr; | |
| 352 | + link->ops = &rt1015_ops; | |
| 353 | + | |
| 354 | + if (fs == 100) | |
| 355 | + rt1015_ops.hw_params = rt1015_hw_params_pll_and_tdm; | |
| 356 | +} | |
| @@ -28,4 +28,11 @@ void sof_rt1011_codec_conf(struct snd_soc_card *card); · 27 unmodified lines | ||
| 28 | 28 | void sof_rt1015p_dai_link(struct snd_soc_dai_link *link); |
| 29 | 29 | void sof_rt1015p_codec_conf(struct snd_soc_card *card); |
| 30 | 30 | |
| 31 | +#define RT1015_CODEC_DAI "rt1015-aif" | |
| 32 | +#define RT1015_DEV0_NAME "i2c-10EC1015:00" | |
| 33 | +#define RT1015_DEV1_NAME "i2c-10EC1015:01" | |
| 34 | + | |
| 35 | +void sof_rt1015_dai_link(struct snd_soc_dai_link *link, unsigned int fs); | |
| 36 | +void sof_rt1015_codec_conf(struct snd_soc_card *card); | |
| 37 | + | |
| 31 | 38 | #endif /* __SOF_REALTEK_COMMON_H */ |
| @@ -20,7 +20,6 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <sound/rt5682.h> |
| 21 | 21 | #include <sound/rt5682s.h> |
| 22 | 22 | #include <sound/soc-acpi.h> |
| 23 | −#include "../../codecs/rt1015.h" | |
| 24 | 23 | #include "../../codecs/rt5682.h" |
| 25 | 24 | #include "../../codecs/rt5682s.h" |
| 26 | 25 | #include "../../codecs/hdac_hdmi.h" |
| @@ -59,6 +58,9 @@ · 32 unmodified lines | ||
| 59 | 58 | (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) |
| 60 | 59 | #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(22) |
| 61 | 60 | #define SOF_RT5682S_HEADPHONE_CODEC_PRESENT BIT(23) |
| 61 | +#define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(24) | |
| 62 | +#define SOF_MAX98390_TWEETER_SPEAKER_PRESENT BIT(25) | |
| 63 | + | |
| 62 | 64 | |
| 63 | 65 | /* Default: MCLK on, MCLK 19.2M, SSP0 */ |
| 64 | 66 | static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN | |
| @@ -179,6 +181,36 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { · 114 unmodified lines | ||
| 179 | 181 | SOF_RT5682_SSP_AMP(2) | |
| 180 | 182 | SOF_RT5682_NUM_HDMIDEV(4)), |
| 181 | 183 | }, |
| 184 | + { | |
| 185 | + .callback = sof_rt5682_quirk_cb, | |
| 186 | + .matches = { | |
| 187 | + DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"), | |
| 188 | + DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S"), | |
| 189 | + }, | |
| 190 | + .driver_data = (void *)(SOF_RT5682_MCLK_EN | | |
| 191 | + SOF_RT5682_SSP_CODEC(0) | | |
| 192 | + SOF_SPEAKER_AMP_PRESENT | | |
| 193 | + SOF_MAX98390_SPEAKER_AMP_PRESENT | | |
| 194 | + SOF_RT5682_SSP_AMP(2) | | |
| 195 | + SOF_RT5682_NUM_HDMIDEV(4)), | |
| 196 | + }, | |
| 197 | + { | |
| 198 | + .callback = sof_rt5682_quirk_cb, | |
| 199 | + .matches = { | |
| 200 | + DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"), | |
| 201 | + DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S_4SPK"), | |
| 202 | + }, | |
| 203 | + .driver_data = (void *)(SOF_RT5682_MCLK_EN | | |
| 204 | + SOF_RT5682_SSP_CODEC(0) | | |
| 205 | + SOF_SPEAKER_AMP_PRESENT | | |
| 206 | + SOF_MAX98390_SPEAKER_AMP_PRESENT | | |
| 207 | + SOF_MAX98390_TWEETER_SPEAKER_PRESENT | | |
| 208 | + SOF_RT5682_SSP_AMP(1) | | |
| 209 | + SOF_RT5682_NUM_HDMIDEV(4) | | |
| 210 | + SOF_BT_OFFLOAD_SSP(2) | | |
| 211 | + SOF_SSP_BT_OFFLOAD_PRESENT), | |
| 212 | + | |
| 213 | + }, | |
| 182 | 214 | {} |
| 183 | 215 | }; |
| 184 | 216 | |
| @@ -367,67 +399,6 @@ static struct snd_soc_ops sof_rt5682_ops = { · 182 unmodified lines | ||
| 367 | 399 | .hw_params = sof_rt5682_hw_params, |
| 368 | 400 | }; |
| 369 | 401 | |
| 370 | −static int sof_rt1015_hw_params(struct snd_pcm_substream *substream, | |
| 371 | − struct snd_pcm_hw_params *params) | |
| 372 | −{ | |
| 373 | − struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); | |
| 374 | − struct snd_soc_card *card = rtd->card; | |
| 375 | − struct snd_soc_dai *codec_dai; | |
| 376 | − int i, fs, ret; | |
| 377 | − | |
| 378 | − if (!snd_soc_card_get_codec_dai(card, "rt1015-aif")) | |
| 379 | − return 0; | |
| 380 | − | |
| 381 | − if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_100FS) | |
| 382 | − fs = 100; | |
| 383 | − else | |
| 384 | − fs = 64; | |
| 385 | − | |
| 386 | − for_each_rtd_codec_dais(rtd, i, codec_dai) { | |
| 387 | − ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK, | |
| 388 | − params_rate(params) * fs, | |
| 389 | − params_rate(params) * 256); | |
| 390 | − if (ret < 0) { | |
| 391 | − dev_err(card->dev, "failed to set pll\n"); | |
| 392 | − return ret; | |
| 393 | − } | |
| 394 | − /* Configure sysclk for codec */ | |
| 395 | − ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL, | |
| 396 | − params_rate(params) * 256, | |
| 397 | − SND_SOC_CLOCK_IN); | |
| 398 | − if (ret < 0) { | |
| 399 | − dev_err(card->dev, "failed to set sysclk\n"); | |
| 400 | − return ret; | |
| 401 | − } | |
| 402 | − | |
| 403 | − if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_100FS) { | |
| 404 | − if (!strcmp(codec_dai->component->name, "i2c-10EC1015:00")) { | |
| 405 | − ret = snd_soc_dai_set_tdm_slot(codec_dai, | |
| 406 | − 0x0, 0x1, 4, 24); | |
| 407 | − if (ret < 0) { | |
| 408 | − dev_err(card->dev, "failed to set tdm slot\n"); | |
| 409 | − return ret; | |
| 410 | − } | |
| 411 | − } | |
| 412 | − | |
| 413 | − if (!strcmp(codec_dai->component->name, "i2c-10EC1015:01")) { | |
| 414 | − ret = snd_soc_dai_set_tdm_slot(codec_dai, | |
| 415 | − 0x0, 0x2, 4, 24); | |
| 416 | − if (ret < 0) { | |
| 417 | − dev_err(card->dev, "failed to set tdm slot\n"); | |
| 418 | − return ret; | |
| 419 | − } | |
| 420 | − } | |
| 421 | − } | |
| 422 | − } | |
| 423 | − | |
| 424 | − return 0; | |
| 425 | −} | |
| 426 | − | |
| 427 | −static struct snd_soc_ops sof_rt1015_ops = { | |
| 428 | − .hw_params = sof_rt1015_hw_params, | |
| 429 | −}; | |
| 430 | − | |
| 431 | 402 | static struct snd_soc_dai_link_component platform_component[] = { |
| 432 | 403 | { |
| 433 | 404 | /* name might be overridden during probe */ |
| @@ -486,6 +457,7 @@ static int sof_card_late_probe(struct snd_soc_card *card) · 52 unmodified lines | ||
| 486 | 457 | if (err < 0) |
| 487 | 458 | return err; |
| 488 | 459 | } |
| 460 | + | |
| 489 | 461 | return hdac_hdmi_jack_port_init(component, &card->dapm); |
| 490 | 462 | } |
| 491 | 463 | |
| @@ -517,22 +489,11 @@ static const struct snd_soc_dapm_route sof_map[] = { · 25 unmodified lines | ||
| 517 | 489 | { "IN1P", NULL, "Headset Mic" }, |
| 518 | 490 | }; |
| 519 | 491 | |
| 520 | −static const struct snd_soc_dapm_route speaker_map_lr[] = { | |
| 521 | − { "Left Spk", NULL, "Left SPO" }, | |
| 522 | − { "Right Spk", NULL, "Right SPO" }, | |
| 523 | −}; | |
| 524 | − | |
| 525 | 492 | static const struct snd_soc_dapm_route dmic_map[] = { |
| 526 | 493 | /* digital mics */ |
| 527 | 494 | {"DMic", NULL, "SoC DMIC"}, |
| 528 | 495 | }; |
| 529 | 496 | |
| 530 | −static int speaker_codec_init_lr(struct snd_soc_pcm_runtime *rtd) | |
| 531 | −{ | |
| 532 | − return snd_soc_dapm_add_routes(&rtd->card->dapm, speaker_map_lr, | |
| 533 | − ARRAY_SIZE(speaker_map_lr)); | |
| 534 | −} | |
| 535 | − | |
| 536 | 497 | static int dmic_init(struct snd_soc_pcm_runtime *rtd) |
| 537 | 498 | { |
| 538 | 499 | struct snd_soc_card *card = rtd->card; |
| @@ -555,17 +516,6 @@ static int dmic_init(struct snd_soc_pcm_runtime *rtd) · 16 unmodified lines | ||
| 555 | 516 | return ret; |
| 556 | 517 | } |
| 557 | 518 | |
| 558 | −static struct snd_soc_codec_conf rt1015_amp_conf[] = { | |
| 559 | − { | |
| 560 | − .dlc = COMP_CODEC_CONF("i2c-10EC1015:00"), | |
| 561 | − .name_prefix = "Left", | |
| 562 | − }, | |
| 563 | − { | |
| 564 | − .dlc = COMP_CODEC_CONF("i2c-10EC1015:01"), | |
| 565 | − .name_prefix = "Right", | |
| 566 | − }, | |
| 567 | −}; | |
| 568 | − | |
| 569 | 519 | /* sof audio machine driver for rt5682 codec */ |
| 570 | 520 | static struct snd_soc_card sof_audio_card_rt5682 = { |
| 571 | 521 | .name = "rt5682", /* the sof- prefix is added by the core */ |
| @@ -601,17 +551,6 @@ static struct snd_soc_dai_link_component dmic_component[] = { · 29 unmodified lines | ||
| 601 | 551 | } |
| 602 | 552 | }; |
| 603 | 553 | |
| 604 | −static struct snd_soc_dai_link_component rt1015_components[] = { | |
| 605 | − { | |
| 606 | − .name = "i2c-10EC1015:00", | |
| 607 | − .dai_name = "rt1015-aif", | |
| 608 | − }, | |
| 609 | − { | |
| 610 | − .name = "i2c-10EC1015:01", | |
| 611 | − .dai_name = "rt1015-aif", | |
| 612 | − }, | |
| 613 | −}; | |
| 614 | − | |
| 615 | 554 | static struct snd_soc_dai_link_component dummy_component[] = { |
| 616 | 555 | { |
| 617 | 556 | .name = "snd-soc-dummy", |
| @@ -764,10 +703,8 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, · 146 unmodified lines | ||
| 764 | 703 | |
| 765 | 704 | links[id].id = id; |
| 766 | 705 | if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) { |
| 767 | − links[id].codecs = rt1015_components; | |
| 768 | − links[id].num_codecs = ARRAY_SIZE(rt1015_components); | |
| 769 | − links[id].init = speaker_codec_init_lr; | |
| 770 | − links[id].ops = &sof_rt1015_ops; | |
| 706 | + sof_rt1015_dai_link(&links[id], (sof_rt5682_quirk & | |
| 707 | + SOF_RT1015_SPEAKER_AMP_100FS) ? 100 : 64); | |
| 771 | 708 | } else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) { |
| 772 | 709 | sof_rt1015p_dai_link(&links[id]); |
| 773 | 710 | } else if (sof_rt5682_quirk & |
| @@ -784,6 +721,20 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, · 10 unmodified lines | ||
| 784 | 721 | } else if (sof_rt5682_quirk & |
| 785 | 722 | SOF_RT1011_SPEAKER_AMP_PRESENT) { |
| 786 | 723 | sof_rt1011_dai_link(&links[id]); |
| 724 | + } else if (sof_rt5682_quirk & | |
| 725 | + SOF_MAX98390_SPEAKER_AMP_PRESENT) { | |
| 726 | + if (sof_rt5682_quirk & | |
| 727 | + SOF_MAX98390_TWEETER_SPEAKER_PRESENT) { | |
| 728 | + links[id].codecs = max_98390_4spk_components; | |
| 729 | + links[id].num_codecs = ARRAY_SIZE(max_98390_4spk_components); | |
| 730 | + } else { | |
| 731 | + links[id].codecs = max_98390_components; | |
| 732 | + links[id].num_codecs = ARRAY_SIZE(max_98390_components); | |
| 733 | + } | |
| 734 | + links[id].init = max_98390_spk_codec_init; | |
| 735 | + links[id].ops = &max_98390_ops; | |
| 736 | + links[id].dpcm_capture = 1; | |
| 737 | + | |
| 787 | 738 | } else { |
| 788 | 739 | max_98357a_dai_link(&links[id]); |
| 789 | 740 | } |
| @@ -868,6 +819,10 @@ static int sof_audio_probe(struct platform_device *pdev) · 78 unmodified lines | ||
| 868 | 819 | if (acpi_dev_present("RTL5682", NULL, -1)) |
| 869 | 820 | sof_rt5682_quirk |= SOF_RT5682S_HEADPHONE_CODEC_PRESENT; |
| 870 | 821 | |
| 822 | + /* Detect the headset codec variant to support machines in DMI quirk */ | |
| 823 | + if (acpi_dev_present("RTL5682", NULL, -1)) | |
| 824 | + sof_rt5682_quirk |= SOF_RT5682S_HEADPHONE_CODEC_PRESENT; | |
| 825 | + | |
| 871 | 826 | if (soc_intel_is_byt() || soc_intel_is_cht()) { |
| 872 | 827 | is_legacy_cpu = 1; |
| 873 | 828 | dmic_be_num = 0; |
| @@ -924,6 +879,14 @@ static int sof_audio_probe(struct platform_device *pdev) · 50 unmodified lines | ||
| 924 | 879 | sof_rt1011_codec_conf(&sof_audio_card_rt5682); |
| 925 | 880 | else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) |
| 926 | 881 | sof_rt1015p_codec_conf(&sof_audio_card_rt5682); |
| 882 | + else if (sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT) { | |
| 883 | + if (sof_rt5682_quirk & SOF_MAX98390_TWEETER_SPEAKER_PRESENT) | |
| 884 | + max_98390_set_codec_conf(&sof_audio_card_rt5682, | |
| 885 | + ARRAY_SIZE(max_98390_4spk_components)); | |
| 886 | + else | |
| 887 | + max_98390_set_codec_conf(&sof_audio_card_rt5682, | |
| 888 | + ARRAY_SIZE(max_98390_components)); | |
| 889 | + } | |
| 927 | 890 | |
| 928 | 891 | if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) |
| 929 | 892 | sof_audio_card_rt5682.num_links++; |
| @@ -935,10 +898,8 @@ static int sof_audio_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 935 | 898 | |
| 936 | 899 | sof_audio_card_rt5682.dai_link = dai_links; |
| 937 | 900 | |
| 938 | − if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) { | |
| 939 | − sof_audio_card_rt5682.codec_conf = rt1015_amp_conf; | |
| 940 | − sof_audio_card_rt5682.num_configs = ARRAY_SIZE(rt1015_amp_conf); | |
| 941 | − } | |
| 901 | + if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) | |
| 902 | + sof_rt1015_codec_conf(&sof_audio_card_rt5682); | |
| 942 | 903 | |
| 943 | 904 | INIT_LIST_HEAD(&ctx->hdmi_pcm_list); |
| 944 | 905 | |
| @@ -1050,6 +1011,17 @@ static const struct platform_device_id board_ids[] = { · 105 unmodified lines | ||
| 1050 | 1011 | SOF_RT5682_SSP_AMP(2) | |
| 1051 | 1012 | SOF_RT5682_NUM_HDMIDEV(4)), |
| 1052 | 1013 | }, |
| 1014 | + { | |
| 1015 | + .name = "adl_max98390_rt5682", | |
| 1016 | + .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | | |
| 1017 | + SOF_RT5682_SSP_CODEC(0) | | |
| 1018 | + SOF_SPEAKER_AMP_PRESENT | | |
| 1019 | + SOF_MAX98390_SPEAKER_AMP_PRESENT | | |
| 1020 | + SOF_RT5682_SSP_AMP(1) | | |
| 1021 | + SOF_RT5682_NUM_HDMIDEV(4) | | |
| 1022 | + SOF_BT_OFFLOAD_SSP(2) | | |
| 1023 | + SOF_SSP_BT_OFFLOAD_PRESENT), | |
| 1024 | + }, | |
| 1053 | 1025 | { |
| 1054 | 1026 | .name = "adl_mx98360_rt5682", |
| 1055 | 1027 | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | |
| @@ -1080,6 +1052,7 @@ MODULE_DESCRIPTION("SOF Audio Machine driver"); · 24 unmodified lines | ||
| 1080 | 1052 | MODULE_AUTHOR("Bard Liao <bard.liao@intel.com>"); |
| 1081 | 1053 | MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>"); |
| 1082 | 1054 | MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); |
| 1055 | +MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>"); | |
| 1083 | 1056 | MODULE_LICENSE("GPL v2"); |
| 1084 | 1057 | MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); |
| 1085 | 1058 | MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); |
| @@ -36,8 +36,6 @@ static void log_quirks(struct device *dev) · 35 unmodified lines | ||
| 36 | 36 | if (SOF_SSP_GET_PORT(sof_sdw_quirk)) |
| 37 | 37 | dev_dbg(dev, "SSP port %ld\n", |
| 38 | 38 | SOF_SSP_GET_PORT(sof_sdw_quirk)); |
| 39 | − if (sof_sdw_quirk & SOF_RT715_DAI_ID_FIX) | |
| 40 | − dev_dbg(dev, "quirk SOF_RT715_DAI_ID_FIX enabled\n"); | |
| 41 | 39 | if (sof_sdw_quirk & SOF_SDW_NO_AGGREGATION) |
| 42 | 40 | dev_dbg(dev, "quirk SOF_SDW_NO_AGGREGATION enabled\n"); |
| 43 | 41 | } |
| @@ -64,8 +62,7 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 20 unmodified lines | ||
| 64 | 62 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), |
| 65 | 63 | DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "09C6") |
| 66 | 64 | }, |
| 67 | − .driver_data = (void *)(RT711_JD2 | | |
| 68 | − SOF_RT715_DAI_ID_FIX), | |
| 65 | + .driver_data = (void *)RT711_JD2, | |
| 69 | 66 | }, |
| 70 | 67 | { |
| 71 | 68 | /* early version of SKU 09C6 */ |
| @@ -74,8 +71,7 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 2 unmodified lines | ||
| 74 | 71 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), |
| 75 | 72 | DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0983") |
| 76 | 73 | }, |
| 77 | − .driver_data = (void *)(RT711_JD2 | | |
| 78 | − SOF_RT715_DAI_ID_FIX), | |
| 74 | + .driver_data = (void *)RT711_JD2, | |
| 79 | 75 | }, |
| 80 | 76 | { |
| 81 | 77 | .callback = sof_sdw_quirk_cb, |
| @@ -84,7 +80,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 2 unmodified lines | ||
| 84 | 80 | DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "098F"), |
| 85 | 81 | }, |
| 86 | 82 | .driver_data = (void *)(RT711_JD2 | |
| 87 | − SOF_RT715_DAI_ID_FIX | | |
| 88 | 83 | SOF_SDW_FOUR_SPK), |
| 89 | 84 | }, |
| 90 | 85 | { |
| @@ -94,7 +89,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 3 unmodified lines | ||
| 94 | 89 | DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0990"), |
| 95 | 90 | }, |
| 96 | 91 | .driver_data = (void *)(RT711_JD2 | |
| 97 | − SOF_RT715_DAI_ID_FIX | | |
| 98 | 92 | SOF_SDW_FOUR_SPK), |
| 99 | 93 | }, |
| 100 | 94 | /* IceLake devices */ |
| @@ -126,8 +120,17 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 25 unmodified lines | ||
| 126 | 120 | DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A3E") |
| 127 | 121 | }, |
| 128 | 122 | .driver_data = (void *)(SOF_SDW_TGL_HDMI | |
| 129 | − RT711_JD2 | | |
| 130 | − SOF_RT715_DAI_ID_FIX), | |
| 123 | + RT711_JD2), | |
| 124 | + }, | |
| 125 | + { | |
| 126 | + /* another SKU of Dell Latitude 9520 */ | |
| 127 | + .callback = sof_sdw_quirk_cb, | |
| 128 | + .matches = { | |
| 129 | + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), | |
| 130 | + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A3F") | |
| 131 | + }, | |
| 132 | + .driver_data = (void *)(SOF_SDW_TGL_HDMI | | |
| 133 | + RT711_JD2), | |
| 131 | 134 | }, |
| 132 | 135 | { |
| 133 | 136 | /* Dell XPS 9710 */ |
| @@ -138,7 +141,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 4 unmodified lines | ||
| 138 | 141 | }, |
| 139 | 142 | .driver_data = (void *)(SOF_SDW_TGL_HDMI | |
| 140 | 143 | RT711_JD2 | |
| 141 | − SOF_RT715_DAI_ID_FIX | | |
| 142 | 144 | SOF_SDW_FOUR_SPK), |
| 143 | 145 | }, |
| 144 | 146 | { |
| @@ -149,7 +151,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 4 unmodified lines | ||
| 149 | 151 | }, |
| 150 | 152 | .driver_data = (void *)(SOF_SDW_TGL_HDMI | |
| 151 | 153 | RT711_JD2 | |
| 152 | − SOF_RT715_DAI_ID_FIX | | |
| 153 | 154 | SOF_SDW_FOUR_SPK), |
| 154 | 155 | }, |
| 155 | 156 | { |
| @@ -188,7 +189,7 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 32 unmodified lines | ||
| 188 | 189 | }, |
| 189 | 190 | .driver_data = (void *)(SOF_SDW_TGL_HDMI | |
| 190 | 191 | SOF_SDW_PCH_DMIC | |
| 191 | − RT711_JD2), | |
| 192 | + RT711_JD1), | |
| 192 | 193 | }, |
| 193 | 194 | { |
| 194 | 195 | /* NUC15 'Bishop County' LAPBC510 and LAPBC710 skews */ |
| @@ -210,7 +211,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 15 unmodified lines | ||
| 210 | 211 | }, |
| 211 | 212 | .driver_data = (void *)(SOF_SDW_TGL_HDMI | |
| 212 | 213 | RT711_JD2 | |
| 213 | − SOF_RT715_DAI_ID_FIX | | |
| 214 | 214 | SOF_SDW_FOUR_SPK), |
| 215 | 215 | }, |
| 216 | 216 | { |
| @@ -220,8 +220,7 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 3 unmodified lines | ||
| 220 | 220 | DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A45") |
| 221 | 221 | }, |
| 222 | 222 | .driver_data = (void *)(SOF_SDW_TGL_HDMI | |
| 223 | − RT711_JD2 | | |
| 224 | − SOF_RT715_DAI_ID_FIX), | |
| 223 | + RT711_JD2), | |
| 225 | 224 | }, |
| 226 | 225 | /* AlderLake devices */ |
| 227 | 226 | { |
| @@ -232,7 +231,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { · 4 unmodified lines | ||
| 232 | 231 | }, |
| 233 | 232 | .driver_data = (void *)(RT711_JD2_100K | |
| 234 | 233 | SOF_SDW_TGL_HDMI | |
| 235 | − SOF_RT715_DAI_ID_FIX | | |
| 236 | 234 | SOF_BT_OFFLOAD_SSP(2) | |
| 237 | 235 | SOF_SSP_BT_OFFLOAD_PRESENT), |
| 238 | 236 | }, |
| @@ -349,7 +347,7 @@ int sdw_prepare(struct snd_pcm_substream *substream) · 110 unmodified lines | ||
| 349 | 347 | /* Find stream from first CPU DAI */ |
| 350 | 348 | dai = asoc_rtd_to_cpu(rtd, 0); |
| 351 | 349 | |
| 352 | − sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream); | |
| 350 | + sdw_stream = snd_soc_dai_get_stream(dai, substream->stream); | |
| 353 | 351 | |
| 354 | 352 | if (IS_ERR(sdw_stream)) { |
| 355 | 353 | dev_err(rtd->dev, "no stream found for DAI %s", dai->name); |
| @@ -369,7 +367,7 @@ int sdw_trigger(struct snd_pcm_substream *substream, int cmd) · 13 unmodified lines | ||
| 369 | 367 | /* Find stream from first CPU DAI */ |
| 370 | 368 | dai = asoc_rtd_to_cpu(rtd, 0); |
| 371 | 369 | |
| 372 | − sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream); | |
| 370 | + sdw_stream = snd_soc_dai_get_stream(dai, substream->stream); | |
| 373 | 371 | |
| 374 | 372 | if (IS_ERR(sdw_stream)) { |
| 375 | 373 | dev_err(rtd->dev, "no stream found for DAI %s", dai->name); |
| @@ -408,7 +406,7 @@ int sdw_hw_free(struct snd_pcm_substream *substream) · 32 unmodified lines | ||
| 408 | 406 | /* Find stream from first CPU DAI */ |
| 409 | 407 | dai = asoc_rtd_to_cpu(rtd, 0); |
| 410 | 408 | |
| 411 | − sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream); | |
| 409 | + sdw_stream = snd_soc_dai_get_stream(dai, substream->stream); | |
| 412 | 410 | |
| 413 | 411 | if (IS_ERR(sdw_stream)) { |
| 414 | 412 | dev_err(rtd->dev, "no stream found for DAI %s", dai->name); |
| @@ -431,26 +429,13 @@ static const struct snd_soc_ops sdw_ops = { · 16 unmodified lines | ||
| 431 | 429 | .shutdown = sdw_shutdown, |
| 432 | 430 | }; |
| 433 | 431 | |
| 434 | −static int sof_sdw_mic_codec_mockup_init(struct snd_soc_card *card, | |
| 435 | − const struct snd_soc_acpi_link_adr *link, | |
| 436 | − struct snd_soc_dai_link *dai_links, | |
| 437 | − struct sof_sdw_codec_info *info, | |
| 438 | − bool playback) | |
| 439 | −{ | |
| 440 | − /* | |
| 441 | − * force DAI link to use same ID as RT715 and DMIC | |
| 442 | − * to reuse topologies | |
| 443 | − */ | |
| 444 | − dai_links->id = SDW_DMIC_DAI_ID; | |
| 445 | − return 0; | |
| 446 | −} | |
| 447 | − | |
| 448 | 432 | static struct sof_sdw_codec_info codec_info_list[] = { |
| 449 | 433 | { |
| 450 | 434 | .part_id = 0x700, |
| 451 | 435 | .direction = {true, true}, |
| 452 | 436 | .dai_name = "rt700-aif1", |
| 453 | 437 | .init = sof_sdw_rt700_init, |
| 438 | + .codec_type = SOF_SDW_CODEC_TYPE_JACK, | |
| 454 | 439 | }, |
| 455 | 440 | { |
| 456 | 441 | .part_id = 0x711, |
| @@ -459,6 +444,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 2 unmodified lines | ||
| 459 | 444 | .dai_name = "rt711-sdca-aif1", |
| 460 | 445 | .init = sof_sdw_rt711_sdca_init, |
| 461 | 446 | .exit = sof_sdw_rt711_sdca_exit, |
| 447 | + .codec_type = SOF_SDW_CODEC_TYPE_JACK, | |
| 462 | 448 | }, |
| 463 | 449 | { |
| 464 | 450 | .part_id = 0x711, |
| @@ -467,6 +453,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 2 unmodified lines | ||
| 467 | 453 | .dai_name = "rt711-aif1", |
| 468 | 454 | .init = sof_sdw_rt711_init, |
| 469 | 455 | .exit = sof_sdw_rt711_exit, |
| 456 | + .codec_type = SOF_SDW_CODEC_TYPE_JACK, | |
| 470 | 457 | }, |
| 471 | 458 | { |
| 472 | 459 | .part_id = 0x1308, |
| @@ -475,12 +462,14 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 2 unmodified lines | ||
| 475 | 462 | .dai_name = "rt1308-aif", |
| 476 | 463 | .ops = &sof_sdw_rt1308_i2s_ops, |
| 477 | 464 | .init = sof_sdw_rt1308_init, |
| 465 | + .codec_type = SOF_SDW_CODEC_TYPE_AMP, | |
| 478 | 466 | }, |
| 479 | 467 | { |
| 480 | 468 | .part_id = 0x1316, |
| 481 | 469 | .direction = {true, true}, |
| 482 | 470 | .dai_name = "rt1316-aif", |
| 483 | 471 | .init = sof_sdw_rt1316_init, |
| 472 | + .codec_type = SOF_SDW_CODEC_TYPE_AMP, | |
| 484 | 473 | }, |
| 485 | 474 | { |
| 486 | 475 | .part_id = 0x714, |
| @@ -489,6 +478,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 2 unmodified lines | ||
| 489 | 478 | .ignore_pch_dmic = true, |
| 490 | 479 | .dai_name = "rt715-aif2", |
| 491 | 480 | .init = sof_sdw_rt715_sdca_init, |
| 481 | + .codec_type = SOF_SDW_CODEC_TYPE_MIC, | |
| 492 | 482 | }, |
| 493 | 483 | { |
| 494 | 484 | .part_id = 0x715, |
| @@ -497,6 +487,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 2 unmodified lines | ||
| 497 | 487 | .ignore_pch_dmic = true, |
| 498 | 488 | .dai_name = "rt715-aif2", |
| 499 | 489 | .init = sof_sdw_rt715_sdca_init, |
| 490 | + .codec_type = SOF_SDW_CODEC_TYPE_MIC, | |
| 500 | 491 | }, |
| 501 | 492 | { |
| 502 | 493 | .part_id = 0x714, |
| @@ -505,6 +496,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 2 unmodified lines | ||
| 505 | 496 | .ignore_pch_dmic = true, |
| 506 | 497 | .dai_name = "rt715-aif2", |
| 507 | 498 | .init = sof_sdw_rt715_init, |
| 499 | + .codec_type = SOF_SDW_CODEC_TYPE_MIC, | |
| 508 | 500 | }, |
| 509 | 501 | { |
| 510 | 502 | .part_id = 0x715, |
| @@ -513,6 +505,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 2 unmodified lines | ||
| 513 | 505 | .ignore_pch_dmic = true, |
| 514 | 506 | .dai_name = "rt715-aif2", |
| 515 | 507 | .init = sof_sdw_rt715_init, |
| 508 | + .codec_type = SOF_SDW_CODEC_TYPE_MIC, | |
| 516 | 509 | }, |
| 517 | 510 | { |
| 518 | 511 | .part_id = 0x8373, |
| @@ -520,12 +513,14 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 1 unmodified line | ||
| 520 | 513 | .dai_name = "max98373-aif1", |
| 521 | 514 | .init = sof_sdw_mx8373_init, |
| 522 | 515 | .codec_card_late_probe = sof_sdw_mx8373_late_probe, |
| 516 | + .codec_type = SOF_SDW_CODEC_TYPE_AMP, | |
| 523 | 517 | }, |
| 524 | 518 | { |
| 525 | 519 | .part_id = 0x5682, |
| 526 | 520 | .direction = {true, true}, |
| 527 | 521 | .dai_name = "rt5682-sdw", |
| 528 | 522 | .init = sof_sdw_rt5682_init, |
| 523 | + .codec_type = SOF_SDW_CODEC_TYPE_JACK, | |
| 529 | 524 | }, |
| 530 | 525 | { |
| 531 | 526 | .part_id = 0xaaaa, /* generic codec mockup */ |
| @@ -533,6 +528,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 1 unmodified line | ||
| 533 | 528 | .direction = {true, true}, |
| 534 | 529 | .dai_name = "sdw-mockup-aif1", |
| 535 | 530 | .init = NULL, |
| 531 | + .codec_type = SOF_SDW_CODEC_TYPE_JACK, | |
| 536 | 532 | }, |
| 537 | 533 | { |
| 538 | 534 | .part_id = 0xaa55, /* headset codec mockup */ |
| @@ -540,6 +536,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 1 unmodified line | ||
| 540 | 536 | .direction = {true, true}, |
| 541 | 537 | .dai_name = "sdw-mockup-aif1", |
| 542 | 538 | .init = NULL, |
| 539 | + .codec_type = SOF_SDW_CODEC_TYPE_JACK, | |
| 543 | 540 | }, |
| 544 | 541 | { |
| 545 | 542 | .part_id = 0x55aa, /* amplifier mockup */ |
| @@ -547,13 +544,14 @@ static struct sof_sdw_codec_info codec_info_list[] = { · 1 unmodified line | ||
| 547 | 544 | .direction = {true, false}, |
| 548 | 545 | .dai_name = "sdw-mockup-aif1", |
| 549 | 546 | .init = NULL, |
| 547 | + .codec_type = SOF_SDW_CODEC_TYPE_AMP, | |
| 550 | 548 | }, |
| 551 | 549 | { |
| 552 | 550 | .part_id = 0x5555, |
| 553 | 551 | .version_id = 0, |
| 554 | 552 | .direction = {false, true}, |
| 555 | 553 | .dai_name = "sdw-mockup-aif1", |
| 556 | − .init = sof_sdw_mic_codec_mockup_init, | |
| 554 | + .codec_type = SOF_SDW_CODEC_TYPE_MIC, | |
| 557 | 555 | }, |
| 558 | 556 | }; |
| 559 | 557 | |
| @@ -601,10 +599,11 @@ static inline int find_codec_info_acpi(const u8 *acpi_id) · 41 unmodified lines | ||
| 601 | 599 | * Since some sdw slaves may be aggregated, the CPU DAI number |
| 602 | 600 | * may be larger than the number of BE dailinks. |
| 603 | 601 | */ |
| 604 | −static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links, | |
| 602 | +static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_link_adr *links, | |
| 605 | 603 | int *sdw_be_num, int *sdw_cpu_dai_num) |
| 606 | 604 | { |
| 607 | 605 | const struct snd_soc_acpi_link_adr *link; |
| 606 | + int _codec_type = SOF_SDW_CODEC_TYPE_JACK; | |
| 608 | 607 | bool group_visited[SDW_MAX_GROUPS]; |
| 609 | 608 | bool no_aggregation; |
| 610 | 609 | int i; |
| @@ -630,6 +629,12 @@ static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links, · 19 unmodified lines | ||
| 630 | 629 | if (codec_index < 0) |
| 631 | 630 | return codec_index; |
| 632 | 631 | |
| 632 | + if (codec_info_list[codec_index].codec_type < _codec_type) | |
| 633 | + dev_warn(dev, | |
| 634 | + "Unexpected address table ordering. Expected order: jack -> amp -> mic\n"); | |
| 635 | + | |
| 636 | + _codec_type = codec_info_list[codec_index].codec_type; | |
| 637 | + | |
| 633 | 638 | endpoint = link->adr_d->endpoints; |
| 634 | 639 | |
| 635 | 640 | /* count DAI number for playback and capture */ |
| @@ -888,14 +893,14 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link, · 252 unmodified lines | ||
| 888 | 893 | } |
| 889 | 894 | |
| 890 | 895 | static int create_sdw_dailink(struct snd_soc_card *card, |
| 891 | − struct device *dev, int *be_index, | |
| 896 | + struct device *dev, int *link_index, | |
| 892 | 897 | struct snd_soc_dai_link *dai_links, |
| 893 | 898 | int sdw_be_num, int sdw_cpu_dai_num, |
| 894 | 899 | struct snd_soc_dai_link_component *cpus, |
| 895 | 900 | const struct snd_soc_acpi_link_adr *link, |
| 896 | 901 | int *cpu_id, bool *group_generated, |
| 897 | 902 | struct snd_soc_codec_conf *codec_conf, |
| 898 | − int codec_count, | |
| 903 | + int codec_count, int *link_id, | |
| 899 | 904 | int *codec_conf_index, |
| 900 | 905 | bool *ignore_pch_dmic) |
| 901 | 906 | { |
| @@ -953,6 +958,19 @@ static int create_sdw_dailink(struct snd_soc_card *card, · 51 unmodified lines | ||
| 953 | 958 | if (codec_info_list[codec_index].ignore_pch_dmic) |
| 954 | 959 | *ignore_pch_dmic = true; |
| 955 | 960 | |
| 961 | + /* Shift the first amplifier's *link_id to SDW_AMP_DAI_ID */ | |
| 962 | + if (codec_info_list[codec_index].codec_type == SOF_SDW_CODEC_TYPE_AMP && | |
| 963 | + *link_id < SDW_AMP_DAI_ID) | |
| 964 | + *link_id = SDW_AMP_DAI_ID; | |
| 965 | + | |
| 966 | + /* | |
| 967 | + * DAI ID is fixed at SDW_DMIC_DAI_ID for MICs to | |
| 968 | + * keep sdw DMIC and HDMI setting static in UCM | |
| 969 | + */ | |
| 970 | + if (codec_info_list[codec_index].codec_type == SOF_SDW_CODEC_TYPE_MIC && | |
| 971 | + *link_id < SDW_DMIC_DAI_ID) | |
| 972 | + *link_id = SDW_DMIC_DAI_ID; | |
| 973 | + | |
| 956 | 974 | cpu_dai_index = *cpu_id; |
| 957 | 975 | for_each_pcm_streams(stream) { |
| 958 | 976 | char *name, *cpu_name; |
| @@ -991,8 +1009,12 @@ static int create_sdw_dailink(struct snd_soc_card *card, · 32 unmodified lines | ||
| 991 | 1009 | cpus[cpu_dai_index++].dai_name = cpu_name; |
| 992 | 1010 | } |
| 993 | 1011 | |
| 994 | − if (*be_index >= sdw_be_num) { | |
| 995 | − dev_err(dev, " invalid be dai index %d", *be_index); | |
| 1012 | + /* | |
| 1013 | + * We create sdw dai links at first stage, so link index should | |
| 1014 | + * not be larger than sdw_be_num | |
| 1015 | + */ | |
| 1016 | + if (*link_index >= sdw_be_num) { | |
| 1017 | + dev_err(dev, "invalid dai link index %d", *link_index); | |
| 996 | 1018 | return -EINVAL; |
| 997 | 1019 | } |
| 998 | 1020 | |
| @@ -1003,18 +1025,19 @@ static int create_sdw_dailink(struct snd_soc_card *card, · 4 unmodified lines | ||
| 1003 | 1025 | |
| 1004 | 1026 | playback = (stream == SNDRV_PCM_STREAM_PLAYBACK); |
| 1005 | 1027 | capture = (stream == SNDRV_PCM_STREAM_CAPTURE); |
| 1006 | − init_dai_link(dev, dai_links + *be_index, *be_index, name, | |
| 1028 | + init_dai_link(dev, dai_links + *link_index, (*link_id)++, name, | |
| 1007 | 1029 | playback, capture, |
| 1008 | 1030 | cpus + *cpu_id, cpu_dai_num, |
| 1009 | 1031 | codecs, codec_num, |
| 1010 | 1032 | NULL, &sdw_ops); |
| 1033 | + | |
| 1011 | 1034 | /* |
| 1012 | 1035 | * SoundWire DAILINKs use 'stream' functions and Bank Switch operations |
| 1013 | 1036 | * based on wait_for_completion(), tag them as 'nonatomic'. |
| 1014 | 1037 | */ |
| 1015 | − dai_links[*be_index].nonatomic = true; | |
| 1038 | + dai_links[*link_index].nonatomic = true; | |
| 1016 | 1039 | |
| 1017 | − ret = set_codec_init_func(card, link, dai_links + (*be_index)++, | |
| 1040 | + ret = set_codec_init_func(card, link, dai_links + (*link_index)++, | |
| 1018 | 1041 | playback, group_id); |
| 1019 | 1042 | if (ret < 0) { |
| 1020 | 1043 | dev_err(dev, "failed to init codec %d", codec_index); |
| @@ -1028,17 +1051,6 @@ static int create_sdw_dailink(struct snd_soc_card *card, · 7 unmodified lines | ||
| 1028 | 1051 | return 0; |
| 1029 | 1052 | } |
| 1030 | 1053 | |
| 1031 | −/* | |
| 1032 | − * DAI link ID of SSP & DMIC & HDMI are based on last | |
| 1033 | − * link ID used by sdw link. Since be_id may be changed | |
| 1034 | − * in init func of sdw codec, it is not equal to be_id | |
| 1035 | − */ | |
| 1036 | −static inline int get_next_be_id(struct snd_soc_dai_link *links, | |
| 1037 | − int be_id) | |
| 1038 | −{ | |
| 1039 | − return links[be_id - 1].id + 1; | |
| 1040 | −} | |
| 1041 | − | |
| 1042 | 1054 | #define IDISP_CODEC_MASK 0x4 |
| 1043 | 1055 | |
| 1044 | 1056 | static int sof_card_codec_conf_alloc(struct device *dev, |
| @@ -1095,7 +1107,7 @@ static int sof_card_dai_links_create(struct device *dev, · 50 unmodified lines | ||
| 1095 | 1107 | bool group_generated[SDW_MAX_GROUPS]; |
| 1096 | 1108 | int ssp_codec_index, ssp_mask; |
| 1097 | 1109 | struct snd_soc_dai_link *links; |
| 1098 | − int num_links, link_id = 0; | |
| 1110 | + int num_links, link_index = 0; | |
| 1099 | 1111 | char *name, *cpu_name; |
| 1100 | 1112 | int total_cpu_dai_num; |
| 1101 | 1113 | int sdw_cpu_dai_num; |
| @@ -1131,7 +1143,7 @@ static int sof_card_dai_links_create(struct device *dev, · 29 unmodified lines | ||
| 1131 | 1143 | ssp_num = ssp_codec_index >= 0 ? hweight_long(ssp_mask) : 0; |
| 1132 | 1144 | comp_num = hdmi_num + ssp_num; |
| 1133 | 1145 | |
| 1134 | − ret = get_sdw_dailink_info(mach_params->links, | |
| 1146 | + ret = get_sdw_dailink_info(dev, mach_params->links, | |
| 1135 | 1147 | &sdw_be_num, &sdw_cpu_dai_num); |
| 1136 | 1148 | if (ret < 0) { |
| 1137 | 1149 | dev_err(dev, "failed to get sdw link info %d", ret); |
| @@ -1195,24 +1207,18 @@ static int sof_card_dai_links_create(struct device *dev, · 57 unmodified lines | ||
| 1195 | 1207 | group_generated[endpoint->group_id]) |
| 1196 | 1208 | continue; |
| 1197 | 1209 | |
| 1198 | − ret = create_sdw_dailink(card, dev, &be_id, links, sdw_be_num, | |
| 1210 | + ret = create_sdw_dailink(card, dev, &link_index, links, sdw_be_num, | |
| 1199 | 1211 | sdw_cpu_dai_num, cpus, adr_link, |
| 1200 | 1212 | &cpu_id, group_generated, |
| 1201 | 1213 | codec_conf, codec_conf_count, |
| 1202 | − &codec_conf_index, | |
| 1214 | + &be_id, &codec_conf_index, | |
| 1203 | 1215 | &ignore_pch_dmic); |
| 1204 | 1216 | if (ret < 0) { |
| 1205 | − dev_err(dev, "failed to create dai link %d", be_id); | |
| 1206 | − return -ENOMEM; | |
| 1217 | + dev_err(dev, "failed to create dai link %d", link_index); | |
| 1218 | + return ret; | |
| 1207 | 1219 | } |
| 1208 | 1220 | } |
| 1209 | 1221 | |
| 1210 | − /* non-sdw DAI follows sdw DAI */ | |
| 1211 | − link_id = be_id; | |
| 1212 | − | |
| 1213 | − /* get BE ID for non-sdw DAI */ | |
| 1214 | − be_id = get_next_be_id(links, be_id); | |
| 1215 | − | |
| 1216 | 1222 | SSP: |
| 1217 | 1223 | /* SSP */ |
| 1218 | 1224 | if (!ssp_num) |
| @@ -1252,17 +1258,17 @@ SSP: · 33 unmodified lines | ||
| 1252 | 1258 | |
| 1253 | 1259 | playback = info->direction[SNDRV_PCM_STREAM_PLAYBACK]; |
| 1254 | 1260 | capture = info->direction[SNDRV_PCM_STREAM_CAPTURE]; |
| 1255 | − init_dai_link(dev, links + link_id, be_id, name, | |
| 1261 | + init_dai_link(dev, links + link_index, be_id, name, | |
| 1256 | 1262 | playback, capture, |
| 1257 | 1263 | cpus + cpu_id, 1, |
| 1258 | 1264 | ssp_components, 1, |
| 1259 | 1265 | NULL, info->ops); |
| 1260 | 1266 | |
| 1261 | − ret = info->init(card, NULL, links + link_id, info, 0); | |
| 1267 | + ret = info->init(card, NULL, links + link_index, info, 0); | |
| 1262 | 1268 | if (ret < 0) |
| 1263 | 1269 | return ret; |
| 1264 | 1270 | |
| 1265 | − INC_ID(be_id, cpu_id, link_id); | |
| 1271 | + INC_ID(be_id, cpu_id, link_index); | |
| 1266 | 1272 | } |
| 1267 | 1273 | |
| 1268 | 1274 | DMIC: |
| @@ -1273,21 +1279,21 @@ DMIC: · 4 unmodified lines | ||
| 1273 | 1279 | goto HDMI; |
| 1274 | 1280 | } |
| 1275 | 1281 | cpus[cpu_id].dai_name = "DMIC01 Pin"; |
| 1276 | − init_dai_link(dev, links + link_id, be_id, "dmic01", | |
| 1282 | + init_dai_link(dev, links + link_index, be_id, "dmic01", | |
| 1277 | 1283 | 0, 1, // DMIC only supports capture |
| 1278 | 1284 | cpus + cpu_id, 1, |
| 1279 | 1285 | dmic_component, 1, |
| 1280 | 1286 | sof_sdw_dmic_init, NULL); |
| 1281 | − INC_ID(be_id, cpu_id, link_id); | |
| 1287 | + INC_ID(be_id, cpu_id, link_index); | |
| 1282 | 1288 | |
| 1283 | 1289 | cpus[cpu_id].dai_name = "DMIC16k Pin"; |
| 1284 | − init_dai_link(dev, links + link_id, be_id, "dmic16k", | |
| 1290 | + init_dai_link(dev, links + link_index, be_id, "dmic16k", | |
| 1285 | 1291 | 0, 1, // DMIC only supports capture |
| 1286 | 1292 | cpus + cpu_id, 1, |
| 1287 | 1293 | dmic_component, 1, |
| 1288 | 1294 | /* don't call sof_sdw_dmic_init() twice */ |
| 1289 | 1295 | NULL, NULL); |
| 1290 | − INC_ID(be_id, cpu_id, link_id); | |
| 1296 | + INC_ID(be_id, cpu_id, link_index); | |
| 1291 | 1297 | } |
| 1292 | 1298 | |
| 1293 | 1299 | HDMI: |
| @@ -1325,12 +1331,12 @@ HDMI: · 31 unmodified lines | ||
| 1325 | 1331 | return -ENOMEM; |
| 1326 | 1332 | |
| 1327 | 1333 | cpus[cpu_id].dai_name = cpu_name; |
| 1328 | − init_dai_link(dev, links + link_id, be_id, name, | |
| 1334 | + init_dai_link(dev, links + link_index, be_id, name, | |
| 1329 | 1335 | 1, 0, // HDMI only supports playback |
| 1330 | 1336 | cpus + cpu_id, 1, |
| 1331 | 1337 | idisp_components + i, 1, |
| 1332 | 1338 | sof_sdw_hdmi_init, NULL); |
| 1333 | − INC_ID(be_id, cpu_id, link_id); | |
| 1339 | + INC_ID(be_id, cpu_id, link_index); | |
| 1334 | 1340 | } |
| 1335 | 1341 | |
| 1336 | 1342 | if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) { |
| @@ -1354,7 +1360,7 @@ HDMI: · 17 unmodified lines | ||
| 1354 | 1360 | return -ENOMEM; |
| 1355 | 1361 | |
| 1356 | 1362 | cpus[cpu_id].dai_name = cpu_name; |
| 1357 | − init_dai_link(dev, links + link_id, be_id, name, 1, 1, | |
| 1363 | + init_dai_link(dev, links + link_index, be_id, name, 1, 1, | |
| 1358 | 1364 | cpus + cpu_id, 1, ssp_components, 1, NULL, NULL); |
| 1359 | 1365 | } |
| 1360 | 1366 | |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | #define MAX_NO_PROPS 2 |
| 17 | 17 | #define MAX_HDMI_NUM 4 |
| 18 | +#define SDW_AMP_DAI_ID 2 | |
| 18 | 19 | #define SDW_DMIC_DAI_ID 4 |
| 19 | 20 | #define SDW_MAX_CPU_DAIS 16 |
| 20 | 21 | #define SDW_INTEL_BIDIR_PDI_BASE 2 |
| @@ -42,7 +43,6 @@ enum { · 21 unmodified lines | ||
| 42 | 43 | #define SOF_SDW_PCH_DMIC BIT(6) |
| 43 | 44 | #define SOF_SSP_PORT(x) (((x) & GENMASK(5, 0)) << 7) |
| 44 | 45 | #define SOF_SSP_GET_PORT(quirk) (((quirk) >> 7) & GENMASK(5, 0)) |
| 45 | −#define SOF_RT715_DAI_ID_FIX BIT(13) | |
| 46 | 46 | #define SOF_SDW_NO_AGGREGATION BIT(14) |
| 47 | 47 | |
| 48 | 48 | /* BT audio offload: reserve 3 bits for future */ |
| @@ -52,9 +52,14 @@ enum { · 3 unmodified lines | ||
| 52 | 52 | (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) |
| 53 | 53 | #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(18) |
| 54 | 54 | |
| 55 | +#define SOF_SDW_CODEC_TYPE_JACK 0 | |
| 56 | +#define SOF_SDW_CODEC_TYPE_AMP 1 | |
| 57 | +#define SOF_SDW_CODEC_TYPE_MIC 2 | |
| 58 | + | |
| 55 | 59 | struct sof_sdw_codec_info { |
| 56 | 60 | const int part_id; |
| 57 | 61 | const int version_id; |
| 62 | + const int codec_type; | |
| 58 | 63 | int amp_num; |
| 59 | 64 | const u8 acpi_id[ACPI_ID_LEN]; |
| 60 | 65 | const bool direction[2]; // playback & capture support |
| @@ -30,13 +30,6 @@ int sof_sdw_rt715_init(struct snd_soc_card *card, · 29 unmodified lines | ||
| 30 | 30 | struct sof_sdw_codec_info *info, |
| 31 | 31 | bool playback) |
| 32 | 32 | { |
| 33 | − /* | |
| 34 | − * DAI ID is fixed at SDW_DMIC_DAI_ID for 715 to | |
| 35 | − * keep sdw DMIC and HDMI setting static in UCM | |
| 36 | − */ | |
| 37 | − if (sof_sdw_quirk & SOF_RT715_DAI_ID_FIX) | |
| 38 | − dai_links->id = SDW_DMIC_DAI_ID; | |
| 39 | − | |
| 40 | 33 | dai_links->init = rt715_rtd_init; |
| 41 | 34 | |
| 42 | 35 | return 0; |
| @@ -30,13 +30,6 @@ int sof_sdw_rt715_sdca_init(struct snd_soc_card *card, · 29 unmodified lines | ||
| 30 | 30 | struct sof_sdw_codec_info *info, |
| 31 | 31 | bool playback) |
| 32 | 32 | { |
| 33 | − /* | |
| 34 | − * DAI ID is fixed at SDW_DMIC_DAI_ID for 715-SDCA to | |
| 35 | − * keep sdw DMIC and HDMI setting static in UCM | |
| 36 | − */ | |
| 37 | − if (sof_sdw_quirk & SOF_RT715_DAI_ID_FIX) | |
| 38 | − dai_links->id = SDW_DMIC_DAI_ID; | |
| 39 | − | |
| 40 | 33 | dai_links->init = rt715_sdca_rtd_init; |
| 41 | 34 | |
| 42 | 35 | return 0; |
| @@ -65,6 +65,7 @@ static int catpt_dma_memcpy(struct catpt_dev *cdev, struct dma_chan *chan, · 64 unmodified lines | ||
| 65 | 65 | { |
| 66 | 66 | struct dma_async_tx_descriptor *desc; |
| 67 | 67 | enum dma_status status; |
| 68 | + int ret; | |
| 68 | 69 | |
| 69 | 70 | desc = dmaengine_prep_dma_memcpy(chan, dst_addr, src_addr, size, |
| 70 | 71 | DMA_CTRL_ACK); |
| @@ -77,13 +78,22 @@ static int catpt_dma_memcpy(struct catpt_dev *cdev, struct dma_chan *chan, · 6 unmodified lines | ||
| 77 | 78 | catpt_updatel_shim(cdev, HMDC, |
| 78 | 79 | CATPT_HMDC_HDDA(CATPT_DMA_DEVID, chan->chan_id), |
| 79 | 80 | CATPT_HMDC_HDDA(CATPT_DMA_DEVID, chan->chan_id)); |
| 80 | − dmaengine_submit(desc); | |
| 81 | + | |
| 82 | + ret = dma_submit_error(dmaengine_submit(desc)); | |
| 83 | + if (ret) { | |
| 84 | + dev_err(cdev->dev, "submit tx failed: %d\n", ret); | |
| 85 | + goto clear_hdda; | |
| 86 | + } | |
| 87 | + | |
| 81 | 88 | status = dma_wait_for_async_tx(desc); |
| 89 | + ret = (status == DMA_COMPLETE) ? 0 : -EPROTO; | |
| 90 | + | |
| 91 | +clear_hdda: | |
| 82 | 92 | /* regardless of status, disable access to HOST memory in demand mode */ |
| 83 | 93 | catpt_updatel_shim(cdev, HMDC, |
| 84 | 94 | CATPT_HMDC_HDDA(CATPT_DMA_DEVID, chan->chan_id), 0); |
| 85 | 95 | |
| 86 | − return (status == DMA_COMPLETE) ? 0 : -EPROTO; | |
| 96 | + return ret; | |
| 87 | 97 | } |
| 88 | 98 | |
| 89 | 99 | int catpt_dma_memcpy_todsp(struct catpt_dev *cdev, struct dma_chan *chan, |
| @@ -259,9 +259,9 @@ static enum catpt_channel_config catpt_get_channel_config(u32 num_channels) · 258 unmodified lines | ||
| 259 | 259 | static int catpt_dai_startup(struct snd_pcm_substream *substream, |
| 260 | 260 | struct snd_soc_dai *dai) |
| 261 | 261 | { |
| 262 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 263 | 262 | struct catpt_stream_template *template; |
| 264 | 263 | struct catpt_stream_runtime *stream; |
| 264 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 265 | 265 | struct resource *res; |
| 266 | 266 | int ret; |
| 267 | 267 | |
| @@ -306,8 +306,8 @@ err_pgtbl: · 38 unmodified lines | ||
| 306 | 306 | static void catpt_dai_shutdown(struct snd_pcm_substream *substream, |
| 307 | 307 | struct snd_soc_dai *dai) |
| 308 | 308 | { |
| 309 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 310 | 309 | struct catpt_stream_runtime *stream; |
| 310 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 311 | 311 | |
| 312 | 312 | stream = snd_soc_dai_get_dma_data(dai, substream); |
| 313 | 313 | |
| @@ -329,9 +329,9 @@ static int catpt_set_dspvol(struct catpt_dev *cdev, u8 stream_id, long *ctlvol); · 15 unmodified lines | ||
| 329 | 329 | static int catpt_dai_apply_usettings(struct snd_soc_dai *dai, |
| 330 | 330 | struct catpt_stream_runtime *stream) |
| 331 | 331 | { |
| 332 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 333 | 332 | struct snd_soc_component *component = dai->component; |
| 334 | 333 | struct snd_kcontrol *pos; |
| 334 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 335 | 335 | const char *name; |
| 336 | 336 | int ret; |
| 337 | 337 | u32 id = stream->info.stream_hw_id; |
| @@ -374,12 +374,12 @@ static int catpt_dai_hw_params(struct snd_pcm_substream *substream, · 36 unmodified lines | ||
| 374 | 374 | struct snd_pcm_hw_params *params, |
| 375 | 375 | struct snd_soc_dai *dai) |
| 376 | 376 | { |
| 377 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 377 | + struct snd_pcm_runtime *rtm = substream->runtime; | |
| 378 | + struct snd_dma_buffer *dmab; | |
| 378 | 379 | struct catpt_stream_runtime *stream; |
| 379 | 380 | struct catpt_audio_format afmt; |
| 380 | 381 | struct catpt_ring_info rinfo; |
| 381 | − struct snd_pcm_runtime *rtm = substream->runtime; | |
| 382 | − struct snd_dma_buffer *dmab; | |
| 382 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 383 | 383 | int ret; |
| 384 | 384 | |
| 385 | 385 | stream = snd_soc_dai_get_dma_data(dai, substream); |
| @@ -427,8 +427,8 @@ static int catpt_dai_hw_params(struct snd_pcm_substream *substream, · 41 unmodified lines | ||
| 427 | 427 | static int catpt_dai_hw_free(struct snd_pcm_substream *substream, |
| 428 | 428 | struct snd_soc_dai *dai) |
| 429 | 429 | { |
| 430 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 431 | 430 | struct catpt_stream_runtime *stream; |
| 431 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 432 | 432 | |
| 433 | 433 | stream = snd_soc_dai_get_dma_data(dai, substream); |
| 434 | 434 | if (!stream->allocated) |
| @@ -444,8 +444,8 @@ static int catpt_dai_hw_free(struct snd_pcm_substream *substream, · 9 unmodified lines | ||
| 444 | 444 | static int catpt_dai_prepare(struct snd_pcm_substream *substream, |
| 445 | 445 | struct snd_soc_dai *dai) |
| 446 | 446 | { |
| 447 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 448 | 447 | struct catpt_stream_runtime *stream; |
| 448 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 449 | 449 | int ret; |
| 450 | 450 | |
| 451 | 451 | stream = snd_soc_dai_get_dma_data(dai, substream); |
| @@ -467,9 +467,9 @@ static int catpt_dai_prepare(struct snd_pcm_substream *substream, · 15 unmodified lines | ||
| 467 | 467 | static int catpt_dai_trigger(struct snd_pcm_substream *substream, int cmd, |
| 468 | 468 | struct snd_soc_dai *dai) |
| 469 | 469 | { |
| 470 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 471 | − struct catpt_stream_runtime *stream; | |
| 472 | 470 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 471 | + struct catpt_stream_runtime *stream; | |
| 472 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 473 | 473 | snd_pcm_uframes_t pos; |
| 474 | 474 | int ret; |
| 475 | 475 | |
| @@ -595,9 +595,8 @@ static int catpt_component_open(struct snd_soc_component *component, · 119 unmodified lines | ||
| 595 | 595 | { |
| 596 | 596 | struct snd_soc_pcm_runtime *rtm = substream->private_data; |
| 597 | 597 | |
| 598 | − if (rtm->dai_link->no_pcm) | |
| 599 | − return 0; | |
| 600 | − snd_soc_set_runtime_hwparams(substream, &catpt_pcm_hardware); | |
| 598 | + if (!rtm->dai_link->no_pcm) | |
| 599 | + snd_soc_set_runtime_hwparams(substream, &catpt_pcm_hardware); | |
| 601 | 600 | return 0; |
| 602 | 601 | } |
| 603 | 602 | |
| @@ -605,10 +604,10 @@ static snd_pcm_uframes_t · 1 unmodified line | ||
| 605 | 604 | catpt_component_pointer(struct snd_soc_component *component, |
| 606 | 605 | struct snd_pcm_substream *substream) |
| 607 | 606 | { |
| 608 | − struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 609 | − struct catpt_stream_runtime *stream; | |
| 610 | 607 | struct snd_soc_pcm_runtime *rtm = substream->private_data; |
| 611 | 608 | struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtm, 0); |
| 609 | + struct catpt_stream_runtime *stream; | |
| 610 | + struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 612 | 611 | u32 pos; |
| 613 | 612 | |
| 614 | 613 | if (rtm->dai_link->no_pcm) |
| @@ -633,8 +632,8 @@ static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtm, · 18 unmodified lines | ||
| 633 | 632 | struct snd_soc_dai *dai) |
| 634 | 633 | { |
| 635 | 634 | struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtm, 0); |
| 636 | − struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 637 | 635 | struct catpt_ssp_device_format devfmt; |
| 636 | + struct catpt_dev *cdev = dev_get_drvdata(dai->dev); | |
| 638 | 637 | int ret; |
| 639 | 638 | |
| 640 | 639 | devfmt.iface = dai->driver->id; |
| @@ -894,8 +893,8 @@ static int catpt_stream_volume_get(struct snd_kcontrol *kcontrol, · 253 unmodified lines | ||
| 894 | 893 | { |
| 895 | 894 | struct snd_soc_component *component = |
| 896 | 895 | snd_soc_kcontrol_component(kcontrol); |
| 897 | − struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 898 | 896 | struct catpt_stream_runtime *stream; |
| 897 | + struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 899 | 898 | long *ctlvol = (long *)kcontrol->private_value; |
| 900 | 899 | u32 dspvol; |
| 901 | 900 | int i; |
| @@ -926,8 +925,8 @@ static int catpt_stream_volume_put(struct snd_kcontrol *kcontrol, · 24 unmodified lines | ||
| 926 | 925 | { |
| 927 | 926 | struct snd_soc_component *component = |
| 928 | 927 | snd_soc_kcontrol_component(kcontrol); |
| 929 | − struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 930 | 928 | struct catpt_stream_runtime *stream; |
| 929 | + struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 931 | 930 | long *ctlvol = (long *)kcontrol->private_value; |
| 932 | 931 | int ret, i; |
| 933 | 932 | |
| @@ -1002,8 +1001,8 @@ static int catpt_loopback_switch_put(struct snd_kcontrol *kcontrol, · 68 unmodified lines | ||
| 1002 | 1001 | { |
| 1003 | 1002 | struct snd_soc_component *component = |
| 1004 | 1003 | snd_soc_kcontrol_component(kcontrol); |
| 1005 | − struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 1006 | 1004 | struct catpt_stream_runtime *stream; |
| 1005 | + struct catpt_dev *cdev = dev_get_drvdata(component->dev); | |
| 1007 | 1006 | bool mute; |
| 1008 | 1007 | int ret; |
| 1009 | 1008 | |
| @@ -374,6 +374,16 @@ static const struct snd_soc_acpi_codecs adl_rt5682_rt5682s_hp = { · 373 unmodified lines | ||
| 374 | 374 | .codecs = {"10EC5682", "RTL5682"}, |
| 375 | 375 | }; |
| 376 | 376 | |
| 377 | +static const struct snd_soc_acpi_codecs adl_rt1019p_amp = { | |
| 378 | + .num_codecs = 1, | |
| 379 | + .codecs = {"RTL1019"} | |
| 380 | +}; | |
| 381 | + | |
| 382 | +static const struct snd_soc_acpi_codecs adl_max98390_amp = { | |
| 383 | + .num_codecs = 1, | |
| 384 | + .codecs = {"MX98390"} | |
| 385 | +}; | |
| 386 | + | |
| 377 | 387 | struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { |
| 378 | 388 | { |
| 379 | 389 | .comp_ids = &adl_rt5682_rt5682s_hp, |
| @@ -399,6 +409,44 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { · 19 unmodified lines | ||
| 399 | 409 | .sof_fw_filename = "sof-adl.ri", |
| 400 | 410 | .sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg", |
| 401 | 411 | }, |
| 412 | + { | |
| 413 | + .id = "10508825", | |
| 414 | + .drv_name = "adl_rt1019p_nau8825", | |
| 415 | + .machine_quirk = snd_soc_acpi_codec_list, | |
| 416 | + .quirk_data = &adl_rt1019p_amp, | |
| 417 | + .sof_fw_filename = "sof-adl.ri", | |
| 418 | + .sof_tplg_filename = "sof-adl-rt1019-nau8825.tplg", | |
| 419 | + }, | |
| 420 | + { | |
| 421 | + .id = "10508825", | |
| 422 | + .drv_name = "adl_max98373_nau8825", | |
| 423 | + .machine_quirk = snd_soc_acpi_codec_list, | |
| 424 | + .quirk_data = &adl_max98373_amp, | |
| 425 | + .sof_fw_filename = "sof-adl.ri", | |
| 426 | + .sof_tplg_filename = "sof-adl-max98373-nau8825.tplg", | |
| 427 | + }, | |
| 428 | + { | |
| 429 | + .id = "10508825", | |
| 430 | + .drv_name = "adl_mx98360a_nau8825", | |
| 431 | + .machine_quirk = snd_soc_acpi_codec_list, | |
| 432 | + .quirk_data = &adl_max98360a_amp, | |
| 433 | + .sof_fw_filename = "sof-adl.ri", | |
| 434 | + .sof_tplg_filename = "sof-adl-mx98360a-nau8825.tplg", | |
| 435 | + }, | |
| 436 | + { | |
| 437 | + .id = "10508825", | |
| 438 | + .drv_name = "sof_nau8825", | |
| 439 | + .sof_fw_filename = "sof-adl.ri", | |
| 440 | + .sof_tplg_filename = "sof-adl-nau8825.tplg", | |
| 441 | + }, | |
| 442 | + { | |
| 443 | + .comp_ids = &adl_rt5682_rt5682s_hp, | |
| 444 | + .drv_name = "adl_max98390_rt5682", | |
| 445 | + .machine_quirk = snd_soc_acpi_codec_list, | |
| 446 | + .quirk_data = &adl_max98390_amp, | |
| 447 | + .sof_fw_filename = "sof-adl.ri", | |
| 448 | + .sof_tplg_filename = "sof-adl-max98390-rt5682.tplg", | |
| 449 | + }, | |
| 402 | 450 | {}, |
| 403 | 451 | }; |
| 404 | 452 | EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines); |
| @@ -13,108 +13,6 @@ · 12 unmodified lines | ||
| 13 | 13 | #include "skl.h" |
| 14 | 14 | #include "skl-i2s.h" |
| 15 | 15 | |
| 16 | −static struct nhlt_specific_cfg *skl_get_specific_cfg( | |
| 17 | − struct device *dev, struct nhlt_fmt *fmt, | |
| 18 | − u8 no_ch, u32 rate, u16 bps, u8 linktype) | |
| 19 | −{ | |
| 20 | − struct nhlt_specific_cfg *sp_config; | |
| 21 | − struct wav_fmt *wfmt; | |
| 22 | − struct nhlt_fmt_cfg *fmt_config = fmt->fmt_config; | |
| 23 | − int i; | |
| 24 | − | |
| 25 | − dev_dbg(dev, "Format count =%d\n", fmt->fmt_count); | |
| 26 | − | |
| 27 | − for (i = 0; i < fmt->fmt_count; i++) { | |
| 28 | − wfmt = &fmt_config->fmt_ext.fmt; | |
| 29 | − dev_dbg(dev, "ch=%d fmt=%d s_rate=%d\n", wfmt->channels, | |
| 30 | − wfmt->bits_per_sample, wfmt->samples_per_sec); | |
| 31 | − if (wfmt->channels == no_ch && wfmt->bits_per_sample == bps) { | |
| 32 | − /* | |
| 33 | − * if link type is dmic ignore rate check as the blob is | |
| 34 | − * generic for all rates | |
| 35 | − */ | |
| 36 | − sp_config = &fmt_config->config; | |
| 37 | − if (linktype == NHLT_LINK_DMIC) | |
| 38 | − return sp_config; | |
| 39 | − | |
| 40 | − if (wfmt->samples_per_sec == rate) | |
| 41 | − return sp_config; | |
| 42 | − } | |
| 43 | − | |
| 44 | − fmt_config = (struct nhlt_fmt_cfg *)(fmt_config->config.caps + | |
| 45 | − fmt_config->config.size); | |
| 46 | − } | |
| 47 | − | |
| 48 | − return NULL; | |
| 49 | −} | |
| 50 | − | |
| 51 | −static void dump_config(struct device *dev, u32 instance_id, u8 linktype, | |
| 52 | − u8 s_fmt, u8 num_channels, u32 s_rate, u8 dirn, u16 bps) | |
| 53 | −{ | |
| 54 | − dev_dbg(dev, "Input configuration\n"); | |
| 55 | − dev_dbg(dev, "ch=%d fmt=%d s_rate=%d\n", num_channels, s_fmt, s_rate); | |
| 56 | − dev_dbg(dev, "vbus_id=%d link_type=%d\n", instance_id, linktype); | |
| 57 | − dev_dbg(dev, "bits_per_sample=%d\n", bps); | |
| 58 | −} | |
| 59 | − | |
| 60 | −static bool skl_check_ep_match(struct device *dev, struct nhlt_endpoint *epnt, | |
| 61 | − u32 instance_id, u8 link_type, u8 dirn, u8 dev_type) | |
| 62 | −{ | |
| 63 | − dev_dbg(dev, "vbus_id=%d link_type=%d dir=%d dev_type = %d\n", | |
| 64 | − epnt->virtual_bus_id, epnt->linktype, | |
| 65 | − epnt->direction, epnt->device_type); | |
| 66 | − | |
| 67 | − if ((epnt->virtual_bus_id == instance_id) && | |
| 68 | − (epnt->linktype == link_type) && | |
| 69 | − (epnt->direction == dirn)) { | |
| 70 | − /* do not check dev_type for DMIC link type */ | |
| 71 | − if (epnt->linktype == NHLT_LINK_DMIC) | |
| 72 | − return true; | |
| 73 | − | |
| 74 | − if (epnt->device_type == dev_type) | |
| 75 | − return true; | |
| 76 | − } | |
| 77 | − | |
| 78 | − return false; | |
| 79 | −} | |
| 80 | − | |
| 81 | −struct nhlt_specific_cfg | |
| 82 | −*skl_get_ep_blob(struct skl_dev *skl, u32 instance, u8 link_type, | |
| 83 | − u8 s_fmt, u8 num_ch, u32 s_rate, | |
| 84 | − u8 dirn, u8 dev_type) | |
| 85 | −{ | |
| 86 | − struct nhlt_fmt *fmt; | |
| 87 | − struct nhlt_endpoint *epnt; | |
| 88 | − struct hdac_bus *bus = skl_to_bus(skl); | |
| 89 | − struct device *dev = bus->dev; | |
| 90 | − struct nhlt_specific_cfg *sp_config; | |
| 91 | − struct nhlt_acpi_table *nhlt = skl->nhlt; | |
| 92 | − u16 bps = (s_fmt == 16) ? 16 : 32; | |
| 93 | − u8 j; | |
| 94 | − | |
| 95 | − dump_config(dev, instance, link_type, s_fmt, num_ch, s_rate, dirn, bps); | |
| 96 | − | |
| 97 | − epnt = (struct nhlt_endpoint *)nhlt->desc; | |
| 98 | − | |
| 99 | − dev_dbg(dev, "endpoint count =%d\n", nhlt->endpoint_count); | |
| 100 | − | |
| 101 | − for (j = 0; j < nhlt->endpoint_count; j++) { | |
| 102 | − if (skl_check_ep_match(dev, epnt, instance, link_type, | |
| 103 | − dirn, dev_type)) { | |
| 104 | − fmt = (struct nhlt_fmt *)(epnt->config.caps + | |
| 105 | − epnt->config.size); | |
| 106 | − sp_config = skl_get_specific_cfg(dev, fmt, num_ch, | |
| 107 | − s_rate, bps, link_type); | |
| 108 | − if (sp_config) | |
| 109 | − return sp_config; | |
| 110 | − } | |
| 111 | − | |
| 112 | − epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); | |
| 113 | − } | |
| 114 | − | |
| 115 | − return NULL; | |
| 116 | −} | |
| 117 | − | |
| 118 | 16 | static void skl_nhlt_trim_space(char *trim) |
| 119 | 17 | { |
| 120 | 18 | char *s = trim; |
| @@ -317,6 +317,7 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream, · 316 unmodified lines | ||
| 317 | 317 | dev_dbg(dai->dev, "dma_id=%d\n", dma_id); |
| 318 | 318 | |
| 319 | 319 | p_params.s_fmt = snd_pcm_format_width(params_format(params)); |
| 320 | + p_params.s_cont = snd_pcm_format_physical_width(params_format(params)); | |
| 320 | 321 | p_params.ch = params_channels(params); |
| 321 | 322 | p_params.s_freq = params_rate(params); |
| 322 | 323 | p_params.host_dma_id = dma_id; |
| @@ -405,6 +406,7 @@ static int skl_be_hw_params(struct snd_pcm_substream *substream, · 82 unmodified lines | ||
| 405 | 406 | struct skl_pipe_params p_params = {0}; |
| 406 | 407 | |
| 407 | 408 | p_params.s_fmt = snd_pcm_format_width(params_format(params)); |
| 409 | + p_params.s_cont = snd_pcm_format_physical_width(params_format(params)); | |
| 408 | 410 | p_params.ch = params_channels(params); |
| 409 | 411 | p_params.s_freq = params_rate(params); |
| 410 | 412 | p_params.stream = substream->stream; |
| @@ -562,13 +564,11 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream, · 151 unmodified lines | ||
| 562 | 564 | |
| 563 | 565 | stream_tag = hdac_stream(link_dev)->stream_tag; |
| 564 | 566 | |
| 565 | − /* set the stream tag in the codec dai dma params */ | |
| 566 | − if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
| 567 | − snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0); | |
| 568 | − else | |
| 569 | − snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0); | |
| 567 | + /* set the hdac_stream in the codec dai */ | |
| 568 | + snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream); | |
| 570 | 569 | |
| 571 | 570 | p_params.s_fmt = snd_pcm_format_width(params_format(params)); |
| 571 | + p_params.s_cont = snd_pcm_format_physical_width(params_format(params)); | |
| 572 | 572 | p_params.ch = params_channels(params); |
| 573 | 573 | p_params.s_freq = params_rate(params); |
| 574 | 574 | p_params.stream = substream->stream; |
| @@ -1251,7 +1251,6 @@ static int skl_platform_soc_get_time_info( · 676 unmodified lines | ||
| 1251 | 1251 | snd_pcm_gettime(substream->runtime, system_ts); |
| 1252 | 1252 | |
| 1253 | 1253 | nsec = timecounter_read(&hstr->tc); |
| 1254 | − nsec = div_u64(nsec, 3); /* can be optimized */ | |
| 1255 | 1254 | if (audio_tstamp_config->report_delay) |
| 1256 | 1255 | nsec = skl_adjust_codec_delay(substream, nsec); |
| 1257 | 1256 | |
| @@ -285,7 +285,7 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, · 284 unmodified lines | ||
| 285 | 285 | { |
| 286 | 286 | struct skl_module_cfg *m_cfg = w->priv; |
| 287 | 287 | int link_type, dir; |
| 288 | − u32 ch, s_freq, s_fmt; | |
| 288 | + u32 ch, s_freq, s_fmt, s_cont; | |
| 289 | 289 | struct nhlt_specific_cfg *cfg; |
| 290 | 290 | u8 dev_type = skl_tplg_be_dev_type(m_cfg->dev_type); |
| 291 | 291 | int fmt_idx = m_cfg->fmt_idx; |
| @@ -301,7 +301,8 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, · 9 unmodified lines | ||
| 301 | 301 | link_type = NHLT_LINK_DMIC; |
| 302 | 302 | dir = SNDRV_PCM_STREAM_CAPTURE; |
| 303 | 303 | s_freq = m_iface->inputs[0].fmt.s_freq; |
| 304 | − s_fmt = m_iface->inputs[0].fmt.bit_depth; | |
| 304 | + s_fmt = m_iface->inputs[0].fmt.valid_bit_depth; | |
| 305 | + s_cont = m_iface->inputs[0].fmt.bit_depth; | |
| 305 | 306 | ch = m_iface->inputs[0].fmt.channels; |
| 306 | 307 | break; |
| 307 | 308 | |
| @@ -310,12 +311,14 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, · 2 unmodified lines | ||
| 310 | 311 | if (m_cfg->hw_conn_type == SKL_CONN_SOURCE) { |
| 311 | 312 | dir = SNDRV_PCM_STREAM_PLAYBACK; |
| 312 | 313 | s_freq = m_iface->outputs[0].fmt.s_freq; |
| 313 | − s_fmt = m_iface->outputs[0].fmt.bit_depth; | |
| 314 | + s_fmt = m_iface->outputs[0].fmt.valid_bit_depth; | |
| 315 | + s_cont = m_iface->outputs[0].fmt.bit_depth; | |
| 314 | 316 | ch = m_iface->outputs[0].fmt.channels; |
| 315 | 317 | } else { |
| 316 | 318 | dir = SNDRV_PCM_STREAM_CAPTURE; |
| 317 | 319 | s_freq = m_iface->inputs[0].fmt.s_freq; |
| 318 | − s_fmt = m_iface->inputs[0].fmt.bit_depth; | |
| 320 | + s_fmt = m_iface->inputs[0].fmt.valid_bit_depth; | |
| 321 | + s_cont = m_iface->inputs[0].fmt.bit_depth; | |
| 319 | 322 | ch = m_iface->inputs[0].fmt.channels; |
| 320 | 323 | } |
| 321 | 324 | break; |
| @@ -325,16 +328,17 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, · 3 unmodified lines | ||
| 325 | 328 | } |
| 326 | 329 | |
| 327 | 330 | /* update the blob based on virtual bus_id and default params */ |
| 328 | − cfg = skl_get_ep_blob(skl, m_cfg->vbus_id, link_type, | |
| 329 | − s_fmt, ch, s_freq, dir, dev_type); | |
| 331 | + cfg = intel_nhlt_get_endpoint_blob(skl->dev, skl->nhlt, m_cfg->vbus_id, | |
| 332 | + link_type, s_fmt, s_cont, ch, | |
| 333 | + s_freq, dir, dev_type); | |
| 330 | 334 | if (cfg) { |
| 331 | 335 | m_cfg->formats_config[SKL_PARAM_INIT].caps_size = cfg->size; |
| 332 | 336 | m_cfg->formats_config[SKL_PARAM_INIT].caps = (u32 *)&cfg->caps; |
| 333 | 337 | } else { |
| 334 | 338 | dev_err(skl->dev, "Blob NULL for id %x type %d dirn %d\n", |
| 335 | 339 | m_cfg->vbus_id, link_type, dir); |
| 336 | − dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d\n", | |
| 337 | − ch, s_freq, s_fmt); | |
| 340 | + dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d/%d\n", | |
| 341 | + ch, s_freq, s_fmt, s_cont); | |
| 338 | 342 | return -EIO; |
| 339 | 343 | } |
| 340 | 344 | |
| @@ -1849,10 +1853,11 @@ static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai, · 1508 unmodified lines | ||
| 1849 | 1853 | pipe_fmt = &pipe->configs[pipe->pipe_config_idx].in_fmt; |
| 1850 | 1854 | |
| 1851 | 1855 | /* update the blob based on virtual bus_id*/ |
| 1852 | − cfg = skl_get_ep_blob(skl, mconfig->vbus_id, link_type, | |
| 1853 | − pipe_fmt->bps, pipe_fmt->channels, | |
| 1854 | − pipe_fmt->freq, pipe->direction, | |
| 1855 | − dev_type); | |
| 1856 | + cfg = intel_nhlt_get_endpoint_blob(dai->dev, skl->nhlt, | |
| 1857 | + mconfig->vbus_id, link_type, | |
| 1858 | + pipe_fmt->bps, params->s_cont, | |
| 1859 | + pipe_fmt->channels, pipe_fmt->freq, | |
| 1860 | + pipe->direction, dev_type); | |
| 1856 | 1861 | if (cfg) { |
| 1857 | 1862 | mconfig->formats_config[SKL_PARAM_INIT].caps_size = cfg->size; |
| 1858 | 1863 | mconfig->formats_config[SKL_PARAM_INIT].caps = (u32 *)&cfg->caps; |
| @@ -284,6 +284,7 @@ struct skl_pipe_params { · 283 unmodified lines | ||
| 284 | 284 | u32 ch; |
| 285 | 285 | u32 s_freq; |
| 286 | 286 | u32 s_fmt; |
| 287 | + u32 s_cont; | |
| 287 | 288 | u8 linktype; |
| 288 | 289 | snd_pcm_format_t format; |
| 289 | 290 | int link_index; |
| @@ -439,7 +439,7 @@ static int skl_free(struct hdac_bus *bus) · 438 unmodified lines | ||
| 439 | 439 | |
| 440 | 440 | skl->init_done = 0; /* to be sure */ |
| 441 | 441 | |
| 442 | − snd_hdac_ext_stop_streams(bus); | |
| 442 | + snd_hdac_stop_streams_and_chip(bus); | |
| 443 | 443 | |
| 444 | 444 | if (bus->irq >= 0) |
| 445 | 445 | free_irq(bus->irq, (void *)bus); |
| @@ -1096,7 +1096,7 @@ static void skl_shutdown(struct pci_dev *pci) · 650 unmodified lines | ||
| 1096 | 1096 | if (!skl->init_done) |
| 1097 | 1097 | return; |
| 1098 | 1098 | |
| 1099 | − snd_hdac_ext_stop_streams(bus); | |
| 1099 | + snd_hdac_stop_streams_and_chip(bus); | |
| 1100 | 1100 | list_for_each_entry(s, &bus->stream_list, list) { |
| 1101 | 1101 | stream = stream_to_hdac_ext_stream(s); |
| 1102 | 1102 | snd_hdac_ext_stream_decouple(bus, stream, false); |
| @@ -165,10 +165,6 @@ struct skl_dsp_ops { · 164 unmodified lines | ||
| 165 | 165 | int skl_platform_unregister(struct device *dev); |
| 166 | 166 | int skl_platform_register(struct device *dev); |
| 167 | 167 | |
| 168 | −struct nhlt_specific_cfg *skl_get_ep_blob(struct skl_dev *skl, u32 instance, | |
| 169 | − u8 link_type, u8 s_fmt, u8 num_ch, | |
| 170 | − u32 s_rate, u8 dirn, u8 dev_type); | |
| 171 | − | |
| 172 | 168 | int skl_nhlt_update_topology_bin(struct skl_dev *skl); |
| 173 | 169 | int skl_init_dsp(struct skl_dev *skl); |
| 174 | 170 | int skl_free_dsp(struct skl_dev *skl); |
| @@ -205,6 +205,7 @@ config SND_SOC_MT8195_MT6359_RT1019_RT5682 · 204 unmodified lines | ||
| 205 | 205 | select SND_SOC_MT6359 |
| 206 | 206 | select SND_SOC_RT1015P |
| 207 | 207 | select SND_SOC_RT5682_I2C |
| 208 | + select SND_SOC_RT5682S | |
| 208 | 209 | select SND_SOC_DMIC |
| 209 | 210 | select SND_SOC_HDMI_CODEC |
| 210 | 211 | help |
| @@ -220,6 +221,7 @@ config SND_SOC_MT8195_MT6359_RT1011_RT5682 · 9 unmodified lines | ||
| 220 | 221 | select SND_SOC_MT6359 |
| 221 | 222 | select SND_SOC_RT1011 |
| 222 | 223 | select SND_SOC_RT5682_I2C |
| 224 | + select SND_SOC_RT5682S | |
| 223 | 225 | select SND_SOC_DMIC |
| 224 | 226 | select SND_SOC_HDMI_CODEC |
| 225 | 227 | help |
| @@ -1474,9 +1474,7 @@ static struct platform_driver mt2701_afe_pcm_driver = { · 1473 unmodified lines | ||
| 1474 | 1474 | .driver = { |
| 1475 | 1475 | .name = "mt2701-audio", |
| 1476 | 1476 | .of_match_table = mt2701_afe_pcm_dt_match, |
| 1477 | −#ifdef CONFIG_PM | |
| 1478 | 1477 | .pm = &mt2701_afe_pm_ops, |
| 1479 | −#endif | |
| 1480 | 1478 | }, |
| 1481 | 1479 | .probe = mt2701_afe_pcm_dev_probe, |
| 1482 | 1480 | .remove = mt2701_afe_pcm_dev_remove, |
| @@ -901,9 +901,7 @@ static struct platform_driver mt6797_afe_pcm_driver = { · 900 unmodified lines | ||
| 901 | 901 | .driver = { |
| 902 | 902 | .name = "mt6797-audio", |
| 903 | 903 | .of_match_table = mt6797_afe_pcm_dt_match, |
| 904 | −#ifdef CONFIG_PM | |
| 905 | 904 | .pm = &mt6797_afe_pm_ops, |
| 906 | −#endif | |
| 907 | 905 | }, |
| 908 | 906 | .probe = mt6797_afe_pcm_dev_probe, |
| 909 | 907 | .remove = mt6797_afe_pcm_dev_remove, |
| @@ -177,9 +177,9 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev) · 176 unmodified lines | ||
| 177 | 177 | card->dev = &pdev->dev; |
| 178 | 178 | |
| 179 | 179 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 180 | − if (ret) | |
| 181 | − dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", | |
| 182 | − __func__, ret); | |
| 180 | + | |
| 181 | + of_node_put(codec_node); | |
| 182 | + of_node_put(platform_node); | |
| 183 | 183 | return ret; |
| 184 | 184 | } |
| 185 | 185 | |
| @@ -193,9 +193,7 @@ static struct platform_driver mt8173_max98090_driver = { · 7 unmodified lines | ||
| 193 | 193 | .driver = { |
| 194 | 194 | .name = "mt8173-max98090", |
| 195 | 195 | .of_match_table = mt8173_max98090_dt_match, |
| 196 | −#ifdef CONFIG_PM | |
| 197 | 196 | .pm = &snd_soc_pm_ops, |
| 198 | −#endif | |
| 199 | 197 | }, |
| 200 | 198 | .probe = mt8173_max98090_dev_probe, |
| 201 | 199 | }; |
| @@ -215,9 +215,8 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev) · 214 unmodified lines | ||
| 215 | 215 | card->dev = &pdev->dev; |
| 216 | 216 | |
| 217 | 217 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 218 | − if (ret) | |
| 219 | − dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", | |
| 220 | − __func__, ret); | |
| 218 | + | |
| 219 | + of_node_put(platform_node); | |
| 221 | 220 | return ret; |
| 222 | 221 | } |
| 223 | 222 | |
| @@ -231,9 +230,7 @@ static struct platform_driver mt8173_rt5650_rt5514_driver = { · 7 unmodified lines | ||
| 231 | 230 | .driver = { |
| 232 | 231 | .name = "mtk-rt5650-rt5514", |
| 233 | 232 | .of_match_table = mt8173_rt5650_rt5514_dt_match, |
| 234 | −#ifdef CONFIG_PM | |
| 235 | 233 | .pm = &snd_soc_pm_ops, |
| 236 | −#endif | |
| 237 | 234 | }, |
| 238 | 235 | .probe = mt8173_rt5650_rt5514_dev_probe, |
| 239 | 236 | }; |
| @@ -282,9 +282,8 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev) · 281 unmodified lines | ||
| 282 | 282 | card->dev = &pdev->dev; |
| 283 | 283 | |
| 284 | 284 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 285 | − if (ret) | |
| 286 | − dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", | |
| 287 | − __func__, ret); | |
| 285 | + | |
| 286 | + of_node_put(platform_node); | |
| 288 | 287 | return ret; |
| 289 | 288 | } |
| 290 | 289 | |
| @@ -298,9 +297,7 @@ static struct platform_driver mt8173_rt5650_rt5676_driver = { · 7 unmodified lines | ||
| 298 | 297 | .driver = { |
| 299 | 298 | .name = "mtk-rt5650-rt5676", |
| 300 | 299 | .of_match_table = mt8173_rt5650_rt5676_dt_match, |
| 301 | −#ifdef CONFIG_PM | |
| 302 | 300 | .pm = &snd_soc_pm_ops, |
| 303 | −#endif | |
| 304 | 301 | }, |
| 305 | 302 | .probe = mt8173_rt5650_rt5676_dev_probe, |
| 306 | 303 | }; |
| @@ -320,9 +320,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev) · 319 unmodified lines | ||
| 320 | 320 | card->dev = &pdev->dev; |
| 321 | 321 | |
| 322 | 322 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 323 | − if (ret) | |
| 324 | − dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", | |
| 325 | − __func__, ret); | |
| 323 | + | |
| 324 | + of_node_put(platform_node); | |
| 326 | 325 | return ret; |
| 327 | 326 | } |
| 328 | 327 | |
| @@ -336,9 +335,7 @@ static struct platform_driver mt8173_rt5650_driver = { · 7 unmodified lines | ||
| 336 | 335 | .driver = { |
| 337 | 336 | .name = "mtk-rt5650", |
| 338 | 337 | .of_match_table = mt8173_rt5650_dt_match, |
| 339 | −#ifdef CONFIG_PM | |
| 340 | 338 | .pm = &snd_soc_pm_ops, |
| 341 | −#endif | |
| 342 | 339 | }, |
| 343 | 340 | .probe = mt8173_rt5650_dev_probe, |
| 344 | 341 | }; |
| @@ -1279,9 +1279,7 @@ static struct platform_driver mt8183_afe_pcm_driver = { · 1278 unmodified lines | ||
| 1279 | 1279 | .driver = { |
| 1280 | 1280 | .name = "mt8183-audio", |
| 1281 | 1281 | .of_match_table = mt8183_afe_pcm_dt_match, |
| 1282 | −#ifdef CONFIG_PM | |
| 1283 | 1282 | .pm = &mt8183_afe_pm_ops, |
| 1284 | −#endif | |
| 1285 | 1283 | }, |
| 1286 | 1284 | .probe = mt8183_afe_pcm_dev_probe, |
| 1287 | 1285 | .remove = mt8183_afe_pcm_dev_remove, |
| @@ -155,9 +155,9 @@ static const struct snd_soc_ops mt8183_da7219_rt1015_i2s_ops = { · 154 unmodified lines | ||
| 155 | 155 | static int mt8183_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 156 | 156 | struct snd_pcm_hw_params *params) |
| 157 | 157 | { |
| 158 | − /* fix BE i2s format to 32bit, clean param mask first */ | |
| 158 | + /* fix BE i2s format to S32_LE, clean param mask first */ | |
| 159 | 159 | snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), |
| 160 | − 0, SNDRV_PCM_FORMAT_LAST); | |
| 160 | + 0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST); | |
| 161 | 161 | |
| 162 | 162 | params_set_format(params, SNDRV_PCM_FORMAT_S32_LE); |
| 163 | 163 | |
| @@ -167,9 +167,9 @@ static int mt8183_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, · 3 unmodified lines | ||
| 167 | 167 | static int mt8183_rt1015_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 168 | 168 | struct snd_pcm_hw_params *params) |
| 169 | 169 | { |
| 170 | − /* fix BE i2s format to 32bit, clean param mask first */ | |
| 170 | + /* fix BE i2s format to S24_LE, clean param mask first */ | |
| 171 | 171 | snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), |
| 172 | − 0, SNDRV_PCM_FORMAT_LAST); | |
| 172 | + 0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST); | |
| 173 | 173 | |
| 174 | 174 | params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); |
| 175 | 175 | |
| @@ -685,7 +685,6 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev) · 509 unmodified lines | ||
| 685 | 685 | struct snd_soc_dai_link *dai_link; |
| 686 | 686 | struct mt8183_da7219_max98357_priv *priv; |
| 687 | 687 | struct pinctrl *pinctrl; |
| 688 | − const struct of_device_id *match; | |
| 689 | 688 | int ret, i; |
| 690 | 689 | |
| 691 | 690 | platform_node = of_parse_phandle(pdev->dev.of_node, |
| @@ -695,11 +694,9 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 695 | 694 | return -EINVAL; |
| 696 | 695 | } |
| 697 | 696 | |
| 698 | − match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); | |
| 699 | − if (!match || !match->data) | |
| 697 | + card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev); | |
| 698 | + if (!card) | |
| 700 | 699 | return -EINVAL; |
| 701 | − | |
| 702 | − card = (struct snd_soc_card *)match->data; | |
| 703 | 700 | card->dev = &pdev->dev; |
| 704 | 701 | |
| 705 | 702 | hdmi_codec = of_parse_phandle(pdev->dev.of_node, |
| @@ -781,7 +778,11 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev) · 75 unmodified lines | ||
| 781 | 778 | return ret; |
| 782 | 779 | } |
| 783 | 780 | |
| 784 | − return devm_snd_soc_register_card(&pdev->dev, card); | |
| 781 | + ret = devm_snd_soc_register_card(&pdev->dev, card); | |
| 782 | + | |
| 783 | + of_node_put(platform_node); | |
| 784 | + of_node_put(hdmi_codec); | |
| 785 | + return ret; | |
| 785 | 786 | } |
| 786 | 787 | |
| 787 | 788 | #ifdef CONFIG_OF |
| @@ -94,11 +94,11 @@ static const struct snd_soc_ops mt8183_mt6358_rt1015_i2s_ops = { · 93 unmodified lines | ||
| 94 | 94 | static int mt8183_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 95 | 95 | struct snd_pcm_hw_params *params) |
| 96 | 96 | { |
| 97 | − dev_dbg(rtd->dev, "%s(), fix format to 32bit\n", __func__); | |
| 97 | + dev_dbg(rtd->dev, "%s(), fix format to S32_LE\n", __func__); | |
| 98 | 98 | |
| 99 | − /* fix BE i2s format to 32bit, clean param mask first */ | |
| 99 | + /* fix BE i2s format to S32_LE, clean param mask first */ | |
| 100 | 100 | snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), |
| 101 | − 0, SNDRV_PCM_FORMAT_LAST); | |
| 101 | + 0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST); | |
| 102 | 102 | |
| 103 | 103 | params_set_format(params, SNDRV_PCM_FORMAT_S32_LE); |
| 104 | 104 | return 0; |
| @@ -107,11 +107,11 @@ static int mt8183_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, · 2 unmodified lines | ||
| 107 | 107 | static int mt8183_rt1015_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 108 | 108 | struct snd_pcm_hw_params *params) |
| 109 | 109 | { |
| 110 | − dev_dbg(rtd->dev, "%s(), fix format to 32bit\n", __func__); | |
| 110 | + dev_dbg(rtd->dev, "%s(), fix format to S24_LE\n", __func__); | |
| 111 | 111 | |
| 112 | − /* fix BE i2s format to 32bit, clean param mask first */ | |
| 112 | + /* fix BE i2s format to S24_LE, clean param mask first */ | |
| 113 | 113 | snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), |
| 114 | − 0, SNDRV_PCM_FORMAT_LAST); | |
| 114 | + 0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST); | |
| 115 | 115 | |
| 116 | 116 | params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); |
| 117 | 117 | return 0; |
| @@ -637,7 +637,6 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev) · 519 unmodified lines | ||
| 637 | 637 | struct device_node *platform_node, *ec_codec, *hdmi_codec; |
| 638 | 638 | struct snd_soc_dai_link *dai_link; |
| 639 | 639 | struct mt8183_mt6358_ts3a227_max98357_priv *priv; |
| 640 | − const struct of_device_id *match; | |
| 641 | 640 | int ret, i; |
| 642 | 641 | |
| 643 | 642 | platform_node = of_parse_phandle(pdev->dev.of_node, |
| @@ -647,11 +646,9 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 647 | 646 | return -EINVAL; |
| 648 | 647 | } |
| 649 | 648 | |
| 650 | − match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); | |
| 651 | − if (!match || !match->data) | |
| 649 | + card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev); | |
| 650 | + if (!card) | |
| 652 | 651 | return -EINVAL; |
| 653 | − | |
| 654 | − card = (struct snd_soc_card *)match->data; | |
| 655 | 652 | card->dev = &pdev->dev; |
| 656 | 653 | |
| 657 | 654 | ec_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,ec-codec", 0); |
| @@ -780,7 +777,12 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev) · 122 unmodified lines | ||
| 780 | 777 | __func__, ret); |
| 781 | 778 | } |
| 782 | 779 | |
| 783 | − return devm_snd_soc_register_card(&pdev->dev, card); | |
| 780 | + ret = devm_snd_soc_register_card(&pdev->dev, card); | |
| 781 | + | |
| 782 | + of_node_put(platform_node); | |
| 783 | + of_node_put(ec_codec); | |
| 784 | + of_node_put(hdmi_codec); | |
| 785 | + return ret; | |
| 784 | 786 | } |
| 785 | 787 | |
| 786 | 788 | #ifdef CONFIG_OF |
| @@ -2381,9 +2381,7 @@ static struct platform_driver mt8192_afe_pcm_driver = { · 2380 unmodified lines | ||
| 2381 | 2381 | .driver = { |
| 2382 | 2382 | .name = "mt8192-audio", |
| 2383 | 2383 | .of_match_table = mt8192_afe_pcm_dt_match, |
| 2384 | −#ifdef CONFIG_PM | |
| 2385 | 2384 | .pm = &mt8192_afe_pm_ops, |
| 2386 | −#endif | |
| 2387 | 2385 | }, |
| 2388 | 2386 | .probe = mt8192_afe_pcm_dev_probe, |
| 2389 | 2387 | .remove = mt8192_afe_pcm_dev_remove, |
| @@ -350,9 +350,9 @@ static int mt8192_mt6359_hdmi_init(struct snd_soc_pcm_runtime *rtd) · 349 unmodified lines | ||
| 350 | 350 | static int mt8192_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 351 | 351 | struct snd_pcm_hw_params *params) |
| 352 | 352 | { |
| 353 | − /* fix BE i2s format to 32bit, clean param mask first */ | |
| 353 | + /* fix BE i2s format to S24_LE, clean param mask first */ | |
| 354 | 354 | snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), |
| 355 | − 0, SNDRV_PCM_FORMAT_LAST); | |
| 355 | + 0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST); | |
| 356 | 356 | |
| 357 | 357 | params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); |
| 358 | 358 | |
| @@ -1106,7 +1106,6 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) · 747 unmodified lines | ||
| 1106 | 1106 | struct device_node *platform_node, *hdmi_codec; |
| 1107 | 1107 | int ret, i; |
| 1108 | 1108 | struct snd_soc_dai_link *dai_link; |
| 1109 | − const struct of_device_id *match; | |
| 1110 | 1109 | struct mt8192_mt6359_priv *priv; |
| 1111 | 1110 | |
| 1112 | 1111 | platform_node = of_parse_phandle(pdev->dev.of_node, |
| @@ -1116,11 +1115,9 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 1116 | 1115 | return -EINVAL; |
| 1117 | 1116 | } |
| 1118 | 1117 | |
| 1119 | − match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); | |
| 1120 | − if (!match || !match->data) | |
| 1118 | + card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev); | |
| 1119 | + if (!card) | |
| 1121 | 1120 | return -EINVAL; |
| 1122 | − | |
| 1123 | − card = (struct snd_soc_card *)match->data; | |
| 1124 | 1121 | card->dev = &pdev->dev; |
| 1125 | 1122 | |
| 1126 | 1123 | hdmi_codec = of_parse_phandle(pdev->dev.of_node, |
| @@ -1172,7 +1169,11 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) · 45 unmodified lines | ||
| 1172 | 1169 | return ret; |
| 1173 | 1170 | } |
| 1174 | 1171 | |
| 1175 | − return devm_snd_soc_register_card(&pdev->dev, card); | |
| 1172 | + ret = devm_snd_soc_register_card(&pdev->dev, card); | |
| 1173 | + | |
| 1174 | + of_node_put(platform_node); | |
| 1175 | + of_node_put(hdmi_codec); | |
| 1176 | + return ret; | |
| 1176 | 1177 | } |
| 1177 | 1178 | |
| 1178 | 1179 | #ifdef CONFIG_OF |
| @@ -326,7 +326,7 @@ int mt8195_afe_enable_reg_rw_clk(struct mtk_base_afe *afe) · 325 unmodified lines | ||
| 326 | 326 | { |
| 327 | 327 | struct mt8195_afe_private *afe_priv = afe->platform_priv; |
| 328 | 328 | int i; |
| 329 | − unsigned int clk_array[] = { | |
| 329 | + static const unsigned int clk_array[] = { | |
| 330 | 330 | MT8195_CLK_SCP_ADSP_AUDIODSP, /* bus clock for infra */ |
| 331 | 331 | MT8195_CLK_TOP_AUDIO_H_SEL, /* clock for ADSP bus */ |
| 332 | 332 | MT8195_CLK_TOP_AUDIO_LOCAL_BUS_SEL, /* bus clock for DRAM access */ |
| @@ -347,7 +347,7 @@ int mt8195_afe_disable_reg_rw_clk(struct mtk_base_afe *afe) · 14 unmodified lines | ||
| 347 | 347 | { |
| 348 | 348 | struct mt8195_afe_private *afe_priv = afe->platform_priv; |
| 349 | 349 | int i; |
| 350 | − unsigned int clk_array[] = { | |
| 350 | + static const unsigned int clk_array[] = { | |
| 351 | 351 | MT8195_CLK_AUD_A1SYS, |
| 352 | 352 | MT8195_CLK_AUD_A1SYS_HP, |
| 353 | 353 | MT8195_CLK_AUD_AFE, |
| @@ -380,11 +380,11 @@ static int mt8195_afe_enable_timing_sys(struct mtk_base_afe *afe) · 26 unmodified lines | ||
| 380 | 380 | { |
| 381 | 381 | struct mt8195_afe_private *afe_priv = afe->platform_priv; |
| 382 | 382 | int i; |
| 383 | − unsigned int clk_array[] = { | |
| 383 | + static const unsigned int clk_array[] = { | |
| 384 | 384 | MT8195_CLK_AUD_A1SYS, |
| 385 | 385 | MT8195_CLK_AUD_A2SYS, |
| 386 | 386 | }; |
| 387 | − unsigned int cg_array[] = { | |
| 387 | + static const unsigned int cg_array[] = { | |
| 388 | 388 | MT8195_TOP_CG_A1SYS_TIMING, |
| 389 | 389 | MT8195_TOP_CG_A2SYS_TIMING, |
| 390 | 390 | MT8195_TOP_CG_26M_TIMING, |
| @@ -403,11 +403,11 @@ static int mt8195_afe_disable_timing_sys(struct mtk_base_afe *afe) · 12 unmodified lines | ||
| 403 | 403 | { |
| 404 | 404 | struct mt8195_afe_private *afe_priv = afe->platform_priv; |
| 405 | 405 | int i; |
| 406 | − unsigned int clk_array[] = { | |
| 406 | + static const unsigned int clk_array[] = { | |
| 407 | 407 | MT8195_CLK_AUD_A2SYS, |
| 408 | 408 | MT8195_CLK_AUD_A1SYS, |
| 409 | 409 | }; |
| 410 | − unsigned int cg_array[] = { | |
| 410 | + static const unsigned int cg_array[] = { | |
| 411 | 411 | MT8195_TOP_CG_26M_TIMING, |
| 412 | 412 | MT8195_TOP_CG_A2SYS_TIMING, |
| 413 | 413 | MT8195_TOP_CG_A1SYS_TIMING, |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <linux/of.h> |
| 15 | 15 | #include <linux/of_address.h> |
| 16 | 16 | #include <linux/of_platform.h> |
| 17 | +#include <linux/of_reserved_mem.h> | |
| 17 | 18 | #include <linux/pm_runtime.h> |
| 18 | 19 | #include "mt8195-afe-common.h" |
| 19 | 20 | #include "mt8195-afe-clk.h" |
| @@ -3028,7 +3029,7 @@ static const struct reg_sequence mt8195_afe_reg_defaults[] = { · 3008 unmodified lines | ||
| 3028 | 3029 | |
| 3029 | 3030 | static const struct reg_sequence mt8195_cg_patch[] = { |
| 3030 | 3031 | { AUDIO_TOP_CON0, 0xfffffffb }, |
| 3031 | − { AUDIO_TOP_CON1, 0xfffffffa }, | |
| 3032 | + { AUDIO_TOP_CON1, 0xfffffff8 }, | |
| 3032 | 3033 | }; |
| 3033 | 3034 | |
| 3034 | 3035 | static int mt8195_afe_init_registers(struct mtk_base_afe *afe) |
| @@ -3061,6 +3062,12 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev) · 26 unmodified lines | ||
| 3061 | 3062 | int i, irq_id, ret; |
| 3062 | 3063 | struct snd_soc_component *component; |
| 3063 | 3064 | |
| 3065 | + ret = of_reserved_mem_device_init(dev); | |
| 3066 | + if (ret) { | |
| 3067 | + dev_err(dev, "failed to assign memory region: %d\n", ret); | |
| 3068 | + return ret; | |
| 3069 | + } | |
| 3070 | + | |
| 3064 | 3071 | ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(33)); |
| 3065 | 3072 | if (ret) |
| 3066 | 3073 | return ret; |
| @@ -80,8 +80,15 @@ static const struct snd_soc_dapm_widget mtk_dai_pcm_widgets[] = { · 79 unmodified lines | ||
| 80 | 80 | mtk_dai_pcm_o001_mix, |
| 81 | 81 | ARRAY_SIZE(mtk_dai_pcm_o001_mix)), |
| 82 | 82 | |
| 83 | + SND_SOC_DAPM_SUPPLY("PCM_EN", PCM_INTF_CON1, | |
| 84 | + PCM_INTF_CON1_PCM_EN_SHIFT, 0, NULL, 0), | |
| 85 | + | |
| 83 | 86 | SND_SOC_DAPM_INPUT("PCM1_INPUT"), |
| 84 | 87 | SND_SOC_DAPM_OUTPUT("PCM1_OUTPUT"), |
| 88 | + | |
| 89 | + SND_SOC_DAPM_CLOCK_SUPPLY("aud_asrc11"), | |
| 90 | + SND_SOC_DAPM_CLOCK_SUPPLY("aud_asrc12"), | |
| 91 | + SND_SOC_DAPM_CLOCK_SUPPLY("aud_pcmif"), | |
| 85 | 92 | }; |
| 86 | 93 | |
| 87 | 94 | static const struct snd_soc_dapm_route mtk_dai_pcm_routes[] = { |
| @@ -97,22 +104,18 @@ static const struct snd_soc_dapm_route mtk_dai_pcm_routes[] = { · 9 unmodified lines | ||
| 97 | 104 | {"PCM1 Playback", NULL, "O000"}, |
| 98 | 105 | {"PCM1 Playback", NULL, "O001"}, |
| 99 | 106 | |
| 107 | + {"PCM1 Playback", NULL, "PCM_EN"}, | |
| 108 | + {"PCM1 Playback", NULL, "aud_asrc12"}, | |
| 109 | + {"PCM1 Playback", NULL, "aud_pcmif"}, | |
| 110 | + | |
| 111 | + {"PCM1 Capture", NULL, "PCM_EN"}, | |
| 112 | + {"PCM1 Capture", NULL, "aud_asrc11"}, | |
| 113 | + {"PCM1 Capture", NULL, "aud_pcmif"}, | |
| 114 | + | |
| 100 | 115 | {"PCM1_OUTPUT", NULL, "PCM1 Playback"}, |
| 101 | 116 | {"PCM1 Capture", NULL, "PCM1_INPUT"}, |
| 102 | 117 | }; |
| 103 | 118 | |
| 104 | −static void mtk_dai_pcm_enable(struct mtk_base_afe *afe) | |
| 105 | −{ | |
| 106 | − regmap_update_bits(afe->regmap, PCM_INTF_CON1, | |
| 107 | − PCM_INTF_CON1_PCM_EN, PCM_INTF_CON1_PCM_EN); | |
| 108 | −} | |
| 109 | − | |
| 110 | −static void mtk_dai_pcm_disable(struct mtk_base_afe *afe) | |
| 111 | −{ | |
| 112 | − regmap_update_bits(afe->regmap, PCM_INTF_CON1, | |
| 113 | − PCM_INTF_CON1_PCM_EN, 0x0); | |
| 114 | −} | |
| 115 | − | |
| 116 | 119 | static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream, |
| 117 | 120 | struct snd_soc_dai *dai) |
| 118 | 121 | { |
| @@ -207,54 +210,22 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream, · 88 unmodified lines | ||
| 207 | 210 | } |
| 208 | 211 | |
| 209 | 212 | /* dai ops */ |
| 210 | −static int mtk_dai_pcm_startup(struct snd_pcm_substream *substream, | |
| 211 | − struct snd_soc_dai *dai) | |
| 212 | −{ | |
| 213 | − struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); | |
| 214 | − struct mt8195_afe_private *afe_priv = afe->platform_priv; | |
| 215 | − | |
| 216 | − if (dai->component->active) | |
| 217 | − return 0; | |
| 218 | − | |
| 219 | − mt8195_afe_enable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC11]); | |
| 220 | − mt8195_afe_enable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC12]); | |
| 221 | − mt8195_afe_enable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_PCMIF]); | |
| 222 | − | |
| 223 | − return 0; | |
| 224 | −} | |
| 225 | − | |
| 226 | −static void mtk_dai_pcm_shutdown(struct snd_pcm_substream *substream, | |
| 227 | − struct snd_soc_dai *dai) | |
| 228 | −{ | |
| 229 | − struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); | |
| 230 | − struct mt8195_afe_private *afe_priv = afe->platform_priv; | |
| 231 | − | |
| 232 | − if (dai->component->active) | |
| 233 | − return; | |
| 234 | − | |
| 235 | − mtk_dai_pcm_disable(afe); | |
| 236 | − | |
| 237 | − mt8195_afe_disable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_PCMIF]); | |
| 238 | − mt8195_afe_disable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC12]); | |
| 239 | − mt8195_afe_disable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC11]); | |
| 240 | −} | |
| 241 | − | |
| 242 | 213 | static int mtk_dai_pcm_prepare(struct snd_pcm_substream *substream, |
| 243 | 214 | struct snd_soc_dai *dai) |
| 244 | 215 | { |
| 245 | − struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); | |
| 246 | − int ret = 0; | |
| 216 | + int ret; | |
| 247 | 217 | |
| 248 | − if (snd_soc_dai_stream_active(dai, SNDRV_PCM_STREAM_PLAYBACK) && | |
| 249 | − snd_soc_dai_stream_active(dai, SNDRV_PCM_STREAM_CAPTURE)) | |
| 218 | + dev_dbg(dai->dev, "%s(), id %d, stream %d, widget active p %d, c %d\n", | |
| 219 | + __func__, dai->id, substream->stream, | |
| 220 | + dai->playback_widget->active, dai->capture_widget->active); | |
| 221 | + | |
| 222 | + if (dai->playback_widget->active || dai->capture_widget->active) | |
| 250 | 223 | return 0; |
| 251 | 224 | |
| 252 | 225 | ret = mtk_dai_pcm_configure(substream, dai); |
| 253 | 226 | if (ret) |
| 254 | 227 | return ret; |
| 255 | 228 | |
| 256 | − mtk_dai_pcm_enable(afe); | |
| 257 | − | |
| 258 | 229 | return 0; |
| 259 | 230 | } |
| 260 | 231 | |
| @@ -316,8 +287,6 @@ static int mtk_dai_pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) · 55 unmodified lines | ||
| 316 | 287 | } |
| 317 | 288 | |
| 318 | 289 | static const struct snd_soc_dai_ops mtk_dai_pcm_ops = { |
| 319 | − .startup = mtk_dai_pcm_startup, | |
| 320 | − .shutdown = mtk_dai_pcm_shutdown, | |
| 321 | 290 | .prepare = mtk_dai_pcm_prepare, |
| 322 | 291 | .set_fmt = mtk_dai_pcm_set_fmt, |
| 323 | 292 | }; |
| @@ -18,6 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | #include "../../codecs/rt1011.h" |
| 19 | 19 | #include "../../codecs/rt5682.h" |
| 20 | 20 | #include "../common/mtk-afe-platform-driver.h" |
| 21 | +#include "mt8195-afe-clk.h" | |
| 21 | 22 | #include "mt8195-afe-common.h" |
| 22 | 23 | |
| 23 | 24 | #define RT1011_CODEC_DAI "rt1011-aif" |
| @@ -27,13 +28,14 @@ · 3 unmodified lines | ||
| 27 | 28 | #define RT5682_CODEC_DAI "rt5682-aif1" |
| 28 | 29 | #define RT5682_DEV0_NAME "rt5682.2-001a" |
| 29 | 30 | |
| 31 | +#define RT5682S_CODEC_DAI "rt5682s-aif1" | |
| 32 | +#define RT5682S_DEV0_NAME "rt5682s.2-001a" | |
| 33 | + | |
| 30 | 34 | struct mt8195_mt6359_rt1011_rt5682_priv { |
| 31 | − struct device_node *platform_node; | |
| 32 | − struct device_node *hdmi_node; | |
| 33 | − struct device_node *dp_node; | |
| 34 | 35 | struct snd_soc_jack headset_jack; |
| 35 | 36 | struct snd_soc_jack dp_jack; |
| 36 | 37 | struct snd_soc_jack hdmi_jack; |
| 38 | + struct clk *i2so1_mclk; | |
| 37 | 39 | }; |
| 38 | 40 | |
| 39 | 41 | static const struct snd_soc_dapm_widget |
| @@ -84,8 +86,8 @@ static int mt8195_rt5682_etdm_hw_params(struct snd_pcm_substream *substream, · 44 unmodified lines | ||
| 84 | 86 | return ret; |
| 85 | 87 | } |
| 86 | 88 | |
| 87 | − ret = snd_soc_dai_set_pll(codec_dai, RT5682_PLL1, RT5682_PLL1_S_BCLK1, | |
| 88 | − rate * 64, rate * 512); | |
| 89 | + ret = snd_soc_dai_set_pll(codec_dai, RT5682_PLL1, RT5682_PLL1_S_MCLK, | |
260 more lines aren’t shown here.
This diff is large: its 683 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 58 lines aren’t shown here.
This diff is large: its 25 lines aren’t shown here.
This diff is large: its 43 lines aren’t shown here.
This diff is large: its 33 lines aren’t shown here.
This diff is large: its 33 lines aren’t shown here.
This diff is large: its 79 lines aren’t shown here.
This diff is large: its 43 lines aren’t shown here.
This diff is large: its 15 lines aren’t shown here.
This diff is large: its 23 lines aren’t shown here.
This diff is large: its 15 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 201 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 31 lines aren’t shown here.
This diff is large: its 51 lines aren’t shown here.
This diff is large: its 50 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 17 lines aren’t shown here.
This diff is large: its 27 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 14 lines aren’t shown here.
This diff is large: its 35 lines aren’t shown here.
This diff is large: its 65 lines aren’t shown here.
This diff is large: its 54 lines aren’t shown here.
This diff is large: its 940 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 52 lines aren’t shown here.
This diff is large: its 13 lines aren’t shown here.
This diff is large: its 34 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 79 lines aren’t shown here.
This diff is large: its 188 lines aren’t shown here.
This diff is large: its 200 lines aren’t shown here.
This diff is large: its 83 lines aren’t shown here.
This diff is large: its 182 lines aren’t shown here.
This diff is large: its 85 lines aren’t shown here.
This diff is large: its 447 lines aren’t shown here.
This diff is large: its 227 lines aren’t shown here.
This diff is large: its 166 lines aren’t shown here.
This diff is large: its 187 lines aren’t shown here.
This diff is large: its 158 lines aren’t shown here.
This diff is large: its 219 lines aren’t shown here.
This diff is large: its 214 lines aren’t shown here.
This diff is large: its 67 lines aren’t shown here.
This diff is large: its 36 lines aren’t shown here.
This diff is large: its 23 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 318 lines aren’t shown here.
This diff is large: its 367 lines aren’t shown here.
This diff is large: its 27 lines aren’t shown here.
This diff is large: its 137 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 143 lines aren’t shown here.
This diff is large: its 20 lines aren’t shown here.
This diff is large: its 62 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 179 lines aren’t shown here.
This diff is large: its 76 lines aren’t shown here.
This diff is large: its 72 lines aren’t shown here.
This diff is large: its 166 lines aren’t shown here.
This diff is large: its 169 lines aren’t shown here.
This diff is large: its 183 lines aren’t shown here.
This diff is large: its 408 lines aren’t shown here.
This diff is large: its 70 lines aren’t shown here.
This diff is large: its 107 lines aren’t shown here.
This diff is large: its 19 lines aren’t shown here.
This diff is large: its 30 lines aren’t shown here.
This diff is large: its 68 lines aren’t shown here.
This diff is large: its 253 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 34 lines aren’t shown here.
This diff is large: its 3 lines aren’t shown here.
This diff is large: its 50 lines aren’t shown here.
This diff is large: its 4 lines aren’t shown here.
This diff is large: its 159 lines aren’t shown here.
This diff is large: its 29 lines aren’t shown here.
This diff is large: its 57 lines aren’t shown here.
This diff is large: its 464 lines aren’t shown here.
This diff is large: its 159 lines aren’t shown here.
This diff is large: its 60 lines aren’t shown here.
This diff is large: its 142 lines aren’t shown here.
This diff is large: its 198 lines aren’t shown here.
This diff is large: its 31 lines aren’t shown here.
This diff is large: its 432 lines aren’t shown here.
This diff is large: its 43 lines aren’t shown here.
This diff is large: its 113 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 33 lines aren’t shown here.
This diff is large: its 205 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 411 lines aren’t shown here.
This diff is large: its 32 lines aren’t shown here.
This diff is large: its 75 lines aren’t shown here.
This diff is large: its 26 lines aren’t shown here.
This diff is large: its 109 lines aren’t shown here.
This diff is large: its 56 lines aren’t shown here.
This diff is large: its 64 lines aren’t shown here.
This diff is large: its 96 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 148 lines aren’t shown here.
This diff is large: its 100 lines aren’t shown here.
This diff is large: its 60 lines aren’t shown here.
This diff is large: its 352 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 302 lines aren’t shown here.
This diff is large: its 19 lines aren’t shown here.
This diff is large: its 13 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 43 lines aren’t shown here.
This diff is large: its 17 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 25 lines aren’t shown here.
This diff is large: its 27 lines aren’t shown here.
This diff is large: its 21 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 32 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 38 lines aren’t shown here.
This diff is large: its 25 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 2 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 706 lines aren’t shown here.