diff options
author | Jin Park <jinyoungp@nvidia.com> | 2011-06-03 20:25:49 +0900 |
---|---|---|
committer | Niket Sirsi <nsirsi@nvidia.com> | 2011-06-20 19:54:57 -0700 |
commit | 9877d85b7e39a8cfaea245e55b1a7c5e5c18a82d (patch) | |
tree | 660b95dde058c6030517e204853d2bc8488354b5 | |
parent | 886517603c1576796e3a1ca349ba69efeed5ecae (diff) |
aat2870: Change suspend and resume event source
Change aat2870_bl suspend and resume event source to backlight driver
from platform driver.
Clean-up codes.
Bug 813111
Change-Id: If04b77bf0c3c3118f05107db6ffeaea7a21cdfac
Signed-off-by: Jin Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/35390
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r-- | drivers/mfd/Kconfig | 2 | ||||
-rw-r--r-- | drivers/mfd/aat2870-core.c | 13 | ||||
-rw-r--r-- | drivers/regulator/aat2870-regulator.c | 4 | ||||
-rw-r--r-- | drivers/video/backlight/Kconfig | 1 | ||||
-rw-r--r-- | drivers/video/backlight/aat2870_bl.c | 67 | ||||
-rw-r--r-- | include/linux/mfd/aat2870.h | 14 |
6 files changed, 25 insertions, 76 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index e258103f6c9c..c6009e534473 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -577,7 +577,7 @@ config MFD_TPS6591X functionality of the device. config MFD_AAT2870_CORE - bool "Support for the AnlogicTech AAT2870" + bool "Support for the AnalogicTech AAT2870" select MFD_CORE depends on I2C=y && GPIOLIB help diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c index 2f9a651e5c43..6d7e868b8b23 100644 --- a/drivers/mfd/aat2870-core.c +++ b/drivers/mfd/aat2870-core.c @@ -195,7 +195,7 @@ static int aat2870_update_bits(struct aat2870_data *aat2870, u8 addr, if (ret) return ret; - new_val = (old_val & ~mask) | val; + new_val = (old_val & ~mask) | (val & mask); change = old_val != new_val; if (change) ret = aat2870->write(aat2870, addr, new_val); @@ -471,14 +471,25 @@ static int aat2870_i2c_suspend(struct i2c_client *client, pm_message_t state) struct aat2870_data *aat2870 = i2c_get_clientdata(client); aat2870_disable(aat2870); + return 0; } static int aat2870_i2c_resume(struct i2c_client *client) { struct aat2870_data *aat2870 = i2c_get_clientdata(client); + struct aat2870_register *reg = NULL; + int i; aat2870_enable(aat2870); + + /* restore registers */ + for (i = 0; i < AAT2870_REG_NUM; i++) { + reg = &aat2870->reg_cache[i]; + if (reg->writeable) + aat2870->write(aat2870, i, reg->value); + } + return 0; } #else diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index c9939ff526db..a119fff6eefc 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c @@ -33,7 +33,7 @@ struct aat2870_regulator { struct platform_device *pdev; struct regulator_desc desc; - int *voltages; /* uV */ + const int *voltages; /* uV */ int min_uV; int max_uV; @@ -145,7 +145,7 @@ static struct regulator_ops aat2870_ldo_ops = { .is_enabled = aat2870_ldo_is_enabled, }; -static int aat2870_ldo_voltages[] = { +static const int aat2870_ldo_voltages[] = { 1200000, 1300000, 1500000, 1600000, 1800000, 2000000, 2200000, 2500000, 2600000, 2700000, 2800000, 2900000, diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index bc62673a2447..5e1b4c655b8f 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -319,6 +319,7 @@ config BACKLIGHT_PCF50633 config BACKLIGHT_AAT2870 bool "AnalogicTech AAT2870 Backlight" depends on BACKLIGHT_CLASS_DEVICE && MFD_AAT2870_CORE + default n help If you have a AnalogicTech AAT2870 say Y to enable the backlight driver. diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c index e17d88619ec9..8b683858e924 100644 --- a/drivers/video/backlight/aat2870_bl.c +++ b/drivers/video/backlight/aat2870_bl.c @@ -28,9 +28,6 @@ #include <linux/fb.h> #include <linux/backlight.h> #include <linux/mfd/aat2870.h> -#if defined(CONFIG_HAS_EARLYSUSPEND) -#include <linux/earlysuspend.h> -#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */ struct aat2870_bl_driver_data { struct platform_device *pdev; @@ -39,9 +36,6 @@ struct aat2870_bl_driver_data { int channels; int max_current; int brightness; /* current brightness */ -#if defined(CONFIG_HAS_EARLYSUSPEND) - struct early_suspend early_suspend; -#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */ }; static inline int aat2870_brightness(struct aat2870_bl_driver_data *aat2870_bl, @@ -125,54 +119,12 @@ static int aat2870_bl_check_fb(struct backlight_device *bd, struct fb_info *fi) } static const struct backlight_ops aat2870_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, .get_brightness = aat2870_bl_get_brightness, - .update_status = aat2870_bl_update_status, + .update_status = aat2870_bl_update_status, .check_fb = aat2870_bl_check_fb, }; -#if defined(CONFIG_PM) -static int aat2870_bl_suspend(struct platform_device *pdev, pm_message_t state) -{ - struct aat2870_bl_driver_data *aat2870_bl = platform_get_drvdata(pdev); - - aat2870_bl_disable(aat2870_bl); - - return 0; -} - -static int aat2870_bl_resume(struct platform_device *pdev) -{ - struct aat2870_bl_driver_data *aat2870_bl = platform_get_drvdata(pdev); - struct backlight_device *bd = aat2870_bl->bd; - - aat2870_bl_enable(aat2870_bl); - backlight_update_status(bd); - - return 0; -} -#else -#define aat2870_bl_suspend NULL -#define aat2870_bl_resume NULL -#endif /* defined(CONFIG_PM) */ - -#if defined(CONFIG_HAS_EARLYSUSPEND) -static void aat2870_bl_early_suspend(struct early_suspend *h) -{ - struct aat2870_bl_driver_data *aat2870_bl = - container_of(h, struct aat2870_bl_driver_data, early_suspend); - - aat2870_bl_suspend(aat2870_bl->pdev, PMSG_SUSPEND); -} - -static void aat2870_bl_late_resume(struct early_suspend *h) -{ - struct aat2870_bl_driver_data *aat2870_bl = - container_of(h, struct aat2870_bl_driver_data, early_suspend); - - aat2870_bl_resume(aat2870_bl->pdev); -} -#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */ - static int aat2870_bl_probe(struct platform_device *pdev) { struct aat2870_bl_platform_data *pdata = pdev->dev.platform_data; @@ -242,13 +194,6 @@ static int aat2870_bl_probe(struct platform_device *pdev) goto out_bl_dev_unregister; } -#if defined(CONFIG_HAS_EARLYSUSPEND) - aat2870_bl->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN; - aat2870_bl->early_suspend.suspend = aat2870_bl_early_suspend; - aat2870_bl->early_suspend.resume = aat2870_bl_late_resume; - register_early_suspend(&aat2870_bl->early_suspend); -#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */ - return 0; out_bl_dev_unregister: @@ -264,10 +209,6 @@ static int aat2870_bl_remove(struct platform_device *pdev) struct aat2870_bl_driver_data *aat2870_bl = platform_get_drvdata(pdev); struct backlight_device *bd = aat2870_bl->bd; -#if defined(CONFIG_HAS_EARLYSUSPEND) - unregister_early_suspend(&aat2870_bl->early_suspend); -#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */ - bd->props.power = FB_BLANK_POWERDOWN; bd->props.brightness = 0; backlight_update_status(bd); @@ -285,10 +226,6 @@ static struct platform_driver aat2870_bl_driver = { }, .probe = aat2870_bl_probe, .remove = aat2870_bl_remove, -#if !defined(CONFIG_HAS_EARLYSUSPEND) - .suspend = aat2870_bl_suspend, - .resume = aat2870_bl_resume, -#endif /* !defined(CONFIG_HAS_EARLYSUSPEND) */ }; static int __init aat2870_bl_init(void) diff --git a/include/linux/mfd/aat2870.h b/include/linux/mfd/aat2870.h index d9ea3a228ff4..d34944e784cf 100644 --- a/include/linux/mfd/aat2870.h +++ b/include/linux/mfd/aat2870.h @@ -89,7 +89,7 @@ enum aat2870_id { /* Backlight current magnitude (mA) */ enum aat2870_current { - AAT2870_CURRENT_0_45 = 0, + AAT2870_CURRENT_0_45, AAT2870_CURRENT_0_90, AAT2870_CURRENT_1_80, AAT2870_CURRENT_2_70, @@ -99,7 +99,7 @@ enum aat2870_current { AAT2870_CURRENT_6_30, AAT2870_CURRENT_7_20, AAT2870_CURRENT_8_10, - AAT2870_CURRENT_9_00 = 10, + AAT2870_CURRENT_9_00, AAT2870_CURRENT_9_90, AAT2870_CURRENT_10_8, AAT2870_CURRENT_11_7, @@ -109,7 +109,7 @@ enum aat2870_current { AAT2870_CURRENT_15_3, AAT2870_CURRENT_16_2, AAT2870_CURRENT_17_1, - AAT2870_CURRENT_18_0 = 20, + AAT2870_CURRENT_18_0, AAT2870_CURRENT_18_9, AAT2870_CURRENT_19_8, AAT2870_CURRENT_20_7, @@ -119,13 +119,13 @@ enum aat2870_current { AAT2870_CURRENT_24_3, AAT2870_CURRENT_25_2, AAT2870_CURRENT_26_1, - AAT2870_CURRENT_27_0 = 30, + AAT2870_CURRENT_27_0, AAT2870_CURRENT_27_9 }; struct aat2870_register { - int readable; - int writeable; + bool readable; + bool writeable; u8 value; }; @@ -136,7 +136,7 @@ struct aat2870_data { struct mutex io_lock; struct aat2870_register *reg_cache; /* register cache */ int en_pin; /* enable GPIO pin (if < 0, ignore this value) */ - int is_enable; + bool is_enable; /* init and uninit for platform specified */ int (*init)(struct aat2870_data *aat2870); |