2011-03-17 05:07:36 +00:00
|
|
|
/*
|
|
|
|
* TSC2005 touchscreen driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006-2010 Nokia Corporation
|
2015-11-03 01:45:51 +00:00
|
|
|
* Copyright (C) 2015 QWERTY Embedded Design
|
|
|
|
* Copyright (C) 2015 EMAC Inc.
|
2011-03-17 05:07:36 +00:00
|
|
|
*
|
2015-11-03 01:45:51 +00:00
|
|
|
* Based on original tsc2005.c by Lauri Leukkunen <lauri.leukkunen@nokia.com>
|
2011-03-17 05:07:36 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/input.h>
|
2017-02-10 23:12:20 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/of.h>
|
2011-03-17 05:07:36 +00:00
|
|
|
#include <linux/spi/spi.h>
|
2015-07-28 00:27:25 +00:00
|
|
|
#include <linux/regmap.h>
|
2015-11-03 01:45:51 +00:00
|
|
|
#include "tsc200x-core.h"
|
2011-03-17 05:07:36 +00:00
|
|
|
|
2016-07-20 17:02:07 +00:00
|
|
|
static const struct input_id tsc2005_input_id = {
|
|
|
|
.bustype = BUS_SPI,
|
|
|
|
.product = 2005,
|
|
|
|
};
|
|
|
|
|
2015-11-03 01:45:51 +00:00
|
|
|
static int tsc2005_cmd(struct device *dev, u8 cmd)
|
2011-03-17 05:07:36 +00:00
|
|
|
{
|
2015-11-03 01:51:49 +00:00
|
|
|
u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
|
2011-03-17 05:10:52 +00:00
|
|
|
struct spi_transfer xfer = {
|
2015-11-03 01:45:51 +00:00
|
|
|
.tx_buf = &tx,
|
|
|
|
.len = 1,
|
|
|
|
.bits_per_word = 8,
|
2011-03-17 05:10:52 +00:00
|
|
|
};
|
2011-03-17 05:07:36 +00:00
|
|
|
struct spi_message msg;
|
2015-11-03 01:45:51 +00:00
|
|
|
struct spi_device *spi = to_spi_device(dev);
|
2011-03-17 05:11:25 +00:00
|
|
|
int error;
|
2011-03-17 05:07:36 +00:00
|
|
|
|
|
|
|
spi_message_init(&msg);
|
|
|
|
spi_message_add_tail(&xfer, &msg);
|
2011-03-17 05:11:25 +00:00
|
|
|
|
2015-11-03 01:45:51 +00:00
|
|
|
error = spi_sync(spi, &msg);
|
2011-03-17 05:11:25 +00:00
|
|
|
if (error) {
|
2015-11-03 01:45:51 +00:00
|
|
|
dev_err(dev, "%s: failed, command: %x, spi error: %d\n",
|
2011-03-17 05:11:25 +00:00
|
|
|
__func__, cmd, error);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2011-03-17 05:07:36 +00:00
|
|
|
}
|
|
|
|
|
2012-11-24 05:38:25 +00:00
|
|
|
static int tsc2005_probe(struct spi_device *spi)
|
2011-03-17 05:07:36 +00:00
|
|
|
{
|
2011-03-17 05:09:38 +00:00
|
|
|
int error;
|
2011-03-17 05:07:36 +00:00
|
|
|
|
2011-03-17 05:09:38 +00:00
|
|
|
spi->mode = SPI_MODE_0;
|
|
|
|
spi->bits_per_word = 8;
|
|
|
|
if (!spi->max_speed_hz)
|
|
|
|
spi->max_speed_hz = TSC2005_SPI_MAX_SPEED_HZ;
|
2011-03-17 05:07:36 +00:00
|
|
|
|
2011-03-17 05:09:38 +00:00
|
|
|
error = spi_setup(spi);
|
|
|
|
if (error)
|
|
|
|
return error;
|
2011-03-17 05:07:36 +00:00
|
|
|
|
2016-07-20 17:02:07 +00:00
|
|
|
return tsc200x_probe(&spi->dev, spi->irq, &tsc2005_input_id,
|
2015-11-03 01:45:51 +00:00
|
|
|
devm_regmap_init_spi(spi, &tsc200x_regmap_config),
|
|
|
|
tsc2005_cmd);
|
2011-03-17 05:07:36 +00:00
|
|
|
}
|
|
|
|
|
2012-11-24 05:50:47 +00:00
|
|
|
static int tsc2005_remove(struct spi_device *spi)
|
2011-03-17 05:07:36 +00:00
|
|
|
{
|
2015-11-03 01:45:51 +00:00
|
|
|
return tsc200x_remove(&spi->dev);
|
2011-03-17 05:07:36 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 23:12:20 +00:00
|
|
|
#ifdef CONFIG_OF
|
|
|
|
static const struct of_device_id tsc2005_of_match[] = {
|
|
|
|
{ .compatible = "ti,tsc2005" },
|
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, tsc2005_of_match);
|
|
|
|
#endif
|
|
|
|
|
2011-03-17 05:07:36 +00:00
|
|
|
static struct spi_driver tsc2005_driver = {
|
2011-03-17 05:08:26 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "tsc2005",
|
2017-02-10 23:12:20 +00:00
|
|
|
.of_match_table = of_match_ptr(tsc2005_of_match),
|
2015-11-03 01:45:51 +00:00
|
|
|
.pm = &tsc200x_pm_ops,
|
2011-03-17 05:07:36 +00:00
|
|
|
},
|
2011-03-17 05:08:26 +00:00
|
|
|
.probe = tsc2005_probe,
|
2012-11-24 05:27:39 +00:00
|
|
|
.remove = tsc2005_remove,
|
2011-03-17 05:07:36 +00:00
|
|
|
};
|
2012-03-17 06:05:26 +00:00
|
|
|
module_spi_driver(tsc2005_driver);
|
2011-03-17 05:07:36 +00:00
|
|
|
|
2015-11-03 01:45:51 +00:00
|
|
|
MODULE_AUTHOR("Michael Welling <mwelling@ieee.org>");
|
2011-03-17 05:09:03 +00:00
|
|
|
MODULE_DESCRIPTION("TSC2005 Touchscreen Driver");
|
2011-03-17 05:07:36 +00:00
|
|
|
MODULE_LICENSE("GPL");
|
2013-02-17 06:01:44 +00:00
|
|
|
MODULE_ALIAS("spi:tsc2005");
|