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