From: xieyi Date: Tue, 9 Oct 2012 10:36:16 +0000 (+0800) Subject: rk2928: act8931: switch charge current when suspend X-Git-Tag: firefly_0821_release~8463 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ba3e1d5c4edabe1e43f34d11eb6acf2687de39a8;p=firefly-linux-kernel-4.4.55.git rk2928: act8931: switch charge current when suspend --- diff --git a/arch/arm/mach-rk2928/board-rk2928-sdk-act8931.c b/arch/arm/mach-rk2928/board-rk2928-sdk-act8931.c index 6a816138d819..d495acb3251a 100755 --- a/arch/arm/mach-rk2928/board-rk2928-sdk-act8931.c +++ b/arch/arm/mach-rk2928/board-rk2928-sdk-act8931.c @@ -8,12 +8,16 @@ #ifdef CONFIG_REGULATOR_ACT8931 +#define ACT8931_CHGSEL_PIN RK2928_PIN1_PA1 +#define ACT8931_CHGSEL_VALUE GPIO_LOW /* Decline to 20% current */ + extern int platform_device_register(struct platform_device *pdev); static int act8931_set_init(struct act8931 *act8931) { struct regulator *dcdc; struct regulator *ldo; + int ret; printk("%s,line=%d\n", __func__,__LINE__); g_pmic_type = PMIC_TYPE_ACT8931; @@ -73,6 +77,10 @@ static int act8931_set_init(struct act8931 *act8931) regulator_put(dcdc); udelay(100); + ret = gpio_request(ACT8931_CHGSEL_PIN, "ACT8931_CHGSEL"); + if (ret != 0) + gpio_free(ACT8931_CHGSEL_PIN); + gpio_direction_output(ACT8931_CHGSEL_PIN, ACT8931_CHGSEL_VALUE); printk("%s,line=%d END\n", __func__,__LINE__); @@ -273,9 +281,19 @@ static struct act8931_platform_data act8931_data={ .set_init=act8931_set_init, .num_regulators=7, .regulators=act8931_regulator_subdev_id, - }; +#ifdef CONFIG_HAS_EARLYSUSPEND +void act8931_early_suspend(struct early_suspend *h) +{ + gpio_direction_output(ACT8931_CHGSEL_PIN, ACT8931_CHGSEL_VALUE); +} + +void act8931_late_resume(struct early_suspend *h) +{ + gpio_direction_output(ACT8931_CHGSEL_PIN, !ACT8931_CHGSEL_VALUE); +} +#endif #endif diff --git a/drivers/regulator/act8931.c b/drivers/regulator/act8931.c index 2bc2d429835d..5c7034c9f717 100755 --- a/drivers/regulator/act8931.c +++ b/drivers/regulator/act8931.c @@ -22,7 +22,10 @@ #include #include #include - +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif + #if 0 #define DBG(x...) printk(KERN_INFO x) #else @@ -42,6 +45,7 @@ struct act8931 { struct i2c_client *i2c; int num_regulators; struct regulator_dev **rdev; + struct early_suspend act8931_suspend; }; static u8 act8931_reg_read(struct act8931 *act8931, u8 reg); @@ -586,6 +590,12 @@ static irqreturn_t act8931_irq_thread(unsigned int irq, void *dev_id) rk28_send_wakeup_key(); return IRQ_HANDLED; } + +#ifdef CONFIG_HAS_EARLYSUSPEND +__weak void act8931_early_suspend(struct early_suspend *h) {} +__weak void act8931_late_resume(struct early_suspend *h) {} +#endif + static int __devinit act8931_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct act8931 *act8931; @@ -657,6 +667,14 @@ static int __devinit act8931_i2c_probe(struct i2c_client *i2c, const struct i2c_ } enable_irq_wake(act8931->irq); + + #ifdef CONFIG_HAS_EARLYSUSPEND + act8931->act8931_suspend.suspend = act8931_early_suspend, + act8931->act8931_suspend.resume = act8931_late_resume, + act8931->act8931_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1, + register_early_suspend(&act8931->act8931_suspend); + #endif + return 0; err: