From 3317f45d6b68ec2e07c847c850467ac48a349ef5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Mon, 28 May 2012 19:46:44 +0800 Subject: [PATCH] rk30:phone loquat:modify the pmu battery charger work quenes --- arch/arm/mach-rk30/board-rk30-phone-twl60xx.c | 4 ++ drivers/power/twl6030_bci_battery.c | 43 +++++++++---------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-phone-twl60xx.c b/arch/arm/mach-rk30/board-rk30-phone-twl60xx.c index c9408d315ceb..b7464e65f102 100755 --- a/arch/arm/mach-rk30/board-rk30-phone-twl60xx.c +++ b/arch/arm/mach-rk30/board-rk30-phone-twl60xx.c @@ -87,6 +87,7 @@ #define LDO7_CFG_VOLTAGE 0x77 #define CLK32KG_CFG_STATE 0x11 #define CLK32KAUDIO_CFG_STATE 0x14 +#define CHARGERUSB_CTRLLIMIT2 0x10 static inline int twl_reg_read(unsigned base, unsigned slave_subgp) { u8 value; @@ -126,6 +127,9 @@ int tps80032_pre_init(void){ twl_reg_write(CLK32KG_CFG_STATE,TWL_MODULE_PM_SLAVE_RES,0x01); //set clk32kg on when we use twl_reg_write(CLK32KAUDIO_CFG_STATE,TWL_MODULE_PM_SLAVE_RES,0x01); //set clk32kaudio on when we use + + twl_i2c_write_u8(CHARGERUSB_CTRLLIMIT2,TWL6030_MODULE_CHARGER, 0x0f); + twl_i2c_write_u8(CHARGERUSB_CTRLLIMIT2,TWL6030_MODULE_CHARGER, 0x1f); twl_reg_write(LDO5_CFG_TRANS,TWL_MODULE_PM_RECEIVER,0x03); //set ldo5 is disabled when in sleep mode twl_reg_write(LDO7_CFG_TRANS,TWL_MODULE_PM_RECEIVER,0x03); //set ldo7 is disabled when in sleep mode diff --git a/drivers/power/twl6030_bci_battery.c b/drivers/power/twl6030_bci_battery.c index d844d3e88fb3..15c65112b8c7 100755 --- a/drivers/power/twl6030_bci_battery.c +++ b/drivers/power/twl6030_bci_battery.c @@ -243,8 +243,6 @@ #define BATTERY_DETECT_THRESHOLD ((BATTERY_RESISTOR + SIMULATOR_RESISTOR) / 2) //battery voltage threshold divided by 22uA #define CHARGING_CAPACITY_UPDATE_PERIOD (1000 * 60 * 1) -#define PMU_CHRG_DET_N RK30_PIN0_PC7 - /* To get VBUS input limit from twl6030_usb */ #if CONFIG_TWL6030_USB extern unsigned int twl6030_get_usb_max_power(struct otg_transceiver *x); @@ -314,6 +312,8 @@ struct twl6030_bci_device_info { struct notifier_block nb; struct work_struct usb_work; + struct workqueue_struct *freezable_work; + struct delayed_work twl6030_bci_monitor_work; struct delayed_work twl6030_current_avg_work; @@ -991,7 +991,7 @@ static irqreturn_t twl6030charger_ctrl_interrupt(int irq, void *_di) power_supply_changed(&di->bat); else { cancel_delayed_work(&di->twl6030_bci_monitor_work); - schedule_delayed_work(&di->twl6030_bci_monitor_work, 0); + queue_delayed_work(di->freezable_work, &di->twl6030_bci_monitor_work, 0); } err: return IRQ_HANDLED; @@ -1511,7 +1511,7 @@ static void twl6030_current_avg(struct work_struct *work) di->current_avg_uA = current_avg_uA * 1000; } - schedule_delayed_work(&di->twl6030_current_avg_work, + queue_delayed_work(di->freezable_work, &di->twl6030_current_avg_work, msecs_to_jiffies(1000 * di->current_avg_interval)); return; err: @@ -1639,7 +1639,7 @@ static void twl6030_bci_battery_work(struct work_struct *work) req.func_cb = NULL; ret = twl6030_gpadc_conversion(&req); - schedule_delayed_work(&di->twl6030_bci_monitor_work, + queue_delayed_work(di->freezable_work, &di->twl6030_bci_monitor_work, msecs_to_jiffies(1000 * di->monitoring_interval)); if (ret < 0) { dev_info(di->dev, "gpadc conversion failed: %d\n", ret); @@ -1688,7 +1688,7 @@ static void twl6030_current_mode_changed(struct twl6030_bci_device_info *di) goto err; cancel_delayed_work(&di->twl6030_current_avg_work); - schedule_delayed_work(&di->twl6030_current_avg_work, + queue_delayed_work(di->freezable_work, &di->twl6030_current_avg_work, msecs_to_jiffies(1000 * di->current_avg_interval)); return; err: @@ -1698,7 +1698,7 @@ err: static void twl6030_work_interval_changed(struct twl6030_bci_device_info *di) { cancel_delayed_work(&di->twl6030_bci_monitor_work); - schedule_delayed_work(&di->twl6030_bci_monitor_work, + queue_delayed_work(di->freezable_work, &di->twl6030_bci_monitor_work, msecs_to_jiffies(1000 * di->monitoring_interval)); } @@ -1710,7 +1710,7 @@ static void twl6030_bci_battery_external_power_changed(struct power_supply *psy) struct twl6030_bci_device_info *di = to_twl6030_bci_device_info(psy); cancel_delayed_work(&di->twl6030_bci_monitor_work); - schedule_delayed_work(&di->twl6030_bci_monitor_work, 0); + queue_delayed_work(di->freezable_work, &di->twl6030_bci_monitor_work, 0); } #define to_twl6030_ac_device_info(x) container_of((x), \ @@ -2425,24 +2425,19 @@ static void twl6030_battery_work(struct work_struct *work) { struct twl6030_bci_device_info *di = container_of(work, struct twl6030_bci_device_info, work.work); twl6030_battery_update_status(di); - int ret; - u8 reg; //set charging current - gpio_request(PMU_CHRG_DET_N, "NULL"); twl_i2c_write_u8(TWL6030_MODULE_CHARGER,0x00,CHARGERUSB_CTRL1); if(2 == dwc_vbus_status()){ - gpio_direction_output(PMU_CHRG_DET_N, 0); twl_i2c_write_u8(TWL6030_MODULE_CHARGER, 0x29,CHARGERUSB_CINLIMIT); //set vbus input current is 1A twl_i2c_write_u8(TWL6030_MODULE_CHARGER, 0x09,CHARGERUSB_VICHRG); //set mos output current is 1A } else if(1 == dwc_vbus_status()){ - gpio_direction_output(PMU_CHRG_DET_N, 1); twl_i2c_write_u8(TWL6030_MODULE_CHARGER, 0x09,CHARGERUSB_CINLIMIT);//set vbus input current is 500ma twl_i2c_write_u8(TWL6030_MODULE_CHARGER, 0x04,CHARGERUSB_VICHRG); //set mos output current is 500ma } /* reschedule for the next time */ - schedule_delayed_work(&di->work, di->interval); + queue_delayed_work(di->freezable_work, &di->work, di->interval); } static int __devinit twl6030_bci_battery_probe(struct platform_device *pdev) @@ -2633,13 +2628,15 @@ static int __devinit twl6030_bci_battery_probe(struct platform_device *pdev) di->charge_n1 = 0; di->timer_n1 = 0; - INIT_DELAYED_WORK_DEFERRABLE(&di->twl6030_bci_monitor_work, + //di->freezable_work = create_freezable_workqueue("battery"); + di->freezable_work = system_freezable_wq; + INIT_DELAYED_WORK(&di->twl6030_bci_monitor_work, twl6030_bci_battery_work); - schedule_delayed_work(&di->twl6030_bci_monitor_work, 0); + queue_delayed_work(di->freezable_work, &di->twl6030_bci_monitor_work, 0); INIT_DELAYED_WORK_DEFERRABLE(&di->twl6030_current_avg_work, twl6030_current_avg); - schedule_delayed_work(&di->twl6030_current_avg_work, 500); + queue_delayed_work(di->freezable_work, &di->twl6030_current_avg_work, 500); ret = twl6030battery_voltage_setup(di); if (ret) @@ -2763,7 +2760,7 @@ static int __devinit twl6030_bci_battery_probe(struct platform_device *pdev) di->interval = msecs_to_jiffies(1 * 1000); INIT_DELAYED_WORK(&di->work, twl6030_battery_work); - schedule_delayed_work(&di->work, 1*HZ); + queue_delayed_work(di->freezable_work, &di->work, 1*HZ); ret = twl6030backupbatt_setup(); if (ret) @@ -2862,8 +2859,9 @@ static int twl6030_bci_battery_suspend(struct device *dev) if (ret) goto err; - cancel_delayed_work(&di->twl6030_bci_monitor_work); - cancel_delayed_work(&di->twl6030_current_avg_work); + //cancel_delayed_work(&di->work); + //cancel_delayed_work(&di->twl6030_bci_monitor_work); + //cancel_delayed_work(&di->twl6030_current_avg_work); /* We cannot tolarate a sleep longer than 30 seconds * while on ac charging we have to reset the BQ watchdog timer. @@ -2929,8 +2927,9 @@ static int twl6030_bci_battery_resume(struct device *dev) if (ret) goto err; - schedule_delayed_work(&di->twl6030_bci_monitor_work, 0); - schedule_delayed_work(&di->twl6030_current_avg_work, 50); + //queue_delayed_work(di->freezable_work, &di->twl6030_bci_monitor_work, 0); + //queue_delayed_work(di->freezable_work, &di->twl6030_current_avg_work, 50); + //queue_delayed_work(di->freezable_work, &di->work, di->interval); events = BQ2415x_RESET_TIMER; blocking_notifier_call_chain(¬ifier_list, events, NULL); -- 2.34.1