xref: /openbmc/linux/sound/soc/sof/amd/rembrandt.c (revision 2f164822)
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) 2022 Advanced Micro Devices, Inc.
7 //
8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
9 
10 /*
11  * Hardware interface for Audio DSP on Rembrandt 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_HS_INSTANCE		0
23 #define I2S_BT_INSTANCE		1
24 #define I2S_SP_INSTANCE		2
25 #define PDM_DMIC_INSTANCE	3
26 #define I2S_HS_VIRTUAL_INSTANCE	4
27 
28 static struct snd_soc_dai_driver rembrandt_sof_dai[] = {
29 	[I2S_HS_INSTANCE] = {
30 		.id = I2S_HS_INSTANCE,
31 		.name = "acp-sof-hs",
32 		.playback = {
33 			.rates = SNDRV_PCM_RATE_8000_96000,
34 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
35 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
36 			.channels_min = 2,
37 			.channels_max = 8,
38 			.rate_min = 8000,
39 			.rate_max = 96000,
40 		},
41 		.capture = {
42 			.rates = SNDRV_PCM_RATE_8000_48000,
43 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
44 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
45 			/* Supporting only stereo for I2S HS controller capture */
46 			.channels_min = 2,
47 			.channels_max = 2,
48 			.rate_min = 8000,
49 			.rate_max = 48000,
50 		},
51 		.probe = &acp_dai_probe,
52 	},
53 
54 	[I2S_BT_INSTANCE] = {
55 		.id = I2S_BT_INSTANCE,
56 		.name = "acp-sof-bt",
57 		.playback = {
58 			.rates = SNDRV_PCM_RATE_8000_96000,
59 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
60 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
61 			.channels_min = 2,
62 			.channels_max = 8,
63 			.rate_min = 8000,
64 			.rate_max = 96000,
65 		},
66 		.capture = {
67 			.rates = SNDRV_PCM_RATE_8000_48000,
68 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
69 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
70 			/* Supporting only stereo for I2S BT controller capture */
71 			.channels_min = 2,
72 			.channels_max = 2,
73 			.rate_min = 8000,
74 			.rate_max = 48000,
75 		},
76 		.probe = &acp_dai_probe,
77 	},
78 
79 	[I2S_SP_INSTANCE] = {
80 		.id = I2S_SP_INSTANCE,
81 		.name = "acp-sof-sp",
82 		.playback = {
83 			.rates = SNDRV_PCM_RATE_8000_96000,
84 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
85 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
86 			.channels_min = 2,
87 			.channels_max = 8,
88 			.rate_min = 8000,
89 			.rate_max = 96000,
90 		},
91 		.capture = {
92 			.rates = SNDRV_PCM_RATE_8000_48000,
93 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
94 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
95 			/* Supporting only stereo for I2S SP controller capture */
96 			.channels_min = 2,
97 			.channels_max = 2,
98 			.rate_min = 8000,
99 			.rate_max = 48000,
100 		},
101 		.probe = &acp_dai_probe,
102 	},
103 
104 	[PDM_DMIC_INSTANCE] = {
105 		.id = PDM_DMIC_INSTANCE,
106 		.name = "acp-sof-dmic",
107 		.capture = {
108 			.rates = SNDRV_PCM_RATE_8000_48000,
109 			.formats = SNDRV_PCM_FMTBIT_S32_LE,
110 			.channels_min = 2,
111 			.channels_max = 4,
112 			.rate_min = 8000,
113 			.rate_max = 48000,
114 		},
115 	},
116 
117 	[I2S_HS_VIRTUAL_INSTANCE] = {
118 		.id = I2S_HS_VIRTUAL_INSTANCE,
119 		.name = "acp-sof-hs-virtual",
120 		.playback = {
121 			.rates = SNDRV_PCM_RATE_8000_96000,
122 			.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
123 				   SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
124 			.channels_min = 2,
125 			.channels_max = 8,
126 			.rate_min = 8000,
127 			.rate_max = 96000,
128 		},
129 		.probe = &acp_dai_probe,
130 	},
131 };
132 
133 /* Rembrandt ops */
134 struct snd_sof_dsp_ops sof_rembrandt_ops;
135 EXPORT_SYMBOL_NS(sof_rembrandt_ops, SND_SOC_SOF_AMD_COMMON);
136 
137 int sof_rembrandt_ops_init(struct snd_sof_dev *sdev)
138 {
139 	/* common defaults */
140 	memcpy(&sof_rembrandt_ops, &sof_acp_common_ops, sizeof(struct snd_sof_dsp_ops));
141 
142 	sof_rembrandt_ops.drv = rembrandt_sof_dai;
143 	sof_rembrandt_ops.num_drv = ARRAY_SIZE(rembrandt_sof_dai);
144 
145 	return 0;
146 }
147 
148 MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
149 MODULE_DESCRIPTION("REMBRANDT SOF Driver");
150 MODULE_LICENSE("Dual BSD/GPL");
151