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