byte I2C_ReadByte(byte deviceID, byte offset)
{
    	byte number = 0;
	struct i2c_client* client_ptr = get_sii9234_client(deviceID);
	if(!client_ptr)
	{
		printk("[MHL]I2C_ReadByte error %x\n",deviceID); 
		return 0;	
	}

	EXIT_ON_CABLE_DISCONNECTION;
  
  	if(deviceID == 0x72)
		number = SII9234_i2c_read(client_ptr,offset);
	else if(deviceID == 0x7A)
		number = SII9234_i2c_read(client_ptr,offset);
	else if(deviceID == 0x92)
		number = SII9234_i2c_read(client_ptr,offset);
	else if(deviceID == 0xC8)
		number = SII9234_i2c_read(client_ptr,offset);

		if (number < 0)
	{
		printk("I2C_ReadByte: Device ID=0x%X, Err ret = %d \n", deviceID, number);
	}

    return (number);

}
Exemple #2
0
static int SII9234B_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	//SII_DEV_DBG("");

	struct SII9234_state *state;

	state = kzalloc(sizeof(struct SII9234_state), GFP_KERNEL);
	if (state == NULL) {		
		printk("failed to allocate memory \n");
		return -ENOMEM;
	}
	
	state->client = client;
	i2c_set_clientdata(client, state);
	
	/* rest of the initialisation goes here. */
	
	printk("SII9234B attach success!!!\n");

	SII9234B_i2c_client = client;

	SII9234B_i2cprobe_status = 1;
	if(( SII9234_i2cprobe_status == 1) && ( SII9234A_i2cprobe_status == 1) 
		&& ( SII9234B_i2cprobe_status == 1) && ( SII9234C_i2cprobe_status == 1))
	{
		SII9234_i2c_status = 1;
		MHL_On(false);
	}

	printk("ksw sii9234_i2c_read(sii9234_i2c_client, 0x02) = %x\n", SII9234_i2c_read(SII9234B_i2c_client, 0x4C));
	
	return 0;

}
byte I2C_ReadByte(byte deviceID, byte offset)
{
    byte number = 0;
    //printk("[MHL]I2C_ReadByte called ID%x Offset%x\n",deviceID,offset);
    if(deviceID == 0x72)
        number = SII9234_i2c_read(SII9234_i2c_client,offset);
    else if(deviceID == 0x7A)
        number = SII9234_i2c_read(SII9234A_i2c_client,offset);
    else if(deviceID == 0x92)
        number = SII9234_i2c_read(SII9234B_i2c_client,offset);
    else if(deviceID == 0xC8)
        number = SII9234_i2c_read(SII9234C_i2c_client,offset);
    else
        printk("[MHL]I2C_ReadByte error %x\n",deviceID);
    //printk("[MHL]I2C_ReadByte ID:%x Offset:%x data:%x\n",deviceID,offset,number);
    return (number);
}
Exemple #4
0
static int SII9234C_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int ret;
	//SII_DEV_DBG("");

	struct SII9234_state *state;

	state = kzalloc(sizeof(struct SII9234_state), GFP_KERNEL);
	if (state == NULL) {		
		printk("failed to allocate memory \n");
		return -ENOMEM;
	}
	
	state->client = client;
	i2c_set_clientdata(client, state);
	
	/* rest of the initialisation goes here. */
	
	printk("SII9234C attach success!!!\n");

	SII9234C_i2c_client = client;

	SII9234C_i2cprobe_status = 1;
	if(( SII9234_i2cprobe_status == 1) && ( SII9234A_i2cprobe_status == 1) 
		&& ( SII9234B_i2cprobe_status == 1) && ( SII9234C_i2cprobe_status == 1))
	{
		SII9234_i2c_status = 1;
		MHL_On(false);
	}
#if 0
	/* Initialize GPIO 30 (IRQ_MHL_INT).
	* Check if other driver already occupied it.
	*/
	ret = gpio_request(IRQ_MHL_INT, "IRQ MHL INT");
	if(ret < 0){
		printk(KERN_INFO "[MHL] GPIO 30 IRQ_MHL_INT is already occupied by other driver!\n");
		return -ENOSYS;
	}

	/* Initialize GPIO direction before use or IRQ setting */
	ret = gpio_direction_input(IRQ_MHL_INT);
	if(ret < 0){
		printk(KERN_INFO "[MHL] GPIO 30 IRQ_MHL_INT direction initialization failed!\n");
		return -ENOSYS;
	}
#endif
	sii9234_wq = create_singlethread_workqueue("sii9234_wq");
	INIT_WORK(&SiI9234_int_work,SiI9234_interrupt_event_work);

	set_irq_type(IRQ_MHL_INT, IRQ_TYPE_EDGE_FALLING);
	ret = request_threaded_irq( IRQ_MHL_INT , 
		NULL, mhl_int_irq_handler, IRQF_DISABLED	, "mhl_int", (void*)state);
	if (ret < 0) 
	{
		printk("unable to request irq mhl_int err:: %d\n", ret);
		return ret;
	}		
	
	sii9234_wq = create_singlethread_workqueue("sii9234_wq");
	INIT_WORK(&SiI9234_int_work,SiI9234_interrupt_event_work);

/*
	ret = request_irq(IRQ_MHL_WAKE_UP, mhl_wake_up_irq_handler, IRQF_DISABLED, "mhl_wake_up", (void *) state); // check and study here...
	if (ret) 
	{
		printk("unable to request irq mhl_wake_up err:: %d\n", ret);
		return ret;
	}		
	

	ret = request_irq(IRQ_MHL_HPD, mhl_hpd_irq_handler, IRQ_TYPE_EDGE_BOTH  , "mhl_hpd", mhl_hpd_irq_handler);  
	if (ret) 
	{
		printk("unable to request irq mhl_int err:: %d\n", ret);
		return ret;
	}		
	printk("MHL HPD request successful \n");
*/
	//sii9234_cfg_power(1); Unnecessary supply  the current during boot up time.
	mhl_i2c_client_info();
	printk("ksw sii9234_i2c_read(sii9234_i2c_client, 0x02) = %x\n", SII9234_i2c_read(SII9234C_i2c_client, 0x07));

#ifdef TIMER_ACC_ADC 
  hrtimer_init(&sii9234_adc_timer,CLOCK_MONOTONIC,HRTIMER_MODE_REL);
  sii9234_adc_timer.function = sii9234_adctimer_func;
  sii9234_adc_wq = create_singlethread_workqueue("sii9234_adc_wq");

  if (!sii9234_adc_wq) {
		pr_err("%s: could not create workqueue sii9234_adc_wq\n", __func__);
	}
  INIT_WORK(&sii9234_adc_work,sii9234_adc_work_func);
	hrtimer_start(&sii9234_adc_timer,
		ns_to_ktime(500000000/*500ms*/), HRTIMER_MODE_REL);

#endif
	
	return 0;

}
Exemple #5
0
static int SII9234_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	//SII_DEV_DBG("");
	//int retval;

	struct SII9234_state *state;

	struct class *mhl_class;
	struct device *mhl_dev;
	int usb_switch;

	state = kzalloc(sizeof(struct SII9234_state), GFP_KERNEL);
	if (state == NULL) {		
		printk("failed to allocate memory \n");
		return -ENOMEM;
	}
	
	state->client = client;
	i2c_set_clientdata(client, state);


	
	/* rest of the initialisation goes here. */
	
	printk("SII9234 attach success!!!\n");

	SII9234_i2c_client = client;

	MHL_i2c_init = 1;

	mhl_class = class_create(THIS_MODULE, "mhl");
	if (IS_ERR(mhl_class))
	{
		pr_err("Failed to create class(mhl)!\n");
	}

	mhl_dev = device_create(mhl_class, NULL, 0, NULL, "mhl_dev");
	if (IS_ERR(mhl_dev))
	{
		pr_err("Failed to create device(mhl_dev)!\n");
	}

	if (device_create_file(mhl_dev, &dev_attr_MHD_file) < 0)
		printk("Failed to create device file(%s)!\n", dev_attr_MHD_file.attr.name);

	SII9234_i2cprobe_status = 1;
	if(( SII9234_i2cprobe_status == 1) && ( SII9234A_i2cprobe_status == 1) 
		&& ( SII9234B_i2cprobe_status == 1) && ( SII9234C_i2cprobe_status == 1))
	{
		SII9234_i2c_status = 1;
		MHL_On(false);
	}

	printk("ksw sii9234_i2c_read(sii9234_i2c_client, 0x02) = %x\n", SII9234_i2c_read(SII9234_i2c_client, 0x02));
	usb_switch = gpio_get_value(GPIO_MHL_SEL);
	printk("ksw mhl_sel_gpio_value = 0x%x\n", usb_switch);
	


	
	return 0;

}