arm: ardbeg: board file change for maxim touch
Xiaohui Tao [Fri, 20 Sep 2013 20:37:30 +0000 (13:37 -0700)]
Bug 1364399

Change-Id: I4c8f854e7d3c08dcf6d91350c41a490ffdeb2f7e
Signed-off-by: Xiaohui Tao <xtao@nvidia.com>
Signed-off-by: Hayden Du <haydend@nvidia.com>
Reviewed-on: http://git-master/r/289391
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/board-ardbeg.c
arch/arm/mach-tegra/board-ardbeg.h
arch/arm/mach-tegra/board-touch-maxim_sti-spi.c [new file with mode: 0644]
arch/arm/mach-tegra/board-touch-maxim_sti.h [new file with mode: 0644]
arch/arm/mach-tegra/board.h

index f96f50d..1061465 100644 (file)
@@ -204,6 +204,7 @@ obj-${CONFIG_MACH_BONAIRE}              += board-bonaire-sensors.o
 
 obj-y                                   += board-touch-raydium_spi.o
 obj-y                                   += board-touch-synaptics-spi.o
+obj-y                                   += board-touch-maxim_sti-spi.o
 
 obj-y                                   += board-panel.o
 
index 60bb337..a13b5e0 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/platform_data/tegra_usb.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/rm31080a_ts.h>
+#include <linux/maxim_sti.h>
 #include <linux/memblock.h>
 #include <linux/spi/spi-tegra.h>
 #include <linux/nfc/pn544.h>
@@ -77,6 +78,7 @@
 #include "board-ardbeg.h"
 #include "board-common.h"
 #include "board-touch-raydium.h"
+#include "board-touch-maxim_sti.h"
 #include "clock.h"
 #include "common.h"
 #include "devices.h"
@@ -924,6 +926,36 @@ struct of_dev_auxdata ardbeg_auxdata_lookup[] __initdata = {
 };
 #endif
 
+struct maxim_sti_pdata maxim_sti_pdata = {
+       .touch_fusion         = "/vendor/bin/touch_fusion",
+       .config_file          = "/vendor/firmware/touch_fusion.cfg",
+       .fw_name              = "maxim_fp35.bin",
+       .nl_family            = TF_FAMILY_NAME,
+       .nl_mc_groups         = 5,
+       .chip_access_method   = 2,
+       .default_reset_state  = 0,
+       .tx_buf_size          = 4100,
+       .rx_buf_size          = 4100,
+       .gpio_reset           = TOUCH_GPIO_RST_MAXIM_STI_SPI,
+       .gpio_irq             = TOUCH_GPIO_IRQ_MAXIM_STI_SPI
+};
+
+static struct tegra_spi_device_controller_data maxim_dev_cdata = {
+       .rx_clk_tap_delay = 0,
+       .is_hw_based_cs = true,
+       .tx_clk_tap_delay = 0,
+};
+
+struct spi_board_info maxim_sti_spi_board = {
+       .modalias = MAXIM_STI_NAME,
+       .bus_num = TOUCH_SPI_ID,
+       .chip_select = TOUCH_SPI_CS,
+       .max_speed_hz = 12 * 1000 * 1000,
+       .mode = SPI_MODE_0,
+       .platform_data = &maxim_sti_pdata,
+       .controller_data = &maxim_dev_cdata,
+};
+
 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
        /* name         parent          rate            enabled */
        { "extern2",    "pll_p",        41000000,       false},
@@ -958,14 +990,23 @@ struct spi_board_info rm31080a_ardbeg_spi_board[1] = {
 
 static int __init ardbeg_touch_init(void)
 {
-       tegra_clk_init_from_table(touch_clk_init_table);
-       rm31080a_ardbeg_spi_board[0].irq =
-               gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
-       touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
+       if (tegra_get_touch_vendor_id() == MAXIM_TOUCH) {
+               pr_info("%s init maxim touch\n", __func__);
+#if defined(CONFIG_TOUCHSCREEN_MAXIM_STI) || \
+       defined(CONFIG_TOUCHSCREEN_MAXIM_STI_MODULE)
+               (void)touch_init_maxim_sti(&maxim_sti_spi_board);
+#endif
+       } else if (tegra_get_touch_vendor_id() == RAYDIUM_TOUCH) {
+               pr_info("%s init raydium touch\n", __func__);
+               tegra_clk_init_from_table(touch_clk_init_table);
+               rm31080a_ardbeg_spi_board[0].irq =
+                       gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
+               touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
                                TOUCH_GPIO_RST_RAYDIUM_SPI,
                                &rm31080ts_ardbeg_data,
                                &rm31080a_ardbeg_spi_board[0],
                                ARRAY_SIZE(rm31080a_ardbeg_spi_board));
+       }
        return 0;
 }
 
index d247cad..82ca11c 100644 (file)
@@ -101,6 +101,9 @@ enum tegra_bb_type {
 #define TOUCH_SPI_ID                   0       /*SPI 1 on ardbeg_interposer*/
 #define TOUCH_SPI_CS                   0       /*CS  0 on ardbeg_interposer*/
 
+#define TOUCH_GPIO_IRQ_MAXIM_STI_SPI   TEGRA_GPIO_PK2
+#define TOUCH_GPIO_RST_MAXIM_STI_SPI   TEGRA_GPIO_PK4
+
 /* Audio-related GPIOs */
 /*Same GPIO's used for T114(Interposer) and T124*/
 /*Below GPIO's are same for Laguna and Ardbeg*/
diff --git a/arch/arm/mach-tegra/board-touch-maxim_sti-spi.c b/arch/arm/mach-tegra/board-touch-maxim_sti-spi.c
new file mode 100644 (file)
index 0000000..5a4e28a
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * arch/arm/mach-tegra/board-touch-maxim_sti-spi.c
+ *
+ * Copyright (c)2013 Maxim Integrated Products, Inc.
+ * Copyright (C) 2013, NVIDIA Corporation.  All Rights Reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#if defined(CONFIG_TOUCHSCREEN_MAXIM_STI) || \
+       defined(CONFIG_TOUCHSCREEN_MAXIM_STI_MODULE)
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/spi/spi-tegra.h>
+#include <linux/spi/spi.h>
+#include <linux/gpio.h>
+#include <linux/maxim_sti.h>
+
+#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;                                                \
+       } })
+static int maxim_sti_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;
+}
+
+static void maxim_sti_reset(struct maxim_sti_pdata *pdata, int value)
+{
+       gpio_set_value(pdata->gpio_reset, !!value);
+}
+
+static int maxim_sti_irq(struct maxim_sti_pdata *pdata)
+{
+       return gpio_get_value(pdata->gpio_irq);
+}
+
+void __init touch_init_maxim_sti(struct spi_board_info *spi_board)
+{
+       struct maxim_sti_pdata  *pdata;
+
+       pdata = (struct maxim_sti_pdata *)spi_board->platform_data;
+       pdata->init  = maxim_sti_init;
+       pdata->reset = maxim_sti_reset;
+       pdata->irq   = maxim_sti_irq;
+
+       spi_board->irq = gpio_to_irq(pdata->gpio_irq);
+
+       spi_register_board_info(spi_board, 1);
+}
+
+#endif
+
diff --git a/arch/arm/mach-tegra/board-touch-maxim_sti.h b/arch/arm/mach-tegra/board-touch-maxim_sti.h
new file mode 100644 (file)
index 0000000..af27543
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * arch/arm/mach-tegra/board-touch-maxim_sti.h
+ *
+ * Copyright (c)2013 Maxim Integrated Products, Inc.
+ * Copyright (C) 2013, NVIDIA Corporation.  All Rights Reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#ifndef _MACH_TEGRA_BOARD_TOUCH_MAXIM_STI_H
+#define _MACH_TEGRA_BOARD_TOUCH_MAXIM_STI_H
+
+void __init touch_init_maxim_sti(struct spi_board_info *spi_board);
+
+#endif
+
index dc4abbc..6c9313c 100644 (file)
@@ -211,6 +211,7 @@ enum panel_type {
 enum touch_type {
        RAYDIUM_TOUCH  = 0,
        SYNAPTIC_TOUCH = 1,
+       MAXIM_TOUCH = 2,
 };
 
 enum audio_codec_type {