19
19
20
20
#include "stm32_sai.h"
21
21
22
+ static int stm32_sai_get_parent_clk (struct stm32_sai_data * sai );
23
+
22
24
static const struct stm32_sai_conf stm32_sai_conf_f4 = {
23
25
.version = STM_SAI_STM32F4 ,
24
26
.fifo_size = 8 ,
25
27
.has_spdif_pdm = false,
28
+ .get_sai_ck_parent = stm32_sai_get_parent_clk ,
26
29
};
27
30
28
31
/*
29
- * Default settings for stm32 H7 socs and next .
32
+ * Default settings for STM32H7x socs and STM32MP1x .
30
33
* These default settings will be overridden if the soc provides
31
34
* support of hardware configuration registers.
35
+ * - STM32H7: rely on default settings
36
+ * - STM32MP1: retrieve settings from registers
32
37
*/
33
38
static const struct stm32_sai_conf stm32_sai_conf_h7 = {
34
39
.version = STM_SAI_STM32H7 ,
35
40
.fifo_size = 8 ,
36
41
.has_spdif_pdm = true,
42
+ .get_sai_ck_parent = stm32_sai_get_parent_clk ,
43
+ };
44
+
45
+ /*
46
+ * STM32MP2x:
47
+ * - do not use SAI parent clock source selection
48
+ * - do not use DMA burst mode
49
+ */
50
+ static const struct stm32_sai_conf stm32_sai_conf_mp25 = {
51
+ .no_dma_burst = true,
37
52
};
38
53
39
54
static const struct of_device_id stm32_sai_ids [] = {
40
55
{ .compatible = "st,stm32f4-sai" , .data = (void * )& stm32_sai_conf_f4 },
41
56
{ .compatible = "st,stm32h7-sai" , .data = (void * )& stm32_sai_conf_h7 },
57
+ { .compatible = "st,stm32mp25-sai" , .data = (void * )& stm32_sai_conf_mp25 },
42
58
{}
43
59
};
44
60
@@ -148,6 +164,29 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
148
164
return ret ;
149
165
}
150
166
167
+ static int stm32_sai_get_parent_clk (struct stm32_sai_data * sai )
168
+ {
169
+ struct device * dev = & sai -> pdev -> dev ;
170
+
171
+ sai -> clk_x8k = devm_clk_get (dev , "x8k" );
172
+ if (IS_ERR (sai -> clk_x8k )) {
173
+ if (PTR_ERR (sai -> clk_x8k ) != - EPROBE_DEFER )
174
+ dev_err (dev , "missing x8k parent clock: %ld\n" ,
175
+ PTR_ERR (sai -> clk_x8k ));
176
+ return PTR_ERR (sai -> clk_x8k );
177
+ }
178
+
179
+ sai -> clk_x11k = devm_clk_get (dev , "x11k" );
180
+ if (IS_ERR (sai -> clk_x11k )) {
181
+ if (PTR_ERR (sai -> clk_x11k ) != - EPROBE_DEFER )
182
+ dev_err (dev , "missing x11k parent clock: %ld\n" ,
183
+ PTR_ERR (sai -> clk_x11k ));
184
+ return PTR_ERR (sai -> clk_x11k );
185
+ }
186
+
187
+ return 0 ;
188
+ }
189
+
151
190
static int stm32_sai_probe (struct platform_device * pdev )
152
191
{
153
192
struct stm32_sai_data * sai ;
@@ -160,6 +199,8 @@ static int stm32_sai_probe(struct platform_device *pdev)
160
199
if (!sai )
161
200
return - ENOMEM ;
162
201
202
+ sai -> pdev = pdev ;
203
+
163
204
sai -> base = devm_platform_ioremap_resource (pdev , 0 );
164
205
if (IS_ERR (sai -> base ))
165
206
return PTR_ERR (sai -> base );
@@ -178,15 +219,11 @@ static int stm32_sai_probe(struct platform_device *pdev)
178
219
"missing bus clock pclk\n" );
179
220
}
180
221
181
- sai -> clk_x8k = devm_clk_get (& pdev -> dev , "x8k" );
182
- if (IS_ERR (sai -> clk_x8k ))
183
- return dev_err_probe (& pdev -> dev , PTR_ERR (sai -> clk_x8k ),
184
- "missing x8k parent clock\n" );
185
-
186
- sai -> clk_x11k = devm_clk_get (& pdev -> dev , "x11k" );
187
- if (IS_ERR (sai -> clk_x11k ))
188
- return dev_err_probe (& pdev -> dev , PTR_ERR (sai -> clk_x11k ),
189
- "missing x11k parent clock\n" );
222
+ if (sai -> conf .get_sai_ck_parent ) {
223
+ ret = sai -> conf .get_sai_ck_parent (sai );
224
+ if (ret )
225
+ return ret ;
226
+ }
190
227
191
228
/* init irqs */
192
229
sai -> irq = platform_get_irq (pdev , 0 );
@@ -227,7 +264,6 @@ static int stm32_sai_probe(struct platform_device *pdev)
227
264
}
228
265
clk_disable_unprepare (sai -> pclk );
229
266
230
- sai -> pdev = pdev ;
231
267
sai -> set_sync = & stm32_sai_set_sync ;
232
268
platform_set_drvdata (pdev , sai );
233
269
0 commit comments