[ARM] tegra: usb_phy: Moved suspend/resume code to ehci driver
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-ventana.c
1 /*
2  * arch/arm/mach-tegra/board-ventana.c
3  *
4  * Copyright (c) 2010, NVIDIA Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/slab.h>
24 #include <linux/ctype.h>
25 #include <linux/platform_device.h>
26 #include <linux/clk.h>
27 #include <linux/serial_8250.h>
28 #include <linux/i2c.h>
29 #include <linux/pda_power.h>
30 #include <linux/dma-mapping.h>
31 #include <linux/delay.h>
32 #include <linux/i2c-tegra.h>
33 #include <linux/gpio.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/input.h>
36
37 #include <mach/iomap.h>
38 #include <mach/irqs.h>
39 #include <mach/pinmux.h>
40 #include <mach/iomap.h>
41 #include <mach/io.h>
42
43 #include <asm/mach-types.h>
44 #include <asm/mach/arch.h>
45
46 #include "board.h"
47 #include "clock.h"
48 #include "board-ventana.h"
49 #include "devices.h"
50 #include "gpio-names.h"
51
52 static struct plat_serial8250_port debug_uart_platform_data[] = {
53         {
54                 .membase        = IO_ADDRESS(TEGRA_UARTD_BASE),
55                 .mapbase        = TEGRA_UARTD_BASE,
56                 .irq            = INT_UARTD,
57                 .flags          = UPF_BOOT_AUTOCONF,
58                 .iotype         = UPIO_MEM,
59                 .regshift       = 2,
60                 .uartclk        = 216000000,
61         }, {
62                 .flags          = 0,
63         }
64 };
65
66 static struct platform_device debug_uart = {
67         .name = "serial8250",
68         .id = PLAT8250_DEV_PLATFORM,
69         .dev = {
70                 .platform_data = debug_uart_platform_data,
71         },
72 };
73
74 static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = {
75         /* name         parent          rate            enabled */
76         { "uartd",      "pll_p",        216000000,      true},
77         { "pll_m",      "clk_m",        600000000,      true},
78         { "emc",        "pll_m",        600000000,      true},
79         { NULL,         NULL,           0,              0},
80 };
81
82 /* PDA power */
83 static struct pda_power_pdata pda_power_pdata = {
84 };
85
86 static struct platform_device pda_power_device = {
87         .name   = "pda_power",
88         .id     = -1,
89         .dev    = {
90                 .platform_data  = &pda_power_pdata,
91         },
92 };
93
94 static struct tegra_i2c_platform_data ventana_i2c1_platform_data = {
95         .adapter_nr     = 0,
96         .bus_count      = 1,
97         .bus_clk_rate   = { 400000, 0 },
98 };
99
100 static const struct tegra_pingroup_config i2c2_ddc = {
101         .pingroup       = TEGRA_PINGROUP_DDC,
102         .func           = TEGRA_MUX_I2C2,
103 };
104
105 static const struct tegra_pingroup_config i2c2_gen2 = {
106         .pingroup       = TEGRA_PINGROUP_PTA,
107         .func           = TEGRA_MUX_I2C2,
108 };
109
110 static struct tegra_i2c_platform_data ventana_i2c2_platform_data = {
111         .adapter_nr     = 1,
112         .bus_count      = 2,
113         .bus_clk_rate   = { 400000, 100000 },
114         .bus_mux        = { &i2c2_ddc, &i2c2_gen2 },
115         .bus_mux_len    = { 1, 1 },
116 };
117
118 static struct tegra_i2c_platform_data ventana_i2c3_platform_data = {
119         .adapter_nr     = 3,
120         .bus_count      = 1,
121         .bus_clk_rate   = { 400000, 0 },
122 };
123
124 static struct tegra_i2c_platform_data ventana_dvc_platform_data = {
125         .adapter_nr     = 4,
126         .bus_count      = 1,
127         .bus_clk_rate   = { 400000, 0 },
128         .is_dvc         = true,
129 };
130
131 static void ventana_i2c_init(void)
132 {
133         tegra_i2c_device1.dev.platform_data = &ventana_i2c1_platform_data;
134         tegra_i2c_device2.dev.platform_data = &ventana_i2c2_platform_data;
135         tegra_i2c_device3.dev.platform_data = &ventana_i2c3_platform_data;
136         tegra_i2c_device4.dev.platform_data = &ventana_dvc_platform_data;
137
138         platform_device_register(&tegra_i2c_device4);
139         platform_device_register(&tegra_i2c_device3);
140         platform_device_register(&tegra_i2c_device2);
141         platform_device_register(&tegra_i2c_device1);
142 }
143
144 #define GPIO_KEY(_id, _gpio, _iswake)           \
145         {                                       \
146                 .code = _id,                    \
147                 .gpio = TEGRA_GPIO_##_gpio,     \
148                 .active_low = 1,                \
149                 .desc = #_id,                   \
150                 .type = EV_KEY,                 \
151                 .wakeup = _iswake,              \
152                 .debounce_interval = 10,        \
153         }
154
155 static struct gpio_keys_button ventana_keys[] = {
156         [0] = GPIO_KEY(KEY_MENU, PQ0, 0),
157         [1] = GPIO_KEY(KEY_HOME, PQ1, 0),
158         [2] = GPIO_KEY(KEY_BACK, PQ2, 0),
159         [3] = GPIO_KEY(KEY_VOLUMEUP, PQ3, 0),
160         [4] = GPIO_KEY(KEY_VOLUMEDOWN, PQ4, 0),
161         [5] = GPIO_KEY(KEY_POWER, PV2, 1),
162 };
163
164 static struct gpio_keys_platform_data ventana_keys_platform_data = {
165         .buttons        = ventana_keys,
166         .nbuttons       = ARRAY_SIZE(ventana_keys),
167 };
168
169 static struct platform_device ventana_keys_device = {
170         .name   = "gpio-keys",
171         .id     = 0,
172         .dev    = {
173                 .platform_data  = &ventana_keys_platform_data,
174         },
175 };
176
177 static struct platform_device *ventana_devices[] __initdata = {
178         &debug_uart,
179         &pmu_device,
180         &tegra_udc_device,
181         &pda_power_device,
182         &tegra_gart_device,
183         &ventana_keys_device,
184 };
185
186 static void ventana_touch_reset(void)
187 {
188         gpio_set_value(TEGRA_GPIO_PQ7, 1);
189         msleep(50);
190         gpio_set_value(TEGRA_GPIO_PQ7, 0);
191         msleep(50);
192 }
193
194 static void ventana_keys_init(void)
195 {
196         int i;
197
198         for (i = 0; i < ARRAY_SIZE(ventana_keys); i++)
199                 tegra_gpio_enable(ventana_keys[i].gpio);
200 }
201
202 static const struct i2c_board_info ventana_i2c_bus1_touch_info[] = {
203         {
204                 I2C_BOARD_INFO("panjit_touch", 0x3),
205                 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
206         },
207 };
208
209 static int __init ventana_touch_init(void)
210 {
211         tegra_gpio_enable(TEGRA_GPIO_PV6);
212
213         tegra_gpio_enable(TEGRA_GPIO_PQ7);
214         gpio_request(TEGRA_GPIO_PQ7, "touch_reset");
215         gpio_direction_output(TEGRA_GPIO_PQ7, 1);
216
217         ventana_touch_reset();
218         i2c_register_board_info(0, ventana_i2c_bus1_touch_info, 1);
219
220         return 0;
221 }
222
223 static void __init tegra_ventana_init(void)
224 {
225         tegra_common_init();
226
227         tegra_clk_init_from_table(ventana_clk_init_table);
228         ventana_pinmux_init();
229
230         platform_add_devices(ventana_devices, ARRAY_SIZE(ventana_devices));
231         ventana_sdhci_init();
232         ventana_i2c_init();
233         ventana_regulator_init();
234         ventana_touch_init();
235         ventana_keys_init();
236 }
237
238 MACHINE_START(VENTANA, "ventana")
239         .boot_params    = 0x00000100,
240         .phys_io        = IO_APB_PHYS,
241         .io_pg_offst    = ((IO_APB_VIRT) >> 18) & 0xfffc,
242         .init_irq       = tegra_init_irq,
243         .init_machine   = tegra_ventana_init,
244         .map_io         = tegra_map_common_io,
245         .timer          = &tegra_timer,
246 MACHINE_END