i2s: compatible with rk3126/rk3126b/rk3128.

because i2s controller is different between rk3126 and rk3126b,
but require the same dtb, so add runtime compatible.
This commit is contained in:
sugar 2014-12-09 16:29:02 +08:00
parent 59a94c106e
commit ea0122bffa
4 changed files with 47 additions and 31 deletions

View File

@ -26,34 +26,7 @@ &rockchip_clocks_init {
};
&i2s0 {
/* sdi: 0: from io, 1: from acodec */
sdi_source = <1>;
status = "okay";
};
&i2s1 {
status = "disabled";
};
&rockchip_audio {
dais {
dai0 {
audio-codec = <&codec>;
i2s-controller = <&i2s0>;
format = "i2s";
//continuous-clock;
//bitclock-inversion;
//frame-inversion;
//bitclock-master;
//frame-master;
};
dai1 {
audio-codec = <&codec>;
i2s-controller = <&i2s0>;
format = "i2s";
//continuous-clock;
//bitclock-inversion;
//frame-inversion;
//bitclock-master;
//frame-master;
};
};
};

View File

@ -470,7 +470,7 @@ i2c3: i2c@2005e000 {
status = "disabled";
};
i2s0: i2s@10220000 {
i2s0: i2s0@10220000 {
compatible = "rockchip-i2s";
reg = <0x10220000 0x1000>;
i2s-id = <0>;
@ -486,7 +486,7 @@ i2s0: i2s@10220000 {
status = "disabled";
};
i2s1: i2s@10200000 {
i2s1: i2s1@10200000 {
compatible = "rockchip-i2s";
reg = <0x10200000 0x1000>;
i2s-id = <1>;

28
sound/soc/rockchip/rk30_i2s.c Normal file → Executable file
View File

@ -25,6 +25,9 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/rockchip/cpu.h>
#include <linux/rockchip/cru.h>
#include <linux/rockchip/grf.h>
#include <linux/slab.h>
#include <asm/dma.h>
#include <sound/core.h>
@ -535,6 +538,31 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
goto err;
}
if (soc_is_rk3126b()) {
int sdi_src = 0;
/* rk3126b has no i2s1 controller(i2s_8ch) */
if (1 == pdev->id) {
pr_info("rk3126b has no i2s1 controller\n");
ret = -ENODEV;
goto err;
}
ret = of_property_read_u32(node, "sdi_source",
&sdi_src);
if (ret < 0)
sdi_src = 0;
if (1 == sdi_src) {
int val;
/*GRF_SOC_CON*/
val = readl_relaxed(RK_GRF_VIRT + 0x0140);
val = val | 0x04000400;
writel_relaxed(val, RK_GRF_VIRT + 0x0140);
}
}
if(pdev->id >= MAX_I2S) {
dev_err(&pdev->dev, "id %d out of range\n", pdev->id);
ret = -ENOMEM;

View File

@ -15,6 +15,7 @@
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/rockchip/cpu.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
@ -245,6 +246,7 @@ static struct snd_soc_card rockchip_rk312x_snd_card = {
static int rockchip_rk312x_audio_probe(struct platform_device *pdev)
{
int ret;
struct snd_soc_card *card = &rockchip_rk312x_snd_card;
card->dev = &pdev->dev;
@ -254,6 +256,19 @@ static int rockchip_rk312x_audio_probe(struct platform_device *pdev)
return ret;
}
/* rk3126b workaround remap cpu dai node */
if (soc_is_rk3126b()) {
int i;
struct device_node *cpu_dai_node;
cpu_dai_node = of_find_node_by_name(NULL, "i2s0");
for (i = 0; i < card->num_links; i++) {
card->dai_link[i].cpu_of_node = cpu_dai_node;
card->dai_link[i].platform_of_node = cpu_dai_node;
}
}
ret = snd_soc_register_card(card);
if (ret)
DBG("%s() register card failed:%d\n", __func__, ret);