arm: tegra: usb_phy: add support for t114 usb_phy
[linux-3.10.git] / arch / arm / mach-tegra / board-curacao.c
1 /*
2  * arch/arm/mach-tegra/board-curacao.c
3  *
4  * Copyright (c) 2011-2012, 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/tegra_uart.h>
29 #include <linux/i2c.h>
30 #include <linux/i2c/panjit_ts.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/delay.h>
33 #include <linux/i2c-tegra.h>
34 #include <linux/gpio.h>
35 #include <linux/gpio_keys.h>
36 #include <linux/input.h>
37 #include <linux/platform_data/tegra_usb.h>
38
39 #include <mach/clk.h>
40 #include <mach/iomap.h>
41 #include <mach/irqs.h>
42 #include <mach/pinmux.h>
43 #include <mach/iomap.h>
44 #include <mach/io.h>
45 #include <mach/i2s.h>
46 #include <mach/audio.h>
47 #include <mach/usb_phy.h>
48 #include <mach/nand.h>
49
50 #include <asm/hardware/gic.h>
51 #include <asm/mach-types.h>
52 #include <asm/mach/arch.h>
53
54 #include "board.h"
55 #include "board-curacao.h"
56 #include "clock.h"
57 #include "common.h"
58 #include "devices.h"
59 #include "fuse.h"
60 #include "gpio-names.h"
61
62 #define ENABLE_OTG 0
63 /* uncomment for host only functionality (for FPGA) */
64 /* #define USB_HOST_ONLY */
65
66 static struct plat_serial8250_port debug_uart_platform_data[] = {
67         {
68                 .membase        = IO_ADDRESS(TEGRA_UARTA_BASE),
69                 .mapbase        = TEGRA_UARTA_BASE,
70                 .irq            = INT_UARTA,
71                 .flags          = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
72                 .type           = PORT_TEGRA,
73                 .iotype         = UPIO_MEM,
74                 .regshift       = 2,
75                 .uartclk        = 13000000,
76         }, {
77                 .flags          = 0,
78         }
79 };
80
81 static struct platform_device debug_uart = {
82         .name = "serial8250",
83         .id = PLAT8250_DEV_PLATFORM,
84         .dev = {
85                 .platform_data = debug_uart_platform_data,
86         },
87 };
88
89
90 #ifdef CONFIG_BCM4329_RFKILL
91
92 static struct resource curacao_bcm4329_rfkill_resources[] = {
93         {
94                 .name   = "bcm4329_nreset_gpio",
95                 .start  = TEGRA_GPIO_PU0,
96                 .end    = TEGRA_GPIO_PU0,
97                 .flags  = IORESOURCE_IO,
98         },
99         {
100                 .name   = "bcm4329_nshutdown_gpio",
101                 .start  = TEGRA_GPIO_PK2,
102                 .end    = TEGRA_GPIO_PK2,
103                 .flags  = IORESOURCE_IO,
104         },
105 };
106
107 static struct platform_device curacao_bcm4329_rfkill_device = {
108         .name = "bcm4329_rfkill",
109         .id             = -1,
110         .num_resources  = ARRAY_SIZE(curacao_bcm4329_rfkill_resources),
111         .resource       = curacao_bcm4329_rfkill_resources,
112 };
113
114 static noinline void __init curacao_bt_rfkill(void)
115 {
116         /*Add Clock Resource*/
117         clk_add_alias("bcm4329_32k_clk", curacao_bcm4329_rfkill_device.name, \
118                                 "blink", NULL);
119
120         platform_device_register(&curacao_bcm4329_rfkill_device);
121
122         return;
123 }
124 #else
125 static inline void curacao_bt_rfkill(void) { }
126 #endif
127
128 static __initdata struct tegra_clk_init_table curacao_clk_init_table[] = {
129         /* name         parent          rate            enabled */
130         { "uarta",      "clk_m",        13000000,       true},
131         { "uartb",      "clk_m",        13000000,       true},
132         { "uartc",      "clk_m",        13000000,       true},
133         { "uartd",      "clk_m",        13000000,       true},
134         { "uarte",      "clk_m",        13000000,       true},
135         { "blink",      "clk_32k",      32768,          false},
136         { "pwm",        "clk_32k",      32768,          false},
137         { "blink",      "clk_32k",      32768,          false},
138         { "pll_a",      NULL,           56448000,       true},
139         { "pll_a_out0", NULL,           11289600,       true},
140         { "i2s1",       "pll_a_out0",   11289600,       true},
141         { "i2s2",       "pll_a_out0",   11289600,       true},
142         { "d_audio",    "pll_a_out0",   11289600,       false},
143         { "audio_2x",   "audio",        22579200,       true},
144         { NULL,         NULL,           0,              0},
145 };
146
147 static struct i2c_board_info __initdata curacao_i2c_bus1_board_info[] = {
148         {
149                 I2C_BOARD_INFO("wm8903", 0x1a),
150         },
151 };
152
153 static struct tegra_i2c_platform_data curacao_i2c1_platform_data = {
154         .adapter_nr     = 0,
155         .bus_count      = 1,
156         .bus_clk_rate   = { 100000, 0 },
157 };
158
159 #if 0   /* !!!FIXME!!! */
160 static const struct tegra_pingroup_config i2c2_ddc = {
161         .pingroup       = TEGRA_PINGROUP_DDC,
162         .func           = TEGRA_MUX_I2C2,
163 };
164
165 static const struct tegra_pingroup_config i2c2_gen2 = {
166         .pingroup       = TEGRA_PINGROUP_PTA,
167         .func           = TEGRA_MUX_I2C2,
168 };
169 #endif
170
171 static struct tegra_i2c_platform_data curacao_i2c2_platform_data = {
172         .adapter_nr     = 1,
173         .bus_count      = 2,
174         .bus_clk_rate   = { 100000, 100000 },
175 #if 0   /* !!!FIXME!!!! */
176         .bus_mux        = { &i2c2_ddc, &i2c2_gen2 },
177         .bus_mux_len    = { 1, 1 },
178 #endif
179 };
180
181 static struct tegra_i2c_slave_platform_data curacao_i2c2_slave_platform_data = {
182         .adapter_nr     = 1,
183         .bus_clk_rate   = { 100000, 0 },
184 };
185
186 static struct tegra_i2c_platform_data curacao_i2c3_platform_data = {
187         .adapter_nr     = 3,
188         .bus_count      = 1,
189         .bus_clk_rate   = { 100000, 0 },
190 };
191
192 static struct tegra_i2c_platform_data curacao_i2c4_platform_data = {
193         .adapter_nr     = 4,
194         .bus_count      = 1,
195         .bus_clk_rate   = { 100000, 0 },
196 };
197
198 static struct tegra_i2c_platform_data curacao_i2c5_platform_data = {
199         .adapter_nr     = 5,
200         .bus_count      = 1,
201         .bus_clk_rate   = { 100000, 0 },
202 };
203
204 static void curacao_i2c_init(void)
205 {
206         tegra11_i2c_device1.dev.platform_data = &curacao_i2c1_platform_data;
207         tegra_i2c_slave_device2.dev.platform_data =
208                                         &curacao_i2c2_slave_platform_data;
209         tegra11_i2c_device3.dev.platform_data = &curacao_i2c3_platform_data;
210         tegra11_i2c_device4.dev.platform_data = &curacao_i2c4_platform_data;
211         tegra11_i2c_device5.dev.platform_data = &curacao_i2c5_platform_data;
212
213         i2c_register_board_info(0, curacao_i2c_bus1_board_info, 1);
214
215         platform_device_register(&tegra11_i2c_device5);
216         platform_device_register(&tegra11_i2c_device4);
217         platform_device_register(&tegra11_i2c_device3);
218         platform_device_register(&tegra_i2c_slave_device2);
219         platform_device_register(&tegra11_i2c_device1);
220 }
221
222 #define GPIO_KEY(_id, _gpio, _iswake)           \
223         {                                       \
224                 .code = _id,                    \
225                 .gpio = TEGRA_GPIO_##_gpio,     \
226                 .active_low = 1,                \
227                 .desc = #_id,                   \
228                 .type = EV_KEY,                 \
229                 .wakeup = _iswake,              \
230                 .debounce_interval = 10,        \
231         }
232
233 /* !!!FIXME!!! */
234 static struct gpio_keys_button curacao_keys[] = {
235         [0] = GPIO_KEY(KEY_MENU, PQ0, 0),
236         [1] = GPIO_KEY(KEY_HOME, PQ1, 0),
237         [2] = GPIO_KEY(KEY_BACK, PQ2, 0),
238         [3] = GPIO_KEY(KEY_VOLUMEUP, PQ3, 0),
239         [4] = GPIO_KEY(KEY_VOLUMEDOWN, PQ4, 0),
240         [5] = GPIO_KEY(KEY_POWER, PV2, 1),
241 };
242
243 static struct gpio_keys_platform_data curacao_keys_platform_data = {
244         .buttons        = curacao_keys,
245         .nbuttons       = ARRAY_SIZE(curacao_keys),
246 };
247
248 static struct platform_device curacao_keys_device = {
249         .name   = "gpio-keys",
250         .id     = 0,
251         .dev    = {
252                 .platform_data  = &curacao_keys_platform_data,
253         },
254 };
255
256 static struct platform_device tegra_camera = {
257         .name = "tegra_camera",
258         .id = -1,
259 };
260
261 static struct resource tegra_rtc_resources[] = {
262         [0] = {
263                 .start = TEGRA_RTC_BASE,
264                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
265                 .flags = IORESOURCE_MEM,
266         },
267         [1] = {
268                 .start = INT_RTC,
269                 .end = INT_RTC,
270                 .flags = IORESOURCE_IRQ,
271         },
272 };
273
274 static struct platform_device tegra_rtc_device = {
275         .name = "tegra_rtc",
276         .id   = -1,
277         .resource = tegra_rtc_resources,
278         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
279 };
280
281 #if defined(CONFIG_MTD_NAND_TEGRA)
282 static struct resource nand_resources[] = {
283         [0] = {
284                 .start = INT_NANDFLASH,
285                 .end   = INT_NANDFLASH,
286                 .flags = IORESOURCE_IRQ
287         },
288         [1] = {
289                 .start = TEGRA_NAND_BASE,
290                 .end = TEGRA_NAND_BASE + TEGRA_NAND_SIZE - 1,
291                 .flags = IORESOURCE_MEM
292         }
293 };
294
295 static struct tegra_nand_chip_parms nand_chip_parms[] = {
296         /* Samsung K5E2G1GACM */
297         [0] = {
298                 .vendor_id   = 0xEC,
299                 .device_id   = 0xAA,
300                 .capacity    = 256,
301                 .timing      = {
302                         .trp            = 21,
303                         .trh            = 15,
304                         .twp            = 21,
305                         .twh            = 15,
306                         .tcs            = 31,
307                         .twhr           = 60,
308                         .tcr_tar_trr    = 20,
309                         .twb            = 100,
310                         .trp_resp       = 30,
311                         .tadl           = 100,
312                 },
313         },
314         /* Hynix H5PS1GB3EFR */
315         [1] = {
316                 .vendor_id   = 0xAD,
317                 .device_id   = 0xDC,
318                 .capacity    = 512,
319                 .timing      = {
320                         .trp            = 12,
321                         .trh            = 10,
322                         .twp            = 12,
323                         .twh            = 10,
324                         .tcs            = 20,
325                         .twhr           = 80,
326                         .tcr_tar_trr    = 20,
327                         .twb            = 100,
328                         .trp_resp       = 20,
329                         .tadl           = 70,
330                 },
331         },
332 };
333
334 struct tegra_nand_platform nand_data = {
335         .max_chips      = 8,
336         .chip_parms     = nand_chip_parms,
337         .nr_chip_parms  = ARRAY_SIZE(nand_chip_parms),
338 };
339
340 struct platform_device tegra_nand_device = {
341         .name          = "tegra_nand",
342         .id            = -1,
343         .resource      = nand_resources,
344         .num_resources = ARRAY_SIZE(nand_resources),
345         .dev            = {
346                 .platform_data = &nand_data,
347         },
348 };
349 #endif
350
351 #if defined(CONFIG_TEGRA_SIMULATION_PLATFORM) && defined(CONFIG_SMC91X)
352 static struct resource tegra_sim_smc91x_resources[] = {
353         [0] = {
354                 .start          = TEGRA_SIM_ETH_BASE,
355                 .end            = TEGRA_SIM_ETH_BASE + TEGRA_SIM_ETH_SIZE - 1,
356                 .flags          = IORESOURCE_MEM,
357         },
358         [1] = {
359                 .start          = IRQ_ETH,
360                 .end            = IRQ_ETH,
361                 .flags          = IORESOURCE_IRQ,
362         },
363 };
364
365 static struct platform_device tegra_sim_smc91x_device = {
366         .name           = "smc91x",
367         .id             = 0,
368         .num_resources  = ARRAY_SIZE(tegra_sim_smc91x_resources),
369         .resource       = tegra_sim_smc91x_resources,
370 };
371 #endif
372
373 static struct platform_device *curacao_devices[] __initdata = {
374 #if ENABLE_OTG
375         &tegra_otg_device,
376 #endif
377         &debug_uart,
378         &tegra_pmu_device,
379         &tegra_rtc_device,
380 #if !defined(USB_HOST_ONLY)
381         &tegra_udc_device,
382 #endif
383 #if defined(CONFIG_TEGRA_IOVMM_SMMU)
384         &tegra_smmu_device,
385 #endif
386         &curacao_keys_device,
387         &tegra_wdt_device,
388 #if defined(CONFIG_SND_HDA_TEGRA)
389         &tegra_hda_device,
390 #endif
391         &tegra_avp_device,
392         &tegra_camera,
393 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
394         &tegra_se_device,
395 #endif
396 #if defined(CONFIG_MTD_NAND_TEGRA)
397         &tegra_nand_device,
398 #endif
399
400 #if defined(CONFIG_TEGRA_SIMULATION_PLATFORM) && defined(CONFIG_SMC91X)
401         &tegra_sim_smc91x_device,
402 #endif
403 };
404
405 static void curacao_keys_init(void)
406 {
407         int i;
408
409         for (i = 0; i < ARRAY_SIZE(curacao_keys); i++)
410                 tegra_gpio_enable(curacao_keys[i].gpio);
411 }
412
413 static int __init curacao_touch_init(void)
414 {
415         return 0;
416 }
417
418 static struct tegra_usb_platform_data tegra_udc_pdata = {
419         .port_otg = true,
420         .has_hostpc = true,
421         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
422         .op_mode = TEGRA_USB_OPMODE_DEVICE,
423         .u_data.dev = {
424                 .vbus_pmu_irq = 0,
425                 .vbus_gpio = -1,
426                 .charging_supported = false,
427                 .remote_wakeup_supported = false,
428         },
429         .u_cfg.utmi = {
430                 .hssync_start_delay = 0,
431                 .elastic_limit = 16,
432                 .idle_wait_delay = 17,
433                 .term_range_adj = 6,
434                 .xcvr_setup = 8,
435                 .xcvr_lsfslew = 2,
436                 .xcvr_lsrslew = 2,
437                 .xcvr_setup_offset = 0,
438                 .xcvr_use_fuses = 1,
439         },
440 };
441
442 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
443         .port_otg = true,
444         .has_hostpc = true,
445         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
446         .op_mode = TEGRA_USB_OPMODE_HOST,
447         .u_data.host = {
448                 .vbus_gpio = -1,
449                 .vbus_reg = "vdd_vbus_micro_usb",
450                 .hot_plug = true,
451                 .remote_wakeup_supported = true,
452                 .power_off_on_suspend = true,
453         },
454         .u_cfg.utmi = {
455                 .hssync_start_delay = 0,
456                 .elastic_limit = 16,
457                 .idle_wait_delay = 17,
458                 .term_range_adj = 6,
459                 .xcvr_setup = 15,
460                 .xcvr_lsfslew = 2,
461                 .xcvr_lsrslew = 2,
462                 .xcvr_setup_offset = 0,
463                 .xcvr_use_fuses = 1,
464         },
465 };
466
467 static struct tegra_usb_platform_data tegra_ehci2_utmi_pdata = {
468         .port_otg = false,
469         .has_hostpc = true,
470         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
471         .op_mode        = TEGRA_USB_OPMODE_HOST,
472         .u_data.host = {
473                 .vbus_gpio = -1,
474                 .hot_plug = true,
475                 .remote_wakeup_supported = true,
476                 .power_off_on_suspend = true,
477         },
478         .u_cfg.utmi = {
479                 .hssync_start_delay = 0,
480                 .elastic_limit = 16,
481                 .idle_wait_delay = 17,
482                 .term_range_adj = 6,
483                 .xcvr_setup = 15,
484                 .xcvr_lsfslew = 2,
485                 .xcvr_lsrslew = 2,
486                 .xcvr_setup_offset = 0,
487                 .xcvr_use_fuses = 1,
488         },
489 };
490
491 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
492         .port_otg = false,
493         .has_hostpc = true,
494         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
495         .op_mode        = TEGRA_USB_OPMODE_HOST,
496         .u_data.host = {
497                 .vbus_gpio = -1,
498                 .vbus_reg = "vdd_vbus_typea_usb",
499                 .hot_plug = true,
500                 .remote_wakeup_supported = true,
501                 .power_off_on_suspend = true,
502         },
503         .u_cfg.utmi = {
504                 .hssync_start_delay = 0,
505                 .elastic_limit = 16,
506                 .idle_wait_delay = 17,
507                 .term_range_adj = 6,
508                 .xcvr_setup = 8,
509                 .xcvr_lsfslew = 2,
510                 .xcvr_lsrslew = 2,
511                 .xcvr_setup_offset = 0,
512                 .xcvr_use_fuses = 1,
513         },
514 };
515
516 static struct tegra_usb_otg_data tegra_otg_pdata = {
517         .ehci_device = &tegra_ehci1_device,
518         .ehci_pdata = &tegra_ehci1_utmi_pdata,
519 };
520
521 static void curacao_usb_init(void)
522 {
523 #if defined(USB_HOST_ONLY)
524         tegra_ehci1_device.dev.platform_data = &tegra_ehci1_utmi_pdata;
525         platform_device_register(&tegra_ehci1_device);
526 #else
527         /* setup the udc platform data */
528         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
529
530 #endif
531 }
532
533 static struct platform_device *curacao_hs_uart_devices[] __initdata = {
534         &tegra_uartb_device,
535         &tegra_uartc_device,
536         &tegra_uartd_device,
537         &tegra_uarte_device,
538 };
539
540 static struct uart_clk_parent uart_parent_clk[] = {
541         [0] = {.name = "clk_m"},
542 };
543
544 static struct tegra_uart_platform_data curacao_uart_pdata;
545 static struct tegra_uart_platform_data curacao_loopback_uart_pdata;
546
547 static void __init curacao_hs_uart_init(void)
548 {
549         struct clk *c;
550         int i;
551
552         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
553                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
554                 if (IS_ERR_OR_NULL(c)) {
555                         pr_err("Not able to get the clock for %s\n",
556                                         uart_parent_clk[i].name);
557                         continue;
558                 }
559                 uart_parent_clk[i].parent_clk = c;
560                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
561         }
562         curacao_uart_pdata.parent_clk_list = uart_parent_clk;
563         curacao_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
564         curacao_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
565         curacao_loopback_uart_pdata.parent_clk_count =
566                                                 ARRAY_SIZE(uart_parent_clk);
567         curacao_loopback_uart_pdata.is_loopback = true;
568         tegra_uartb_device.dev.platform_data = &curacao_uart_pdata;
569         tegra_uartc_device.dev.platform_data = &curacao_uart_pdata;
570         tegra_uartd_device.dev.platform_data = &curacao_uart_pdata;
571         tegra_uarte_device.dev.platform_data = &curacao_loopback_uart_pdata;
572         platform_add_devices(curacao_hs_uart_devices,
573                                 ARRAY_SIZE(curacao_hs_uart_devices));
574 }
575
576 static void __init tegra_curacao_init(void)
577 {
578         tegra_clk_init_from_table(curacao_clk_init_table);
579         curacao_pinmux_init();
580
581         if (tegra_get_revision() == TEGRA_REVISION_QT)
582                 debug_uart_platform_data[0].uartclk = tegra_clk_measure_input_freq();
583
584         platform_add_devices(curacao_devices, ARRAY_SIZE(curacao_devices));
585
586         curacao_power_off_init();
587         curacao_sdhci_init();
588         curacao_i2c_init();
589         curacao_regulator_init();
590         curacao_suspend_init();
591         curacao_touch_init();
592         curacao_keys_init();
593         curacao_usb_init();
594         curacao_panel_init();
595         curacao_hs_uart_init();
596         curacao_bt_rfkill();
597         curacao_sensors_init();
598 }
599
600 static void __init tegra_curacao_reserve(void)
601 {
602 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
603         tegra_reserve(0, SZ_4M, 0);
604 #else
605         tegra_reserve(SZ_32M, SZ_4M, 0);
606 #endif
607 }
608
609 MACHINE_START(CURACAO, CURACAO_BOARD_NAME)
610         .boot_params    = 0x80000100,
611         .soc            = &tegra_soc_desc,
612         .map_io         = tegra_map_common_io,
613         .reserve        = tegra_curacao_reserve,
614         .init_early     = tegra_init_early,
615         .init_irq       = tegra_init_irq,
616         .handle_irq     = gic_handle_irq,
617         .timer          = &tegra_timer,
618         .init_machine   = tegra_curacao_init,
619 MACHINE_END