cec: otp: support one touch play and enter source
authorYong Qin <yong.qin@amlogic.com>
Wed, 8 Aug 2018 07:23:00 +0000 (15:23 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Fri, 10 Aug 2018 08:36:28 +0000 (01:36 -0700)
PD#170723: cec: support otp and enter source

1.get wakeup reason from stick register
2.add get wakeup reason from wakeup

Change-Id: Idb0e56980569d3092fde971c0dcb73a4684bff0b
Signed-off-by: Yong Qin <yong.qin@amlogic.com>
drivers/amlogic/cec/hdmi_ao_cec.c
drivers/amlogic/mailbox/scpi_protocol.c
include/linux/amlogic/scpi_protocol.h

index 7ff6b77bddf53191722601d2379183245f6f20b8..7640f44f4913e757c2e9e152a020b936229c5647 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/amlogic/pm.h>
 #include <linux/amlogic/cpu_version.h>
 #include <linux/amlogic/jtag.h>
+#include <linux/amlogic/scpi_protocol.h>
 
 #ifdef CONFIG_HAS_EARLYSUSPEND
 #include <linux/earlysuspend.h>
@@ -2965,8 +2966,13 @@ static int aml_cec_probe(struct platform_device *pdev)
        /* default enable all function*/
        cec_config(CEC_FUNC_CFG_ALL, 1);
        queue_delayed_work(cec_dev->cec_thread, &cec_dev->cec_work, 0);
-       CEC_ERR("boot:%#x;%#x\n", *((unsigned int *)&cec_dev->wakup_data),
-                                               cec_dev->wakeup_reason);
+       scpi_get_wakeup_reason(&cec_dev->wakeup_reason);
+       CEC_ERR("wakeup_reason:0x%x\n", cec_dev->wakeup_reason);
+       scpi_get_cec_val(SCPI_CMD_GET_CEC1,
+                               (unsigned int *)&cec_dev->wakup_data);
+       scpi_get_cec_val(SCPI_CMD_GET_CEC2, &r);
+       CEC_ERR("cev val1: %#x;val2: %#x\n",
+                       *((unsigned int *)&cec_dev->wakup_data), r);
        CEC_ERR("%s success end\n", __func__);
        return 0;
 
@@ -3041,8 +3047,22 @@ static int aml_cec_suspend_noirq(struct device *dev)
 static int aml_cec_resume_noirq(struct device *dev)
 {
        int ret = 0;
+       unsigned int temp;
 
        CEC_INFO("cec resume noirq!\n");
+
+       cec_dev->cec_info.power_status = TRANS_STANDBY_TO_ON;
+
+       scpi_get_wakeup_reason(&cec_dev->wakeup_reason);
+       CEC_ERR("wakeup_reason:0x%x\n", cec_dev->wakeup_reason);
+
+       scpi_get_cec_val(SCPI_CMD_GET_CEC1,
+                               (unsigned int *)&cec_dev->wakup_data);
+       scpi_get_cec_val(SCPI_CMD_GET_CEC2, &temp);
+       CEC_ERR("cev val1: %#x;val2: %#x\n",
+                                       *((unsigned int *)&cec_dev->wakup_data),
+                                               temp);
+
        cec_dev->cec_info.power_status = TRANS_STANDBY_TO_ON;
        cec_dev->cec_suspend = CEC_POWER_RESUME;
        if (!IS_ERR(cec_dev->dbg_dev->pins->default_state))
index 8ed94a3d8c2aafd04907a887a34aaf29787dc9b2..f8592adedb27933e0739fd4648a05a7f83b63533 100644 (file)
@@ -82,6 +82,8 @@ static int high_priority_cmds[] = {
        SCPI_CMD_GET_PSU,
        SCPI_CMD_SENSOR_CFG_PERIODIC,
        SCPI_CMD_SENSOR_CFG_BOUNDS,
+       SCPI_CMD_WAKEUP_REASON_GET,
+       SCPI_CMD_WAKEUP_REASON_CLR,
 };
 
 static struct scpi_dvfs_info *scpi_opps[MAX_DVFS_DOMAINS];
@@ -481,3 +483,61 @@ int scpi_get_ring_value(unsigned char *val)
        return ret;
 }
 EXPORT_SYMBOL_GPL(scpi_get_ring_value);
+
+int scpi_get_wakeup_reason(u32 *wakeup_reason)
+{
+       struct scpi_data_buf sdata;
+       struct mhu_data_buf mdata;
+       u32 temp = 0;
+       struct __packed {
+               u32 status;
+               u32 reason;
+       } buf;
+
+       SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_NONE,
+                       SCPI_CMD_WAKEUP_REASON_GET, temp, buf);
+       if (scpi_execute_cmd(&sdata))
+               return -EPERM;
+
+       *wakeup_reason = buf.reason;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(scpi_get_wakeup_reason);
+
+int scpi_clr_wakeup_reason(void)
+{
+       struct scpi_data_buf sdata;
+       struct mhu_data_buf mdata;
+       u32 temp = 0, state;
+
+       SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_NONE,
+                       SCPI_CMD_WAKEUP_REASON_CLR, temp, state);
+       if (scpi_execute_cmd(&sdata))
+               return -EPERM;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(scpi_clr_wakeup_reason);
+
+int scpi_get_cec_val(enum scpi_std_cmd index, u32 *p_cec)
+{
+       struct scpi_data_buf sdata;
+       struct mhu_data_buf mdata;
+       u32 temp = 0;
+       struct __packed {
+               u32 status;
+               u32 cec_val;
+       } buf;
+
+       SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_NONE,
+                       index, temp, buf);
+       if (scpi_execute_cmd(&sdata))
+               return -EPERM;
+
+       *p_cec = buf.cec_val;
+       return 0;
+
+}
+EXPORT_SYMBOL_GPL(scpi_get_cec_val);
+
index 806689db153b54d2d86721633163d68274ab2680..c0c9de6b9583f4e564e26c29b980372b67fee052 100644 (file)
@@ -65,6 +65,10 @@ enum scpi_std_cmd {
        SCPI_CMD_SENSOR_ASYNC_VALUE     = 0x1f,
        SCPI_CMD_SET_USR_DATA = 0x20,
        SCPI_CMD_OSCRING_VALUE = 0x43,
+       SCPI_CMD_WAKEUP_REASON_GET = 0x30,
+       SCPI_CMD_WAKEUP_REASON_CLR = 0X31,
+       SCPI_CMD_GET_CEC1               = 0xB4,
+       SCPI_CMD_GET_CEC2               = 0xB5,
        SCPI_CMD_COUNT
 };
 
@@ -91,4 +95,7 @@ int scpi_send_usr_data(u32 client_id, u32 *val, u32 size);
 int scpi_get_vrtc(u32 *p_vrtc);
 int scpi_set_vrtc(u32 vrtc_val);
 int scpi_get_ring_value(unsigned char *val);
+int scpi_get_wakeup_reason(u32 *wakeup_reason);
+int scpi_clr_wakeup_reason(void);
+int scpi_get_cec_val(enum scpi_std_cmd index, u32 *p_cec);
 #endif /*_SCPI_PROTOCOL_H_*/