arm: tegra: sd: enable sd dpd
[linux-2.6.git] / arch / arm / mach-tegra / board-touch-kai-synaptics-spi.c
1 /*
2  * arch/arm/mach-tegra/board-touch-synaptics-spi.c
3  *
4  * Copyright (C) 2010-2012 NVIDIA Corporation
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/spi/spi.h>
19 #include <linux/delay.h>
20 #include <linux/gpio.h>
21 #include <linux/input.h>
22 #include <linux/interrupt.h>
23 #include <linux/spi/spi.h>
24 #include <linux/rmi.h>
25 #include "board.h"
26 #include "board-kai.h"
27
28 #define SYNAPTICS_SPI_CS 0
29 #define SYNAPTICS_BUTTON_CODES {KEY_HOME, KEY_BACK,}
30
31 static unsigned char synaptics_button_codes[] = SYNAPTICS_BUTTON_CODES;
32
33 static struct rmi_f19_button_map synaptics_button_map = {
34         .nbuttons = ARRAY_SIZE(synaptics_button_codes),
35         .map = synaptics_button_codes,
36 };
37
38 static int synaptics_touchpad_gpio_setup(void *gpio_data, bool configure)
39 {
40         if (configure) {
41                 tegra_gpio_enable(SYNAPTICS_ATTN_GPIO);
42                 gpio_request(SYNAPTICS_ATTN_GPIO, "synaptics-irq");
43                 gpio_direction_input(SYNAPTICS_ATTN_GPIO);
44
45                 tegra_gpio_enable(SYNAPTICS_RESET_GPIO);
46                 gpio_request(SYNAPTICS_RESET_GPIO, "synaptics-reset");
47                 gpio_direction_output(SYNAPTICS_RESET_GPIO, 0);
48
49                 msleep(1);
50                 gpio_set_value(SYNAPTICS_RESET_GPIO, 1);
51                 msleep(100);
52         } else {
53                 gpio_free(SYNAPTICS_ATTN_GPIO);
54                 gpio_free(SYNAPTICS_RESET_GPIO);
55                 tegra_gpio_disable(SYNAPTICS_ATTN_GPIO);
56                 tegra_gpio_disable(SYNAPTICS_RESET_GPIO);
57         }
58         return 0;
59 }
60
61 static struct rmi_device_platform_data synaptics_platformdata = {
62         .driver_name = "rmi_generic",
63         .irq = SYNAPTICS_ATTN_GPIO,
64         .irq_polarity = RMI_IRQ_ACTIVE_LOW,
65         .gpio_config = synaptics_touchpad_gpio_setup,
66         .spi_data = {
67                 .block_delay_us = 15,
68                 .read_delay_us = 15,
69                 .write_delay_us = 2,
70         },
71         .axis_align = {
72                 .flip_y = true,
73         },
74         .button_map = &synaptics_button_map,
75 };
76
77 struct spi_board_info synaptics_2002_spi_board[] = {
78         {
79                 .modalias = "rmi_spi",
80                 .bus_num = 0,
81                 .chip_select = 0,
82                 .irq = 999,  /* just to make sure this one is not being used */
83                 .max_speed_hz = 1*1000*1000,
84                 .mode = SPI_MODE_3,
85                 .platform_data = &synaptics_platformdata,
86         },
87 };
88
89 int __init touch_init_synaptics_kai(void)
90 {
91         pr_info("%s: registering synaptics_2002_spi_board\n", __func__);
92         pr_info("               modalias     = %s\n",
93                                         synaptics_2002_spi_board->modalias);
94         pr_info("               bus_num      = %d\n",
95                                         synaptics_2002_spi_board->bus_num);
96         pr_info("               chip_select  = %d\n",
97                                         synaptics_2002_spi_board->chip_select);
98         pr_info("               irq          = %d\n",
99                                         synaptics_2002_spi_board->irq);
100         pr_info("               max_speed_hz = %d\n",
101                                         synaptics_2002_spi_board->max_speed_hz);
102         pr_info("               mode         = %d\n",
103                                         synaptics_2002_spi_board->mode);
104
105         msleep(100);
106         spi_register_board_info(synaptics_2002_spi_board,
107                                         ARRAY_SIZE(synaptics_2002_spi_board));
108         return 0;
109 }