Esempio n. 1
0
void sp_tx_hardware_powerdown(struct i2c_client *client)
{

	struct anx7808_platform_data *pdata = client->dev.platform_data;
	//return;

	gpio_set_value(pdata->gpio_reset, 0);
	msleep(2);
	//gpio_set_value(pdata->gpio_v10_ctrl, 0);
	sp_tx_hardware_power_set(0);	
	msleep(5);

	gpio_set_value(pdata->gpio_p_dwn, 1);
	msleep(2);


#ifdef CONFIG_EEPROM_NUVOTON
	if (!AX_MicroP_IsP01Connected() || !sp_tx_asus_pad) {
		printk("[myDP] switch to USB\n");		
		gpio_set_value(pdata->gpio_usb_select, 0);
	}
#else	
	printk("[myDP] switch to USB\n");
	gpio_set_value(pdata->gpio_usb_select, 0);
#endif	

	g_i2c_error_count = 0;
	g_tx_recovery_process = 0;

	DEV_DBG("%s: anx7808 power down\n", __func__);
}
Esempio n. 2
0
bool AXC_Gauge_P02_IsBatExisted(struct AXI_Gauge *gauge)
{
//	AXC_Gauge_P02 *this = container_of(gauge, AXC_Gauge_P02, msParentGauge);
#ifdef CONFIG_EEPROM_NUVOTON  //ASUS_BSP Eason_Chang 1120 porting +++
	if (1 == AX_MicroP_IsP01Connected())
		return true;
	else
		return false;
#else//ASUS_BSP Eason_Chang 1120 porting 
        return false;
#endif //CONFIG_EEPROM_NUVOTON//ASUS_BSP Eason_Chang 1120 porting ---
}
int set_als_power_state_of_P01(int state)
{
	int ret = 0, indx;
	/* For resume check Pad power state */
	int microp_state = -1;
	
	printk("[als_P01]set_als_pwr_state: %d\n", state );
	if( !AX_MicroP_IsP01Connected() )	{
		printk("[als_P01]Without P03 plug in\n");
		return -1;		
	}
	
	if( g_al3010_switch_earlysuspend == 1 )	{
		g_al3010_suspend_switch_on = state;
		printk("[als_P01][als] Al3010 without resume, by pass; state:%d\n", g_al3010_switch_earlysuspend);
		return 0;
	}else
		g_al3010_suspend_switch_on = false;

	mutex_lock(&g_al3010_data_as->lock);
	wake_lock_timeout(&pad_lightsensoer_wake_lock, 2*HZ);
	al3010_interrupt_busy = true;

	/*Check microp state before Inital al3010 */
	if(!AX_MicroP_Is_3V3_ON())	{
		printk("[als_P01][als] Bus Suspended: Skip\r\n");
		microp_state = st_MICROP_Sleep;
	}
	else
		microp_state = AX_MicroP_getOPState();
	
	if(microp_state == st_MICROP_Active)	{
		al3010_power_on_retry_time = 0;
		printk(DBGMSK_PRX_G2"[al3010][als] Microp in Active mode\n");
	}
	else	{
		printk("[al3010][als] Microp not in Active mode(%d), retry %d\n", microp_state, al3010_power_on_retry_time);
		al3010_power_on_retry_time++;
		if ( al3010_power_on_retry_time < 10 )	{
			al3010_interrupt_busy = false;
			mutex_unlock(&g_al3010_data_as->lock);
			wake_unlock(&pad_lightsensoer_wake_lock);
			queue_delayed_work(Al3010light_delay_workqueue, &Al3010light_resume_work, 50 );
			return 0;
		}
		else
			printk("[als_P01] set_als_pwr_state retry fail!!(%d)\n", state);
	}
	
	/*Inital al3010*/
	for(indx = 0; indx<5; indx++) {
		ret = al3010_put_property(g_al3010_data_as->client);
		if(!ret)	{
			printk(DBGMSK_PRX_G2"[al3010][als] init al3010 success\n");
			break;
		}else	{
			printk("[al3010][als] init_client error retry = %d\n",indx);
			msleep( 10 );
		}
		if ( indx >= 4 ){
			al3010_interrupt_busy = false;
			mutex_unlock(&g_al3010_data_as->lock);
			wake_unlock(&pad_lightsensoer_wake_lock);
			return ret;
		}
	}

	/*Trun on/off al3010*/
	for(indx = 0; indx<5; indx++) {
		ret = al3010_set_power_state(
			g_al3010_data_as->client, state? AL3010_POW_UP:AL3010_POW_DOWN);
		if(!ret) {
			printk(DBGMSK_PRX_G2"[al3010][als] switch on al3010 success\n");
			break;
		}else
			printk("[al3010][als] i2c error retry = %d\n",indx);
		if (indx >= 4 ) {
			al3010_interrupt_busy = false;
			mutex_unlock(&g_al3010_data_as->lock);
			wake_unlock(&pad_lightsensoer_wake_lock);
			//reportPadStationI2CFail("al3010");
			return ret;
		}
	}
	
	/*Release interrupt trigger*/
	i2c_smbus_read_byte_data(g_al3010_data_as->client, AL3010_ADC_MSB);
	al3010_interrupt_busy = false;
	mutex_unlock(&g_al3010_data_as->lock);
	wake_unlock(&pad_lightsensoer_wake_lock);

	if (state == 1)
		printk(DBGMSK_PRX_G2"[al3010][als] P02 light sensor dev_open\n");
	else
		printk(DBGMSK_PRX_G2"[al3010][als] P02 light sensor dev_close\n");

	queue_delayed_work(Al3010light_delay_workqueue, &al3010_ISR_delay_work, 10);

	return ret;
}