}
+static bool is_bat_exist(struct battery_info *di)
+{
+ u8 buf;
+
+ battery_read(di->rk818, SUP_STS_REG, &buf, 1);
+ return (buf & 0x80) ? true : false;
+}
+
static bool _is_first_poweron(struct battery_info *di)
{
u8 buf;
enum power_supply_property psp,
union power_supply_propval *val)
{
+ u8 buf;
struct battery_info *di = to_device_info(psy);
switch (psp) {
break;
case POWER_SUPPLY_PROP_PRESENT:
- val->intval = val->intval <= 0 ? 0 : 1;
+ /*val->intval = val->intval <= 0 ? 0 : 1;*/
+ battery_read(di->rk818, SUP_STS_REG, &buf, 1);
+ val->intval = (buf >> 7); /*bit7:BAT_EX*/
break;
+
case POWER_SUPPLY_PROP_CAPACITY:
val->intval = di->real_soc;
break;
platform_set_drvdata(pdev, di);
battery_info_init(di, chip);
+ if (!is_bat_exist(di)) {
+ dev_err(&pdev->dev, "could not find Li-ion battery!\n");
+ return -ENODEV;
+ }
fg_init(di);
wake_lock_init(&di->resume_wake_lock, WAKE_LOCK_SUSPEND, "resume_charging");