[tegra/usb host] enabling support for USB3 host
[linux-2.6.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/i2c/panjit_ts.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 #include <linux/tegra_usb.h>
37
38 #include <mach/clk.h>
39 #include <mach/iomap.h>
40 #include <mach/irqs.h>
41 #include <mach/pinmux.h>
42 #include <mach/iomap.h>
43 #include <mach/io.h>
44
45 #include <asm/mach-types.h>
46 #include <asm/mach/arch.h>
47 #include <mach/usb_phy.h>
48
49 #include "board.h"
50 #include "clock.h"
51 #include "board-ventana.h"
52 #include "devices.h"
53 #include "gpio-names.h"
54
55 static struct plat_serial8250_port debug_uart_platform_data[] = {
56         {
57                 .membase        = IO_ADDRESS(TEGRA_UARTD_BASE),
58                 .mapbase        = TEGRA_UARTD_BASE,
59                 .irq            = INT_UARTD,
60                 .flags          = UPF_BOOT_AUTOCONF,
61                 .iotype         = UPIO_MEM,
62                 .regshift       = 2,
63                 .uartclk        = 216000000,
64         }, {
65                 .flags          = 0,
66         }
67 };
68
69 static struct platform_device debug_uart = {
70         .name = "serial8250",
71         .id = PLAT8250_DEV_PLATFORM,
72         .dev = {
73                 .platform_data = debug_uart_platform_data,
74         },
75 };
76
77 static struct tegra_utmip_config utmi_phy_config[] = {
78         [0] = {
79                         .hssync_start_delay = 0,
80                         .idle_wait_delay = 17,
81                         .elastic_limit = 16,
82                         .term_range_adj = 6,
83                         .xcvr_setup = 15,
84                         .xcvr_lsfslew = 2,
85                         .xcvr_lsrslew = 2,
86         },
87         [1] = {
88                         .hssync_start_delay = 0,
89                         .idle_wait_delay = 17,
90                         .elastic_limit = 16,
91                         .term_range_adj = 6,
92                         .xcvr_setup = 8,
93                         .xcvr_lsfslew = 2,
94                         .xcvr_lsrslew = 2,
95         },
96 };
97
98 static struct tegra_ulpi_config ulpi_phy_config = {
99         .reset_gpio = TEGRA_GPIO_PG2,
100         .clk = "cdev2",
101 };
102
103 #ifdef CONFIG_BCM4329_RFKILL
104
105 static struct resource ventana_bcm4329_rfkill_resources[] = {
106         {
107                 .name   = "bcm4329_nreset_gpio",
108                 .start  = TEGRA_GPIO_PU0,
109                 .end    = TEGRA_GPIO_PU0,
110                 .flags  = IORESOURCE_IO,
111         },
112         {
113                 .name   = "bcm4329_nshutdown_gpio",
114                 .start  = TEGRA_GPIO_PK2,
115                 .end    = TEGRA_GPIO_PK2,
116                 .flags  = IORESOURCE_IO,
117         },
118 };
119
120 static struct platform_device ventana_bcm4329_rfkill_device = {
121         .name = "bcm4329_rfkill",
122         .id             = -1,
123         .num_resources  = ARRAY_SIZE(ventana_bcm4329_rfkill_resources),
124         .resource       = ventana_bcm4329_rfkill_resources,
125 };
126
127 static noinline void __init ventana_bt_rfkill(void)
128 {
129         /*Add Clock Resource*/
130         clk_add_alias("bcm4329_32k_clk", ventana_bcm4329_rfkill_device.name, \
131                                 "blink", NULL);
132
133         platform_device_register(&ventana_bcm4329_rfkill_device);
134
135         return;
136 }
137 #else
138 static inline void ventana_bt_rfkill(void) { }
139 #endif
140
141 static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = {
142         /* name         parent          rate            enabled */
143         { "uartd",      "pll_p",        216000000,      true},
144         { "pll_m",      "clk_m",        600000000,      true},
145         { "uartc",      "pll_m",        600000000,      false},
146         { "blink",      "clk_32k",      32768,          false},
147         { "pwm",        "clk_32k",      32768,          false},
148         { NULL,         NULL,           0,              0},
149 };
150
151 static struct tegra_i2c_platform_data ventana_i2c1_platform_data = {
152         .adapter_nr     = 0,
153         .bus_count      = 1,
154         .bus_clk_rate   = { 400000, 0 },
155 };
156
157 static const struct tegra_pingroup_config i2c2_ddc = {
158         .pingroup       = TEGRA_PINGROUP_DDC,
159         .func           = TEGRA_MUX_I2C2,
160 };
161
162 static const struct tegra_pingroup_config i2c2_gen2 = {
163         .pingroup       = TEGRA_PINGROUP_PTA,
164         .func           = TEGRA_MUX_I2C2,
165 };
166
167 static struct tegra_i2c_platform_data ventana_i2c2_platform_data = {
168         .adapter_nr     = 1,
169         .bus_count      = 2,
170         .bus_clk_rate   = { 400000, 100000 },
171         .bus_mux        = { &i2c2_ddc, &i2c2_gen2 },
172         .bus_mux_len    = { 1, 1 },
173 };
174
175 static struct tegra_i2c_platform_data ventana_i2c3_platform_data = {
176         .adapter_nr     = 3,
177         .bus_count      = 1,
178         .bus_clk_rate   = { 400000, 0 },
179 };
180
181 static struct tegra_i2c_platform_data ventana_dvc_platform_data = {
182         .adapter_nr     = 4,
183         .bus_count      = 1,
184         .bus_clk_rate   = { 400000, 0 },
185         .is_dvc         = true,
186 };
187
188 static void ventana_i2c_init(void)
189 {
190         tegra_i2c_device1.dev.platform_data = &ventana_i2c1_platform_data;
191         tegra_i2c_device2.dev.platform_data = &ventana_i2c2_platform_data;
192         tegra_i2c_device3.dev.platform_data = &ventana_i2c3_platform_data;
193         tegra_i2c_device4.dev.platform_data = &ventana_dvc_platform_data;
194
195         platform_device_register(&tegra_i2c_device4);
196         platform_device_register(&tegra_i2c_device3);
197         platform_device_register(&tegra_i2c_device2);
198         platform_device_register(&tegra_i2c_device1);
199 }
200
201 #define GPIO_KEY(_id, _gpio, _iswake)           \
202         {                                       \
203                 .code = _id,                    \
204                 .gpio = TEGRA_GPIO_##_gpio,     \
205                 .active_low = 1,                \
206                 .desc = #_id,                   \
207                 .type = EV_KEY,                 \
208                 .wakeup = _iswake,              \
209                 .debounce_interval = 10,        \
210         }
211
212 static struct gpio_keys_button ventana_keys[] = {
213         [0] = GPIO_KEY(KEY_MENU, PQ3, 0),
214         [1] = GPIO_KEY(KEY_HOME, PQ1, 0),
215         [2] = GPIO_KEY(KEY_BACK, PQ2, 0),
216         [3] = GPIO_KEY(KEY_VOLUMEUP, PQ5, 0),
217         [4] = GPIO_KEY(KEY_VOLUMEDOWN, PQ4, 0),
218         [5] = GPIO_KEY(KEY_POWER, PV2, 1),
219 };
220
221 static struct gpio_keys_platform_data ventana_keys_platform_data = {
222         .buttons        = ventana_keys,
223         .nbuttons       = ARRAY_SIZE(ventana_keys),
224 };
225
226 static struct platform_device ventana_keys_device = {
227         .name   = "gpio-keys",
228         .id     = 0,
229         .dev    = {
230                 .platform_data  = &ventana_keys_platform_data,
231         },
232 };
233
234 static struct platform_device *ventana_devices[] __initdata = {
235         &tegra_otg_device,
236         &debug_uart,
237         &tegra_uart2_device,
238         &pmu_device,
239         &tegra_udc_device,
240         &tegra_gart_device,
241         &tegra_aes_device,
242         &ventana_keys_device,
243         &tegra_wdt_device,
244 };
245
246 static void ventana_keys_init(void)
247 {
248         int i;
249
250         for (i = 0; i < ARRAY_SIZE(ventana_keys); i++)
251                 tegra_gpio_enable(ventana_keys[i].gpio);
252 }
253
254 static struct panjit_i2c_ts_platform_data panjit_data = {
255         .gpio_reset = TEGRA_GPIO_PQ7,
256 };
257
258 static const struct i2c_board_info ventana_i2c_bus1_touch_info[] = {
259         {
260                 I2C_BOARD_INFO("panjit_touch", 0x3),
261                 .irq            = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
262                 .platform_data  = &panjit_data,
263         },
264 };
265
266 static int __init ventana_touch_init(void)
267 {
268         tegra_gpio_enable(TEGRA_GPIO_PV6);
269
270         tegra_gpio_enable(TEGRA_GPIO_PQ7);
271         i2c_register_board_info(0, ventana_i2c_bus1_touch_info, 1);
272
273         return 0;
274 }
275
276
277 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
278         [0] = {
279                         .phy_config = &utmi_phy_config[0],
280                         .operating_mode = TEGRA_USB_HOST,
281                         .power_down_on_bus_suspend = 0,
282         },
283         [1] = {
284                         .phy_config = &ulpi_phy_config,
285                         .operating_mode = TEGRA_USB_HOST,
286                         .power_down_on_bus_suspend = 1,
287         },
288         [2] = {
289                         .phy_config = &utmi_phy_config[1],
290                         .operating_mode = TEGRA_USB_HOST,
291                         .power_down_on_bus_suspend = 0,
292         },
293 };
294
295 static void ventana_usb_init()
296 {
297         tegra_ehci3_device.dev.platform_data=&tegra_ehci_pdata[2];
298         platform_device_register(&tegra_ehci3_device);
299 }
300
301 static void __init tegra_ventana_init(void)
302 {
303         tegra_common_init();
304
305         tegra_clk_init_from_table(ventana_clk_init_table);
306         ventana_pinmux_init();
307
308         platform_add_devices(ventana_devices, ARRAY_SIZE(ventana_devices));
309         ventana_sdhci_init();
310         ventana_i2c_init();
311         ventana_regulator_init();
312         ventana_touch_init();
313         ventana_keys_init();
314         ventana_usb_init();
315         ventana_panel_init();
316         ventana_sensors_init();
317         ventana_bt_rfkill();
318 }
319
320 MACHINE_START(VENTANA, "ventana")
321         .boot_params    = 0x00000100,
322         .phys_io        = IO_APB_PHYS,
323         .io_pg_offst    = ((IO_APB_VIRT) >> 18) & 0xfffc,
324         .init_irq       = tegra_init_irq,
325         .init_machine   = tegra_ventana_init,
326         .map_io         = tegra_map_common_io,
327         .timer          = &tegra_timer,
328 MACHINE_END