static int gta02_udc_vbus_status(void) { struct pcf50633 *pcf = gta02_pcf; if (!gta02_pcf) return -ENODEV; return !!(pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ONLINE); }
static int iphone_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { int charging = 0; int status = 0; if(pcf50633 && platform_get_drvdata(pcf50633->mbc_pdev)) { status = pcf50633_mbc_get_status(pcf50633); charging = (status & (PCF50633_MBC_USB_ONLINE | PCF50633_MBC_ADAPTER_ONLINE)) != 0; } else dev_err(pcf50633->dev, "failed to contact mbc for charging state.\n"); dev_info(pcf50633->dev, "status: %d, charging: %d.\n", status, charging); switch (psp) { case POWER_SUPPLY_PROP_STATUS: if(charging) { if(iphone_battery_info.level == 100) val->intval = POWER_SUPPLY_STATUS_FULL; else val->intval = POWER_SUPPLY_STATUS_CHARGING; } else { val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; } break; case POWER_SUPPLY_PROP_HEALTH: val->intval = POWER_SUPPLY_HEALTH_GOOD; /* TODO: we might need to set POWER_SUPPLY_HEALTH_OVERHEAT if we figure out the battery temperature stuff */ break; case POWER_SUPPLY_PROP_PRESENT: val->intval = (iphone_battery_info.voltage > 0) ? 1: 0; break; case POWER_SUPPLY_PROP_TECHNOLOGY: val->intval = POWER_SUPPLY_TECHNOLOGY_LION; break; case POWER_SUPPLY_PROP_CAPACITY: val->intval = iphone_battery_info.level; break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: val->intval = iphone_battery_info.voltage * 1000; break; default: return -EINVAL; } return 0; }
static int gta02_get_charger_active_status(void) { struct pcf50633 *pcf = gta02_pcf; return pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ACTIVE; }
static int gta02_get_charger_online_status(void) { struct pcf50633 *pcf = gta02_pcf; return pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ONLINE; }