From 9545efad09c5f9d4a7d21e7a895efe837cad829f Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 21 Jan 2011 11:57:43 -0800 Subject: [PATCH] ARM: tegra: stingray: Only enable bridge chip in resume on power button Powering on the LVDS chip during resume when the resume was not caused by the user pushing the power button causes the screen to flicker and wastes power. Only power on the LVDS chip if the power button event is detected during resume. Change-Id: I6a36e00a04c7a4e33bad08af20d485426f429264 Signed-off-by: Colin Cross --- arch/arm/mach-tegra/board-stingray-panel.c | 57 ++++++++++++++++------ 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-tegra/board-stingray-panel.c b/arch/arm/mach-tegra/board-stingray-panel.c index af4635a8305e..1a66d9827fdf 100644 --- a/arch/arm/mach-tegra/board-stingray-panel.c +++ b/arch/arm/mach-tegra/board-stingray-panel.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -230,39 +232,65 @@ static void stingray_panel_early_reg_enable(struct work_struct *work) static DECLARE_WORK(stingray_panel_early_reg_enable_work, stingray_panel_early_reg_enable); +static bool stingray_panel_early_reg_in_resume; static int stingray_panel_early_reg_resume_noirq(struct device *dev) { - /* Start the bridge chip powering up during early resume */ - schedule_work(&stingray_panel_early_reg_enable_work); - + stingray_panel_early_reg_in_resume = true; + smp_wmb(); return 0; } +static void stingray_panel_early_reg_resume_complete(struct device *dev) +{ + stingray_panel_early_reg_in_resume = false; + smp_wmb(); +} + static int stingray_panel_early_reg_suspend(struct device *dev) { cancel_work_sync(&stingray_panel_early_reg_enable_work); + flush_delayed_work(&stingray_panel_early_reg_disable_work); - /* - * If the delayed disable work was pending when it was cancelled, - * do the disable immediately. - */ - if (cancel_delayed_work_sync(&stingray_panel_early_reg_disable_work)) - stingray_panel_disable(); + return 0; +} + +/* + * If the power button key event is detected during the resume process, + * the screen will get turned on later. Immediately start the LVDS bridge chip + * turning on to reduce time spent waiting for it later in resume. + */ +static int stingray_panel_early_reg_power(void) +{ + smp_rmb(); + if (stingray_panel_early_reg_in_resume) + schedule_work(&stingray_panel_early_reg_enable_work); return 0; } static struct dev_pm_ops stingray_panel_early_reg_pm_ops = { .resume_noirq = stingray_panel_early_reg_resume_noirq, + .complete = stingray_panel_early_reg_resume_complete, .suspend = stingray_panel_early_reg_suspend, }; -/* - * This driver uses a resume_noirq handler to start the bridge chip powering up - * as soon as possible during resume to avoid waiting for 200 ms after all the - * other resume handlers have finished. - */ +static struct keyreset_platform_data stingray_panel_early_reg_keyreset = { + .reset_fn = stingray_panel_early_reg_power, + .keys_down = { + KEY_END, + 0 + }, +}; + +struct platform_device stingray_panel_early_reg_keyreset_device = { + .name = KEYRESET_NAME, + .id = -1, + .dev = { + .platform_data = &stingray_panel_early_reg_keyreset, + }, +}; + static struct platform_driver stingray_panel_early_reg_driver = { .driver = { .name = "stingray-panel-early-reg", @@ -463,6 +491,7 @@ int __init stingray_panel_init(void) platform_driver_register(&stingray_panel_early_reg_driver); platform_device_register(&stingray_panel_early_reg_device); + platform_device_register(&stingray_panel_early_reg_keyreset_device); stingray_hdmi_init(); -- 2.34.1