static kal_uint32 charging_enable(void *data) { kal_uint32 status = STATUS_OK; kal_uint32 enable = *(kal_uint32*)(data); if(KAL_TRUE == enable) { ncp1854_set_chg_en(0x1); // charger enable //Set SPM = 1 #ifdef GPIO_SWCHARGER_EN_PIN mt_set_gpio_mode(GPIO_SWCHARGER_EN_PIN, GPIO_MODE_00); mt_set_gpio_dir(GPIO_SWCHARGER_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_SWCHARGER_EN_PIN, GPIO_OUT_ONE); #endif } else { #if defined(CONFIG_USB_MTK_HDRC_HCD) if(mt_usb_is_device()) #endif { ncp1854_set_chg_en(0x0); // charger disable } } return status; }
static kal_uint32 charging_enable(void *data) { kal_uint32 status = STATUS_OK; kal_uint32 enable = *(kal_uint32*)(data); if(KAL_TRUE == enable) { ncp1854_set_chg_en(0x1); // charger enable //Set SPM = 1 mt_set_gpio_mode(GPIO_CHR_SPM_PIN, GPIO_MODE_00); mt_set_gpio_dir(GPIO_CHR_SPM_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CHR_SPM_PIN, GPIO_OUT_ONE); } else { #if defined(CONFIG_USB_MTK_HDRC_HCD) if(mt_usb_is_device()) #endif { if(charging_get_error_state()) { ncp1854_set_chg_en(0x0); // charger disable battery_log(BAT_LOG_CRTI,"[charging_enable] ncp1854_set_pwr_path(0)\n"); ncp1854_set_pwr_path(0); // disable power path } } } return status; }
void lenovo_charging_term_reset_to_stage_2(void) { int en = KAL_TRUE; lenovo_charging_term_set_stage_2(); ncp1854_set_chg_en(0x0); msleep(10); charging_hw_init(&en); ncp1854_set_chg_en(0x1); }
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 } };
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 }