#define BQ24192_CHRG_CUR_HIGH 900 /* 900mA */
#define BQ24192_CHRG_CUR_NOLIMIT 1500 /* 1500mA */
+#define STATUS_UPDATE_INTERVAL (HZ * 60) /* 60sec */
+
struct bq24192_chrg_regs {
u8 in_src;
u8 pwr_cfg;
struct power_supply usb;
struct power_supply_charger_cap cap;
struct delayed_work chrg_evt_wrkr;
+ struct delayed_work stat_mon_wrkr;
struct mutex event_lock;
int present;
reg->chr_volt = chrg_volt_to_reg(BQ24192_DEF_VBATT_MAX);
}
+static void bq24192_monitor_worker(struct work_struct *work)
+{
+ struct bq24192_chip *chip = container_of(work,
+ struct bq24192_chip, stat_mon_wrkr.work);
+ power_supply_changed(&chip->usb);
+ schedule_delayed_work(&chip->stat_mon_wrkr, STATUS_UPDATE_INTERVAL);
+}
+
static void bq24192_event_worker(struct work_struct *work)
{
struct bq24192_chip *chip = container_of(work,
}
INIT_DELAYED_WORK(&chip->chrg_evt_wrkr, bq24192_event_worker);
+ INIT_DELAYED_WORK(&chip->stat_mon_wrkr, bq24192_monitor_worker);
mutex_init(&chip->event_lock);
chip->chrg_cur_cntl = POWER_SUPPLY_CHARGE_CURRENT_LIMIT_NONE;
kfree(chip);
return ret;
}
-
+ /* start the status monitor worker */
+ schedule_delayed_work(&chip->stat_mon_wrkr, 0);
return 0;
}
{
struct bq24192_chip *chip = dev_get_drvdata(dev);
+ cancel_delayed_work(&chip->stat_mon_wrkr);
dev_dbg(&chip->client->dev, "bq24192 suspend\n");
return 0;
}
{
struct bq24192_chip *chip = dev_get_drvdata(dev);
+ schedule_delayed_work(&chip->stat_mon_wrkr, 0);
dev_dbg(&chip->client->dev, "bq24192 resume\n");
return 0;
}