ARM: tegra: macallan: enable OTG ID pin detect through PMIC
[linux-3.10.git] / arch / arm / mach-tegra / board-macallan.c
1 /*
2  * arch/arm/mach-tegra/board-macallan.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/usb/tegra_usb_phy.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/rm31080a_ts.h>
37 #include <linux/tegra_uart.h>
38 #include <linux/memblock.h>
39 #include <linux/spi-tegra.h>
40 #include <linux/nfc/pn544.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/irqs.h>
55 #include <mach/pinmux.h>
56 #include <mach/pinmux-tegra30.h>
57 #include <mach/io_dpd.h>
58 #include <mach/i2s.h>
59 #include <mach/isomgr.h>
60 #include <mach/tegra_asoc_pdata.h>
61 #include <asm/mach-types.h>
62 #include <asm/mach/arch.h>
63 #include <mach/gpio-tegra.h>
64 #include <mach/tegra_fiq_debugger.h>
65 #include <linux/platform_data/tegra_usb_modem_power.h>
66
67 #include "board-touch-raydium.h"
68 #include "board.h"
69 #include "board-common.h"
70 #include "clock.h"
71 #include "board-macallan.h"
72 #include "devices.h"
73 #include "gpio-names.h"
74 #include "fuse.h"
75 #include "iomap.h"
76 #include "pm.h"
77 #include "pm-irq.h"
78 #include "common.h"
79 #include "tegra-board-id.h"
80
81 static struct board_info board_info, display_board_info;
82
83 #if defined CONFIG_TI_ST || defined CONFIG_TI_ST_MODULE
84 struct ti_st_plat_data macallan_wilink_pdata = {
85         .nshutdown_gpio = TEGRA_GPIO_PQ7,
86         .dev_name = BLUETOOTH_UART_DEV_NAME,
87         .flow_cntrl = 1,
88         .baud_rate = 3000000,
89 };
90
91 static struct platform_device wl128x_device = {
92         .name           = "kim",
93         .id             = -1,
94         .dev.platform_data = &macallan_wilink_pdata,
95 };
96
97 static struct platform_device btwilink_device = {
98         .name = "btwilink",
99         .id = -1,
100 };
101
102 static noinline void __init macallan_bt_st(void)
103 {
104         pr_info("macallan_bt_st");
105
106         platform_device_register(&wl128x_device);
107         platform_device_register(&btwilink_device);
108 }
109
110 static struct resource macallan_st_host_wake_resources[] = {
111         [0] = {
112                 .name = "host_wake",
113                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
114         },
115 };
116
117 static struct platform_device macallan_st_host_wake_device = {
118         .name           = "st_host_wake",
119         .id             = 0,
120         .num_resources  = ARRAY_SIZE(macallan_st_host_wake_resources),
121         .resource       = macallan_st_host_wake_resources,
122 };
123
124 static noinline void __init macallan_tegra_setup_st_host_wake(void)
125 {
126         macallan_st_host_wake_resources[0].start =
127                 macallan_st_host_wake_resources[0].end =
128                 gpio_to_irq(TEGRA_GPIO_PU6);
129         platform_device_register(&macallan_st_host_wake_device);
130 }
131 #endif
132
133 static __initdata struct tegra_clk_init_table macallan_clk_init_table[] = {
134         /* name         parent          rate            enabled */
135         { "pll_m",      NULL,           0,              false},
136         { "hda",        "pll_p",        108000000,      false},
137         { "hda2codec_2x", "pll_p",      48000000,       false},
138         { "pwm",        "pll_p",        3187500,        false},
139         { "blink",      "clk_32k",      32768,          true},
140         { "i2s1",       "pll_a_out0",   0,              false},
141         { "i2s3",       "pll_a_out0",   0,              false},
142         { "i2s4",       "pll_a_out0",   0,              false},
143         { "spdif_out",  "pll_a_out0",   0,              false},
144         { "d_audio",    "clk_m",        12000000,       false},
145         { "dam0",       "clk_m",        12000000,       false},
146         { "dam1",       "clk_m",        12000000,       false},
147         { "dam2",       "clk_m",        12000000,       false},
148         { "audio1",     "i2s1_sync",    0,              false},
149         { "audio3",     "i2s3_sync",    0,              false},
150         /* Setting vi_sensor-clk to true for validation purpose, will imapact
151          * power, later set to be false.*/
152         { "vi_sensor",  "pll_p",        150000000,      false},
153         { "cilab",      "pll_p",        150000000,      false},
154         { "cilcd",      "pll_p",        150000000,      false},
155         { "cile",       "pll_p",        150000000,      false},
156         { "i2c1",       "pll_p",        3200000,        false},
157         { "i2c2",       "pll_p",        3200000,        false},
158         { "i2c3",       "pll_p",        3200000,        false},
159         { "i2c4",       "pll_p",        3200000,        false},
160         { "i2c5",       "pll_p",        3200000,        false},
161         { NULL,         NULL,           0,              0},
162 };
163
164 #ifndef CONFIG_USE_OF
165 static struct tegra_i2c_platform_data macallan_i2c1_platform_data = {
166         .bus_clk_rate   = 100000,
167         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
168         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
169 };
170
171 static struct tegra_i2c_platform_data macallan_i2c2_platform_data = {
172         .bus_clk_rate   = 100000,
173         .is_clkon_always = true,
174         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
175         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
176 };
177
178 static struct tegra_i2c_platform_data macallan_i2c3_platform_data = {
179         .bus_clk_rate   = 400000,
180         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
181         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
182 };
183
184 static struct tegra_i2c_platform_data macallan_i2c4_platform_data = {
185         .bus_clk_rate   = 10000,
186         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
187         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
188 };
189
190 static struct tegra_i2c_platform_data macallan_i2c5_platform_data = {
191         .bus_clk_rate   = 400000,
192         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
193         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
194 };
195 #endif
196
197 static struct i2c_board_info __initdata rt5640_board_info = {
198         I2C_BOARD_INFO("rt5640", 0x1c),
199 };
200
201 static struct pn544_i2c_platform_data nfc_pdata = {
202         .irq_gpio = TEGRA_GPIO_PW2,
203         .ven_gpio = TEGRA_GPIO_PQ3,
204         .firm_gpio = TEGRA_GPIO_PH0,
205 };
206
207 static struct i2c_board_info __initdata nfc_board_info = {
208         I2C_BOARD_INFO("pn544", 0x28),
209         .platform_data = &nfc_pdata,
210 };
211
212 static void macallan_i2c_init(void)
213 {
214 #ifndef CONFIG_USE_OF
215         tegra11_i2c_device1.dev.platform_data = &macallan_i2c1_platform_data;
216         tegra11_i2c_device2.dev.platform_data = &macallan_i2c2_platform_data;
217         tegra11_i2c_device3.dev.platform_data = &macallan_i2c3_platform_data;
218         tegra11_i2c_device4.dev.platform_data = &macallan_i2c4_platform_data;
219         tegra11_i2c_device5.dev.platform_data = &macallan_i2c5_platform_data;
220
221         platform_device_register(&tegra11_i2c_device5);
222         platform_device_register(&tegra11_i2c_device4);
223         platform_device_register(&tegra11_i2c_device3);
224         platform_device_register(&tegra11_i2c_device2);
225         platform_device_register(&tegra11_i2c_device1);
226 #endif
227
228         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
229         i2c_register_board_info(0, &nfc_board_info, 1);
230         i2c_register_board_info(0, &rt5640_board_info, 1);
231 }
232
233 static struct platform_device *macallan_uart_devices[] __initdata = {
234         &tegra_uarta_device,
235         &tegra_uartb_device,
236         &tegra_uartc_device,
237         &tegra_uartd_device,
238 };
239 static struct uart_clk_parent uart_parent_clk[] = {
240         [0] = {.name = "clk_m"},
241         [1] = {.name = "pll_p"},
242 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
243         [2] = {.name = "pll_m"},
244 #endif
245 };
246
247 static struct tegra_uart_platform_data macallan_uart_pdata;
248 static struct tegra_uart_platform_data macallan_loopback_uart_pdata;
249
250 static void __init uart_debug_init(void)
251 {
252         int debug_port_id;
253
254         debug_port_id = uart_console_debug_init(3);
255         if (debug_port_id < 0)
256                 return;
257
258         macallan_uart_devices[debug_port_id] = uart_console_debug_device;
259 }
260
261 static void __init macallan_uart_init(void)
262 {
263         struct clk *c;
264         int i;
265
266         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
267                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
268                 if (IS_ERR_OR_NULL(c)) {
269                         pr_err("Not able to get the clock for %s\n",
270                                                 uart_parent_clk[i].name);
271                         continue;
272                 }
273                 uart_parent_clk[i].parent_clk = c;
274                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
275         }
276         macallan_uart_pdata.parent_clk_list = uart_parent_clk;
277         macallan_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
278         macallan_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
279         macallan_loopback_uart_pdata.parent_clk_count =
280                                                 ARRAY_SIZE(uart_parent_clk);
281         macallan_loopback_uart_pdata.is_loopback = true;
282         tegra_uarta_device.dev.platform_data = &macallan_uart_pdata;
283         tegra_uartb_device.dev.platform_data = &macallan_uart_pdata;
284         tegra_uartc_device.dev.platform_data = &macallan_uart_pdata;
285         tegra_uartd_device.dev.platform_data = &macallan_uart_pdata;
286
287         /* Register low speed only if it is selected */
288         if (!is_tegra_debug_uartport_hs())
289                 uart_debug_init();
290
291         platform_add_devices(macallan_uart_devices,
292                                 ARRAY_SIZE(macallan_uart_devices));
293 }
294
295 static struct resource tegra_rtc_resources[] = {
296         [0] = {
297                 .start = TEGRA_RTC_BASE,
298                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
299                 .flags = IORESOURCE_MEM,
300         },
301         [1] = {
302                 .start = INT_RTC,
303                 .end = INT_RTC,
304                 .flags = IORESOURCE_IRQ,
305         },
306 };
307
308 static struct platform_device tegra_rtc_device = {
309         .name = "tegra_rtc",
310         .id   = -1,
311         .resource = tegra_rtc_resources,
312         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
313 };
314
315 static struct tegra_asoc_platform_data macallan_audio_pdata = {
316         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
317         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
318         .gpio_hp_mute           = -1,
319         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
320         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
321         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
322         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
323         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
324         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
325         .i2s_param[HIFI_CODEC]  = {
326                 .audio_port_id  = 1,
327                 .is_i2s_master  = 1,
328                 .i2s_mode       = TEGRA_DAIFMT_I2S,
329         },
330         .i2s_param[BT_SCO]      = {
331                 .audio_port_id  = 3,
332                 .is_i2s_master  = 1,
333                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
334         },
335 };
336
337 static struct platform_device macallan_audio_device = {
338         .name   = "tegra-snd-rt5640",
339         .id     = 0,
340         .dev    = {
341                 .platform_data = &macallan_audio_pdata,
342         },
343 };
344
345 static struct platform_device *macallan_devices[] __initdata = {
346         &tegra_pmu_device,
347         &tegra_rtc_device,
348         &tegra_udc_device,
349 #if defined(CONFIG_TEGRA_AVP)
350         &tegra_avp_device,
351 #endif
352 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
353         &tegra11_se_device,
354 #endif
355         &tegra_ahub_device,
356         &tegra_dam_device0,
357         &tegra_dam_device1,
358         &tegra_dam_device2,
359         &tegra_i2s_device1,
360         &tegra_i2s_device3,
361         &tegra_i2s_device4,
362         &tegra_spdif_device,
363         &spdif_dit_device,
364         &bluetooth_dit_device,
365         &macallan_audio_device,
366         &tegra_hda_device,
367 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
368         &tegra_aes_device,
369 #endif
370 };
371
372 #ifdef CONFIG_USB_SUPPORT
373 static struct tegra_usb_platform_data tegra_udc_pdata = {
374         .port_otg = true,
375         .has_hostpc = true,
376         .support_pmu_vbus = true,
377         .id_det_type = TEGRA_USB_PMU_ID,
378         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
379         .op_mode = TEGRA_USB_OPMODE_DEVICE,
380         .u_data.dev = {
381                 .vbus_pmu_irq = 0,
382                 .vbus_gpio = -1,
383                 .charging_supported = false,
384                 .remote_wakeup_supported = false,
385         },
386         .u_cfg.utmi = {
387                 .hssync_start_delay = 0,
388                 .elastic_limit = 16,
389                 .idle_wait_delay = 17,
390                 .term_range_adj = 6,
391                 .xcvr_setup = 8,
392                 .xcvr_lsfslew = 2,
393                 .xcvr_lsrslew = 2,
394                 .xcvr_setup_offset = 0,
395                 .xcvr_use_fuses = 1,
396         },
397 };
398
399 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
400         .port_otg = true,
401         .has_hostpc = true,
402         .support_pmu_vbus = true,
403         .id_det_type = TEGRA_USB_PMU_ID,
404         .unaligned_dma_buf_supported = false,
405         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
406         .op_mode = TEGRA_USB_OPMODE_HOST,
407         .u_data.host = {
408                 .vbus_gpio = -1,
409                 .hot_plug = false,
410                 .remote_wakeup_supported = true,
411                 .power_off_on_suspend = true,
412         },
413         .u_cfg.utmi = {
414                 .hssync_start_delay = 0,
415                 .elastic_limit = 16,
416                 .idle_wait_delay = 17,
417                 .term_range_adj = 6,
418                 .xcvr_setup = 15,
419                 .xcvr_lsfslew = 2,
420                 .xcvr_lsrslew = 2,
421                 .xcvr_setup_offset = 0,
422                 .xcvr_use_fuses = 1,
423                 .vbus_oc_map = 0x4,
424         },
425 };
426
427 static struct tegra_usb_otg_data tegra_otg_pdata = {
428         .ehci_device = &tegra_ehci1_device,
429         .ehci_pdata = &tegra_ehci1_utmi_pdata,
430         .vbus_extcon_dev_name = "palmas-extcon",
431         .id_extcon_dev_name = "palmas-extcon",
432 };
433
434 static void macallan_usb_init(void)
435 {
436         int usb_port_owner_info = tegra_get_usb_port_owner_info();
437
438         /* Set USB wake sources for macallan */
439         tegra_set_usb_wake_source();
440
441         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
442                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
443                 platform_device_register(&tegra_otg_device);
444                 /* Setup the udc platform data */
445                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
446         }
447 }
448
449 static struct gpio modem_gpios[] = { /* Nemo modem */
450         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
451         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
452 };
453
454 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
455         .port_otg = false,
456         .has_hostpc = true,
457         .unaligned_dma_buf_supported = false,
458         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
459         .op_mode = TEGRA_USB_OPMODE_HOST,
460         .u_data.host = {
461                 .vbus_gpio = -1,
462                 .hot_plug = false,
463                 .remote_wakeup_supported = true,
464                 .power_off_on_suspend = true,
465         },
466 };
467
468 static int baseband_init(void)
469 {
470         int ret;
471
472         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
473         if (ret) {
474                 pr_warn("%s:gpio request failed\n", __func__);
475                 return ret;
476         }
477
478         /* enable pull-down for MDM_COLD_BOOT */
479         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
480                                     TEGRA_PUPD_PULL_DOWN);
481
482         /* export GPIO for user space access through sysfs */
483         gpio_export(MDM_RST, false);
484
485         return 0;
486 }
487
488 static const struct tegra_modem_operations baseband_operations = {
489         .init = baseband_init,
490 };
491
492 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
493         .ops = &baseband_operations,
494         .wake_gpio = -1,
495         .boot_gpio = MDM_COLDBOOT,
496         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
497         .autosuspend_delay = 2000,
498         .short_autosuspend_delay = 50,
499         .tegra_ehci_device = &tegra_ehci2_device,
500         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
501 };
502
503 static struct platform_device icera_nemo_device = {
504         .name = "tegra_usb_modem_power",
505         .id = -1,
506         .dev = {
507                 .platform_data = &baseband_pdata,
508         },
509 };
510
511 static void macallan_modem_init(void)
512 {
513         int modem_id = tegra_get_modem_id();
514         int usb_port_owner_info = tegra_get_usb_port_owner_info();
515         switch (modem_id) {
516         case TEGRA_BB_NEMO: /* on board i500 HSIC */
517                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
518                         platform_device_register(&icera_nemo_device);
519                 break;
520         }
521 }
522
523 #else
524 static void macallan_usb_init(void) { }
525 static void macallan_modem_init(void) { }
526 #endif
527
528 static void macallan_audio_init(void)
529 {
530         macallan_audio_pdata.codec_name = "rt5640.0-001c";
531         macallan_audio_pdata.codec_dai_name = "rt5640-aif1";
532 }
533
534
535 static struct platform_device *macallan_spi_devices[] __initdata = {
536         &tegra11_spi_device1,
537 };
538
539 struct spi_clk_parent spi_parent_clk_macallan[] = {
540         [0] = {.name = "pll_p"},
541 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
542         [1] = {.name = "pll_m"},
543         [2] = {.name = "clk_m"},
544 #else
545         [1] = {.name = "clk_m"},
546 #endif
547 };
548
549 static struct tegra_spi_platform_data macallan_spi_pdata = {
550         .is_dma_based           = false,
551         .max_dma_buffer         = 16 * 1024,
552         .is_clkon_always        = false,
553         .max_rate               = 25000000,
554 };
555
556 static void __init macallan_spi_init(void)
557 {
558         int i;
559         struct clk *c;
560
561         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_macallan); ++i) {
562                 c = tegra_get_clock_by_name(spi_parent_clk_macallan[i].name);
563                 if (IS_ERR_OR_NULL(c)) {
564                         pr_err("Not able to get the clock for %s\n",
565                                         spi_parent_clk_macallan[i].name);
566                         continue;
567                 }
568                 spi_parent_clk_macallan[i].parent_clk = c;
569                 spi_parent_clk_macallan[i].fixed_clk_rate = clk_get_rate(c);
570         }
571         macallan_spi_pdata.parent_clk_list = spi_parent_clk_macallan;
572         macallan_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_macallan);
573         tegra11_spi_device1.dev.platform_data = &macallan_spi_pdata;
574         platform_add_devices(macallan_spi_devices,
575                                 ARRAY_SIZE(macallan_spi_devices));
576 }
577
578 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
579         /* name         parent          rate            enabled */
580         { "extern2",    "pll_p",        41000000,       false},
581         { "clk_out_2",  "extern2",      40800000,       false},
582         { NULL,         NULL,           0,              0},
583 };
584
585 struct rm_spi_ts_platform_data rm31080ts_macallan_data = {
586         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
587         .config = 0,
588         .platform_id = RM_PLATFORM_D010,
589         .name_of_clock = "clk_out_2",
590         .name_of_clock_con = "extern2",
591 };
592
593 static struct tegra_spi_device_controller_data dev_cdata = {
594         .rx_clk_tap_delay = 0,
595         .tx_clk_tap_delay = 16,
596 };
597
598 struct spi_board_info rm31080a_macallan_spi_board[1] = {
599         {
600          .modalias = "rm_ts_spidev",
601          .bus_num = 0,
602          .chip_select = 0,
603          .max_speed_hz = 12 * 1000 * 1000,
604          .mode = SPI_MODE_0,
605          .controller_data = &dev_cdata,
606          .platform_data = &rm31080ts_macallan_data,
607          },
608 };
609
610 static int __init macallan_touch_init(void)
611 {
612         tegra_clk_init_from_table(touch_clk_init_table);
613         if (display_board_info.board_id == BOARD_E1582)
614                 rm31080ts_macallan_data.platform_id = RM_PLATFORM_P005;
615         else
616                 rm31080ts_macallan_data.platform_id = RM_PLATFORM_D010;
617         mdelay(20);
618         rm31080a_macallan_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
619         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
620                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
621                                 &rm31080ts_macallan_data,
622                                 &rm31080a_macallan_spi_board[0],
623                                 ARRAY_SIZE(rm31080a_macallan_spi_board));
624         return 0;
625 }
626
627 #ifdef CONFIG_USE_OF
628 struct of_dev_auxdata macallan_auxdata_lookup[] __initdata = {
629         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
630                                 NULL),
631         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
632                                 NULL),
633         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
634                                 &macallan_tegra_sdhci_platform_data0),
635         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
636                                 NULL),
637         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
638                                 NULL),
639         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
640                                 NULL),
641         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
642                                 NULL),
643         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
644                                 NULL),
645         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
646                                 NULL),
647         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
648                                 NULL),
649         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
650                                 NULL),
651
652         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
653                                 NULL),
654         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
655                                 NULL),
656         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
657                                 NULL),
658         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
659                                 NULL),
660         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
661                                 NULL),
662         {}
663 };
664 #endif
665
666 static void __init tegra_macallan_early_init(void)
667 {
668         tegra_clk_init_from_table(macallan_clk_init_table);
669         tegra_clk_verify_parents();
670         tegra_soc_device_init("macallan");
671 }
672
673
674 static void __init tegra_macallan_late_init(void)
675 {
676         platform_device_register(&tegra_pinmux_device);
677         macallan_pinmux_init();
678         macallan_i2c_init();
679         macallan_spi_init();
680         macallan_usb_init();
681         macallan_uart_init();
682         macallan_audio_init();
683         platform_add_devices(macallan_devices, ARRAY_SIZE(macallan_devices));
684         //tegra_ram_console_debug_init();
685         tegra_io_dpd_init();
686         macallan_regulator_init();
687         macallan_sdhci_init();
688         macallan_suspend_init();
689         macallan_emc_init();
690         macallan_edp_init();
691         isomgr_init();
692         macallan_touch_init();
693         macallan_panel_init();
694         macallan_kbc_init();
695         macallan_pmon_init();
696 #if defined CONFIG_TI_ST || defined CONFIG_TI_ST_MODULE
697         macallan_bt_st();
698         macallan_tegra_setup_st_host_wake();
699 #endif
700         tegra_release_bootloader_fb();
701         macallan_modem_init();
702 #ifdef CONFIG_TEGRA_WDT_RECOVERY
703         tegra_wdt_recovery_init();
704 #endif
705         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
706         macallan_sensors_init();
707         macallan_soctherm_init();
708         tegra_register_fuse();
709 }
710
711 static void __init macallan_ramconsole_reserve(unsigned long size)
712 {
713         tegra_ram_console_debug_reserve(SZ_1M);
714 }
715
716 static void __init tegra_macallan_dt_init(void)
717 {
718         tegra_get_board_info(&board_info);
719         tegra_get_display_board_info(&display_board_info);
720
721         tegra_macallan_early_init();
722
723 #ifdef CONFIG_USE_OF
724         of_platform_populate(NULL,
725                 of_default_bus_match_table, macallan_auxdata_lookup,
726                 &platform_bus);
727 #else
728         platform_device_register(&tegra_gpio_device);
729 #endif
730
731         tegra_macallan_late_init();
732 }
733
734 static void __init tegra_macallan_reserve(void)
735 {
736 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
737         /* 1920*1200*4*2 = 18432000 bytes */
738         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
739 #else
740         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
741 #endif
742         macallan_ramconsole_reserve(SZ_1M);
743 }
744
745 static const char * const macallan_dt_board_compat[] = {
746         "nvidia,macallan",
747         NULL
748 };
749
750 MACHINE_START(MACALLAN, "macallan")
751         .atag_offset    = 0x100,
752         .smp            = smp_ops(tegra_smp_ops),
753         .map_io         = tegra_map_common_io,
754         .reserve        = tegra_macallan_reserve,
755         .init_early     = tegra11x_init_early,
756         .init_irq       = tegra_dt_init_irq,
757         .handle_irq     = gic_handle_irq,
758         .timer          = &tegra_sys_timer,
759         .init_machine   = tegra_macallan_dt_init,
760         .restart        = tegra_assert_system_reset,
761         .dt_compat      = macallan_dt_board_compat,
762 MACHINE_END