static kal_uint32 charging_hw_init(void *data) { kal_uint32 status = STATUS_OK; static bool charging_init_flag = KAL_FALSE; mt_set_gpio_mode(gpio_number,gpio_on_mode); mt_set_gpio_dir(gpio_number,gpio_on_dir); mt_set_gpio_out(gpio_number,gpio_on_out); #if defined(MTK_WIRELESS_CHARGER_SUPPORT) 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 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); upmu_set_rg_usbdl_rst(1); //force leave USBDL mode #if defined(HIGH_BATTERY_VOLTAGE_SUPPORT) bq24158_config_interface_liao(0x06,0x77); // ISAFE = 1250mA, VSAFE = 4.34V #else bq24158_config_interface_liao(0x06,0x70); #endif bq24158_config_interface_liao(0x00,0xC0); //kick chip watch dog bq24158_config_interface_liao(0x01,0xb8); //TE=1, CE=0, HZ_MODE=0, OPA_MODE=0 bq24158_config_interface_liao(0x05,0x03); bq24158_config_interface_liao(0x04,0x1A); //146mA if ( !charging_init_flag ) { bq24158_config_interface_liao(0x04,0x1A); //146mA charging_init_flag = KAL_TRUE; } 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 MTK_FAN5405_SUPPORT fan5405_set_opa_mode(1); fan5405_set_otg_pl(1); fan5405_set_otg_en(1); #elif defined(MTK_BQ24157_SUPPORT) bq24157_set_opa_mode(1); bq24157_set_otg_pl(1); bq24157_set_otg_en(1); #elif defined(MTK_BQ24158_SUPPORT) bq24158_set_opa_mode(1); bq24158_set_otg_pl(1); bq24158_set_otg_en(1); #elif defined(MTK_NCP1851_SUPPORT) || defined(MTK_BQ24196_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 1); #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 } else { //power off VBUS, implement later... #ifdef MTK_FAN5405_SUPPORT fan5405_config_interface_liao(0x01,0x30); fan5405_config_interface_liao(0x02,0x8e); #elif defined(MTK_BQ24157_SUPPORT) bq24157_config_interface_liao(0x01,0x30); bq24157_config_interface_liao(0x02,0x8e); #elif defined(MTK_BQ24158_SUPPORT) bq24158_config_interface_liao(0x01,0x30); bq24158_config_interface_liao(0x02,0x8e); #elif defined(MTK_NCP1851_SUPPORT) || defined(MTK_BQ24196_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 0); #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 }