Exemple #1
0
static int rmi_irq_thread(void *p)
{
	struct rmi_i2c_data *data = p;
	struct rmi_phys_device *phys = data->phys;
	struct rmi_device_platform_data *pdata = phys->dev->platform_data;

	static const struct sched_param param = {
		.sched_priority = MAX_USER_RT_PRIO/2,
	};

	sched_setscheduler(current, SCHED_FIFO, &param);

	while (!kthread_should_stop()){
		set_current_state(TASK_INTERRUPTIBLE);
		if (test_and_clear_bit(RMI_IRQ_WAKED,&rmi_irq_flag)) {
			set_current_state(TASK_RUNNING);
			rmi_i2c_irq_thread(data->irq, data->phys);
			enable_irq(data->irq);
		}
		else
			schedule();
	}
	return 0;
}

static int acquire_attn_irq(struct rmi_i2c_data *data)
{
	return request_threaded_irq(data->irq, rmi_irq_handler_process, NULL,
			data->irq_flags, dev_name(data->phys->dev), data->phys);
}


static int enable_device(struct rmi_phys_device *phys)
{
	int retval = 0;

	struct rmi_i2c_data *data = phys->data;

	if (data->enabled)
		return 0;

	retval = acquire_attn_irq(data);
	if (retval)
		goto error_exit;

	data->enabled = true;
	dev_dbg(phys->dev, "Physical device enabled.\n");
	return 0;

error_exit:
	dev_err(phys->dev, "Failed to enable physical device. Code=%d.\n",
		retval);
	return retval;
}
Exemple #2
0
static int enable_device(struct rmi_phys_device *phys)
{
	int retval = 0;

	struct rmi_i2c_data *data = phys->data;

	if (data->enabled)
		return 0;

	retval = acquire_attn_irq(data);
	if (retval)
		goto error_exit;

	data->enabled = true;
	dev_dbg(phys->dev, "Physical device enabled.\n");
	return 0;

error_exit:
	printk( "ITUCH : Device(%s) failed to enable physical device(%d)\n", dev_name( phys->dev ), retval );
	return retval;
}
static int enable_device(struct rmi_phys_device *phys)
{
    int retval = 0;

    struct rmi_i2c_data *data = phys->data;

    if (data->enabled)
        return 0;

    retval = acquire_attn_irq(data);
    if (retval)
        goto error_exit;

    data->enabled = true;
    dev_dbg(phys->dev, "Physical device enabled.\n");
    return 0;

error_exit:
    dev_err(phys->dev, "Failed to enable physical device. Code=%d.\n",
            retval);
    return retval;
}
static int __devinit rmi_i2c_probe(struct i2c_client *client,
                                   const struct i2c_device_id *id)
{
    struct rmi_phys_device *rmi_phys;
    struct rmi_i2c_data *data;
    struct rmi_device_platform_data *pdata = client->dev.platform_data;
    int error;

    if (!pdata) {
        dev_err(&client->dev, "no platform data\n");
        return -EINVAL;
    }
    pr_info("%s: Probing %s at %#02x (IRQ %d).\n", __func__,
            pdata->sensor_name ? pdata->sensor_name : "-no name-",
            client->addr, pdata->attn_gpio);

    error = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
    if (!error) {
        dev_err(&client->dev, "i2c_check_functionality error %d.\n",
                error);
        return error;
    }

    rmi_phys = kzalloc(sizeof(struct rmi_phys_device), GFP_KERNEL);
    if (!rmi_phys)
        return -ENOMEM;

    data = kzalloc(sizeof(struct rmi_i2c_data), GFP_KERNEL);
    if (!data) {
        error = -ENOMEM;
        goto err_phys;
    }

    data->enabled = true;	/* We plan to come up enabled. */
    data->irq = gpio_to_irq(pdata->attn_gpio);
    data->irq_flags = (pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ?
                      IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
    data->phys = rmi_phys;

    rmi_phys->data = data;
    rmi_phys->dev = &client->dev;

    rmi_phys->write = rmi_i2c_write;
    rmi_phys->write_block = rmi_i2c_write_block;
    rmi_phys->read = rmi_i2c_read;
    rmi_phys->read_block = rmi_i2c_read_block;
    rmi_phys->enable_device = enable_device;
    rmi_phys->disable_device = disable_device;

    rmi_phys->info.proto = phys_proto_name;

    mutex_init(&data->page_mutex);

    mdelay(1000);

    /* Setting the page to zero will (a) make sure the PSR is in a
     * known state, and (b) make sure we can talk to the device.
     */
    error = rmi_set_page(rmi_phys, 0);
    if (error) {
        dev_err(&client->dev, "Failed to set page select to 0.\n");
        goto err_data;
    }

    if (pdata->gpio_config) {
        error = pdata->gpio_config(pdata->gpio_data, true);
        if (error < 0) {
            dev_err(&client->dev, "failed to setup irq %d\n",
                    pdata->attn_gpio);
            goto err_data;
        }
    }

    error = rmi_register_phys_device(rmi_phys);
    if (error) {
        dev_err(&client->dev,
                "failed to register physical driver at 0x%.2X.\n",
                client->addr);
        goto err_data;
    }
    i2c_set_clientdata(client, rmi_phys);

    if (pdata->attn_gpio > 0) {
        error = acquire_attn_irq(data);
        if (error < 0) {
            dev_err(&client->dev,
                    "request_threaded_irq failed %d\n",
                    pdata->attn_gpio);
            goto err_unregister;
        }
    }

#if defined(CONFIG_RMI4_DEV)
    error = gpio_export(pdata->attn_gpio, false);
    if (error) {
        dev_warn(&client->dev, "%s: WARNING: Failed to "
                 "export ATTN gpio!\n", __func__);
        error = 0;
    } else {
        error = gpio_export_link(&(rmi_phys->rmi_dev->dev), "attn",
                                 pdata->attn_gpio);
        if (error) {
            dev_warn(&(rmi_phys->rmi_dev->dev), "%s: WARNING: "
                     "Failed to symlink ATTN gpio!\n", __func__);
            error = 0;
        } else {
            dev_info(&(rmi_phys->rmi_dev->dev),
                     "%s: Exported GPIO %d.", __func__,
                     pdata->attn_gpio);
        }
    }
#endif /* CONFIG_RMI4_DEV */

    dev_info(&client->dev, "registered rmi i2c driver at 0x%.2X.\n",
             client->addr);
    return 0;

err_unregister:
    rmi_unregister_phys_device(rmi_phys);
err_data:
    kfree(data);
err_phys:
    kfree(rmi_phys);
    return error;
}
Exemple #5
0
static int __devinit rmi_i2c_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct rmi_phys_device *rmi_phys;
	struct rmi_i2c_data *data;
	struct rmi_device_platform_data *pdata = client->dev.platform_data;
	int error;

	if (!pdata) {
		dev_err(&client->dev, "no platform data\n");
		return -EINVAL;
	}
	if (!hsad_get_rmi_enable()) {
		dev_err(&client->dev, "rmi not exits\n");
		return -EINVAL;
	}

	dev_info(&client->dev, "Probing %s at %#02x (IRQ %d).\n",
		pdata->sensor_name ? pdata->sensor_name : "-no name-",
		client->addr, pdata->attn_gpio);
	error = set_touch_chip_info(TOUCH_INFO_RMI3250);
	if (error) {
		dev_err(&client->dev, "set_touch_chip_info error\n");
	}

	dev_info(&client->dev, "Configuring GPIOs.\n");
	error = synaptics_touchpad_gpio_setup(pdata->gpio_data);
	if (error < 0) {
		dev_err(&client->dev, "Failed to configure GPIOs, code: %d.\n",
			error);
		return error;
	}
	dev_info(&client->dev, "Done with GPIO configuration.\n");
	error = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
	if (!error) {
		dev_err(&client->dev, "i2c_check_functionality error %d.\n",
			error);
		return error;
	}

	rmi_phys = kzalloc(sizeof(struct rmi_phys_device), GFP_KERNEL);
	if (!rmi_phys)
		return -ENOMEM;

	data = kzalloc(sizeof(struct rmi_i2c_data), GFP_KERNEL);
	if (!data) {
		error = -ENOMEM;
		goto err_phys;
	}

	data->enabled = true;	/* We plan to come up enabled. */
	data->irq = gpio_to_irq(pdata->attn_gpio);
	if (pdata->level_triggered) {
		data->irq_flags = IRQF_ONESHOT |
			((pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ?
			IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW);
	} else {
		data->irq_flags =
			(pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ?
			IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
	}
	data->phys = rmi_phys;

	rmi_phys->data = data;
	rmi_phys->dev = &client->dev;

	rmi_phys->write = rmi_i2c_write;
	rmi_phys->write_block = rmi_i2c_write_block;
	rmi_phys->read = rmi_i2c_read;
	rmi_phys->read_block = rmi_i2c_read_block;
	rmi_phys->enable_device = enable_device;
	rmi_phys->disable_device = disable_device;

	rmi_phys->info.proto = phys_proto_name;

	mutex_init(&data->page_mutex);

	/* Setting the page to zero will (a) make sure the PSR is in a
	 * known state, and (b) make sure we can talk to the device.
	 */
	msleep(100);
	error = rmi_set_page(rmi_phys, 0);
	if (error) {
		dev_err(&client->dev, "Failed to set page select to 0.\n");
		goto err_data;
	}

	error = rmi_register_phys_device(rmi_phys);
	if (error) {
		dev_err(&client->dev,
			"failed to register physical driver at 0x%.2X.\n",
			client->addr);
		goto err_gpio;
	}
	i2c_set_clientdata(client, rmi_phys);

	rmi_phys->rmi_task = kthread_create(rmi_irq_thread, data, "rmi_irq_thread");
	if (IS_ERR(rmi_phys->rmi_task)){
		dev_err(&client->dev,	"create thread failed!\n");
		goto err_unregister;
	}

	if (pdata->attn_gpio > 0) {
		error = acquire_attn_irq(data);
		if (error < 0) {
			dev_err(&client->dev,
				"request_threaded_irq failed %d\n",
				pdata->attn_gpio);
			goto err_unregister;
		}
	}

#if defined(CONFIG_RMI4_DEV)
	error = gpio_export(pdata->attn_gpio, false);
	if (error) {
		dev_warn(&client->dev,
			 "WARNING: Failed to export ATTN gpio!\n");
		error = 0;
	} else {
		error = gpio_export_link(&(rmi_phys->rmi_dev->dev), "attn",
					pdata->attn_gpio);
		if (error) {
			dev_warn(&(rmi_phys->rmi_dev->dev),
				 "WARNING: Failed to symlink ATTN gpio!\n");
			error = 0;
		} else {
			dev_info(&(rmi_phys->rmi_dev->dev),
				"%s: Exported ATTN GPIO %d.", __func__,
				pdata->attn_gpio);
		}
	}
#endif /* CONFIG_RMI4_DEV */

	dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n",
			client->addr);
	return 0;

err_unregister:
	rmi_unregister_phys_device(rmi_phys);
err_gpio:
	synaptics_touchpad_gpio_free(pdata->gpio_data);
err_data:
	kfree(data);
err_phys:
	kfree(rmi_phys);
	return error;
}
Exemple #6
0
static int __devinit rmi_i2c_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct rmi_phys_device *rmi_phys;
	struct rmi_i2c_data *data;
	struct rmi_device_platform_data *pdata = client->dev.platform_data;
	int error;

	if (!pdata) {
		printk( "ITUCH : Device(%s) no platform data\n", dev_name( &client->dev ) );
		return -EINVAL;
	}
	printk( "ITUCH : Probing %s at %#02x (IRQ %d)\n", pdata->sensor_name ? pdata->sensor_name : "-no name-", client->addr, pdata->attn_gpio );

	error = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
	if (!error) {
		printk( "ITUCH : Device(%s) i2c_check_functionality error(%d)\n", dev_name( &client->dev ), error );
		return error;
	}

	rmi_phys = kzalloc(sizeof(struct rmi_phys_device), GFP_KERNEL);
	if (!rmi_phys)
		return -ENOMEM;

	data = kzalloc(sizeof(struct rmi_i2c_data), GFP_KERNEL);
	if (!data) {
		error = -ENOMEM;
		goto err_phys;
	}

	if( gpio_request( pdata->reset_gpio, "RMI4_RESET" ) )
		printk( "ITUCH : Unable to request gpio%d\n", pdata->reset_gpio );

	reset_touch( pdata );

	data->enabled = true;	/* We plan to come up enabled. */
	data->irq = gpio_to_irq(pdata->attn_gpio);
	if (pdata->level_triggered) {
		data->irq_flags = IRQF_ONESHOT |
			((pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ?
			IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW);
	} else {
		data->irq_flags =
			(pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH) ?
			IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
	}
	data->phys = rmi_phys;

	rmi_phys->data = data;
	rmi_phys->dev = &client->dev;

	rmi_phys->write = rmi_i2c_write;
	rmi_phys->write_block = rmi_i2c_write_block;
	rmi_phys->read = rmi_i2c_read;
	rmi_phys->read_block = rmi_i2c_read_block;
	rmi_phys->enable_device = enable_device;
	rmi_phys->disable_device = disable_device;

	rmi_phys->info.proto = phys_proto_name;

	mutex_init(&data->page_mutex);

	/* Setting the page to zero will (a) make sure the PSR is in a
	 * known state, and (b) make sure we can talk to the device.
	 */
	error = rmi_set_page(rmi_phys, 0);
	if (error) {
		printk( "ITUCH : Device(%s) failed to set page select to 0\n", dev_name( &client->dev ) );
		goto err_data;
	}

	if (pdata->gpio_config) {
		error = pdata->gpio_config(pdata->gpio_data, true);
		if (error < 0) {
			printk( "ITUCH : Device(%s) failed to setup irq%d\n", dev_name( &client->dev ), pdata->attn_gpio );
			goto err_data;
		}
	}

	error = rmi_register_phys_device(rmi_phys);
	if (error) {
		printk( "ITUCH : Device(%s) failed to register physical driver at 0x%.2X\n", dev_name( &client->dev ), client->addr );
		goto err_gpio;
	}
	i2c_set_clientdata(client, rmi_phys);

	if (pdata->attn_gpio > 0) {
		error = acquire_attn_irq(data);
		if (error < 0) {
			printk( "ITUCH : Device(%s) request_threaded_irq(IRQ%d) failed\n", dev_name( &client->dev ), pdata->attn_gpio );
			goto err_unregister;
		}
	}

#if defined(CONFIG_RMI4_DEV)
	error = gpio_export(pdata->attn_gpio, false);
	if (error) {
		printk( "ITUCH : Device(%s) failed to export ATTN gpio\n", dev_name( &client->dev ) );
		error = 0;
	} else {
		error = gpio_export_link(&(rmi_phys->rmi_dev->dev), "attn",
					pdata->attn_gpio);
		if (error) {
			printk( "ITUCH : Device(%s) failed to symlink ATTN gpio\n", dev_name( &rmi_phys->rmi_dev->dev ) );
			error = 0;
		} else {
			printk( "ITUCH : Device(%s) exported GPIO-%d\n", dev_name( &rmi_phys->rmi_dev->dev ), pdata->attn_gpio );
		}
	}
#endif /* CONFIG_RMI4_DEV */

	printk( "ITUCH : Device(%s) registered rmi i2c driver at 0x%.2X\n", dev_name( &client->dev ), client->addr );
	return 0;

err_unregister:
	rmi_unregister_phys_device(rmi_phys);
err_gpio:
	if (pdata->gpio_config)
		pdata->gpio_config(pdata->gpio_data, false);
err_data:
	kfree(data);
err_phys:
	kfree(rmi_phys);
	return error;
}