コード例 #1
0
/*
 * al3010 later init function
 */
static int al3010_later_init(struct i2c_client *client){
	int err = 0;

	//+++ limit check al3010 init time
	if( init_check_count > 0){
        init_check_count--;
    }else{
        return -1;
    }
    //---

	if (al3010_get_power_state(client) != 0x01){
		printk("light sensor info : al3010 power off , init in al3010_later_init \n");

		err = al3010_set_power_state(client, 1);
		if(err){
			printk("light sensor err : al3010 set power up err\n");
			return err;
		}

		err = al3010_set_range(client, 1);	//set range to 19000 lux
		if(err){
			printk("light sensor err : al3010 set range err\n");
			return err;
		}
	}

	return err;
}
コード例 #2
0
static int __devexit al3010_remove(struct i2c_client *client)
{
	struct al3010_data *data = i2c_get_clientdata(client);
	misc_deregister(&data->misc_dev);

	sysfs_remove_group(&client->dev.kobj, &al3010_attr_group);
	al3010_set_power_state(client, 0);
	kfree(i2c_get_clientdata(client));
	printk("light sensor info : al3010 remove successed\n");
	return 0;
}
コード例 #3
0
static int al3010_suspend(struct i2c_client *client, pm_message_t mesg)
{
	printk("al3010_suspend+\n");
	int ret = 0;
	struct al3010_data *data = i2c_get_clientdata(client);

	data->power_state_before_suspend = al3010_get_power_state(client);
	al3010_set_power_state(client, 0);
	light_sensor_ready = false;
	catch_first_poll_time = false;
	control_als_cam_2v85(0);	//disable 2V85
	init_check_count = 0;
	printk("al3010_suspend-\n");
	return ret;
}
コード例 #4
0
static int al3010_init_client(struct i2c_client *client)
{
	struct al3010_data *data = i2c_get_clientdata(client);
	int err = 0;
	/* set defaults */
	err = al3010_set_power_state(client, 1);
	if(err){
		printk("light sensor err : al3010 set power up err\n");
		return err;
	}
	err = al3010_set_range(client, 1);	//set range to 19000 lux
	if(err){
		printk("light sensor err : al3010 set range err\n");
		return err;
	}
	//al3010_set_resolution(client, 0);
	//al3010_set_mode(client, 0);

	return 0;
}
コード例 #5
0
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;
}