1 // SPDX-License-Identifier: GPL-2.0
3 // Socionext UniPhier AIO ALSA driver for LD11/LD20.
5 // Copyright (c) 2016-2018 Socionext Inc.
7 #include <linux/module.h>
11 static const struct uniphier_aio_spec uniphier_aio_ld11
[] = {
12 /* for HDMI PCM In, Pin:AI1Dx */
14 .name
= AUD_NAME_PCMIN1
,
15 .gname
= AUD_GNAME_HDMI
,
17 .type
= PORT_TYPE_I2S
,
18 .dir
= PORT_DIR_INPUT
,
22 .iport
= { 0, AUD_HW_PCMIN1
, },
26 /* for SIF In, Pin:AI2Dx */
28 .name
= AUD_NAME_PCMIN2
,
30 .type
= PORT_TYPE_I2S
,
31 .dir
= PORT_DIR_INPUT
,
35 .iport
= { 1, AUD_HW_PCMIN2
, },
39 /* for Line In, Pin:AI3Dx */
41 .name
= AUD_NAME_PCMIN3
,
42 .gname
= AUD_GNAME_LINE
,
44 .type
= PORT_TYPE_EVE
,
45 .dir
= PORT_DIR_INPUT
,
49 .iport
= { 2, AUD_HW_PCMIN3
, },
53 /* for S/PDIF In, Pin:AI1IEC */
55 .name
= AUD_NAME_IECIN1
,
56 .gname
= AUD_GNAME_IEC
,
58 .type
= PORT_TYPE_SPDIF
,
59 .dir
= PORT_DIR_INPUT
,
63 .iport
= { 3, AUD_HW_IECIN1
, },
67 /* for Speaker, Pin:AO1Dx */
69 .name
= AUD_NAME_HPCMOUT1
,
71 .type
= PORT_TYPE_I2S
,
72 .dir
= PORT_DIR_OUTPUT
,
76 .oport
= { 0, AUD_HW_HPCMOUT1
, },
80 /* for HDMI PCM, Pin:AO2Dx */
82 .name
= AUD_NAME_PCMOUT1
,
83 .gname
= AUD_GNAME_HDMI
,
85 .type
= PORT_TYPE_I2S
,
86 .dir
= PORT_DIR_OUTPUT
,
90 .oport
= { 3, AUD_HW_PCMOUT1
, },
94 /* for Line Out, Pin:LO2_x */
96 .name
= AUD_NAME_PCMOUT2
,
97 .gname
= AUD_GNAME_LINE
,
99 .type
= PORT_TYPE_EVE
,
100 .dir
= PORT_DIR_OUTPUT
,
104 .oport
= { 1, AUD_HW_PCMOUT2
, },
108 /* for Headphone, Pin:HP1_x */
110 .name
= AUD_NAME_PCMOUT3
,
112 .type
= PORT_TYPE_EVE
,
113 .dir
= PORT_DIR_OUTPUT
,
117 .oport
= { 2, AUD_HW_PCMOUT3
, },
121 /* for HW Sampling Rate Converter */
123 .name
= AUD_NAME_EPCMOUT2
,
125 .type
= PORT_TYPE_CONV
,
126 .dir
= PORT_DIR_OUTPUT
,
130 .oport
= { 6, AUD_HW_EPCMOUT2
, },
136 /* for HW Sampling Rate Converter 2 */
138 .name
= AUD_NAME_EPCMOUT3
,
140 .type
= PORT_TYPE_CONV
,
141 .dir
= PORT_DIR_OUTPUT
,
145 .oport
= { 7, AUD_HW_EPCMOUT3
, },
151 /* for S/PDIF Out, Pin:AO1IEC */
153 .name
= AUD_NAME_HIECOUT1
,
154 .gname
= AUD_GNAME_IEC
,
156 .type
= PORT_TYPE_SPDIF
,
157 .dir
= PORT_DIR_OUTPUT
,
161 .oport
= { 12, AUD_HW_HIECOUT1
, },
165 /* for S/PDIF Out, Pin:AO1IEC, Compress */
167 .name
= AUD_NAME_HIECCOMPOUT1
,
168 .gname
= AUD_GNAME_IEC
,
170 .type
= PORT_TYPE_SPDIF
,
171 .dir
= PORT_DIR_OUTPUT
,
175 .oport
= { 12, AUD_HW_HIECOUT1
, },
180 static const struct uniphier_aio_pll uniphier_aio_pll_ld11
[] = {
181 [AUD_PLL_A1
] = { .enable
= true, },
182 [AUD_PLL_F1
] = { .enable
= true, },
183 [AUD_PLL_A2
] = { .enable
= true, },
184 [AUD_PLL_F2
] = { .enable
= true, },
185 [AUD_PLL_APLL
] = { .enable
= true, },
186 [AUD_PLL_RX0
] = { .enable
= true, },
187 [AUD_PLL_USB0
] = { .enable
= true, },
188 [AUD_PLL_HSC0
] = { .enable
= true, },
191 static int uniphier_aio_ld11_probe(struct snd_soc_dai
*dai
)
195 ret
= uniphier_aio_dai_probe(dai
);
199 ret
= snd_soc_dai_set_pll(dai
, AUD_PLL_A1
, 0, 0, 36864000);
202 ret
= snd_soc_dai_set_pll(dai
, AUD_PLL_F1
, 0, 0, 36864000);
206 ret
= snd_soc_dai_set_pll(dai
, AUD_PLL_A2
, 0, 0, 33868800);
209 ret
= snd_soc_dai_set_pll(dai
, AUD_PLL_F2
, 0, 0, 33868800);
216 static struct snd_soc_dai_driver uniphier_aio_dai_ld11
[] = {
218 .name
= AUD_GNAME_HDMI
,
219 .probe
= uniphier_aio_ld11_probe
,
220 .remove
= uniphier_aio_dai_remove
,
222 .stream_name
= AUD_NAME_PCMOUT1
,
223 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
224 .rates
= SNDRV_PCM_RATE_48000
,
229 .stream_name
= AUD_NAME_PCMIN1
,
230 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
231 .rates
= SNDRV_PCM_RATE_48000
|
232 SNDRV_PCM_RATE_44100
|
233 SNDRV_PCM_RATE_32000
,
237 .ops
= &uniphier_aio_i2s_ops
,
240 .name
= AUD_NAME_PCMIN2
,
241 .probe
= uniphier_aio_ld11_probe
,
242 .remove
= uniphier_aio_dai_remove
,
244 .stream_name
= AUD_NAME_PCMIN2
,
245 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
246 .rates
= SNDRV_PCM_RATE_48000
,
250 .ops
= &uniphier_aio_i2s_ops
,
253 .name
= AUD_GNAME_LINE
,
254 .probe
= uniphier_aio_ld11_probe
,
255 .remove
= uniphier_aio_dai_remove
,
257 .stream_name
= AUD_NAME_PCMOUT2
,
258 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
259 .rates
= SNDRV_PCM_RATE_48000
,
264 .stream_name
= AUD_NAME_PCMIN3
,
265 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
266 .rates
= SNDRV_PCM_RATE_48000
,
270 .ops
= &uniphier_aio_i2s_ops
,
273 .name
= AUD_NAME_HPCMOUT1
,
274 .probe
= uniphier_aio_ld11_probe
,
275 .remove
= uniphier_aio_dai_remove
,
277 .stream_name
= AUD_NAME_HPCMOUT1
,
278 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
279 .rates
= SNDRV_PCM_RATE_48000
,
283 .ops
= &uniphier_aio_i2s_ops
,
286 .name
= AUD_NAME_PCMOUT3
,
287 .probe
= uniphier_aio_ld11_probe
,
288 .remove
= uniphier_aio_dai_remove
,
290 .stream_name
= AUD_NAME_PCMOUT3
,
291 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
292 .rates
= SNDRV_PCM_RATE_48000
,
296 .ops
= &uniphier_aio_i2s_ops
,
299 .name
= AUD_NAME_HIECOUT1
,
300 .probe
= uniphier_aio_ld11_probe
,
301 .remove
= uniphier_aio_dai_remove
,
303 .stream_name
= AUD_NAME_HIECOUT1
,
304 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
305 .rates
= SNDRV_PCM_RATE_48000
,
309 .ops
= &uniphier_aio_spdif_ops
,
312 .name
= AUD_NAME_EPCMOUT2
,
313 .probe
= uniphier_aio_ld11_probe
,
314 .remove
= uniphier_aio_dai_remove
,
316 .stream_name
= AUD_NAME_EPCMOUT2
,
317 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
318 .rates
= SNDRV_PCM_RATE_48000
|
319 SNDRV_PCM_RATE_44100
|
320 SNDRV_PCM_RATE_32000
,
324 .ops
= &uniphier_aio_i2s_ops
,
327 .name
= AUD_NAME_EPCMOUT3
,
328 .probe
= uniphier_aio_ld11_probe
,
329 .remove
= uniphier_aio_dai_remove
,
331 .stream_name
= AUD_NAME_EPCMOUT3
,
332 .formats
= SNDRV_PCM_FMTBIT_S32_LE
,
333 .rates
= SNDRV_PCM_RATE_48000
|
334 SNDRV_PCM_RATE_44100
|
335 SNDRV_PCM_RATE_32000
,
339 .ops
= &uniphier_aio_i2s_ops
,
342 .name
= AUD_NAME_HIECCOMPOUT1
,
343 .probe
= uniphier_aio_ld11_probe
,
344 .remove
= uniphier_aio_dai_remove
,
345 .compress_new
= snd_soc_new_compress
,
347 .stream_name
= AUD_NAME_HIECCOMPOUT1
,
351 .ops
= &uniphier_aio_spdif_ops
,
355 static const struct uniphier_aio_chip_spec uniphier_aio_ld11_spec
= {
356 .specs
= uniphier_aio_ld11
,
357 .num_specs
= ARRAY_SIZE(uniphier_aio_ld11
),
358 .dais
= uniphier_aio_dai_ld11
,
359 .num_dais
= ARRAY_SIZE(uniphier_aio_dai_ld11
),
360 .plls
= uniphier_aio_pll_ld11
,
361 .num_plls
= ARRAY_SIZE(uniphier_aio_pll_ld11
),
365 static const struct uniphier_aio_chip_spec uniphier_aio_ld20_spec
= {
366 .specs
= uniphier_aio_ld11
,
367 .num_specs
= ARRAY_SIZE(uniphier_aio_ld11
),
368 .dais
= uniphier_aio_dai_ld11
,
369 .num_dais
= ARRAY_SIZE(uniphier_aio_dai_ld11
),
370 .plls
= uniphier_aio_pll_ld11
,
371 .num_plls
= ARRAY_SIZE(uniphier_aio_pll_ld11
),
375 static const struct of_device_id uniphier_aio_of_match
[] __maybe_unused
= {
377 .compatible
= "socionext,uniphier-ld11-aio",
378 .data
= &uniphier_aio_ld11_spec
,
381 .compatible
= "socionext,uniphier-ld20-aio",
382 .data
= &uniphier_aio_ld20_spec
,
386 MODULE_DEVICE_TABLE(of
, uniphier_aio_of_match
);
388 static struct platform_driver uniphier_aio_driver
= {
390 .name
= "snd-uniphier-aio-ld11",
391 .of_match_table
= of_match_ptr(uniphier_aio_of_match
),
393 .probe
= uniphier_aio_probe
,
394 .remove
= uniphier_aio_remove
,
396 module_platform_driver(uniphier_aio_driver
);
398 MODULE_AUTHOR("Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>");
399 MODULE_DESCRIPTION("UniPhier LD11/LD20 AIO driver.");
400 MODULE_LICENSE("GPL v2");