1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel Broxton-P I2S Machine Driver
5 * Copyright (C) 2016, Intel Corporation. All rights reserved.
8 * Intel Skylake I2S Machine driver
11 #include <linux/input.h>
12 #include <linux/module.h>
13 #include <linux/platform_device.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/soc-acpi.h>
20 #include "../../codecs/hdac_hdmi.h"
21 #include "../../codecs/da7219.h"
22 #include "../../codecs/da7219-aad.h"
23 #include "../common/soc-intel-quirks.h"
24 #include "hda_dsp_common.h"
26 #define BXT_DIALOG_CODEC_DAI "da7219-hifi"
27 #define BXT_MAXIM_CODEC_DAI "HiFi"
28 #define MAX98390_DEV0_NAME "i2c-MX98390:00"
29 #define MAX98390_DEV1_NAME "i2c-MX98390:01"
30 #define DUAL_CHANNEL 2
31 #define QUAD_CHANNEL 4
33 #define SPKAMP_MAX98357A 1
34 #define SPKAMP_MAX98390 2
36 static struct snd_soc_jack broxton_headset
;
37 static struct snd_soc_jack broxton_hdmi
[3];
40 struct list_head head
;
41 struct snd_soc_dai
*codec_dai
;
45 struct bxt_card_private
{
46 struct list_head hdmi_pcm_list
;
47 bool common_hdmi_codec_drv
;
52 BXT_DPCM_AUDIO_PB
= 0,
55 BXT_DPCM_AUDIO_REF_CP
,
56 BXT_DPCM_AUDIO_DMIC_CP
,
57 BXT_DPCM_AUDIO_HDMI1_PB
,
58 BXT_DPCM_AUDIO_HDMI2_PB
,
59 BXT_DPCM_AUDIO_HDMI3_PB
,
62 static int platform_clock_control(struct snd_soc_dapm_widget
*w
,
63 struct snd_kcontrol
*k
, int event
)
66 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
67 struct snd_soc_card
*card
= dapm
->card
;
68 struct snd_soc_dai
*codec_dai
;
70 codec_dai
= snd_soc_card_get_codec_dai(card
, BXT_DIALOG_CODEC_DAI
);
72 dev_err(card
->dev
, "Codec dai not found; Unable to set/unset codec pll\n");
76 if (SND_SOC_DAPM_EVENT_OFF(event
)) {
77 ret
= snd_soc_dai_set_pll(codec_dai
, 0,
78 DA7219_SYSCLK_MCLK
, 0, 0);
80 dev_err(card
->dev
, "failed to stop PLL: %d\n", ret
);
81 } else if(SND_SOC_DAPM_EVENT_ON(event
)) {
82 ret
= snd_soc_dai_set_pll(codec_dai
, 0,
83 DA7219_SYSCLK_PLL_SRM
, 0, DA7219_PLL_FREQ_OUT_98304
);
85 dev_err(card
->dev
, "failed to start PLL: %d\n", ret
);
91 static const struct snd_kcontrol_new broxton_controls
[] = {
92 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
93 SOC_DAPM_PIN_SWITCH("Headset Mic"),
96 static const struct snd_kcontrol_new max98357a_controls
[] = {
97 SOC_DAPM_PIN_SWITCH("Spk"),
100 static const struct snd_kcontrol_new max98390_controls
[] = {
101 SOC_DAPM_PIN_SWITCH("Left Spk"),
102 SOC_DAPM_PIN_SWITCH("Right Spk"),
105 static const struct snd_soc_dapm_widget broxton_widgets
[] = {
106 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
107 SND_SOC_DAPM_MIC("Headset Mic", NULL
),
108 SND_SOC_DAPM_MIC("SoC DMIC", NULL
),
109 SND_SOC_DAPM_SPK("HDMI1", NULL
),
110 SND_SOC_DAPM_SPK("HDMI2", NULL
),
111 SND_SOC_DAPM_SPK("HDMI3", NULL
),
112 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM
, 0, 0,
113 platform_clock_control
, SND_SOC_DAPM_POST_PMD
|SND_SOC_DAPM_PRE_PMU
),
116 static const struct snd_soc_dapm_widget max98357a_widgets
[] = {
117 SND_SOC_DAPM_SPK("Spk", NULL
),
120 static const struct snd_soc_dapm_widget max98390_widgets
[] = {
121 SND_SOC_DAPM_SPK("Left Spk", NULL
),
122 SND_SOC_DAPM_SPK("Right Spk", NULL
),
125 static const struct snd_soc_dapm_route audio_map
[] = {
126 /* HP jack connectors - unknown if we have jack detection */
127 {"Headphone Jack", NULL
, "HPL"},
128 {"Headphone Jack", NULL
, "HPR"},
131 {"MIC", NULL
, "Headset Mic"},
134 {"DMic", NULL
, "SoC DMIC"},
136 /* CODEC BE connections */
137 {"HDMI1", NULL
, "hif5-0 Output"},
138 {"HDMI2", NULL
, "hif6-0 Output"},
139 {"HDMI2", NULL
, "hif7-0 Output"},
141 {"hifi3", NULL
, "iDisp3 Tx"},
142 {"iDisp3 Tx", NULL
, "iDisp3_out"},
143 {"hifi2", NULL
, "iDisp2 Tx"},
144 {"iDisp2 Tx", NULL
, "iDisp2_out"},
145 {"hifi1", NULL
, "iDisp1 Tx"},
146 {"iDisp1 Tx", NULL
, "iDisp1_out"},
149 {"dmic01_hifi", NULL
, "DMIC01 Rx"},
150 {"DMIC01 Rx", NULL
, "DMIC AIF"},
152 { "Headphone Jack", NULL
, "Platform Clock" },
153 { "Headset Mic", NULL
, "Platform Clock" },
156 static const struct snd_soc_dapm_route max98357a_routes
[] = {
158 {"Spk", NULL
, "Speaker"},
161 static const struct snd_soc_dapm_route max98390_routes
[] = {
163 {"Left Spk", NULL
, "Left BE_OUT"},
164 {"Right Spk", NULL
, "Right BE_OUT"},
167 static const struct snd_soc_dapm_route broxton_map
[] = {
168 {"HiFi Playback", NULL
, "ssp5 Tx"},
169 {"ssp5 Tx", NULL
, "codec0_out"},
171 {"Playback", NULL
, "ssp1 Tx"},
172 {"ssp1 Tx", NULL
, "codec1_out"},
174 {"codec0_in", NULL
, "ssp1 Rx"},
175 {"ssp1 Rx", NULL
, "Capture"},
178 static const struct snd_soc_dapm_route gemini_map
[] = {
179 {"HiFi Playback", NULL
, "ssp1 Tx"},
180 {"ssp1 Tx", NULL
, "codec0_out"},
182 {"Playback", NULL
, "ssp2 Tx"},
183 {"ssp2 Tx", NULL
, "codec1_out"},
185 {"codec0_in", NULL
, "ssp2 Rx"},
186 {"ssp2 Rx", NULL
, "Capture"},
189 static int broxton_ssp_fixup(struct snd_soc_pcm_runtime
*rtd
,
190 struct snd_pcm_hw_params
*params
)
192 struct snd_interval
*rate
= hw_param_interval(params
,
193 SNDRV_PCM_HW_PARAM_RATE
);
194 struct snd_interval
*chan
= hw_param_interval(params
,
195 SNDRV_PCM_HW_PARAM_CHANNELS
);
196 struct snd_mask
*fmt
= hw_param_mask(params
, SNDRV_PCM_HW_PARAM_FORMAT
);
198 /* The ADSP will convert the FE rate to 48k, stereo */
199 rate
->min
= rate
->max
= 48000;
200 chan
->min
= chan
->max
= DUAL_CHANNEL
;
202 /* set SSP to 24 bit */
204 snd_mask_set_format(fmt
, SNDRV_PCM_FORMAT_S24_LE
);
209 static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime
*rtd
)
212 struct snd_soc_dai
*codec_dai
= asoc_rtd_to_codec(rtd
, 0);
213 struct snd_soc_component
*component
= asoc_rtd_to_codec(rtd
, 0)->component
;
216 /* Configure sysclk for codec */
217 if (soc_intel_is_cml())
222 ret
= snd_soc_dai_set_sysclk(codec_dai
, DA7219_CLKSRC_MCLK
, clk_freq
,
226 dev_err(rtd
->dev
, "can't set codec sysclk configuration\n");
231 * Headset buttons map to the google Reference headset.
232 * These can be configured by userspace.
234 ret
= snd_soc_card_jack_new(rtd
->card
, "Headset Jack",
235 SND_JACK_HEADSET
| SND_JACK_BTN_0
| SND_JACK_BTN_1
|
236 SND_JACK_BTN_2
| SND_JACK_BTN_3
| SND_JACK_LINEOUT
,
237 &broxton_headset
, NULL
, 0);
239 dev_err(rtd
->dev
, "Headset Jack creation failed: %d\n", ret
);
243 snd_jack_set_key(broxton_headset
.jack
, SND_JACK_BTN_0
, KEY_PLAYPAUSE
);
244 snd_jack_set_key(broxton_headset
.jack
, SND_JACK_BTN_1
, KEY_VOLUMEUP
);
245 snd_jack_set_key(broxton_headset
.jack
, SND_JACK_BTN_2
, KEY_VOLUMEDOWN
);
246 snd_jack_set_key(broxton_headset
.jack
, SND_JACK_BTN_3
,
249 da7219_aad_jack_det(component
, &broxton_headset
);
251 snd_soc_dapm_ignore_suspend(&rtd
->card
->dapm
, "SoC DMIC");
256 static int broxton_hdmi_init(struct snd_soc_pcm_runtime
*rtd
)
258 struct bxt_card_private
*ctx
= snd_soc_card_get_drvdata(rtd
->card
);
259 struct snd_soc_dai
*dai
= asoc_rtd_to_codec(rtd
, 0);
260 struct bxt_hdmi_pcm
*pcm
;
262 pcm
= devm_kzalloc(rtd
->card
->dev
, sizeof(*pcm
), GFP_KERNEL
);
266 pcm
->device
= BXT_DPCM_AUDIO_HDMI1_PB
+ dai
->id
;
267 pcm
->codec_dai
= dai
;
269 list_add_tail(&pcm
->head
, &ctx
->hdmi_pcm_list
);
274 static int broxton_da7219_fe_init(struct snd_soc_pcm_runtime
*rtd
)
276 struct snd_soc_dapm_context
*dapm
;
277 struct snd_soc_component
*component
= asoc_rtd_to_cpu(rtd
, 0)->component
;
279 dapm
= snd_soc_component_get_dapm(component
);
280 snd_soc_dapm_ignore_suspend(dapm
, "Reference Capture");
285 static const unsigned int rates
[] = {
289 static const struct snd_pcm_hw_constraint_list constraints_rates
= {
290 .count
= ARRAY_SIZE(rates
),
295 static const unsigned int channels
[] = {
299 static const struct snd_pcm_hw_constraint_list constraints_channels
= {
300 .count
= ARRAY_SIZE(channels
),
305 static const unsigned int channels_quad
[] = {
309 static const struct snd_pcm_hw_constraint_list constraints_channels_quad
= {
310 .count
= ARRAY_SIZE(channels_quad
),
311 .list
= channels_quad
,
315 static int bxt_fe_startup(struct snd_pcm_substream
*substream
)
317 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
320 * On this platform for PCM device we support,
326 runtime
->hw
.channels_max
= DUAL_CHANNEL
;
327 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_CHANNELS
,
328 &constraints_channels
);
330 runtime
->hw
.formats
= SNDRV_PCM_FMTBIT_S16_LE
;
331 snd_pcm_hw_constraint_msbits(runtime
, 0, 16, 16);
333 snd_pcm_hw_constraint_list(runtime
, 0,
334 SNDRV_PCM_HW_PARAM_RATE
, &constraints_rates
);
339 static const struct snd_soc_ops broxton_da7219_fe_ops
= {
340 .startup
= bxt_fe_startup
,
343 static int broxton_dmic_fixup(struct snd_soc_pcm_runtime
*rtd
,
344 struct snd_pcm_hw_params
*params
)
346 struct snd_interval
*chan
= hw_param_interval(params
,
347 SNDRV_PCM_HW_PARAM_CHANNELS
);
348 if (params_channels(params
) == 2)
349 chan
->min
= chan
->max
= 2;
351 chan
->min
= chan
->max
= 4;
356 static int broxton_dmic_startup(struct snd_pcm_substream
*substream
)
358 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
360 runtime
->hw
.channels_min
= runtime
->hw
.channels_max
= QUAD_CHANNEL
;
361 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_CHANNELS
,
362 &constraints_channels_quad
);
364 return snd_pcm_hw_constraint_list(substream
->runtime
, 0,
365 SNDRV_PCM_HW_PARAM_RATE
, &constraints_rates
);
368 static const struct snd_soc_ops broxton_dmic_ops
= {
369 .startup
= broxton_dmic_startup
,
372 static const unsigned int rates_16000
[] = {
376 static const struct snd_pcm_hw_constraint_list constraints_16000
= {
377 .count
= ARRAY_SIZE(rates_16000
),
381 static const unsigned int ch_mono
[] = {
385 static const struct snd_pcm_hw_constraint_list constraints_refcap
= {
386 .count
= ARRAY_SIZE(ch_mono
),
390 static int broxton_refcap_startup(struct snd_pcm_substream
*substream
)
392 substream
->runtime
->hw
.channels_max
= 1;
393 snd_pcm_hw_constraint_list(substream
->runtime
, 0,
394 SNDRV_PCM_HW_PARAM_CHANNELS
,
395 &constraints_refcap
);
397 return snd_pcm_hw_constraint_list(substream
->runtime
, 0,
398 SNDRV_PCM_HW_PARAM_RATE
,
402 static const struct snd_soc_ops broxton_refcap_ops
= {
403 .startup
= broxton_refcap_startup
,
406 /* broxton digital audio interface glue - connects codec <--> CPU */
407 SND_SOC_DAILINK_DEF(dummy
,
408 DAILINK_COMP_ARRAY(COMP_DUMMY()));
410 SND_SOC_DAILINK_DEF(system
,
411 DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
413 SND_SOC_DAILINK_DEF(system2
,
414 DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
416 SND_SOC_DAILINK_DEF(reference
,
417 DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
419 SND_SOC_DAILINK_DEF(dmic
,
420 DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
422 SND_SOC_DAILINK_DEF(hdmi1
,
423 DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
425 SND_SOC_DAILINK_DEF(hdmi2
,
426 DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
428 SND_SOC_DAILINK_DEF(hdmi3
,
429 DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
432 SND_SOC_DAILINK_DEF(ssp5_pin
,
433 DAILINK_COMP_ARRAY(COMP_CPU("SSP5 Pin")));
434 SND_SOC_DAILINK_DEF(ssp5_codec
,
435 DAILINK_COMP_ARRAY(COMP_CODEC("MX98357A:00",
436 BXT_MAXIM_CODEC_DAI
)));
437 SND_SOC_DAILINK_DEF(max98390_codec
,
439 /* Left */ COMP_CODEC(MAX98390_DEV0_NAME
, "max98390-aif1"),
440 /* Right */ COMP_CODEC(MAX98390_DEV1_NAME
, "max98390-aif1")));
442 SND_SOC_DAILINK_DEF(ssp1_pin
,
443 DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
444 SND_SOC_DAILINK_DEF(ssp1_codec
,
445 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
446 BXT_DIALOG_CODEC_DAI
)));
448 SND_SOC_DAILINK_DEF(dmic_pin
,
449 DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
451 SND_SOC_DAILINK_DEF(dmic16k_pin
,
452 DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));
454 SND_SOC_DAILINK_DEF(dmic_codec
,
455 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
457 SND_SOC_DAILINK_DEF(idisp1_pin
,
458 DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
459 SND_SOC_DAILINK_DEF(idisp1_codec
,
460 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
462 SND_SOC_DAILINK_DEF(idisp2_pin
,
463 DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
464 SND_SOC_DAILINK_DEF(idisp2_codec
,
465 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
466 "intel-hdmi-hifi2")));
468 SND_SOC_DAILINK_DEF(idisp3_pin
,
469 DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
470 SND_SOC_DAILINK_DEF(idisp3_codec
,
471 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
472 "intel-hdmi-hifi3")));
474 SND_SOC_DAILINK_DEF(platform
,
475 DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0")));
477 static struct snd_soc_dai_link broxton_dais
[] = {
478 /* Front End DAI links */
479 [BXT_DPCM_AUDIO_PB
] =
481 .name
= "Bxt Audio Port",
482 .stream_name
= "Audio",
485 .init
= broxton_da7219_fe_init
,
487 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
489 .ops
= &broxton_da7219_fe_ops
,
490 SND_SOC_DAILINK_REG(system
, dummy
, platform
),
492 [BXT_DPCM_AUDIO_CP
] =
494 .name
= "Bxt Audio Capture Port",
495 .stream_name
= "Audio Record",
499 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
501 .ops
= &broxton_da7219_fe_ops
,
502 SND_SOC_DAILINK_REG(system
, dummy
, platform
),
504 [BXT_DPCM_AUDIO_HS_PB
] = {
505 .name
= "Bxt Audio Headset Playback",
506 .stream_name
= "Headset Playback",
510 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
512 .ops
= &broxton_da7219_fe_ops
,
513 SND_SOC_DAILINK_REG(system2
, dummy
, platform
),
515 [BXT_DPCM_AUDIO_REF_CP
] =
517 .name
= "Bxt Audio Reference cap",
518 .stream_name
= "Refcap",
523 .ops
= &broxton_refcap_ops
,
524 SND_SOC_DAILINK_REG(reference
, dummy
, platform
),
526 [BXT_DPCM_AUDIO_DMIC_CP
] =
528 .name
= "Bxt Audio DMIC cap",
529 .stream_name
= "dmiccap",
534 .ops
= &broxton_dmic_ops
,
535 SND_SOC_DAILINK_REG(dmic
, dummy
, platform
),
537 [BXT_DPCM_AUDIO_HDMI1_PB
] =
539 .name
= "Bxt HDMI Port1",
540 .stream_name
= "Hdmi1",
545 SND_SOC_DAILINK_REG(hdmi1
, dummy
, platform
),
547 [BXT_DPCM_AUDIO_HDMI2_PB
] =
549 .name
= "Bxt HDMI Port2",
550 .stream_name
= "Hdmi2",
555 SND_SOC_DAILINK_REG(hdmi2
, dummy
, platform
),
557 [BXT_DPCM_AUDIO_HDMI3_PB
] =
559 .name
= "Bxt HDMI Port3",
560 .stream_name
= "Hdmi3",
565 SND_SOC_DAILINK_REG(hdmi3
, dummy
, platform
),
567 /* Back End DAI links */
570 .name
= "SSP5-Codec",
573 .dai_fmt
= SND_SOC_DAIFMT_I2S
|
574 SND_SOC_DAIFMT_NB_NF
|
575 SND_SOC_DAIFMT_CBS_CFS
,
576 .ignore_pmdown_time
= 1,
577 .be_hw_params_fixup
= broxton_ssp_fixup
,
579 SND_SOC_DAILINK_REG(ssp5_pin
, ssp5_codec
, platform
),
583 .name
= "SSP1-Codec",
586 .init
= broxton_da7219_codec_init
,
587 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
588 SND_SOC_DAIFMT_CBS_CFS
,
589 .ignore_pmdown_time
= 1,
590 .be_hw_params_fixup
= broxton_ssp_fixup
,
593 SND_SOC_DAILINK_REG(ssp1_pin
, ssp1_codec
, platform
),
599 .be_hw_params_fixup
= broxton_dmic_fixup
,
602 SND_SOC_DAILINK_REG(dmic_pin
, dmic_codec
, platform
),
607 .init
= broxton_hdmi_init
,
610 SND_SOC_DAILINK_REG(idisp1_pin
, idisp1_codec
, platform
),
615 .init
= broxton_hdmi_init
,
618 SND_SOC_DAILINK_REG(idisp2_pin
, idisp2_codec
, platform
),
623 .init
= broxton_hdmi_init
,
626 SND_SOC_DAILINK_REG(idisp3_pin
, idisp3_codec
, platform
),
631 .be_hw_params_fixup
= broxton_dmic_fixup
,
634 SND_SOC_DAILINK_REG(dmic16k_pin
, dmic_codec
, platform
),
638 static struct snd_soc_codec_conf max98390_codec_confs
[] = {
640 .dlc
= COMP_CODEC_CONF(MAX98390_DEV0_NAME
),
641 .name_prefix
= "Left",
644 .dlc
= COMP_CODEC_CONF(MAX98390_DEV1_NAME
),
645 .name_prefix
= "Right",
650 static int bxt_card_late_probe(struct snd_soc_card
*card
)
652 struct bxt_card_private
*ctx
= snd_soc_card_get_drvdata(card
);
653 struct bxt_hdmi_pcm
*pcm
;
654 struct snd_soc_component
*component
= NULL
;
655 const struct snd_kcontrol_new
*controls
;
656 const struct snd_soc_dapm_widget
*widgets
;
657 const struct snd_soc_dapm_route
*routes
;
658 int num_controls
, num_widgets
, num_routes
, err
, i
= 0;
659 char jack_name
[NAME_SIZE
];
661 switch (ctx
->spkamp
) {
662 case SPKAMP_MAX98357A
:
663 controls
= max98357a_controls
;
664 num_controls
= ARRAY_SIZE(max98357a_controls
);
665 widgets
= max98357a_widgets
;
666 num_widgets
= ARRAY_SIZE(max98357a_widgets
);
667 routes
= max98357a_routes
;
668 num_routes
= ARRAY_SIZE(max98357a_routes
);
670 case SPKAMP_MAX98390
:
671 controls
= max98390_controls
;
672 num_controls
= ARRAY_SIZE(max98390_controls
);
673 widgets
= max98390_widgets
;
674 num_widgets
= ARRAY_SIZE(max98390_widgets
);
675 routes
= max98390_routes
;
676 num_routes
= ARRAY_SIZE(max98390_routes
);
679 dev_err(card
->dev
, "Invalid speaker amplifier %d\n", ctx
->spkamp
);
683 err
= snd_soc_dapm_new_controls(&card
->dapm
, widgets
, num_widgets
);
685 dev_err(card
->dev
, "Fail to new widgets\n");
689 err
= snd_soc_add_card_controls(card
, controls
, num_controls
);
691 dev_err(card
->dev
, "Fail to add controls\n");
695 err
= snd_soc_dapm_add_routes(&card
->dapm
, routes
, num_routes
);
697 dev_err(card
->dev
, "Fail to add routes\n");
701 if (soc_intel_is_glk())
702 snd_soc_dapm_add_routes(&card
->dapm
, gemini_map
,
703 ARRAY_SIZE(gemini_map
));
705 snd_soc_dapm_add_routes(&card
->dapm
, broxton_map
,
706 ARRAY_SIZE(broxton_map
));
708 if (list_empty(&ctx
->hdmi_pcm_list
))
711 if (ctx
->common_hdmi_codec_drv
) {
712 pcm
= list_first_entry(&ctx
->hdmi_pcm_list
, struct bxt_hdmi_pcm
,
714 component
= pcm
->codec_dai
->component
;
715 return hda_dsp_hdmi_build_controls(card
, component
);
718 list_for_each_entry(pcm
, &ctx
->hdmi_pcm_list
, head
) {
719 component
= pcm
->codec_dai
->component
;
720 snprintf(jack_name
, sizeof(jack_name
),
721 "HDMI/DP, pcm=%d Jack", pcm
->device
);
722 err
= snd_soc_card_jack_new(card
, jack_name
,
723 SND_JACK_AVOUT
, &broxton_hdmi
[i
],
729 err
= hdac_hdmi_jack_init(pcm
->codec_dai
, pcm
->device
,
737 return hdac_hdmi_jack_port_init(component
, &card
->dapm
);
740 /* broxton audio machine driver for SPT + da7219 */
741 static struct snd_soc_card broxton_audio_card
= {
742 .name
= "bxtda7219max",
743 .owner
= THIS_MODULE
,
744 .dai_link
= broxton_dais
,
745 .num_links
= ARRAY_SIZE(broxton_dais
),
746 .controls
= broxton_controls
,
747 .num_controls
= ARRAY_SIZE(broxton_controls
),
748 .dapm_widgets
= broxton_widgets
,
749 .num_dapm_widgets
= ARRAY_SIZE(broxton_widgets
),
750 .dapm_routes
= audio_map
,
751 .num_dapm_routes
= ARRAY_SIZE(audio_map
),
752 .fully_routed
= true,
753 .late_probe
= bxt_card_late_probe
,
756 static int broxton_audio_probe(struct platform_device
*pdev
)
758 struct bxt_card_private
*ctx
;
759 struct snd_soc_acpi_mach
*mach
;
760 const char *platform_name
;
763 ctx
= devm_kzalloc(&pdev
->dev
, sizeof(*ctx
), GFP_KERNEL
);
767 INIT_LIST_HEAD(&ctx
->hdmi_pcm_list
);
769 if (acpi_dev_present("MX98390", NULL
, -1))
770 ctx
->spkamp
= SPKAMP_MAX98390
;
772 ctx
->spkamp
= SPKAMP_MAX98357A
;
774 broxton_audio_card
.dev
= &pdev
->dev
;
775 snd_soc_card_set_drvdata(&broxton_audio_card
, ctx
);
776 if (soc_intel_is_glk()) {
779 broxton_audio_card
.name
= "glkda7219max";
780 /* Fixup the SSP entries for geminilake */
781 for (i
= 0; i
< ARRAY_SIZE(broxton_dais
); i
++) {
782 /* MAXIM_CODEC is connected to SSP1. */
783 if (!strcmp(broxton_dais
[i
].codecs
->dai_name
,
784 BXT_MAXIM_CODEC_DAI
)) {
785 broxton_dais
[i
].name
= "SSP1-Codec";
786 broxton_dais
[i
].cpus
->dai_name
= "SSP1 Pin";
788 /* DIALOG_CODE is connected to SSP2 */
789 else if (!strcmp(broxton_dais
[i
].codecs
->dai_name
,
790 BXT_DIALOG_CODEC_DAI
)) {
791 broxton_dais
[i
].name
= "SSP2-Codec";
792 broxton_dais
[i
].cpus
->dai_name
= "SSP2 Pin";
795 } else if (soc_intel_is_cml()) {
798 if (ctx
->spkamp
== SPKAMP_MAX98390
) {
799 broxton_audio_card
.name
= "cml_max98390_da7219";
801 broxton_audio_card
.codec_conf
= max98390_codec_confs
;
802 broxton_audio_card
.num_configs
= ARRAY_SIZE(max98390_codec_confs
);
804 broxton_audio_card
.name
= "cmlda7219max";
806 for (i
= 0; i
< ARRAY_SIZE(broxton_dais
); i
++) {
807 /* MAXIM_CODEC is connected to SSP1. */
808 if (!strcmp(broxton_dais
[i
].codecs
->dai_name
,
809 BXT_MAXIM_CODEC_DAI
)) {
810 broxton_dais
[i
].name
= "SSP1-Codec";
811 broxton_dais
[i
].cpus
->dai_name
= "SSP1 Pin";
813 if (ctx
->spkamp
== SPKAMP_MAX98390
) {
814 broxton_dais
[i
].codecs
= max98390_codec
;
815 broxton_dais
[i
].num_codecs
= ARRAY_SIZE(max98390_codec
);
818 /* DIALOG_CODEC is connected to SSP0 */
819 else if (!strcmp(broxton_dais
[i
].codecs
->dai_name
,
820 BXT_DIALOG_CODEC_DAI
)) {
821 broxton_dais
[i
].name
= "SSP0-Codec";
822 broxton_dais
[i
].cpus
->dai_name
= "SSP0 Pin";
827 /* override plaform name, if required */
828 mach
= pdev
->dev
.platform_data
;
829 platform_name
= mach
->mach_params
.platform
;
831 ret
= snd_soc_fixup_dai_links_platform_name(&broxton_audio_card
,
836 ctx
->common_hdmi_codec_drv
= mach
->mach_params
.common_hdmi_codec_drv
;
838 return devm_snd_soc_register_card(&pdev
->dev
, &broxton_audio_card
);
841 static const struct platform_device_id bxt_board_ids
[] = {
842 { .name
= "bxt_da7219_max98357a" },
843 { .name
= "glk_da7219_max98357a" },
844 { .name
= "cml_da7219_max98357a" },
848 static struct platform_driver broxton_audio
= {
849 .probe
= broxton_audio_probe
,
851 .name
= "bxt_da7219_max98357a",
852 .pm
= &snd_soc_pm_ops
,
854 .id_table
= bxt_board_ids
,
856 module_platform_driver(broxton_audio
)
858 /* Module information */
859 MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode");
860 MODULE_AUTHOR("Sathyanarayana Nujella <sathyanarayana.nujella@intel.com>");
861 MODULE_AUTHOR("Rohit Ainapure <rohit.m.ainapure@intel.com>");
862 MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
863 MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>");
864 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
865 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
866 MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
867 MODULE_LICENSE("GPL v2");
868 MODULE_ALIAS("platform:bxt_da7219_max98357a");
869 MODULE_ALIAS("platform:glk_da7219_max98357a");
870 MODULE_ALIAS("platform:cml_da7219_max98357a");