Skip to content

Commit

Permalink
pm2301-charger: Wake device on register access
Browse files Browse the repository at this point in the history
When USB  Dedicated or Standard host chargers are plugged into
the device, chargealg attempts to disable the PM2301 AC charger,
However, disabling PM2301 was failing because of it being in
runtime suepend mode & LPN pin being low.

Signed-off-by: Rupesh Kumar <rupesh.kumar@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Reviewed-by: Philippe LANGLAIS <philippe.langlais@stericsson.com>
  • Loading branch information
Rupesh Kumar authored and Lee Jones committed Mar 7, 2013
1 parent 7a2cf9b commit b64f51c
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions drivers/power/pm2301_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,43 +128,33 @@ static void clear_lpn_pin(struct pm2xxx_charger *pm2)
static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val)
{
int ret;
/*
* When AC adaptor is unplugged, the host
* must put LPN high to be able to
* communicate by I2C with PM2301
* and receive I2C "acknowledge" from PM2301.
*/
mutex_lock(&pm2->lock);

/* wake up the device */
pm_runtime_get_sync(pm2->dev);

ret = i2c_smbus_read_i2c_block_data(pm2->config.pm2xxx_i2c, reg,
1, val);
if (ret < 0)
dev_err(pm2->dev, "Error reading register at 0x%x\n", reg);
else
ret = 0;
mutex_unlock(&pm2->lock);

return ret;
}

static int pm2xxx_reg_write(struct pm2xxx_charger *pm2, int reg, u8 val)
{
int ret;
/*
* When AC adaptor is unplugged, the host
* must put LPN high to be able to
* communicate by I2C with PM2301
* and receive I2C "acknowledge" from PM2301.
*/
mutex_lock(&pm2->lock);

/* wake up the device */
pm_runtime_get_sync(pm2->dev);

ret = i2c_smbus_write_i2c_block_data(pm2->config.pm2xxx_i2c, reg,
1, &val);
if (ret < 0)
dev_err(pm2->dev, "Error writing register at 0x%x\n", reg);
else
ret = 0;
mutex_unlock(&pm2->lock);

return ret;
}
Expand Down

0 comments on commit b64f51c

Please sign in to comment.