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