Skip to content

Commit b3ea5be

Browse files
committed
ASoC: stm32: sai: add stm32mp25 support
Merge series from Olivier Moysan <[email protected]>: Update STM32 SAI driver and binding to support STM32MP25 SoCs.
2 parents 79ef7a4 + 2cfe1ff commit b3ea5be

File tree

4 files changed

+216
-18
lines changed

4 files changed

+216
-18
lines changed

Documentation/devicetree/bindings/sound/st,stm32-sai.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ properties:
2020
enum:
2121
- st,stm32f4-sai
2222
- st,stm32h7-sai
23+
- st,stm32mp25-sai
2324

2425
reg:
2526
items:
@@ -43,9 +44,11 @@ properties:
4344
const: 1
4445

4546
clocks:
47+
minItems: 1
4648
maxItems: 3
4749

4850
clock-names:
51+
minItems: 1
4952
maxItems: 3
5053

5154
access-controllers:
@@ -156,7 +159,13 @@ allOf:
156159
items:
157160
- const: x8k
158161
- const: x11k
159-
else:
162+
163+
- if:
164+
properties:
165+
compatible:
166+
contains:
167+
const: st,stm32mph7-sai
168+
then:
160169
properties:
161170
clocks:
162171
items:
@@ -170,6 +179,21 @@ allOf:
170179
- const: x8k
171180
- const: x11k
172181

182+
- if:
183+
properties:
184+
compatible:
185+
contains:
186+
const: st,stm32mp25-sai
187+
then:
188+
properties:
189+
clocks:
190+
items:
191+
- description: pclk feeds the peripheral bus interface.
192+
193+
clock-names:
194+
items:
195+
- const: pclk
196+
173197
additionalProperties: false
174198

175199
examples:

sound/soc/stm/stm32_sai.c

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,42 @@
1919

2020
#include "stm32_sai.h"
2121

22+
static int stm32_sai_get_parent_clk(struct stm32_sai_data *sai);
23+
2224
static const struct stm32_sai_conf stm32_sai_conf_f4 = {
2325
.version = STM_SAI_STM32F4,
2426
.fifo_size = 8,
2527
.has_spdif_pdm = false,
28+
.get_sai_ck_parent = stm32_sai_get_parent_clk,
2629
};
2730

2831
/*
29-
* Default settings for stm32 H7 socs and next.
32+
* Default settings for STM32H7x socs and STM32MP1x.
3033
* These default settings will be overridden if the soc provides
3134
* support of hardware configuration registers.
35+
* - STM32H7: rely on default settings
36+
* - STM32MP1: retrieve settings from registers
3237
*/
3338
static const struct stm32_sai_conf stm32_sai_conf_h7 = {
3439
.version = STM_SAI_STM32H7,
3540
.fifo_size = 8,
3641
.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,
3752
};
3853

3954
static const struct of_device_id stm32_sai_ids[] = {
4055
{ .compatible = "st,stm32f4-sai", .data = (void *)&stm32_sai_conf_f4 },
4156
{ .compatible = "st,stm32h7-sai", .data = (void *)&stm32_sai_conf_h7 },
57+
{ .compatible = "st,stm32mp25-sai", .data = (void *)&stm32_sai_conf_mp25 },
4258
{}
4359
};
4460

@@ -148,6 +164,29 @@ static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
148164
return ret;
149165
}
150166

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+
151190
static int stm32_sai_probe(struct platform_device *pdev)
152191
{
153192
struct stm32_sai_data *sai;
@@ -160,6 +199,8 @@ static int stm32_sai_probe(struct platform_device *pdev)
160199
if (!sai)
161200
return -ENOMEM;
162201

202+
sai->pdev = pdev;
203+
163204
sai->base = devm_platform_ioremap_resource(pdev, 0);
164205
if (IS_ERR(sai->base))
165206
return PTR_ERR(sai->base);
@@ -178,15 +219,11 @@ static int stm32_sai_probe(struct platform_device *pdev)
178219
"missing bus clock pclk\n");
179220
}
180221

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+
}
190227

191228
/* init irqs */
192229
sai->irq = platform_get_irq(pdev, 0);
@@ -227,7 +264,6 @@ static int stm32_sai_probe(struct platform_device *pdev)
227264
}
228265
clk_disable_unprepare(sai->pclk);
229266

230-
sai->pdev = pdev;
231267
sai->set_sync = &stm32_sai_set_sync;
232268
platform_set_drvdata(pdev, sai);
233269

sound/soc/stm/stm32_sai.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,22 @@ enum stm32_sai_syncout {
264264
STM_SAI_SYNC_OUT_B,
265265
};
266266

267+
struct stm32_sai_data;
268+
267269
/**
268270
* struct stm32_sai_conf - SAI configuration
271+
* @get_sai_ck_parent: get parent clock of SAI kernel clock
269272
* @version: SAI version
270273
* @fifo_size: SAI fifo size as words number
271274
* @has_spdif_pdm: SAI S/PDIF and PDM features support flag
275+
* @no_dma_burst: Support only DMA single transfers if set
272276
*/
273277
struct stm32_sai_conf {
278+
int (*get_sai_ck_parent)(struct stm32_sai_data *sai);
274279
u32 version;
275280
u32 fifo_size;
276281
bool has_spdif_pdm;
282+
bool no_dma_burst;
277283
};
278284

279285
/**

0 commit comments

Comments
 (0)