From c459e072c62b22f7bb39632958a366ab1b08d84a Mon Sep 17 00:00:00 2001 From: Qiufang Dai Date: Wed, 26 Apr 2017 16:06:03 +0800 Subject: [PATCH] PM / sleep: Re-implement legacy early_suspend. PD#138714: Re-implement legacy early_suspend for Amlogic driver. 1. re-implement early_suspend mechanism for legacy early_suspend driver code. The early_suspend/late_resume can be trigger via cmd: echo 1/0 > /sys/power/eary_suspend_trigger 2. Register wakeup source and report wakeup event for Remoute KEY_POWER Change-Id: I07ba9861aa0c0c1126238e84248948f7707e9ae2 Signed-off-by: Qiufang Dai --- arch/arm64/configs/meson64_defconfig | 1 + drivers/amlogic/bluetooth/bt_device.c | 8 +- drivers/amlogic/cec/hdmi_ao_cec.c | 18 ++-- drivers/amlogic/cec/m8_ao_cec.c | 10 +- drivers/amlogic/input/keyboard/adc_keypad.c | 12 +-- drivers/amlogic/input/remote/remote_core.c | 2 + drivers/amlogic/input/remote/remote_meson.c | 27 +++-- drivers/amlogic/media/osd/osd_fb.c | 16 +-- drivers/amlogic/media/osd_ext/osd_fb.c | 16 +-- .../media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c | 6 +- drivers/amlogic/media/vout/vout_serve/vout_serve.c | 16 +-- drivers/amlogic/pm/Kconfig | 11 ++ drivers/amlogic/pm/gx_pm.c | 115 ++++++++++++++++++++- drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c | 7 +- drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.h | 6 +- .../amlogic/usb/dwc_otg/310/dwc_otg_pcd_linux.c | 4 +- include/linux/amlogic/pm.h | 30 ++++-- 17 files changed, 229 insertions(+), 76 deletions(-) diff --git a/arch/arm64/configs/meson64_defconfig b/arch/arm64/configs/meson64_defconfig index da768ef..d884949 100644 --- a/arch/arm64/configs/meson64_defconfig +++ b/arch/arm64/configs/meson64_defconfig @@ -243,6 +243,7 @@ CONFIG_AMLOGIC_GPU_THERMAL=y CONFIG_AMLOGIC_GPUCORE_THERMAL=y CONFIG_AMLOGIC_AUDIO_DSP=y CONFIG_AMLOGIC_GX_SUSPEND=y +CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND=y CONFIG_AMLOGIC_LED=y CONFIG_AMLOGIC_LED_SYS=y CONFIG_AMLOGIC_JTAG=y diff --git a/drivers/amlogic/bluetooth/bt_device.c b/drivers/amlogic/bluetooth/bt_device.c index 42d2e8f..e9d8f30 100644 --- a/drivers/amlogic/bluetooth/bt_device.c +++ b/drivers/amlogic/bluetooth/bt_device.c @@ -37,8 +37,8 @@ #endif #include "../../gpio/gpiolib.h" -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include static struct early_suspend bt_early_suspend; #endif @@ -158,7 +158,7 @@ static int bt_set_block(void *data, bool blocked) static const struct rfkill_ops bt_rfkill_ops = { .set_block = bt_set_block, }; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void bt_earlysuspend(struct early_suspend *h) { @@ -269,7 +269,7 @@ static int bt_probe(struct platform_device *pdev) prdata->bt_rfk = bt_rfk; prdata->pdata = pdata; platform_set_drvdata(pdev, prdata); -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND bt_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; bt_early_suspend.suspend = bt_earlysuspend; diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 953ca36..546e21f 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -55,9 +55,8 @@ #include #include #include -#ifdef CONFIG_HAS_EARLYSUSPEND -#include -#endif +#include + #include #include #include @@ -142,9 +141,6 @@ struct ao_cec_dev { spinlock_t cec_reg_lock; struct mutex cec_mutex; struct hrtimer start_bit_check; -#ifdef CONFIG_HAS_EARLYSUSPEND - struct early_suspend aocec_suspend_handler; -#endif }; static struct ao_cec_dev *cec_dev; @@ -2056,7 +2052,8 @@ static const struct file_operations hdmitx_cec_fops = { }; /************************ cec high level code *****************************/ -#ifdef CONFIG_HAS_EARLYSUSPEND +#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; @@ -2067,9 +2064,9 @@ static void aocec_late_resume(struct early_suspend *h) { cec_dev->cec_suspend = 0; CEC_INFO("%s, suspend:%d\n", __func__, cec_dev->cec_suspend); - } -#endif + +#endif //CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static int aml_cec_probe(struct platform_device *pdev) { @@ -2258,13 +2255,14 @@ static int aml_cec_probe(struct platform_device *pdev) } #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND aocec_suspend_handler.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 20; aocec_suspend_handler.suspend = aocec_early_suspend; aocec_suspend_handler.resume = aocec_late_resume; aocec_suspend_handler.param = cec_dev; register_early_suspend(&aocec_suspend_handler); #endif + hrtimer_init(&cec_dev->start_bit_check, CLOCK_MONOTONIC, HRTIMER_MODE_REL); cec_dev->start_bit_check.function = cec_line_check; diff --git a/drivers/amlogic/cec/m8_ao_cec.c b/drivers/amlogic/cec/m8_ao_cec.c index 0e231d5..b0a7c2c 100644 --- a/drivers/amlogic/cec/m8_ao_cec.c +++ b/drivers/amlogic/cec/m8_ao_cec.c @@ -55,8 +55,8 @@ #include #include #include -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include #endif #include #include @@ -136,7 +136,7 @@ struct ao_cec_dev { spinlock_t cec_reg_lock; struct mutex cec_mutex; struct hrtimer start_bit_check; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND struct early_suspend aocec_suspend_handler; #endif }; @@ -1719,7 +1719,7 @@ static const struct file_operations hdmitx_cec_fops = { }; /************************ cec high level code *****************************/ -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void aocec_early_suspend(struct early_suspend *h) { cec_dev->cec_suspend = CEC_EARLY_SUSPEND; @@ -1887,7 +1887,7 @@ static __init int aml_cec_probe(struct platform_device *pdev) } #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND aocec_suspend_handler.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 20; aocec_suspend_handler.suspend = aocec_early_suspend; aocec_suspend_handler.resume = aocec_late_resume; diff --git a/drivers/amlogic/input/keyboard/adc_keypad.c b/drivers/amlogic/input/keyboard/adc_keypad.c index 6590caa..da73e02 100644 --- a/drivers/amlogic/input/keyboard/adc_keypad.c +++ b/drivers/amlogic/input/keyboard/adc_keypad.c @@ -35,8 +35,8 @@ #include #include #include -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include #endif #define POLL_PERIOD_WHEN_KEY_DOWN 10 /* unit msec */ @@ -59,7 +59,7 @@ struct kp { struct adc_key *key; int key_num; struct work_struct work_update; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND struct early_suspend early_suspend; #endif }; @@ -184,7 +184,7 @@ static int register_keypad_dev(struct kp *kp) return ret; } -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void kp_early_suspend(struct early_suspend *h) { struct kp *kp = container_of(h, struct kp, early_suspend); @@ -411,7 +411,7 @@ static int kp_probe(struct platform_device *pdev) } register_keypad_dev(gp_kp); kfree(key_param); - #ifdef CONFIG_HAS_EARLYSUSPEND + #ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND kp->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN; kp->early_suspend.suspend = kp_early_suspend; kp->early_suspend.resume = kp_late_resume; @@ -434,7 +434,7 @@ static int kp_remove(struct platform_device *pdev) struct adc_kp_platform_data *pdata = platform_get_drvdata(pdev); struct kp *kp = gp_kp; - #ifdef CONFIG_HAS_EARLYSUSPEND + #ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND unregister_early_suspend(&kp->early_suspend); #endif del_timer_sync(&kp->timer); diff --git a/drivers/amlogic/input/remote/remote_core.c b/drivers/amlogic/input/remote/remote_core.c index 3f20f48..42d3dda 100644 --- a/drivers/amlogic/input/remote/remote_core.c +++ b/drivers/amlogic/input/remote/remote_core.c @@ -127,6 +127,8 @@ void remote_keydown(struct remote_dev *dev, int scancode, int status) spin_lock_irqsave(&dev->keylock, flags); if (status == REMOTE_NORMAL) { keycode = dev->getkeycode(dev, scancode); + if (keycode == KEY_POWER) + pm_wakeup_event(dev->dev, 2000); ir_do_keydown(dev, scancode, keycode); } diff --git a/drivers/amlogic/input/remote/remote_meson.c b/drivers/amlogic/input/remote/remote_meson.c index fa37f34..32b7eb2 100644 --- a/drivers/amlogic/input/remote/remote_meson.c +++ b/drivers/amlogic/input/remote/remote_meson.c @@ -43,6 +43,7 @@ #include "remote_meson.h" #include +#include static void amlremote_tasklet(unsigned long data); @@ -563,6 +564,8 @@ static int remote_probe(struct platform_device *pdev) if (ret) goto error_register_remote; + device_init_wakeup(&pdev->dev, 1); + return 0; error_register_remote: @@ -593,14 +596,14 @@ static int remote_remove(struct platform_device *pdev) return 0; } -static int remote_resume(struct platform_device *pdev) +static int remote_resume(struct device *dev) { - struct remote_chip *chip = platform_get_drvdata(pdev); + struct remote_chip *chip = dev_get_drvdata(dev); unsigned int val; unsigned long flags; unsigned char cnt; - dev_info(chip->dev, "remote resume\n"); + dev_info(dev, "remote resume\n"); /*resume register config*/ spin_lock_irqsave(&chip->slock, flags); chip->set_register_config(chip, chip->protocol); @@ -634,11 +637,11 @@ static int remote_resume(struct platform_device *pdev) return 0; } -static int remote_suspend(struct platform_device *pdev, pm_message_t state) +static int remote_suspend(struct device *dev) { - struct remote_chip *chip = platform_get_drvdata(pdev); + struct remote_chip *chip = dev_get_drvdata(dev); - dev_info(chip->dev, "remote suspend\n"); + dev_info(dev, "remote suspend\n"); disable_irq(chip->irqno); return 0; } @@ -650,14 +653,22 @@ static const struct of_device_id remote_dt_match[] = { {}, }; +#ifdef CONFIG_PM +static const struct dev_pm_ops remote_pm_ops = { + .suspend_late = remote_suspend, + .resume_early = remote_resume, +}; +#endif + static struct platform_driver remote_driver = { .probe = remote_probe, .remove = remote_remove, - .suspend = remote_suspend, - .resume = remote_resume, .driver = { .name = DRIVER_NAME, .of_match_table = remote_dt_match, +#ifdef CONFIG_PM + .pm = &remote_pm_ops, +#endif }, }; diff --git a/drivers/amlogic/media/osd/osd_fb.c b/drivers/amlogic/media/osd/osd_fb.c index 23e293e..b51d8d1 100644 --- a/drivers/amlogic/media/osd/osd_fb.c +++ b/drivers/amlogic/media/osd/osd_fb.c @@ -279,8 +279,8 @@ static struct fb_fix_screeninfo fb_def_fix = { .accel = FB_ACCEL_NONE, }; -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include static struct early_suspend early_suspend; static int early_suspend_flag; #endif @@ -2271,7 +2271,7 @@ static struct device_attribute osd_attrs[] = { #ifdef CONFIG_PM static int osd_suspend(struct platform_device *dev, pm_message_t state) { -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND if (early_suspend_flag) return 0; #endif @@ -2287,7 +2287,7 @@ static int osd_resume(struct platform_device *dev) return 0; } #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND if (early_suspend_flag) return 0; #endif @@ -2296,7 +2296,7 @@ static int osd_resume(struct platform_device *dev) } #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void osd_early_suspend(struct early_suspend *h) { if (early_suspend_flag) @@ -2317,7 +2317,7 @@ static void osd_late_resume(struct early_suspend *h) #ifdef CONFIG_SCREEN_ON_EARLY void osd_resume_early(void) { -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND osd_resume_hw(); early_suspend_flag = 0; #endif @@ -2558,7 +2558,7 @@ static int osd_probe(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(osd_attrs); i++) ret = device_create_file(fbi->dev, &osd_attrs[i]); } -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND early_suspend.level = EARLY_SUSPEND_LEVEL_STOP_DRAWING; early_suspend.suspend = osd_early_suspend; early_suspend.resume = osd_late_resume; @@ -2594,7 +2594,7 @@ static int osd_remove(struct platform_device *pdev) osd_log_info("osd_remove.\n"); if (!pdev) return -ENODEV; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND unregister_early_suspend(&early_suspend); #endif vout_unregister_client(&osd_notifier_nb); diff --git a/drivers/amlogic/media/osd_ext/osd_fb.c b/drivers/amlogic/media/osd_ext/osd_fb.c index dae6e455..147d5d7 100644 --- a/drivers/amlogic/media/osd_ext/osd_fb.c +++ b/drivers/amlogic/media/osd_ext/osd_fb.c @@ -50,8 +50,8 @@ #include "osd_fb.h" -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include static struct early_suspend early_suspend; static int early_suspend_flag; #endif @@ -1308,7 +1308,7 @@ static struct device_attribute osd_ext_attrs[] = { #ifdef CONFIG_PM static int osd_ext_suspend(struct platform_device *pdev, pm_message_t state) { -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND if (early_suspend_flag) return 0; #endif @@ -1324,7 +1324,7 @@ static int osd_ext_resume(struct platform_device *dev) return 0; } #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND if (early_suspend_flag) return 0; #endif @@ -1333,7 +1333,7 @@ static int osd_ext_resume(struct platform_device *dev) } #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void osd_ext_early_suspend(struct early_suspend *h) { if (early_suspend_flag) @@ -1354,7 +1354,7 @@ static void osd_ext_late_resume(struct early_suspend *h) #ifdef CONFIG_SCREEN_ON_EARLY void osd_ext_resume_early(void) { -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND osd_ext_resume_hw(); early_suspend_flag = 0; #endif @@ -1532,7 +1532,7 @@ osd_ext_probe(struct platform_device *pdev) } index = 0; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND early_suspend.level = EARLY_SUSPEND_LEVEL_STOP_DRAWING; early_suspend.suspend = osd_ext_early_suspend; early_suspend.resume = osd_ext_late_resume; @@ -1559,7 +1559,7 @@ osd_ext_remove(struct platform_device *pdev) if (!pdev) return -ENODEV; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND unregister_early_suspend(&early_suspend); #endif diff --git a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c index 19a44de..a055aa5 100644 --- a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c +++ b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c @@ -129,8 +129,8 @@ static inline void hdmitx_notify_hpd(int hpd) else hdmitx_event_notify(HDMITX_UNPLUG, NULL); } -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include static void hdmitx_early_suspend(struct early_suspend *h) { const struct vinfo_s *info = hdmi_get_current_vinfo(); @@ -2627,7 +2627,7 @@ static int amhdmitx_probe(struct platform_device *pdev) hdmitx_device.hdcp_mode = -1; /* no hdcp by default */ hdmitx_device.ready = 0; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND register_early_suspend(&hdmitx_early_suspend_handler); #endif hdmitx_device.nb.notifier_call = hdmitx_reboot_notifier; diff --git a/drivers/amlogic/media/vout/vout_serve/vout_serve.c b/drivers/amlogic/media/vout/vout_serve/vout_serve.c index 7db1212..8a0b7d6 100644 --- a/drivers/amlogic/media/vout/vout_serve/vout_serve.c +++ b/drivers/amlogic/media/vout/vout_serve/vout_serve.c @@ -43,8 +43,8 @@ /* Local Headers */ #include "vout_serve.h" -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include static struct early_suspend early_suspend; static int early_suspend_flag; #endif @@ -423,7 +423,7 @@ static int vout_remove_attr(void) #ifdef CONFIG_PM static int aml_vout_suspend(struct platform_device *pdev, pm_message_t state) { -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND if (early_suspend_flag) return 0; @@ -443,7 +443,7 @@ static int aml_vout_resume(struct platform_device *pdev) } #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND if (early_suspend_flag) return 0; @@ -491,7 +491,7 @@ static int aml_vout_pm_resume(struct device *dev) #ifdef CONFIG_SCREEN_ON_EARLY void resume_vout_early(void) { -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND early_suspend_flag = 0; early_resume_flag = 1; vout_resume(); @@ -500,7 +500,7 @@ void resume_vout_early(void) EXPORT_SYMBOL(resume_vout_early); #endif -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void aml_vout_early_suspend(struct early_suspend *h) { if (early_suspend_flag) @@ -603,7 +603,7 @@ static int aml_vout_probe(struct platform_device *pdev) { int ret = -1; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN; early_suspend.suspend = aml_vout_early_suspend; early_suspend.resume = aml_vout_late_resume; @@ -628,7 +628,7 @@ static int aml_vout_probe(struct platform_device *pdev) static int aml_vout_remove(struct platform_device *pdev) { -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND unregister_early_suspend(&early_suspend); #endif vout_remove_attr(); diff --git a/drivers/amlogic/pm/Kconfig b/drivers/amlogic/pm/Kconfig index 9e405cc..4a84c89 100644 --- a/drivers/amlogic/pm/Kconfig +++ b/drivers/amlogic/pm/Kconfig @@ -28,4 +28,15 @@ config AMLOGIC_MX_SUSPEND If you want this support, you should say Y here. +config AMLOGIC_LEGACY_EARLY_SUSPEND + bool "A re-implement early_suspend instead of legacy ealry_suspend." + depends on AMLOGIC_GX_SUSPEND || AMLOGIC_MX_SUSPEND + depends on PM + default n + help + Kernel has abandoned legacy early_suspend mechanism. + Here re-implement a early_suspend for use driver legacy early_suspend code easily. + + If you want this support, you should say Y here. + endmenu diff --git a/drivers/amlogic/pm/gx_pm.c b/drivers/amlogic/pm/gx_pm.c index 5191cb7..32f7551 100644 --- a/drivers/amlogic/pm/gx_pm.c +++ b/drivers/amlogic/pm/gx_pm.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -38,6 +37,9 @@ #include #include #include +#include +#include +#include <../kernel/power/power.h> typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); @@ -64,11 +66,116 @@ static u32 psci_get_version(void) static void __iomem *exit_reg; static int max_idle_lvl; +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +static DEFINE_MUTEX(early_suspend_lock); +static LIST_HEAD(early_suspend_handlers); + +void register_early_suspend(struct early_suspend *handler) +{ + struct list_head *pos; + + mutex_lock(&early_suspend_lock); + list_for_each(pos, &early_suspend_handlers) { + struct early_suspend *e; + + e = list_entry(pos, struct early_suspend, link); + if (e->level > handler->level) + break; + } + list_add_tail(&handler->link, pos); + mutex_unlock(&early_suspend_lock); +} +EXPORT_SYMBOL(register_early_suspend); + +void unregister_early_suspend(struct early_suspend *handler) +{ + mutex_lock(&early_suspend_lock); + list_del(&handler->link); + mutex_unlock(&early_suspend_lock); +} +EXPORT_SYMBOL(unregister_early_suspend); + +static void early_suspend(void) +{ + struct early_suspend *pos; + + mutex_lock(&early_suspend_lock); + + pr_info("early_suspend: call handlers\n"); + list_for_each_entry(pos, &early_suspend_handlers, link) { + if (pos->suspend != NULL) { + pr_info("early_suspend: %pf\n", pos->suspend); + pos->suspend(pos); + } + } + mutex_unlock(&early_suspend_lock); + + pr_info("early_suspend: done\n"); + +} + +static void late_resume(void) +{ + struct early_suspend *pos; + + mutex_lock(&early_suspend_lock); + + pr_info("late_resume: call handlers\n"); + list_for_each_entry_reverse(pos, &early_suspend_handlers, link) + if (pos->resume != NULL) { + pr_info("late_resume: %pf\n", pos->resume); + pos->resume(pos); + } + pr_info("late_resume: done\n"); + + mutex_unlock(&early_suspend_lock); +} + +unsigned int early_suspend_state; +static ssize_t early_suspend_trigger_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + unsigned int len; + + len = sprintf(buf, "%d\n", early_suspend_state); + + return len; +} +static ssize_t early_suspend_trigger_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t n) +{ + int ret; + + ret = kstrtouint(buf, 0, &early_suspend_state); + pr_info("early_suspend_state=%d\n", early_suspend_state); + + if (ret) + return -EINVAL; + + if (early_suspend_state == 0) + late_resume(); + else if (early_suspend_state == 1) + early_suspend(); + + return n; +} + +power_attr(early_suspend_trigger); +static struct attribute *g[] = { + &early_suspend_trigger_attr.attr, + NULL, +}; + +static struct attribute_group attr_group = { + .attrs = g, +}; +#endif //CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND /* *0x10000 : bit[16]=1:control cpu suspend to power down *cpu_suspend(0, meson_system_suspend); */ - static void meson_gx_suspend(void) { pr_info("enter meson_pm_suspend!\n"); @@ -182,6 +289,10 @@ static int __init meson_pm_probe(struct platform_device *pdev) exit_reg = of_iomap(pdev->dev.of_node, 0); device_create_file(&pdev->dev, &dev_attr_suspend_reason); +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND + if (sysfs_create_group(power_kobj, &attr_group)) + return -1; +#endif pr_info("meson_pm_probe done\n"); return 0; } diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c index 5ae522a..9bde76d 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c @@ -71,6 +71,9 @@ #include #include #include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include +#endif #define DWC_DRIVER_VERSION "3.10a 12-MAY-2014" #define DWC_DRIVER_DESC "HS OTG USB Controller driver" @@ -873,7 +876,7 @@ static void dwc_otg_driver_shutdown(struct platform_device *pdev) #endif return; } -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND extern int get_pcd_ums_state(dwc_otg_pcd_t *pcd); static void usb_early_suspend(struct early_suspend *h) { @@ -1357,7 +1360,7 @@ static int dwc_otg_driver_probe(struct platform_device *pdev) } else { dwc_otg_enable_global_interrupts(dwc_otg_device->core_if); } -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND dwc_otg_device->usb_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; dwc_otg_device->usb_early_suspend.suspend = usb_early_suspend; dwc_otg_device->usb_early_suspend.resume = usb_early_resume; diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.h b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.h index a124564..5c9b338 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.h +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.h @@ -39,8 +39,8 @@ */ #include "dwc_otg_os_dep.h" #include "dwc_otg_core_if.h" -#ifdef CONFIG_HAS_EARLYSUSPEND -#include +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +#include #endif #include @@ -80,7 +80,7 @@ typedef struct dwc_otg_device { uint8_t common_irq_installed; dwc_timer_t *id_change_timer; -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND struct early_suspend usb_early_suspend; #endif diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_linux.c b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_linux.c index 1356e37..d72c2cb 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_linux.c +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_linux.c @@ -1364,13 +1364,15 @@ void pcd_remove(struct platform_device *pdev) otg_dev->pcd = 0; } -#ifdef CONFIG_HAS_EARLYSUSPEND +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND int get_pcd_ums_state(dwc_otg_pcd_t *pcd) { +#if 0 //Mark for compile error if (gadget_wrapper && (pcd == gadget_wrapper->pcd) && gadget_wrapper->gadget.priv_data) return *(int *)gadget_wrapper->gadget.priv_data; +#endif return 0; } #endif diff --git a/include/linux/amlogic/pm.h b/include/linux/amlogic/pm.h index 9045dd0..57433fe 100644 --- a/include/linux/amlogic/pm.h +++ b/include/linux/amlogic/pm.h @@ -17,6 +17,8 @@ #ifndef __AML_PM_H__ #define __AML_PM_H__ +#include + /* wake up reason*/ #define UDEFINED_WAKEUP 0 #define CHARGING_WAKEUP 1 @@ -29,12 +31,24 @@ #define CEC_WAKEUP 8 #define REMOTE_CUS_WAKEUP 9 #define ETH_PHY_WAKEUP 10 -#ifdef CONFIG_GXBB_SUSPEND -unsigned int get_resume_method(void); -#else -static inline unsigned int get_resume_method(void) -{ - return 0; -} -#endif +extern unsigned int get_resume_method(void); + +#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND +enum { + EARLY_SUSPEND_LEVEL_BLANK_SCREEN = 50, + EARLY_SUSPEND_LEVEL_STOP_DRAWING = 100, + EARLY_SUSPEND_LEVEL_DISABLE_FB = 150, +}; + +struct early_suspend { + struct list_head link; + int level; + void (*suspend)(struct early_suspend *h); + void (*resume)(struct early_suspend *h); + void *param; +}; +extern void register_early_suspend(struct early_suspend *handler); +extern void unregister_early_suspend(struct early_suspend *handler); + +#endif //CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND #endif -- 2.7.4