Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330501
b: refs/heads/master
c: 318cb38
h: refs/heads/master
i:
  330499: e9ed478
v: v3
  • Loading branch information
Kim, Milo authored and Anton Vorontsov committed Sep 21, 2012
1 parent 8ba3eea commit a185b21
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 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: fb9adc5190d7605506ebc0e05351baa57365cc90
refs/heads/master: 318cb389d020e3107979d7d794ab992e4bcd6665
28 changes: 21 additions & 7 deletions trunk/drivers/power/lp8727_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,21 @@ static void lp8727_ctrl_switch(struct lp8727_chg *pchg, u8 sw)

static void lp8727_id_detection(struct lp8727_chg *pchg, u8 id, int vbusin)
{
struct lp8727_platform_data *pdata = pchg->pdata;
u8 devid = ID_NONE;
u8 swctrl = SW_DM1_HiZ | SW_DP2_HiZ;

switch (id) {
case 0x5:
devid = ID_TA;
pchg->chg_parm = &pchg->pdata->ac;
pchg->chg_parm = pdata ? pdata->ac : NULL;
break;
case 0xB:
if (lp8727_is_dedicated_charger(pchg)) {
pchg->chg_parm = &pchg->pdata->ac;
pchg->chg_parm = pdata ? pdata->ac : NULL;
devid = ID_DEDICATED_CHG;
} else if (lp8727_is_usb_charger(pchg)) {
pchg->chg_parm = &pchg->pdata->usb;
pchg->chg_parm = pdata ? pdata->usb : NULL;
devid = ID_USB_CHG;
swctrl = SW_DM1_DM | SW_DP2_DP;
} else if (vbusin) {
Expand Down Expand Up @@ -295,6 +296,7 @@ static int lp8727_battery_get_property(struct power_supply *psy,
union power_supply_propval *val)
{
struct lp8727_chg *pchg = dev_get_drvdata(psy->dev->parent);
struct lp8727_platform_data *pdata = pchg->pdata;
u8 read;

switch (psp) {
Expand All @@ -318,19 +320,31 @@ static int lp8727_battery_get_property(struct power_supply *psy,
val->intval = POWER_SUPPLY_HEALTH_GOOD;
break;
case POWER_SUPPLY_PROP_PRESENT:
if (pchg->pdata->get_batt_present)
if (!pdata)
return -EINVAL;

if (pdata->get_batt_present)
val->intval = pchg->pdata->get_batt_present();
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
if (pchg->pdata->get_batt_level)
if (!pdata)
return -EINVAL;

if (pdata->get_batt_level)
val->intval = pchg->pdata->get_batt_level();
break;
case POWER_SUPPLY_PROP_CAPACITY:
if (pchg->pdata->get_batt_capacity)
if (!pdata)
return -EINVAL;

if (pdata->get_batt_capacity)
val->intval = pchg->pdata->get_batt_capacity();
break;
case POWER_SUPPLY_PROP_TEMP:
if (pchg->pdata->get_batt_temp)
if (!pdata)
return -EINVAL;

if (pdata->get_batt_temp)
val->intval = pchg->pdata->get_batt_temp();
break;
default:
Expand Down
7 changes: 4 additions & 3 deletions trunk/include/linux/platform_data/lp8727.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ struct lp8727_chg_param {
* @get_batt_level : get battery voltage (mV)
* @get_batt_capacity : get battery capacity (%)
* @get_batt_temp : get battery temperature
* @ac, @usb : charging parameters each charger type
* @ac : charging parameters for AC type charger
* @usb : charging parameters for USB type charger
*/
struct lp8727_platform_data {
u8 (*get_batt_present)(void);
u16 (*get_batt_level)(void);
u8 (*get_batt_capacity)(void);
u8 (*get_batt_temp)(void);
struct lp8727_chg_param ac;
struct lp8727_chg_param usb;
struct lp8727_chg_param *ac;
struct lp8727_chg_param *usb;
};

#endif

0 comments on commit a185b21

Please sign in to comment.