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) { //static kal_uint32 run_hw_init_once_flag=1; kal_uint32 ncp1854_status; kal_uint32 status = STATUS_OK; if (Enable_BATDRV_LOG == 1) { xlog_printk(ANDROID_LOG_INFO, "Power/Battery", "[BATTERY:ncp1854] ChargerHwInit_ncp1854\n" ); } ncp1854_status = ncp1854_get_chip_status(); ncp1854_set_otg_en(0x0); ncp1854_set_trans_en(0); ncp1854_set_tj_warn_opt(0x0);//set at disabled, by MT6325 BATON // ncp1854_set_int_mask(0x0); //disable all interrupt ncp1854_set_int_mask(0x1); //enable all interrupt for boost mode status monitor // ncp1854_set_tchg_rst(0x1); //reset charge timer #ifdef NCP1854_PWR_PATH ncp1854_set_pwr_path(0x1); #else ncp1854_set_pwr_path(0x0); #endif ncp1854_set_chgto_dis(0x1); //disable charge timer if((ncp1854_status == 0x8) || (ncp1854_status == 0x9) || (ncp1854_status == 0xA)) //WEAK WAIT, WEAK SAFE, WEAK CHARGE ncp1854_set_ctrl_vbat(0x1C); //VCHG = 4.0V //if(run_hw_init_once_flag) //{ ncp1854_set_ieoc(0x4); // terminate current = 200mA for ICS optimized suspend power ncp1854_set_iweak(0x3); //weak charge current = 300mA // run_hw_init_once_flag=0; //} ncp1854_set_aicl_en(0x1); //enable AICL as PT team suggest ncp1854_set_iinset_pin_en(0x0); //Input current limit and AICL control by I2C ncp1854_set_ctrl_vfet(0x3); // VFET = 3.4V #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 return status; }
static kal_uint32 charging_hw_init(void *data) { kal_uint32 ncp1854_status; kal_uint32 status = STATUS_OK; if (Enable_BATDRV_LOG == 1) { battery_log(BAT_LOG_CRTI, "[BATTERY:ncp1854] ChargerHwInit_ncp1854\n"); } ncp1854_status = ncp1854_get_chip_status(); upmu_set_rg_bc11_bb_ctrl(1); //BC11_BB_CTRL upmu_set_rg_bc11_rst(1); //BC11_RST ncp1854_set_otg_en(0x0); ncp1854_set_trans_en(0); ncp1854_set_tj_warn_opt(0x1); // ncp1854_set_int_mask(0x0); //disable all interrupt ncp1854_set_int_mask(0x1); //enable all interrupt for boost mode status monitor ncp1854_set_tchg_rst(0x1); //reset charge timer #ifdef NCP1854_PWR_PATH ncp1854_set_pwr_path(0x1); #else ncp1854_set_pwr_path(0x0); #endif if((ncp1854_status == 0x8) || (ncp1854_status == 0x9) || (ncp1854_status == 0xA)) //WEAK WAIT, WEAK SAFE, WEAK CHARGE ncp1854_set_ctrl_vbat(0x1C); //VCHG = 4.0V else if(ncp1854_status == 0x4) ncp1854_set_ctrl_vbat(0x28); //VCHG = 4.3V to decrease charge time else ncp1854_set_ctrl_vbat(0x24); //VCHG = 4.2V ncp1854_set_ieoc(0x4); // terminate current = 200mA for ICS optimized suspend power ncp1854_set_iweak(0x3); //weak charge current = 300mA ncp1854_set_ctrl_vfet(0x3); // VFET = 3.4V return status; }
void mt_usb_set_vbus(struct musb *musb, int is_on) { DBG(0, "mt65xx_usb20_vbus++,is_on=%d\r\n", is_on); #ifndef FPGA_PLATFORM if (is_on) { /* power on VBUS, implement later... */ #ifdef CONFIG_MTK_FAN5405_SUPPORT fan5405_set_opa_mode(1); fan5405_set_otg_pl(1); fan5405_set_otg_en(1); #elif defined(CONFIG_MTK_BQ24261_SUPPORT) bq24261_set_en_boost(1); #elif defined(CONFIG_MTK_BQ24296_SUPPORT) 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); #elif defined(CONFIG_MTK_BQ24196_SUPPORT) bq24196_set_otg_config(0x01); /* OTG */ bq24196_set_boost_lim(0x01); /* 1.3A on VBUS */ #elif defined(CONFIG_MTK_NCP1854_SUPPORT) ncp1854_set_otg_en(0); ncp1854_set_chg_en(0); ncp1854_set_otg_en(1); #else #ifdef CONFIG_OF #if defined(CONFIG_MTK_LEGACY) mt_set_gpio_mode(drvvbus_pin, drvvbus_pin_mode); mt_set_gpio_out(drvvbus_pin, GPIO_OUT_ONE); #else pr_debug("****%s:%d Drive VBUS HIGH KS!!!!!\n", __func__, __LINE__); pinctrl_select_state(pinctrl, pinctrl_drvvbus_high); #endif #else mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN, GPIO_OTG_DRVVBUS_PIN_M_GPIO); mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN, GPIO_OUT_ONE); #endif #endif } else { /* power off VBUS, implement later... */ #ifdef CONFIG_MTK_FAN5405_SUPPORT fan5405_reg_config_interface(0x01, 0x30); fan5405_reg_config_interface(0x02, 0x8e); #elif defined(CONFIG_MTK_BQ24261_SUPPORT) bq24261_set_en_boost(0); #elif defined(CONFIG_MTK_BQ24296_SUPPORT) bq24296_set_otg_config(0); #elif defined(CONFIG_MTK_BQ24196_SUPPORT) bq24196_set_otg_config(0x0); /* OTG disabled */ #elif defined(CONFIG_MTK_NCP1854_SUPPORT) ncp1854_set_otg_en(0x0); #else #ifdef CONFIG_OF #if defined(CONFIG_MTK_LEGACY) mt_set_gpio_mode(drvvbus_pin, drvvbus_pin_mode); mt_set_gpio_out(drvvbus_pin, GPIO_OUT_ZERO); #else pr_debug("****%s:%d Drive VBUS LOW KS!!!!!\n", __func__, __LINE__); pinctrl_select_state(pinctrl, pinctrl_drvvbus_low); #endif #else mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN, GPIO_OTG_DRVVBUS_PIN_M_GPIO); mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN, GPIO_OUT_ZERO); #endif #endif } #endif }