misc: tegra-baseband: move modem power driver to /driver/misc/tegra-baseband
[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_wakeup_monitor.h>
74 #include <linux/platform_data/tegra_usb_modem_power.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         .needs_cl_dvfs_clock = true,
276 };
277
278 static struct aic3262_gpio_setup aic3262_gpio[] = {
279         /* GPIO 1*/
280         {
281                 .used = 1,
282                 .in = 0,
283                 .value = AIC3262_GPIO1_FUNC_INT1_OUTPUT ,
284         },
285         /* GPIO 2*/
286         {
287                 .used = 1,
288                 .in = 0,
289                 .value = AIC3262_GPIO2_FUNC_ADC_MOD_CLK_OUTPUT,
290         },
291         /* GPI1 */
292         {
293                 .used = 1,
294                 .in = 1,
295         },
296         /* GPI2 */
297         {
298                 .used = 1,
299                 .in = 1,
300                 .in_reg = AIC3262_DMIC_INPUT_CNTL,
301                 .in_reg_bitmask = AIC3262_DMIC_CONFIGURE_MASK,
302                 .in_reg_shift = AIC3262_DMIC_CONFIGURE_SHIFT,
303                 .value = AIC3262_DMIC_GPI2_LEFT_GPI2_RIGHT,
304         },
305         /* GPO1 */
306         {
307                 .used = 1,
308                 .in = 0,
309                 .value = AIC3262_GPO1_FUNC_MSO_OUTPUT_FOR_SPI,
310         },
311 };
312 static struct aic3xxx_pdata aic3262_codec_pdata = {
313         .gpio_irq       = 0,
314         .gpio           = aic3262_gpio,
315         .naudint_irq    = 0,
316         .irq_base       = AIC3262_CODEC_IRQ_BASE,
317 };
318
319 static struct i2c_board_info __initdata cs42l73_board_info = {
320         I2C_BOARD_INFO("cs42l73", 0x4a),
321 };
322
323 static struct i2c_board_info __initdata pluto_codec_a2220_info = {
324         I2C_BOARD_INFO("audience_a2220", 0x3E),
325 };
326
327 static struct i2c_board_info __initdata pluto_codec_aic326x_info = {
328         I2C_BOARD_INFO("tlv320aic3262", 0x18),
329         .platform_data = &aic3262_codec_pdata,
330 };
331
332 static void pluto_i2c_init(void)
333 {
334         tegra11_i2c_device1.dev.platform_data = &pluto_i2c1_platform_data;
335         tegra11_i2c_device2.dev.platform_data = &pluto_i2c2_platform_data;
336         tegra11_i2c_device3.dev.platform_data = &pluto_i2c3_platform_data;
337         tegra11_i2c_device4.dev.platform_data = &pluto_i2c4_platform_data;
338         tegra11_i2c_device5.dev.platform_data = &pluto_i2c5_platform_data;
339
340         platform_device_register(&tegra11_i2c_device5);
341         platform_device_register(&tegra11_i2c_device4);
342         platform_device_register(&tegra11_i2c_device3);
343         platform_device_register(&tegra11_i2c_device2);
344         platform_device_register(&tegra11_i2c_device1);
345
346         i2c_register_board_info(0, &pluto_codec_a2220_info, 1);
347         i2c_register_board_info(0, &cs42l73_board_info, 1);
348         i2c_register_board_info(0, &pluto_codec_aic326x_info, 1);
349         pluto_i2c_bus3_board_info[0].irq = gpio_to_irq(TEGRA_GPIO_PW2);
350         i2c_register_board_info(0, pluto_i2c_bus3_board_info, 1);
351         i2c_register_board_info(0, &pluto_codec_aic326x_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         .edp_states             = {1776, 888, 0},
458         .i2s_param[HIFI_CODEC]  = {
459                 .audio_port_id  = 1,
460                 .is_i2s_master  = 0,
461                 .i2s_mode       = TEGRA_DAIFMT_I2S,
462                 .sample_size    = 16,
463                 .channels       = 2,
464         },
465         .i2s_param[BASEBAND]    = {
466                 .audio_port_id  = 2,
467                 .is_i2s_master  = 1,
468                 .i2s_mode       = TEGRA_DAIFMT_I2S,
469                 .sample_size    = 16,
470                 .rate           = 16000,
471                 .channels       = 2,
472                 .bit_clk        = 1024000,
473         },
474         .i2s_param[BT_SCO]      = {
475                 .audio_port_id  = 3,
476                 .is_i2s_master  = 1,
477                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
478                 .sample_size    = 16,
479                 .channels       = 1,
480                 .bit_clk        = 512000,
481         },
482         .i2s_param[VOICE_CODEC] = {
483                 .audio_port_id  = 0,
484                 .is_i2s_master  = 1,
485                 .i2s_mode       = TEGRA_DAIFMT_I2S,
486                 .sample_size    = 16,
487                 .rate           = 16000,
488                 .channels       = 2,
489         },
490 };
491
492 static struct tegra_asoc_platform_data pluto_aic3262_pdata = {
493         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
494         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
495         .gpio_hp_mute           = -1,
496         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
497         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
498         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
499         .edp_states             = {1776, 888, 0},
500         .i2s_param[HIFI_CODEC]  = {
501                 .audio_port_id  = 1,
502                 .is_i2s_master  = 1,
503                 .i2s_mode       = TEGRA_DAIFMT_I2S,
504                 .sample_size    = 16,
505                 .rate           = 48000,
506                 .channels       = 2,
507         },
508         .i2s_param[BASEBAND]    = {
509                 .audio_port_id  = 2,
510                 .is_i2s_master  = 1,
511                 .i2s_mode       = TEGRA_DAIFMT_I2S,
512                 .sample_size    = 16,
513                 .rate           = 16000,
514                 .channels       = 2,
515                 .bit_clk        = 1024000,
516         },
517         .i2s_param[BT_SCO]      = {
518                 .audio_port_id  = 3,
519                 .is_i2s_master  = 1,
520                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
521                 .sample_size    = 16,
522                 .channels       = 1,
523                 .bit_clk        = 512000,
524         },
525         .i2s_param[VOICE_CODEC] = {
526                 .audio_port_id  = 0,
527                 .is_i2s_master  = 1,
528                 .i2s_mode       = TEGRA_DAIFMT_I2S,
529                 .sample_size    = 16,
530                 .rate           = 16000,
531                 .channels       = 2,
532         },
533 };
534
535 static struct platform_device pluto_audio_device = {
536         .name   = "tegra-snd-cs42l73",
537         .id     = 2,
538         .dev    = {
539                 .platform_data = &pluto_audio_pdata,
540         },
541 };
542
543 static struct platform_device pluto_audio_aic326x_device = {
544         .name   = "tegra-snd-aic326x",
545         .id     = 2,
546         .dev    = {
547                 .platform_data  = &pluto_aic3262_pdata,
548         },
549 };
550
551 static struct tegra_spi_device_controller_data dev_bdata = {
552         .rx_clk_tap_delay = 0,
553         .tx_clk_tap_delay = 0,
554 };
555 static struct spi_board_info aic326x_spi_board_info[] = {
556         {
557                 .modalias = "tlv320aic3xxx",
558                 .bus_num = 3,
559                 .chip_select = 0,
560                 .max_speed_hz = 4*1000*1000,
561                 .mode = SPI_MODE_1,
562                 .controller_data = &dev_bdata,
563                 .platform_data = &aic3262_codec_pdata,
564         },
565 };
566
567 #ifdef CONFIG_MHI_NETDEV
568 struct platform_device mhi_netdevice0 = {
569         .name = "mhi_net_device",
570         .id = 0,
571 };
572 #endif /* CONFIG_MHI_NETDEV */
573
574 static struct platform_device *pluto_devices[] __initdata = {
575         &tegra_pmu_device,
576         &tegra_rtc_device,
577         &tegra_udc_device,
578 #if defined(CONFIG_TEGRA_WATCHDOG)
579         /* three CPU watchdog timers, user space */
580         &tegra_wdt0_device,
581         &tegra_wdt1_device,
582         &tegra_wdt2_device,
583         /* 4th used for the suspend/resume only */
584 #endif
585 #if defined(CONFIG_TEGRA_AVP)
586         &tegra_avp_device,
587 #endif
588 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
589         &tegra11_se_device,
590 #endif
591         &tegra_ahub_device,
592         &tegra_dam_device0,
593         &tegra_dam_device1,
594         &tegra_dam_device2,
595         &tegra_i2s_device0,
596         &tegra_i2s_device1,
597         &tegra_i2s_device2,
598         &tegra_i2s_device3,
599         &tegra_i2s_device4,
600         &tegra_spdif_device,
601         &spdif_dit_device,
602         &bluetooth_dit_device,
603         &baseband_dit_device,
604 #if defined(CONFIG_TEGRA_WAKEUP_MONITOR)
605         &pluto_tegra_wakeup_monitor_device,
606 #endif
607         &pluto_audio_device,
608         &pluto_audio_aic326x_device,
609         &tegra_hda_device,
610 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
611         &tegra_aes_device,
612 #endif
613 #ifdef CONFIG_MHI_NETDEV
614         &mhi_netdevice0,  /* MHI netdevice */
615 #endif /* CONFIG_MHI_NETDEV */
616 };
617
618 #ifdef CONFIG_USB_SUPPORT
619
620 static void pluto_usb_hsic_postsupend(void)
621 {
622         pr_debug("%s\n", __func__);
623 #ifdef CONFIG_TEGRA_BB_XMM_POWER
624         baseband_xmm_set_power_status(BBXMM_PS_L2);
625 #endif
626 }
627
628 static void pluto_usb_hsic_preresume(void)
629 {
630         pr_debug("%s\n", __func__);
631 #ifdef CONFIG_TEGRA_BB_XMM_POWER
632         baseband_xmm_set_power_status(BBXMM_PS_L2TOL0);
633 #endif
634 }
635
636 static void pluto_usb_hsic_post_resume(void)
637 {
638         pr_debug("%s\n", __func__);
639 #ifdef CONFIG_TEGRA_BB_XMM_POWER
640         baseband_xmm_set_power_status(BBXMM_PS_L0);
641 #endif
642 }
643
644 static void pluto_usb_hsic_phy_power(void)
645 {
646         pr_debug("%s\n", __func__);
647 #ifdef CONFIG_TEGRA_BB_XMM_POWER
648         baseband_xmm_set_power_status(BBXMM_PS_L0);
649 #endif
650 }
651
652 static void pluto_usb_hsic_post_phy_off(void)
653 {
654         pr_debug("%s\n", __func__);
655 #ifdef CONFIG_TEGRA_BB_XMM_POWER
656         baseband_xmm_set_power_status(BBXMM_PS_L2);
657 #endif
658 }
659
660 static struct tegra_usb_phy_platform_ops oem2_plat_ops = {
661         .post_suspend = pluto_usb_hsic_postsupend,
662         .pre_resume = pluto_usb_hsic_preresume,
663         .port_power = pluto_usb_hsic_phy_power,
664         .post_resume = pluto_usb_hsic_post_resume,
665         .post_phy_off = pluto_usb_hsic_post_phy_off,
666 };
667
668 static struct tegra_usb_platform_data tegra_ehci3_hsic_smsc_hub_pdata = {
669         .port_otg = false,
670         .has_hostpc = true,
671         .unaligned_dma_buf_supported = false,
672         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
673         .op_mode        = TEGRA_USB_OPMODE_HOST,
674         .u_data.host = {
675                 .vbus_gpio = -1,
676                 .hot_plug = false,
677                 .remote_wakeup_supported = true,
678                 .power_off_on_suspend = true,
679         },
680 };
681
682 static struct tegra_usb_platform_data tegra_udc_pdata = {
683         .port_otg = true,
684         .has_hostpc = true,
685         .builtin_host_disabled = true,
686         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
687         .op_mode = TEGRA_USB_OPMODE_DEVICE,
688         .u_data.dev = {
689                 .vbus_pmu_irq = 0,
690                 .vbus_gpio = -1,
691                 .charging_supported = false,
692                 .remote_wakeup_supported = false,
693         },
694         .u_cfg.utmi = {
695                 .hssync_start_delay = 0,
696                 .elastic_limit = 16,
697                 .idle_wait_delay = 17,
698                 .term_range_adj = 6,
699                 .xcvr_setup = 8,
700                 .xcvr_lsfslew = 2,
701                 .xcvr_lsrslew = 2,
702                 .xcvr_setup_offset = 0,
703                 .xcvr_use_fuses = 1,
704         },
705 };
706
707 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
708         .port_otg = true,
709         .has_hostpc = true,
710         .builtin_host_disabled = true,
711         .unaligned_dma_buf_supported = false,
712         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
713         .op_mode = TEGRA_USB_OPMODE_HOST,
714         .u_data.host = {
715                 .vbus_gpio = -1,
716                 .hot_plug = false,
717                 .remote_wakeup_supported = true,
718                 .power_off_on_suspend = true,
719         },
720         .u_cfg.utmi = {
721                 .hssync_start_delay = 0,
722                 .elastic_limit = 16,
723                 .idle_wait_delay = 17,
724                 .term_range_adj = 6,
725                 .xcvr_setup = 15,
726                 .xcvr_lsfslew = 2,
727                 .xcvr_lsrslew = 2,
728                 .xcvr_setup_offset = 0,
729                 .xcvr_use_fuses = 1,
730                 .vbus_oc_map = 0x7,
731         },
732 };
733
734 static struct tegra_usb_otg_data tegra_otg_pdata = {
735         .ehci_device = &tegra_ehci1_device,
736         .ehci_pdata = &tegra_ehci1_utmi_pdata,
737 };
738
739 static struct regulator *baseband_reg;
740 static struct gpio modem_gpios[] = { /* i500 modem */
741         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
742 };
743
744 static struct gpio modem2_gpios[] = {
745         {MDM2_PWR_ON, GPIOF_OUT_INIT_LOW, "MODEM2 PWR ON"},
746         {MDM2_RST, GPIOF_DIR_OUT, "MODEM2 RESET"},
747         {MDM2_ACK2, GPIOF_OUT_INIT_HIGH, "MODEM2 ACK2"},
748         {MDM2_ACK1, GPIOF_OUT_INIT_LOW, "MODEM2 ACK1"},
749 };
750
751 static void baseband2_post_phy_on(void);
752 static void baseband2_pre_phy_off(void);
753
754 static struct tegra_usb_phy_platform_ops baseband2_plat_ops = {
755         .pre_phy_off = baseband2_pre_phy_off,
756         .post_phy_on = baseband2_post_phy_on,
757 };
758
759 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
760         .port_otg = false,
761         .has_hostpc = true,
762         .unaligned_dma_buf_supported = false,
763         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
764         .op_mode = TEGRA_USB_OPMODE_HOST,
765         .u_data.host = {
766                 .vbus_gpio = -1,
767                 .hot_plug = false,
768                 .remote_wakeup_supported = true,
769                 .power_off_on_suspend = true,
770         },
771 };
772
773 static struct tegra_usb_platform_data tegra_ehci3_hsic_baseband2_pdata = {
774         .port_otg = false,
775         .has_hostpc = true,
776         .unaligned_dma_buf_supported = false,
777         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
778         .op_mode = TEGRA_USB_OPMODE_HOST,
779         .u_data.host = {
780                 .vbus_gpio = -1,
781                 .hot_plug = false,
782                 .remote_wakeup_supported = true,
783                 .power_off_on_suspend = true,
784         },
785         .ops = &baseband2_plat_ops,
786 };
787
788 static struct tegra_usb_platform_data tegra_hsic_pdata = {
789         .port_otg = false,
790         .has_hostpc = true,
791         .unaligned_dma_buf_supported = false,
792         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
793         .op_mode        = TEGRA_USB_OPMODE_HOST,
794         .u_data.host = {
795                 .vbus_gpio = -1,
796                 .hot_plug = false,
797                 .remote_wakeup_supported = true,
798                 .power_off_on_suspend = true,
799         },
800 };
801
802 static struct platform_device *
803 tegra_usb_hsic_host_register(struct platform_device *ehci_dev)
804 {
805         struct platform_device *pdev;
806         int val;
807
808         pdev = platform_device_alloc(ehci_dev->name, ehci_dev->id);
809         if (!pdev)
810                 return NULL;
811
812         val = platform_device_add_resources(pdev, ehci_dev->resource,
813                                                 ehci_dev->num_resources);
814         if (val)
815                 goto error;
816
817         pdev->dev.dma_mask =  ehci_dev->dev.dma_mask;
818         pdev->dev.coherent_dma_mask = ehci_dev->dev.coherent_dma_mask;
819
820         val = platform_device_add_data(pdev, &tegra_hsic_pdata,
821                         sizeof(struct tegra_usb_platform_data));
822         if (val)
823                 goto error;
824
825         val = platform_device_add(pdev);
826         if (val)
827                 goto error;
828
829         return pdev;
830
831 error:
832         pr_err("%s: failed to add the host contoller device\n", __func__);
833         platform_device_put(pdev);
834         return NULL;
835 }
836
837 static void tegra_usb_hsic_host_unregister(struct platform_device **platdev)
838 {
839         struct platform_device *pdev = *platdev;
840
841         if (pdev && &pdev->dev) {
842                 platform_device_unregister(pdev);
843                 *platdev = NULL;
844         } else
845                 pr_err("%s: no platform device\n", __func__);
846 }
847
848 static struct tegra_usb_phy_platform_ops oem1_hsic_pops;
849
850 static union tegra_bb_gpio_id bb_gpio_oem1 = {
851         .oem1 = {
852                 .reset = BB_OEM1_GPIO_RST,
853                 .pwron = BB_OEM1_GPIO_ON,
854                 .awr = BB_OEM1_GPIO_AWR,
855                 .cwr = BB_OEM1_GPIO_CWR,
856                 .spare = BB_OEM1_GPIO_SPARE,
857                 .wdi = BB_OEM1_GPIO_WDI,
858         },
859 };
860
861 static struct tegra_bb_pdata bb_pdata_oem1 = {
862         .id = &bb_gpio_oem1,
863         .device = &tegra_ehci3_device,
864         .ehci_register = tegra_usb_hsic_host_register,
865         .ehci_unregister = tegra_usb_hsic_host_unregister,
866         .bb_id = TEGRA_BB_OEM1,
867 };
868
869 static struct platform_device tegra_bb_oem1 = {
870         .name = "tegra_baseband_power",
871         .id = -1,
872         .dev = {
873                 .platform_data = &bb_pdata_oem1,
874         },
875 };
876
877 static int baseband_init(void)
878 {
879         int ret;
880
881         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
882         if (ret) {
883                 pr_warn("%s:gpio request failed\n", __func__);
884                 return ret;
885         }
886
887         baseband_reg = regulator_get(NULL, "vdd_core_bb");
888         if (IS_ERR_OR_NULL(baseband_reg))
889                 pr_warn("%s: baseband regulator get failed\n", __func__);
890         else
891                 regulator_enable(baseband_reg);
892
893         /* enable pull-up for MDM1 UART RX */
894         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PU1,
895                                     TEGRA_PUPD_PULL_UP);
896
897         /* enable pull-down for MDM1_COLD_BOOT */
898         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
899                                     TEGRA_PUPD_PULL_DOWN);
900
901         /* export GPIO for user space access through sysfs */
902         gpio_export(MDM_RST, false);
903
904         return 0;
905 }
906
907 static const struct tegra_modem_operations baseband_operations = {
908         .init = baseband_init,
909 };
910
911 #define MODEM_BOOT_EDP_MAX 0
912 /* FIXME: get accurate boot current value */
913 static unsigned int modem_boot_edp_states[] = { 1900, 0 };
914 static struct edp_client modem_boot_edp_client = {
915         .name = "modem_boot",
916         .states = modem_boot_edp_states,
917         .num_states = ARRAY_SIZE(modem_boot_edp_states),
918         .e0_index = MODEM_BOOT_EDP_MAX,
919         .priority = EDP_MAX_PRIO,
920 };
921
922 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
923         .ops = &baseband_operations,
924         .wake_gpio = -1,
925         .boot_gpio = MDM_COLDBOOT,
926         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
927         .autosuspend_delay = 2000,
928         .short_autosuspend_delay = 50,
929         .tegra_ehci_device = &tegra_ehci2_device,
930         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
931         .modem_boot_edp_client = &modem_boot_edp_client,
932         .edp_manager_name = "battery",
933         .i_breach_ppm = 500000,
934         /* FIXME: get useful adjperiods */
935         .i_thresh_3g_adjperiod = 10000,
936         .i_thresh_lte_adjperiod = 10000,
937 };
938
939 static struct platform_device icera_baseband_device = {
940         .name = "tegra_usb_modem_power",
941         .id = -1,
942         .dev = {
943                 .platform_data = &baseband_pdata,
944         },
945 };
946
947 static void baseband2_post_phy_on(void)
948 {
949         /* set MDM2_ACK2 low */
950         gpio_set_value(MDM2_ACK2, 0);
951 }
952
953 static void baseband2_pre_phy_off(void)
954 {
955         /* set MDM2_ACK2 high */
956         gpio_set_value(MDM2_ACK2, 1);
957 }
958
959 static void baseband2_start(void)
960 {
961         /*
962          *  Leave baseband powered OFF.
963          *  User-space daemons will take care of powering it up.
964          */
965         pr_info("%s\n", __func__);
966         gpio_set_value(MDM2_PWR_ON, 0);
967 }
968
969 static void baseband2_reset(void)
970 {
971         /* Initiate power cycle on baseband sub system */
972         pr_info("%s\n", __func__);
973         gpio_set_value(MDM2_PWR_ON, 0);
974         mdelay(200);
975         gpio_set_value(MDM2_PWR_ON, 1);
976 }
977
978 static int baseband2_init(void)
979 {
980         int ret;
981
982         ret = gpio_request_array(modem2_gpios, ARRAY_SIZE(modem2_gpios));
983         if (ret)
984                 return ret;
985
986         /* enable pull-up for MDM2_REQ2 */
987         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PV1,
988                                     TEGRA_PUPD_PULL_UP);
989
990         /* export GPIO for user space access through sysfs */
991         gpio_export(MDM2_PWR_ON, false);
992
993         return 0;
994 }
995
996 static const struct tegra_modem_operations baseband2_operations = {
997         .init = baseband2_init,
998         .start = baseband2_start,
999         .reset = baseband2_reset,
1000 };
1001
1002 static struct tegra_usb_modem_power_platform_data baseband2_pdata = {
1003         .ops = &baseband2_operations,
1004         .wake_gpio = MDM2_REQ2,
1005         .wake_irq_flags = IRQF_TRIGGER_FALLING,
1006         .boot_gpio = MDM2_COLDBOOT,
1007         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
1008         .autosuspend_delay = 2000,
1009         .short_autosuspend_delay = 50,
1010         .tegra_ehci_device = &tegra_ehci3_device,
1011         .tegra_ehci_pdata = &tegra_ehci3_hsic_baseband2_pdata,
1012 };
1013
1014 static struct platform_device icera_baseband2_device = {
1015         .name = "tegra_usb_modem_power",
1016         .id = -1,
1017         .dev = {
1018                 .platform_data = &baseband2_pdata,
1019         },
1020 };
1021
1022 static struct baseband_power_platform_data tegra_baseband_xmm_power_data = {
1023         .baseband_type = BASEBAND_XMM,
1024         .modem = {
1025                 .xmm = {
1026                         .bb_rst = XMM_GPIO_BB_RST,
1027                         .bb_on = XMM_GPIO_BB_ON,
1028                         .ipc_bb_wake = XMM_GPIO_IPC_BB_WAKE,
1029                         .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
1030                         .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
1031                         .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
1032                 },
1033         },
1034 };
1035
1036 static struct platform_device tegra_baseband_xmm_power_device = {
1037         .name = "baseband_xmm_power",
1038         .id = -1,
1039         .dev = {
1040                 .platform_data = &tegra_baseband_xmm_power_data,
1041         },
1042 };
1043
1044 static struct platform_device tegra_baseband_xmm_power2_device = {
1045         .name = "baseband_xmm_power2",
1046         .id = -1,
1047         .dev = {
1048                 .platform_data = &tegra_baseband_xmm_power_data,
1049         },
1050 };
1051
1052 static void pluto_usb_init(void)
1053 {
1054         int usb_port_owner_info = tegra_get_usb_port_owner_info();
1055
1056         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
1057                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
1058                 platform_device_register(&tegra_otg_device);
1059
1060                 /* Setup the udc platform data */
1061                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
1062         }
1063 }
1064
1065 static void pluto_modem_init(void)
1066 {
1067         int modem_id = tegra_get_modem_id();
1068         struct board_info board_info;
1069         int usb_port_owner_info = tegra_get_usb_port_owner_info();
1070
1071         tegra_get_board_info(&board_info);
1072         pr_info("%s: modem_id = %d\n", __func__, modem_id);
1073
1074         switch (modem_id) {
1075         case TEGRA_BB_I500: /* on board i500 HSIC */
1076                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
1077                         platform_device_register(&icera_baseband_device);
1078                 break;
1079         case TEGRA_BB_I500SWD: /* i500 SWD HSIC */
1080                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB))
1081                         platform_device_register(&icera_baseband2_device);
1082                 break;
1083         case TEGRA_BB_OEM1:     /* OEM1 HSIC */
1084                 if ((board_info.board_id == BOARD_E1575) ||
1085                         ((board_info.board_id == BOARD_E1580) &&
1086                                 (board_info.fab >= BOARD_FAB_A03))) {
1087                         tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPIO_X1_AUD,
1088                                                         TEGRA_TRI_NORMAL);
1089                         bb_gpio_oem1.oem1.pwron = BB_OEM1_GPIO_ON_V;
1090                 }
1091                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB)) {
1092                         tegra_hsic_pdata.ops = &oem1_hsic_pops;
1093                         tegra_ehci3_device.dev.platform_data
1094                                 = &tegra_hsic_pdata;
1095                         platform_device_register(&tegra_bb_oem1);
1096                 }
1097                 break;
1098         case TEGRA_BB_OEM2: /* XMM6260/XMM6360 HSIC */
1099                 /* fix wrong wiring in Pluto A02 */
1100                 if ((board_info.board_id == BOARD_E1580) &&
1101                         (board_info.fab == BOARD_FAB_A02)) {
1102                         pr_info(
1103 "%s: Pluto A02: replace MDM2_PWR_ON with MDM2_PWR_ON_FOR_PLUTO_A02\n",
1104                                 __func__);
1105                         if (tegra_baseband_xmm_power_data.modem.xmm.bb_on
1106                                 != MDM2_PWR_ON)
1107                                 pr_err(
1108 "%s: expected MDM2_PWR_ON default gpio for XMM bb_on\n",
1109                                         __func__);
1110                         tegra_baseband_xmm_power_data.modem.xmm.bb_on
1111                                 = MDM2_PWR_ON_FOR_PLUTO_A02;
1112                 }
1113                 /* baseband-power.ko will register ehci3 device */
1114                 tegra_hsic_pdata.ops = &oem2_plat_ops;
1115                 tegra_hsic_pdata.u_data.host.remote_wakeup_supported = false;
1116                 tegra_hsic_pdata.u_data.host.power_off_on_suspend = false;
1117                 tegra_ehci3_device.dev.platform_data =
1118                                         &tegra_hsic_pdata;
1119                 tegra_baseband_xmm_power_data.hsic_register =
1120                                                 &tegra_usb_hsic_host_register;
1121                 tegra_baseband_xmm_power_data.hsic_unregister =
1122                                                 &tegra_usb_hsic_host_unregister;
1123                 tegra_baseband_xmm_power_data.ehci_device =
1124                                         &tegra_ehci3_device;
1125                 platform_device_register(&tegra_baseband_xmm_power_device);
1126                 platform_device_register(&tegra_baseband_xmm_power2_device);
1127                 /* override audio settings - use 8kHz */
1128                 pluto_audio_pdata.i2s_param[BASEBAND].audio_port_id
1129                         = pluto_aic3262_pdata.i2s_param[BASEBAND].audio_port_id
1130                         = 2;
1131                 pluto_audio_pdata.i2s_param[BASEBAND].is_i2s_master
1132                         = pluto_aic3262_pdata.i2s_param[BASEBAND].is_i2s_master
1133                         = 1;
1134                 pluto_audio_pdata.i2s_param[BASEBAND].i2s_mode
1135                         = pluto_aic3262_pdata.i2s_param[BASEBAND].i2s_mode
1136                         = TEGRA_DAIFMT_I2S;
1137                 pluto_audio_pdata.i2s_param[BASEBAND].sample_size
1138                         = pluto_aic3262_pdata.i2s_param[BASEBAND].sample_size
1139                         = 16;
1140                 pluto_audio_pdata.i2s_param[BASEBAND].rate
1141                         = pluto_aic3262_pdata.i2s_param[BASEBAND].rate
1142                         = 8000;
1143                 pluto_audio_pdata.i2s_param[BASEBAND].channels
1144                         = pluto_aic3262_pdata.i2s_param[BASEBAND].channels
1145                         = 2;
1146                 break;
1147         case TEGRA_BB_HSIC_HUB: /* HSIC hub */
1148                 if (!(usb_port_owner_info & HSIC2_PORT_OWNER_XUSB)) {
1149                         tegra_ehci3_device.dev.platform_data =
1150                                 &tegra_ehci3_hsic_smsc_hub_pdata;
1151                         platform_device_register(&tegra_ehci3_device);
1152                 }
1153                 break;
1154         default:
1155                 return;
1156         }
1157 }
1158
1159 static struct tegra_xusb_pad_data xusb_padctl_data = {
1160         .pad_mux = (0x1 << 0),
1161         .port_cap = (0x1 << 0),
1162         .snps_oc_map = (0x1ff << 0),
1163         .usb2_oc_map = (0x3c << 0),
1164         .ss_port_map = (0x1 << 0),
1165         .oc_det = (0x3f << 10),
1166         .rx_wander = (0xf << 4),
1167         .rx_eq = (0x3070 << 8),
1168         .cdr_cntl = (0x26 << 24),
1169         .dfe_cntl = 0x002008EE,
1170         .hs_slew = (0x3 << 6),
1171         .otg_pad0_ctl0 = (0x0 << 19),
1172         .otg_pad1_ctl0 = (0x7 << 19),
1173         .otg_pad0_ctl1 = (0x3 << 0),
1174         .otg_pad1_ctl1 = (0x4 << 0),
1175         .hs_disc_lvl = (0x5 << 2),
1176         .hsic_pad0_ctl0 = (0x00 << 8),
1177         .hsic_pad0_ctl1 = (0x00 << 8),
1178 };
1179
1180 static void pluto_xusb_init(void)
1181 {
1182         int usb_port_owner_info = tegra_get_usb_port_owner_info();
1183
1184         if (usb_port_owner_info & UTMI1_PORT_OWNER_XUSB) {
1185                 u32 usb_calib0 = tegra_fuse_readl(FUSE_SKU_USB_CALIB_0);
1186
1187                 pr_info("dalmore_xusb_init: usb_calib0 = 0x%08x\n", usb_calib0);
1188                 /*
1189                  * read from usb_calib0 and pass to driver
1190                  * set HS_CURR_LEVEL (PAD0)     = usb_calib0[5:0]
1191                  * set TERM_RANGE_ADJ           = usb_calib0[10:7]
1192                  * set HS_SQUELCH_LEVEL         = usb_calib0[12:11]
1193                  * set HS_IREF_CAP              = usb_calib0[14:13]
1194                  * set HS_CURR_LEVEL (PAD1)     = usb_calib0[20:15]
1195                  */
1196
1197                 xusb_padctl_data.hs_curr_level_pad0 = (usb_calib0 >> 0) & 0x3f;
1198                 xusb_padctl_data.hs_term_range_adj = (usb_calib0 >> 7) & 0xf;
1199                 xusb_padctl_data.hs_squelch_level = (usb_calib0 >> 11) & 0x3;
1200                 xusb_padctl_data.hs_iref_cap = (usb_calib0 >> 13) & 0x3;
1201                 xusb_padctl_data.hs_curr_level_pad1 = (usb_calib0 >> 15) & 0x3f;
1202
1203                 tegra_xhci_device.dev.platform_data = &xusb_padctl_data;
1204                 platform_device_register(&tegra_xhci_device);
1205         }
1206 }
1207 #else
1208 static void pluto_usb_init(void) { }
1209 static void pluto_modem_init(void) { }
1210 static void pluto_xusb_init(void) { }
1211 #endif
1212
1213 static void pluto_audio_init(void)
1214 {
1215         struct board_info board_info;
1216
1217         tegra_get_board_info(&board_info);
1218
1219         spi_register_board_info(aic326x_spi_board_info,
1220                                         ARRAY_SIZE(aic326x_spi_board_info));
1221 }
1222
1223 #ifndef CONFIG_USE_OF
1224 static struct platform_device *pluto_spi_devices[] __initdata = {
1225         &tegra11_spi_device4,
1226 };
1227
1228 static struct tegra_spi_platform_data pluto_spi_pdata = {
1229         .dma_req_sel            = 0,
1230         .spi_max_frequency      = 25000000,
1231         .clock_always_on        = false,
1232 };
1233
1234 static void __init pluto_spi_init(void)
1235 {
1236         struct board_info board_info, display_board_info;
1237
1238         tegra_get_board_info(&board_info);
1239         tegra_get_display_board_info(&display_board_info);
1240
1241         tegra11_spi_device4.dev.platform_data = &pluto_spi_pdata;
1242         platform_add_devices(pluto_spi_devices,
1243                                 ARRAY_SIZE(pluto_spi_devices));
1244 }
1245 #else
1246 static void __init pluto_spi_init(void)
1247 {
1248 }
1249 #endif
1250
1251 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
1252         /* name         parent          rate            enabled */
1253         { "extern2",    "pll_p",        41000000,       false},
1254         { "clk_out_2",  "extern2",      40800000,       false},
1255         { NULL,         NULL,           0,              0},
1256 };
1257
1258 struct rm_spi_ts_platform_data rm31080ts_pluto_data = {
1259         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
1260         .config = 0,
1261         .platform_id = RM_PLATFORM_P005,
1262         .name_of_clock = "clk_out_2",
1263         .name_of_clock_con = "extern2",
1264 };
1265
1266 static struct tegra_spi_device_controller_data dev_cdata = {
1267         .rx_clk_tap_delay = 0,
1268         .tx_clk_tap_delay = 0,
1269 };
1270
1271 struct spi_board_info rm31080a_pluto_spi_board[1] = {
1272         {
1273          .modalias = "rm_ts_spidev",
1274          .bus_num = 3,
1275          .chip_select = 2,
1276          .max_speed_hz = 12 * 1000 * 1000,
1277          .mode = SPI_MODE_0,
1278          .controller_data = &dev_cdata,
1279          .platform_data = &rm31080ts_pluto_data,
1280          },
1281 };
1282
1283 static int __init pluto_touch_init(void)
1284 {
1285         tegra_clk_init_from_table(touch_clk_init_table);
1286         rm31080a_pluto_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
1287         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
1288                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
1289                                 &rm31080ts_pluto_data,
1290                                 &rm31080a_pluto_spi_board[0],
1291                                 ARRAY_SIZE(rm31080a_pluto_spi_board));
1292         return 0;
1293 }
1294
1295 #ifdef CONFIG_EDP_FRAMEWORK
1296 static struct edp_manager battery_edp_manager = {
1297         .name = "battery",
1298         .max = 20000
1299 };
1300
1301 static void __init pluto_battery_edp_init(void)
1302 {
1303         struct edp_governor *g;
1304         int r;
1305
1306         r = edp_register_manager(&battery_edp_manager);
1307         if (r)
1308                 goto err_ret;
1309
1310         /* start with priority governor */
1311         g = edp_get_governor("priority");
1312         if (!g) {
1313                 r = -EFAULT;
1314                 goto err_ret;
1315         }
1316
1317         r = edp_set_governor(&battery_edp_manager, g);
1318         if (r)
1319                 goto err_ret;
1320
1321         return;
1322
1323 err_ret:
1324         pr_err("Battery EDP init failed with error %d\n", r);
1325         WARN_ON(1);
1326 }
1327 #else
1328 static inline void pluto_battery_edp_init(void) {}
1329 #endif
1330
1331 #ifdef CONFIG_USE_OF
1332 struct of_dev_auxdata pluto_auxdata_lookup[] __initdata = {
1333         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-dma", NULL),
1334         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
1335                                 NULL),
1336         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
1337                                 NULL),
1338         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
1339                                 &pluto_tegra_sdhci_platform_data0),
1340         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
1341                                 NULL),
1342         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
1343                                 NULL),
1344         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
1345                                 NULL),
1346         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
1347                                 NULL),
1348         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
1349                                 NULL),
1350         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
1351                                 NULL),
1352         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
1353                                 NULL),
1354         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
1355                                 NULL),
1356         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d400, "spi-tegra114.0",
1357                                 NULL),
1358         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d600, "spi-tegra114.1",
1359                                 NULL),
1360         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d800, "spi-tegra114.2",
1361                                 NULL),
1362         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000da00, "spi-tegra114.3",
1363                                 NULL),
1364         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000dc00, "spi-tegra114.4",
1365                                 NULL),
1366         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000de00, "spi-tegra114.5",
1367                                 NULL),
1368         {}
1369 };
1370 #endif
1371
1372 static void __init tegra_pluto_early_init(void)
1373 {
1374         pluto_battery_edp_init();
1375         tegra_clk_init_from_table(pluto_clk_init_table);
1376         tegra_clk_vefify_parents();
1377         tegra_smmu_init();
1378         tegra_soc_device_init("tegra_pluto");
1379 }
1380
1381 static void __init tegra_pluto_late_init(void)
1382 {
1383         platform_device_register(&tegra_pinmux_device);
1384         pluto_pinmux_init();
1385         pluto_i2c_init();
1386         pluto_spi_init();
1387         pluto_usb_init();
1388         pluto_xusb_init();
1389         pluto_uart_init();
1390         pluto_audio_init();
1391         platform_add_devices(pluto_devices, ARRAY_SIZE(pluto_devices));
1392         //tegra_ram_console_debug_init();
1393         tegra_io_dpd_init();
1394         pluto_sdhci_init();
1395         pluto_regulator_init();
1396         pluto_suspend_init();
1397         pluto_touch_init();
1398         pluto_emc_init();
1399         pluto_edp_init();
1400         isomgr_init();
1401         pluto_panel_init();
1402         pluto_pmon_init();
1403         pluto_kbc_init();
1404 #ifdef CONFIG_BT_BLUESLEEP
1405         pluto_setup_bluesleep();
1406         pluto_setup_bt_rfkill();
1407 #elif defined CONFIG_BLUEDROID_PM
1408         pluto_setup_bluedroid_pm();
1409 #endif
1410         tegra_release_bootloader_fb();
1411         pluto_modem_init();
1412 #ifdef CONFIG_TEGRA_WDT_RECOVERY
1413         tegra_wdt_recovery_init();
1414 #endif
1415         pluto_sensors_init();
1416         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
1417         pluto_soctherm_init();
1418         tegra_register_fuse();
1419 }
1420
1421 static void __init pluto_ramconsole_reserve(unsigned long size)
1422 {
1423         tegra_ram_console_debug_reserve(SZ_1M);
1424 }
1425
1426 static void __init tegra_pluto_dt_init(void)
1427 {
1428         tegra_pluto_early_init();
1429
1430         of_platform_populate(NULL,
1431                 of_default_bus_match_table, pluto_auxdata_lookup,
1432                 &platform_bus);
1433
1434         tegra_pluto_late_init();
1435 }
1436
1437 static void __init tegra_pluto_reserve(void)
1438 {
1439 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
1440         /* for PANEL_5_SHARP_1080p: 1920*1080*4*2 = 16588800 bytes */
1441         tegra_reserve(0, SZ_16M, SZ_4M);
1442 #else
1443         tegra_reserve(SZ_128M, SZ_16M, SZ_4M);
1444 #endif
1445         pluto_ramconsole_reserve(SZ_1M);
1446 }
1447
1448 static const char * const pluto_dt_board_compat[] = {
1449         "nvidia,pluto",
1450         NULL
1451 };
1452
1453 MACHINE_START(TEGRA_PLUTO, "tegra_pluto")
1454         .atag_offset    = 0x100,
1455         .smp            = smp_ops(tegra_smp_ops),
1456         .map_io         = tegra_map_common_io,
1457         .reserve        = tegra_pluto_reserve,
1458         .init_early     = tegra11x_init_early,
1459         .init_irq       = tegra_dt_init_irq,
1460         .handle_irq     = gic_handle_irq,
1461         .timer          = &tegra_sys_timer,
1462         .init_machine   = tegra_pluto_dt_init,
1463         .restart        = tegra_assert_system_reset,
1464         .dt_compat      = pluto_dt_board_compat,
1465 MACHINE_END