asoc: tegra: SPI interface for TI codec
[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-2013, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/slab.h>
23 #include <linux/ctype.h>
24 #include <linux/platform_device.h>
25 #include <linux/clk.h>
26 #include <linux/serial_8250.h>
27 #include <linux/i2c.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/delay.h>
30 #include <linux/i2c-tegra.h>
31 #include <linux/gpio.h>
32 #include <linux/input.h>
33 #include <linux/platform_data/tegra_usb.h>
34 #include <linux/platform_data/tegra_xusb.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/spi-tegra.h>
40 #include <linux/nfc/pn544.h>
41 #include <linux/nfc/bcm2079x.h>
42 #include <linux/rfkill-gpio.h>
43 #include <linux/skbuff.h>
44 #include <linux/ti_wilink_st.h>
45 #include <linux/regulator/consumer.h>
46 #include <linux/smb349-charger.h>
47 #include <linux/max17048_battery.h>
48 #include <linux/leds.h>
49 #include <linux/i2c/at24.h>
50 #include <linux/mfd/max8831.h>
51 #include <linux/of_platform.h>
52 #include <linux/a2220.h>
53 #include <linux/edp.h>
54 #include <linux/mfd/tlv320aic3262-registers.h>
55 #include <linux/mfd/tlv320aic3xxx-core.h>
56 #include <linux/usb/tegra_usb_phy.h>
57
58 #include <asm/hardware/gic.h>
59
60 #include <mach/clk.h>
61 #include <mach/irqs.h>
62 #include <mach/pinmux.h>
63 #include <mach/pinmux-t11.h>
64 #include <mach/io_dpd.h>
65 #include <mach/i2s.h>
66 #include <mach/isomgr.h>
67 #include <mach/tegra_asoc_pdata.h>
68 #include <asm/mach-types.h>
69 #include <asm/mach/arch.h>
70 #include <mach/gpio-tegra.h>
71 #include <mach/tegra_fiq_debugger.h>
72 #include <mach/tegra-bb-power.h>
73 #include <mach/tegra_usb_modem_power.h>
74 #include <mach/tegra_wakeup_monitor.h>
75
76 #include "board.h"
77 #include "board-common.h"
78 #include "board-touch-raydium.h"
79 #include "clock.h"
80 #include "board-pluto.h"
81 #include "baseband-xmm-power.h"
82 #include "tegra-board-id.h"
83 #include "devices.h"
84 #include "gpio-names.h"
85 #include "fuse.h"
86 #include "pm.h"
87 #include "common.h"
88 #include "iomap.h"
89
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         { "sbc1",       "pll_p",        25000000,       false},
224         { "sbc2",       "pll_p",        25000000,       false},
225         { "sbc3",       "pll_p",        25000000,       false},
226         { "sbc4",       "pll_p",        25000000,       false},
227         { "sbc5",       "pll_p",        25000000,       false},
228         { "sbc6",       "pll_p",        25000000,       false},
229         { "extern3",    "clk_m",        12000000,       false},
230         { NULL,         NULL,           0,              0},
231 };
232
233 static struct bcm2079x_platform_data nfc_pdata = {
234         .irq_gpio = TEGRA_GPIO_PW2,
235         .en_gpio = TEGRA_GPIO_PU4,
236         .wake_gpio = TEGRA_GPIO_PX7,
237         };
238
239 static struct i2c_board_info __initdata pluto_i2c_bus3_board_info[] = {
240         {
241                 I2C_BOARD_INFO("bcm2079x-i2c", 0x77),
242                 .platform_data = &nfc_pdata,
243         },
244 };
245
246 static struct tegra_i2c_platform_data pluto_i2c1_platform_data = {
247         .bus_clk_rate   = 100000,
248         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
249         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
250 };
251
252 static struct tegra_i2c_platform_data pluto_i2c2_platform_data = {
253         .bus_clk_rate   = 100000,
254         .is_clkon_always = true,
255         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
256         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
257 };
258
259 static struct tegra_i2c_platform_data pluto_i2c3_platform_data = {
260         .bus_clk_rate   = 100000,
261         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
262         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
263 };
264
265 static struct tegra_i2c_platform_data pluto_i2c4_platform_data = {
266         .bus_clk_rate   = 10000,
267         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
268         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
269 };
270
271 static struct tegra_i2c_platform_data pluto_i2c5_platform_data = {
272         .bus_clk_rate   = 400000,
273         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
274         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
275 };
276
277 static struct aic3262_gpio_setup aic3262_gpio[] = {
278         /* GPIO 1*/
279         {
280                 .used = 1,
281                 .in = 0,
282                 .value = AIC3262_GPIO1_FUNC_INT1_OUTPUT ,
283         },
284         /* GPIO 2*/
285         {
286                 .used = 1,
287                 .in = 0,
288                 .value = AIC3262_GPIO2_FUNC_ADC_MOD_CLK_OUTPUT,
289         },
290         /* GPI1 */
291         {
292                 .used = 1,
293                 .in = 1,
294         },
295         /* GPI2 */
296         {
297                 .used = 1,
298                 .in = 1,
299                 .in_reg = AIC3262_DMIC_INPUT_CNTL,
300                 .in_reg_bitmask = AIC3262_DMIC_CONFIGURE_MASK,
301                 .in_reg_shift = AIC3262_DMIC_CONFIGURE_SHIFT,
302                 .value = AIC3262_DMIC_GPI2_LEFT_GPI2_RIGHT,
303         },
304         /* GPO1 */
305         {
306                 .used = 1,
307                 .in = 0,
308                 .value = AIC3262_GPO1_FUNC_MSO_OUTPUT_FOR_SPI,
309         },
310 };
311 static struct aic3xxx_pdata aic3262_codec_pdata = {
312         .gpio_irq       = 0,
313         .gpio           = aic3262_gpio,
314         .naudint_irq    = 0,
315         .irq_base       = AIC3262_CODEC_IRQ_BASE,
316 };
317
318 static struct i2c_board_info __initdata cs42l73_board_info = {
319         I2C_BOARD_INFO("cs42l73", 0x4a),
320 };
321
322 static struct i2c_board_info __initdata pluto_codec_a2220_info = {
323         I2C_BOARD_INFO("audience_a2220", 0x3E),
324 };
325
326 static struct i2c_board_info __initdata pluto_codec_aic326x_info = {
327         I2C_BOARD_INFO("tlv320aic3262", 0x18),
328         .platform_data = &aic3262_codec_pdata,
329 };
330
331 static void pluto_i2c_init(void)
332 {
333         tegra11_i2c_device1.dev.platform_data = &pluto_i2c1_platform_data;
334         tegra11_i2c_device2.dev.platform_data = &pluto_i2c2_platform_data;
335         tegra11_i2c_device3.dev.platform_data = &pluto_i2c3_platform_data;
336         tegra11_i2c_device4.dev.platform_data = &pluto_i2c4_platform_data;
337         tegra11_i2c_device5.dev.platform_data = &pluto_i2c5_platform_data;
338
339         platform_device_register(&tegra11_i2c_device5);
340         platform_device_register(&tegra11_i2c_device4);
341         platform_device_register(&tegra11_i2c_device3);
342         platform_device_register(&tegra11_i2c_device2);
343         platform_device_register(&tegra11_i2c_device1);
344
345         i2c_register_board_info(0, &pluto_codec_a2220_info, 1);
346         i2c_register_board_info(0, &cs42l73_board_info, 1);
347         i2c_register_board_info(0, &pluto_codec_aic326x_info, 1);
348         pluto_i2c_bus3_board_info[0].irq = gpio_to_irq(TEGRA_GPIO_PW2);
349         i2c_register_board_info(0, pluto_i2c_bus3_board_info, 1);
350         i2c_register_board_info(0, &pluto_codec_aic326x_info, 1);
351 }
352
353 static struct platform_device *pluto_uart_devices[] __initdata = {
354         &tegra_uarta_device,
355         &tegra_uartb_device,
356         &tegra_uartc_device,
357         &tegra_uartd_device,
358 };
359 static struct uart_clk_parent uart_parent_clk[] = {
360         [0] = {.name = "clk_m"},
361         [1] = {.name = "pll_p"},
362 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
363         [2] = {.name = "pll_m"},
364 #endif
365 };
366
367 static struct tegra_uart_platform_data pluto_uart_pdata;
368 static struct tegra_uart_platform_data pluto_loopback_uart_pdata;
369
370 static void __init uart_debug_init(void)
371 {
372         int debug_port_id;
373
374         debug_port_id = uart_console_debug_init(3);
375         if (debug_port_id < 0)
376                 return;
377         pluto_uart_devices[debug_port_id] = uart_console_debug_device;
378 }
379
380 static void __init pluto_uart_init(void)
381 {
382         struct clk *c;
383         int i;
384
385         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
386                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
387                 if (IS_ERR_OR_NULL(c)) {
388                         pr_err("Not able to get the clock for %s\n",
389                                                 uart_parent_clk[i].name);
390                         continue;
391                 }
392                 uart_parent_clk[i].parent_clk = c;
393                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
394         }
395         pluto_uart_pdata.parent_clk_list = uart_parent_clk;
396         pluto_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
397         pluto_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
398         pluto_loopback_uart_pdata.parent_clk_count =
399                                                 ARRAY_SIZE(uart_parent_clk);
400         pluto_loopback_uart_pdata.is_loopback = true;
401         tegra_uarta_device.dev.platform_data = &pluto_uart_pdata;
402         tegra_uartb_device.dev.platform_data = &pluto_uart_pdata;
403         tegra_uartc_device.dev.platform_data = &pluto_uart_pdata;
404         tegra_uartd_device.dev.platform_data = &pluto_uart_pdata;
405
406         /* Register low speed only if it is selected */
407         if (!is_tegra_debug_uartport_hs())
408                 uart_debug_init();
409
410         platform_add_devices(pluto_uart_devices,
411                                 ARRAY_SIZE(pluto_uart_devices));
412 }
413
414 static struct resource tegra_rtc_resources[] = {
415         [0] = {
416                 .start = TEGRA_RTC_BASE,
417                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
418                 .flags = IORESOURCE_MEM,
419         },
420         [1] = {
421                 .start = INT_RTC,
422                 .end = INT_RTC,
423                 .flags = IORESOURCE_IRQ,
424         },
425 };
426
427 static struct platform_device tegra_rtc_device = {
428         .name = "tegra_rtc",
429         .id   = -1,
430         .resource = tegra_rtc_resources,
431         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
432 };
433
434 #if defined(CONFIG_TEGRA_WAKEUP_MONITOR)
435 static struct tegra_wakeup_monitor_platform_data
436                         pluto_tegra_wakeup_monitor_pdata = {
437         .wifi_wakeup_source     = 6,
438 };
439
440 static struct platform_device pluto_tegra_wakeup_monitor_device = {
441         .name = "tegra_wakeup_monitor",
442         .id   = -1,
443         .dev  = {
444                 .platform_data = &pluto_tegra_wakeup_monitor_pdata,
445         },
446 };
447 #endif
448
449 static struct tegra_asoc_platform_data pluto_audio_pdata = {
450         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
451         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
452         .gpio_hp_mute           = -1,
453         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
454         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
455         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
456         .i2s_param[HIFI_CODEC]  = {
457                 .audio_port_id  = 1,
458                 .is_i2s_master  = 0,
459                 .i2s_mode       = TEGRA_DAIFMT_I2S,
460                 .sample_size    = 16,
461                 .channels       = 2,
462         },
463         .i2s_param[BASEBAND]    = {
464                 .audio_port_id  = 2,
465                 .is_i2s_master  = 1,
466                 .i2s_mode       = TEGRA_DAIFMT_I2S,
467                 .sample_size    = 16,
468                 .rate           = 16000,
469                 .channels       = 2,
470                 .bit_clk        = 1024000,
471         },
472         .i2s_param[BT_SCO]      = {
473                 .audio_port_id  = 3,
474                 .is_i2s_master  = 1,
475                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
476                 .sample_size    = 16,
477                 .channels       = 1,
478                 .bit_clk        = 512000,
479         },
480         .i2s_param[VOICE_CODEC] = {
481                 .audio_port_id  = 0,
482                 .is_i2s_master  = 1,
483                 .i2s_mode       = TEGRA_DAIFMT_I2S,
484                 .sample_size    = 16,
485                 .rate           = 16000,
486                 .channels       = 2,
487         },
488 };
489
490 static struct tegra_asoc_platform_data pluto_aic3262_pdata = {
491         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
492         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
493         .gpio_hp_mute           = -1,
494         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
495         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
496         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
497         .i2s_param[HIFI_CODEC]  = {
498                 .audio_port_id  = 1,
499                 .is_i2s_master  = 1,
500                 .i2s_mode       = TEGRA_DAIFMT_I2S,
501                 .sample_size    = 16,
502                 .rate           = 48000,
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 #ifndef CONFIG_USE_OF
549 static struct platform_device tegra_camera = {
550         .name = "tegra_camera",
551         .id = -1,
552 };
553 #endif
554
555 static struct tegra_spi_device_controller_data dev_bdata = {
556         .rx_clk_tap_delay = 0,
557         .tx_clk_tap_delay = 0,
558 };
559 static struct spi_board_info aic326x_spi_board_info[] = {
560         {
561                 .modalias = "tlv320aic3xxx",
562                 .bus_num = 3,
563                 .chip_select = 0,
564                 .max_speed_hz = 4*1000*1000,
565                 .mode = SPI_MODE_1,
566                 .controller_data = &dev_bdata,
567                 .platform_data = &aic3262_codec_pdata,
568         },
569 };
570
571
572 #ifdef CONFIG_MHI_NETDEV
573 struct platform_device mhi_netdevice0 = {
574         .name = "mhi_net_device",
575         .id = 0,
576 };
577 #endif /* CONFIG_MHI_NETDEV */
578
579 static struct platform_device *pluto_devices[] __initdata = {
580         &tegra_pmu_device,
581         &tegra_rtc_device,
582         &tegra_udc_device,
583 #if defined(CONFIG_TEGRA_AVP)
584         &tegra_avp_device,
585 #endif
586 #ifndef CONFIG_USE_OF
587         &tegra_camera,
588 #endif
589 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
590         &tegra11_se_device,
591 #endif
592         &tegra_ahub_device,
593         &tegra_dam_device0,
594         &tegra_dam_device1,
595         &tegra_dam_device2,
596         &tegra_i2s_device0,
597         &tegra_i2s_device1,
598         &tegra_i2s_device2,
599         &tegra_i2s_device3,
600         &tegra_i2s_device4,
601         &tegra_spdif_device,
602         &spdif_dit_device,
603         &bluetooth_dit_device,
604         &baseband_dit_device,
605 #if defined(CONFIG_TEGRA_WAKEUP_MONITOR)
606         &pluto_tegra_wakeup_monitor_device,
607 #endif
608         &pluto_audio_device,
609         &pluto_audio_aic326x_device,
610         &tegra_hda_device,
611 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
612         &tegra_aes_device,
613 #endif
614 #ifdef CONFIG_MHI_NETDEV
615         &mhi_netdevice0,  /* MHI netdevice */
616 #endif /* CONFIG_MHI_NETDEV */
617 };
618
619 #ifdef CONFIG_USB_SUPPORT
620
621 static void pluto_usb_hsic_postsupend(void)
622 {
623         pr_debug("%s\n", __func__);
624 #ifdef CONFIG_TEGRA_BB_XMM_POWER
625         baseband_xmm_set_power_status(BBXMM_PS_L2);
626 #endif
627 }
628
629 static void pluto_usb_hsic_preresume(void)
630 {
631         pr_debug("%s\n", __func__);
632 #ifdef CONFIG_TEGRA_BB_XMM_POWER
633         baseband_xmm_set_power_status(BBXMM_PS_L2TOL0);
634 #endif
635 }
636
637 static void pluto_usb_hsic_post_resume(void)
638 {
639         pr_debug("%s\n", __func__);
640 #ifdef CONFIG_TEGRA_BB_XMM_POWER
641         baseband_xmm_set_power_status(BBXMM_PS_L0);
642 #endif
643 }
644
645 static void pluto_usb_hsic_phy_power(void)
646 {
647         pr_debug("%s\n", __func__);
648 #ifdef CONFIG_TEGRA_BB_XMM_POWER
649         baseband_xmm_set_power_status(BBXMM_PS_L0);
650 #endif
651 }
652
653 static void pluto_usb_hsic_post_phy_off(void)
654 {
655         pr_debug("%s\n", __func__);
656 #ifdef CONFIG_TEGRA_BB_XMM_POWER
657         baseband_xmm_set_power_status(BBXMM_PS_L2);
658 #endif
659 }
660
661 static struct tegra_usb_phy_platform_ops oem2_plat_ops = {
662         .post_suspend = pluto_usb_hsic_postsupend,
663         .pre_resume = pluto_usb_hsic_preresume,
664         .port_power = pluto_usb_hsic_phy_power,
665         .post_resume = pluto_usb_hsic_post_resume,
666         .post_phy_off = pluto_usb_hsic_post_phy_off,
667 };
668
669 static struct tegra_usb_platform_data tegra_ehci3_hsic_xmm_pdata = {
670         .port_otg = false,
671         .has_hostpc = true,
672         .unaligned_dma_buf_supported = false,
673         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
674         .op_mode        = TEGRA_USB_OPMODE_HOST,
675         .u_data.host = {
676                 .vbus_gpio = -1,
677                 .hot_plug = false,
678                 .remote_wakeup_supported = false,
679                 .power_off_on_suspend = false,
680         },
681         .ops = &oem2_plat_ops,
682 };
683
684 static struct tegra_usb_platform_data tegra_ehci3_hsic_smsc_hub_pdata = {
685         .port_otg = false,
686         .has_hostpc = true,
687         .unaligned_dma_buf_supported = false,
688         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
689         .op_mode        = TEGRA_USB_OPMODE_HOST,
690         .u_data.host = {
691                 .vbus_gpio = -1,
692                 .hot_plug = false,
693                 .remote_wakeup_supported = true,
694                 .power_off_on_suspend = true,
695         },
696 };
697
698 static struct tegra_usb_platform_data tegra_udc_pdata = {
699         .port_otg = true,
700         .has_hostpc = true,
701         .builtin_host_disabled = true,
702         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
703         .op_mode = TEGRA_USB_OPMODE_DEVICE,
704         .u_data.dev = {
705                 .vbus_pmu_irq = 0,
706                 .vbus_gpio = -1,
707                 .charging_supported = false,
708                 .remote_wakeup_supported = false,
709         },
710         .u_cfg.utmi = {
711                 .hssync_start_delay = 0,
712                 .elastic_limit = 16,
713                 .idle_wait_delay = 17,
714                 .term_range_adj = 6,
715                 .xcvr_setup = 8,
716                 .xcvr_lsfslew = 2,
717                 .xcvr_lsrslew = 2,
718                 .xcvr_setup_offset = 0,
719                 .xcvr_use_fuses = 1,
720         },
721 };
722
723 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
724         .port_otg = true,
725         .has_hostpc = true,
726         .builtin_host_disabled = true,
727         .unaligned_dma_buf_supported = false,
728         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
729         .op_mode = TEGRA_USB_OPMODE_HOST,
730         .u_data.host = {
731                 .vbus_gpio = -1,
732                 .hot_plug = false,
733                 .remote_wakeup_supported = true,
734                 .power_off_on_suspend = true,
735         },
736         .u_cfg.utmi = {
737                 .hssync_start_delay = 0,
738                 .elastic_limit = 16,
739                 .idle_wait_delay = 17,
740                 .term_range_adj = 6,
741                 .xcvr_setup = 15,
742                 .xcvr_lsfslew = 2,
743                 .xcvr_lsrslew = 2,
744                 .xcvr_setup_offset = 0,
745                 .xcvr_use_fuses = 1,
746                 .vbus_oc_map = 0x7,
747         },
748 };
749
750 static struct tegra_usb_otg_data tegra_otg_pdata = {
751         .ehci_device = &tegra_ehci1_device,
752         .ehci_pdata = &tegra_ehci1_utmi_pdata,
753 };
754
755 static struct regulator *baseband_reg;
756 static struct gpio modem_gpios[] = { /* i500 modem */
757         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
758 };
759
760 static struct gpio modem2_gpios[] = {
761         {MDM2_PWR_ON, GPIOF_OUT_INIT_LOW, "MODEM2 PWR ON"},
762         {MDM2_RST, GPIOF_DIR_OUT, "MODEM2 RESET"},
763         {MDM2_ACK2, GPIOF_OUT_INIT_HIGH, "MODEM2 ACK2"},
764         {MDM2_ACK1, GPIOF_OUT_INIT_LOW, "MODEM2 ACK1"},
765 };
766
767 static void baseband2_post_phy_on(void);
768 static void baseband2_pre_phy_off(void);
769
770 static struct tegra_usb_phy_platform_ops baseband2_plat_ops = {
771         .pre_phy_off = baseband2_pre_phy_off,
772         .post_phy_on = baseband2_post_phy_on,
773 };
774
775 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
776         .port_otg = false,
777         .has_hostpc = true,
778         .unaligned_dma_buf_supported = false,
779         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
780         .op_mode = TEGRA_USB_OPMODE_HOST,
781         .u_data.host = {
782                 .vbus_gpio = -1,
783                 .hot_plug = false,
784                 .remote_wakeup_supported = true,
785                 .power_off_on_suspend = true,
786         },
787 };
788
789 static struct tegra_usb_platform_data tegra_ehci3_hsic_baseband2_pdata = {
790         .port_otg = false,
791         .has_hostpc = true,
792         .unaligned_dma_buf_supported = false,
793         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
794         .op_mode = TEGRA_USB_OPMODE_HOST,
795         .u_data.host = {
796                 .vbus_gpio = -1,
797                 .hot_plug = false,
798                 .remote_wakeup_supported = true,
799                 .power_off_on_suspend = true,
800         },
801         .ops = &baseband2_plat_ops,
802 };
803
804 static struct tegra_usb_platform_data tegra_hsic_pdata = {
805         .port_otg = false,
806         .has_hostpc = true,
807         .unaligned_dma_buf_supported = false,
808         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
809         .op_mode        = TEGRA_USB_OPMODE_HOST,
810         .u_data.host = {
811                 .vbus_gpio = -1,
812                 .hot_plug = false,
813                 .remote_wakeup_supported = true,
814                 .power_off_on_suspend = true,
815         },
816 };
817
818 static struct platform_device *
819 tegra_usb_hsic_host_register(struct platform_device *ehci_dev)
820 {
821         struct platform_device *pdev;
822         int val;
823
824         pdev = platform_device_alloc(ehci_dev->name, ehci_dev->id);
825         if (!pdev)
826                 return NULL;
827
828         val = platform_device_add_resources(pdev, ehci_dev->resource,
829                                                 ehci_dev->num_resources);
830         if (val)
831                 goto error;
832
833         pdev->dev.dma_mask =  ehci_dev->dev.dma_mask;
834         pdev->dev.coherent_dma_mask = ehci_dev->dev.coherent_dma_mask;
835
836         val = platform_device_add_data(pdev, &tegra_ehci3_hsic_xmm_pdata,
837                         sizeof(struct tegra_usb_platform_data));
838         if (val)
839                 goto error;
840
841         val = platform_device_add(pdev);
842         if (val)
843                 goto error;
844
845         return pdev;
846
847 error:
848         pr_err("%s: failed to add the host contoller device\n", __func__);
849         platform_device_put(pdev);
850         return NULL;
851 }
852
853 static void tegra_usb_hsic_host_unregister(struct platform_device **platdev)
854 {
855         struct platform_device *pdev = *platdev;
856
857         if (pdev && &pdev->dev) {
858                 platform_device_unregister(pdev);
859                 *platdev = NULL;
860         } else
861                 pr_err("%s: no platform device\n", __func__);
862 }
863
864 static struct tegra_usb_phy_platform_ops oem1_hsic_pops;
865
866 static union tegra_bb_gpio_id bb_gpio_oem1 = {
867         .oem1 = {
868                 .reset = BB_OEM1_GPIO_RST,
869                 .pwron = BB_OEM1_GPIO_ON,
870                 .awr = BB_OEM1_GPIO_AWR,
871                 .cwr = BB_OEM1_GPIO_CWR,
872                 .spare = BB_OEM1_GPIO_SPARE,
873                 .wdi = BB_OEM1_GPIO_WDI,
874         },
875 };
876
877 static struct tegra_bb_pdata bb_pdata_oem1 = {
878         .id = &bb_gpio_oem1,
879         .device = &tegra_ehci3_device,
880         .ehci_register = tegra_usb_hsic_host_register,
881         .ehci_unregister = tegra_usb_hsic_host_unregister,
882         .bb_id = TEGRA_BB_OEM1,
883 };
884
885 static struct platform_device tegra_bb_oem1 = {
886         .name = "tegra_baseband_power",
887         .id = -1,
888         .dev = {
889                 .platform_data = &bb_pdata_oem1,
890         },
891 };
892
893 static int baseband_init(void)
894 {
895         int ret;
896
897         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
898         if (ret) {
899                 pr_warn("%s:gpio request failed\n", __func__);
900                 return ret;
901         }
902
903         baseband_reg = regulator_get(NULL, "vdd_core_bb");
904         if (IS_ERR_OR_NULL(baseband_reg))
905                 pr_warn("%s: baseband regulator get failed\n", __func__);
906         else
907                 regulator_enable(baseband_reg);
908
909         /* enable pull-down for MDM1_COLD_BOOT */
910         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
911                                     TEGRA_PUPD_PULL_DOWN);
912
913         /* export GPIO for user space access through sysfs */
914         gpio_export(MDM_RST, false);
915
916         return 0;
917 }
918
919 static const struct tegra_modem_operations baseband_operations = {
920         .init = baseband_init,
921 };
922
923 #define MODEM_BOOT_EDP_MAX 0
924 /* FIXME: get accurate boot current value */
925 static unsigned int modem_boot_edp_states[] = { 1900 };
926 static struct edp_client modem_boot_edp_client = {
927         .name = "modem_boot",
928         .states = modem_boot_edp_states,
929         .num_states = ARRAY_SIZE(modem_boot_edp_states),
930         .e0_index = MODEM_BOOT_EDP_MAX,
931         .priority = EDP_MAX_PRIO,
932 };
933
934 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
935         .ops = &baseband_operations,
936         .wake_gpio = -1,
937         .boot_gpio = MDM_COLDBOOT,
938         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
939         .autosuspend_delay = 2000,
940         .short_autosuspend_delay = 50,
941         .tegra_ehci_device = &tegra_ehci2_device,
942         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
943         .modem_boot_edp_client = &modem_boot_edp_client,
944         .edp_manager_name = "battery",
945         .i_breach_ppm = 500000,
946         /* FIXME: get useful adjperiods */
947         .i_thresh_3g_adjperiod = 10000,
948         .i_thresh_lte_adjperiod = 10000,
949 };
950
951 static struct platform_device icera_baseband_device = {
952         .name = "tegra_usb_modem_power",
953         .id = -1,
954         .dev = {
955                 .platform_data = &baseband_pdata,
956         },
957 };
958
959 static void baseband2_post_phy_on(void)
960 {
961         /* set MDM2_ACK2 low */
962         gpio_set_value(MDM2_ACK2, 0);
963 }
964
965 static void baseband2_pre_phy_off(void)
966 {
967         /* set MDM2_ACK2 high */
968         gpio_set_value(MDM2_ACK2, 1);
969 }
970
971 static void baseband2_start(void)
972 {
973         /*
974          *  Leave baseband powered OFF.
975          *  User-space daemons will take care of powering it up.
976          */
977         pr_info("%s\n", __func__);
978         gpio_set_value(MDM2_PWR_ON, 0);
979 }
980
981 static void baseband2_reset(void)
982 {
983         /* Initiate power cycle on baseband sub system */
984         pr_info("%s\n", __func__);
985         gpio_set_value(MDM2_PWR_ON, 0);
986         mdelay(200);
987         gpio_set_value(MDM2_PWR_ON, 1);
988 }
989
990 static int baseband2_init(void)
991 {
992         int ret;
993
994         ret = gpio_request_array(modem2_gpios, ARRAY_SIZE(modem2_gpios));
995         if (ret)
996                 return ret;
997
998         /* enable pull-up for MDM2_REQ2 */
999         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PV1,
1000                                     TEGRA_PUPD_PULL_UP);
1001
1002         /* export GPIO for user space access through sysfs */
1003         gpio_export(MDM2_PWR_ON, false);
1004
1005         return 0;
1006 }
1007
1008 static const struct tegra_modem_operations baseband2_operations = {
1009         .init = baseband2_init,
1010         .start = baseband2_start,
1011         .reset = baseband2_reset,
1012 };
1013
1014 static struct tegra_usb_modem_power_platform_data baseband2_pdata = {
1015         .ops = &baseband2_operations,
1016         .wake_gpio = MDM2_REQ2,
1017         .wake_irq_flags = IRQF_TRIGGER_FALLING,
1018         .boot_gpio = MDM2_COLDBOOT,
1019         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
1020         .autosuspend_delay = 2000,
1021         .short_autosuspend_delay = 50,
1022         .tegra_ehci_device = &tegra_ehci3_device,
1023         .tegra_ehci_pdata = &tegra_ehci3_hsic_baseband2_pdata,
1024 };
1025
1026 static struct platform_device icera_baseband2_device = {
1027         .name = "tegra_usb_modem_power",
1028         .id = -1,
1029         .dev = {
1030                 .platform_data = &baseband2_pdata,
1031         },
1032 };
1033
1034 static struct baseband_power_platform_data tegra_baseband_xmm_power_data = {
1035         .baseband_type = BASEBAND_XMM,
1036         .modem = {
1037                 .xmm = {
1038                         .bb_rst = XMM_GPIO_BB_RST,
1039                         .bb_on = XMM_GPIO_BB_ON,
1040                         .ipc_bb_wake = XMM_GPIO_IPC_BB_WAKE,
1041                         .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
1042                         .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
1043                         .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
1044                 },
1045         },
1046 };
1047
1048 static struct platform_device tegra_baseband_xmm_power_device = {
1049         .name = "baseband_xmm_power",
1050         .id = -1,
1051         .dev = {
1052                 .platform_data = &tegra_baseband_xmm_power_data,
1053         },
1054 };
1055
1056 static struct platform_device tegra_baseband_xmm_power2_device = {
1057         .name = "baseband_xmm_power2",
1058         .id = -1,
1059         .dev = {
1060                 .platform_data = &tegra_baseband_xmm_power_data,
1061         },
1062 };
1063
1064 static void pluto_usb_init(void)
1065 {
1066         int usb_port_owner_info = tegra_get_usb_port_owner_info();
1067
1068         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
1069                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
1070                 platform_device_register(&tegra_otg_device);
1071
1072                 /* Setup the udc platform data */
1073                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
1074         }
1075 }
1076
1077 static void pluto_modem_init(void)
1078 {
1079         int modem_id = tegra_get_modem_id();
1080         struct board_info board_info;
1081         int usb_port_owner_info = tegra_get_usb_port_owner_info();
1082
1083         tegra_get_board_info(&board_info);
1084         pr_info("%s: modem_id = %d\n", __func__, modem_id);
1085
1086         switch (modem_id) {
1087         case TEGRA_BB_I500: /* on board i500 HSIC */
1088                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
1089                         platform_device_register(&icera_baseband_device);
1090                 break;
1091         case TEGRA_BB_I500SWD: /* i500 SWD HSIC */
1092                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB))
1093                         platform_device_register(&icera_baseband2_device);
1094                 break;
1095         case TEGRA_BB_OEM1:     /* OEM1 HSIC */
1096                 if ((board_info.board_id == BOARD_E1575) ||
1097                         ((board_info.board_id == BOARD_E1580) &&
1098                                 (board_info.fab >= BOARD_FAB_A03))) {
1099                         tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPIO_X1_AUD,
1100                                                         TEGRA_TRI_NORMAL);
1101                         bb_gpio_oem1.oem1.pwron = BB_OEM1_GPIO_ON_V;
1102                 }
1103                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB)) {
1104                         tegra_hsic_pdata.ops = &oem1_hsic_pops;
1105                         tegra_ehci3_device.dev.platform_data
1106                                 = &tegra_hsic_pdata;
1107                         platform_device_register(&tegra_bb_oem1);
1108                 }
1109                 break;
1110         case TEGRA_BB_OEM2: /* XMM6260/XMM6360 HSIC */
1111                 /* fix wrong wiring in Pluto A02 */
1112                 if ((board_info.board_id == BOARD_E1580) &&
1113                         (board_info.fab == BOARD_FAB_A02)) {
1114                         pr_info(
1115 "%s: Pluto A02: replace MDM2_PWR_ON with MDM2_PWR_ON_FOR_PLUTO_A02\n",
1116                                 __func__);
1117                         if (tegra_baseband_xmm_power_data.modem.xmm.bb_on
1118                                 != MDM2_PWR_ON)
1119                                 pr_err(
1120 "%s: expected MDM2_PWR_ON default gpio for XMM bb_on\n",
1121                                         __func__);
1122                         tegra_baseband_xmm_power_data.modem.xmm.bb_on
1123                                 = MDM2_PWR_ON_FOR_PLUTO_A02;
1124                 }
1125                 /* baseband-power.ko will register ehci3 device */
1126                 tegra_ehci3_device.dev.platform_data =
1127                                         &tegra_ehci3_hsic_xmm_pdata;
1128                 tegra_baseband_xmm_power_data.hsic_register =
1129                                                 &tegra_usb_hsic_host_register;
1130                 tegra_baseband_xmm_power_data.hsic_unregister =
1131                                                 &tegra_usb_hsic_host_unregister;
1132                 tegra_baseband_xmm_power_data.ehci_device =
1133                                         &tegra_ehci3_device;
1134                 platform_device_register(&tegra_baseband_xmm_power_device);
1135                 platform_device_register(&tegra_baseband_xmm_power2_device);
1136                 /* override audio settings - use 8kHz */
1137                 pluto_audio_pdata.i2s_param[BASEBAND].audio_port_id
1138                         = pluto_aic3262_pdata.i2s_param[BASEBAND].audio_port_id
1139                         = 2;
1140                 pluto_audio_pdata.i2s_param[BASEBAND].is_i2s_master
1141                         = pluto_aic3262_pdata.i2s_param[BASEBAND].is_i2s_master
1142                         = 1;
1143                 pluto_audio_pdata.i2s_param[BASEBAND].i2s_mode
1144                         = pluto_aic3262_pdata.i2s_param[BASEBAND].i2s_mode
1145                         = TEGRA_DAIFMT_I2S;
1146                 pluto_audio_pdata.i2s_param[BASEBAND].sample_size
1147                         = pluto_aic3262_pdata.i2s_param[BASEBAND].sample_size
1148                         = 16;
1149                 pluto_audio_pdata.i2s_param[BASEBAND].rate
1150                         = pluto_aic3262_pdata.i2s_param[BASEBAND].rate
1151                         = 8000;
1152                 pluto_audio_pdata.i2s_param[BASEBAND].channels
1153                         = pluto_aic3262_pdata.i2s_param[BASEBAND].channels
1154                         = 2;
1155                 break;
1156         case TEGRA_BB_HSIC_HUB: /* i500 SWD HSIC */
1157                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB)) {
1158                         tegra_ehci3_device.dev.platform_data =
1159                                 &tegra_ehci3_hsic_smsc_hub_pdata;
1160                         platform_device_register(&tegra_ehci3_device);
1161                 }
1162                 break;
1163         default:
1164                 return;
1165         }
1166 }
1167
1168 static struct tegra_xusb_pad_data xusb_padctl_data = {
1169         .pad_mux = 0x1,
1170         .port_cap = 0x1,
1171         .snps_oc_map = 0x1ff,
1172         .usb2_oc_map = 0x3c,
1173         .ss_port_map = 0x2,
1174         .oc_det = 0,
1175         .rx_wander = 0xf0,
1176         .otg_pad0_ctl0 = 0xffc7ffff,
1177         .otg_pad0_ctl1 = 0x7,
1178         .otg_pad1_ctl0 = 0xffffffff,
1179         .otg_pad1_ctl1 = 0,
1180         .bias_pad_ctl0 = 0,
1181         .hsic_pad0_ctl0 = 0xffff00ff,
1182         .hsic_pad0_ctl1 = 0xffff00ff,
1183         .pmc_value = 0xfffffff0,
1184 };
1185
1186 static void pluto_xusb_init(void)
1187 {
1188         int usb_port_owner_info = tegra_get_usb_port_owner_info();
1189
1190         if (usb_port_owner_info & UTMI1_PORT_OWNER_XUSB) {
1191                 u32 usb_calib0 = tegra_fuse_readl(FUSE_SKU_USB_CALIB_0);
1192
1193                 /*
1194                  * read from usb_calib0 and pass to driver
1195                  * set HS_CURR_LEVEL = usb_calib0[5:0]
1196                  * set TERM_RANGE_ADJ = usb_calib0[10:7]
1197                  * set HS_IREF_CAP = usb_calib0[14:13]
1198                  * set HS_SQUELCH_LEVEL = usb_calib0[12:11]
1199                  */
1200
1201                 xusb_padctl_data.hs_curr_level = (usb_calib0 >> 0) & 0x3f;
1202                 xusb_padctl_data.hs_iref_cap = (usb_calib0 >> 13) & 0x3;
1203                 xusb_padctl_data.hs_term_range_adj = (usb_calib0 >> 7) & 0xf;
1204                 xusb_padctl_data.hs_squelch_level = (usb_calib0 >> 11) & 0x3;
1205
1206                 tegra_xhci_device.dev.platform_data = &xusb_padctl_data;
1207                 platform_device_register(&tegra_xhci_device);
1208         }
1209 }
1210 #else
1211 static void pluto_usb_init(void) { }
1212 static void pluto_modem_init(void) { }
1213 static void pluto_xusb_init(void) { }
1214 #endif
1215
1216 static void pluto_audio_init(void)
1217 {
1218         struct board_info board_info;
1219
1220         tegra_get_board_info(&board_info);
1221
1222         spi_register_board_info(aic326x_spi_board_info,
1223                                         ARRAY_SIZE(aic326x_spi_board_info));
1224 }
1225
1226 #ifndef CONFIG_USE_OF
1227 static struct platform_device *pluto_spi_devices[] __initdata = {
1228         &tegra11_spi_device4,
1229 };
1230
1231 static struct tegra_spi_platform_data pluto_spi_pdata = {
1232         .dma_req_sel            = 0,
1233         .spi_max_frequency      = 25000000,
1234         .clock_always_on        = false,
1235 };
1236
1237 static void __init pluto_spi_init(void)
1238 {
1239         struct board_info board_info, display_board_info;
1240
1241         tegra_get_board_info(&board_info);
1242         tegra_get_display_board_info(&display_board_info);
1243
1244         tegra11_spi_device4.dev.platform_data = &pluto_spi_pdata;
1245         platform_add_devices(pluto_spi_devices,
1246                                 ARRAY_SIZE(pluto_spi_devices));
1247 }
1248 #else
1249 static void __init pluto_spi_init(void)
1250 {
1251 }
1252 #endif
1253
1254 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
1255         /* name         parent          rate            enabled */
1256         { "extern2",    "pll_p",        41000000,       false},
1257         { "clk_out_2",  "extern2",      40800000,       false},
1258         { NULL,         NULL,           0,              0},
1259 };
1260
1261 struct rm_spi_ts_platform_data rm31080ts_pluto_data = {
1262         .gpio_reset = 0,
1263         .config = 0,
1264         .platform_id = RM_PLATFORM_P005,
1265         .name_of_clock = "clk_out_2",
1266 };
1267
1268 static struct tegra_spi_device_controller_data dev_cdata = {
1269         .rx_clk_tap_delay = 0,
1270         .tx_clk_tap_delay = 0,
1271 };
1272
1273 struct spi_board_info rm31080a_pluto_spi_board[1] = {
1274         {
1275          .modalias = "rm_ts_spidev",
1276          .bus_num = 3,
1277          .chip_select = 2,
1278          .max_speed_hz = 12 * 1000 * 1000,
1279          .mode = SPI_MODE_0,
1280          .controller_data = &dev_cdata,
1281          .platform_data = &rm31080ts_pluto_data,
1282          },
1283 };
1284
1285 static int __init pluto_touch_init(void)
1286 {
1287         tegra_clk_init_from_table(touch_clk_init_table);
1288         clk_enable(tegra_get_clock_by_name("clk_out_2"));
1289         mdelay(20);
1290         rm31080a_pluto_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
1291         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
1292                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
1293                                 &rm31080ts_pluto_data,
1294                                 &rm31080a_pluto_spi_board[0],
1295                                 ARRAY_SIZE(rm31080a_pluto_spi_board));
1296         return 0;
1297 }
1298
1299 #ifdef CONFIG_EDP_FRAMEWORK
1300 static struct edp_manager battery_edp_manager = {
1301         .name = "battery",
1302         .max = 12350
1303 };
1304
1305 static void __init pluto_battery_edp_init(void)
1306 {
1307         struct edp_governor *g;
1308         int r;
1309
1310         r = edp_register_manager(&battery_edp_manager);
1311         if (r)
1312                 goto err_ret;
1313
1314         /* start with priority governor */
1315         g = edp_get_governor("priority");
1316         if (!g) {
1317                 r = -EFAULT;
1318                 goto err_ret;
1319         }
1320
1321         r = edp_set_governor(&battery_edp_manager, g);
1322         if (r)
1323                 goto err_ret;
1324
1325         return;
1326
1327 err_ret:
1328         pr_err("Battery EDP init failed with error %d\n", r);
1329         WARN_ON(1);
1330 }
1331 #else
1332 static inline void pluto_battery_edp_init(void) {}
1333 #endif
1334
1335 #ifdef CONFIG_USE_OF
1336 struct of_dev_auxdata pluto_auxdata_lookup[] __initdata = {
1337         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-dma", NULL),
1338         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
1339                                 NULL),
1340         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
1341                                 NULL),
1342         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
1343                                 &pluto_tegra_sdhci_platform_data0),
1344         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
1345                                 NULL),
1346         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
1347                                 NULL),
1348         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
1349                                 NULL),
1350         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
1351                                 NULL),
1352         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
1353                                 NULL),
1354         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
1355                                 NULL),
1356         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
1357                                 NULL),
1358         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
1359                                 NULL),
1360         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d400, "spi-tegra114.0",
1361                                 NULL),
1362         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d600, "spi-tegra114.1",
1363                                 NULL),
1364         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d800, "spi-tegra114.2",
1365                                 NULL),
1366         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000da00, "spi-tegra114.3",
1367                                 NULL),
1368         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000dc00, "spi-tegra114.4",
1369                                 NULL),
1370         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000de00, "spi-tegra114.5",
1371                                 NULL),
1372         {}
1373 };
1374 #endif
1375
1376 static void __init tegra_pluto_early_init(void)
1377 {
1378         pluto_battery_edp_init();
1379         tegra_clk_init_from_table(pluto_clk_init_table);
1380         tegra_clk_vefify_parents();
1381         tegra_smmu_init();
1382         tegra_soc_device_init("tegra_pluto");
1383 }
1384
1385 static void __init tegra_pluto_late_init(void)
1386 {
1387         platform_device_register(&tegra_pinmux_device);
1388         pluto_pinmux_init();
1389         pluto_i2c_init();
1390         pluto_spi_init();
1391         pluto_usb_init();
1392         pluto_xusb_init();
1393         pluto_uart_init();
1394         pluto_audio_init();
1395         platform_add_devices(pluto_devices, ARRAY_SIZE(pluto_devices));
1396         //tegra_ram_console_debug_init();
1397         tegra_io_dpd_init();
1398         pluto_sdhci_init();
1399         pluto_regulator_init();
1400         pluto_suspend_init();
1401         pluto_touch_init();
1402         pluto_emc_init();
1403         pluto_edp_init();
1404         isomgr_init();
1405         pluto_panel_init();
1406         pluto_pmon_init();
1407         pluto_kbc_init();
1408 #ifdef CONFIG_BT_BLUESLEEP
1409         pluto_setup_bluesleep();
1410         pluto_setup_bt_rfkill();
1411 #elif defined CONFIG_BLUEDROID_PM
1412         pluto_setup_bluedroid_pm();
1413 #endif
1414         tegra_release_bootloader_fb();
1415         pluto_modem_init();
1416 #ifdef CONFIG_TEGRA_WDT_RECOVERY
1417         tegra_wdt_recovery_init();
1418 #endif
1419         pluto_sensors_init();
1420         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
1421         pluto_soctherm_init();
1422         tegra_register_fuse();
1423 }
1424
1425 static void __init pluto_ramconsole_reserve(unsigned long size)
1426 {
1427         tegra_ram_console_debug_reserve(SZ_1M);
1428 }
1429
1430 static void __init tegra_pluto_dt_init(void)
1431 {
1432         tegra_pluto_early_init();
1433
1434         of_platform_populate(NULL,
1435                 of_default_bus_match_table, pluto_auxdata_lookup,
1436                 &platform_bus);
1437
1438         tegra_pluto_late_init();
1439 }
1440
1441 static void __init tegra_pluto_reserve(void)
1442 {
1443 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
1444         /* for PANEL_5_SHARP_1080p: 1920*1080*4*2 = 16588800 bytes */
1445         tegra_reserve(0, SZ_16M, SZ_4M);
1446 #else
1447         tegra_reserve(SZ_128M, SZ_16M, SZ_4M);
1448 #endif
1449         pluto_ramconsole_reserve(SZ_1M);
1450 }
1451
1452 static const char * const pluto_dt_board_compat[] = {
1453         "nvidia,pluto",
1454         NULL
1455 };
1456
1457 MACHINE_START(TEGRA_PLUTO, "tegra_pluto")
1458         .atag_offset    = 0x100,
1459         .smp            = smp_ops(tegra_smp_ops),
1460         .map_io         = tegra_map_common_io,
1461         .reserve        = tegra_pluto_reserve,
1462         .init_early     = tegra11x_init_early,
1463         .init_irq       = tegra_dt_init_irq,
1464         .handle_irq     = gic_handle_irq,
1465         .timer          = &tegra_sys_timer,
1466         .init_machine   = tegra_pluto_dt_init,
1467         .restart        = tegra_assert_system_reset,
1468         .dt_compat      = pluto_dt_board_compat,
1469 MACHINE_END