ARM: tegra: remove bus recovery API from platform data
[linux-3.10.git] / arch / arm / mach-tegra / board-pluto.c
1 /*
2  * arch/arm/mach-tegra/board-pluto.c
3  *
4  * Copyright (c) 2012, 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/spi/spi.h>
35 #include <linux/spi/rm31080a_ts.h>
36 #include <linux/tegra_uart.h>
37 #include <linux/memblock.h>
38 #include <linux/spi-tegra.h>
39 #include <linux/nfc/pn544.h>
40 #include <linux/nfc/bcm2079x.h>
41 #include <linux/rfkill-gpio.h>
42 #include <linux/skbuff.h>
43 #include <linux/ti_wilink_st.h>
44 #include <linux/regulator/consumer.h>
45 #include <linux/smb349-charger.h>
46 #include <linux/max17048_battery.h>
47 #include <linux/leds.h>
48 #include <linux/i2c/at24.h>
49 #include <linux/mfd/max8831.h>
50 #include <linux/of_platform.h>
51 #include <linux/a2220.h>
52 #include <linux/edp.h>
53 #include <linux/mfd/tlv320aic3262-registers.h>
54 #include <linux/mfd/tlv320aic3xxx-core.h>
55
56 #include <asm/hardware/gic.h>
57
58 #include <mach/clk.h>
59 #include <mach/iomap.h>
60 #include <mach/irqs.h>
61 #include <mach/pinmux.h>
62 #include <mach/pinmux-t11.h>
63 #include <mach/iomap.h>
64 #include <mach/io.h>
65 #include <mach/io_dpd.h>
66 #include <mach/i2s.h>
67 #include <mach/isomgr.h>
68 #include <mach/tegra_asoc_pdata.h>
69 #include <asm/mach-types.h>
70 #include <asm/mach/arch.h>
71 #include <mach/usb_phy.h>
72 #include <mach/gpio-tegra.h>
73 #include <mach/tegra_fiq_debugger.h>
74 #include <mach/tegra-bb-power.h>
75 #include <mach/tegra_usb_modem_power.h>
76 #include <mach/tegra_wakeup_monitor.h>
77
78 #include "board.h"
79 #include "board-common.h"
80 #include "board-touch-raydium.h"
81 #include "clock.h"
82 #include "board-pluto.h"
83 #include "baseband-xmm-power.h"
84 #include "tegra-board-id.h"
85 #include "devices.h"
86 #include "gpio-names.h"
87 #include "fuse.h"
88 #include "pm.h"
89 #include "common.h"
90
91 #ifdef CONFIG_BT_BLUESLEEP
92 static struct rfkill_gpio_platform_data pluto_bt_rfkill_pdata = {
93         .name           = "bt_rfkill",
94         .shutdown_gpio  = TEGRA_GPIO_PQ7,
95         .reset_gpio     = TEGRA_GPIO_PQ6,
96         .type           = RFKILL_TYPE_BLUETOOTH,
97 };
98
99 static struct platform_device pluto_bt_rfkill_device = {
100         .name = "rfkill_gpio",
101         .id             = -1,
102         .dev = {
103                 .platform_data = &pluto_bt_rfkill_pdata,
104         },
105 };
106
107 static noinline void __init pluto_setup_bt_rfkill(void)
108 {
109         platform_device_register(&pluto_bt_rfkill_device);
110 }
111
112 static struct resource pluto_bluesleep_resources[] = {
113         [0] = {
114                 .name = "gpio_host_wake",
115                         .start  = TEGRA_GPIO_PU6,
116                         .end    = TEGRA_GPIO_PU6,
117                         .flags  = IORESOURCE_IO,
118         },
119         [1] = {
120                 .name = "gpio_ext_wake",
121                         .start  = TEGRA_GPIO_PEE1,
122                         .end    = TEGRA_GPIO_PEE1,
123                         .flags  = IORESOURCE_IO,
124         },
125         [2] = {
126                 .name = "host_wake",
127                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
128         },
129 };
130
131 static struct platform_device pluto_bluesleep_device = {
132         .name           = "bluesleep",
133         .id             = -1,
134         .num_resources  = ARRAY_SIZE(pluto_bluesleep_resources),
135         .resource       = pluto_bluesleep_resources,
136 };
137
138 static noinline void __init pluto_setup_bluesleep(void)
139 {
140         pluto_bluesleep_resources[2].start =
141                 pluto_bluesleep_resources[2].end =
142                         gpio_to_irq(TEGRA_GPIO_PU6);
143         platform_device_register(&pluto_bluesleep_device);
144         return;
145 }
146 #elif defined CONFIG_BLUEDROID_PM
147 static struct resource pluto_bluedroid_pm_resources[] = {
148         [0] = {
149                 .name   = "shutdown_gpio",
150                 .start  = TEGRA_GPIO_PQ7,
151                 .end    = TEGRA_GPIO_PQ7,
152                 .flags  = IORESOURCE_IO,
153         },
154         [1] = {
155                 .name = "host_wake",
156                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
157         },
158         [2] = {
159                 .name = "gpio_ext_wake",
160                 .start  = TEGRA_GPIO_PEE1,
161                 .end    = TEGRA_GPIO_PEE1,
162                 .flags  = IORESOURCE_IO,
163         },
164         [3] = {
165                 .name = "gpio_host_wake",
166                 .start  = TEGRA_GPIO_PU6,
167                 .end    = TEGRA_GPIO_PU6,
168                 .flags  = IORESOURCE_IO,
169         },
170         [4] = {
171                 .name = "reset_gpio",
172                 .start  = TEGRA_GPIO_PQ6,
173                 .end    = TEGRA_GPIO_PQ6,
174                 .flags  = IORESOURCE_IO,
175         },
176 };
177
178 static struct platform_device pluto_bluedroid_pm_device = {
179         .name = "bluedroid_pm",
180         .id             = 0,
181         .num_resources  = ARRAY_SIZE(pluto_bluedroid_pm_resources),
182         .resource       = pluto_bluedroid_pm_resources,
183 };
184
185 static noinline void __init pluto_setup_bluedroid_pm(void)
186 {
187         pluto_bluedroid_pm_resources[1].start =
188                 pluto_bluedroid_pm_resources[1].end =
189                                         gpio_to_irq(TEGRA_GPIO_PU6);
190         platform_device_register(&pluto_bluedroid_pm_device);
191 }
192 #endif
193
194 static __initdata struct tegra_clk_init_table pluto_clk_init_table[] = {
195         /* name         parent          rate            enabled */
196         { "pll_m",      NULL,           0,              false},
197         { "hda",        "pll_p",        108000000,      false},
198         { "hda2codec_2x", "pll_p",      48000000,       false},
199         { "pwm",        "pll_p",        3187500,        false},
200         { "i2s1",       "pll_a_out0",   0,              false},
201         { "i2s2",       "pll_a_out0",   0,              false},
202         { "i2s3",       "pll_a_out0",   0,              false},
203         { "i2s4",       "pll_a_out0",   0,              false},
204         { "spdif_out",  "pll_a_out0",   0,              false},
205         { "d_audio",    "clk_m",        12000000,       false},
206         { "dam0",       "clk_m",        12000000,       false},
207         { "dam1",       "clk_m",        12000000,       false},
208         { "dam2",       "clk_m",        12000000,       false},
209         { "audio0",     "i2s0_sync",    0,              false},
210         { "audio1",     "i2s1_sync",    0,              false},
211         { "audio2",     "i2s2_sync",    0,              false},
212         { "audio3",     "i2s3_sync",    0,              false},
213         { "audio4",     "i2s4_sync",    0,              false},
214         { "vi_sensor",  "pll_p",        150000000,      false},
215         { "cilab",      "pll_p",        150000000,      false},
216         { "cilcd",      "pll_p",        150000000,      false},
217         { "cile",       "pll_p",        150000000,      false},
218         { "i2c1",       "pll_p",        3200000,        false},
219         { "i2c2",       "pll_p",        3200000,        false},
220         { "i2c3",       "pll_p",        3200000,        false},
221         { "i2c4",       "pll_p",        3200000,        false},
222         { "i2c5",       "pll_p",        3200000,        false},
223         { "extern3",    "clk_m",        12000000,       false},
224         { NULL,         NULL,           0,              0},
225 };
226
227 static struct bcm2079x_platform_data nfc_pdata = {
228         .irq_gpio = TEGRA_GPIO_PW2,
229         .en_gpio = TEGRA_GPIO_PU4,
230         .wake_gpio = TEGRA_GPIO_PX7,
231         };
232
233 static struct i2c_board_info __initdata pluto_i2c_bus3_board_info[] = {
234         {
235                 I2C_BOARD_INFO("bcm2079x-i2c", 0x77),
236                 .platform_data = &nfc_pdata,
237         },
238 };
239
240 static struct tegra_i2c_platform_data pluto_i2c1_platform_data = {
241         .adapter_nr     = 0,
242         .bus_count      = 1,
243         .bus_clk_rate   = { 100000, 0 },
244         .scl_gpio               = {TEGRA_GPIO_I2C1_SCL, 0},
245         .sda_gpio               = {TEGRA_GPIO_I2C1_SDA, 0},
246 };
247
248 static struct tegra_i2c_platform_data pluto_i2c2_platform_data = {
249         .adapter_nr     = 1,
250         .bus_count      = 1,
251         .bus_clk_rate   = { 100000, 0 },
252         .is_clkon_always = true,
253         .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
254         .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
255 };
256
257 static struct tegra_i2c_platform_data pluto_i2c3_platform_data = {
258         .adapter_nr     = 2,
259         .bus_count      = 1,
260         .bus_clk_rate   = { 100000, 0 },
261         .scl_gpio               = {TEGRA_GPIO_I2C3_SCL, 0},
262         .sda_gpio               = {TEGRA_GPIO_I2C3_SDA, 0},
263 };
264
265 static struct tegra_i2c_platform_data pluto_i2c4_platform_data = {
266         .adapter_nr     = 3,
267         .bus_count      = 1,
268         .bus_clk_rate   = { 10000, 0 },
269         .scl_gpio               = {TEGRA_GPIO_I2C4_SCL, 0},
270         .sda_gpio               = {TEGRA_GPIO_I2C4_SDA, 0},
271 };
272
273 static struct tegra_i2c_platform_data pluto_i2c5_platform_data = {
274         .adapter_nr     = 4,
275         .bus_count      = 1,
276         .bus_clk_rate   = { 400000, 0 },
277         .scl_gpio               = {TEGRA_GPIO_I2C5_SCL, 0},
278         .sda_gpio               = {TEGRA_GPIO_I2C5_SDA, 0},
279 };
280
281 static struct aic3262_gpio_setup aic3262_gpio[] = {
282         /* GPIO 1*/
283         {
284                 .used = 1,
285                 .in = 0,
286                 .value = AIC3262_GPIO1_FUNC_INT1_OUTPUT ,
287         },
288         /* GPIO 2*/
289         {
290                 .used = 1,
291                 .in = 0,
292                 .value = AIC3262_GPIO2_FUNC_ADC_MOD_CLK_OUTPUT,
293         },
294         /* GPIO 1 */
295         {
296                 .used = 0,
297         },
298         /* GPI2 */
299         {
300                 .used = 1,
301                 .in = 1,
302                 .in_reg = AIC3262_DMIC_INPUT_CNTL,
303                 .in_reg_bitmask = AIC3262_DMIC_CONFIGURE_MASK,
304                 .in_reg_shift = AIC3262_DMIC_CONFIGURE_SHIFT,
305                 .value = AIC3262_DMIC_GPI2_LEFT_GPI2_RIGHT,
306         },
307         /* GPO1 */
308         {
309                 .used = 0,
310                 .value = AIC3262_GPO1_FUNC_DISABLED,
311         },
312 };
313 static struct aic3xxx_pdata aic3262_codec_pdata = {
314         .gpio_irq       = 0,
315         .gpio           = aic3262_gpio,
316         .naudint_irq    = 0,
317         .irq_base       = AIC3262_CODEC_IRQ_BASE,
318 };
319
320 static struct i2c_board_info __initdata cs42l73_board_info = {
321         I2C_BOARD_INFO("cs42l73", 0x4a),
322 };
323
324 static struct i2c_board_info __initdata pluto_codec_a2220_info = {
325         I2C_BOARD_INFO("audience_a2220", 0x3E),
326 };
327
328 static struct i2c_board_info __initdata pluto_codec_aic326x_info = {
329         I2C_BOARD_INFO("tlv320aic3262", 0x18),
330         .platform_data = &aic3262_codec_pdata,
331 };
332
333 static void pluto_i2c_init(void)
334 {
335         tegra11_i2c_device1.dev.platform_data = &pluto_i2c1_platform_data;
336         tegra11_i2c_device2.dev.platform_data = &pluto_i2c2_platform_data;
337         tegra11_i2c_device3.dev.platform_data = &pluto_i2c3_platform_data;
338         tegra11_i2c_device4.dev.platform_data = &pluto_i2c4_platform_data;
339         tegra11_i2c_device5.dev.platform_data = &pluto_i2c5_platform_data;
340
341         platform_device_register(&tegra11_i2c_device5);
342         platform_device_register(&tegra11_i2c_device4);
343         platform_device_register(&tegra11_i2c_device3);
344         platform_device_register(&tegra11_i2c_device2);
345         platform_device_register(&tegra11_i2c_device1);
346
347         i2c_register_board_info(0, &pluto_codec_a2220_info, 1);
348         i2c_register_board_info(0, &cs42l73_board_info, 1);
349         i2c_register_board_info(0, &pluto_codec_aic326x_info, 1);
350         pluto_i2c_bus3_board_info[0].irq = gpio_to_irq(TEGRA_GPIO_PW2);
351         i2c_register_board_info(0, pluto_i2c_bus3_board_info, 1);
352 }
353
354 static struct platform_device *pluto_uart_devices[] __initdata = {
355         &tegra_uarta_device,
356         &tegra_uartb_device,
357         &tegra_uartc_device,
358         &tegra_uartd_device,
359 };
360 static struct uart_clk_parent uart_parent_clk[] = {
361         [0] = {.name = "clk_m"},
362         [1] = {.name = "pll_p"},
363 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
364         [2] = {.name = "pll_m"},
365 #endif
366 };
367
368 static struct tegra_uart_platform_data pluto_uart_pdata;
369 static struct tegra_uart_platform_data pluto_loopback_uart_pdata;
370
371 static void __init uart_debug_init(void)
372 {
373         int debug_port_id;
374
375         debug_port_id = uart_console_debug_init(3);
376         if (debug_port_id < 0)
377                 return;
378         pluto_uart_devices[debug_port_id] = uart_console_debug_device;
379 }
380
381 static void __init pluto_uart_init(void)
382 {
383         struct clk *c;
384         int i;
385
386         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
387                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
388                 if (IS_ERR_OR_NULL(c)) {
389                         pr_err("Not able to get the clock for %s\n",
390                                                 uart_parent_clk[i].name);
391                         continue;
392                 }
393                 uart_parent_clk[i].parent_clk = c;
394                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
395         }
396         pluto_uart_pdata.parent_clk_list = uart_parent_clk;
397         pluto_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
398         pluto_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
399         pluto_loopback_uart_pdata.parent_clk_count =
400                                                 ARRAY_SIZE(uart_parent_clk);
401         pluto_loopback_uart_pdata.is_loopback = true;
402         tegra_uarta_device.dev.platform_data = &pluto_uart_pdata;
403         tegra_uartb_device.dev.platform_data = &pluto_uart_pdata;
404         tegra_uartc_device.dev.platform_data = &pluto_uart_pdata;
405         tegra_uartd_device.dev.platform_data = &pluto_uart_pdata;
406
407         /* Register low speed only if it is selected */
408         if (!is_tegra_debug_uartport_hs())
409                 uart_debug_init();
410
411         platform_add_devices(pluto_uart_devices,
412                                 ARRAY_SIZE(pluto_uart_devices));
413 }
414
415 static struct resource tegra_rtc_resources[] = {
416         [0] = {
417                 .start = TEGRA_RTC_BASE,
418                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
419                 .flags = IORESOURCE_MEM,
420         },
421         [1] = {
422                 .start = INT_RTC,
423                 .end = INT_RTC,
424                 .flags = IORESOURCE_IRQ,
425         },
426 };
427
428 static struct platform_device tegra_rtc_device = {
429         .name = "tegra_rtc",
430         .id   = -1,
431         .resource = tegra_rtc_resources,
432         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
433 };
434
435 #if defined(CONFIG_TEGRA_WAKEUP_MONITOR)
436 static struct tegra_wakeup_monitor_platform_data
437                         pluto_tegra_wakeup_monitor_pdata = {
438         .wifi_wakeup_source     = 6,
439 };
440
441 static struct platform_device pluto_tegra_wakeup_monitor_device = {
442         .name = "tegra_wakeup_monitor",
443         .id   = -1,
444         .dev  = {
445                 .platform_data = &pluto_tegra_wakeup_monitor_pdata,
446         },
447 };
448 #endif
449
450 static struct tegra_asoc_platform_data pluto_audio_pdata = {
451         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
452         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
453         .gpio_hp_mute           = -1,
454         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
455         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
456         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
457         .i2s_param[HIFI_CODEC]  = {
458                 .audio_port_id  = 1,
459                 .is_i2s_master  = 0,
460                 .i2s_mode       = TEGRA_DAIFMT_I2S,
461                 .sample_size    = 16,
462                 .channels       = 2,
463         },
464         .i2s_param[BASEBAND]    = {
465                 .audio_port_id  = 2,
466                 .is_i2s_master  = 1,
467                 .i2s_mode       = TEGRA_DAIFMT_I2S,
468                 .sample_size    = 16,
469                 .rate           = 16000,
470                 .channels       = 2,
471                 .bit_clk        = 1024000,
472         },
473         .i2s_param[BT_SCO]      = {
474                 .audio_port_id  = 3,
475                 .is_i2s_master  = 1,
476                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
477                 .sample_size    = 16,
478                 .channels       = 1,
479                 .bit_clk        = 512000,
480         },
481         .i2s_param[VOICE_CODEC] = {
482                 .audio_port_id  = 0,
483                 .is_i2s_master  = 1,
484                 .i2s_mode       = TEGRA_DAIFMT_I2S,
485                 .sample_size    = 16,
486                 .rate           = 16000,
487                 .channels       = 2,
488         },
489 };
490
491 static struct tegra_asoc_platform_data pluto_aic3262_pdata = {
492         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
493         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
494         .gpio_hp_mute           = -1,
495         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
496         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
497         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
498         .i2s_param[HIFI_CODEC]  = {
499                 .audio_port_id  = 1,
500                 .is_i2s_master  = 1,
501                 .i2s_mode       = TEGRA_DAIFMT_I2S,
502                 .sample_size    = 16,
503                 .channels       = 2,
504         },
505         .i2s_param[BASEBAND]    = {
506                 .audio_port_id  = 2,
507                 .is_i2s_master  = 1,
508                 .i2s_mode       = TEGRA_DAIFMT_I2S,
509                 .sample_size    = 16,
510                 .rate           = 16000,
511                 .channels       = 2,
512                 .bit_clk        = 1024000,
513         },
514         .i2s_param[BT_SCO]      = {
515                 .audio_port_id  = 3,
516                 .is_i2s_master  = 1,
517                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
518                 .sample_size    = 16,
519                 .channels       = 1,
520                 .bit_clk        = 512000,
521         },
522         .i2s_param[VOICE_CODEC] = {
523                 .audio_port_id  = 0,
524                 .is_i2s_master  = 1,
525                 .i2s_mode       = TEGRA_DAIFMT_I2S,
526                 .sample_size    = 16,
527                 .rate           = 16000,
528                 .channels       = 2,
529         },
530 };
531
532 static struct platform_device pluto_audio_device = {
533         .name   = "tegra-snd-cs42l73",
534         .id     = 2,
535         .dev    = {
536                 .platform_data = &pluto_audio_pdata,
537         },
538 };
539
540 static struct platform_device pluto_audio_aic326x_device = {
541         .name   = "tegra-snd-aic326x",
542         .id     = 2,
543         .dev    = {
544                 .platform_data  = &pluto_aic3262_pdata,
545         },
546 };
547
548 static struct platform_device tegra_camera = {
549         .name = "tegra_camera",
550         .id = -1,
551 };
552
553 #ifdef CONFIG_MHI_NETDEV
554 struct platform_device mhi_netdevice0 = {
555         .name = "mhi_net_device",
556         .id = 0,
557 };
558 #endif /* CONFIG_MHI_NETDEV */
559
560 static struct platform_device *pluto_devices[] __initdata = {
561         &tegra_pmu_device,
562         &tegra_rtc_device,
563         &tegra_udc_device,
564 #if defined(CONFIG_TEGRA_AVP)
565         &tegra_avp_device,
566 #endif
567         &tegra_camera,
568 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
569         &tegra11_se_device,
570 #endif
571         &tegra_ahub_device,
572         &tegra_dam_device0,
573         &tegra_dam_device1,
574         &tegra_dam_device2,
575         &tegra_i2s_device0,
576         &tegra_i2s_device1,
577         &tegra_i2s_device2,
578         &tegra_i2s_device3,
579         &tegra_i2s_device4,
580         &tegra_spdif_device,
581         &spdif_dit_device,
582         &bluetooth_dit_device,
583         &baseband_dit_device,
584 #if defined(CONFIG_TEGRA_WAKEUP_MONITOR)
585         &pluto_tegra_wakeup_monitor_device,
586 #endif
587         &pluto_audio_device,
588         &pluto_audio_aic326x_device,
589         &tegra_hda_device,
590 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
591         &tegra_aes_device,
592 #endif
593 #ifdef CONFIG_MHI_NETDEV
594         &mhi_netdevice0,  /* MHI netdevice */
595 #endif /* CONFIG_MHI_NETDEV */
596 };
597
598 #ifdef CONFIG_USB_SUPPORT
599 static struct tegra_usb_platform_data tegra_ehci3_hsic_xmm_pdata = {
600         .port_otg = false,
601         .has_hostpc = true,
602         .unaligned_dma_buf_supported = false,
603         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
604         .op_mode        = TEGRA_USB_OPMODE_HOST,
605         .u_data.host = {
606                 .vbus_gpio = -1,
607                 .hot_plug = false,
608                 .remote_wakeup_supported = true,
609                 .power_off_on_suspend = true,
610         },
611 };
612
613 static struct tegra_usb_platform_data tegra_ehci3_hsic_smsc_hub_pdata = {
614         .port_otg = false,
615         .has_hostpc = true,
616         .unaligned_dma_buf_supported = false,
617         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
618         .op_mode        = TEGRA_USB_OPMODE_HOST,
619         .u_data.host = {
620                 .vbus_gpio = -1,
621                 .hot_plug = false,
622                 .remote_wakeup_supported = true,
623                 .power_off_on_suspend = true,
624         },
625 };
626
627 static struct tegra_usb_platform_data tegra_udc_pdata = {
628         .port_otg = true,
629         .has_hostpc = true,
630         .builtin_host_disabled = true,
631         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
632         .op_mode = TEGRA_USB_OPMODE_DEVICE,
633         .u_data.dev = {
634                 .vbus_pmu_irq = 0,
635                 .vbus_gpio = -1,
636                 .charging_supported = false,
637                 .remote_wakeup_supported = false,
638         },
639         .u_cfg.utmi = {
640                 .hssync_start_delay = 0,
641                 .elastic_limit = 16,
642                 .idle_wait_delay = 17,
643                 .term_range_adj = 6,
644                 .xcvr_setup = 8,
645                 .xcvr_lsfslew = 2,
646                 .xcvr_lsrslew = 2,
647                 .xcvr_setup_offset = 0,
648                 .xcvr_use_fuses = 1,
649         },
650 };
651
652 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
653         .port_otg = true,
654         .has_hostpc = true,
655         .builtin_host_disabled = true,
656         .unaligned_dma_buf_supported = false,
657         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
658         .op_mode = TEGRA_USB_OPMODE_HOST,
659         .u_data.host = {
660                 .vbus_gpio = -1,
661                 .hot_plug = false,
662                 .remote_wakeup_supported = true,
663                 .power_off_on_suspend = true,
664         },
665         .u_cfg.utmi = {
666                 .hssync_start_delay = 0,
667                 .elastic_limit = 16,
668                 .idle_wait_delay = 17,
669                 .term_range_adj = 6,
670                 .xcvr_setup = 15,
671                 .xcvr_lsfslew = 2,
672                 .xcvr_lsrslew = 2,
673                 .xcvr_setup_offset = 0,
674                 .xcvr_use_fuses = 1,
675                 .vbus_oc_map = 0x7,
676         },
677 };
678
679 static struct tegra_usb_otg_data tegra_otg_pdata = {
680         .ehci_device = &tegra_ehci1_device,
681         .ehci_pdata = &tegra_ehci1_utmi_pdata,
682 };
683
684 static struct regulator *baseband_reg;
685 static struct gpio modem_gpios[] = { /* i500 modem */
686         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
687 };
688
689 static struct gpio modem2_gpios[] = {
690         {MDM2_PWR_ON, GPIOF_OUT_INIT_LOW, "MODEM2 PWR ON"},
691         {MDM2_RST, GPIOF_DIR_OUT, "MODEM2 RESET"},
692         {MDM2_ACK2, GPIOF_OUT_INIT_HIGH, "MODEM2 ACK2"},
693         {MDM2_ACK1, GPIOF_OUT_INIT_LOW, "MODEM2 ACK1"},
694 };
695
696 static void baseband2_post_phy_on(void);
697 static void baseband2_pre_phy_off(void);
698
699 static struct tegra_usb_phy_platform_ops baseband2_plat_ops = {
700         .pre_phy_off = baseband2_pre_phy_off,
701         .post_phy_on = baseband2_post_phy_on,
702 };
703
704 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
705         .port_otg = false,
706         .has_hostpc = true,
707         .unaligned_dma_buf_supported = false,
708         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
709         .op_mode = TEGRA_USB_OPMODE_HOST,
710         .u_data.host = {
711                 .vbus_gpio = -1,
712                 .hot_plug = false,
713                 .remote_wakeup_supported = false,
714                 .power_off_on_suspend = false,
715         },
716 };
717
718 static struct tegra_usb_platform_data tegra_ehci3_hsic_baseband2_pdata = {
719         .port_otg = false,
720         .has_hostpc = true,
721         .unaligned_dma_buf_supported = false,
722         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
723         .op_mode = TEGRA_USB_OPMODE_HOST,
724         .u_data.host = {
725                 .vbus_gpio = -1,
726                 .hot_plug = false,
727                 .remote_wakeup_supported = false,
728                 .power_off_on_suspend = false,
729         },
730         .ops = &baseband2_plat_ops,
731 };
732
733 static struct tegra_usb_platform_data tegra_hsic_pdata = {
734         .port_otg = false,
735         .has_hostpc = true,
736         .unaligned_dma_buf_supported = false,
737         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
738         .op_mode        = TEGRA_USB_OPMODE_HOST,
739         .u_data.host = {
740                 .vbus_gpio = -1,
741                 .hot_plug = false,
742                 .remote_wakeup_supported = true,
743                 .power_off_on_suspend = true,
744         },
745 };
746
747 static struct platform_device *
748 tegra_usb_hsic_host_register(struct platform_device *ehci_dev)
749 {
750         struct platform_device *pdev;
751         int val;
752
753         pdev = platform_device_alloc(ehci_dev->name, ehci_dev->id);
754         if (!pdev)
755                 return NULL;
756
757         val = platform_device_add_resources(pdev, ehci_dev->resource,
758                                                 ehci_dev->num_resources);
759         if (val)
760                 goto error;
761
762         pdev->dev.dma_mask =  ehci_dev->dev.dma_mask;
763         pdev->dev.coherent_dma_mask = ehci_dev->dev.coherent_dma_mask;
764
765         val = platform_device_add_data(pdev, &tegra_hsic_pdata,
766                         sizeof(struct tegra_usb_platform_data));
767         if (val)
768                 goto error;
769
770         val = platform_device_add(pdev);
771         if (val)
772                 goto error;
773
774         return pdev;
775
776 error:
777         pr_err("%s: failed to add the host contoller device\n", __func__);
778         platform_device_put(pdev);
779         return NULL;
780 }
781
782 static void tegra_usb_hsic_host_unregister(struct platform_device **platdev)
783 {
784         struct platform_device *pdev = *platdev;
785
786         if (pdev && &pdev->dev) {
787                 platform_device_unregister(pdev);
788                 *platdev = NULL;
789         } else
790                 pr_err("%s: no platform device\n", __func__);
791 }
792
793 static struct tegra_usb_phy_platform_ops oem1_hsic_pops;
794
795 static union tegra_bb_gpio_id bb_gpio_oem1 = {
796         .oem1 = {
797                 .reset = BB_OEM1_GPIO_RST,
798                 .pwron = BB_OEM1_GPIO_ON,
799                 .awr = BB_OEM1_GPIO_AWR,
800                 .cwr = BB_OEM1_GPIO_CWR,
801                 .spare = BB_OEM1_GPIO_SPARE,
802                 .wdi = BB_OEM1_GPIO_WDI,
803         },
804 };
805
806 static struct tegra_bb_pdata bb_pdata_oem1 = {
807         .id = &bb_gpio_oem1,
808         .device = &tegra_ehci3_device,
809         .ehci_register = tegra_usb_hsic_host_register,
810         .ehci_unregister = tegra_usb_hsic_host_unregister,
811         .bb_id = TEGRA_BB_OEM1,
812 };
813
814 static struct platform_device tegra_bb_oem1 = {
815         .name = "tegra_baseband_power",
816         .id = -1,
817         .dev = {
818                 .platform_data = &bb_pdata_oem1,
819         },
820 };
821
822 static int baseband_init(void)
823 {
824         int ret;
825
826         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
827         if (ret) {
828                 pr_warn("%s:gpio request failed\n", __func__);
829                 return ret;
830         }
831
832         baseband_reg = regulator_get(NULL, "vdd_core_bb");
833         if (IS_ERR_OR_NULL(baseband_reg))
834                 pr_warn("%s: baseband regulator get failed\n", __func__);
835         else
836                 regulator_enable(baseband_reg);
837
838         /* enable pull-down for MDM1_COLD_BOOT */
839         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
840                                     TEGRA_PUPD_PULL_DOWN);
841
842         /* export GPIO for user space access through sysfs */
843         gpio_export(MDM_RST, false);
844
845         return 0;
846 }
847
848 static const struct tegra_modem_operations baseband_operations = {
849         .init = baseband_init,
850 };
851
852 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
853         .ops = &baseband_operations,
854         .wake_gpio = -1,
855         .boot_gpio = MDM_COLDBOOT,
856         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
857         .autosuspend_delay = 2000,
858         .short_autosuspend_delay = 50,
859         .tegra_ehci_device = &tegra_ehci2_device,
860         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
861 };
862
863 static struct platform_device icera_baseband_device = {
864         .name = "tegra_usb_modem_power",
865         .id = -1,
866         .dev = {
867                 .platform_data = &baseband_pdata,
868         },
869 };
870
871 static void baseband2_post_phy_on(void)
872 {
873         /* set MDM2_ACK2 low */
874         gpio_set_value(MDM2_ACK2, 0);
875 }
876
877 static void baseband2_pre_phy_off(void)
878 {
879         /* set MDM2_ACK2 high */
880         gpio_set_value(MDM2_ACK2, 1);
881 }
882
883 static void baseband2_start(void)
884 {
885         /*
886          *  Leave baseband powered OFF.
887          *  User-space daemons will take care of powering it up.
888          */
889         pr_info("%s\n", __func__);
890         gpio_set_value(MDM2_PWR_ON, 0);
891 }
892
893 static void baseband2_reset(void)
894 {
895         /* Initiate power cycle on baseband sub system */
896         pr_info("%s\n", __func__);
897         gpio_set_value(MDM2_PWR_ON, 0);
898         mdelay(200);
899         gpio_set_value(MDM2_PWR_ON, 1);
900 }
901
902 static int baseband2_init(void)
903 {
904         int ret;
905
906         ret = gpio_request_array(modem2_gpios, ARRAY_SIZE(modem2_gpios));
907         if (ret)
908                 return ret;
909
910         /* enable pull-up for MDM2_REQ2 */
911         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PV1,
912                                     TEGRA_PUPD_PULL_UP);
913
914         /* export GPIO for user space access through sysfs */
915         gpio_export(MDM2_PWR_ON, false);
916
917         return 0;
918 }
919
920 static const struct tegra_modem_operations baseband2_operations = {
921         .init = baseband2_init,
922         .start = baseband2_start,
923         .reset = baseband2_reset,
924 };
925
926 static struct tegra_usb_modem_power_platform_data baseband2_pdata = {
927         .ops = &baseband2_operations,
928         .wake_gpio = MDM2_REQ2,
929         .wake_irq_flags = IRQF_TRIGGER_FALLING,
930         .boot_gpio = MDM2_COLDBOOT,
931         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
932         .autosuspend_delay = 2000,
933         .short_autosuspend_delay = 50,
934         .tegra_ehci_device = &tegra_ehci3_device,
935         .tegra_ehci_pdata = &tegra_ehci3_hsic_baseband2_pdata,
936 };
937
938 static struct platform_device icera_baseband2_device = {
939         .name = "tegra_usb_modem_power",
940         .id = -1,
941         .dev = {
942                 .platform_data = &baseband2_pdata,
943         },
944 };
945
946 static struct baseband_power_platform_data tegra_baseband_xmm_power_data = {
947         .baseband_type = BASEBAND_XMM,
948         .modem = {
949                 .xmm = {
950                         .bb_rst = XMM_GPIO_BB_RST,
951                         .bb_on = XMM_GPIO_BB_ON,
952                         .ipc_bb_wake = XMM_GPIO_IPC_BB_WAKE,
953                         .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
954                         .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
955                         .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
956                 },
957         },
958 };
959
960 static struct platform_device tegra_baseband_xmm_power_device = {
961         .name = "baseband_xmm_power",
962         .id = -1,
963         .dev = {
964                 .platform_data = &tegra_baseband_xmm_power_data,
965         },
966 };
967
968 static struct platform_device tegra_baseband_xmm_power2_device = {
969         .name = "baseband_xmm_power2",
970         .id = -1,
971         .dev = {
972                 .platform_data = &tegra_baseband_xmm_power_data,
973         },
974 };
975
976 static void pluto_usb_init(void)
977 {
978         int usb_port_owner_info = tegra_get_usb_port_owner_info();
979
980         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
981                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
982                 platform_device_register(&tegra_otg_device);
983
984                 /* Setup the udc platform data */
985                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
986         }
987 }
988
989 static void pluto_modem_init(void)
990 {
991         int modem_id = tegra_get_modem_id();
992         struct board_info board_info;
993         int usb_port_owner_info = tegra_get_usb_port_owner_info();
994
995         tegra_get_board_info(&board_info);
996         pr_info("%s: modem_id = %d\n", __func__, modem_id);
997
998         switch (modem_id) {
999         case TEGRA_BB_I500: /* on board i500 HSIC */
1000                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
1001                         platform_device_register(&icera_baseband_device);
1002                 break;
1003         case TEGRA_BB_I500SWD: /* i500 SWD HSIC */
1004                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB))
1005                         platform_device_register(&icera_baseband2_device);
1006                 break;
1007         case TEGRA_BB_OEM1:     /* OEM1 HSIC */
1008                 if ((board_info.board_id == BOARD_E1575) ||
1009                         ((board_info.board_id == BOARD_E1580) &&
1010                                 (board_info.fab >= BOARD_FAB_A03))) {
1011                         tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPIO_X1_AUD,
1012                                                         TEGRA_TRI_NORMAL);
1013                         bb_gpio_oem1.oem1.pwron = BB_OEM1_GPIO_ON_V;
1014                 }
1015                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB)) {
1016                         tegra_hsic_pdata.ops = &oem1_hsic_pops;
1017                         tegra_ehci3_device.dev.platform_data
1018                                 = &tegra_hsic_pdata;
1019                         platform_device_register(&tegra_bb_oem1);
1020                 }
1021                 break;
1022         case TEGRA_BB_OEM2: /* XMM6260/XMM6360 HSIC */
1023                 /* fix wrong wiring in Pluto A02 */
1024                 if ((board_info.board_id == BOARD_E1580) &&
1025                         (board_info.fab == BOARD_FAB_A02)) {
1026                         pr_info(
1027 "%s: Pluto A02: replace MDM2_PWR_ON with MDM2_PWR_ON_FOR_PLUTO_A02\n",
1028                                 __func__);
1029                         if (tegra_baseband_xmm_power_data.modem.xmm.bb_on
1030                                 != MDM2_PWR_ON)
1031                                 pr_err(
1032 "%s: expected MDM2_PWR_ON default gpio for XMM bb_on\n",
1033                                         __func__);
1034                         tegra_baseband_xmm_power_data.modem.xmm.bb_on
1035                                 = MDM2_PWR_ON_FOR_PLUTO_A02;
1036                 }
1037                 /* baseband-power.ko will register ehci3 device */
1038                 tegra_ehci3_device.dev.platform_data =
1039                                         &tegra_ehci3_hsic_xmm_pdata;
1040                 tegra_baseband_xmm_power_data.hsic_register =
1041                                                 &tegra_usb_hsic_host_register;
1042                 tegra_baseband_xmm_power_data.hsic_unregister =
1043                                                 &tegra_usb_hsic_host_unregister;
1044                 tegra_baseband_xmm_power_data.ehci_device =
1045                                         &tegra_ehci3_device;
1046                 platform_device_register(&tegra_baseband_xmm_power_device);
1047                 platform_device_register(&tegra_baseband_xmm_power2_device);
1048                 /* override audio settings - use 8kHz */
1049                 pluto_audio_pdata.i2s_param[BASEBAND].audio_port_id
1050                         = pluto_aic3262_pdata.i2s_param[BASEBAND].audio_port_id
1051                         = 2;
1052                 pluto_audio_pdata.i2s_param[BASEBAND].is_i2s_master
1053                         = pluto_aic3262_pdata.i2s_param[BASEBAND].is_i2s_master
1054                         = 1;
1055                 pluto_audio_pdata.i2s_param[BASEBAND].i2s_mode
1056                         = pluto_aic3262_pdata.i2s_param[BASEBAND].i2s_mode
1057                         = TEGRA_DAIFMT_I2S;
1058                 pluto_audio_pdata.i2s_param[BASEBAND].sample_size
1059                         = pluto_aic3262_pdata.i2s_param[BASEBAND].sample_size
1060                         = 16;
1061                 pluto_audio_pdata.i2s_param[BASEBAND].rate
1062                         = pluto_aic3262_pdata.i2s_param[BASEBAND].rate
1063                         = 8000;
1064                 pluto_audio_pdata.i2s_param[BASEBAND].channels
1065                         = pluto_aic3262_pdata.i2s_param[BASEBAND].channels
1066                         = 2;
1067                 break;
1068         case TEGRA_BB_HSIC_HUB: /* i500 SWD HSIC */
1069                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB)) {
1070                         tegra_ehci3_device.dev.platform_data =
1071                                 &tegra_ehci3_hsic_smsc_hub_pdata;
1072                         platform_device_register(&tegra_ehci3_device);
1073                 }
1074                 break;
1075         default:
1076                 return;
1077         }
1078 }
1079
1080 #else
1081 static void pluto_usb_init(void) { }
1082 static void pluto_modem_init(void) { }
1083 #endif
1084
1085 static void pluto_audio_init(void)
1086 {
1087         struct board_info board_info;
1088
1089         tegra_get_board_info(&board_info);
1090
1091 }
1092
1093 static struct platform_device *pluto_spi_devices[] __initdata = {
1094         &tegra11_spi_device4,
1095 };
1096
1097 struct spi_clk_parent spi_parent_clk_pluto[] = {
1098         [0] = {.name = "pll_p"},
1099 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
1100         [1] = {.name = "pll_m"},
1101         [2] = {.name = "clk_m"},
1102 #else
1103         [1] = {.name = "clk_m"},
1104 #endif
1105 };
1106
1107 static struct tegra_spi_platform_data pluto_spi_pdata = {
1108         .is_dma_based           = false,
1109         .max_dma_buffer         = 16 * 1024,
1110         .is_clkon_always        = false,
1111         .max_rate               = 25000000,
1112 };
1113
1114 static void __init pluto_spi_init(void)
1115 {
1116         int i;
1117         struct clk *c;
1118         struct board_info board_info, display_board_info;
1119
1120         tegra_get_board_info(&board_info);
1121         tegra_get_display_board_info(&display_board_info);
1122
1123         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_pluto); ++i) {
1124                 c = tegra_get_clock_by_name(spi_parent_clk_pluto[i].name);
1125                 if (IS_ERR_OR_NULL(c)) {
1126                         pr_err("Not able to get the clock for %s\n",
1127                                                 spi_parent_clk_pluto[i].name);
1128                         continue;
1129                 }
1130                 spi_parent_clk_pluto[i].parent_clk = c;
1131                 spi_parent_clk_pluto[i].fixed_clk_rate = clk_get_rate(c);
1132         }
1133         pluto_spi_pdata.parent_clk_list = spi_parent_clk_pluto;
1134         pluto_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_pluto);
1135         tegra11_spi_device4.dev.platform_data = &pluto_spi_pdata;
1136         platform_add_devices(pluto_spi_devices,
1137                                 ARRAY_SIZE(pluto_spi_devices));
1138 }
1139
1140 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
1141         /* name         parent          rate            enabled */
1142         { "extern2",    "pll_p",        41000000,       false},
1143         { "clk_out_2",  "extern2",      40800000,       false},
1144         { NULL,         NULL,           0,              0},
1145 };
1146
1147 struct rm_spi_ts_platform_data rm31080ts_pluto_data = {
1148         .gpio_reset = 0,
1149         .config = 0,
1150         .platform_id = RM_PLATFORM_P005,
1151         .name_of_clock = "clk_out_2",
1152 };
1153
1154 static struct tegra_spi_device_controller_data dev_cdata = {
1155         .rx_clk_tap_delay = 0,
1156         .tx_clk_tap_delay = 0,
1157 };
1158
1159 struct spi_board_info rm31080a_pluto_spi_board[1] = {
1160         {
1161          .modalias = "rm_ts_spidev",
1162          .bus_num = 3,
1163          .chip_select = 2,
1164          .max_speed_hz = 12 * 1000 * 1000,
1165          .mode = SPI_MODE_0,
1166          .controller_data = &dev_cdata,
1167          .platform_data = &rm31080ts_pluto_data,
1168          },
1169 };
1170
1171 static int __init pluto_touch_init(void)
1172 {
1173         tegra_clk_init_from_table(touch_clk_init_table);
1174         clk_enable(tegra_get_clock_by_name("clk_out_2"));
1175         mdelay(20);
1176         rm31080a_pluto_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
1177         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
1178                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
1179                                 &rm31080ts_pluto_data,
1180                                 &rm31080a_pluto_spi_board[0],
1181                                 ARRAY_SIZE(rm31080a_pluto_spi_board));
1182         return 0;
1183 }
1184
1185 #ifdef CONFIG_EDP_FRAMEWORK
1186 static struct edp_manager battery_edp_manager = {
1187         .name = "battery",
1188         .imax = 3250
1189 };
1190
1191 static void __init pluto_battery_edp_init(void)
1192 {
1193         struct edp_governor *g;
1194         int r;
1195
1196         r = edp_register_manager(&battery_edp_manager);
1197         if (r)
1198                 goto err_ret;
1199
1200         /* start with priority governor */
1201         g = edp_get_governor("priority");
1202         if (!g) {
1203                 r = -EFAULT;
1204                 goto err_ret;
1205         }
1206
1207         r = edp_set_governor(&battery_edp_manager, g);
1208         if (r)
1209                 goto err_ret;
1210
1211         return;
1212
1213 err_ret:
1214         pr_err("Battery EDP init failed with error %d\n", r);
1215         WARN_ON(1);
1216 }
1217 #else
1218 static inline void pluto_battery_edp_init(void) {}
1219 #endif
1220
1221 #ifdef CONFIG_USE_OF
1222 struct of_dev_auxdata pluto_auxdata_lookup[] __initdata = {
1223         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
1224                                 NULL),
1225         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
1226                                 NULL),
1227         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
1228                                 &pluto_tegra_sdhci_platform_data0),
1229         {}
1230 };
1231 #endif
1232
1233 static void __init tegra_pluto_early_init(void)
1234 {
1235         pluto_battery_edp_init();
1236         tegra_clk_init_from_table(pluto_clk_init_table);
1237         tegra_clk_vefify_parents();
1238         tegra_smmu_init();
1239         tegra_soc_device_init("tegra_pluto");
1240 }
1241
1242 static void __init tegra_pluto_late_init(void)
1243 {
1244         platform_device_register(&tegra_pinmux_device);
1245         pluto_pinmux_init();
1246         pluto_i2c_init();
1247         pluto_spi_init();
1248         pluto_usb_init();
1249         pluto_uart_init();
1250         pluto_audio_init();
1251         platform_add_devices(pluto_devices, ARRAY_SIZE(pluto_devices));
1252         //tegra_ram_console_debug_init();
1253         tegra_io_dpd_init();
1254         pluto_sdhci_init();
1255         pluto_regulator_init();
1256         pluto_suspend_init();
1257         pluto_touch_init();
1258         pluto_emc_init();
1259         pluto_edp_init();
1260         isomgr_init();
1261         pluto_panel_init();
1262         pluto_pmon_init();
1263         pluto_kbc_init();
1264 #ifdef CONFIG_BT_BLUESLEEP
1265         pluto_setup_bluesleep();
1266         pluto_setup_bt_rfkill();
1267 #elif defined CONFIG_BLUEDROID_PM
1268         pluto_setup_bluedroid_pm();
1269 #endif
1270         tegra_release_bootloader_fb();
1271         pluto_modem_init();
1272 #ifdef CONFIG_TEGRA_WDT_RECOVERY
1273         tegra_wdt_recovery_init();
1274 #endif
1275         pluto_sensors_init();
1276         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
1277         pluto_soctherm_init();
1278         tegra_register_fuse();
1279 }
1280
1281 static void __init pluto_ramconsole_reserve(unsigned long size)
1282 {
1283         tegra_ram_console_debug_reserve(SZ_1M);
1284 }
1285
1286 static void __init tegra_pluto_dt_init(void)
1287 {
1288         tegra_pluto_early_init();
1289
1290         of_platform_populate(NULL,
1291                 of_default_bus_match_table, pluto_auxdata_lookup, NULL);
1292
1293         tegra_pluto_late_init();
1294 }
1295
1296 static void __init tegra_pluto_reserve(void)
1297 {
1298 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
1299         /* for PANEL_5_SHARP_1080p: 1920*1080*4*2 = 16588800 bytes */
1300         tegra_reserve(0, SZ_16M, SZ_4M);
1301 #else
1302         tegra_reserve(SZ_128M, SZ_16M, SZ_4M);
1303 #endif
1304         pluto_ramconsole_reserve(SZ_1M);
1305 }
1306
1307 static const char * const pluto_dt_board_compat[] = {
1308         "nvidia,pluto",
1309         NULL
1310 };
1311
1312 MACHINE_START(TEGRA_PLUTO, "tegra_pluto")
1313         .atag_offset    = 0x100,
1314         .smp            = smp_ops(tegra_smp_ops),
1315         .map_io         = tegra_map_common_io,
1316         .reserve        = tegra_pluto_reserve,
1317         .init_early     = tegra11x_init_early,
1318         .init_irq       = tegra_dt_init_irq,
1319         .handle_irq     = gic_handle_irq,
1320         .timer          = &tegra_timer,
1321         .init_machine   = tegra_pluto_dt_init,
1322         .restart        = tegra_assert_system_reset,
1323         .dt_compat      = pluto_dt_board_compat,
1324 MACHINE_END