From c84c9569e879e5e0d8b336e11233cdade10e2496 Mon Sep 17 00:00:00 2001 From: Yong Qin Date: Wed, 8 Aug 2018 15:23:00 +0800 Subject: [PATCH] cec: otp: support one touch play and enter source 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 --- drivers/amlogic/cec/hdmi_ao_cec.c | 24 +++++++++++-- drivers/amlogic/mailbox/scpi_protocol.c | 60 +++++++++++++++++++++++++++++++++ include/linux/amlogic/scpi_protocol.h | 7 ++++ 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 7ff6b77..7640f44 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -57,6 +57,7 @@ #include #include #include +#include #ifdef CONFIG_HAS_EARLYSUSPEND #include @@ -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)) diff --git a/drivers/amlogic/mailbox/scpi_protocol.c b/drivers/amlogic/mailbox/scpi_protocol.c index 8ed94a3..f8592ad 100644 --- a/drivers/amlogic/mailbox/scpi_protocol.c +++ b/drivers/amlogic/mailbox/scpi_protocol.c @@ -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); + diff --git a/include/linux/amlogic/scpi_protocol.h b/include/linux/amlogic/scpi_protocol.h index 806689d..c0c9de6 100644 --- a/include/linux/amlogic/scpi_protocol.h +++ b/include/linux/amlogic/scpi_protocol.h @@ -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_*/ -- 2.7.4