Example #1
0
void pchr_turn_on_charging (void)
{
	upmu_set_rg_usbdl_set(0);        //force leave USBDL mode
	upmu_set_rg_usbdl_rst(1);		//force leave USBDL mode
	
	kick_charger_wdt();
	
	upmu_set_rg_cs_vth(0xC);    	// CS_VTH, 450mA            
	upmu_set_rg_csdac_en(1);                // CSDAC_EN
	upmu_set_rg_chr_en(1);                  // CHR_EN  

#ifdef MTK_FAN5405_SUPPORT
	fan5405_hw_init();
	fan5405_turn_on_charging();
	fan5405_dump_register();
#endif

#ifdef MTK_BQ24196_SUPPORT
	bq24196_hw_init();
	bq24196_charging_enable(0);  //disable charging with power path
	bq24196_dump_register();
#endif
#ifdef MTK_BQ24158_SUPPORT
    bq24158_hw_init();
    bq24158_turn_on_charging();
    bq24158_dump_register();
#endif

}
Example #2
0
 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_log(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,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;
 }
Example #3
0
 static kal_uint32 charging_hw_init(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	
   	upmu_set_rg_chrwdt_td(0x0);           // CHRWDT_TD, 4s
    upmu_set_rg_chrwdt_int_en(1);         // CHRWDT_INT_EN
    upmu_set_rg_chrwdt_en(1);             // CHRWDT_EN
    upmu_set_rg_chrwdt_wr(1);             // CHRWDT_WR

    upmu_set_rg_vcdt_mode(0);       //VCDT_MODE
    upmu_set_rg_vcdt_hv_en(1);      //VCDT_HV_EN    

	upmu_set_rg_usbdl_rst(1);		//force leave USBDL mode

    upmu_set_rg_bc11_bb_ctrl(1);    //BC11_BB_CTRL
    upmu_set_rg_bc11_rst(1);        //BC11_RST
    
    upmu_set_rg_csdac_mode(1);      //CSDAC_MODE
    upmu_set_rg_vbat_ov_en(1);      //VBAT_OV_EN
#ifdef HIGH_BATTERY_VOLTAGE_SUPPORT
	upmu_set_rg_vbat_ov_vth(0x2);   //VBAT_OV_VTH, 4.4V,
#else
    upmu_set_rg_vbat_ov_vth(0x1);   //VBAT_OV_VTH, 4.3V,
#endif
    upmu_set_rg_baton_en(1);        //BATON_EN

    //Tim, for TBAT
    //upmu_set_rg_buf_pwd_b(1);       //RG_BUF_PWD_B
    upmu_set_rg_baton_ht_en(0);     //BATON_HT_EN
    
    upmu_set_rg_ulc_det_en(1);      // RG_ULC_DET_EN=1
    upmu_set_rg_low_ich_db(1);      // RG_LOW_ICH_DB=000001'b

	return status;
 }
 static kal_uint32 charging_hw_init(void *data)
 {
 	kal_uint32 status = STATUS_OK;

	upmu_set_rg_usbdl_rst(1);		//force leave USBDL mode

 	return status;
 }
 static kal_uint32 charging_hw_init(void *data)
 {
 	kal_uint32 status = STATUS_OK;

	//CE PORT
	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);

/* Begin lenovo-sw chailu1 delet 2014-05-06, bq24250 dose not use this gpio */
#if 0
	//PSEL PORT
	mt_set_gpio_mode(gpio_psel_number,gpio_on_mode);  
    mt_set_gpio_dir(gpio_psel_number,gpio_on_dir);
    mt_set_gpio_out(gpio_psel_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);
    battery_xlog_printk(BAT_LOG_FULL, "gpio_number=0x%x,gpio_on_mode=%d,gpio_off_mode=%d\n", gpio_psel_number, gpio_on_mode, gpio_off_mode);
#endif
/* Begin lenovo-sw chailu1 delet 2014-05-06, bq24250 dose not use this gpio */

	upmu_set_rg_usbdl_rst(1);		//force leave USBDL mode
   
	#if defined(HIGH_BATTERY_VOLTAGE_SUPPORT)
        //fan5405_config_interface_liao(0x06,0x77); // ISAFE = 1250mA, VSAFE = 4.34V
		//bq24250_set_vindpm(0x6);
//lenovo_sw liaohj modify 2014-04-15
		bq24250_set_vreg(0x2b);
    #else
        //fan5405_config_interface_liao(0x06,0x70);
		//bq24250_set_vindpm();
//lenovo_sw liaohj modify 2014-04-15
		bq24250_set_vreg(0x23);
	#endif
	
	bq24250_set_wdt_rst();
	//bq24250_set_term_stat(0);
/*lenovo-sw weiweij modified for changing input current to 3A*/	
#ifdef LENOVO_BQ24250_CHG_CUR_DET
	bq24250_set_iinlim(0x06);
#else
	bq24250_set_iinlim(0x07);
#endif
/*lenovo-sw weiweij modified for changing input current to 3A end*/
	bq24250_set_en_hiz(0);
	bq24250_set_en_term(1);
	bq24250_set_iterm(4);
	//lenovo_sw liaohj add 2014-04-15
	bq24250_set_vin_dpm(4);
	//bq24250_set_res_ir(7);
	//bq24250_set_vol_ir(7);

	//bq24250_set_treg(3);
	//bq24250_set_boost_lim(0);	
	
 	return status;
 }
/* Charger Control Interface Handler */
static kal_uint32 charging_hw_init(void *data)
{
	static int hw_initialized = 0;

	if (hw_initialized)
		return STATUS_OK;

	upmu_set_rg_usbdl_set(0);       //force leave USBDL mode
	upmu_set_rg_usbdl_rst(1);	//force leave USBDL mode

	hw_initialized = 1;
	battery_xlog_printk(BAT_LOG_FULL, "[PowerSupply] initialized.\n");

	return STATUS_OK;
}
 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;
 }
 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);

    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

    fan5402_reg_config_interface(0x00,0xC0);	//kick chip watch dog
    fan5402_reg_config_interface(0x01,0xb8);	//TE=1, CE=0, HZ_MODE=0, OPA_MODE=0
    if ( !charging_init_flag ) {    
        fan5402_reg_config_interface(0x04,0x1A); //146mA
        charging_init_flag = KAL_TRUE;
        
    }
	        
 	return status;
 }