arm: tegra: Cardhu: E1198 DirectTouch setup
Ali Ekici [Tue, 20 Mar 2012 16:29:43 +0000 (09:29 -0700)]
Modified touch setup and init calls to support DirectTouch
in E1198 19x12 system.

Change-Id: Ide208c4759af15200fb57530e7fbdc023d074c5c
Signed-off-by: Ali Ekici <aekici@nvidia.com>
Reviewed-on: http://git-master/r/91260
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

arch/arm/mach-tegra/board-cardhu.c
arch/arm/mach-tegra/board-touch.h [new file with mode: 0644]

index 339011e..cce0d4d 100644 (file)
@@ -62,6 +62,7 @@
 #include "board.h"
 #include "clock.h"
 #include "board-cardhu.h"
+#include "board-touch.h"
 #include "devices.h"
 #include "gpio-names.h"
 #include "fuse.h"
@@ -574,6 +575,10 @@ static struct platform_device *cardhu_spi_devices[] __initdata = {
        &tegra_spi_device4,
 };
 
+static struct platform_device *touch_spi_device[] __initdata = {
+       &tegra_spi_device1,
+};
+
 struct spi_clk_parent spi_parent_clk[] = {
        [0] = {.name = "pll_p"},
 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
@@ -595,9 +600,10 @@ static void __init cardhu_spi_init(void)
 {
        int i;
        struct clk *c;
-       struct board_info board_info;
+       struct board_info board_info, display_board_info;
 
        tegra_get_board_info(&board_info);
+       tegra_get_display_board_info(&display_board_info);
 
        for (i = 0; i < ARRAY_SIZE(spi_parent_clk); ++i) {
                c = tegra_get_clock_by_name(spi_parent_clk[i].name);
@@ -615,6 +621,10 @@ static void __init cardhu_spi_init(void)
        platform_add_devices(cardhu_spi_devices,
                                ARRAY_SIZE(cardhu_spi_devices));
 
+       if (display_board_info.board_id == BOARD_DISPLAY_PM313) {
+               platform_add_devices(touch_spi_device,
+                               ARRAY_SIZE(touch_spi_device));
+       }
        if (board_info.board_id == BOARD_E1198) {
                tegra_spi_device2.dev.platform_data = &cardhu_spi_pdata;
                platform_device_register(&tegra_spi_device2);
@@ -821,30 +831,43 @@ static struct i2c_board_info __initdata atmel_i2c_info[] = {
        }
 };
 
+static __initdata struct tegra_clk_init_table spi_clk_init_table[] = {
+       /* name         parent          rate            enabled */
+       { "sbc1",       "pll_p",        52000000,       true},
+       { NULL,         NULL,           0,              0},
+};
+
 static int __init cardhu_touch_init(void)
 {
        struct board_info BoardInfo;
 
-       tegra_gpio_enable(TEGRA_GPIO_PH4);
-       tegra_gpio_enable(TEGRA_GPIO_PH6);
-
-       gpio_request(TEGRA_GPIO_PH4, "atmel-irq");
-       gpio_direction_input(TEGRA_GPIO_PH4);
+       tegra_get_display_board_info(&BoardInfo);
+       if (BoardInfo.board_id == BOARD_DISPLAY_PM313) {
+               tegra_clk_init_from_table(spi_clk_init_table);
 
-       gpio_request(TEGRA_GPIO_PH6, "atmel-reset");
-       gpio_direction_output(TEGRA_GPIO_PH6, 0);
-       msleep(1);
-       gpio_set_value(TEGRA_GPIO_PH6, 1);
-       msleep(100);
+               touch_init_raydium(TEGRA_GPIO_PH4, TEGRA_GPIO_PH6, 2);
+       } else {
+               tegra_gpio_enable(TEGRA_GPIO_PH4);
+               tegra_gpio_enable(TEGRA_GPIO_PH6);
+
+               gpio_request(TEGRA_GPIO_PH4, "atmel-irq");
+               gpio_direction_input(TEGRA_GPIO_PH4);
+
+               gpio_request(TEGRA_GPIO_PH6, "atmel-reset");
+               gpio_direction_output(TEGRA_GPIO_PH6, 0);
+               msleep(1);
+               gpio_set_value(TEGRA_GPIO_PH6, 1);
+               msleep(100);
+
+               tegra_get_board_info(&BoardInfo);
+               if ((BoardInfo.sku & SKU_TOUCH_MASK) == SKU_TOUCH_2000) {
+                       atmel_mxt_info.config = config_sku2000;
+                       atmel_mxt_info.config_crc = MXT_CONFIG_CRC_SKU2000;
+               }
 
-       tegra_get_board_info(&BoardInfo);
-       if ((BoardInfo.sku & SKU_TOUCH_MASK) == SKU_TOUCH_2000) {
-               atmel_mxt_info.config = config_sku2000;
-               atmel_mxt_info.config_crc = MXT_CONFIG_CRC_SKU2000;
+               i2c_register_board_info(1, atmel_i2c_info, 1);
        }
 
-       i2c_register_board_info(1, atmel_i2c_info, 1);
-
        return 0;
 }
 
diff --git a/arch/arm/mach-tegra/board-touch.h b/arch/arm/mach-tegra/board-touch.h
new file mode 100644 (file)
index 0000000..61b64d3
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * arch/arm/mach-tegra/board-touch.h
+ *
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _MACH_TEGRA_BOARD_TOUCH_H
+#define _MACH_TEGRA_BOARD_TOUCH_H
+
+
+int __init touch_init_raydium(int irq_gpio, int reset_gpio, int platform);
+
+#endif