.. | .. |
---|
46 | 46 | #define DUAL_CHANNEL 2 |
---|
47 | 47 | |
---|
48 | 48 | static struct snd_soc_jack cz_jack; |
---|
49 | | -static struct clk *da7219_dai_clk; |
---|
50 | | -extern int bt_uart_enable; |
---|
| 49 | +static struct clk *da7219_dai_wclk; |
---|
| 50 | +static struct clk *da7219_dai_bclk; |
---|
| 51 | +extern bool bt_uart_enable; |
---|
51 | 52 | |
---|
52 | 53 | static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) |
---|
53 | 54 | { |
---|
54 | 55 | int ret; |
---|
55 | 56 | struct snd_soc_card *card = rtd->card; |
---|
56 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
---|
| 57 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
---|
57 | 58 | struct snd_soc_component *component = codec_dai->component; |
---|
58 | 59 | |
---|
59 | 60 | dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name); |
---|
.. | .. |
---|
72 | 73 | return ret; |
---|
73 | 74 | } |
---|
74 | 75 | |
---|
75 | | - da7219_dai_clk = clk_get(component->dev, "da7219-dai-clks"); |
---|
| 76 | + da7219_dai_wclk = devm_clk_get(component->dev, "da7219-dai-wclk"); |
---|
| 77 | + if (IS_ERR(da7219_dai_wclk)) |
---|
| 78 | + return PTR_ERR(da7219_dai_wclk); |
---|
| 79 | + |
---|
| 80 | + da7219_dai_bclk = devm_clk_get(component->dev, "da7219-dai-bclk"); |
---|
| 81 | + if (IS_ERR(da7219_dai_bclk)) |
---|
| 82 | + return PTR_ERR(da7219_dai_bclk); |
---|
76 | 83 | |
---|
77 | 84 | ret = snd_soc_card_jack_new(card, "Headset Jack", |
---|
78 | | - SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | |
---|
| 85 | + SND_JACK_HEADSET | SND_JACK_LINEOUT | |
---|
79 | 86 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
---|
80 | 87 | SND_JACK_BTN_2 | SND_JACK_BTN_3, |
---|
81 | 88 | &cz_jack, NULL, 0); |
---|
.. | .. |
---|
97 | 104 | static int da7219_clk_enable(struct snd_pcm_substream *substream) |
---|
98 | 105 | { |
---|
99 | 106 | int ret = 0; |
---|
100 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
| 107 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
101 | 108 | |
---|
102 | | - ret = clk_prepare_enable(da7219_dai_clk); |
---|
| 109 | + /* |
---|
| 110 | + * Set wclk to 48000 because the rate constraint of this driver is |
---|
| 111 | + * 48000. ADAU7002 spec: "The ADAU7002 requires a BCLK rate that is |
---|
| 112 | + * minimum of 64x the LRCLK sample rate." DA7219 is the only clk |
---|
| 113 | + * source so for all codecs we have to limit bclk to 64X lrclk. |
---|
| 114 | + */ |
---|
| 115 | + clk_set_rate(da7219_dai_wclk, 48000); |
---|
| 116 | + clk_set_rate(da7219_dai_bclk, 48000 * 64); |
---|
| 117 | + ret = clk_prepare_enable(da7219_dai_bclk); |
---|
103 | 118 | if (ret < 0) { |
---|
104 | 119 | dev_err(rtd->dev, "can't enable master clock %d\n", ret); |
---|
105 | 120 | return ret; |
---|
.. | .. |
---|
110 | 125 | |
---|
111 | 126 | static void da7219_clk_disable(void) |
---|
112 | 127 | { |
---|
113 | | - clk_disable_unprepare(da7219_dai_clk); |
---|
| 128 | + clk_disable_unprepare(da7219_dai_bclk); |
---|
114 | 129 | } |
---|
115 | 130 | |
---|
116 | 131 | static const unsigned int channels[] = { |
---|
.. | .. |
---|
133 | 148 | .mask = 0, |
---|
134 | 149 | }; |
---|
135 | 150 | |
---|
136 | | -static int cz_da7219_startup(struct snd_pcm_substream *substream) |
---|
| 151 | +static int cz_da7219_play_startup(struct snd_pcm_substream *substream) |
---|
137 | 152 | { |
---|
138 | 153 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
139 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
| 154 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
140 | 155 | struct snd_soc_card *card = rtd->card; |
---|
141 | 156 | struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
142 | 157 | |
---|
.. | .. |
---|
150 | 165 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
---|
151 | 166 | &constraints_rates); |
---|
152 | 167 | |
---|
153 | | - machine->i2s_instance = I2S_SP_INSTANCE; |
---|
| 168 | + machine->play_i2s_instance = I2S_SP_INSTANCE; |
---|
| 169 | + return da7219_clk_enable(substream); |
---|
| 170 | +} |
---|
| 171 | + |
---|
| 172 | +static int cz_da7219_cap_startup(struct snd_pcm_substream *substream) |
---|
| 173 | +{ |
---|
| 174 | + struct snd_pcm_runtime *runtime = substream->runtime; |
---|
| 175 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 176 | + struct snd_soc_card *card = rtd->card; |
---|
| 177 | + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
| 178 | + |
---|
| 179 | + /* |
---|
| 180 | + * On this platform for PCM device we support stereo |
---|
| 181 | + */ |
---|
| 182 | + |
---|
| 183 | + runtime->hw.channels_max = DUAL_CHANNEL; |
---|
| 184 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
---|
| 185 | + &constraints_channels); |
---|
| 186 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
---|
| 187 | + &constraints_rates); |
---|
| 188 | + |
---|
| 189 | + machine->cap_i2s_instance = I2S_SP_INSTANCE; |
---|
154 | 190 | machine->capture_channel = CAP_CHANNEL1; |
---|
| 191 | + return da7219_clk_enable(substream); |
---|
| 192 | +} |
---|
| 193 | + |
---|
| 194 | +static int cz_max_startup(struct snd_pcm_substream *substream) |
---|
| 195 | +{ |
---|
| 196 | + struct snd_pcm_runtime *runtime = substream->runtime; |
---|
| 197 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 198 | + struct snd_soc_card *card = rtd->card; |
---|
| 199 | + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
| 200 | + |
---|
| 201 | + /* |
---|
| 202 | + * On this platform for PCM device we support stereo |
---|
| 203 | + */ |
---|
| 204 | + |
---|
| 205 | + runtime->hw.channels_max = DUAL_CHANNEL; |
---|
| 206 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
---|
| 207 | + &constraints_channels); |
---|
| 208 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
---|
| 209 | + &constraints_rates); |
---|
| 210 | + |
---|
| 211 | + machine->play_i2s_instance = I2S_BT_INSTANCE; |
---|
| 212 | + return da7219_clk_enable(substream); |
---|
| 213 | +} |
---|
| 214 | + |
---|
| 215 | +static int cz_dmic0_startup(struct snd_pcm_substream *substream) |
---|
| 216 | +{ |
---|
| 217 | + struct snd_pcm_runtime *runtime = substream->runtime; |
---|
| 218 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 219 | + struct snd_soc_card *card = rtd->card; |
---|
| 220 | + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
| 221 | + |
---|
| 222 | + /* |
---|
| 223 | + * On this platform for PCM device we support stereo |
---|
| 224 | + */ |
---|
| 225 | + |
---|
| 226 | + runtime->hw.channels_max = DUAL_CHANNEL; |
---|
| 227 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
---|
| 228 | + &constraints_channels); |
---|
| 229 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
---|
| 230 | + &constraints_rates); |
---|
| 231 | + |
---|
| 232 | + machine->cap_i2s_instance = I2S_BT_INSTANCE; |
---|
| 233 | + return da7219_clk_enable(substream); |
---|
| 234 | +} |
---|
| 235 | + |
---|
| 236 | +static int cz_dmic1_startup(struct snd_pcm_substream *substream) |
---|
| 237 | +{ |
---|
| 238 | + struct snd_pcm_runtime *runtime = substream->runtime; |
---|
| 239 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 240 | + struct snd_soc_card *card = rtd->card; |
---|
| 241 | + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
| 242 | + |
---|
| 243 | + /* |
---|
| 244 | + * On this platform for PCM device we support stereo |
---|
| 245 | + */ |
---|
| 246 | + |
---|
| 247 | + runtime->hw.channels_max = DUAL_CHANNEL; |
---|
| 248 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
---|
| 249 | + &constraints_channels); |
---|
| 250 | + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
---|
| 251 | + &constraints_rates); |
---|
| 252 | + |
---|
| 253 | + machine->cap_i2s_instance = I2S_SP_INSTANCE; |
---|
| 254 | + machine->capture_channel = CAP_CHANNEL0; |
---|
155 | 255 | return da7219_clk_enable(substream); |
---|
156 | 256 | } |
---|
157 | 257 | |
---|
.. | .. |
---|
160 | 260 | da7219_clk_disable(); |
---|
161 | 261 | } |
---|
162 | 262 | |
---|
163 | | -static int cz_max_startup(struct snd_pcm_substream *substream) |
---|
164 | | -{ |
---|
165 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
166 | | - struct snd_soc_card *card = rtd->card; |
---|
167 | | - struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
168 | | - |
---|
169 | | - machine->i2s_instance = I2S_BT_INSTANCE; |
---|
170 | | - return da7219_clk_enable(substream); |
---|
171 | | -} |
---|
172 | | - |
---|
173 | | -static void cz_max_shutdown(struct snd_pcm_substream *substream) |
---|
174 | | -{ |
---|
175 | | - da7219_clk_disable(); |
---|
176 | | -} |
---|
177 | | - |
---|
178 | | -static int cz_dmic0_startup(struct snd_pcm_substream *substream) |
---|
179 | | -{ |
---|
180 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
181 | | - struct snd_soc_card *card = rtd->card; |
---|
182 | | - struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
183 | | - |
---|
184 | | - machine->i2s_instance = I2S_BT_INSTANCE; |
---|
185 | | - return da7219_clk_enable(substream); |
---|
186 | | -} |
---|
187 | | - |
---|
188 | | -static int cz_dmic1_startup(struct snd_pcm_substream *substream) |
---|
189 | | -{ |
---|
190 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
191 | | - struct snd_soc_card *card = rtd->card; |
---|
192 | | - struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); |
---|
193 | | - |
---|
194 | | - machine->i2s_instance = I2S_SP_INSTANCE; |
---|
195 | | - machine->capture_channel = CAP_CHANNEL0; |
---|
196 | | - return da7219_clk_enable(substream); |
---|
197 | | -} |
---|
198 | | - |
---|
199 | | -static void cz_dmic_shutdown(struct snd_pcm_substream *substream) |
---|
200 | | -{ |
---|
201 | | - da7219_clk_disable(); |
---|
202 | | -} |
---|
| 263 | +static const struct snd_soc_ops cz_da7219_play_ops = { |
---|
| 264 | + .startup = cz_da7219_play_startup, |
---|
| 265 | + .shutdown = cz_da7219_shutdown, |
---|
| 266 | +}; |
---|
203 | 267 | |
---|
204 | 268 | static const struct snd_soc_ops cz_da7219_cap_ops = { |
---|
205 | | - .startup = cz_da7219_startup, |
---|
| 269 | + .startup = cz_da7219_cap_startup, |
---|
206 | 270 | .shutdown = cz_da7219_shutdown, |
---|
207 | 271 | }; |
---|
208 | 272 | |
---|
209 | 273 | static const struct snd_soc_ops cz_max_play_ops = { |
---|
210 | 274 | .startup = cz_max_startup, |
---|
211 | | - .shutdown = cz_max_shutdown, |
---|
| 275 | + .shutdown = cz_da7219_shutdown, |
---|
212 | 276 | }; |
---|
213 | 277 | |
---|
214 | 278 | static const struct snd_soc_ops cz_dmic0_cap_ops = { |
---|
215 | 279 | .startup = cz_dmic0_startup, |
---|
216 | | - .shutdown = cz_dmic_shutdown, |
---|
| 280 | + .shutdown = cz_da7219_shutdown, |
---|
217 | 281 | }; |
---|
218 | 282 | |
---|
219 | 283 | static const struct snd_soc_ops cz_dmic1_cap_ops = { |
---|
220 | 284 | .startup = cz_dmic1_startup, |
---|
221 | | - .shutdown = cz_dmic_shutdown, |
---|
| 285 | + .shutdown = cz_da7219_shutdown, |
---|
222 | 286 | }; |
---|
| 287 | + |
---|
| 288 | +SND_SOC_DAILINK_DEF(designware1, |
---|
| 289 | + DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.1.auto"))); |
---|
| 290 | +SND_SOC_DAILINK_DEF(designware2, |
---|
| 291 | + DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.2.auto"))); |
---|
| 292 | +SND_SOC_DAILINK_DEF(designware3, |
---|
| 293 | + DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.3.auto"))); |
---|
| 294 | + |
---|
| 295 | +SND_SOC_DAILINK_DEF(dlgs, |
---|
| 296 | + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00", "da7219-hifi"))); |
---|
| 297 | +SND_SOC_DAILINK_DEF(mx, |
---|
| 298 | + DAILINK_COMP_ARRAY(COMP_CODEC("MX98357A:00", "HiFi"))); |
---|
| 299 | +SND_SOC_DAILINK_DEF(adau, |
---|
| 300 | + DAILINK_COMP_ARRAY(COMP_CODEC("ADAU7002:00", "adau7002-hifi"))); |
---|
| 301 | + |
---|
| 302 | +SND_SOC_DAILINK_DEF(platform, |
---|
| 303 | + DAILINK_COMP_ARRAY(COMP_PLATFORM("acp_audio_dma.0.auto"))); |
---|
223 | 304 | |
---|
224 | 305 | static struct snd_soc_dai_link cz_dai_7219_98357[] = { |
---|
225 | 306 | { |
---|
226 | 307 | .name = "amd-da7219-play", |
---|
227 | 308 | .stream_name = "Playback", |
---|
228 | | - .platform_name = "acp_audio_dma.0.auto", |
---|
229 | | - .cpu_dai_name = "designware-i2s.1.auto", |
---|
230 | | - .codec_dai_name = "da7219-hifi", |
---|
231 | | - .codec_name = "i2c-DLGS7219:00", |
---|
232 | 309 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
---|
233 | 310 | | SND_SOC_DAIFMT_CBM_CFM, |
---|
234 | 311 | .init = cz_da7219_init, |
---|
235 | 312 | .dpcm_playback = 1, |
---|
236 | | - .ops = &cz_da7219_cap_ops, |
---|
| 313 | + .ops = &cz_da7219_play_ops, |
---|
| 314 | + SND_SOC_DAILINK_REG(designware1, dlgs, platform), |
---|
237 | 315 | }, |
---|
238 | 316 | { |
---|
239 | 317 | .name = "amd-da7219-cap", |
---|
240 | 318 | .stream_name = "Capture", |
---|
241 | | - .platform_name = "acp_audio_dma.0.auto", |
---|
242 | | - .cpu_dai_name = "designware-i2s.2.auto", |
---|
243 | | - .codec_dai_name = "da7219-hifi", |
---|
244 | | - .codec_name = "i2c-DLGS7219:00", |
---|
245 | 319 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
---|
246 | 320 | | SND_SOC_DAIFMT_CBM_CFM, |
---|
247 | 321 | .dpcm_capture = 1, |
---|
248 | 322 | .ops = &cz_da7219_cap_ops, |
---|
| 323 | + SND_SOC_DAILINK_REG(designware2, dlgs, platform), |
---|
249 | 324 | }, |
---|
250 | 325 | { |
---|
251 | 326 | .name = "amd-max98357-play", |
---|
252 | 327 | .stream_name = "HiFi Playback", |
---|
253 | | - .platform_name = "acp_audio_dma.0.auto", |
---|
254 | | - .cpu_dai_name = "designware-i2s.3.auto", |
---|
255 | | - .codec_dai_name = "HiFi", |
---|
256 | | - .codec_name = "MX98357A:00", |
---|
257 | 328 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
---|
258 | 329 | | SND_SOC_DAIFMT_CBM_CFM, |
---|
259 | 330 | .dpcm_playback = 1, |
---|
260 | 331 | .ops = &cz_max_play_ops, |
---|
| 332 | + SND_SOC_DAILINK_REG(designware3, mx, platform), |
---|
261 | 333 | }, |
---|
262 | 334 | { |
---|
263 | 335 | /* C panel DMIC */ |
---|
264 | 336 | .name = "dmic0", |
---|
265 | 337 | .stream_name = "DMIC0 Capture", |
---|
266 | | - .platform_name = "acp_audio_dma.0.auto", |
---|
267 | | - .cpu_dai_name = "designware-i2s.3.auto", |
---|
268 | | - .codec_dai_name = "adau7002-hifi", |
---|
269 | | - .codec_name = "ADAU7002:00", |
---|
270 | 338 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
---|
271 | 339 | | SND_SOC_DAIFMT_CBM_CFM, |
---|
272 | 340 | .dpcm_capture = 1, |
---|
273 | 341 | .ops = &cz_dmic0_cap_ops, |
---|
| 342 | + SND_SOC_DAILINK_REG(designware3, adau, platform), |
---|
274 | 343 | }, |
---|
275 | 344 | { |
---|
276 | 345 | /* A/B panel DMIC */ |
---|
277 | 346 | .name = "dmic1", |
---|
278 | 347 | .stream_name = "DMIC1 Capture", |
---|
279 | | - .platform_name = "acp_audio_dma.0.auto", |
---|
280 | | - .cpu_dai_name = "designware-i2s.2.auto", |
---|
281 | | - .codec_dai_name = "adau7002-hifi", |
---|
282 | | - .codec_name = "ADAU7002:00", |
---|
283 | 348 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
---|
284 | 349 | | SND_SOC_DAIFMT_CBM_CFM, |
---|
285 | 350 | .dpcm_capture = 1, |
---|
286 | 351 | .ops = &cz_dmic1_cap_ops, |
---|
| 352 | + SND_SOC_DAILINK_REG(designware2, adau, platform), |
---|
287 | 353 | }, |
---|
288 | 354 | }; |
---|
289 | 355 | |
---|
.. | .. |
---|
344 | 410 | static struct regulator_ops acp_da7219_ops = { |
---|
345 | 411 | }; |
---|
346 | 412 | |
---|
347 | | -static struct regulator_desc acp_da7219_desc = { |
---|
| 413 | +static const struct regulator_desc acp_da7219_desc = { |
---|
348 | 414 | .name = "reg-fixed-1.8V", |
---|
349 | 415 | .type = REGULATOR_VOLTAGE, |
---|
350 | 416 | .owner = THIS_MODULE, |
---|
.. | .. |
---|
389 | 455 | return 0; |
---|
390 | 456 | } |
---|
391 | 457 | |
---|
| 458 | +#ifdef CONFIG_ACPI |
---|
392 | 459 | static const struct acpi_device_id cz_audio_acpi_match[] = { |
---|
393 | 460 | { "AMD7219", 0 }, |
---|
394 | 461 | {}, |
---|
395 | 462 | }; |
---|
396 | 463 | MODULE_DEVICE_TABLE(acpi, cz_audio_acpi_match); |
---|
| 464 | +#endif |
---|
397 | 465 | |
---|
398 | 466 | static struct platform_driver cz_pcm_driver = { |
---|
399 | 467 | .driver = { |
---|