static int lm3642_probe(struct i2c_client *client,
			       const struct i2c_device_id *devid)
{
	int ret = LM3642_ERROR;
	int tempvalue = LM3642_ERROR;
	
	CDBG("%s : probe start!\n", __func__);

	lm3642_client = client;

	/*device init of gpio init*/
	if ( lm3642_device_init() )
	{
		printk("%s : Device init error!\n", __func__);	
	}
	
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 
	{
		printk("%s : I2C error1!\n", __func__);
		ret = -ENODEV;
	}

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
	{
		printk("%s : I2C error2!\n", __func__);
		ret = -ENODEV;
	}
	
	/* read chip id */
	tempvalue = lm3642_i2c_read(lm3642_client, 0x00);

	if ( FLASH_CHIP_ID == (tempvalue & FLASH_CHIP_ID_MASK) )
	{
		CDBG("%s : Read chip id ok!Chip ID is %d.\n", __func__, tempvalue);
		register_led_set_state(lm3642_set_flash);
		
		#ifdef CONFIG_HUAWEI_HW_DEV_DCT
		/* detect current device successful, set the flag as present */
		set_hw_dev_flag(DEV_I2C_FLASH);
		#endif
		
		CDBG("%s : probe succeed!\n", __func__);
		ret = LM3642_NORMAL;
	} 
	else 
	{
		printk("%s : read chip id error!Chip ID is %d.\n", __func__, tempvalue);
		ret = -ENODEV;
	}

	return ret;
}
Ejemplo n.º 2
0
static int tps61310_probe(struct i2c_client *client,
			       const struct i2c_device_id *devid)
{
	int ret = -1;
	int tempvalue = 0;
	
	printk("tps61310_probe start!\n");

	tps61310_client = client;
	/* GPIO 27 used by BT of some products, we use GPIO 83 instead. */
	if(HW_BT_WAKEUP_GPIO_IS_27 == get_hw_bt_wakeup_gpio_type())
	{
		tps61310_nreset = 83;
	}
	else
	{
		tps61310_nreset = 27;
	}
	/*device init of gpio init*/
	if ( tps61310_device_init()){
		printk("tps61310_device_init error!\n");	
	}
	
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		ret = -ENODEV;
	}

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)){
		ret = -ENODEV;
	}
	
	/* read chip id */
	tempvalue = tps61310_i2c_read(tps61310_client, 0x07);
	if ((tempvalue & 0x07) == 0x06) {
		printk("tps61310 read chip id ok!\n");
		register_led_set_state(tps61310_set_flash);
	} else {
		printk("tps61310 read chip id error!\n");
		/*if probe failed,  free the gpio*/
		gpio_free(tps61310_nreset);
		gpio_free(tps61310_strb0);
		return -ENODEV;
	}

#ifdef CONFIG_HUAWEI_HW_DEV_DCT
	/* detect current device successful, set the flag as present */
	set_hw_dev_flag(DEV_I2C_FLASH);
#endif

	printk("tps61310_probe end!\n");
	return 0;
}