int opchg_battery_set_property(struct power_supply *psy, enum power_supply_property prop, const union power_supply_propval *val) { struct opchg_charger *chip = container_of(psy, struct opchg_charger, batt_psy); switch (prop) { case POWER_SUPPLY_PROP_STATUS: if (!chip->bms_controlled_charging) return -EINVAL; switch (val->intval) { case POWER_SUPPLY_STATUS_FULL: chip->batt_full = true; dev_dbg(chip->dev, "status = FULL, batt_full = %d\n",chip->batt_full); break; case POWER_SUPPLY_STATUS_DISCHARGING: chip->batt_full = false; power_supply_changed(&chip->batt_psy); dev_dbg(chip->dev, "status = DISCHARGING, batt_full = %d\n",chip->batt_full); break; case POWER_SUPPLY_STATUS_CHARGING: chip->batt_full = false; dev_dbg(chip->dev, "status = CHARGING, batt_full = %d\n",chip->batt_full); break; default: return -EINVAL; } break; case POWER_SUPPLY_PROP_CHARGING_ENABLED: opchg_config_charging_disable(chip, USER_DISABLE, !val->intval);//smb358_charging(chip, val->intval); break; case POWER_SUPPLY_PROP_CAPACITY: chip->fake_battery_soc = val->intval; power_supply_changed(&chip->batt_psy); break; case POWER_SUPPLY_PROP_BATTERY_CHARGER_ENABLE: chip->is_factory_mode= val->intval; if(chip->is_factory_mode == true) { /*[email protected] add for clone 15085*/ if(is_project(OPPO_14005)) { opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 0); } } else { /*[email protected] add for clone 15085*/ if( is_project(OPPO_14005)) { opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 1); } } break; case POWER_SUPPLY_PROP_SHIPPING_MODE: chip->shipping_mode = !!val->intval; break; default: return -EINVAL; } return 0; }
int opchg_battery_set_property(struct power_supply *psy, enum power_supply_property prop, const union power_supply_propval *val) { int rc; struct opchg_charger *chip = container_of(psy, struct opchg_charger, batt_psy); switch (prop) { case POWER_SUPPLY_PROP_STATUS: if (!chip->bms_controlled_charging) return -EINVAL; switch (val->intval) { case POWER_SUPPLY_STATUS_FULL: rc = smb358_charging_disable(chip, SOC, true); if (rc < 0) { dev_err(chip->dev,"Couldn't set charging disable rc = %d\n",rc); } else { chip->batt_full = true; dev_dbg(chip->dev, "status = FULL, batt_full = %d\n",chip->batt_full); } break; case POWER_SUPPLY_STATUS_DISCHARGING: chip->batt_full = false; power_supply_changed(&chip->batt_psy); dev_dbg(chip->dev, "status = DISCHARGING, batt_full = %d\n",chip->batt_full); break; case POWER_SUPPLY_STATUS_CHARGING: rc = smb358_charging_disable(chip, SOC, false); if (rc < 0) { dev_err(chip->dev,"Couldn't set charging disable rc = %d\n",rc); } else { chip->batt_full = false; dev_dbg(chip->dev, "status = CHARGING, batt_full = %d\n",chip->batt_full); } break; default: return -EINVAL; } break; case POWER_SUPPLY_PROP_CHARGING_ENABLED: opchg_config_charging_disable(chip, USER_DISABLE, !val->intval);//smb358_charging(chip, val->intval); break; case POWER_SUPPLY_PROP_CAPACITY: chip->fake_battery_soc = val->intval; power_supply_changed(&chip->batt_psy); break; case POWER_SUPPLY_PROP_BATTERY_CHARGER_ENABLE: chip->is_factory_mode= val->intval; if(chip->is_factory_mode == true) { if(is_project(OPPO_15011)||is_project(OPPO_14045)||is_project(OPPO_15005) || is_project(OPPO_15025)) { opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 0); } } else { if(is_project(OPPO_15011)||is_project(OPPO_14045)||is_project(OPPO_15005) || is_project(OPPO_15025)) { opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 1); } } break; default: return -EINVAL; } return 0; }