/* Charging power state initialization */ int charger_post_init(void) { int rv; int option; rv = charger_get_option(&option); if (rv) return rv; /* Don't be noisy */ option |= OPT_AUDIO_FREQ_40KHZ_LIMIT; /* Always monitor adapter current (40X multiplier). */ option |= OPT_FIX_IOUT_ALWAYS; option &= ~OPT_IOUT_MASK; option &= ~OPT_LEARN_MASK; /* Enable dynamic power management */ option |= OPT_IDPM_ENABLE; rv = charger_set_option(option); if (rv) return rv; rv = charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT); return rv; }
/* Charging power state initialization */ int charger_post_init(void) { int rv, option; #ifdef CONFIG_CHARGER_ILIM_PIN_DISABLED int option2; #endif rv = charger_get_option(&option); if (rv) return rv; option &= ~OPTION0_LEARN_ENABLE; rv = charger_set_option(option); if (rv) return rv; #ifndef BOARD_SAMUS /* Turn off PROCHOT warning */ rv = raw_read16(REG_PROCHOT_OPTION1, &option); if (rv) return rv; option &= ~PROCHOT_OPTION1_SELECTOR_MASK; rv = raw_write16(REG_PROCHOT_OPTION1, option); #else /* On Samus, use PROCHOT warning to detect charging problems */ /* Turn on PROCHOT warning */ rv = raw_write16(REG_PROCHOT_OPTION1, 0x8120); /* Set PROCHOT ICRIT warning when IADP is >120% of IDPM */ rv |= raw_write16(REG_PROCHOT_OPTION0, 0x1b54); #endif if (rv) return rv; #ifdef CONFIG_CHARGER_ILIM_PIN_DISABLED /* Read the external ILIM pin enabled flag. */ rv = raw_read16(REG_CHARGE_OPTION2, &option2); if (rv) return rv; /* Set ILIM pin disabled if it is currently enabled. */ if (option2 & OPTION2_EN_EXTILIM) { option2 &= ~OPTION2_EN_EXTILIM; rv = raw_write16(REG_CHARGE_OPTION2, option2); } return rv; #else return EC_SUCCESS; #endif }
int charger_set_mode(int mode) { int rv; int option; rv = charger_get_option(&option); if (rv) return rv; if (mode & CHARGE_FLAG_INHIBIT_CHARGE) option |= OPTION_CHARGE_INHIBIT; else option &= ~OPTION_CHARGE_INHIBIT; return charger_set_option(option); }
int charger_discharge_on_ac(int enable) { int rv; int option; rv = charger_get_option(&option); if (rv) return rv; if (enable) rv = charger_set_option(option | OPTION_LEARN_ENABLE); else rv = charger_set_option(option & ~OPTION_LEARN_ENABLE); return rv; }
int charger_set_mode(int mode) { int rv; int option; rv = charger_get_option(&option); if (rv) return rv; option &= ~OPT_CHARGE_INHIBIT_MASK; if (mode & CHARGE_FLAG_INHIBIT_CHARGE) option |= OPT_CHARGE_DISABLE; else option |= OPT_CHARGE_ENABLE; return charger_set_option(option); }
int charger_get_status(int *status) { int rv; int option; rv = charger_get_option(&option); if (rv) return rv; /* Default status */ *status = CHARGER_LEVEL_2; if (option & OPTION_CHARGE_INHIBIT) *status |= CHARGER_CHARGE_INHIBITED; return EC_SUCCESS; }
int charger_discharge_on_ac(int enable) { int rv; int option; rv = charger_get_option(&option); if (rv) return rv; option &= ~OPT_LEARN_MASK; if (enable) option |= OPT_LEARN_ENABLE; else option |= OPT_LEARN_DISABLE; rv = charger_set_option(option); return rv; }
/* Charging power state initialization */ int charger_post_init(void) { /* * Note: bq24735 power on reset state is: * watch dog timer = 175 sec * input current limit = ~1/2 maximum setting * charging voltage = 0 mV * charging current = 0 mA */ int rv, option; rv = charger_get_option(&option); if (rv) return rv; option &= ~OPTION_LEARN_ENABLE; rv = charger_set_option(option); if (rv) return rv; /* Set charger input current limit */ return charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT); }