ARM: tegra: tegratab: Change default state of maxim touch reset
[linux-2.6.git] / arch / arm / mach-tegra / board-tegratab.c
1 /*
2  * arch/arm/mach-tegra/board-tegratab.c
3  *
4  * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
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 version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/slab.h>
23 #include <linux/ctype.h>
24 #include <linux/platform_device.h>
25 #include <linux/clk.h>
26 #include <linux/serial_8250.h>
27 #include <linux/i2c.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/delay.h>
30 #include <linux/i2c-tegra.h>
31 #include <linux/gpio.h>
32 #include <linux/input.h>
33 #include <linux/platform_data/tegra_usb.h>
34 #include <linux/platform_data/tegra_usb_modem_power.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/rm31080a_ts.h>
37 #include <linux/maxim_sti.h>
38 #include <linux/tegra_uart.h>
39 #include <linux/memblock.h>
40 #include <linux/spi-tegra.h>
41 #include <linux/skbuff.h>
42 #include <linux/ti_wilink_st.h>
43 #include <linux/regulator/consumer.h>
44 #include <linux/smb349-charger.h>
45 #include <linux/max17048_battery.h>
46 #include <linux/leds.h>
47 #include <linux/i2c/at24.h>
48 #include <linux/of_platform.h>
49 #include <linux/edp.h>
50
51 #include <asm/hardware/gic.h>
52
53 #include <mach/clk.h>
54 #include <mach/iomap.h>
55 #include <mach/irqs.h>
56 #include <mach/pinmux.h>
57 #include <mach/pinmux-t11.h>
58 #include <mach/iomap.h>
59 #include <mach/io.h>
60 #include <mach/io_dpd.h>
61 #include <mach/i2s.h>
62 #include <mach/tegra_asoc_pdata.h>
63 #include <asm/mach-types.h>
64 #include <asm/mach/arch.h>
65 #include <mach/usb_phy.h>
66 #include <mach/gpio-tegra.h>
67 #include <mach/tegra_fiq_debugger.h>
68 #include <mach/hardware.h>
69
70 #include "board-touch-raydium.h"
71 #include "board.h"
72 #include "board-common.h"
73 #include "board-touch-maxim_sti.h"
74 #include "clock.h"
75 #include "board-tegratab.h"
76 #include "devices.h"
77 #include "gpio-names.h"
78 #include "fuse.h"
79 #include "pm.h"
80 #include "pm-irq.h"
81 #include "common.h"
82 #include "tegra-board-id.h"
83
84 #if defined CONFIG_TI_ST || defined CONFIG_TI_ST_MODULE
85 struct ti_st_plat_data tegratab_wilink_pdata = {
86         .nshutdown_gpio = TEGRA_GPIO_PQ7,
87         .dev_name = BLUETOOTH_UART_DEV_NAME,
88         .flow_cntrl = 1,
89         .baud_rate = 3000000,
90 };
91
92 static struct platform_device wl128x_device = {
93         .name           = "kim",
94         .id             = -1,
95         .dev.platform_data = &tegratab_wilink_pdata,
96 };
97
98 static struct platform_device btwilink_device = {
99         .name = "btwilink",
100         .id = -1,
101 };
102
103 static noinline void __init tegratab_bt_st(void)
104 {
105         struct board_info board_info;
106
107         pr_info("tegratab_bt_st");
108         tegra_get_board_info(&board_info);
109
110         if (board_info.board_id == BOARD_P1640)
111                 tegratab_wilink_pdata.nshutdown_gpio = TEGRA_GPIO_PR1;
112
113         platform_device_register(&wl128x_device);
114         platform_device_register(&btwilink_device);
115 }
116
117 static struct resource tegratab_st_host_wake_resources[] = {
118         [0] = {
119                 .name = "host_wake",
120                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
121         },
122 };
123
124 static struct platform_device tegratab_st_host_wake_device = {
125         .name           = "st_host_wake",
126         .id             = 0,
127         .num_resources  = ARRAY_SIZE(tegratab_st_host_wake_resources),
128         .resource       = tegratab_st_host_wake_resources,
129 };
130
131 static noinline void __init tegratab_tegra_setup_st_host_wake(void)
132 {
133         tegratab_st_host_wake_resources[0].start =
134                 tegratab_st_host_wake_resources[0].end =
135                 gpio_to_irq(TEGRA_GPIO_PU6);
136         platform_device_register(&tegratab_st_host_wake_device);
137 }
138 #endif
139
140 static __initdata struct tegra_clk_init_table tegratab_clk_init_table[] = {
141         /* name         parent          rate            enabled */
142         { "pll_m",      NULL,           0,              false},
143         { "hda",        "pll_p",        108000000,      false},
144         { "hda2codec_2x", "pll_p",      48000000,       false},
145         { "pwm",        "pll_p",        48000000,       false},
146         { "i2s1",       "pll_a_out0",   0,              false},
147         { "i2s3",       "pll_a_out0",   0,              false},
148         { "i2s4",       "pll_a_out0",   0,              false},
149         { "spdif_out",  "pll_a_out0",   0,              false},
150         { "d_audio",    "clk_m",        12000000,       false},
151         { "dam0",       "clk_m",        12000000,       false},
152         { "dam1",       "clk_m",        12000000,       false},
153         { "dam2",       "clk_m",        12000000,       false},
154         { "audio1",     "i2s1_sync",    0,              false},
155         { "audio3",     "i2s3_sync",    0,              false},
156         /* Setting vi_sensor-clk to true for validation purpose, will imapact
157          * power, later set to be false.*/
158         { "vi_sensor",  "pll_p",        150000000,      false},
159         { "cilab",      "pll_p",        150000000,      false},
160         { "cilcd",      "pll_p",        150000000,      false},
161         { "cile",       "pll_p",        150000000,      false},
162         { "i2c1",       "pll_p",        3200000,        false},
163         { "i2c2",       "pll_p",        3200000,        false},
164         { "i2c3",       "pll_p",        3200000,        false},
165         { "i2c4",       "pll_p",        3200000,        false},
166         { "i2c5",       "pll_p",        3200000,        false},
167         { NULL,         NULL,           0,              0},
168 };
169
170 static __initdata struct tegra_clk_init_table e1569_wifi_clk_init_table[] = {
171         { "blink",      "clk_32k",      32768,          true},
172         { NULL,         NULL,           0,              0},
173 };
174
175 static __initdata struct tegra_clk_init_table P1640_wifi_clk_init_table[] = {
176         { "extern3",    "clk_32k",      32768,          true},
177         { "clk_out_3",  "extern3",      32768,          true},
178         { NULL,         NULL,           0,              0},
179 };
180
181 static struct tegra_i2c_platform_data tegratab_i2c1_platform_data = {
182         .adapter_nr     = 0,
183         .bus_count      = 1,
184         .bus_clk_rate   = { 100000, 0 },
185         .scl_gpio               = {TEGRA_GPIO_I2C1_SCL, 0},
186         .sda_gpio               = {TEGRA_GPIO_I2C1_SDA, 0},
187         .arb_recovery = arb_lost_recovery,
188 };
189
190 static struct tegra_i2c_platform_data tegratab_i2c2_platform_data = {
191         .adapter_nr     = 1,
192         .bus_count      = 1,
193         .bus_clk_rate   = { 100000, 0 },
194         .is_clkon_always = true,
195         .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
196         .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
197         .arb_recovery = arb_lost_recovery,
198 };
199
200 static struct tegra_i2c_platform_data tegratab_i2c3_platform_data = {
201         .adapter_nr     = 2,
202         .bus_count      = 1,
203         .bus_clk_rate   = { 400000, 0 },
204         .scl_gpio               = {TEGRA_GPIO_I2C3_SCL, 0},
205         .sda_gpio               = {TEGRA_GPIO_I2C3_SDA, 0},
206         .arb_recovery = arb_lost_recovery,
207 };
208
209 static struct tegra_i2c_platform_data tegratab_i2c4_platform_data = {
210         .adapter_nr     = 3,
211         .bus_count      = 1,
212         .bus_clk_rate   = { 10000, 0 },
213         .scl_gpio               = {TEGRA_GPIO_I2C4_SCL, 0},
214         .sda_gpio               = {TEGRA_GPIO_I2C4_SDA, 0},
215         .arb_recovery = arb_lost_recovery,
216 };
217
218 static struct tegra_i2c_platform_data tegratab_i2c5_platform_data = {
219         .adapter_nr     = 4,
220         .bus_count      = 1,
221         .bus_clk_rate   = { 400000, 0 },
222         .scl_gpio               = {TEGRA_GPIO_I2C5_SCL, 0},
223         .sda_gpio               = {TEGRA_GPIO_I2C5_SDA, 0},
224         .arb_recovery = arb_lost_recovery,
225 };
226
227 static struct i2c_board_info __initdata rt5640_board_info = {
228         I2C_BOARD_INFO("rt5640", 0x1c),
229 };
230
231 static struct i2c_board_info __initdata rt5639_board_info = {
232         I2C_BOARD_INFO("rt5639", 0x1c),
233 };
234
235 static void tegratab_i2c_init(void)
236 {
237         struct board_info board_info;
238
239         tegra_get_board_info(&board_info);
240
241         if (board_info.board_id == BOARD_P1640)
242                 i2c_register_board_info(0, &rt5639_board_info, 1);
243         else
244                 i2c_register_board_info(0, &rt5640_board_info, 1);
245 }
246
247 static struct platform_device *tegratab_uart_devices[] __initdata = {
248         &tegra_uarta_device,
249         &tegra_uartb_device,
250         &tegra_uartc_device,
251         &tegra_uartd_device,
252 };
253 static struct uart_clk_parent uart_parent_clk[] = {
254         [0] = {.name = "clk_m"},
255         [1] = {.name = "pll_p"},
256 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
257         [2] = {.name = "pll_m"},
258 #endif
259 };
260
261 static struct tegra_uart_platform_data tegratab_uart_pdata;
262 static struct tegra_uart_platform_data tegratab_loopback_uart_pdata;
263
264 static void __init uart_debug_init(void)
265 {
266         int debug_port_id;
267
268         debug_port_id = uart_console_debug_init(3);
269         if (debug_port_id < 0)
270                 return;
271
272         tegratab_uart_devices[debug_port_id] = uart_console_debug_device;
273 }
274
275 static void __init tegratab_uart_init(void)
276 {
277         struct clk *c;
278         int i;
279
280         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
281                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
282                 if (IS_ERR_OR_NULL(c)) {
283                         pr_err("Not able to get the clock for %s\n",
284                                                 uart_parent_clk[i].name);
285                         continue;
286                 }
287                 uart_parent_clk[i].parent_clk = c;
288                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
289         }
290         tegratab_uart_pdata.parent_clk_list = uart_parent_clk;
291         tegratab_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
292         tegratab_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
293         tegratab_loopback_uart_pdata.parent_clk_count =
294                                                 ARRAY_SIZE(uart_parent_clk);
295         tegratab_loopback_uart_pdata.is_loopback = true;
296         tegra_uarta_device.dev.platform_data = &tegratab_uart_pdata;
297         tegra_uartb_device.dev.platform_data = &tegratab_uart_pdata;
298         tegra_uartc_device.dev.platform_data = &tegratab_uart_pdata;
299         tegra_uartd_device.dev.platform_data = &tegratab_uart_pdata;
300
301         /* Register low speed only if it is selected */
302         if (!is_tegra_debug_uartport_hs())
303                 uart_debug_init();
304
305         platform_add_devices(tegratab_uart_devices,
306                                 ARRAY_SIZE(tegratab_uart_devices));
307 }
308
309 static struct resource tegra_rtc_resources[] = {
310         [0] = {
311                 .start = TEGRA_RTC_BASE,
312                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
313                 .flags = IORESOURCE_MEM,
314         },
315         [1] = {
316                 .start = INT_RTC,
317                 .end = INT_RTC,
318                 .flags = IORESOURCE_IRQ,
319         },
320 };
321
322 static struct platform_device tegra_rtc_device = {
323         .name = "tegra_rtc",
324         .id   = -1,
325         .resource = tegra_rtc_resources,
326         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
327 };
328
329 static struct tegra_asoc_platform_data tegratab_audio_pdata = {
330         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
331         .gpio_hp_mute           = -1,
332         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
333         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
334         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
335         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
336         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
337         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
338         .micbias_gpio_absent = true,
339         .i2s_param[HIFI_CODEC]  = {
340                 .audio_port_id  = 1,
341                 .is_i2s_master  = 1,
342                 .i2s_mode       = TEGRA_DAIFMT_I2S,
343         },
344         .i2s_param[BT_SCO]      = {
345                 .audio_port_id  = 3,
346                 .is_i2s_master  = 1,
347                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
348         },
349 };
350
351 static struct platform_device tegratab_audio_device = {
352         .name   = "tegra-snd-rt5640",
353         .id     = 0,
354         .dev    = {
355                 .platform_data = &tegratab_audio_pdata,
356         },
357 };
358
359 static struct platform_device *tegratab_devices[] __initdata = {
360         &tegra_pmu_device,
361         &tegra_rtc_device,
362         &tegra_udc_device,
363 #if defined(CONFIG_TEGRA_AVP)
364         &tegra_avp_device,
365 #endif
366 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
367         &tegra11_se_device,
368 #endif
369         &tegra_ahub_device,
370         &tegra_dam_device0,
371         &tegra_dam_device1,
372         &tegra_dam_device2,
373         &tegra_i2s_device1,
374         &tegra_i2s_device3,
375         &tegra_i2s_device4,
376         &tegra_spdif_device,
377         &spdif_dit_device,
378         &bluetooth_dit_device,
379         &tegra_pcm_device,
380         &tegratab_audio_device,
381         &tegra_hda_device,
382 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
383         &tegra_aes_device,
384 #endif
385 };
386
387 #ifdef CONFIG_USB_SUPPORT
388 static struct tegra_usb_platform_data tegra_udc_pdata = {
389         .port_otg = true,
390         .has_hostpc = true,
391         .support_pmu_vbus = true,
392         .id_det_type = TEGRA_USB_PMU_ID,
393         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
394         .op_mode = TEGRA_USB_OPMODE_DEVICE,
395         .u_data.dev = {
396                 .vbus_pmu_irq = 0,
397                 .vbus_gpio = -1,
398                 .charging_supported = false,
399                 .remote_wakeup_supported = false,
400         },
401         .u_cfg.utmi = {
402                 .hssync_start_delay = 0,
403                 .elastic_limit = 16,
404                 .idle_wait_delay = 17,
405                 .term_range_adj = 6,
406                 .xcvr_setup = 8,
407                 .xcvr_lsfslew = 2,
408                 .xcvr_lsrslew = 2,
409                 .xcvr_setup_offset = 0,
410                 .xcvr_use_fuses = 1,
411         },
412 };
413
414 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
415         .port_otg = true,
416         .has_hostpc = true,
417         .support_pmu_vbus = true,
418         .id_det_type = TEGRA_USB_PMU_ID,
419         .unaligned_dma_buf_supported = false,
420         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
421         .op_mode = TEGRA_USB_OPMODE_HOST,
422         .u_data.host = {
423                 .vbus_gpio = -1,
424                 .hot_plug = false,
425                 .remote_wakeup_supported = true,
426                 .power_off_on_suspend = true,
427                 .turn_off_vbus_on_lp0 = true,
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 = 15,
435                 .xcvr_lsfslew = 2,
436                 .xcvr_lsrslew = 2,
437                 .xcvr_setup_offset = -5,
438                 .xcvr_use_fuses = 1,
439                 .vbus_oc_map = 0x4,
440                 .xcvr_hsslew_lsb = 3,
441         },
442 };
443
444 static struct tegra_usb_otg_data tegra_otg_pdata = {
445         .ehci_device = &tegra_ehci1_device,
446         .ehci_pdata = &tegra_ehci1_utmi_pdata,
447         .vbus_extcon_dev_name = "palmas-extcon",
448         .id_extcon_dev_name = "palmas-extcon",
449 };
450
451 static void tegratab_usb_init(void)
452 {
453         int usb_port_owner_info = tegra_get_usb_port_owner_info();
454
455         /* Set USB wake sources for tegratab */
456         tegra_set_usb_wake_source();
457
458         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
459                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
460                 platform_device_register(&tegra_otg_device);
461                 /* Setup the udc platform data */
462                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
463         }
464 }
465
466 static struct gpio modem_gpios[] = { /* Nemo modem */
467         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
468         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
469 };
470
471 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
472         .port_otg = false,
473         .has_hostpc = true,
474         .unaligned_dma_buf_supported = false,
475         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
476         .op_mode = TEGRA_USB_OPMODE_HOST,
477         .u_data.host = {
478                 .vbus_gpio = -1,
479                 .hot_plug = false,
480                 .remote_wakeup_supported = true,
481                 .power_off_on_suspend = true,
482         },
483 };
484
485 static int baseband_init(void)
486 {
487         int ret;
488
489         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
490         if (ret) {
491                 pr_warn("%s:gpio request failed\n", __func__);
492                 return ret;
493         }
494
495         /* enable pull-down for MDM_COLD_BOOT */
496         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
497                                     TEGRA_PUPD_PULL_DOWN);
498
499         /* export GPIO for user space access through sysfs */
500         gpio_export(MDM_RST, false);
501
502         return 0;
503 }
504
505 static const struct tegra_modem_operations baseband_operations = {
506         .init = baseband_init,
507 };
508
509 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
510         .ops = &baseband_operations,
511         .wake_gpio = -1,
512         .boot_gpio = MDM_COLDBOOT,
513         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
514         .autosuspend_delay = 2000,
515         .short_autosuspend_delay = 50,
516         .tegra_ehci_device = &tegra_ehci2_device,
517         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
518 };
519
520 static struct platform_device icera_nemo_device = {
521         .name = "tegra_usb_modem_power",
522         .id = -1,
523         .dev = {
524                 .platform_data = &baseband_pdata,
525         },
526 };
527
528 static void tegratab_modem_init(void)
529 {
530         int modem_id = tegra_get_modem_id();
531         int usb_port_owner_info = tegra_get_usb_port_owner_info();
532         switch (modem_id) {
533         case TEGRA_BB_NEMO: /* on board i500 HSIC */
534                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB)) {
535                         platform_device_register(&icera_nemo_device);
536                 }
537                 break;
538         }
539 }
540
541 #else
542 static void tegratab_usb_init(void) { }
543 static void tegratab_modem_init(void) { }
544 #endif
545
546 static void tegratab_audio_init(void)
547 {
548         struct board_info board_info;
549
550         tegra_get_board_info(&board_info);
551
552         if (board_info.board_id == BOARD_P1640) {
553                 tegratab_audio_pdata.codec_name = "rt5639.0-001c";
554                 tegratab_audio_pdata.codec_dai_name = "rt5639-aif1";
555                 if (board_info.fab == BOARD_FAB_A00)
556                         tegratab_audio_pdata.gpio_hp_det = TEGRA_GPIO_HP_DET;
557                 else {/* from A01, CDC_IRQ from codec is used as interrupt */
558                         tegratab_audio_pdata.gpio_hp_det = TEGRA_GPIO_CDC_IRQ;
559                         tegratab_audio_pdata.use_codec_jd_irq = true;
560                 }
561         } else {
562                 tegratab_audio_pdata.codec_name = "rt5640.0-001c";
563                 tegratab_audio_pdata.codec_dai_name = "rt5640-aif1";
564                 tegratab_audio_pdata.gpio_hp_det = TEGRA_GPIO_HP_DET;
565         }
566 }
567
568
569 static struct platform_device *tegratab_spi_devices[] __initdata = {
570         &tegra11_spi_device1,
571 };
572
573 struct spi_clk_parent spi_parent_clk_tegratab[] = {
574         [0] = {.name = "pll_p"},
575 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
576         [1] = {.name = "pll_m"},
577         [2] = {.name = "clk_m"},
578 #else
579         [1] = {.name = "clk_m"},
580 #endif
581 };
582
583 static struct tegra_spi_platform_data tegratab_spi_pdata = {
584         .max_dma_buffer         = 16 * 1024,
585         .is_clkon_always        = false,
586         .max_rate               = 25000000,
587 };
588
589 static void __init tegratab_spi_init(void)
590 {
591         int i;
592         struct clk *c;
593         struct board_info board_info, display_board_info;
594
595         tegra_get_board_info(&board_info);
596         tegra_get_display_board_info(&display_board_info);
597
598         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_tegratab); ++i) {
599                 c = tegra_get_clock_by_name(spi_parent_clk_tegratab[i].name);
600                 if (IS_ERR_OR_NULL(c)) {
601                         pr_err("Not able to get the clock for %s\n",
602                                         spi_parent_clk_tegratab[i].name);
603                         continue;
604                 }
605                 spi_parent_clk_tegratab[i].parent_clk = c;
606                 spi_parent_clk_tegratab[i].fixed_clk_rate = clk_get_rate(c);
607         }
608         tegratab_spi_pdata.parent_clk_list = spi_parent_clk_tegratab;
609         tegratab_spi_pdata.parent_clk_count =
610                 ARRAY_SIZE(spi_parent_clk_tegratab);
611         tegratab_spi_pdata.is_dma_based =
612                 (tegra_revision == TEGRA_REVISION_A01) ? false : true;
613         tegra11_spi_device1.dev.platform_data = &tegratab_spi_pdata;
614         platform_add_devices(tegratab_spi_devices,
615                 ARRAY_SIZE(tegratab_spi_devices));
616 }
617
618 #if defined(CONFIG_TOUCHSCREEN_MAXIM_STI) || \
619         defined(CONFIG_TOUCHSCREEN_MAXIM_STI_MODULE)
620 struct maxim_sti_pdata maxim_sti_pdata = {
621         .touch_fusion         = "/vendor/bin/touch_fusion",
622         .config_file          = "/vendor/firmware/touch_fusion.cfg",
623         .nl_family            = TF_FAMILY_NAME,
624         .nl_mc_groups         = 5,
625         .chip_access_method   = 2,
626         .default_reset_state  = 0,
627         .tx_buf_size          = 4100,
628         .rx_buf_size          = 4100,
629         .gpio_reset           = TOUCH_GPIO_RST_MAXIM_STI_SPI,
630         .gpio_irq             = TOUCH_GPIO_IRQ_MAXIM_STI_SPI
631 };
632
633 static struct tegra_spi_device_controller_data dev_cdata = {
634         .rx_clk_tap_delay = 0,
635         .is_hw_based_cs = true,
636         .tx_clk_tap_delay = 0,
637 };
638
639 struct spi_board_info maxim_sti_spi_board = {
640         .modalias = MAXIM_STI_NAME,
641         .bus_num = 0,
642         .chip_select = 0,
643         .max_speed_hz = 12 * 1000 * 1000,
644         .mode = SPI_MODE_0,
645         .platform_data = &maxim_sti_pdata,
646         .controller_data = &dev_cdata
647 };
648 #else
649 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
650         /* name         parent          rate            enabled */
651         { "extern2",    "pll_p",        41000000,       false},
652         { "clk_out_2",  "extern2",      40800000,       false},
653         { NULL,         NULL,           0,              0},
654 };
655
656 struct rm_spi_ts_platform_data rm31080ts_tegratab_data = {
657         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
658         .config = 0,
659         .platform_id = RM_PLATFORM_D010,
660         .name_of_clock = "clk_out_2",
661         .name_of_clock_con = "extern2",
662 };
663
664 static struct tegra_spi_device_controller_data dev_cdata = {
665         .rx_clk_tap_delay = 0,
666         .tx_clk_tap_delay = 0,
667 };
668
669 struct spi_board_info rm31080a_tegratab_spi_board[1] = {
670         {
671          .modalias = "rm_ts_spidev",
672          .bus_num = 0,
673          .chip_select = 0,
674          .max_speed_hz = 12 * 1000 * 1000,
675          .mode = SPI_MODE_0,
676          .controller_data = &dev_cdata,
677          .platform_data = &rm31080ts_tegratab_data,
678          },
679 };
680 #endif
681
682 static int __init tegratab_touch_init(void)
683 {
684 #if defined(CONFIG_TOUCHSCREEN_MAXIM_STI) || \
685         defined(CONFIG_TOUCHSCREEN_MAXIM_STI_MODULE)
686         struct board_info board_info;
687
688         tegra_get_board_info(&board_info);
689         if (board_info.board_id == BOARD_P1640)
690                 (void)touch_init_maxim_sti(&maxim_sti_spi_board);
691 #else
692         tegra_clk_init_from_table(touch_clk_init_table);
693         rm31080ts_tegratab_data.platform_id = RM_PLATFORM_D010;
694         mdelay(20);
695         rm31080a_tegratab_spi_board[0].irq =
696                 gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
697         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
698                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
699                                 &rm31080ts_tegratab_data,
700                                 &rm31080a_tegratab_spi_board[0],
701                                 ARRAY_SIZE(rm31080a_tegratab_spi_board));
702 #endif
703         return 0;
704 }
705
706 static void __init tegra_tegratab_early_init(void)
707 {
708         struct board_info board_info;
709
710         tegra_clk_init_from_table(tegratab_clk_init_table);
711         /* enable wifi 32K clk according to board revision */
712         tegra_get_board_info(&board_info);
713         if (board_info.board_id == BOARD_E1569)
714                 tegra_clk_init_from_table(e1569_wifi_clk_init_table);
715         else if (board_info.board_id == BOARD_P1640 &&
716                         board_info.fab == BOARD_FAB_A00)
717                 tegra_clk_init_from_table(P1640_wifi_clk_init_table);
718         tegra_clk_verify_parents();
719         tegra_soc_device_init("tegratab");
720 #if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
721         platform_device_register(&tegra_smmu_device);
722 #endif
723 }
724
725 struct of_dev_auxdata tegratab_auxdata_lookup[] __initdata = {
726         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
727                                 NULL),
728         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
729                                 NULL),
730         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
731                                 NULL),
732         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
733                                 NULL),
734         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
735                                 NULL),
736         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
737                                 NULL),
738         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
739                                 NULL),
740         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
741                 &tegratab_i2c1_platform_data),
742         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
743                 &tegratab_i2c2_platform_data),
744         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
745                 &tegratab_i2c3_platform_data),
746         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
747                 &tegratab_i2c4_platform_data),
748         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
749                 &tegratab_i2c5_platform_data),
750         {},
751 };
752
753 static void __init tegra_tegratab_late_init(void)
754 {
755         struct board_info board_info;
756         tegra_get_display_board_info(&board_info);
757
758         platform_device_register(&tegra_pinmux_device);
759         tegratab_pinmux_init();
760         tegratab_i2c_init();
761         tegratab_spi_init();
762         tegratab_usb_init();
763         tegratab_uart_init();
764         tegratab_audio_init();
765         platform_add_devices(tegratab_devices, ARRAY_SIZE(tegratab_devices));
766         tegra_ram_console_debug_init();
767         tegra_io_dpd_init();
768         tegratab_regulator_init();
769         tegratab_power_off_init();
770         tegratab_sdhci_init();
771         tegratab_suspend_init();
772         tegratab_emc_init();
773         tegratab_edp_init();
774         tegratab_touch_init();
775         tegratab_panel_init();
776         tegratab_kbc_init();
777         tegratab_pmon_init();
778 #if defined CONFIG_TI_ST || defined CONFIG_TI_ST_MODULE
779         tegratab_bt_st();
780         tegratab_tegra_setup_st_host_wake();
781 #endif
782         tegra_release_bootloader_fb();
783         tegratab_modem_init();
784 #ifdef CONFIG_TEGRA_WDT_RECOVERY
785         tegra_wdt_recovery_init();
786 #endif
787         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
788         tegratab_sensors_init();
789         tegratab_soctherm_init();
790         tegra_register_fuse();
791 }
792
793 static void __init tegratab_ramconsole_reserve(unsigned long size)
794 {
795         tegra_ram_console_debug_reserve(SZ_1M);
796 }
797
798 static void __init tegra_tegratab_dt_init(void)
799 {
800         tegra_tegratab_early_init();
801
802 #ifdef CONFIG_USE_OF
803         of_platform_populate(NULL, of_default_bus_match_table,
804                 tegratab_auxdata_lookup, &platform_bus);
805 #endif
806
807         tegra_tegratab_late_init();
808 }
809
810 static void __init tegra_tegratab_reserve(void)
811 {
812 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
813         /* 1920*1200*4*2 = 18432000 bytes */
814         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
815 #else
816         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
817 #endif
818         tegratab_ramconsole_reserve(SZ_1M);
819 }
820
821 static const char * const tegratab_dt_board_compat[] = {
822         "nvidia,tegratab",
823         NULL
824 };
825
826 MACHINE_START(TEGRATAB, "tegratab")
827         .atag_offset    = 0x100,
828         .soc            = &tegra_soc_desc,
829         .map_io         = tegra_map_common_io,
830         .reserve        = tegra_tegratab_reserve,
831         .init_early     = tegra11x_init_early,
832         .init_irq       = tegra_dt_init_irq,
833         .handle_irq     = gic_handle_irq,
834         .timer          = &tegra_timer,
835         .init_machine   = tegra_tegratab_dt_init,
836         .restart        = tegra_assert_system_reset,
837         .dt_compat      = tegratab_dt_board_compat,
838 MACHINE_END