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);

       bc11_set_register_value(PMIC_RG_USBDL_SET,0x0);//force leave USBDL mode
       bc11_set_register_value(PMIC_RG_USBDL_RST,0x1);//force leave USBDL mode

   
	#if defined(HIGH_BATTERY_VOLTAGE_SUPPORT)
	fan5405_reg_config_interface(0x06,0x77); // ISAFE = 1250mA, VSAFE = 4.34V
	#else
	fan5405_reg_config_interface(0x06,0x70);
	#endif
	    
	fan5405_reg_config_interface(0x00,0xC0);	//kick chip watch dog
	fan5405_reg_config_interface(0x01,0xb8);	//TE=1, CE=0, HZ_MODE=0, OPA_MODE=0
	fan5405_reg_config_interface(0x05,0x03);
	if ( !charging_init_flag ) {   
		fan5405_reg_config_interface(0x04,0x1A); //146mA
		charging_init_flag = KAL_TRUE;
	}        
 	return status;
 }
Exemplo n.º 2
0
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_BQ24158_SUPPORT)
        bq24158_set_opa_mode(1);
        bq24158_set_otg_pl(1);
        bq24158_set_otg_en(1);
    #elif defined(CONFIG_MTK_NCP1851_SUPPORT) || defined(CONFIG_MTK_BQ24196_SUPPORT) || defined(MTK_BQ24296_SUPPORT) || defined(MTK_NCP1854_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 CONFIG_MTK_FAN5405_SUPPORT
        fan5405_reg_config_interface(0x01,0x30);
        fan5405_reg_config_interface(0x02,0x8e);
    #elif defined(CONFIG_MTK_BQ24158_SUPPORT)		
        bq24158_config_interface_liao(0x01,0x30);
		bq24158_config_interface_liao(0x02,0x8e);
    #elif defined(CONFIG_MTK_NCP1851_SUPPORT) || defined(CONFIG_MTK_BQ24196_SUPPORT) || defined(MTK_BQ24296_SUPPORT) || defined(MTK_NCP1854_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
}
Exemplo n.º 3
0
 static kal_uint32 charging_hw_init(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	static bool charging_init_flag = KAL_FALSE;
#ifdef USING_TFA9890_EXTAMP
  printk("[LHJ_TFA9890][%s][L%d]Tfa9890 found:%d",__func__,__LINE__,Tfa9890_IsFound());
  if(Tfa9890_IsFound())
  {
      //gpio_number = GPIO15;
  }
  else
  {
       gpio_number = GPIO19;
  }
#endif

	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);

	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_set(0);       //force leave USBDL mode
	upmu_set_rg_usbdl_rst(1);		//force leave USBDL mode
   
	#if defined(HIGH_BATTERY_VOLTAGE_SUPPORT)
	fan5405_reg_config_interface(0x06,0x67);//modify by lifeng for zhangshouchuang request // ISAFE = 1250mA, VSAFE = 4.34V
	#else
	fan5405_reg_config_interface(0x06,0x70);
	#endif
	    
	fan5405_reg_config_interface(0x00,0xC0);	//kick chip watch dog
	fan5405_reg_config_interface(0x01,0xC8);//0xF8	
	fan5405_reg_config_interface(0x02,0xAA);//4.34V
// 苏 勇 2014年05月20日 15:55:09	fan5405_reg_config_interface(0x02,0xae);//4.36V
	//fan5405_reg_config_interface(0x04,0x78); //set IOCHARGE 1000MA
// 苏 勇 2014年05月19日 17:59:16	fan5405_reg_config_interface(0x04,0x7D); //修改截止充电电流为200ma
	fan5405_reg_config_interface(0x04,0x7a); //修改截止充电电流为9.9/82=120.7ma
	fan5405_reg_config_interface(0x05,0x04);//VSP=4.533v
	if ( !charging_init_flag ) {   
       // fan5405_config_interface_liao(0x04,0x1A); //146mA
		charging_init_flag = KAL_TRUE;
	}        
 	return status;
 }
Exemplo n.º 4
0
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
}