int power_init_board(void) { int chrg, ret; struct power_battery *pb; struct pmic *p_fg, *p_chrg, *p_muic, *p_bat; /* * For PMIC/MUIC the I2C bus is named as I2C5, but it is connected * to logical I2C adapter 0 * * The FUEL_GAUGE is marked as I2C9 on the schematic, but connected * to logical I2C adapter 1 */ ret = pmic_init(I2C_5); ret |= pmic_init_max8997(); ret |= power_fg_init(I2C_9); ret |= power_muic_init(I2C_5); ret |= power_bat_init(0); if (ret) return ret; p_fg = pmic_get("MAX17042_FG"); if (!p_fg) { puts("MAX17042_FG: Not found\n"); return -ENODEV; } p_chrg = pmic_get("MAX8997_PMIC"); if (!p_chrg) { puts("MAX8997_PMIC: Not found\n"); return -ENODEV; } p_muic = pmic_get("MAX8997_MUIC"); if (!p_muic) { puts("MAX8997_MUIC: Not found\n"); return -ENODEV; } p_bat = pmic_get("BAT_TRATS"); if (!p_bat) { puts("BAT_TRATS: Not found\n"); return -ENODEV; } p_fg->parent = p_bat; p_chrg->parent = p_bat; p_muic->parent = p_bat; p_bat->low_power_mode = trats_low_power_mode; p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic); pb = p_bat->pbat; chrg = p_muic->chrg->chrg_type(p_muic); debug("CHARGER TYPE: %d\n", chrg); if (!p_chrg->chrg->chrg_bat_present(p_chrg)) { puts("No battery detected\n"); return -1; } p_fg->fg->fg_battery_check(p_fg, p_bat); if (pb->bat->state == CHARGE && chrg == CHARGER_USB) puts("CHARGE Battery !\n"); return 0; }
int power_init_board(void) { int chrg, ret; struct power_battery *pb; struct pmic *p_fg, *p_chrg, *p_muic, *p_bat; ret = pmic_init(I2C_5); ret |= pmic_init_max8997(); ret |= power_fg_init(I2C_9); ret |= power_muic_init(I2C_5); ret |= power_bat_init(0); if (ret) return ret; p_fg = pmic_get("MAX17042_FG"); if (!p_fg) { puts("MAX17042_FG: Not found\n"); return -ENODEV; } p_chrg = pmic_get("MAX8997_PMIC"); if (!p_chrg) { puts("MAX8997_PMIC: Not found\n"); return -ENODEV; } p_muic = pmic_get("MAX8997_MUIC"); if (!p_muic) { puts("MAX8997_MUIC: Not found\n"); return -ENODEV; } p_bat = pmic_get("BAT_TRATS"); if (!p_bat) { puts("BAT_TRATS: Not found\n"); return -ENODEV; } p_fg->parent = p_bat; p_chrg->parent = p_bat; p_muic->parent = p_bat; p_bat->low_power_mode = trats_low_power_mode; p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic); pb = p_bat->pbat; chrg = p_muic->chrg->chrg_type(p_muic); debug("CHARGER TYPE: %d\n", chrg); if (!p_chrg->chrg->chrg_bat_present(p_chrg)) { puts("No battery detected\n"); return -1; } p_fg->fg->fg_battery_check(p_fg, p_bat); if (pb->bat->state == CHARGE && chrg == CHARGER_USB) puts("CHARGE Battery !\n"); return 0; }