i2s: compatible with rk3126/rk3126b/rk3128.
authorsugar <sugar.zhang@rock-chips.com>
Tue, 9 Dec 2014 08:29:02 +0000 (16:29 +0800)
committersugar <sugar.zhang@rock-chips.com>
Tue, 9 Dec 2014 08:29:02 +0000 (16:29 +0800)
because i2s controller is different between rk3126 and rk3126b,
but require the same dtb, so add runtime compatible.

arch/arm/boot/dts/rk3126-sdk.dtsi
arch/arm/boot/dts/rk312x.dtsi
sound/soc/rockchip/rk30_i2s.c [changed mode: 0644->0755]
sound/soc/rockchip/rk_rk312x.c

index 9ecc0b400fd15cb1333fe276b28da88308cf4be4..4ef2434411a71dd8d11375146c292a7566216cb9 100755 (executable)
 };
 
 &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;
-               };
-       };
 };
\ No newline at end of file
index fe7cd7697f92c8fb9a66ee3c87fd70e94d813aa0..bfd45e82e295a099cbee55092c806a1dbec2b983 100755 (executable)
                status = "disabled";
        };
 
-       i2s0: i2s@10220000 {
+       i2s0: i2s0@10220000 {
                compatible = "rockchip-i2s";
                reg = <0x10220000 0x1000>;
                i2s-id = <0>;
                status = "disabled";
        };
 
-       i2s1: i2s@10200000 {
+       i2s1: i2s1@10200000 {
                compatible = "rockchip-i2s";
                reg = <0x10200000 0x1000>;
                i2s-id = <1>;
old mode 100644 (file)
new mode 100755 (executable)
index df121bb..3c8b5d2
@@ -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;
index dca6fac5b1ba2c0c2489b9575a70fc9695351eeb..f42956f8e0b811c16c477a55cfa35edf84a90d30 100755 (executable)
@@ -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);