vdac: get cputype from dts
authorNian Jing <nian.jing@amlogic.com>
Thu, 27 Sep 2018 05:32:14 +0000 (13:32 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 10 Oct 2018 10:43:25 +0000 (03:43 -0700)
PD#174269: get cputype from dts

Change-Id: I50e240e8d1f2aa275a2c215989e02e8b51cb6738
Signed-off-by: Nian Jing <nian.jing@amlogic.com>
40 files changed:
arch/arm/boot/dts/amlogic/mesongxl.dtsi
arch/arm/boot/dts/amlogic/mesontxl.dtsi
arch/arm/boot/dts/amlogic/mesontxlx.dtsi
arch/arm/boot/dts/amlogic/txlx_t962e_r321.dts
arch/arm/boot/dts/amlogic/txlx_t962x_r311_1g.dts
arch/arm/boot/dts/amlogic/txlx_t962x_r311_2g.dts
arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts
arch/arm64/boot/dts/amlogic/gxl_p212_1g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxl_p212_1g_hd.dts
arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts
arch/arm64/boot/dts/amlogic/gxl_p212_2g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts
arch/arm64/boot/dts/amlogic/gxl_p230_2g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxl_p231_1g.dts
arch/arm64/boot/dts/amlogic/gxl_p231_2g.dts
arch/arm64/boot/dts/amlogic/gxl_p231_2g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxl_p241_1g.dts
arch/arm64/boot/dts/amlogic/gxl_p241_1g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxl_p241_v2-1g.dts
arch/arm64/boot/dts/amlogic/gxl_p241_v2_1g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxl_sei210_1g.dts
arch/arm64/boot/dts/amlogic/gxl_sei210_2g.dts
arch/arm64/boot/dts/amlogic/gxl_skt.dts
arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts
arch/arm64/boot/dts/amlogic/gxm_q200_2g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxm_skt.dts
arch/arm64/boot/dts/amlogic/mesong12a.dtsi
arch/arm64/boot/dts/amlogic/mesong12b.dtsi
arch/arm64/boot/dts/amlogic/mesongxl.dtsi
arch/arm64/boot/dts/amlogic/mesongxl_sei210.dtsi
arch/arm64/boot/dts/amlogic/mesongxm.dtsi
arch/arm64/boot/dts/amlogic/mesontxl.dtsi
arch/arm64/boot/dts/amlogic/mesontxlx.dtsi
arch/arm64/boot/dts/amlogic/txlx_t962e_r321.dts
arch/arm64/boot/dts/amlogic/txlx_t962e_r321_buildroot.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts
drivers/amlogic/media/vout/vdac/vdac_dev.c
include/linux/amlogic/media/vout/vdac_dev.h

index f534e7d..88f08e4 100644 (file)
        cpu_ver_name {
                compatible = "amlogic, cpu-major-id-gxl";
        };
+
+       vdac {
+               compatible = "amlogic, vdac-gxl";
+               status = "okay";
+       };
 }; /* end of root */
 
 &pinctrl_aobus {
index 9e47e49..d585dc2 100644 (file)
                reg_base = <0xda838400>;
                interrupts = <0 51 1>;
        };
+
+       vdac {
+               compatible = "amlogic, vdac-txl";
+               status = "okay";
+       };
 }; /* end of / */
 
 &gpu{
index 70813bb..9989091 100644 (file)
        cpu_ver_name {
                compatible = "amlogic, cpu-major-id-txlx";
        };
+
+       vdac {
+               compatible = "amlogic, vdac-txlx";
+               status = "okay";
+       };
 }; /* end of / */
 
 &pinctrl_aobus {
index 9aa3be6..e40d783 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index 6192078..b9b6bfe 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index 93ab8e9..9a39e56 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index 4eefc12..5fa4dbc 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 13fb0af..c2d3b92 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 3a34777..6a064bb 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 01e81fb..2ffd2de 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 149cb47..b2a48e9 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 3ed702f..bbb6ab8 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index b2e9b9a..bbea7f6 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 6924250..0d924c2 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index ad78b2a..e66d3e4 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index b4acc1e..f77ec38 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index ed5256c..f8e7ff5 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index aa9cce3..b7104b5 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 49605c5..25b9fdc 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index bf77a30..8118feb 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index b0821d8..2c2f3f8 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 9e3d5ac..565b840 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index 70cb2e2..1ab1a07 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxl";
                dev_name = "cvbsout";
index d75ee5c..38214b1 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxm";
                dev_name = "cvbsout";
index 03ec331..20d0c13 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxm";
                dev_name = "cvbsout";
index 5e026ec..90dde40 100644 (file)
                fr_auto_policy = <0>;
        };
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-gxm";
                dev_name = "cvbsout";
index 250aa29..378950d 100644 (file)
        };
 
        vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
+               compatible = "amlogic, vdac-g12a";
                status = "okay";
        };
 
index fc16512..a5be3ea 100644 (file)
        };
 
        vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "disabled";
+               compatible = "amlogic, vdac-g12b";
+               status = "okay";
        };
 
        canvas: canvas{
index e06f4c8..42fdd83 100644 (file)
        cpu_ver_name {
                compatible = "amlogic, cpu-major-id-gxl";
        };
+
+       vdac {
+               compatible = "amlogic, vdac-gxl";
+               status = "okay";
+       };
 }; /* end of root */
 
 &pinctrl_aobus {
index 77c62b9..b2e72ec 100644 (file)
                        ranges = <0x0 0x0 0x0 0xd0000000 0x0 0x200000>;
                };
        }; /* end of soc */
+
+       vdac {
+               compatible = "amlogic, vdac-gxl";
+               status = "okay";
+       };
 }; /* end of root */
 
 &pinctrl_aobus {
index d127e64..22cbefd 100644 (file)
        cpu_ver_name {
                compatible = "amlogic, cpu-major-id-gxm";
        };
+
+       vdac {
+               compatible = "amlogic, vdac-gxm";
+               status = "okay";
+       };
 }; /* end of root */
 
 &pinctrl_aobus {
index ba294f2..43885b0 100644 (file)
                reg_base = <0xda838400>;
                interrupts = <0 51 1>;
        };
+
+       vdac {
+               compatible = "amlogic, vdac-txl";
+               status = "okay";
+       };
 }; /* end of / */
 
 &gpu{
index c2c9eb7..11424d0 100644 (file)
        cpu_ver_name {
                compatible = "amlogic, cpu-major-id-txlx";
        };
+
+       vdac {
+               compatible = "amlogic, vdac-txlx";
+               status = "okay";
+       };
 }; /* end of / */
 
 &pinctrl_aobus {
index e8eb091..87ec785 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index 76c5a37..8564ca3 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index 7d37fd6..017e54b 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index b0b5f7f..fb3aaac 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index 2d00975..c6e9fdd 100644 (file)
                };
        }; /* End unifykey */
 
-       vdac {
-               compatible = "amlogic, vdac";
-               dev_name = "vdac";
-               status = "okay";
-       };
-
        cvbsout {
                compatible = "amlogic, cvbsout-txlx";
                dev_name = "cvbsout";
index ea13a56..a1a1548 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/device.h>
 #include <linux/cdev.h>
 #include <linux/platform_device.h>
+#include <linux/of_device.h>
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
@@ -52,6 +53,7 @@ struct amvdac_dev_s {
        struct class                *clsp;
 };
 static struct amvdac_dev_s amvdac_dev;
+static struct meson_vdac_data *s_vdac_data;
 static struct mutex vdac_mutex;
 
 #define HHI_VDAC_CNTL0 0xbd
@@ -152,7 +154,8 @@ void ana_ref_cntl0_bit9(bool on, unsigned int module_sel)
                        vdac_cntl0_bit9 &= ~VDAC_MODULE_CVBS_OUT;
                break;
        case VDAC_MODULE_AUDIO_OUT: /* audio out ctrl*/
-               if (is_meson_txl_cpu() || is_meson_txlx_cpu()) {
+               if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+                       s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
                        if (on)
                                vdac_cntl0_bit9 |= VDAC_MODULE_AUDIO_OUT;
                        else
@@ -170,10 +173,10 @@ void ana_ref_cntl0_bit9(bool on, unsigned int module_sel)
        else
                enable = 1;
 
-       if (is_meson_txl_cpu() || is_meson_txlx_cpu())
+       if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+                       s_vdac_data->cpu_id == CPU_TYPE_TXLX)
                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, enable, 9, 1);
-       else if (is_meson_g12a_cpu() ||
-                       is_meson_g12b_cpu())
+       else if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
                vdac_hiu_reg_setb(HHI_VDAC_CNTL0_G12A, ~enable, 9, 1);
        else
                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, ~enable, 9, 1);
@@ -188,7 +191,7 @@ void vdac_out_cntl0_bit10(bool on, unsigned int module_sel)
        bool enable = 0;
 
        /*bit10 is for bandgap startup setting in g12a*/
-       if (is_meson_g12a_cpu() || is_meson_g12b_cpu())
+       if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
                return;
 
        switch (module_sel & 0xf) {
@@ -274,7 +277,7 @@ void vdac_out_cntl0_bit0(bool on, unsigned int module_sel)
        else
                enable = 1;
 
-       if (is_meson_g12a_cpu() || is_meson_g12b_cpu())
+       if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
                vdac_hiu_reg_setb(HHI_VDAC_CNTL0_G12A, enable, 0, 1);
        else
                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, enable, 0, 1);
@@ -324,9 +327,10 @@ void vdac_out_cntl1_bit3(bool on, unsigned int module_sel)
        else
                enable = 1;
 
-       if (is_meson_txl_cpu() || is_meson_txlx_cpu())
+       if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+                       s_vdac_data->cpu_id == CPU_TYPE_TXLX)
                vdac_hiu_reg_setb(HHI_VDAC_CNTL1, enable, 3, 1);
-       else if (is_meson_g12a_cpu() || is_meson_g12b_cpu())
+       else if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
                vdac_hiu_reg_setb(HHI_VDAC_CNTL1_G12A, ~enable, 3, 1);
        else
                vdac_hiu_reg_setb(HHI_VDAC_CNTL1, ~enable, 3, 1);
@@ -335,7 +339,7 @@ EXPORT_SYMBOL(vdac_out_cntl1_bit3);
 
 void vdac_set_ctrl0_ctrl1(unsigned int ctrl0, unsigned int ctrl1)
 {
-       if (is_meson_g12a_cpu() || is_meson_g12b_cpu()) {
+       if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB) {
                vdac_hiu_reg_write(HHI_VDAC_CNTL0_G12A, ctrl0);
                vdac_hiu_reg_write(HHI_VDAC_CNTL1_G12A, ctrl1);
        } else {
@@ -359,7 +363,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                        ana_ref_cntl0_bit9(1, VDAC_MODULE_ATV_DEMOD);
                        /*after txlx need reset bandgap after bit9 enabled*/
                        /*bit10 reset bandgap in g12a*/
-                       if (is_meson_txlx_cpu()) {
+                       if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
                                udelay(5);
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
@@ -371,7 +375,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                        /*Cdac pwd*/
                        vdac_out_cntl1_bit3(1, VDAC_MODULE_ATV_DEMOD);
                        /* enable AFE output buffer */
-                       if (!is_meson_g12a_cpu() && !is_meson_g12b_cpu())
+                       if (s_vdac_data->cpu_id < CPU_TYPE_G12AB)
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 10, 1);
                        vdac_out_cntl0_bit0(1, VDAC_MODULE_ATV_DEMOD);
                } else {
@@ -381,7 +385,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                                break;
                        vdac_out_cntl0_bit0(0, VDAC_MODULE_ATV_DEMOD);
                        /* Disable AFE output buffer */
-                       if (!is_meson_g12a_cpu() && !is_meson_g12b_cpu())
+                       if (s_vdac_data->cpu_id < CPU_TYPE_G12AB)
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 10, 1);
                        /* enable dac output */
                        vdac_out_cntl1_bit3(0, VDAC_MODULE_ATV_DEMOD);
@@ -389,10 +393,10 @@ void vdac_enable(bool on, unsigned int module_sel)
                break;
        case VDAC_MODULE_DTV_DEMOD: /* dtv demod */
                if (on) {
-                       if (is_meson_gxlx_cpu())
+                       if (s_vdac_data->cpu_id == CPU_TYPE_GXLX)
                                vdac_out_cntl1_bit3(1, VDAC_MODULE_DTV_DEMOD);
                        ana_ref_cntl0_bit9(1, VDAC_MODULE_DTV_DEMOD);
-                       if (is_meson_txlx_cpu()) {
+                       if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
                                udelay(5);
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
@@ -400,7 +404,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                        pri_flag |= VDAC_MODULE_DTV_DEMOD;
                } else {
                        ana_ref_cntl0_bit9(0, VDAC_MODULE_DTV_DEMOD);
-                       if (is_meson_gxlx_cpu())
+                       if (s_vdac_data->cpu_id == CPU_TYPE_GXLX)
                                vdac_out_cntl1_bit3(0, VDAC_MODULE_DTV_DEMOD);
                        pri_flag &= ~VDAC_MODULE_DTV_DEMOD;
                }
@@ -409,7 +413,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                if (on) {
                        ana_ref_cntl0_bit9(1, VDAC_MODULE_TVAFE);
                        /*after txlx need reset bandgap after bit9 enabled*/
-                       if (is_meson_txlx_cpu()) {
+                       if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
                                udelay(5);
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
@@ -436,7 +440,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                        vdac_out_cntl1_bit3(1, VDAC_MODULE_CVBS_OUT);
                        vdac_out_cntl0_bit0(1, VDAC_MODULE_CVBS_OUT);
                        ana_ref_cntl0_bit9(1, VDAC_MODULE_CVBS_OUT);
-                       if (is_meson_txlx_cpu()) {
+                       if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
                                udelay(5);
                                vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
@@ -451,8 +455,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                        pri_flag &= ~VDAC_MODULE_CVBS_OUT;
                        if (pri_flag & VDAC_MODULE_ATV_DEMOD) {
                                vdac_out_cntl1_bit3(1, VDAC_MODULE_ATV_DEMOD);
-                               if (!is_meson_g12a_cpu() &&
-                                       !is_meson_g12b_cpu())
+                               if (s_vdac_data->cpu_id < CPU_TYPE_G12AB)
                                        vdac_hiu_reg_setb(HHI_VDAC_CNTL0,
                                                0, 10, 1);
                                vdac_out_cntl0_bit0(1, VDAC_MODULE_ATV_DEMOD);
@@ -460,7 +463,7 @@ void vdac_enable(bool on, unsigned int module_sel)
                                vdac_out_cntl1_bit3(0, VDAC_MODULE_TVAFE);
                                vdac_out_cntl0_bit10(1, VDAC_MODULE_TVAFE);
                        } else if (pri_flag & VDAC_MODULE_DTV_DEMOD) {
-                               if (is_meson_gxlx_cpu())
+                               if (s_vdac_data->cpu_id == CPU_TYPE_GXLX)
                                        vdac_out_cntl1_bit3(1,
                                                        VDAC_MODULE_DTV_DEMOD);
                                ana_ref_cntl0_bit9(1, VDAC_MODULE_DTV_DEMOD);
@@ -469,10 +472,12 @@ void vdac_enable(bool on, unsigned int module_sel)
                break;
        case VDAC_MODULE_AUDIO_OUT: /* audio demod */
                /*Bandgap optimization*/
-               if (is_meson_txlx_cpu() || is_meson_txhd_cpu())
+               if (s_vdac_data->cpu_id == CPU_TYPE_TXHD ||
+                       s_vdac_data->cpu_id == CPU_TYPE_TXLX)
                        vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0xe, 3, 5);
 
-               if (is_meson_txl_cpu() || is_meson_txlx_cpu()) {
+               if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+                       s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
                        if (on)
                                ana_ref_cntl0_bit9(1, VDAC_MODULE_AUDIO_OUT);
                        else
@@ -515,14 +520,89 @@ static const struct file_operations amvdac_fops = {
        .release = amvdac_release,
 };
 
+struct meson_vdac_data meson_gxtvbb_vdac_data = {
+       .cpu_id = CPU_TYPE_GXTVBB,
+       .name = "meson-gxtvbb-vdac",
+};
+
+struct meson_vdac_data meson_gx_l_m_vdac_data = {
+       .cpu_id = CPU_TYPE_GX_L_M,
+       .name = "meson-gx_l_m-vdac",
+};
+
+struct meson_vdac_data meson_txl_vdac_data = {
+       .cpu_id = CPU_TYPE_TXL,
+       .name = "meson-txl-vdac",
+};
+
+struct meson_vdac_data meson_txlx_vdac_data = {
+       .cpu_id = CPU_TYPE_TXLX,
+       .name = "meson-txlx-vdac",
+};
+
+struct meson_vdac_data meson_gxlx_vdac_data = {
+       .cpu_id = CPU_TYPE_GXLX,
+       .name = "meson-gxlx-vdac",
+};
+
+struct meson_vdac_data meson_txhd_vdac_data = {
+       .cpu_id = CPU_TYPE_TXHD,
+       .name = "meson-txhd-vdac",
+};
+
+struct meson_vdac_data meson_g12ab_vdac_data = {
+       .cpu_id = CPU_TYPE_G12AB,
+       .name = "meson-g12ab-vdac",
+};
+
+static const struct of_device_id meson_vdac_dt_match[] = {
+       {
+               .compatible = "amlogic, vdac-gxtvbb",
+               .data           = &meson_gxtvbb_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-gxl",
+               .data           = &meson_gx_l_m_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-gxm",
+               .data           = &meson_gx_l_m_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-txl",
+               .data           = &meson_txl_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-txlx",
+               .data           = &meson_txlx_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-gxlx",
+               .data           = &meson_gxlx_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-txhd",
+               .data           = &meson_txhd_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-g12a",
+               .data           = &meson_g12ab_vdac_data,
+       }, {
+               .compatible = "amlogic, vdac-g12b",
+               .data           = &meson_g12ab_vdac_data,
+       },
+       {},
+};
+
 static int aml_vdac_probe(struct platform_device *pdev)
 {
        int ret = 0;
+       const struct of_device_id *match;
        struct amvdac_dev_s *devp = &amvdac_dev;
 
        memset(devp, 0, (sizeof(struct amvdac_dev_s)));
 
-       pr_info("\n%s: probe start\n", __func__);
+       match = of_match_device(meson_vdac_dt_match, &pdev->dev);
+       if (match == NULL) {
+               pr_err("%s,no matched table\n", __func__);
+               return -1;
+       }
+       s_vdac_data = (struct meson_vdac_data *)match->data;
+       pr_info("%s:probe start.cpu_id:%d,name:%s\n", __func__,
+               s_vdac_data->cpu_id, s_vdac_data->name);
 
        ret = alloc_chrdev_region(&devp->devno, 0, 1, AMVDAC_NAME);
        if (ret < 0)
@@ -608,19 +688,11 @@ static void amvdac_drv_shutdown(struct platform_device *pdev)
        vdac_set_ctrl0_ctrl1(cntl0, cntl1);
 }
 
-
-static const struct of_device_id aml_vdac_dt_match[] = {
-       {
-               .compatible = "amlogic, vdac",
-       },
-       {},
-};
-
 static struct platform_driver aml_vdac_driver = {
        .driver = {
                .name = "aml_vdac",
                .owner = THIS_MODULE,
-               .of_match_table = aml_vdac_dt_match,
+               .of_match_table = meson_vdac_dt_match,
        },
        .probe = aml_vdac_probe,
        .remove = __exit_p(aml_vdac_remove),
index c6fa495..21971ff 100644 (file)
 #ifndef _VDAC_DEV_H_
 #define _VDAC_DEV_H_
 
+enum vdac_cpu_type {
+       CPU_TYPE_GXTVBB = 0,
+       CPU_TYPE_GX_L_M = 1,
+       CPU_TYPE_TXL  = 2,
+       CPU_TYPE_TXLX  = 3,
+       CPU_TYPE_GXLX  = 4,
+       CPU_TYPE_TXHD = 5,
+       CPU_TYPE_G12AB = 6,
+       CPU_TYPE_TL1 = 7,
+};
+
+struct meson_vdac_data {
+       enum vdac_cpu_type cpu_id;
+       const char *name;
+};
+
 extern void vdac_set_ctrl0_ctrl1(unsigned int ctrl0, unsigned int ctrl1);
 
 #endif