arm: tegra: suspend/resume will mng clk
[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         /* export GPIO for user space access through sysfs */
584         gpio_export(MDM_RST, false);
585
586         return 0;
587 }
588
589 static const struct tegra_modem_operations baseband_operations = {
590         .init = baseband_init,
591 };
592
593 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
594         .ops = &baseband_operations,
595         .wake_gpio = MDM_REQ,
596         .wake_irq_flags = IRQF_TRIGGER_FALLING,
597         .boot_gpio = MDM_COLDBOOT,
598         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
599         .autosuspend_delay = 2000,
600         .short_autosuspend_delay = 50,
601         .tegra_ehci_device = &tegra_ehci2_device,
602         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
603 };
604
605 static struct platform_device icera_baseband_device = {
606         .name = "tegra_usb_modem_power",
607         .id = -1,
608         .dev = {
609                 .platform_data = &baseband_pdata,
610         },
611 };
612
613 static void baseband2_post_phy_on(void)
614 {
615         /* set MDM2_ACK2 low */
616         gpio_set_value(MDM2_ACK2, 0);
617 }
618
619 static void baseband2_pre_phy_off(void)
620 {
621         /* set MDM2_ACK2 high */
622         gpio_set_value(MDM2_ACK2, 1);
623 }
624
625 static void baseband2_start(void)
626 {
627         /*
628          *  Leave baseband powered OFF.
629          *  User-space daemons will take care of powering it up.
630          */
631         pr_info("%s\n", __func__);
632         gpio_set_value(MDM2_PWR_ON, 0);
633 }
634
635 static void baseband2_reset(void)
636 {
637         /* Initiate power cycle on baseband sub system */
638         pr_info("%s\n", __func__);
639         gpio_set_value(MDM2_PWR_ON, 0);
640         mdelay(200);
641         gpio_set_value(MDM2_PWR_ON, 1);
642 }
643
644 static int baseband2_init(void)
645 {
646         int ret;
647
648         ret = gpio_request_array(modem2_gpios, ARRAY_SIZE(modem2_gpios));
649         if (ret)
650                 return ret;
651
652         /* enable pull-up for MDM2_REQ2 */
653         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PV1,
654                                     TEGRA_PUPD_PULL_UP);
655
656         /* export GPIO for user space access through sysfs */
657         gpio_export(MDM2_PWR_ON, false);
658
659         return 0;
660 }
661
662 static const struct tegra_modem_operations baseband2_operations = {
663         .init = baseband2_init,
664         .start = baseband2_start,
665         .reset = baseband2_reset,
666 };
667
668 static struct tegra_usb_modem_power_platform_data baseband2_pdata = {
669         .ops = &baseband2_operations,
670         .wake_gpio = MDM2_REQ2,
671         .wake_irq_flags = IRQF_TRIGGER_FALLING,
672         .boot_gpio = MDM2_COLDBOOT,
673         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
674         .autosuspend_delay = 2000,
675         .short_autosuspend_delay = 50,
676 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
677         .tegra_ehci_device = &tegra_ehci3_device,
678         .tegra_ehci_pdata = &tegra_ehci3_hsic_baseband2_pdata,
679 #else
680         .tegra_ehci_device = &tegra_ehci2_device,
681         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband2_pdata,
682 #endif
683 };
684
685 static struct platform_device icera_baseband2_device = {
686         .name = "tegra_usb_modem_power",
687         .id = -1,
688         .dev = {
689                 .platform_data = &baseband2_pdata,
690         },
691 };
692
693 static void pluto_usb_init(void)
694 {
695         int modem_id = tegra_get_modem_id();
696
697         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
698         platform_device_register(&tegra_otg_device);
699
700         /* Setup the udc platform data */
701         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
702
703         if (!modem_id) {
704                 tegra_ehci3_device.dev.platform_data =
705                         &tegra_ehci3_hsic_smsc_hub_pdata;
706                 platform_device_register(&tegra_ehci3_device);
707         }
708 }
709
710 static void pluto_modem_init(void)
711 {
712         int modem_id = tegra_get_modem_id();
713
714         pr_info("%s: modem_id = %d\n", __func__, modem_id);
715
716         switch (modem_id) {
717         case TEGRA_BB_I500: /* on board i500 HSIC */
718                 platform_device_register(&icera_baseband_device);
719                 break;
720         case TEGRA_BB_I500SWD: /* i500 SWD HSIC */
721                 platform_device_register(&icera_baseband2_device);
722                 break;
723         default:
724                 return;
725         }
726 }
727
728 #else
729 static void pluto_usb_init(void) { }
730 static void pluto_modem_init(void) { }
731 #endif
732
733 static void pluto_audio_init(void)
734 {
735         struct board_info board_info;
736
737         tegra_get_board_info(&board_info);
738
739         pluto_audio_pdata.codec_name = "cs42l73.0-004a";
740         pluto_audio_pdata.codec_dai_name = "cs42l73-vsp";
741 }
742
743 static struct platform_device *pluto_spi_devices[] __initdata = {
744         &tegra11_spi_device4,
745 };
746
747 struct spi_clk_parent spi_parent_clk_pluto[] = {
748         [0] = {.name = "pll_p"},
749 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
750         [1] = {.name = "pll_m"},
751         [2] = {.name = "clk_m"},
752 #else
753         [1] = {.name = "clk_m"},
754 #endif
755 };
756
757 static struct tegra_spi_platform_data pluto_spi_pdata = {
758         .is_dma_based           = false,
759         .max_dma_buffer         = 16 * 1024,
760         .is_clkon_always        = false,
761         .max_rate               = 25000000,
762 };
763
764 static void __init pluto_spi_init(void)
765 {
766         int i;
767         struct clk *c;
768         struct board_info board_info, display_board_info;
769
770         tegra_get_board_info(&board_info);
771         tegra_get_display_board_info(&display_board_info);
772
773         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_pluto); ++i) {
774                 c = tegra_get_clock_by_name(spi_parent_clk_pluto[i].name);
775                 if (IS_ERR_OR_NULL(c)) {
776                         pr_err("Not able to get the clock for %s\n",
777                                                 spi_parent_clk_pluto[i].name);
778                         continue;
779                 }
780                 spi_parent_clk_pluto[i].parent_clk = c;
781                 spi_parent_clk_pluto[i].fixed_clk_rate = clk_get_rate(c);
782         }
783         pluto_spi_pdata.parent_clk_list = spi_parent_clk_pluto;
784         pluto_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_pluto);
785         tegra11_spi_device4.dev.platform_data = &pluto_spi_pdata;
786         platform_add_devices(pluto_spi_devices,
787                                 ARRAY_SIZE(pluto_spi_devices));
788 }
789
790 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
791         /* name         parent          rate            enabled */
792         { "extern2",    "pll_p",        41000000,       false},
793         { "clk_out_2",  "extern2",      40800000,       false},
794         { NULL,         NULL,           0,              0},
795 };
796
797 struct rm_spi_ts_platform_data rm31080ts_pluto_data = {
798         .gpio_reset = 0,
799         .config = 0,
800 };
801
802 static struct tegra_spi_device_controller_data dev_cdata = {
803         .rx_clk_tap_delay = 0,
804         .tx_clk_tap_delay = 0,
805 };
806
807 struct spi_board_info rm31080a_pluto_spi_board[1] = {
808         {
809          .modalias = "rm_ts_spidev",
810          .bus_num = 3,
811          .chip_select = 2,
812          .max_speed_hz = 12 * 1000 * 1000,
813          .mode = SPI_MODE_0,
814          .controller_data = &dev_cdata,
815          .platform_data = &rm31080ts_pluto_data,
816          },
817 };
818
819 static int __init pluto_touch_init(void)
820 {
821         tegra_clk_init_from_table(touch_clk_init_table);
822         clk_enable(tegra_get_clock_by_name("clk_out_2"));
823         rm31080ts_pluto_data.platform_id = RM_PLATFORM_P005;
824         rm31080a_pluto_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
825         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
826                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
827                                 &rm31080ts_pluto_data,
828                                 &rm31080a_pluto_spi_board[0],
829                                 ARRAY_SIZE(rm31080a_pluto_spi_board));
830         return 0;
831 }
832
833 static void __init tegra_pluto_init(void)
834 {
835         tegra_battery_edp_init(2500);
836         tegra_clk_init_from_table(pluto_clk_init_table);
837         tegra_soc_device_init("tegra_pluto");
838         tegra_enable_pinmux();
839         pluto_pinmux_init();
840         pluto_i2c_init();
841         pluto_spi_init();
842         pluto_usb_init();
843         pluto_edp_init();
844         pluto_uart_init();
845         pluto_audio_init();
846         platform_add_devices(pluto_devices, ARRAY_SIZE(pluto_devices));
847         //tegra_ram_console_debug_init();
848         tegra_io_dpd_init();
849         pluto_sdhci_init();
850         pluto_regulator_init();
851         pluto_suspend_init();
852         pluto_touch_init();
853         pluto_emc_init();
854         pluto_panel_init();
855         pluto_pmon_init();
856         pluto_kbc_init();
857         pluto_setup_bluesleep();
858         pluto_setup_bt_rfkill();
859         tegra_release_bootloader_fb();
860         pluto_modem_init();
861 #ifdef CONFIG_TEGRA_WDT_RECOVERY
862         tegra_wdt_recovery_init();
863 #endif
864         pluto_sensors_init();
865         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
866 }
867
868 static void __init pluto_ramconsole_reserve(unsigned long size)
869 {
870         tegra_ram_console_debug_reserve(SZ_1M);
871 }
872
873 static void __init tegra_pluto_dt_init(void)
874 {
875         tegra_pluto_init();
876
877         of_platform_populate(NULL,
878                 of_default_bus_match_table, NULL, NULL);
879 }
880
881 static void __init tegra_pluto_reserve(void)
882 {
883 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
884         /* for PANEL_5_SHARP_1080p: 1920*1080*4*2 = 16588800 bytes */
885         tegra_reserve(0, SZ_16M, SZ_4M);
886 #else
887         tegra_reserve(SZ_128M, SZ_16M, SZ_4M);
888 #endif
889         pluto_ramconsole_reserve(SZ_1M);
890 }
891
892 static const char * const pluto_dt_board_compat[] = {
893         "nvidia,pluto",
894         NULL
895 };
896
897 MACHINE_START(TEGRA_PLUTO, "tegra_pluto")
898         .atag_offset    = 0x100,
899         .smp            = smp_ops(tegra_smp_ops),
900         .map_io         = tegra_map_common_io,
901         .reserve        = tegra_pluto_reserve,
902 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
903         .init_early     = tegra30_init_early,
904 #else
905         .init_early     = tegra11x_init_early,
906 #endif
907         .init_irq       = tegra_init_irq,
908         .handle_irq     = gic_handle_irq,
909         .timer          = &tegra_timer,
910         .init_machine   = tegra_pluto_dt_init,
911         .restart        = tegra_assert_system_reset,
912         .dt_compat      = pluto_dt_board_compat,
913 MACHINE_END