From: sugar Date: Tue, 9 Dec 2014 08:29:02 +0000 (+0800) Subject: i2s: compatible with rk3126/rk3126b/rk3128. X-Git-Tag: firefly_0821_release~4406 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ea0122bffa0db1cf8ba42381e450cb489c386c8c;p=firefly-linux-kernel-4.4.55.git i2s: compatible with rk3126/rk3126b/rk3128. because i2s controller is different between rk3126 and rk3126b, but require the same dtb, so add runtime compatible. --- diff --git a/arch/arm/boot/dts/rk3126-sdk.dtsi b/arch/arm/boot/dts/rk3126-sdk.dtsi index 9ecc0b400fd1..4ef2434411a7 100755 --- a/arch/arm/boot/dts/rk3126-sdk.dtsi +++ b/arch/arm/boot/dts/rk3126-sdk.dtsi @@ -26,34 +26,7 @@ }; &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 diff --git a/arch/arm/boot/dts/rk312x.dtsi b/arch/arm/boot/dts/rk312x.dtsi index fe7cd7697f92..bfd45e82e295 100755 --- a/arch/arm/boot/dts/rk312x.dtsi +++ b/arch/arm/boot/dts/rk312x.dtsi @@ -470,7 +470,7 @@ status = "disabled"; }; - i2s0: i2s@10220000 { + i2s0: i2s0@10220000 { compatible = "rockchip-i2s"; reg = <0x10220000 0x1000>; i2s-id = <0>; @@ -486,7 +486,7 @@ status = "disabled"; }; - i2s1: i2s@10200000 { + i2s1: i2s1@10200000 { compatible = "rockchip-i2s"; reg = <0x10200000 0x1000>; i2s-id = <1>; diff --git a/sound/soc/rockchip/rk30_i2s.c b/sound/soc/rockchip/rk30_i2s.c old mode 100644 new mode 100755 index df121bbf7eb0..3c8b5d250ab2 --- a/sound/soc/rockchip/rk30_i2s.c +++ b/sound/soc/rockchip/rk30_i2s.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -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; diff --git a/sound/soc/rockchip/rk_rk312x.c b/sound/soc/rockchip/rk_rk312x.c index dca6fac5b1ba..f42956f8e0b8 100755 --- a/sound/soc/rockchip/rk_rk312x.c +++ b/sound/soc/rockchip/rk_rk312x.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -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);