Skip to content

Commit

Permalink
s3c_adc_battery: Add gpio_inverted field to pdata
Browse files Browse the repository at this point in the history
Add support for inverted gpio_charge_finished values.
This change is necessary for H1940 support.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
  • Loading branch information
Vasily Khoruzhick authored and Anton Vorontsov committed Dec 21, 2010
1 parent bc51e7f commit c66ae9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/power/s3c_adc_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ static int calc_full_volt(int volt_val, int cur_val, int impedance)
return volt_val + cur_val * impedance / 1000;
}

static int charge_finished(struct s3c_adc_bat *bat)
{
return bat->pdata->gpio_inverted ?
!gpio_get_value(bat->pdata->gpio_charge_finished) :
gpio_get_value(bat->pdata->gpio_charge_finished);
}

static int s3c_adc_bat_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
Expand Down Expand Up @@ -140,7 +147,7 @@ static int s3c_adc_bat_get_property(struct power_supply *psy,

if (bat->cable_plugged &&
((bat->pdata->gpio_charge_finished < 0) ||
!gpio_get_value(bat->pdata->gpio_charge_finished))) {
!charge_finished(bat))) {
lut = bat->pdata->lut_acin;
lut_size = bat->pdata->lut_acin_cnt;
}
Expand Down Expand Up @@ -236,8 +243,7 @@ static void s3c_adc_bat_work(struct work_struct *work)
}
} else {
if ((bat->pdata->gpio_charge_finished >= 0) && is_plugged) {
is_charged = gpio_get_value(
main_bat.pdata->gpio_charge_finished);
is_charged = charge_finished(&main_bat);
if (is_charged) {
if (bat->pdata->disable_charger)
bat->pdata->disable_charger();
Expand Down
1 change: 1 addition & 0 deletions include/linux/s3c_adc_battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct s3c_adc_bat_pdata {
void (*disable_charger)(void);

int gpio_charge_finished;
int gpio_inverted;

const struct s3c_adc_bat_thresh *lut_noac;
unsigned int lut_noac_cnt;
Expand Down

0 comments on commit c66ae9b

Please sign in to comment.