// S[, 20120725, [email protected], Enable charging by fake mode. int twl4030_bci_battery_set_property(struct power_supply *psy, enum power_supply_property psp, const union power_supply_propval *val) { int cable_check; struct twl4030_bci_device_info *di; di = to_twl4030_bci_device_info(psy); switch (psp) { case POWER_SUPPLY_PROP_TEMP_CONTROL: printk("[TWL4030] set di->temp_control = %02X ", val->intval); if (val->intval == UNLIMITED_TEMP_VAL) { di->temp_control = val->intval; } else { di->temp_control = 0; } //FIXME: write to nv data. // lge_dynamic_nvdata_write(LGE_NVDATA_DYNAMIC_CHARGING_TEMP_OFFSET, &(di->temp_control), 1); break; default: return -EINVAL; } return 0; }
static void twl4030_bci_battery_external_power_changed(struct power_supply *psy) { struct twl4030_bci_device_info *di = to_twl4030_bci_device_info(psy); cancel_delayed_work(&di->twl4030_bci_monitor_work); schedule_delayed_work(&di->twl4030_bci_monitor_work, 0); }
static int twl4030_bci_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { struct twl4030_bci_device_info *di; int status = 0; di = to_twl4030_bci_device_info(psy); switch (psp) { case POWER_SUPPLY_PROP_STATUS: val->intval = di->charge_status; return 0; default: break; } switch (psp) { case POWER_SUPPLY_PROP_VOLTAGE_NOW: val->intval = di->voltage_uV; break; case POWER_SUPPLY_PROP_CURRENT_NOW: val->intval = di->current_uA; break; case POWER_SUPPLY_PROP_TEMP: val->intval = di->temp_C; break; case POWER_SUPPLY_PROP_ONLINE: status = twl4030bci_status(); if ((status & AC_STATEC) == AC_STATEC) val->intval = POWER_SUPPLY_TYPE_MAINS; else if (usb_charger_flag) val->intval = POWER_SUPPLY_TYPE_USB; else val->intval = 0; break; case POWER_SUPPLY_PROP_CAPACITY: val->intval = twl4030battery_capacity(di); break; default: return -EINVAL; } return 0; }
static int twl4030_bci_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { struct twl4030_bci_device_info *di; #if defined(CONFIG_HUB_MUIC) #else int status = 0; #endif max8922_status chr_ic_status = CHARGING_IC_DEACTIVE; chr_ic_status = get_charging_ic_status(); TYPE_MUIC_MODE muic_mode = MUIC_NONE; di = to_twl4030_bci_device_info(psy); /* switch (psp) { case POWER_SUPPLY_PROP_STATUS: val->intval = di->charge_status; return 0; default: break; } */ switch (psp) { case POWER_SUPPLY_PROP_STATUS: val->intval = di->charge_status; #if 0 //ntyeongon.moon 2011-03-16 full-charge status comes from soc level [START] if(di->voltage_uV > 4190) { // QM Requested for Dummy Battery Test (LGP970) val->intval = POWER_SUPPLY_STATUS_FULL; } #endif //ntyeongon.moon 2011-03-16 full-charge status comes from soc level [END] break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: val->intval = di->voltage_uV; break; case POWER_SUPPLY_PROP_CURRENT_NOW: val->intval = di->current_uA; break; case POWER_SUPPLY_PROP_TEMP: if(di->battery_present == 0) // No Battery or Dummy Battery val->intval = 200; // S[, 20120725, [email protected], Enable charging by fake mode. else if (di->temp_control == UNLIMITED_TEMP_VAL) { if (di->temp_C > UNLIMITED_TEMP_HIGH) val->intval = UNLIMITED_TEMP_HIGH; else if (di->temp_C < UNLIMITED_TEMP_LOW) val->intval = UNLIMITED_TEMP_LOW; else val->intval = di->temp_C; } // E], 20120725, [email protected], Enable charging by fake mode. else val->intval = di->temp_C; break; case POWER_SUPPLY_PROP_ONLINE: #if defined(CONFIG_HUB_MUIC) || defined(CONFIG_MUIC) val->intval = di->charge_rsoc; //2011-03-23 [email protected] get muic INT_STAT VBUS [START_LGE] if(!is_muic_mvbus_on()) val->intval = 0; //2011-03-23 [email protected] get muic INT_STAT VBUSVBUS [END_LGE] break; #else status = twl4030bci_status(); if ((status & AC_STATEC) == AC_STATEC) val->intval = POWER_SUPPLY_TYPE_MAINS; else if (usb_charger_flag) val->intval = POWER_SUPPLY_TYPE_USB; else val->intval = 0; break; #endif // CONFIG_HUB_MUIC case POWER_SUPPLY_PROP_PRESENT: val->intval = di->battery_present; #if defined(CONFIG_HUB_MUIC) muic_mode = get_muic_mode(); if(muic_mode == MUIC_CP_USB || // JIG muic_mode == MUIC_CP_UART || muic_mode == MUIC_AP_UART) { val->intval = 1; } else if(muic_mode == MUIC_NONE) { // Dummy Battery val->intval = 1; } // [email protected] 20120502 MUIC re-work start #elif defined(CONFIG_MUIC) muic_mode = muic_get_mode(); if(muic_mode == MUIC_CP_USB || // JIG muic_mode == MUIC_CP_UART || muic_mode == MUIC_AP_UART && chr_ic_status != CHARGING_IC_DEACTIVE) { val->intval = 1; } else if(muic_mode == MUIC_NONE) { // Dummy Battery val->intval = 1; } #else #error // [email protected] 20120502 MUIC re-work end #endif break; case POWER_SUPPLY_PROP_CAPACITY: #if defined(CONFIG_HUB_MUIC) muic_mode = get_muic_mode(); #elif defined(CONFIG_MUIC) muic_mode = muic_get_mode(); #endif val->intval = di->battery_capacity; printk("[BATTER] cap:%d , muic:%d \n",val->intval, muic_mode); // for Lockscreen sync with status bar #if 0 //ntyeongon.moon 2011-03-16 full-charge status comes from soc level [START] if(di->charge_rsoc == POWER_SUPPLY_TYPE_MAINS || di->charge_rsoc == POWER_SUPPLY_TYPE_USB) { // When Charging Mode if(di->charge_status == POWER_SUPPLY_STATUS_FULL) { val->intval = 100; } else if(di->battery_present == 1 && // Battery Present and not Full val->intval == 100) { // but battery level is 100% val->intval = 99; // view as 99% for lockscreen } else if(di->voltage_uV > 4190) { // QM Requested for Dummy Battery Test (LGP970) val->intval = 100; } } #endif //ntyeongon.moon 2011-03-16 full-charge status comes from soc level [END] break; /* FIXME : It depends on H/W specific */ case POWER_SUPPLY_PROP_HEALTH: if(!di->battery_present) val->intval = POWER_SUPPLY_HEALTH_UNKNOWN; else if(di->voltage_uV > 5000) // Over voltage val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; else if(di->temp_C < TEMP_CRITICAL_LOWER) // Cold val->intval = POWER_SUPPLY_HEALTH_COLD; else if(di->temp_C > TEMP_CRITICAL_UPPER) // Hot val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; else val->intval = POWER_SUPPLY_HEALTH_GOOD; break; case POWER_SUPPLY_PROP_TECHNOLOGY: val->intval = POWER_SUPPLY_TECHNOLOGY_LION; // Fixed value : Li-ion break; // S[, 20120725, [email protected], Enable charging by fake mode. case POWER_SUPPLY_PROP_TEMP_CONTROL: //#ifdef CONFIG_MACH_LGE_CX2 // <-- not defined. // lge_dynamic_nvdata_read(LGE_NVDATA_DYNAMIC_CHARGING_TEMP_OFFSET, &temp_val, 1); // // val->intval = (int)temp_val; //#else val->intval = (int)di->temp_control; //#endif break; // E], 20120725, [email protected], Enable charging by fake mode. default: return -EINVAL; } return 0; }