cec: Add Feature for freeze mode power on [2/2]
authorYong Qin <yong.qin@amlogic.com>
Sun, 29 Sep 2019 01:44:16 +0000 (09:44 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 16 Oct 2019 02:56:09 +0000 (19:56 -0700)
PD#TV-10483

Problem:
Add feature for freeze mode power on by cec.

Solution:
Add feature for freeze mode power on by cec.

Verify:
tl1

Change-Id: I5be3d672f71a30ed4a7ab445de616023946596ff
Signed-off-by: Yong Qin <yong.qin@amlogic.com>
drivers/amlogic/cec/hdmi_ao_cec.c
drivers/amlogic/cec/hdmi_ao_cec.h

index 681c65fe9e438735ac2ddd658f9dfd558f75ce8d..e31eff17f13f936e703c22c75118c71244674461 100644 (file)
@@ -545,10 +545,14 @@ static int cecb_pick_msg(unsigned char *msg, unsigned char *out_len)
        /* clr CEC lock bit */
        hdmirx_cec_write(DWC_CEC_LOCK, 0);
        CEC_INFO("%s", msg_log_buf);
-       if (cec_message_op(msg, len))
+       if (is_pm_freeze_mode()) {
                *out_len = len;
-       else
-               *out_len = 0;
+       } else {
+               if (cec_message_op(msg, len))
+                       *out_len = len;
+               else
+                       *out_len = 0;
+       }
        pin_status = 1;
        return 0;
 }
@@ -581,8 +585,6 @@ void cecb_irq_handle(void)
                complete(&cec_dev->rx_ok);
                new_msg = 1;
                dwork = &cec_dev->cec_work;
-               if (is_pm_freeze_mode())
-                       cec_freeze_mode_process();
                mod_delayed_work(cec_dev->cec_thread, dwork, 0);
        }
 
@@ -1867,6 +1869,11 @@ static int cec_late_check_rx_buffer(void)
 
 void cec_key_report(int suspend)
 {
+       if (!(cec_config(0, 0) & CEC_FUNC_CFG_AUTO_POWER_ON)) {
+               CEC_ERR("auto pw on is off (cfg:0x%x)\n", cec_config(0, 0));
+               return;
+       }
+
        if (is_pm_freeze_mode()) {
                pm_wakeup_event(cec_dev->dbg_dev, 2000);
                CEC_INFO("freeze mode:pm_wakeup_event\n");
@@ -2184,39 +2191,50 @@ static void cec_save_pre_setting(void)
        CEC_ERR("%s: logaddr:0x%x, devtype:0x%x\n", __func__,
                cec_dev->cec_info.log_addr,
                config_data = cec_dev->dev_type);
+       cec_set_reg_bits(AO_DEBUG_REG1, cec_dev->phy_addr, 0, 8);
 }
 
 static void cec_restore_pre_setting(void)
 {
        unsigned int logaddr;
        unsigned int devtype;
-       unsigned int config_data;
+       unsigned int cec_cfg;
+       unsigned int data32;
        char *token;
 
-       config_data = cec_config(0, 0);
+       cec_msg_dbg_en = 1;
+       cec_cfg = cec_config(0, 0);
        /*get device type*/
-       logaddr = (config_data >> 16) & 0xf;
-       devtype = (config_data >> 20) & 0xf;
+       /* AO_DEBUG_REG1+
+        * 0-15 : phy addr+
+        * 16-20: logical address+
+        * 21-23: device type+
+        */
+        data32 = readl(cec_dev->cec_reg + AO_DEBUG_REG1);
+        logaddr = (data32 >> 16) & 0xf;
+        devtype = (data32 >> 20) & 0xf;
+
        /*get logical address*/
        if (cec_dev->cec_num > ENABLE_ONE_CEC)
                cec_logicaddr_add(CEC_B, logaddr);
        else
                cec_logicaddr_add(ee_cec, logaddr);
        cec_dev->cec_info.addr_enable |= (1 << logaddr);
-
        /* add by hal, to init some data structure */
        cec_dev->dev_type = devtype;
        cec_dev->cec_info.log_addr = logaddr;
        cec_dev->cec_info.vendor_id = cec_dev->v_data.vendor_id;
-       CEC_ERR("%s: logaddr:0x%x, devtype:0x%x\n", __func__,
+       cec_dev->phy_addr = data32 & 0xffff;
+
+       CEC_ERR("%s: logaddr:0x%x, devtype:%d\n", __func__,
                cec_dev->cec_info.log_addr,
-               config_data = cec_dev->dev_type);
+               (unsigned int)cec_dev->dev_type);
 
        /*suspend freeze mode, driver handle cec msg*/
        cec_dev->hal_flag &= ~(1 << HDMI_OPTION_SERVICE_FLAG);
-       if (cec_msg_dbg_en) {
-               cec_status();
-               token = kmalloc(2048, GFP_KERNEL);
+
+       token = kmalloc(2048, GFP_KERNEL);
+       if (token) {
                dump_cecrx_reg(token);
                CEC_ERR("%s\n", token);
                kfree(token);
@@ -2231,7 +2249,7 @@ static void cec_task(struct work_struct *work)
        cec_cfg = cec_config(0, 0);
        if (cec_cfg & CEC_FUNC_CFG_CEC_ON) {
                /*cec module on*/
-               if (cec_dev && (/*!wake_ok || */cec_service_suspended()))
+               if ((cec_dev && cec_service_suspended()) || is_pm_freeze_mode())
                        cec_rx_process();
 
                /*for check rx buffer for old chip version, cec rx irq process*/
@@ -2249,16 +2267,6 @@ static void cec_task(struct work_struct *work)
        queue_delayed_work(cec_dev->cec_thread, dwork, CEC_FRAME_DELAY);
 }
 
-void cec_freeze_mode_process(void)
-{
-       unsigned int cec_cfg;
-
-       CEC_ERR("%s\n", __func__);
-       cec_cfg = cec_config(0, 0);
-       if (cec_cfg & CEC_FUNC_CFG_CEC_ON)
-               cec_rx_process();
-}
-
 static void ceca_tasklet_pro(unsigned long arg)
 {
        unsigned int intr_stat = 0;
index e297fb9b76c95c95350ad150b66cec29ef06a829..e838fbf37730c42264868c45b125aa45db85b95e 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __AO_CEC_H__
 #define __AO_CEC_H__
 
-#define CEC_DRIVER_VERSION     "2019/10/11:add freeze mode wake up func-1\n"
+#define CEC_DRIVER_VERSION     "2019/10/11:add freeze mode wake up func-2\n"
 
 #define CEC_FRAME_DELAY                msecs_to_jiffies(400)
 #define CEC_DEV_NAME           "cec"
@@ -577,6 +577,5 @@ extern void cec_logicaddr_add(unsigned int cec_sel, unsigned int l_add);
 extern void cec_clear_all_logical_addr(unsigned int cec_sel);
 extern int dump_cecrx_reg(char *b);
 extern void cec_ip_share_io(u32 share, u32 cec_ip);
-void cec_freeze_mode_process(void);
 
 #endif /* __AO_CEC_H__ */