xref: /openbmc/linux/sound/soc/sof/amd/renoir.c (revision ca637c0e)
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  * Hardware interface for Audio DSP on Renoir platform
12  */
13 
14 #include <linux/platform_device.h>
15 #include <linux/module.h>
16 
17 #include "../ops.h"
18 #include "../sof-audio.h"
19 #include "acp.h"
20 #include "acp-dsp-offset.h"
21 
22 #define I2S_BT_INSTANCE		0
23 #define I2S_SP_INSTANCE		1
24 #define PDM_DMIC_INSTANCE	2
25 
26 static struct snd_soc_dai_driver renoir_sof_dai[] = {
27 	[I2S_BT_INSTANCE] = {
28 		.id = I2S_BT_INSTANCE,
29 		.name = "acp-sof-bt",
30 		.playback = {
31 			.rates = SNDRV_PCM_RATE_8000_96000,
32 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
33 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
34 			.channels_min = 2,
35 			.channels_max = 8,
36 			.rate_min = 8000,
37 			.rate_max = 96000,
38 		},
39 		.capture = {
40 			.rates = SNDRV_PCM_RATE_8000_48000,
41 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
42 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
43 			/* Supporting only stereo for I2S BT controller capture */
44 			.channels_min = 2,
45 			.channels_max = 2,
46 			.rate_min = 8000,
47 			.rate_max = 48000,
48 		},
49 		.probe = &acp_dai_probe,
50 	},
51 
52 	[I2S_SP_INSTANCE] = {
53 		.id = I2S_SP_INSTANCE,
54 		.name = "acp-sof-sp",
55 		.playback = {
56 			.rates = SNDRV_PCM_RATE_8000_96000,
57 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
58 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
59 			.channels_min = 2,
60 			.channels_max = 8,
61 			.rate_min = 8000,
62 			.rate_max = 96000,
63 		},
64 		.capture = {
65 			.rates = SNDRV_PCM_RATE_8000_48000,
66 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
67 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
68 			/* Supporting only stereo for I2S SP controller capture */
69 			.channels_min = 2,
70 			.channels_max = 2,
71 			.rate_min = 8000,
72 			.rate_max = 48000,
73 		},
74 		.probe = &acp_dai_probe,
75 	},
76 
77 	[PDM_DMIC_INSTANCE] = {
78 		.id = PDM_DMIC_INSTANCE,
79 		.name = "acp-sof-dmic",
80 		.capture = {
81 			.rates = SNDRV_PCM_RATE_8000_48000,
82 			.formats = SNDRV_PCM_FMTBIT_S32_LE,
83 			.channels_min = 2,
84 			.channels_max = 4,
85 			.rate_min = 8000,
86 			.rate_max = 48000,
87 		},
88 	},
89 };
90 
91 /* Renoir ops */
92 struct snd_sof_dsp_ops sof_renoir_ops;
93 EXPORT_SYMBOL_NS(sof_renoir_ops, SND_SOC_SOF_AMD_COMMON);
94 
95 int sof_renoir_ops_init(struct snd_sof_dev *sdev)
96 {
97 	/* common defaults */
98 	memcpy(&sof_renoir_ops, &sof_acp_common_ops, sizeof(struct snd_sof_dsp_ops));
99 
100 	sof_renoir_ops.drv = renoir_sof_dai;
101 	sof_renoir_ops.num_drv = ARRAY_SIZE(renoir_sof_dai);
102 
103 	return 0;
104 }
105 
106 MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
107 MODULE_DESCRIPTION("RENOIR SOF Driver");
108 MODULE_LICENSE("Dual BSD/GPL");
109