summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/maxim_sti_ts.txt46
-rw-r--r--drivers/input/touchscreen/maxim_sti.c185
2 files changed, 231 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/maxim_sti_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/maxim_sti_ts.txt
new file mode 100644
index 000000000000..39902898abf0
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/maxim_sti_ts.txt
@@ -0,0 +1,46 @@
+Maxim touch.
+
+Required properties:
+- compatible.
+- reg.
+- spi-max-frequency.
+- interrupt-parent.
+- interrupts.
+- maxim_sti,reset-gpio.
+- maxim_sti,touch_fusion.
+- maxim_sti,config_file.
+- maxim_sti,fw_name.
+- maxim_sti,nl_family.
+- maxim_sti,nl_mc_groups.
+- maxim_sti,chip_access_method.
+- maxim_sti,default_reset_state.
+- maxim_sti,tx_buf_size.
+- maxim_sti,rx_buf_size.
+
+Sample:
+ spi@7000d400 {
+ maxim_sti@0 {
+ status = "okay";
+ compatible = "maxim,maxim_sti";
+ spi-max-frequency = <12000000>;
+ reg = <0>; /* chip select */
+ interrupt-parent = <&gpio>;
+ interrupts = <TEGRA_GPIO(K, 2) 0x02>;
+ maxim_sti,reset-gpio = <TEGRA_GPIO(K, 4)>;
+ maxim_sti,touch_fusion = "/vendor/bin/touch_fusion";
+ maxim_sti,config_file = "/vendor/firmware/touch_fusion.cfg";
+ maxim_sti,fw_name = "maxim_fp35.bin";
+ maxim_sti,nl_family = "touch_fusion";
+ maxim_sti,nl_mc_groups = <5>;
+ maxim_sti,chip_access_method = <2>;
+ maxim_sti,default_reset_state = <0>;
+ maxim_sti,tx_buf_size = <4100>;
+ maxim_sti,rx_buf_size = <4100>;
+ controller-data {
+ nvidia,enable-hw-based-cs;
+ nvidia,rx-clk-tap-delay = <0>;
+ nvidia,tx-clk-tap-delay = <0>;
+ };
+ };
+ };
+
diff --git a/drivers/input/touchscreen/maxim_sti.c b/drivers/input/touchscreen/maxim_sti.c
index abb91ee42f56..6100bd827ac0 100644
--- a/drivers/input/touchscreen/maxim_sti.c
+++ b/drivers/input/touchscreen/maxim_sti.c
@@ -28,6 +28,12 @@
#include <linux/regulator/consumer.h>
#include <linux/maxim_sti.h>
#include <asm/byteorder.h> /* MUST include this header to get byte order */
+#ifdef CONFIG_OF
+#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#endif
#define CREATE_TRACE_POINTS
#include <trace/events/touchscreen_maxim.h>
@@ -795,6 +801,159 @@ err_null_regulator:
dev_warn(&dd->spi->dev, "Failed to init regulators\n");
}
+#ifdef CONFIG_OF
+#define MAXIM_STI_GPIO_ERROR(ret, gpio, op) \
+{ \
+ if (ret < 0) { \
+ pr_err("%s: GPIO %d %s failed (%d)\n", __func__, gpio, op, \
+ ret); \
+ return ret; \
+ } \
+}
+
+
+int maxim_sti_gpio_init(struct maxim_sti_pdata *pdata, bool init)
+{
+ int ret;
+
+ if (init) {
+ ret = gpio_request(pdata->gpio_irq, "maxim_sti_irq");
+ MAXIM_STI_GPIO_ERROR(ret, pdata->gpio_irq, "request");
+ ret = gpio_direction_input(pdata->gpio_irq);
+ MAXIM_STI_GPIO_ERROR(ret, pdata->gpio_irq, "direction");
+
+ ret = gpio_request(pdata->gpio_reset, "maxim_sti_reset");
+ MAXIM_STI_GPIO_ERROR(ret, pdata->gpio_reset, "request");
+ ret = gpio_direction_output(pdata->gpio_reset,
+ pdata->default_reset_state);
+ MAXIM_STI_GPIO_ERROR(ret, pdata->gpio_reset, "direction");
+ } else {
+ gpio_free(pdata->gpio_irq);
+ gpio_free(pdata->gpio_reset);
+ }
+
+ return 0;
+}
+
+void maxim_sti_gpio_reset(struct maxim_sti_pdata *pdata, int value)
+{
+ gpio_set_value(pdata->gpio_reset, !!value);
+}
+
+int maxim_sti_gpio_irq(struct maxim_sti_pdata *pdata)
+{
+ return gpio_get_value(pdata->gpio_irq);
+}
+
+/****************************************************************************\
+* Device Tree Support
+\****************************************************************************/
+
+static int maxim_parse_dt(struct device *dev, struct maxim_sti_pdata *pdata)
+{
+ struct device_node *np = dev->of_node;
+ u32 val;
+ const char *str;
+ int ret;
+
+
+ ret = of_property_read_u32(np, "maxim_sti,reset-gpio",
+ &pdata->gpio_reset);
+ if (ret) {
+ dev_err(dev, "%s: unable to read reset-gpio (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+
+ ret = of_property_read_u32(np, "interrupts", &pdata->gpio_irq);
+ if (ret) {
+ dev_err(dev, "%s: unable to read irq-gpio (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+
+ ret = of_property_read_u32(np, "maxim_sti,nl_mc_groups", &val);
+ if (ret) {
+ dev_err(dev, "%s: unable to read nl_mc_groups (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->nl_mc_groups = (u8)val;
+
+ ret = of_property_read_u32(np, "maxim_sti,chip_access_method", &val);
+ if (ret) {
+ dev_err(dev, "%s: unable to read chip_access_method (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->chip_access_method = (u8)val;
+
+ ret = of_property_read_u32(np, "maxim_sti,default_reset_state", &val);
+ if (ret) {
+ dev_err(dev, "%s: unable to read default_reset_state (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->default_reset_state = (u8)val;
+
+ ret = of_property_read_u32(np, "maxim_sti,tx_buf_size", &val);
+ if (ret) {
+ dev_err(dev, "%s: unable to read tx_buf_size (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->tx_buf_size = (u16)val;
+
+ ret = of_property_read_u32(np, "maxim_sti,rx_buf_size", &val);
+ if (ret) {
+ dev_err(dev, "%s: unable to read rx_buf_size (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->rx_buf_size = (u16)val;
+
+ ret = of_property_read_string(np, "maxim_sti,touch_fusion", &str);
+ if (ret) {
+ dev_err(dev, "%s: unable to read touch_fusion location (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->touch_fusion = (char *)str;
+
+ ret = of_property_read_string(np, "maxim_sti,config_file", &str);
+ if (ret) {
+ dev_err(dev, "%s: unable to read config_file location (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->config_file = (char *)str;
+
+ ret = of_property_read_string(np, "maxim_sti,nl_family", &str);
+ if (ret) {
+ dev_err(dev, "%s: unable to read nl_family (%d)\n",
+ __func__, ret);
+ goto fail;
+ }
+ pdata->nl_family = (char *)str;
+
+ ret = of_property_read_string(np, "maxim_sti,fw_name", &str);
+ if (ret) {
+ dev_err(dev, "%s: unable to read fw_name (%d)\n",
+ __func__, ret);
+ }
+ pdata->fw_name = (char *)str;
+
+ pdata->init = maxim_sti_gpio_init;
+ pdata->reset = maxim_sti_gpio_reset;
+ pdata->irq = maxim_sti_gpio_irq;
+
+ return 0;
+
+fail:
+ return ret;
+}
+#endif
+
/****************************************************************************\
* Suspend/resume processing *
\****************************************************************************/
@@ -1824,6 +1983,22 @@ static int probe(struct spi_device *spi)
int ret, i;
void *ptr;
+#ifdef CONFIG_OF
+ if (pdata == NULL && spi->dev.of_node) {
+ pdata = devm_kzalloc(&spi->dev,
+ sizeof(struct maxim_sti_pdata), GFP_KERNEL);
+ if (!pdata) {
+ dev_err(&spi->dev, "failed to allocate memory\n");
+ return -ENOMEM;
+ }
+
+ ret = maxim_parse_dt(&spi->dev, pdata);
+ if (ret)
+ return ret;
+ spi->dev.platform_data = pdata;
+ }
+#endif
+
/* validate platform data */
if (pdata == NULL || pdata->init == NULL || pdata->reset == NULL ||
pdata->irq == NULL || pdata->touch_fusion == NULL ||
@@ -2035,6 +2210,13 @@ static const struct spi_device_id id[] = {
MODULE_DEVICE_TABLE(spi, id);
+#ifdef CONFIG_OF
+static struct of_device_id maxim_match_table[] = {
+ { .compatible = "maxim,maxim_sti",},
+ { },
+};
+#endif
+
static struct spi_driver driver = {
.probe = probe,
.remove = remove,
@@ -2042,6 +2224,9 @@ static struct spi_driver driver = {
.id_table = id,
.driver = {
.name = MAXIM_STI_NAME,
+#ifdef CONFIG_OF
+ .of_match_table = maxim_match_table,
+#endif
.owner = THIS_MODULE,
#if defined(CONFIG_PM_SLEEP) && DOUBLE_TAP
.pm = &pm_ops,