Skip to content

Commit 9c5bec9

Browse files
author
Sugar Zhang
committed
ASoC: rockchip: multi_dais: add support for rk3308 i2s-16ch
Change-Id: I63ee1e32ebd70348274ca7da153983071f7906c1 Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
1 parent 158dc61 commit 9c5bec9

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Documentation/devicetree/bindings/sound/rockchip,multidais.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ROCKCHIP multi dais driver
22

33
Required properties:
44
- compatible: "rockchip,multi-dais"
5+
- "rockchip,rk3308-multi-dais"
56
- dais: The phandle of sub dais, such i2s, pdm etc.
67
- capture,channel-mapping: map channels, one for each in dais,
78
capture,channel-mapping = <2 6> means:
@@ -10,6 +11,15 @@ Required properties:
1011
playback,channel-mapping = <4 4> means:
1112
i2s 4ch + pdm 4ch --> total 8ch playback.
1213

14+
Required properties for i2s 16ch:
15+
- rockchip,grf: the phandle of the syscon node for GRF register.
16+
17+
Optional properties:
18+
- frame-master: bool properties, frame master, one for each in dais.
19+
- bitclock-master: bool properties, bit clock master, one for each in dais.
20+
- bitclock-inversion: bool properties, bit clock inversion, one for each in dais.
21+
- frame-inversion: bool properties, frame clock inversion, one for each in dais.
22+
1323
Example:
1424

1525
multi_dais: multi-dais {
@@ -18,6 +28,11 @@ multi_dais: multi-dais {
1828
dais = <&i2s_8ch_2>, <&pdm_8ch>;
1929
capture,channel-mapping = <2 6>;
2030
playback,channel-mapping = <4 4>;
31+
bitclock-master = <1 0>;
32+
frame-master = <1 0>;
33+
bitclock-inversion = <0 0>;
34+
frame-inversion = <0 0>;
35+
rockchip,grf = <&grf>;
2136
};
2237

2338
&i2s_8ch_2 {

sound/soc/rockchip/rockchip_multi_dais.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <linux/module.h>
11+
#include <linux/mfd/syscon.h>
1112
#include <linux/of_device.h>
1213
#include <linux/pm_runtime.h>
1314
#include <sound/pcm_params.h>
@@ -20,6 +21,7 @@
2021
#define BITCLOCK_MASTER_STR "bitclock-master"
2122
#define FRAME_MASTER_STR "frame-master"
2223
#define DAIS_DRV_NAME "rockchip-mdais"
24+
#define RK3308_GRF_SOC_CON2 0x308
2325

2426
static inline struct rk_mdais_dev *to_info(struct snd_soc_dai *dai)
2527
{
@@ -169,6 +171,7 @@ static const struct snd_soc_component_driver rockchip_mdais_component = {
169171

170172
static const struct of_device_id rockchip_mdais_match[] = {
171173
{ .compatible = "rockchip,multi-dais", },
174+
{ .compatible = "rockchip,rk3308-multi-dais", },
172175
{},
173176
};
174177

@@ -418,6 +421,36 @@ static int rockchip_mdais_probe(struct platform_device *pdev)
418421
mdais_parse_daifmt(np, dais, count);
419422
mdais_fixup_dai(soc_dai, mdais);
420423

424+
if (of_device_is_compatible(np, "rockchip,rk3308-multi-dais")) {
425+
struct regmap *grf;
426+
const char *name;
427+
unsigned int i2s0_fmt = 0, i2s1_fmt = 0;
428+
429+
for (i = 0; i < count; i++) {
430+
name = dev_name(dais[i].dev);
431+
if (strstr(name, "ff300000"))
432+
i2s0_fmt = dais[i].fmt;
433+
else if (strstr(name, "ff310000"))
434+
i2s1_fmt = dais[i].fmt;
435+
}
436+
i2s0_fmt &= SND_SOC_DAIFMT_MASTER_MASK;
437+
i2s1_fmt &= SND_SOC_DAIFMT_MASTER_MASK;
438+
439+
if ((i2s0_fmt == SND_SOC_DAIFMT_CBS_CFS &&
440+
i2s1_fmt == SND_SOC_DAIFMT_CBM_CFM) ||
441+
(i2s0_fmt == SND_SOC_DAIFMT_CBM_CFM &&
442+
i2s1_fmt == SND_SOC_DAIFMT_CBS_CFS)) {
443+
grf = syscon_regmap_lookup_by_phandle(np,
444+
"rockchip,grf");
445+
if (IS_ERR(grf))
446+
return PTR_ERR(grf);
447+
448+
dev_info(&pdev->dev, "enable i2s 16ch ctrl en\n");
449+
regmap_write(grf, RK3308_GRF_SOC_CON2,
450+
BIT(14) << 16 | BIT(14));
451+
}
452+
}
453+
421454
mdais->dais = dais;
422455
mdais->dev = &pdev->dev;
423456
dev_set_drvdata(&pdev->dev, mdais);

0 commit comments

Comments
 (0)