Exemplo n.º 1
0
static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv)
{
	return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high;
}
Exemplo n.º 2
0
static irqreturn_t tosa_bat_gpio_isr(int irq, void *data)
{
	pr_info("tosa_bat_gpio irq: %d\n", gpio_get_value(irq_to_gpio(irq)));
	schedule_work(&bat_work);
	return IRQ_HANDLED;
}
Exemplo n.º 3
0
/*******************************************************	
功能:
	触摸屏探测函数
	在注册驱动时调用(要求存在对应的client);
	用于IO,中断等资源申请;设备注册;触摸屏初始化等工作
参数:
	client:待驱动的设备结构体
	id:设备ID
return:
	执行结果码,0表示正常执行
********************************************************/
static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct goodix_ts_data *ts;
	int ret = 0;
	int retry=0;
	int count=0;
FNC_ENTERY;
	struct goodix_i2c_platform_data *pdata;
	dev_dbg(&client->dev,"Install touchscreen driver for guitar.\n");

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 
	{
		dev_err(&client->dev, "System need I2C function.\n");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}
        
	if (!(((board_version == 1)&&(hw_version == 0))||(board_version == 0)))
        {
		printk("%s: system hardware version:%d, GOODIX touchscreen is unsupported!!!\n", __func__, hw_version);
		ret = -1;
		goto err_check_functionality_failed;
	}
	
	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
	if (ts == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}

	/* 获取预定义资源 */
	pdata = client->dev.platform_data;
	if(pdata != NULL) {
		//ts->gpio_shutdown = pdata->gpio_shutdown;
		//ts->gpio_irq = pdata->gpio_irq;
		
		//use as s3c_gpio_cfgpin(ts->gpio_shutdown, pdata->shutdown_cfg);		/* output */
	}
	
#ifdef SHUTDOWN_PORT	
	ts->gpio_shutdown = SHUTDOWN_PORT;
	if(ts->gpio_shutdown)
	{
		//ret = gpio_request(ts->gpio_shutdown, "TS_SHUTDOWN");	//Request IO
		if (ret < 0) 
		{
			printk(KERN_ALERT "Failed to request GPIO:%d, ERRNO:%d\n", ts->gpio_shutdown, ret);
			goto err_gpio_request;
		}	
		gpio_direction_output(ts->gpio_shutdown, 0);	//Touchscreen is waiting to wake up
		ret = gpio_get_value(ts->gpio_shutdown);
		if (ret)
		{
			printk(KERN_ALERT  "Cannot set touchscreen to work.\n");
			goto err_i2c_failed;
		}
		ts->use_shutdown = 1;
		msleep(25);		//waiting for initialization of Guitar.
	}
#endif		
	RESETPIN_CFG;
	RESETPIN_SET1;
	mdelay(200);
	RESETPIN_SET0;
	mdelay(200);

	i2c_connect_client = client;				//used by Guitar Updating.
	//TODO: used to set speed of i2c transfer. Must change as your paltform.
//	s3c24xx_set_i2c_clockrate(client->adapter, 250, &count);	//set i2c <=250kHz
	dev_dbg(&client->dev, "i2c set frequency:%dkHz.\n", count);
#if 0
	for(retry=0; retry < 5; retry++)
	{
		
	ret=i2c_read_bytes(ts->client,version_data, GT80X_VERSION_LENGTH);
		ret =i2c_write_bytes(client, NULL, 0);	//Test i2c.
		if (ret > 0)
			break;
	}
	if(ret < 0)
	{
		dev_err(&client->dev, "Warnning: I2C connection might be something wrong!\n");
		goto err_i2c_failed;
	}
#endif
	if(ts->use_shutdown)
		gpio_set_value(ts->gpio_shutdown, 1);		//suspend
	
	INIT_WORK(&ts->work, goodix_ts_work_func);
	ts->client = client;
	i2c_set_clientdata(client, ts);
	pdata = client->dev.platform_data;
	
	ts->input_dev = input_allocate_device();
	if (ts->input_dev == NULL) {
		ret = -ENOMEM;
		dev_dbg(&client->dev,"Failed to allocate input device\n");
		goto err_input_dev_alloc_failed;
	}

	ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ;
#ifndef GOODIX_MULTI_TOUCH	
	ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	ts->input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);

	input_set_abs_params(ts->input_dev, ABS_X, 0, SCREEN_MAX_HEIGHT, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_Y, 0, SCREEN_MAX_WIDTH, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, 0, 0);	
#else
	//ts->input_dev->absbit[0] = BIT_MASK(ABS_MT_TRACKING_ID) |
	ts->input_dev->absbit[0] = 
		BIT_MASK(ABS_MT_TOUCH_MAJOR)| BIT_MASK(ABS_MT_WIDTH_MAJOR) |
  		BIT_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y); 	// for android
	input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, SCREEN_MAX_HEIGHT, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, SCREEN_MAX_WIDTH, 0, 0);	
	//input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, MAX_FINGER_NUM-1, 0, 0);	
#endif	

	sprintf(ts->phys, "input/ts)");
	ts->input_dev->name = s3c_ts_name;
	ts->input_dev->phys = ts->phys;
	ts->input_dev->id.bustype = BUS_I2C;
	ts->input_dev->id.vendor = 0xDEAD;
	ts->input_dev->id.product = 0xBEEF;
	ts->input_dev->id.version = 0x1103;	

	finger_list.length = 0;
	ret = input_register_device(ts->input_dev);
	if (ret) {
		dev_err(&client->dev,"Probe: Unable to register %s input device\n", ts->input_dev->name);
		goto err_input_register_device_failed;
	}

	ts->use_irq = 1;
	//ts->use_irq = 0;
	ts->retry = 0;
	ts->bad_data = 0;

#if defined(INT_PORT)	
	ts->gpio_irq = INT_PORT;
	client->irq=TS_INT; //If not define in client
	if (client->irq)
	{
	
#ifdef CONFIG_MACH_EMEV
				writel(readl(CHG_PULL1)|0xC000, CHG_PULL1);
				gpio_direction_input(irq_to_gpio(client->irq));
#endif
		//ret = gpio_request(ts->gpio_irq, "TS_INT");	//Request IO
		if (ret < 0) 
		{
			dev_err(&client->dev, "Failed to request GPIO:%d, ERRNO:%d\n", ts->gpio_irq, ret);
			goto err_int_request_failed;
		}
//		ret = s3c_gpio_cfgpin(ts->gpio_irq, INT_CFG);	//Set IO port function
		ret  = request_irq(client->irq, goodix_ts_irq_handler ,  IRQ_TYPE_EDGE_RISING,
			"GoodixIRQ", ts);
		if (ret != 0) {
			dev_err(&client->dev,"Can't allocate touchscreen's interrupt%d!ERRNO:%d\n",client->irq, ret);
			gpio_direction_input(ts->gpio_irq);
			gpio_free(ts->gpio_irq);
			goto err_int_request_failed;
		}
		else 
		{	
			disable_irq(client->irq);
			ts->use_irq = 1;
			dev_dbg(&client->dev,"Reques EIRQ %d succesd on GPIO:%d\n",client->irq, ts->gpio_irq);
		}
	}
#endif

err_int_request_failed:	
	if (!ts->use_irq) 
	{
		hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		ts->timer.function = goodix_ts_timer_func;
		hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
	}

	flush_workqueue(goodix_wq);
	if(ts->use_shutdown)
	{		
		gpio_set_value(ts->gpio_shutdown, 0);	
	#ifdef SHUTDOWN_PORT	
		ts->power = goodix_ts_power;
	#endif
		msleep(30);
	}	
	
	ret = goodix_init_panel(ts);
	if(ret != 0) 
		goto err_init_godix_ts;
	if(ts->use_irq)
		enable_irq(client->irq);
	
	goodix_read_version(ts);
	//msleep(500);
	
#ifdef CONFIG_HAS_EARLYSUSPEND
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = goodix_ts_early_suspend;
	ts->early_suspend.resume = goodix_ts_late_resume;
	register_early_suspend(&ts->early_suspend);
#endif
	dev_dbg(&client->dev,"Start  %s in %s mode\n", 
		ts->input_dev->name, ts->use_irq ? "Interrupt" : "Polling");
	return 0;

err_init_godix_ts:
	if(ts->use_irq)
	{
		free_irq(client->irq,ts);	
		gpio_free(ts->gpio_irq);
	}

err_input_register_device_failed:
	input_free_device(ts->input_dev);

err_input_dev_alloc_failed:
	i2c_set_clientdata(client, NULL);
err_i2c_failed:
	if(ts->use_shutdown)
	{
		gpio_direction_input(ts->gpio_shutdown);
		gpio_free(ts->gpio_shutdown);
	}
err_gpio_request:
	kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
	return ret;
}
static void mxs_gpio_unmask_irq(u32 irq)
{
    u32 gpio = irq_to_gpio(irq);
    set_gpio_irqenable(&mxs_gpio_ports[gpio / 32], gpio & 0x1f, 1);
}
static void mxs_gpio_ack_irq(u32 irq)
{
    u32 gpio = irq_to_gpio(irq);
    clear_gpio_irqstatus(&mxs_gpio_ports[gpio / 32], gpio & 0x1f);
}
Exemplo n.º 6
0
static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
{
	unsigned int irq;
	int gpio;
	struct resource *res;
	struct ata_host *ah;
	struct rb532_cf_info *info;
	int ret;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		dev_err(&pdev->dev, "no IOMEM resource found\n");
		return -EINVAL;
	}

	irq = platform_get_irq(pdev, 0);
	if (irq <= 0) {
		dev_err(&pdev->dev, "no IRQ resource found\n");
		return -ENOENT;
	}

	gpio = irq_to_gpio(irq);
	if (gpio < 0) {
		dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq);
		return -ENOENT;
	}

	ret = gpio_request(gpio, DRV_NAME);
	if (ret) {
		dev_err(&pdev->dev, "GPIO request failed\n");
		return ret;
	}

	/* allocate host */
	ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS);
	if (!ah)
		return -ENOMEM;

	platform_set_drvdata(pdev, ah);

	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
	if (!info)
		return -ENOMEM;

	ah->private_data = info;
	info->gpio_line = gpio;
	info->irq = irq;

	info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
				res->end - res->start + 1);
	if (!info->iobase)
		return -ENOMEM;

	ret = gpio_direction_input(gpio);
	if (ret) {
		dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n",
				ret);
		goto err_free_gpio;
	}

	rb532_pata_setup_ports(ah);

	ret = ata_host_activate(ah, irq, rb532_pata_irq_handler,
				IRQF_TRIGGER_LOW, &rb532_pata_sht);
	if (ret)
		goto err_free_gpio;

	return 0;

err_free_gpio:
	gpio_free(gpio);

	return ret;
}
static void msm_gpio_irq_ack(unsigned int irq)
{
	writel(0x01, GPIO_INTR_STATUS(irq_to_gpio(irq)));
}