From afb6155bebbf861300163fe4a7d08856f2118078 Mon Sep 17 00:00:00 2001 From: Tao Zeng Date: Thu, 27 Apr 2017 16:46:02 +0800 Subject: [PATCH] PD#138714: cec: add wakeup source for cec driver use kernel wake up api for cec driver Change-Id: I181bf0adcd14d20b71ef2a10bb169f131e6bec5d Signed-off-by: Tao Zeng --- drivers/amlogic/cec/hdmi_ao_cec.c | 16 ++++++++++------ drivers/amlogic/cec/m8_ao_cec.c | 9 +++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 546e21fc10a1..adc05db3ba49 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -55,8 +55,9 @@ #include #include #include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND #include - +#endif #include #include #include @@ -1079,6 +1080,7 @@ static void cec_key_report(int suspend) input_sync(cec_dev->remote_cec_dev); input_event(cec_dev->remote_cec_dev, EV_KEY, KEY_POWER, 0); input_sync(cec_dev->remote_cec_dev); + pm_wakeup_event(cec_dev->dbg_dev, 2000); if (!suspend) CEC_INFO("== WAKE UP BY CEC ==\n") else @@ -2262,6 +2264,7 @@ static int aml_cec_probe(struct platform_device *pdev) aocec_suspend_handler.param = cec_dev; register_early_suspend(&aocec_suspend_handler); #endif + device_init_wakeup(cec_dev->dbg_dev, 1); hrtimer_init(&cec_dev->start_bit_check, CLOCK_MONOTONIC, HRTIMER_MODE_REL); @@ -2312,12 +2315,13 @@ static void aml_cec_pm_complete(struct device *dev) cec_key_report(0); } -static int aml_cec_suspend_noirq(struct device *dev) +static int aml_cec_suspend_late(struct device *dev) { struct pinctrl *p; struct pinctrl_state *s; int ret; + CEC_INFO("%s!\n", __func__); if (cec_dev->ee_cec) { p = devm_pinctrl_get(cec_dev->dbg_dev); if (IS_ERR(p)) @@ -2332,11 +2336,11 @@ static int aml_cec_suspend_noirq(struct device *dev) return 0; } -static int aml_cec_resume_noirq(struct device *dev) +static int aml_cec_resume_early(struct device *dev) { struct pinctrl *p; - CEC_INFO("cec resume noirq!\n"); + CEC_INFO("%s!\n", __func__); cec_dev->power_status = TRANS_STANDBY_TO_ON; /* reselect pin mux if resume */ @@ -2351,8 +2355,8 @@ static int aml_cec_resume_noirq(struct device *dev) static const struct dev_pm_ops aml_cec_pm = { .prepare = aml_cec_pm_prepare, .complete = aml_cec_pm_complete, - .suspend_noirq = aml_cec_suspend_noirq, - .resume_noirq = aml_cec_resume_noirq, + .suspend_late = aml_cec_suspend_late, + .resume_early = aml_cec_resume_early, }; #endif diff --git a/drivers/amlogic/cec/m8_ao_cec.c b/drivers/amlogic/cec/m8_ao_cec.c index 7f1e27df2ca2..a20311ded48d 100644 --- a/drivers/amlogic/cec/m8_ao_cec.c +++ b/drivers/amlogic/cec/m8_ao_cec.c @@ -136,9 +136,6 @@ struct ao_cec_dev { spinlock_t cec_reg_lock; struct mutex cec_mutex; struct hrtimer start_bit_check; -#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND - struct early_suspend aocec_suspend_handler; -#endif }; static struct ao_cec_dev *cec_dev; @@ -590,7 +587,7 @@ int cec_ll_tx(const unsigned char *msg, unsigned char len) mutex_lock(&cec_dev->cec_mutex); /* make sure physical address is valid before send */ if (len >= 2 && msg[1] == CEC_OC_REPORT_PHYSICAL_ADDRESS) - check_physical_addr_valid(MAX_INT); + check_physical_addr_valid(20); try_again: reinit_completion(&cec_dev->tx_ok); @@ -749,6 +746,7 @@ static void cec_key_report(int suspend) input_sync(cec_dev->remote_cec_dev); input_event(cec_dev->remote_cec_dev, EV_KEY, KEY_POWER, 0); input_sync(cec_dev->remote_cec_dev); + pm_wakeup_event(cec_dev->dbg_dev, 2000); if (!suspend) CEC_INFO("== WAKE UP BY CEC ==\n") else @@ -1720,6 +1718,7 @@ static const struct file_operations hdmitx_cec_fops = { /************************ cec high level code *****************************/ #ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +struct early_suspend aocec_suspend_handler; static void aocec_early_suspend(struct early_suspend *h) { cec_dev->cec_suspend = CEC_EARLY_SUSPEND; @@ -1894,6 +1893,8 @@ static int aml_cec_probe(struct platform_device *pdev) aocec_suspend_handler.param = cec_dev; register_early_suspend(&aocec_suspend_handler); #endif + device_init_wakeup(cec_dev->dbg_dev, 1); + hrtimer_init(&cec_dev->start_bit_check, CLOCK_MONOTONIC, HRTIMER_MODE_REL); cec_dev->start_bit_check.function = cec_line_check;