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