Beispiel #1
0
static bool check_battery_vf(void)
{
	int val;
	/*
	 * Prevent charging on batteries were isistor is
	 * less than 5K.
	 */
#if 0
	int ret;
	u8 present_battery;

	ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, &present_battery,
						  TWL6030_REG_SIMCTRL);

	if( present_battery & 0x02 ) {
		printk( KERN_INFO "[TA] Battery is present\n");
		return 1;
	} else {
		printk( KERN_INFO "[TA] Battery is not present\n");
		return 0;
	}
#endif

	val = _get_t2adc_data_(0);

	printk( KERN_INFO "[TA] VF ADC : %d\n", val);

	if (val > 50000)
		return 0;
	return 1;

}
Beispiel #2
0
static int get_charging_current_adc_val( void )
{
    int adc;
    
    adc = _get_t2adc_data_( device_config->CHG_CURRENT_ADC_PORT );

    return adc;
}
Beispiel #3
0
static int get_system_temperature( bool flag )
{
    int adc;
    int temp;
    
    adc = _get_t2adc_data_( device_config->TEMP_ADC_PORT );

    if( flag )
        return adc;

    temp = t2adc_to_temperature( adc, device_config->TEMP_ADC_PORT );

//	return 70;
    return temp;
}
Beispiel #4
0
static int get_system_temperature( bool flag )
// ----------------------------------------------------------------------------
// Description    : 
// Input Argument :  
// Return Value   : 
{
	int adc;
	int temp;
	
	adc = _get_t2adc_data_( device_config->TEMP_ADC_PORT );

	//printk("[BR] TEMP ADC: %d\n", adc);

	if( flag )
		return adc;

	temp = t2adc_to_temperature( adc, device_config->TEMP_ADC_PORT );


	return temp;
}
Beispiel #5
0
static bool check_battery_vf( void )
{
	int count = 0;
	int val;
	bool ret = false;

#if 0
	count = 0;
	disable_charging( CHARGE_DUR_ACTIVE );
	msleep( 100 );
	enable_charging( CHARGE_DUR_ACTIVE );
	val = gpio_get_value( KCHG_ING_GPIO );
	if ( !val )
		return true;
	
	while ( count < 10 )
	{
		if ( !gpio_get_value( KCHG_ING_GPIO ) )
			return true;

		count++;
		msleep( 1 );
	}

	if ( !ret && device_config->VF_CHECK_USING_ADC )
	{
#if 0
		int i;
		int val[5];
		for ( i = 0; i < 5 ; i++ )
		{
			val[i] = _get_t2adc_data_( device_config->VF_ADC_PORT );
		}

		count = _get_average_value_( val, 5 );
#else
		count = _get_t2adc_data_( device_config->VF_ADC_PORT );
#endif
		
		printk("vf: %d\n", count);
		if ( count < 100 )
			return true;
	}
	
	disable_charging( CHARGE_DUR_ACTIVE );
#elif 0
	if ( device_config->VF_CHECK_USING_ADC )
	{
		int i;
		int val[5];
		
		for ( i = 0; i < 5 ; i++ )
		{
			val[i] = _get_t2adc_data_( device_config->VF_ADC_PORT );
			if ( val[i] >= 100 )
			{
				printk( "vf: %d\n", val[i] );
				return false;
			}
			msleep( 100 );
		}

		count = _get_average_value_( val, 5 );
		printk("vf: %d\n", count);
		if ( count < 100 )
			return true;
		
/*		count = _get_t2adc_data_( device_config->VF_ADC_PORT );		
		printk("vf: %d\n", count);
		if ( count < 100 )
			return true;*/
	}
	else
	{
		count = 0;
		disable_charging( CHARGE_DUR_ACTIVE );
		msleep( 100 );
		enable_charging( CHARGE_DUR_ACTIVE );
		val = gpio_get_value( KCHG_ING_GPIO );
		if ( !val )
			return true;
		
		while ( count < 10 )
		{
			if ( !gpio_get_value( KCHG_ING_GPIO ) )
				return true;

			count++;
			msleep( 1 );
		}

		disable_charging( CHARGE_DUR_ACTIVE );

	}
#else
	count = 0;
	disable_charging( CHARGE_DUR_ACTIVE );
	msleep( 100 );
	enable_charging( CHARGE_DUR_ACTIVE );
	val = gpio_get_value( KCHG_ING_GPIO );
	if ( !val )
	{
		ret = true;
	}
	
	while ( count < 10 )
	{
		if ( !gpio_get_value( KCHG_ING_GPIO ) )
		{
			ret = true;
			break;
		}

		count++;
		msleep( 1 );
	}

	disable_charging( CHARGE_DUR_ACTIVE );

	if ( !ret &&  device_config->VF_CHECK_USING_ADC )
	{
		int i;
		int val[5];
		
		for ( i = 0; i < 5 ; i++ )
		{
			val[i] = _get_t2adc_data_( device_config->VF_ADC_PORT );
			msleep( 100 );
		}

		count = _get_average_value_( val, 5 );
		printk("vf: %d\n", count);
		if ( count < 200)
			return true;
	}

#endif
	return ret;
}