static kal_uint32 charging_enable(void *data) { kal_uint32 status = STATUS_OK; kal_uint32 enable = *(kal_uint32*)(data); if(KAL_TRUE == enable) { bq24196_set_en_hiz(0x0); bq24196_set_chg_config(0x1); // charger enable } else { #if defined(CONFIG_USB_MTK_HDRC_HCD) if(mt_usb_is_device()) #endif { bq24196_set_chg_config(0x0); if (charging_get_error_state()) { battery_log(BAT_LOG_CRTI, "[charging_enable] bq24196_set_hz_mode(0x1)\n"); bq24196_set_en_hiz(0x1); // disable power path } } #if defined(CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT) bq24196_set_chg_config(0x0); bq24196_set_en_hiz(0x1); // disable power path #endif } return status; }
// ============================================================ // static kal_uint32 charging_hw_init_bq24196(void *data) { kal_uint32 status = STATUS_OK; upmu_set_rg_bc11_bb_ctrl(1); //BC11_BB_CTRL upmu_set_rg_bc11_rst(1); //BC11_RST bq24196_set_en_hiz(0x0); bq24196_set_vindpm(0xA); //VIN DPM check 4.68V bq24196_set_reg_rst(0x0); bq24196_set_wdt_rst(0x1); //Kick watchdog bq24196_set_sys_min(0x5); //Minimum system voltage 3.5V bq24196_set_iprechg(0x3); //Precharge current 512mA bq24196_set_iterm(0x0); //Termination current 128mA bq24196_set_vreg(0x2C); //VREG 4.208V bq24196_set_batlowv(0x1); //BATLOWV 3.0V bq24196_set_vrechg(0x0); //VRECHG 0.1V (4.108V) bq24196_set_en_term(0x1); //Enable termination bq24196_set_term_stat(0x0); //Match ITERM bq24196_set_watchdog(0x1); //WDT 40s bq24196_set_en_timer(0x0); //Disable charge timer bq24196_set_int_mask(0x0); //Disable fault interrupt return status; }
void tbl_charger_otg_vbus(int mode) { xlog_printk(ANDROID_LOG_INFO, "Power/Battery", "[tbl_charger_otg_vbus] mode = %d\n", mode); if(mode&0xFF) { #ifdef CONFIG_MTK_BQ24196_SUPPORT bq24196_set_chg_config(0x3); //OTG bq24196_set_boost_lim(0x1); //1.3A on VBUS bq24196_set_en_hiz(0x0); #endif #ifdef CONFIG_MTK_BQ24297_SUPPORT bq24297_set_otg_config(0x1); //OTG bq24297_set_boost_lim(0x1); //1.5A on VBUS bq24297_set_en_hiz(0x0); #endif #ifdef MTK_BQ24296_SUPPORT bq24296_set_chg_config(0x0); //disable charge bq24296_set_otg_config(0x1); //OTG bq24296_set_boostv(0x7); //boost voltage 4.998V bq24296_set_boost_lim(0x1); //1.5A on VBUS bq24296_set_en_hiz(0x0); #endif #ifdef CONFIG_MTK_NCP1851_SUPPORT ncp1851_set_chg_en(0x0); //charger disable ncp1851_set_otg_en(0x1); //otg enable #endif #ifdef MTK_NCP1854_SUPPORT ncp1854_set_chg_en(0x0); //charger disable ncp1854_set_otg_en(0x1); //otg enable #endif } else { #ifdef CONFIG_MTK_BQ24196_SUPPORT bq24196_set_chg_config(0x0); //OTG & Charge disabled #endif #ifdef CONFIG_MTK_BQ24297_SUPPORT bq24297_set_otg_config(0x0); //OTG & Charge disabled #endif #ifdef MTK_BQ24296_SUPPORT bq24296_set_otg_config(0x0); //OTG disabled bq24296_set_chg_config(0x0); //Charge disabled #endif #ifdef CONFIG_MTK_NCP1851_SUPPORT ncp1851_set_otg_en(0x0); #endif #ifdef MTK_NCP1854_SUPPORT ncp1854_set_otg_en(0x0); #endif } };
static kal_uint32 charging_hw_init(void *data) { kal_uint32 status = STATUS_OK; upmu_set_rg_bc11_bb_ctrl(1); //BC11_BB_CTRL upmu_set_rg_bc11_rst(1); //BC11_RST #if 0 //no use //pull PSEL low mt_set_gpio_mode(GPIO_CHR_PSEL_PIN,GPIO_MODE_GPIO); mt_set_gpio_dir(GPIO_CHR_PSEL_PIN,GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CHR_PSEL_PIN,GPIO_OUT_ZERO); #endif //pull CE low mt_set_gpio_mode(GPIO_SWCHARGER_EN_PIN,GPIO_MODE_GPIO); mt_set_gpio_dir(GPIO_SWCHARGER_EN_PIN,GPIO_DIR_OUT); mt_set_gpio_out(GPIO_SWCHARGER_EN_PIN,GPIO_OUT_ZERO); //battery_xlog_printk(BAT_LOG_FULL, "gpio_number=0x%x,gpio_on_mode=%d,gpio_off_mode=%d\n", gpio_number, gpio_on_mode, gpio_off_mode); bq24196_set_en_hiz(0x0); if (get_usb_current_unlimited()) { bq24196_set_vindpm(0x7); //VIN DPM check 4.44V battery_xlog_printk(BAT_LOG_CRTI, "[charging_hw_init] VIN DPM check 4.44V\n"); }else{ bq24196_set_vindpm(0xA); //VIN DPM check 4.68V } bq24196_set_reg_rst(0x0); bq24196_set_wdt_rst(0x1); //Kick watchdog bq24196_set_sys_min(0x5); //Minimum system voltage 3.5V bq24196_set_iprechg(0x3); //Precharge current 512mA bq24196_set_iterm(0x0); //Termination current 128mA bq24196_set_batlowv(0x1); //BATLOWV 3.0V bq24196_set_vrechg(0x0); //VRECHG 0.1V (4.108V) bq24196_set_en_term(0x1); //Enable termination bq24196_set_term_stat(0x0); //Match ITERM bq24196_set_watchdog(0x1); //WDT 40s bq24196_set_en_timer(0x0); //Disable charge timer bq24196_set_int_mask(0x0); //Disable fault interrupt return status; }
static kal_uint32 charging_hw_init(void *data) { kal_uint32 status = STATUS_OK; bq24196_set_en_hiz(0x0); bq24196_set_vindpm(0xA); //VIN DPM check 4.68V bq24196_set_reg_rst(0x0); bq24196_set_wdt_rst(0x1); //Kick watchdog bq24196_set_sys_min(0x5); //Minimum system voltage 3.5V bq24196_set_iprechg(0x3); //Precharge current 512mA bq24196_set_iterm(0x0); //Termination current 128mA #if defined(HIGH_BATTERY_VOLTAGE_SUPPORT) bq24196_set_vreg(0x32); //VREG 4.304V #else bq24196_set_vreg(0x2C); //VREG 4.208V #endif bq24196_set_batlowv(0x1); //BATLOWV 3.0V bq24196_set_vrechg(0x0); //VRECHG 0.1V (4.108V) bq24196_set_en_term(0x1); //Enable termination bq24196_set_term_stat(0x0); //Match ITERM bq24196_set_watchdog(0x1); //WDT 40s bq24196_set_en_timer(0x0); //Disable charge timer bq24196_set_int_mask(0x0); //Disable fault interrupt #if defined(MTK_WIRELESS_CHARGER_SUPPORT) if(wireless_charger_gpio_number!=0) { mt_set_gpio_mode(wireless_charger_gpio_number,0); // 0:GPIO mode mt_set_gpio_dir(wireless_charger_gpio_number,0); // 0: input, 1: output } #endif #ifdef CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT mt_set_gpio_mode(vin_sel_gpio_number,0); // 0:GPIO mode mt_set_gpio_dir(vin_sel_gpio_number,0); // 0: input, 1: output #endif return status; }
static kal_uint32 charging_enable_bq24196(void *data) { kal_uint32 status = STATUS_OK; kal_uint32 enable = *(kal_uint32*)(data); if(KAL_TRUE == enable) { bq24196_set_en_hiz(0x0); bq24196_set_chg_config(0x1); // charger enable } else { #if defined(CONFIG_USB_MTK_HDRC_HCD) if(mt_usb_is_device()) #endif { bq24196_set_chg_config(0x0); } } return status; }