arm: tegra: pluto: enable pull-down for MDM1_COLD_BOOT
[linux-3.10.git] / arch / arm / mach-tegra / board-pluto.c
1 /*
2  * arch/arm/mach-tegra/board-pluto.c
3  *
4  * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/slab.h>
23 #include <linux/ctype.h>
24 #include <linux/platform_device.h>
25 #include <linux/clk.h>
26 #include <linux/serial_8250.h>
27 #include <linux/i2c.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/delay.h>
30 #include <linux/i2c-tegra.h>
31 #include <linux/gpio.h>
32 #include <linux/input.h>
33 #include <linux/platform_data/tegra_usb.h>
34 #include <linux/spi/spi.h>
35 #include <linux/spi/rm31080a_ts.h>
36 #include <linux/tegra_uart.h>
37 #include <linux/memblock.h>
38 #include <linux/spi-tegra.h>
39 #include <linux/nfc/pn544.h>
40 #include <linux/rfkill-gpio.h>
41 #include <linux/skbuff.h>
42 #include <linux/ti_wilink_st.h>
43 #include <linux/regulator/consumer.h>
44 #include <linux/smb349-charger.h>
45 #include <linux/max17048_battery.h>
46 #include <linux/leds.h>
47 #include <linux/i2c/at24.h>
48 #include <linux/mfd/max8831.h>
49 #include <linux/of_platform.h>
50 #include <linux/a2220.h>
51
52 #include <asm/hardware/gic.h>
53
54 #include <mach/clk.h>
55 #include <mach/iomap.h>
56 #include <mach/irqs.h>
57 #include <mach/pinmux.h>
58 #include <mach/pinmux-tegra30.h>
59 #include <mach/iomap.h>
60 #include <mach/io.h>
61 #include <mach/io_dpd.h>
62 #include <mach/i2s.h>
63 #include <mach/tegra_asoc_pdata.h>
64 #include <asm/mach-types.h>
65 #include <asm/mach/arch.h>
66 #include <mach/usb_phy.h>
67 #include <mach/gpio-tegra.h>
68 #include <mach/tegra_fiq_debugger.h>
69 #include <mach/edp.h>
70 #include <mach/tegra_usb_modem_power.h>
71
72 #include "board.h"
73 #include "board-common.h"
74 #include "board-touch-raydium.h"
75 #include "clock.h"
76 #include "board-pluto.h"
77 #include "devices.h"
78 #include "gpio-names.h"
79 #include "fuse.h"
80 #include "pm.h"
81 #include "common.h"
82
83 static struct rfkill_gpio_platform_data pluto_bt_rfkill_pdata = {
84         .name           = "bt_rfkill",
85         .shutdown_gpio  = TEGRA_GPIO_PQ7,
86         .type           = RFKILL_TYPE_BLUETOOTH,
87 };
88
89 static struct platform_device pluto_bt_rfkill_device = {
90         .name = "rfkill_gpio",
91         .id             = -1,
92         .dev = {
93                 .platform_data = &pluto_bt_rfkill_pdata,
94         },
95 };
96
97 static noinline void __init pluto_setup_bt_rfkill(void)
98 {
99         if ((tegra_get_commchip_id() == COMMCHIP_BROADCOM_BCM43241) ||
100                                 (tegra_get_commchip_id() == COMMCHIP_DEFAULT))
101                 pluto_bt_rfkill_pdata.reset_gpio = TEGRA_GPIO_INVALID;
102         else
103                 pluto_bt_rfkill_pdata.reset_gpio = TEGRA_GPIO_PU6;
104         platform_device_register(&pluto_bt_rfkill_device);
105 }
106
107 static struct resource pluto_bluesleep_resources[] = {
108         [0] = {
109                 .name = "gpio_host_wake",
110                         .start  = TEGRA_GPIO_PU6,
111                         .end    = TEGRA_GPIO_PU6,
112                         .flags  = IORESOURCE_IO,
113         },
114         [1] = {
115                 .name = "gpio_ext_wake",
116                         .start  = TEGRA_GPIO_PEE1,
117                         .end    = TEGRA_GPIO_PEE1,
118                         .flags  = IORESOURCE_IO,
119         },
120         [2] = {
121                 .name = "host_wake",
122                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
123         },
124 };
125
126 static struct platform_device pluto_bluesleep_device = {
127         .name           = "bluesleep",
128         .id             = -1,
129         .num_resources  = ARRAY_SIZE(pluto_bluesleep_resources),
130         .resource       = pluto_bluesleep_resources,
131 };
132
133 static noinline void __init pluto_setup_bluesleep(void)
134 {
135         pluto_bluesleep_resources[2].start =
136                 pluto_bluesleep_resources[2].end =
137                         gpio_to_irq(TEGRA_GPIO_PU6);
138         platform_device_register(&pluto_bluesleep_device);
139         return;
140 }
141 static __initdata struct tegra_clk_init_table pluto_clk_init_table[] = {
142         /* name         parent          rate            enabled */
143         { "pll_m",      NULL,           0,              false},
144         { "hda",        "pll_p",        108000000,      false},
145         { "hda2codec_2x", "pll_p",      48000000,       false},
146         { "pwm",        "pll_p",        3187500,        false},
147         { "i2s1",       "pll_a_out0",   0,              false},
148         { "i2s2",       "pll_a_out0",   0,              false},
149         { "i2s3",       "pll_a_out0",   0,              false},
150         { "i2s4",       "pll_a_out0",   0,              false},
151         { "spdif_out",  "pll_a_out0",   0,              false},
152         { "d_audio",    "clk_m",        12000000,       false},
153         { "dam0",       "clk_m",        12000000,       false},
154         { "dam1",       "clk_m",        12000000,       false},
155         { "dam2",       "clk_m",        12000000,       false},
156         { "audio1",     "i2s1_sync",    0,              false},
157         { "audio2",     "i2s2_sync",    0,              false},
158         { "audio3",     "i2s3_sync",    0,              false},
159         { "audio4",     "i2s4_sync",    0,              false},
160         { "vi_sensor",  "pll_p",        150000000,      false},
161         { "cilab",      "pll_p",        150000000,      false},
162         { "cilcd",      "pll_p",        150000000,      false},
163         { "cile",       "pll_p",        150000000,      false},
164         { "i2c1",       "pll_p",        3200000,        false},
165         { "i2c2",       "pll_p",        3200000,        false},
166         { "i2c3",       "pll_p",        3200000,        false},
167         { "i2c4",       "pll_p",        3200000,        false},
168         { "i2c5",       "pll_p",        3200000,        false},
169         { "extern3",    "clk_m",        12000000,       false},
170         { NULL,         NULL,           0,              0},
171 };
172
173 static struct tegra_i2c_platform_data pluto_i2c1_platform_data = {
174         .adapter_nr     = 0,
175         .bus_count      = 1,
176         .bus_clk_rate   = { 100000, 0 },
177         .scl_gpio               = {TEGRA_GPIO_I2C1_SCL, 0},
178         .sda_gpio               = {TEGRA_GPIO_I2C1_SDA, 0},
179         .arb_recovery = arb_lost_recovery,
180 };
181
182 static struct tegra_i2c_platform_data pluto_i2c2_platform_data = {
183         .adapter_nr     = 1,
184         .bus_count      = 1,
185         .bus_clk_rate   = { 100000, 0 },
186         .is_clkon_always = true,
187         .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
188         .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
189         .arb_recovery = arb_lost_recovery,
190 };
191
192 static struct tegra_i2c_platform_data pluto_i2c3_platform_data = {
193         .adapter_nr     = 2,
194         .bus_count      = 1,
195         .bus_clk_rate   = { 100000, 0 },
196         .scl_gpio               = {TEGRA_GPIO_I2C3_SCL, 0},
197         .sda_gpio               = {TEGRA_GPIO_I2C3_SDA, 0},
198         .arb_recovery = arb_lost_recovery,
199 };
200
201 static struct tegra_i2c_platform_data pluto_i2c4_platform_data = {
202         .adapter_nr     = 3,
203         .bus_count      = 1,
204         .bus_clk_rate   = { 10000, 0 },
205         .scl_gpio               = {TEGRA_GPIO_I2C4_SCL, 0},
206         .sda_gpio               = {TEGRA_GPIO_I2C4_SDA, 0},
207         .arb_recovery = arb_lost_recovery,
208 };
209
210 static struct tegra_i2c_platform_data pluto_i2c5_platform_data = {
211         .adapter_nr     = 4,
212         .bus_count      = 1,
213         .bus_clk_rate   = { 400000, 0 },
214         .scl_gpio               = {TEGRA_GPIO_I2C5_SCL, 0},
215         .sda_gpio               = {TEGRA_GPIO_I2C5_SDA, 0},
216         .arb_recovery = arb_lost_recovery,
217 };
218
219 static struct i2c_board_info __initdata cs42l73_board_info = {
220         I2C_BOARD_INFO("cs42l73", 0x4a),
221 };
222
223 static struct i2c_board_info __initdata pluto_codec_a2220_info = {
224         I2C_BOARD_INFO("audience_a2220", 0x3E),
225 };
226
227
228 static void pluto_i2c_init(void)
229 {
230         struct board_info board_info;
231
232         tegra_get_board_info(&board_info);
233 #ifndef CONFIG_ARCH_TEGRA_11x_SOC
234         tegra_i2c_device1.dev.platform_data = &pluto_i2c1_platform_data;
235         tegra_i2c_device2.dev.platform_data = &pluto_i2c2_platform_data;
236         tegra_i2c_device3.dev.platform_data = &pluto_i2c3_platform_data;
237         tegra_i2c_device4.dev.platform_data = &pluto_i2c4_platform_data;
238         tegra_i2c_device5.dev.platform_data = &pluto_i2c5_platform_data;
239
240         i2c_register_board_info(1, &pluto_i2c_led_info, 1);
241
242         platform_device_register(&tegra_i2c_device5);
243         platform_device_register(&tegra_i2c_device4);
244         platform_device_register(&tegra_i2c_device3);
245         platform_device_register(&tegra_i2c_device2);
246         platform_device_register(&tegra_i2c_device1);
247
248 #else
249         tegra11_i2c_device1.dev.platform_data = &pluto_i2c1_platform_data;
250         tegra11_i2c_device2.dev.platform_data = &pluto_i2c2_platform_data;
251         tegra11_i2c_device3.dev.platform_data = &pluto_i2c3_platform_data;
252         tegra11_i2c_device4.dev.platform_data = &pluto_i2c4_platform_data;
253         tegra11_i2c_device5.dev.platform_data = &pluto_i2c5_platform_data;
254
255         platform_device_register(&tegra11_i2c_device5);
256         platform_device_register(&tegra11_i2c_device4);
257         platform_device_register(&tegra11_i2c_device3);
258         platform_device_register(&tegra11_i2c_device2);
259         platform_device_register(&tegra11_i2c_device1);
260
261 #endif
262
263         i2c_register_board_info(0, &pluto_codec_a2220_info, 1);
264         i2c_register_board_info(0, &cs42l73_board_info, 1);
265 }
266
267 static struct platform_device *pluto_uart_devices[] __initdata = {
268         &tegra_uarta_device,
269         &tegra_uartb_device,
270         &tegra_uartc_device,
271         &tegra_uartd_device,
272 };
273 static struct uart_clk_parent uart_parent_clk[] = {
274         [0] = {.name = "clk_m"},
275         [1] = {.name = "pll_p"},
276 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
277         [2] = {.name = "pll_m"},
278 #endif
279 };
280
281 static struct tegra_uart_platform_data pluto_uart_pdata;
282 static struct tegra_uart_platform_data pluto_loopback_uart_pdata;
283
284 static void __init uart_debug_init(void)
285 {
286         int debug_port_id;
287
288         debug_port_id = uart_console_debug_init(3);
289         if (debug_port_id < 0)
290                 return;
291         pluto_uart_devices[debug_port_id] = uart_console_debug_device;
292 }
293
294 static void __init pluto_uart_init(void)
295 {
296         struct clk *c;
297         int i;
298
299         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
300                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
301                 if (IS_ERR_OR_NULL(c)) {
302                         pr_err("Not able to get the clock for %s\n",
303                                                 uart_parent_clk[i].name);
304                         continue;
305                 }
306                 uart_parent_clk[i].parent_clk = c;
307                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
308         }
309         pluto_uart_pdata.parent_clk_list = uart_parent_clk;
310         pluto_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
311         pluto_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
312         pluto_loopback_uart_pdata.parent_clk_count =
313                                                 ARRAY_SIZE(uart_parent_clk);
314         pluto_loopback_uart_pdata.is_loopback = true;
315         tegra_uarta_device.dev.platform_data = &pluto_uart_pdata;
316         tegra_uartb_device.dev.platform_data = &pluto_uart_pdata;
317         tegra_uartc_device.dev.platform_data = &pluto_uart_pdata;
318         tegra_uartd_device.dev.platform_data = &pluto_uart_pdata;
319
320         /* Register low speed only if it is selected */
321         if (!is_tegra_debug_uartport_hs())
322                 uart_debug_init();
323
324         platform_add_devices(pluto_uart_devices,
325                                 ARRAY_SIZE(pluto_uart_devices));
326 }
327
328 static struct resource tegra_rtc_resources[] = {
329         [0] = {
330                 .start = TEGRA_RTC_BASE,
331                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
332                 .flags = IORESOURCE_MEM,
333         },
334         [1] = {
335                 .start = INT_RTC,
336                 .end = INT_RTC,
337                 .flags = IORESOURCE_IRQ,
338         },
339 };
340
341 static struct platform_device tegra_rtc_device = {
342         .name = "tegra_rtc",
343         .id   = -1,
344         .resource = tegra_rtc_resources,
345         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
346 };
347
348 static struct tegra_asoc_platform_data pluto_audio_pdata = {
349         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
350         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
351         .gpio_hp_mute           = -1,
352         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
353         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
354         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
355         .i2s_param[HIFI_CODEC]  = {
356                 .audio_port_id  = 1,
357                 .is_i2s_master  = 0,
358                 .i2s_mode       = TEGRA_DAIFMT_I2S,
359                 .sample_size    = 16,
360                 .channels       = 2,
361         },
362         .i2s_param[BASEBAND]    = {
363                 .audio_port_id  = 2,
364                 .is_i2s_master  = 1,
365                 .i2s_mode       = TEGRA_DAIFMT_I2S,
366                 .sample_size    = 16,
367                 .rate           = 16000,
368                 .channels       = 2,
369         },
370         .i2s_param[BT_SCO]      = {
371                 .audio_port_id  = 3,
372                 .is_i2s_master  = 1,
373                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
374                 .sample_size    = 16,
375         },
376 };
377
378 static struct platform_device pluto_audio_device = {
379         .name   = "tegra-snd-cs42l73",
380         .id     = 2,
381         .dev    = {
382                 .platform_data = &pluto_audio_pdata,
383         },
384 };
385
386 static struct platform_device tegra_camera = {
387         .name = "tegra_camera",
388         .id = -1,
389 };
390
391 static struct platform_device *pluto_devices[] __initdata = {
392         &tegra_pmu_device,
393         &tegra_rtc_device,
394         &tegra_udc_device,
395 #if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
396         &tegra_smmu_device,
397 #endif
398 #if defined(CONFIG_TEGRA_AVP)
399         &tegra_avp_device,
400 #endif
401         &tegra_camera,
402 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
403         &tegra11_se_device,
404 #endif
405         &tegra_ahub_device,
406         &tegra_dam_device0,
407         &tegra_dam_device1,
408         &tegra_dam_device2,
409         &tegra_i2s_device0,
410         &tegra_i2s_device1,
411         &tegra_i2s_device2,
412         &tegra_i2s_device3,
413         &tegra_i2s_device4,
414         &tegra_spdif_device,
415         &spdif_dit_device,
416         &bluetooth_dit_device,
417         &baseband_dit_device,
418         &pluto_audio_device,
419         &tegra_hda_device,
420 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
421         &tegra_aes_device,
422 #endif
423 };
424
425 #ifdef CONFIG_USB_SUPPORT
426 static struct tegra_usb_platform_data tegra_ehci3_hsic_smsc_hub_pdata = {
427         .port_otg = false,
428         .has_hostpc = true,
429         .unaligned_dma_buf_supported = false,
430         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
431         .op_mode        = TEGRA_USB_OPMODE_HOST,
432         .u_data.host = {
433                 .vbus_gpio = -1,
434                 .hot_plug = false,
435                 .remote_wakeup_supported = true,
436                 .power_off_on_suspend = true,
437         },
438 };
439
440 static struct tegra_usb_platform_data tegra_udc_pdata = {
441         .port_otg = true,
442         .has_hostpc = true,
443         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
444         .op_mode = TEGRA_USB_OPMODE_DEVICE,
445         .u_data.dev = {
446                 .vbus_pmu_irq = 0,
447                 .vbus_gpio = -1,
448                 .charging_supported = false,
449                 .remote_wakeup_supported = false,
450         },
451         .u_cfg.utmi = {
452                 .hssync_start_delay = 0,
453                 .elastic_limit = 16,
454                 .idle_wait_delay = 17,
455                 .term_range_adj = 6,
456                 .xcvr_setup = 8,
457                 .xcvr_lsfslew = 2,
458                 .xcvr_lsrslew = 2,
459                 .xcvr_setup_offset = 0,
460                 .xcvr_use_fuses = 1,
461         },
462 };
463
464 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
465         .port_otg = true,
466         .has_hostpc = true,
467         .unaligned_dma_buf_supported = false,
468         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
469         .op_mode = TEGRA_USB_OPMODE_HOST,
470         .u_data.host = {
471                 .vbus_gpio = -1,
472                 .hot_plug = true,
473                 .remote_wakeup_supported = true,
474                 .power_off_on_suspend = true,
475         },
476         .u_cfg.utmi = {
477                 .hssync_start_delay = 0,
478                 .elastic_limit = 16,
479                 .idle_wait_delay = 17,
480                 .term_range_adj = 6,
481                 .xcvr_setup = 15,
482                 .xcvr_lsfslew = 2,
483                 .xcvr_lsrslew = 2,
484                 .xcvr_setup_offset = 0,
485                 .xcvr_use_fuses = 1,
486         },
487 };
488
489 static struct tegra_usb_otg_data tegra_otg_pdata = {
490         .ehci_device = &tegra_ehci1_device,
491         .ehci_pdata = &tegra_ehci1_utmi_pdata,
492 };
493
494 static struct regulator *baseband_reg;
495 static struct gpio modem_gpios[] = { /* i500 modem */
496         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
497         {MDM_ACK, GPIOF_OUT_INIT_HIGH, "MODEM ACK1"},
498 };
499
500 static void baseband_post_phy_on(void);
501 static void baseband_pre_phy_off(void);
502
503 static struct tegra_usb_phy_platform_ops baseband_plat_ops = {
504         .pre_phy_off = baseband_pre_phy_off,
505         .post_phy_on = baseband_post_phy_on,
506 };
507
508 static struct gpio modem2_gpios[] = {
509         {MDM2_PWR_ON, GPIOF_OUT_INIT_LOW, "MODEM2 PWR ON"},
510         {MDM2_RST, GPIOF_DIR_OUT, "MODEM2 RESET"},
511         {MDM2_ACK2, GPIOF_OUT_INIT_HIGH, "MODEM2 ACK2"},
512         {MDM2_ACK1, GPIOF_OUT_INIT_LOW, "MODEM2 ACK1"},
513 };
514
515 static void baseband2_post_phy_on(void);
516 static void baseband2_pre_phy_off(void);
517
518 static struct tegra_usb_phy_platform_ops baseband2_plat_ops = {
519         .pre_phy_off = baseband2_pre_phy_off,
520         .post_phy_on = baseband2_post_phy_on,
521 };
522
523 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
524         .port_otg = false,
525         .has_hostpc = true,
526         .unaligned_dma_buf_supported = false,
527         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
528         .op_mode = TEGRA_USB_OPMODE_HOST,
529         .u_data.host = {
530                 .vbus_gpio = -1,
531                 .hot_plug = false,
532                 .remote_wakeup_supported = false,
533                 .power_off_on_suspend = false,
534         },
535         .ops = &baseband_plat_ops,
536 };
537
538 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
539 static struct tegra_usb_platform_data tegra_ehci3_hsic_baseband2_pdata = {
540 #else
541 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband2_pdata = {
542 #endif
543         .port_otg = false,
544         .has_hostpc = true,
545         .unaligned_dma_buf_supported = false,
546         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
547         .op_mode = TEGRA_USB_OPMODE_HOST,
548         .u_data.host = {
549                 .vbus_gpio = -1,
550                 .hot_plug = false,
551                 .remote_wakeup_supported = false,
552                 .power_off_on_suspend = false,
553         },
554         .ops = &baseband2_plat_ops,
555 };
556
557 static void baseband_post_phy_on(void)
558 {
559         gpio_set_value(MDM_ACK, 0);
560 }
561
562 static void baseband_pre_phy_off(void)
563 {
564         gpio_set_value(MDM_ACK, 1);
565 }
566
567 static int baseband_init(void)
568 {
569         int ret;
570
571         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
572         if (ret) {
573                 pr_warn("%s:gpio request failed\n", __func__);
574                 return ret;
575         }
576
577         baseband_reg = regulator_get(NULL, "vdd_core_bb");
578         if (IS_ERR_OR_NULL(baseband_reg))
579                 pr_warn("%s: baseband regulator get failed\n", __func__);
580         else
581                 regulator_enable(baseband_reg);
582
583         /* enable pull-down for MDM1_COLD_BOOT */
584         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
585                                     TEGRA_PUPD_PULL_DOWN);
586
587         /* export GPIO for user space access through sysfs */
588         gpio_export(MDM_RST, false);
589
590         return 0;
591 }
592
593 static const struct tegra_modem_operations baseband_operations = {
594         .init = baseband_init,
595 };
596
597 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
598         .ops = &baseband_operations,
599         .wake_gpio = MDM_REQ,
600         .wake_irq_flags = IRQF_TRIGGER_FALLING,
601         .boot_gpio = MDM_COLDBOOT,
602         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
603         .autosuspend_delay = 2000,
604         .short_autosuspend_delay = 50,
605         .tegra_ehci_device = &tegra_ehci2_device,
606         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
607 };
608
609 static struct platform_device icera_baseband_device = {
610         .name = "tegra_usb_modem_power",
611         .id = -1,
612         .dev = {
613                 .platform_data = &baseband_pdata,
614         },
615 };
616
617 static void baseband2_post_phy_on(void)
618 {
619         /* set MDM2_ACK2 low */
620         gpio_set_value(MDM2_ACK2, 0);
621 }
622
623 static void baseband2_pre_phy_off(void)
624 {
625         /* set MDM2_ACK2 high */
626         gpio_set_value(MDM2_ACK2, 1);
627 }
628
629 static void baseband2_start(void)
630 {
631         /*
632          *  Leave baseband powered OFF.
633          *  User-space daemons will take care of powering it up.
634          */
635         pr_info("%s\n", __func__);
636         gpio_set_value(MDM2_PWR_ON, 0);
637 }
638
639 static void baseband2_reset(void)
640 {
641         /* Initiate power cycle on baseband sub system */
642         pr_info("%s\n", __func__);
643         gpio_set_value(MDM2_PWR_ON, 0);
644         mdelay(200);
645         gpio_set_value(MDM2_PWR_ON, 1);
646 }
647
648 static int baseband2_init(void)
649 {
650         int ret;
651
652         ret = gpio_request_array(modem2_gpios, ARRAY_SIZE(modem2_gpios));
653         if (ret)
654                 return ret;
655
656         /* enable pull-up for MDM2_REQ2 */
657         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PV1,
658                                     TEGRA_PUPD_PULL_UP);
659
660         /* export GPIO for user space access through sysfs */
661         gpio_export(MDM2_PWR_ON, false);
662
663         return 0;
664 }
665
666 static const struct tegra_modem_operations baseband2_operations = {
667         .init = baseband2_init,
668         .start = baseband2_start,
669         .reset = baseband2_reset,
670 };
671
672 static struct tegra_usb_modem_power_platform_data baseband2_pdata = {
673         .ops = &baseband2_operations,
674         .wake_gpio = MDM2_REQ2,
675         .wake_irq_flags = IRQF_TRIGGER_FALLING,
676         .boot_gpio = MDM2_COLDBOOT,
677         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
678         .autosuspend_delay = 2000,
679         .short_autosuspend_delay = 50,
680 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
681         .tegra_ehci_device = &tegra_ehci3_device,
682         .tegra_ehci_pdata = &tegra_ehci3_hsic_baseband2_pdata,
683 #else
684         .tegra_ehci_device = &tegra_ehci2_device,
685         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband2_pdata,
686 #endif
687 };
688
689 static struct platform_device icera_baseband2_device = {
690         .name = "tegra_usb_modem_power",
691         .id = -1,
692         .dev = {
693                 .platform_data = &baseband2_pdata,
694         },
695 };
696
697 static void pluto_usb_init(void)
698 {
699         int modem_id = tegra_get_modem_id();
700
701         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
702         platform_device_register(&tegra_otg_device);
703
704         /* Setup the udc platform data */
705         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
706
707         if (!modem_id) {
708                 tegra_ehci3_device.dev.platform_data =
709                         &tegra_ehci3_hsic_smsc_hub_pdata;
710                 platform_device_register(&tegra_ehci3_device);
711         }
712 }
713
714 static void pluto_modem_init(void)
715 {
716         int modem_id = tegra_get_modem_id();
717
718         pr_info("%s: modem_id = %d\n", __func__, modem_id);
719
720         switch (modem_id) {
721         case TEGRA_BB_I500: /* on board i500 HSIC */
722                 platform_device_register(&icera_baseband_device);
723                 break;
724         case TEGRA_BB_I500SWD: /* i500 SWD HSIC */
725                 platform_device_register(&icera_baseband2_device);
726                 break;
727         default:
728                 return;
729         }
730 }
731
732 #else
733 static void pluto_usb_init(void) { }
734 static void pluto_modem_init(void) { }
735 #endif
736
737 static void pluto_audio_init(void)
738 {
739         struct board_info board_info;
740
741         tegra_get_board_info(&board_info);
742
743         pluto_audio_pdata.codec_name = "cs42l73.0-004a";
744         pluto_audio_pdata.codec_dai_name = "cs42l73-vsp";
745 }
746
747 static struct platform_device *pluto_spi_devices[] __initdata = {
748         &tegra11_spi_device4,
749 };
750
751 struct spi_clk_parent spi_parent_clk_pluto[] = {
752         [0] = {.name = "pll_p"},
753 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
754         [1] = {.name = "pll_m"},
755         [2] = {.name = "clk_m"},
756 #else
757         [1] = {.name = "clk_m"},
758 #endif
759 };
760
761 static struct tegra_spi_platform_data pluto_spi_pdata = {
762         .is_dma_based           = false,
763         .max_dma_buffer         = 16 * 1024,
764         .is_clkon_always        = false,
765         .max_rate               = 25000000,
766 };
767
768 static void __init pluto_spi_init(void)
769 {
770         int i;
771         struct clk *c;
772         struct board_info board_info, display_board_info;
773
774         tegra_get_board_info(&board_info);
775         tegra_get_display_board_info(&display_board_info);
776
777         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_pluto); ++i) {
778                 c = tegra_get_clock_by_name(spi_parent_clk_pluto[i].name);
779                 if (IS_ERR_OR_NULL(c)) {
780                         pr_err("Not able to get the clock for %s\n",
781                                                 spi_parent_clk_pluto[i].name);
782                         continue;
783                 }
784                 spi_parent_clk_pluto[i].parent_clk = c;
785                 spi_parent_clk_pluto[i].fixed_clk_rate = clk_get_rate(c);
786         }
787         pluto_spi_pdata.parent_clk_list = spi_parent_clk_pluto;
788         pluto_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_pluto);
789         tegra11_spi_device4.dev.platform_data = &pluto_spi_pdata;
790         platform_add_devices(pluto_spi_devices,
791                                 ARRAY_SIZE(pluto_spi_devices));
792 }
793
794 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
795         /* name         parent          rate            enabled */
796         { "extern2",    "pll_p",        41000000,       false},
797         { "clk_out_2",  "extern2",      40800000,       false},
798         { NULL,         NULL,           0,              0},
799 };
800
801 struct rm_spi_ts_platform_data rm31080ts_pluto_data = {
802         .gpio_reset = 0,
803         .config = 0,
804         .platform_id = RM_PLATFORM_P005,
805         .name_of_clock = "clk_out_2",
806 };
807
808 static struct tegra_spi_device_controller_data dev_cdata = {
809         .rx_clk_tap_delay = 0,
810         .tx_clk_tap_delay = 0,
811 };
812
813 struct spi_board_info rm31080a_pluto_spi_board[1] = {
814         {
815          .modalias = "rm_ts_spidev",
816          .bus_num = 3,
817          .chip_select = 2,
818          .max_speed_hz = 12 * 1000 * 1000,
819          .mode = SPI_MODE_0,
820          .controller_data = &dev_cdata,
821          .platform_data = &rm31080ts_pluto_data,
822          },
823 };
824
825 static int __init pluto_touch_init(void)
826 {
827         tegra_clk_init_from_table(touch_clk_init_table);
828         clk_enable(tegra_get_clock_by_name("clk_out_2"));
829         mdelay(20);
830         rm31080a_pluto_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
831         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
832                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
833                                 &rm31080ts_pluto_data,
834                                 &rm31080a_pluto_spi_board[0],
835                                 ARRAY_SIZE(rm31080a_pluto_spi_board));
836         return 0;
837 }
838
839 static void __init tegra_pluto_init(void)
840 {
841         tegra_battery_edp_init(2500);
842         tegra_clk_init_from_table(pluto_clk_init_table);
843         tegra_soc_device_init("tegra_pluto");
844         tegra_enable_pinmux();
845         pluto_pinmux_init();
846         pluto_i2c_init();
847         pluto_spi_init();
848         pluto_usb_init();
849         pluto_edp_init();
850         pluto_uart_init();
851         pluto_audio_init();
852         platform_add_devices(pluto_devices, ARRAY_SIZE(pluto_devices));
853         //tegra_ram_console_debug_init();
854         tegra_io_dpd_init();
855         pluto_sdhci_init();
856         pluto_regulator_init();
857         pluto_suspend_init();
858         pluto_touch_init();
859         pluto_emc_init();
860         pluto_panel_init();
861         pluto_pmon_init();
862         pluto_kbc_init();
863         pluto_setup_bluesleep();
864         pluto_setup_bt_rfkill();
865         tegra_release_bootloader_fb();
866         pluto_modem_init();
867 #ifdef CONFIG_TEGRA_WDT_RECOVERY
868         tegra_wdt_recovery_init();
869 #endif
870         pluto_sensors_init();
871         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
872 }
873
874 static void __init pluto_ramconsole_reserve(unsigned long size)
875 {
876         tegra_ram_console_debug_reserve(SZ_1M);
877 }
878
879 static void __init tegra_pluto_dt_init(void)
880 {
881         tegra_pluto_init();
882
883         of_platform_populate(NULL,
884                 of_default_bus_match_table, NULL, NULL);
885 }
886
887 static void __init tegra_pluto_reserve(void)
888 {
889 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
890         /* for PANEL_5_SHARP_1080p: 1920*1080*4*2 = 16588800 bytes */
891         tegra_reserve(0, SZ_16M, SZ_4M);
892 #else
893         tegra_reserve(SZ_128M, SZ_16M, SZ_4M);
894 #endif
895         pluto_ramconsole_reserve(SZ_1M);
896 }
897
898 static const char * const pluto_dt_board_compat[] = {
899         "nvidia,pluto",
900         NULL
901 };
902
903 MACHINE_START(TEGRA_PLUTO, "tegra_pluto")
904         .atag_offset    = 0x100,
905         .smp            = smp_ops(tegra_smp_ops),
906         .map_io         = tegra_map_common_io,
907         .reserve        = tegra_pluto_reserve,
908 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
909         .init_early     = tegra30_init_early,
910 #else
911         .init_early     = tegra11x_init_early,
912 #endif
913         .init_irq       = tegra_init_irq,
914         .handle_irq     = gic_handle_irq,
915         .timer          = &tegra_timer,
916         .init_machine   = tegra_pluto_dt_init,
917         .restart        = tegra_assert_system_reset,
918         .dt_compat      = pluto_dt_board_compat,
919 MACHINE_END