int qpnp_power_get_property_mains(struct power_supply *psy, enum power_supply_property prop, union power_supply_propval *val) { struct opchg_charger *chip = container_of(psy, struct opchg_charger, dc_psy); switch (prop) { case POWER_SUPPLY_PROP_PRESENT: case POWER_SUPPLY_PROP_ONLINE: if (chip->charging_disabled) return 0; if( is_project(OPPO_14005)) { if((opchg_get_prop_fast_chg_started(chip) == true) || (opchg_get_prop_fast_switch_to_normal(chip) == true) || (opchg_get_fast_normal_to_warm(chip) == true)) { val->intval = 1; } else { if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) val->intval = 1; else val->intval = 0; } } else { /* [email protected], 2014/02/11 Modify for when no battery gauge present */ if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) val->intval = 1; else val->intval = 0; } #ifdef OPCHARGER_DEBUG_ENABLE pr_debug("oppo_debug dc charging and fast charging sign = %d\n",val->intval); #endif break; case POWER_SUPPLY_PROP_CURRENT_MAX: val->intval = chip->fastchg_current_max_ma * 1000;//chip->maxinput_dc_ma * 1000; break; default: return -EINVAL; } return 0; }
int qpnp_power_get_property_mains(struct power_supply *psy, enum power_supply_property prop, union power_supply_propval *val) { struct opchg_charger *chip = container_of(psy, struct opchg_charger, dc_psy); switch (prop) { case POWER_SUPPLY_PROP_PRESENT: case POWER_SUPPLY_PROP_ONLINE: if (chip->charging_disabled) return 0; #if 1 if(is_project(OPPO_14005)||is_project(OPPO_14023)||is_project(OPPO_15011)||is_project(OPPO_15018)) { if((opchg_get_prop_fast_chg_started(chip) == true) || (opchg_get_prop_fast_switch_to_normal(chip) == true) || (opchg_get_fast_normal_to_warm(chip) == true)) { val->intval = 1; } else { if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) val->intval = 1; else val->intval = 0; } } else { /* [email protected], 2014/02/11 Modify for when no battery gauge present */ if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) val->intval = 1; else val->intval = 0; } #ifdef OPCHARGER_DEBUG_ENABLE pr_debug("oppo_debug dc charging and fast charging sign = %d\n",val->intval); #endif #else if(is_project(OPPO_14005)||is_project(OPPO_14023)||is_project(OPPO_15011)) { if(opchg_get_prop_fast_chg_started(chip) == true) { // in fast charging val->intval = 1; //pr_debug("usb_online= %d,00000 usb_check_inout = %d,vooc_start_step= %d\r\n",val->intval,chip->chg_present,vooc_start_step); } else if(vooc_start_step < OPCHG_VOOC_TO_STANDARD) { // out of fast charging val->intval = 1; //pr_debug("usb_online= %d,1111 usb_check_inout = %d,vooc_start_step= %d\r\n",val->intval,chip->chg_present,vooc_start_step); } else { if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) val->intval = 1; else val->intval = 0; //pr_debug("usb_online= %d,2222 usb_check_inout = %d,vooc_start_step= %d\r\n",val->intval,chip->chg_present,vooc_start_step); } } else { /* [email protected], 2014/02/11 Modify for when no battery gauge present */ if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) val->intval = 1; else val->intval = 0; } #endif /*CONFIG_BATTERY_BQ27541*/ break; case POWER_SUPPLY_PROP_CURRENT_MAX: val->intval = chip->fastchg_current_max_ma * 1000;//chip->maxinput_dc_ma * 1000; break; default: return -EINVAL; } return 0; }
int opchg_battery_get_property(struct power_supply *psy, enum power_supply_property prop, union power_supply_propval *val) { struct opchg_charger *chip = container_of(psy, struct opchg_charger, batt_psy); switch (prop) { case POWER_SUPPLY_PROP_AUTHENTICATE: val->intval = 1; break; case POWER_SUPPLY_PROP_PRESENT: val->intval = chip->bat_exist; break; case POWER_SUPPLY_PROP_TECHNOLOGY: val->intval = POWER_SUPPLY_TECHNOLOGY_LION; break; case POWER_SUPPLY_PROP_CHARGE_NOW: val->intval = chip->charger_vol; //val->intval = opchg_get_prop_charger_voltage_now(chip); break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: val->intval = chip->bat_instant_vol; //val->intval = opchg_get_prop_battery_voltage_now(chip); break; case POWER_SUPPLY_PROP_TEMP: val->intval = chip->temperature; //val->intval = opchg_get_prop_batt_temp(chip); break; case POWER_SUPPLY_PROP_TEMP_STATU: val->intval = chip->charging_opchg_temp_statu; break; case POWER_SUPPLY_PROP_CURRENT_NOW: val->intval = chip->charging_current; //val->intval = opchg_get_prop_current_now(chip); break; case POWER_SUPPLY_PROP_CAPACITY: if(chip->bat_volt_check_point > 100) { val->intval = 100; } else { val->intval =chip->bat_volt_check_point; } break; case POWER_SUPPLY_PROP_CHARGE_TIMEOUT: val->intval = (int)chip->charging_time_out; break; case POWER_SUPPLY_PROP_HEALTH: #if 0 if(is_project(OPPO_14005)) { if(chip->bat_temp_status ==POWER_SUPPLY_HEALTH_WARM) { val->intval = POWER_SUPPLY_HEALTH_GOOD; } else { val->intval = chip->bat_temp_status; } } else { val->intval = chip->bat_temp_status; } #else val->intval = chip->bat_temp_status; #endif break; case POWER_SUPPLY_PROP_ONLINE: // set usb charging sign if((chip->chg_present) && (qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP)) { val->intval = 0; } else { val->intval = chip->chg_present; } #ifdef OPCHARGER_DEBUG_ENABLE pr_debug("oppo_debug usb charging sign = %d\n",val->intval); #endif break; case POWER_SUPPLY_PROP_CHARGING_ENABLED: if( is_project(OPPO_14005)) { if(opchg_get_prop_fast_chg_started(chip) == true) { val->intval = 1; } else { val->intval = chip->is_charging; } } else { val->intval = chip->is_charging; } break; case POWER_SUPPLY_PROP_STATUS: if( is_project(OPPO_14005)) { if(opchg_get_prop_fast_chg_started(chip) == true) { val->intval = POWER_SUPPLY_STATUS_CHARGING; } else { if((opchg_get_prop_fast_switch_to_normal(chip) == true)&&(chip->g_is_vooc_changed == false)) { val->intval = POWER_SUPPLY_STATUS_CHARGING; } else { val->intval = chip->bat_status; } } } else { val->intval = chip->bat_status; } #ifdef OPCHARGER_DEBUG_ENABLE pr_debug("oppo_debug bat_status= %d vooc_start_step= %d\r\n",val->intval,vooc_start_step); #endif break; case POWER_SUPPLY_PROP_CHARGE_TYPE: if( is_project(OPPO_14005)) { if(opchg_get_prop_fast_chg_started(chip) == true) { // in fast charging val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; } else { // in normal charging val->intval = chip->bat_charging_state; } } else { val->intval = chip->bat_charging_state; } break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = "OPCHARGER";//"SMB358"; break; case POWER_SUPPLY_PROP_FAST_CHARGE://wangjc add for fast charger #ifdef OPPO_USE_FAST_CHARGER /* OPPO 2013-12-22 wangjc add for fastchg*/ if( is_project(OPPO_14005)) { chip->fastcharger =opchg_get_prop_fast_chg_started(chip); if(chip->fastcharger == 0) { //if(chip->batt_full == true) if((chip->bat_status == POWER_SUPPLY_STATUS_FULL)|| (chip->batt_hot == true)|| (chip->batt_cold == true) || (chip->batt_voltage_over == true)||(chip->charger_ov_status == true) || (chip->charging_time_out == true)) { chip->fastcharger = 0; } else if((opchg_get_prop_fast_switch_to_normal(chip) == true) || (opchg_get_prop_fast_normal_to_warm(chip) == true) || (opchg_get_fast_low_temp_full(chip) == true)) { chip->fastcharger = 1; } } } else { chip->fastcharger =0; } #else chip->fastcharger =0; #endif val->intval = chip->fastcharger; break; case POWER_SUPPLY_PROP_FAST_CHARGE_PROJECT://wangjc add for fast charger project sign val->intval = chip->fast_charge_project; break; case POWER_SUPPLY_PROP_BATTERY_FCC: //dengnw add for battery fcc if( is_project(OPPO_14005)) { if(bq27541_di == NULL) { val->intval = 100; } else { //val->intval = bq27541_di->full_charge_soc; val->intval = bq27541_di->fcc_pre; } } else { val->intval = 100; } break; case POWER_SUPPLY_PROP_BATTERY_SOH: //dengnw add for battery soh if( is_project(OPPO_14005)) { if(bq27541_di == NULL) { val->intval = 100; } else { //val->intval = bq27541_di->state_of_health; val->intval = bq27541_di->soh_pre; } } else { val->intval = 100; } break; case POWER_SUPPLY_PROP_BATTERY_CC: //dengnw add for battery cc if( is_project(OPPO_14005)) { if(bq27541_di == NULL) { val->intval = 100; } else { //val->intval = bq27541_di->state_of_health; val->intval = bq27541_di->cc_pre; } } else { val->intval = 100; } break; case POWER_SUPPLY_PROP_BATTERY_CHARGER_ENABLE: val->intval = chip->is_factory_mode; break; case POWER_SUPPLY_PROP_BATTERY_NOTIFY: val->intval = chip->batterynotify; #ifdef OPCHARGER_DEBUG_ENABLE pr_debug("oppo_debug batterynotify = 0x%x\r\n",chip->batterynotify); #endif break; case POWER_SUPPLY_PROP_POWER_OFF: val->intval = 0; break; case POWER_SUPPLY_PROP_SHIPPING_MODE: val->intval = chip->shipping_mode; break; default: return -EINVAL; } return 0; }
static void opchg_external_power_changed(struct power_supply *psy) { struct opchg_charger *chip = container_of(psy, struct opchg_charger, batt_psy); union power_supply_propval prop = {0,}; int rc, current_limit = 0, online = 0; if (chip->bms_psy_name) { chip->bms_psy = power_supply_get_by_name((char *)chip->bms_psy_name); } rc = chip->usb_psy->get_property(chip->usb_psy, POWER_SUPPLY_PROP_ONLINE, &prop); if (rc) { dev_err(chip->dev, "Couldn't read USB online property, rc=%d\n", rc); } else { online = prop.intval; } rc = chip->usb_psy->get_property(chip->usb_psy, POWER_SUPPLY_PROP_CURRENT_MAX, &prop); if (rc) { dev_err(chip->dev, "Couldn't read USB current_max property, rc=%d\n", rc); } else { current_limit = prop.intval / 1000; } if(current_limit > chip->limit_current_max_ma) { current_limit = chip->limit_current_max_ma; } //lfc add for charger_ovp chip->charger_vol = opchg_get_prop_charger_voltage_now(chip); opchg_get_charger_ov_status(chip); if(chip->charger_ov_status == true) { dev_err(chip->dev,"%s charger-ovp,return \n",__func__); return ; } opchg_set_enable_volatile_writes(chip); opchg_config_input_chg_current(chip, INPUT_CURRENT_LCD, chip->limit_current_max_ma); opchg_config_input_chg_current(chip, INPUT_CURRENT_CAMERA, chip->limit_current_max_ma); opchg_config_input_chg_current(chip, INPUT_CURRENT_BY_POWER, current_limit); if(is_project(OPPO_14043) || is_project(OPPO_14051) || is_project(OPPO_15005) || is_project(OPPO_15057) || is_project(OPPO_15025)) opchg_set_input_chg_current(chip, chip->max_input_current[INPUT_CURRENT_BY_POWER], false); else opchg_set_input_chg_current(chip, chip->max_input_current[INPUT_CURRENT_MIN], false); if ((chip->multiple_test == 1) && (current_limit >= 500)) { opchg_config_suspend_enable(chip, FACTORY_ENABLE, 1); } opchg_config_over_time(chip, current_limit);//opchg_set_complete_charge_timeout(chip); dev_dbg(chip->dev, "%s set charger input current=%d,online = %d, current_limit = %d\n", __func__,chip->max_input_current[INPUT_CURRENT_MIN], online, current_limit); opchg_check_status(chip); power_supply_changed(&chip->batt_psy); if(is_project(OPPO_14043) || is_project(OPPO_15005) || is_project(OPPO_15025)) { if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) { if(!chip->check_stat_again && (current_limit >= 500) && (chip->charging_current > -250)) { msleep(550); opchg_check_status(chip); chip->check_stat_again = true; power_supply_changed(&chip->batt_psy); } } } }