Esempio n. 1
0
void touchscreen_calibrate(void)
{
	unsigned char cmd[2] = {0x37, 0x03};
	if(m_ts && m_ts->client) {
		i2c_master_send(m_ts->client, cmd, 2);
		msleep(8000);
		pixcir_reset(300);
	}
}
Esempio n. 2
0
static void pixcir_late_resume(struct early_suspend *handler)
{
    struct pixcir_data *pixcir = container_of(handler, struct pixcir_data, early_suspend);

    pixcir_reset(pixcir);
    msleep(200);
    pixcir_active(pixcir);
    
    pixcir->earlysus = 0;

    gpio_enable(pixcir->igp_idx, pixcir->igp_bit,INPUT);
    gpio_pull_enable(pixcir->igp_idx, pixcir->igp_bit, PULL_UP);
    gpio_setup_irq(pixcir->igp_idx, pixcir->igp_bit, IRQ_FALLING);
    
    return;
}
Esempio n. 3
0
static inline void emxx_ts_connect(void)
{
#ifdef DEBUG
	printk("emxx_ts_connect - set gpio\n");
#endif
	pixcir_reset(300);

	gpio_direction_input(GPIO_P29);
	//set_irq_type(INT_GPIO_29, IRQ_TYPE_EDGE_FALLING);

#ifdef DEBUG
	printk( "CHG_PULL1 = 0x%08x\n", readl(CHG_PULL1));
#endif
	writel((readl(CHG_PULL1) | 0x00005000), CHG_PULL1);
#ifdef DEBUG
	printk( "CHG_PULL1 = 0x%08x\n", readl(CHG_PULL1));
#endif
}
Esempio n. 4
0
static void resume_reset(struct work_struct *work)
{
	printk("pixcir touchscreen resume reset\n\n\n");
	pixcir_reset(300);
}
Esempio n. 5
0
static int pixcir_probe(struct platform_device *pdev)
{
	int i;
    int err = 0;
	struct pixcir_data *pixcir = platform_get_drvdata(pdev);
    
	INIT_DELAYED_WORK(&pixcir->read_work, pixcir_read_work);
    pixcir->workqueue = create_singlethread_workqueue(pixcir->name);
	if (!pixcir->workqueue) {
		err = -ESRCH;
		goto exit_create_singlethread;
	}
    
    err = pixcir_sysfs_create_group(pixcir, &pixcir_group);
    if(err < 0){
        dbg("create sysfs group failed.\n");
        goto exit_create_group;
    }
    
	pixcir->input_dev = input_allocate_device();
	if (!pixcir->input_dev) {
		err = -ENOMEM;
		dbg("failed to allocate input device\n");
		goto exit_input_dev_alloc_failed;
	}
	
	pixcir->input_dev->name = pixcir->name;
	pixcir->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
	set_bit(INPUT_PROP_DIRECT, pixcir->input_dev->propbit);

	input_set_abs_params(pixcir->input_dev,
			     ABS_MT_POSITION_X, 0, pixcir->xresl, 0, 0);
	input_set_abs_params(pixcir->input_dev,
			     ABS_MT_POSITION_Y, 0, pixcir->yresl, 0, 0);
    input_set_abs_params(pixcir->input_dev,
                 ABS_MT_TRACKING_ID, 0, 20, 0, 0);
#ifdef TOUCH_KEY 	
	for (i = 0; i <NUM_KEYS; i++)
		set_bit(keycodes[i], pixcir->input_dev->keybit);

	pixcir->input_dev->keycode = keycodes;
	pixcir->input_dev->keycodesize = sizeof(unsigned int);
	pixcir->input_dev->keycodemax = NUM_KEYS;
#endif
    pixcir->earlysus = 1;
	err = input_register_device(pixcir->input_dev);
	if (err) {
		dbg_err("pixcir_ts_probe: failed to register input device.\n");
		goto exit_input_register_device_failed;
	}
        
#ifdef CONFIG_HAS_EARLYSUSPEND
	pixcir->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	pixcir->early_suspend.suspend = pixcir_early_suspend;
	pixcir->early_suspend.resume = pixcir_late_resume;
	register_early_suspend(&pixcir->early_suspend);
#endif
    
	if(request_irq(pixcir->irq, pixcir_isr_handler, IRQF_SHARED, pixcir->name, pixcir) < 0){
		dbg_err("Could not allocate irq for ts_pixcir !\n");
		err = -1;
		goto exit_register_irq;
	}	
	
    gpio_enable(pixcir->igp_idx, pixcir->igp_bit, INPUT);
    gpio_pull_enable(pixcir->igp_idx, pixcir->igp_bit, PULL_UP);
    gpio_setup_irq(pixcir->igp_idx, pixcir->igp_bit, IRQ_FALLING);
    
    pixcir_reset(pixcir);
    msleep(200);
    pixcir_active(pixcir);
    pixcir->earlysus = 0;
    
    return 0;
    
exit_register_irq:
	unregister_early_suspend(&pixcir->early_suspend);
exit_input_register_device_failed:
	input_free_device(pixcir->input_dev);
exit_input_dev_alloc_failed:
    pixcir_sysfs_remove_group(pixcir, &pixcir_group);
exit_create_group:
	cancel_delayed_work_sync(&pixcir->read_work);
	destroy_workqueue(pixcir->workqueue);  
exit_create_singlethread:
    //kfree(pixcir);
	return err;
}
Esempio n. 6
0
static int pixcir_i2c_ts_probe(struct i2c_client *client,
			       const struct i2c_device_id *id)
{
	const struct pixcir_ts_platform_data *pdata =
			dev_get_platdata(&client->dev);
	struct device *dev = &client->dev;
	struct pixcir_i2c_ts_data *tsdata;
	struct input_dev *input;
	int error;

	tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
	if (!tsdata)
		return -ENOMEM;

	if (pdata) {
		tsdata->chip = &pdata->chip;
	} else if (dev->of_node) {
		error = pixcir_parse_dt(dev, tsdata);
		if (error)
			return error;
	} else {
		dev_err(&client->dev, "platform data not defined\n");
		return -EINVAL;
	}

	if (!tsdata->chip->max_fingers) {
		dev_err(dev, "Invalid max_fingers in chip data\n");
		return -EINVAL;
	}

	input = devm_input_allocate_device(dev);
	if (!input) {
		dev_err(dev, "Failed to allocate input device\n");
		return -ENOMEM;
	}

	tsdata->client = client;
	tsdata->input = input;

	input->name = client->name;
	input->id.bustype = BUS_I2C;
	input->open = pixcir_input_open;
	input->close = pixcir_input_close;
	input->dev.parent = &client->dev;

	if (pdata) {
		input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
		input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
	} else {
		input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
		input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
		touchscreen_parse_properties(input, true, &tsdata->prop);
		if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
		    !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
			dev_err(dev, "Touchscreen size is not specified\n");
			return -EINVAL;
		}
	}

	tsdata->max_fingers = tsdata->chip->max_fingers;
	if (tsdata->max_fingers > PIXCIR_MAX_SLOTS) {
		tsdata->max_fingers = PIXCIR_MAX_SLOTS;
		dev_info(dev, "Limiting maximum fingers to %d\n",
			 tsdata->max_fingers);
	}

	error = input_mt_init_slots(input, tsdata->max_fingers,
				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
	if (error) {
		dev_err(dev, "Error initializing Multi-Touch slots\n");
		return error;
	}

	input_set_drvdata(input, tsdata);

	tsdata->gpio_attb = devm_gpiod_get(dev, "attb", GPIOD_IN);
	if (IS_ERR(tsdata->gpio_attb)) {
		error = PTR_ERR(tsdata->gpio_attb);
		dev_err(dev, "Failed to request ATTB gpio: %d\n", error);
		return error;
	}

	tsdata->gpio_reset = devm_gpiod_get_optional(dev, "reset",
						     GPIOD_OUT_LOW);
	if (IS_ERR(tsdata->gpio_reset)) {
		error = PTR_ERR(tsdata->gpio_reset);
		dev_err(dev, "Failed to request RESET gpio: %d\n", error);
		return error;
	}

	tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
						    GPIOD_OUT_HIGH);
	if (IS_ERR(tsdata->gpio_wake)) {
		error = PTR_ERR(tsdata->gpio_wake);
		if (error != -EPROBE_DEFER)
			dev_err(dev, "Failed to get wake gpio: %d\n", error);
		return error;
	}

	tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
						      GPIOD_OUT_HIGH);
	if (IS_ERR(tsdata->gpio_enable)) {
		error = PTR_ERR(tsdata->gpio_enable);
		if (error != -EPROBE_DEFER)
			dev_err(dev, "Failed to get enable gpio: %d\n", error);
		return error;
	}

	if (tsdata->gpio_enable)
		msleep(100);

	error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
					  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
					  client->name, tsdata);
	if (error) {
		dev_err(dev, "failed to request irq %d\n", client->irq);
		return error;
	}

	pixcir_reset(tsdata);

	/* Always be in IDLE mode to save power, device supports auto wake */
	error = pixcir_set_power_mode(tsdata, PIXCIR_POWER_IDLE);
	if (error) {
		dev_err(dev, "Failed to set IDLE mode\n");
		return error;
	}

	/* Stop device till opened */
	error = pixcir_stop(tsdata);
	if (error)
		return error;

	error = input_register_device(input);
	if (error)
		return error;

	i2c_set_clientdata(client, tsdata);

	return 0;
}