cec: modify the line check for g12a
authorhongmin hua <hongmin.hua@amlogic.com>
Mon, 16 Jul 2018 06:15:50 +0000 (14:15 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 25 Jul 2018 09:10:27 +0000 (02:10 -0700)
PD#168682: cec: modify the line check for g12a

Change-Id: Id7f318caae3230df9bd6689f566524e05fd512bd
Signed-off-by: hongmin hua <hongmin.hua@amlogic.com>
27 files changed:
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/gxm_q200_2g.dts
arch/arm64/boot/dts/amlogic/gxm_q200_2g_buildroot.dts
arch/arm64/boot/dts/amlogic/gxm_q201_2g.dts
arch/arm64/boot/dts/amlogic/gxm_skt.dts
arch/arm64/boot/dts/amlogic/mesong12a.dtsi
arch/arm64/boot/dts/amlogic/mesontxl.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/cec/hdmi_ao_cec.c
drivers/amlogic/cec/hdmi_ao_cec.h

index d76282a..3b46504 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 7b61b8d..13fb0af 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 070ebe3..2c40f70 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 4cfe7e4..8f13082 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index dc2989b..149cb47 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 683c69c..c8e8b39 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index b3ffda9..b2e9b9a 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index a13bd14..770b72c 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 749f2e0..ad78b2a 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 510ecbd..b4acc1e 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 7bd2baa..c5a2755 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index b6d0bf3..aa9cce3 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 8690af2..b43d901 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index b3c7b69..bf77a30 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 80d5d13..d75ee5c 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index 343d596..03ec331 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index b98f652..0b0bf70 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        sysled {
index f561949..5e026ec 100644 (file)
                pinctrl-0=<&hdmitx_aocec>;
                reg = <0x0 0xc810023c 0x0 0x4
                       0x0 0xc8100000 0x0 0x200>;
+               reg-names = "ao_exit","ao";
        };
 
        meson-fb {
index cbd9336..2da80f4 100644 (file)
                pinctrl-1=<&eecec_b>;
                pinctrl-2=<&eecec_b>;
                reg = <0x0 0xFF80023c 0x0 0x4
-                      0x0 0xFF800000 0x0 0x400>;
+                      0x0 0xFF800000 0x0 0x400
+                      0x0 0xFF634400 0x0 0x26>;
+               reg-names = "ao_exit","ao","periphs";
        };
 
        /*if you want to use vdin just modify status to "ok"*/
index 2aeb76e..6de9a9d 100644 (file)
                       0x0 0xc8100000 0x0 0x200
                       0x0 0xda83e000 0x0 0x10
                       0x0 0xc883c000 0x0 0x400>;
+               reg-names = "ao_exit","ao","hdmirx","hhi";
        };
 
        canvas: canvas{
index a635ebe..669df5d 100644 (file)
                pinctrl-2=<&hdmitx_aocecb>;
                reg = <0x0 0xFF80023c 0x0 0x4
                       0x0 0xFF800000 0x0 0x400>;
+               reg-names = "ao_exit","ao";
        };
 
 
index 440d31c..4b1203e 100644 (file)
                pinctrl-2=<&hdmitx_aocecb>;
                reg = <0x0 0xFF80023c 0x0 0x4
                       0x0 0xFF800000 0x0 0x400>;
+               reg-names = "ao_exit","ao";
        };
 
 
index 1c5a615..f029ec4 100644 (file)
                pinctrl-2=<&hdmitx_aocecb>;
                reg = <0x0 0xFF80023c 0x0 0x4
                       0x0 0xFF800000 0x0 0x400>;
+               reg-names = "ao_exit","ao";
        };
 
 
index 62aac69..00378df 100644 (file)
                pinctrl-2=<&hdmitx_aocecb>;
                reg = <0x0 0xFF80023c 0x0 0x4
                       0x0 0xFF800000 0x0 0x400>;
+               reg-names = "ao_exit","ao";
        };
 
 
index ee73921..6ba8530 100644 (file)
                pinctrl-2=<&hdmitx_aocecb>;
                reg = <0x0 0xFF80023c 0x0 0x4
                       0x0 0xFF800000 0x0 0x400>;
+               reg-names = "ao_exit","ao";
        };
 
 
index 96df6d3..be49708 100644 (file)
@@ -87,6 +87,7 @@ static struct early_suspend aocec_suspend_handler;
 #define MAX_INT    0x7ffffff
 
 struct cec_platform_data_s {
+       unsigned char line_reg;/*cec gpio_i reg:0  ao;1 periph*/
        unsigned int line_bit;/*cec gpio position in reg*/
        bool ee_to_ao;/*ee cec hw module mv to ao;ao cec delete*/
 };
@@ -112,6 +113,7 @@ struct ao_cec_dev {
        void __iomem *cec_reg;
        void __iomem *hdmi_rxreg;
        void __iomem *hhi_reg;
+       void __iomem *periphs_reg;
        struct hdmitx_dev *tx_dev;
        struct workqueue_struct *cec_thread;
        struct device *dbg_dev;
@@ -946,7 +948,6 @@ static int cec_ll_trigle_tx(const unsigned char *msg, int len)
                return 0;
        }
        CEC_ERR("error msg sts:0x%x\n", reg);
-
        return -1;
 }
 
@@ -989,7 +990,10 @@ static int get_line(void)
 {
        int reg, ret = -EINVAL;
 
-       reg = readl(cec_dev->cec_reg + AO_GPIO_I);
+       if (cec_dev->plat_data->line_reg == 1)
+               reg = readl(cec_dev->periphs_reg + PREG_PAD_GPIO3_I);
+       else
+               reg = readl(cec_dev->cec_reg + AO_GPIO_I);
        ret = (reg & (1 << cec_dev->plat_data->line_bit));
 
        return ret;
@@ -1375,7 +1379,6 @@ static int cec_late_check_rx_buffer(void)
                cec_rx_buf_clear();
                return 0;
        }
-
        return 1;
 }
 
@@ -1895,7 +1898,6 @@ static ssize_t port_status_show(struct class *cla,
                tmp = tx_hpd;
                return sprintf(buf, "%x\n", tmp);
        }
-
        tmp = hdmirx_rd_top(TOP_HPD_PWR5V);
        CEC_INFO("TOP_HPD_PWR5V:%x\n", tmp);
        tmp >>= 20;
@@ -2512,21 +2514,25 @@ static void aocec_late_resume(struct early_suspend *h)
 
 #ifdef CONFIG_OF
 static const struct cec_platform_data_s cec_gxl_data = {
+       .line_reg = 0,
        .line_bit = 8,
        .ee_to_ao = 0,
 };
 
 static const struct cec_platform_data_s cec_txlx_data = {
+       .line_reg = 0,
        .line_bit = 7,
        .ee_to_ao = 1,
 };
 
 static const struct cec_platform_data_s cec_g12a_data = {
-       .line_bit = 7,
+       .line_reg = 1,
+       .line_bit = 3,
        .ee_to_ao = 1,
 };
 
 static const struct cec_platform_data_s cec_txl_data = {
+       .line_reg = 0,
        .line_bit = 7,
        .ee_to_ao = 0,
 };
@@ -2691,39 +2697,63 @@ static int aml_cec_probe(struct platform_device *pdev)
                if (ret > 0)
                        CEC_ERR("select state error:0x%x\n", ret);
        }
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ao_exit");
        if (res) {
-               base = ioremap(res->start, res->end - res->start);
+               base = devm_ioremap(&pdev->dev, res->start,
+                                               res->end - res->start);
+               if (!base) {
+                       CEC_ERR("Unable to map ao_exit base\n");
+                       goto tag_cec_reg_map_err;
+               }
                cec_dev->exit_reg = (void *)base;
-       } else {
-               CEC_INFO("no memory resource\n");
-               cec_dev->exit_reg = NULL;
-       }
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+       } else
+               CEC_ERR("no ao_exit regs\n")
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ao");
        if (res) {
-               base = ioremap(res->start, res->end - res->start);
+               base = devm_ioremap(&pdev->dev, res->start,
+                                               res->end - res->start);
+               if (!base) {
+                       CEC_ERR("Unable to map ao base\n");
+                       goto tag_cec_reg_map_err;
+               }
                cec_dev->cec_reg = (void *)base;
        } else {
-               CEC_ERR("no CEC reg resource\n");
-               cec_dev->cec_reg = NULL;
+               CEC_ERR("no ao regs\n");
+               goto tag_cec_reg_map_err;
        }
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmirx");
        if (res) {
-               base = ioremap(res->start, res->end - res->start);
+               base = devm_ioremap(&pdev->dev, res->start,
+                                               res->end - res->start);
+               if (!base) {
+                       CEC_ERR("Unable to map hdmirx base\n");
+                       goto tag_cec_reg_map_err;
+               }
                cec_dev->hdmi_rxreg = (void *)base;
-       } else {
-               CEC_ERR("no hdmirx reg resource\n");
-               cec_dev->hdmi_rxreg = NULL;
-       }
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+       } else
+               CEC_ERR("no hdmirx regs\n")
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi");
        if (res) {
-               base = ioremap(res->start, res->end - res->start);
+               base = devm_ioremap(&pdev->dev, res->start,
+                                               res->end - res->start);
+               if (!base) {
+                       CEC_ERR("Unable to map hhi base\n");
+                       goto tag_cec_reg_map_err;
+               }
                cec_dev->hhi_reg = (void *)base;
-       } else {
-               CEC_ERR("no hhi reg resource\n");
-               cec_dev->hhi_reg = NULL;
-       }
+       } else
+               CEC_ERR("no hhi regs\n")
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "periphs");
+       if (res) {
+               base = devm_ioremap(&pdev->dev, res->start,
+                                               res->end - res->start);
+               if (!base) {
+                       CEC_ERR("Unable to map periphs base\n");
+                       goto tag_cec_reg_map_err;
+               }
+               cec_dev->periphs_reg = (void *)base;
+       } else
+               CEC_ERR("no periphs regs\n")
        r = of_property_read_u32(node, "port_num", &(cec_dev->port_num));
        if (r) {
                CEC_ERR("not find 'port_num'\n");
@@ -2822,6 +2852,8 @@ static int aml_cec_probe(struct platform_device *pdev)
        return 0;
 
 tag_cec_msg_alloc_err:
+               free_irq(cec_dev->irq_cec, (void *)cec_dev);
+tag_cec_reg_map_err:
                input_free_device(cec_dev->cec_info.remote_cec_dev);
 tag_cec_alloc_input_err:
                destroy_workqueue(cec_dev->cec_thread);
index f54c1b1..4d94c84 100644 (file)
@@ -39,6 +39,8 @@
 #define AO_BASE                                0xc8100000
 
 #define AO_GPIO_I                      ((0x0A << 2))
+#define PREG_PAD_GPIO3_I       (0x01b << 2)
+
 
 #define AO_CEC_GEN_CNTL                        ((0x40 << 2))
 #define AO_CEC_RW_REG                  ((0x41 << 2))