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