Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 367464
b: refs/heads/master
c: 49fddee
h: refs/heads/master
v: v3
  • Loading branch information
Mustapha Ben Zoubeir authored and Lee Jones committed Mar 7, 2013
1 parent bc11d0b commit 6d7f35d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 54fbbb6242247d06d21e21bbcf4ae8339bd75592
refs/heads/master: 49fddeec9fbb0dd58507185104812fde77c38def
35 changes: 26 additions & 9 deletions trunk/drivers/power/pm2301_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#define to_pm2xxx_charger_ac_device_info(x) container_of((x), \
struct pm2xxx_charger, ac_chg)
#define SLEEP_MIN 50
#define SLEEP_MAX 100

static int pm2xxx_interrupt_registers[] = {
PM2XXX_REG_INT1,
Expand Down Expand Up @@ -113,17 +115,14 @@ static const struct i2c_device_id pm2xxx_ident[] = {

static void set_lpn_pin(struct pm2xxx_charger *pm2)
{
if (pm2->ac.charger_connected)
return;
gpio_set_value(pm2->lpn_pin, 1);
usleep_range(SLEEP_MIN, SLEEP_MAX);

return;
}

static void clear_lpn_pin(struct pm2xxx_charger *pm2)
{
if (pm2->ac.charger_connected)
return;
gpio_set_value(pm2->lpn_pin, 0);

return;
Expand All @@ -139,15 +138,13 @@ static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val)
* and receive I2C "acknowledge" from PM2301.
*/
mutex_lock(&pm2->lock);
set_lpn_pin(pm2);

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;
clear_lpn_pin(pm2);
mutex_unlock(&pm2->lock);

return ret;
Expand All @@ -163,15 +160,13 @@ static int pm2xxx_reg_write(struct pm2xxx_charger *pm2, int reg, u8 val)
* and receive I2C "acknowledge" from PM2301.
*/
mutex_lock(&pm2->lock);
set_lpn_pin(pm2);

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;
clear_lpn_pin(pm2);
mutex_unlock(&pm2->lock);

return ret;
Expand Down Expand Up @@ -478,7 +473,6 @@ static int pm2_int_reg5(void *pm2_data, int val)
struct pm2xxx_charger *pm2 = pm2_data;
int ret = 0;


if (val & (PM2XXX_INT6_ITVPWR2DROP | PM2XXX_INT6_ITVPWR1DROP)) {
dev_dbg(pm2->dev, "VMPWR drop to VBAT level\n");
}
Expand Down Expand Up @@ -899,12 +893,34 @@ static struct pm2xxx_irq pm2xxx_charger_irq[] = {

static int pm2xxx_wall_charger_resume(struct i2c_client *i2c_client)
{
struct pm2xxx_charger *pm2;

pm2 = (struct pm2xxx_charger *)i2c_get_clientdata(i2c_client);
set_lpn_pin(pm2);

/* If we still have a HW failure, schedule a new check */
if (pm2->flags.ovv)
queue_delayed_work(pm2->charger_wq,
&pm2->check_hw_failure_work, 0);

return 0;
}

static int pm2xxx_wall_charger_suspend(struct i2c_client *i2c_client,
pm_message_t state)
{
struct pm2xxx_charger *pm2;

pm2 = (struct pm2xxx_charger *)i2c_get_clientdata(i2c_client);
clear_lpn_pin(pm2);

/* Cancel any pending HW failure check */
if (delayed_work_pending(&pm2->check_hw_failure_work))
cancel_delayed_work(&pm2->check_hw_failure_work);

flush_work(&pm2->ac_work);
flush_work(&pm2->check_main_thermal_prot_work);

return 0;
}

Expand Down Expand Up @@ -1056,6 +1072,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
goto free_gpio;
}

set_lpn_pin(pm2);
ret = pm2xxx_charger_detection(pm2, &val);

if ((ret == 0) && val) {
Expand Down

0 comments on commit 6d7f35d

Please sign in to comment.