2 * Intel Broadwell Wildcatpoint SST Audio
4 * Copyright (C) 2013, Intel Corporation. All rights reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <linux/module.h>
18 #include <linux/platform_device.h>
19 #include <sound/core.h>
20 #include <sound/pcm.h>
21 #include <sound/soc.h>
22 #include <sound/pcm_params.h>
25 #include "sst-haswell-ipc.h"
27 #include "../codecs/rt286.h"
29 static const struct snd_soc_dapm_widget broadwell_widgets
[] = {
30 SND_SOC_DAPM_HP("Headphones", NULL
),
31 SND_SOC_DAPM_SPK("Speaker", NULL
),
32 SND_SOC_DAPM_MIC("Mic Jack", NULL
),
33 SND_SOC_DAPM_MIC("DMIC1", NULL
),
34 SND_SOC_DAPM_MIC("DMIC2", NULL
),
35 SND_SOC_DAPM_LINE("Line Jack", NULL
),
38 static const struct snd_soc_dapm_route broadwell_rt286_map
[] = {
41 {"Speaker", NULL
, "SPOR"},
42 {"Speaker", NULL
, "SPOL"},
44 /* HP jack connectors - unknown if we have jack deteck */
45 {"Headphones", NULL
, "HPO Pin"},
48 {"MIC1", NULL
, "Mic Jack"},
49 {"LINE1", NULL
, "Line Jack"},
52 {"DMIC1 Pin", NULL
, "DMIC1"},
53 {"DMIC2 Pin", NULL
, "DMIC2"},
55 /* CODEC BE connections */
56 {"SSP0 CODEC IN", NULL
, "AIF1 Capture"},
57 {"AIF1 Playback", NULL
, "SSP0 CODEC OUT"},
60 static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime
*rtd
,
61 struct snd_pcm_hw_params
*params
)
63 struct snd_interval
*rate
= hw_param_interval(params
,
64 SNDRV_PCM_HW_PARAM_RATE
);
65 struct snd_interval
*channels
= hw_param_interval(params
,
66 SNDRV_PCM_HW_PARAM_CHANNELS
);
68 /* The ADSP will covert the FE rate to 48k, stereo */
69 rate
->min
= rate
->max
= 48000;
70 channels
->min
= channels
->max
= 2;
72 /* set SSP0 to 16 bit */
73 snd_mask_set(¶ms
->masks
[SNDRV_PCM_HW_PARAM_FORMAT
-
74 SNDRV_PCM_HW_PARAM_FIRST_MASK
],
75 SNDRV_PCM_FORMAT_S16_LE
);
79 static int broadwell_rt286_hw_params(struct snd_pcm_substream
*substream
,
80 struct snd_pcm_hw_params
*params
)
82 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
83 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
86 ret
= snd_soc_dai_set_sysclk(codec_dai
, RT286_SCLK_S_PLL
, 24000000,
90 dev_err(rtd
->dev
, "can't set codec sysclk configuration\n");
97 static struct snd_soc_ops broadwell_rt286_ops
= {
98 .hw_params
= broadwell_rt286_hw_params
,
101 static int broadwell_rtd_init(struct snd_soc_pcm_runtime
*rtd
)
103 struct snd_soc_codec
*codec
= rtd
->codec
;
104 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
105 struct sst_pdata
*pdata
= dev_get_platdata(rtd
->platform
->dev
);
106 struct sst_hsw
*broadwell
= pdata
->dsp
;
109 /* Set ADSP SSP port settings */
110 ret
= sst_hsw_device_set_config(broadwell
, SST_HSW_DEVICE_SSP_0
,
111 SST_HSW_DEVICE_MCLK_FREQ_24_MHZ
,
112 SST_HSW_DEVICE_CLOCK_MASTER
, 9);
114 dev_err(rtd
->dev
, "error: failed to set device config\n");
118 /* always connected - check HP for jack detect */
119 snd_soc_dapm_enable_pin(dapm
, "Headphones");
120 snd_soc_dapm_enable_pin(dapm
, "Speaker");
121 snd_soc_dapm_enable_pin(dapm
, "Mic Jack");
122 snd_soc_dapm_enable_pin(dapm
, "Line Jack");
123 snd_soc_dapm_enable_pin(dapm
, "DMIC1");
124 snd_soc_dapm_enable_pin(dapm
, "DMIC2");
129 /* broadwell digital audio interface glue - connects codec <--> CPU */
130 static struct snd_soc_dai_link broadwell_rt286_dais
[] = {
131 /* Front End DAI links */
133 .name
= "System PCM",
134 .stream_name
= "System Playback",
135 .cpu_dai_name
= "System Pin",
136 .platform_name
= "haswell-pcm-audio",
138 .codec_name
= "snd-soc-dummy",
139 .codec_dai_name
= "snd-soc-dummy-dai",
140 .init
= broadwell_rtd_init
,
141 .trigger
= {SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
146 .stream_name
= "Offload0 Playback",
147 .cpu_dai_name
= "Offload0 Pin",
148 .platform_name
= "haswell-pcm-audio",
150 .codec_name
= "snd-soc-dummy",
151 .codec_dai_name
= "snd-soc-dummy-dai",
152 .trigger
= {SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
157 .stream_name
= "Offload1 Playback",
158 .cpu_dai_name
= "Offload1 Pin",
159 .platform_name
= "haswell-pcm-audio",
161 .codec_name
= "snd-soc-dummy",
162 .codec_dai_name
= "snd-soc-dummy-dai",
163 .trigger
= {SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
167 .name
= "Loopback PCM",
168 .stream_name
= "Loopback",
169 .cpu_dai_name
= "Loopback Pin",
170 .platform_name
= "haswell-pcm-audio",
172 .codec_name
= "snd-soc-dummy",
173 .codec_dai_name
= "snd-soc-dummy-dai",
174 .trigger
= {SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
178 .name
= "Capture PCM",
179 .stream_name
= "Capture",
180 .cpu_dai_name
= "Capture Pin",
181 .platform_name
= "haswell-pcm-audio",
183 .codec_name
= "snd-soc-dummy",
184 .codec_dai_name
= "snd-soc-dummy-dai",
185 .trigger
= {SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
189 /* Back End DAI links */
194 .cpu_dai_name
= "snd-soc-dummy-dai",
195 .platform_name
= "snd-soc-dummy",
197 .codec_name
= "i2c-INT343A:00",
198 .codec_dai_name
= "rt286-aif1",
199 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
200 SND_SOC_DAIFMT_CBS_CFS
,
202 .ignore_pmdown_time
= 1,
203 .be_hw_params_fixup
= broadwell_ssp0_fixup
,
204 .ops
= &broadwell_rt286_ops
,
210 /* broadwell audio machine driver for WPT + RT286S */
211 static struct snd_soc_card broadwell_rt286
= {
212 .name
= "broadwell-rt286",
213 .owner
= THIS_MODULE
,
214 .dai_link
= broadwell_rt286_dais
,
215 .num_links
= ARRAY_SIZE(broadwell_rt286_dais
),
216 .dapm_widgets
= broadwell_widgets
,
217 .num_dapm_widgets
= ARRAY_SIZE(broadwell_widgets
),
218 .dapm_routes
= broadwell_rt286_map
,
219 .num_dapm_routes
= ARRAY_SIZE(broadwell_rt286_map
),
220 .fully_routed
= true,
223 static int broadwell_audio_probe(struct platform_device
*pdev
)
225 broadwell_rt286
.dev
= &pdev
->dev
;
227 return snd_soc_register_card(&broadwell_rt286
);
230 static int broadwell_audio_remove(struct platform_device
*pdev
)
232 snd_soc_unregister_card(&broadwell_rt286
);
236 static struct platform_driver broadwell_audio
= {
237 .probe
= broadwell_audio_probe
,
238 .remove
= broadwell_audio_remove
,
240 .name
= "broadwell-audio",
241 .owner
= THIS_MODULE
,
245 module_platform_driver(broadwell_audio
)
247 /* Module information */
248 MODULE_AUTHOR("Liam Girdwood, Xingchao Wang");
249 MODULE_DESCRIPTION("Intel SST Audio for WPT/Broadwell");
250 MODULE_LICENSE("GPL v2");
251 MODULE_ALIAS("platform:broadwell-audio");