ARM: tegra: pluto: Disable USB host on USB1
[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/tegra-bb-power.h>
70 #include <mach/edp.h>
71 #include <mach/tegra_usb_modem_power.h>
72
73 #include "board.h"
74 #include "board-common.h"
75 #include "board-touch-raydium.h"
76 #include "clock.h"
77 #include "board-pluto.h"
78 #include "tegra-board-id.h"
79 #include "devices.h"
80 #include "gpio-names.h"
81 #include "fuse.h"
82 #include "pm.h"
83 #include "common.h"
84
85 static struct rfkill_gpio_platform_data pluto_bt_rfkill_pdata = {
86         .name           = "bt_rfkill",
87         .shutdown_gpio  = TEGRA_GPIO_PQ7,
88         .reset_gpio     = TEGRA_GPIO_PQ6,
89         .type           = RFKILL_TYPE_BLUETOOTH,
90 };
91
92 static struct platform_device pluto_bt_rfkill_device = {
93         .name = "rfkill_gpio",
94         .id             = -1,
95         .dev = {
96                 .platform_data = &pluto_bt_rfkill_pdata,
97         },
98 };
99
100 static noinline void __init pluto_setup_bt_rfkill(void)
101 {
102         platform_device_register(&pluto_bt_rfkill_device);
103 }
104
105 static struct resource pluto_bluesleep_resources[] = {
106         [0] = {
107                 .name = "gpio_host_wake",
108                         .start  = TEGRA_GPIO_PU6,
109                         .end    = TEGRA_GPIO_PU6,
110                         .flags  = IORESOURCE_IO,
111         },
112         [1] = {
113                 .name = "gpio_ext_wake",
114                         .start  = TEGRA_GPIO_PEE1,
115                         .end    = TEGRA_GPIO_PEE1,
116                         .flags  = IORESOURCE_IO,
117         },
118         [2] = {
119                 .name = "host_wake",
120                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
121         },
122 };
123
124 static struct platform_device pluto_bluesleep_device = {
125         .name           = "bluesleep",
126         .id             = -1,
127         .num_resources  = ARRAY_SIZE(pluto_bluesleep_resources),
128         .resource       = pluto_bluesleep_resources,
129 };
130
131 static noinline void __init pluto_setup_bluesleep(void)
132 {
133         pluto_bluesleep_resources[2].start =
134                 pluto_bluesleep_resources[2].end =
135                         gpio_to_irq(TEGRA_GPIO_PU6);
136         platform_device_register(&pluto_bluesleep_device);
137         return;
138 }
139 static __initdata struct tegra_clk_init_table pluto_clk_init_table[] = {
140         /* name         parent          rate            enabled */
141         { "pll_m",      NULL,           0,              false},
142         { "hda",        "pll_p",        108000000,      false},
143         { "hda2codec_2x", "pll_p",      48000000,       false},
144         { "pwm",        "pll_p",        3187500,        false},
145         { "i2s1",       "pll_a_out0",   0,              false},
146         { "i2s2",       "pll_a_out0",   0,              false},
147         { "i2s3",       "pll_a_out0",   0,              false},
148         { "i2s4",       "pll_a_out0",   0,              false},
149         { "spdif_out",  "pll_a_out0",   0,              false},
150         { "d_audio",    "clk_m",        12000000,       false},
151         { "dam0",       "clk_m",        12000000,       false},
152         { "dam1",       "clk_m",        12000000,       false},
153         { "dam2",       "clk_m",        12000000,       false},
154         { "audio1",     "i2s1_sync",    0,              false},
155         { "audio2",     "i2s2_sync",    0,              false},
156         { "audio3",     "i2s3_sync",    0,              false},
157         { "audio4",     "i2s4_sync",    0,              false},
158         { "vi_sensor",  "pll_p",        150000000,      false},
159         { "cilab",      "pll_p",        150000000,      false},
160         { "cilcd",      "pll_p",        150000000,      false},
161         { "cile",       "pll_p",        150000000,      false},
162         { "i2c1",       "pll_p",        3200000,        false},
163         { "i2c2",       "pll_p",        3200000,        false},
164         { "i2c3",       "pll_p",        3200000,        false},
165         { "i2c4",       "pll_p",        3200000,        false},
166         { "i2c5",       "pll_p",        3200000,        false},
167         { "extern3",    "clk_m",        12000000,       false},
168         { NULL,         NULL,           0,              0},
169 };
170
171 static struct tegra_i2c_platform_data pluto_i2c1_platform_data = {
172         .adapter_nr     = 0,
173         .bus_count      = 1,
174         .bus_clk_rate   = { 100000, 0 },
175         .scl_gpio               = {TEGRA_GPIO_I2C1_SCL, 0},
176         .sda_gpio               = {TEGRA_GPIO_I2C1_SDA, 0},
177         .arb_recovery = arb_lost_recovery,
178 };
179
180 static struct tegra_i2c_platform_data pluto_i2c2_platform_data = {
181         .adapter_nr     = 1,
182         .bus_count      = 1,
183         .bus_clk_rate   = { 100000, 0 },
184         .is_clkon_always = true,
185         .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
186         .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
187         .arb_recovery = arb_lost_recovery,
188 };
189
190 static struct tegra_i2c_platform_data pluto_i2c3_platform_data = {
191         .adapter_nr     = 2,
192         .bus_count      = 1,
193         .bus_clk_rate   = { 100000, 0 },
194         .scl_gpio               = {TEGRA_GPIO_I2C3_SCL, 0},
195         .sda_gpio               = {TEGRA_GPIO_I2C3_SDA, 0},
196         .arb_recovery = arb_lost_recovery,
197 };
198
199 static struct tegra_i2c_platform_data pluto_i2c4_platform_data = {
200         .adapter_nr     = 3,
201         .bus_count      = 1,
202         .bus_clk_rate   = { 10000, 0 },
203         .scl_gpio               = {TEGRA_GPIO_I2C4_SCL, 0},
204         .sda_gpio               = {TEGRA_GPIO_I2C4_SDA, 0},
205         .arb_recovery = arb_lost_recovery,
206 };
207
208 static struct tegra_i2c_platform_data pluto_i2c5_platform_data = {
209         .adapter_nr     = 4,
210         .bus_count      = 1,
211         .bus_clk_rate   = { 400000, 0 },
212         .scl_gpio               = {TEGRA_GPIO_I2C5_SCL, 0},
213         .sda_gpio               = {TEGRA_GPIO_I2C5_SDA, 0},
214         .arb_recovery = arb_lost_recovery,
215 };
216
217 static struct i2c_board_info __initdata cs42l73_board_info = {
218         I2C_BOARD_INFO("cs42l73", 0x4a),
219 };
220
221 static struct i2c_board_info __initdata pluto_codec_a2220_info = {
222         I2C_BOARD_INFO("audience_a2220", 0x3E),
223 };
224
225
226 static void pluto_i2c_init(void)
227 {
228         struct board_info board_info;
229
230         tegra_get_board_info(&board_info);
231 #ifndef CONFIG_ARCH_TEGRA_11x_SOC
232         tegra_i2c_device1.dev.platform_data = &pluto_i2c1_platform_data;
233         tegra_i2c_device2.dev.platform_data = &pluto_i2c2_platform_data;
234         tegra_i2c_device3.dev.platform_data = &pluto_i2c3_platform_data;
235         tegra_i2c_device4.dev.platform_data = &pluto_i2c4_platform_data;
236         tegra_i2c_device5.dev.platform_data = &pluto_i2c5_platform_data;
237
238         i2c_register_board_info(1, &pluto_i2c_led_info, 1);
239
240         platform_device_register(&tegra_i2c_device5);
241         platform_device_register(&tegra_i2c_device4);
242         platform_device_register(&tegra_i2c_device3);
243         platform_device_register(&tegra_i2c_device2);
244         platform_device_register(&tegra_i2c_device1);
245
246 #else
247         tegra11_i2c_device1.dev.platform_data = &pluto_i2c1_platform_data;
248         tegra11_i2c_device2.dev.platform_data = &pluto_i2c2_platform_data;
249         tegra11_i2c_device3.dev.platform_data = &pluto_i2c3_platform_data;
250         tegra11_i2c_device4.dev.platform_data = &pluto_i2c4_platform_data;
251         tegra11_i2c_device5.dev.platform_data = &pluto_i2c5_platform_data;
252
253         platform_device_register(&tegra11_i2c_device5);
254         platform_device_register(&tegra11_i2c_device4);
255         platform_device_register(&tegra11_i2c_device3);
256         platform_device_register(&tegra11_i2c_device2);
257         platform_device_register(&tegra11_i2c_device1);
258
259 #endif
260
261         i2c_register_board_info(0, &pluto_codec_a2220_info, 1);
262         i2c_register_board_info(0, &cs42l73_board_info, 1);
263 }
264
265 static struct platform_device *pluto_uart_devices[] __initdata = {
266         &tegra_uarta_device,
267         &tegra_uartb_device,
268         &tegra_uartc_device,
269         &tegra_uartd_device,
270 };
271 static struct uart_clk_parent uart_parent_clk[] = {
272         [0] = {.name = "clk_m"},
273         [1] = {.name = "pll_p"},
274 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
275         [2] = {.name = "pll_m"},
276 #endif
277 };
278
279 static struct tegra_uart_platform_data pluto_uart_pdata;
280 static struct tegra_uart_platform_data pluto_loopback_uart_pdata;
281
282 static void __init uart_debug_init(void)
283 {
284         int debug_port_id;
285
286         debug_port_id = uart_console_debug_init(3);
287         if (debug_port_id < 0)
288                 return;
289         pluto_uart_devices[debug_port_id] = uart_console_debug_device;
290 }
291
292 static void __init pluto_uart_init(void)
293 {
294         struct clk *c;
295         int i;
296
297         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
298                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
299                 if (IS_ERR_OR_NULL(c)) {
300                         pr_err("Not able to get the clock for %s\n",
301                                                 uart_parent_clk[i].name);
302                         continue;
303                 }
304                 uart_parent_clk[i].parent_clk = c;
305                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
306         }
307         pluto_uart_pdata.parent_clk_list = uart_parent_clk;
308         pluto_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
309         pluto_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
310         pluto_loopback_uart_pdata.parent_clk_count =
311                                                 ARRAY_SIZE(uart_parent_clk);
312         pluto_loopback_uart_pdata.is_loopback = true;
313         tegra_uarta_device.dev.platform_data = &pluto_uart_pdata;
314         tegra_uartb_device.dev.platform_data = &pluto_uart_pdata;
315         tegra_uartc_device.dev.platform_data = &pluto_uart_pdata;
316         tegra_uartd_device.dev.platform_data = &pluto_uart_pdata;
317
318         /* Register low speed only if it is selected */
319         if (!is_tegra_debug_uartport_hs())
320                 uart_debug_init();
321
322         platform_add_devices(pluto_uart_devices,
323                                 ARRAY_SIZE(pluto_uart_devices));
324 }
325
326 static struct resource tegra_rtc_resources[] = {
327         [0] = {
328                 .start = TEGRA_RTC_BASE,
329                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
330                 .flags = IORESOURCE_MEM,
331         },
332         [1] = {
333                 .start = INT_RTC,
334                 .end = INT_RTC,
335                 .flags = IORESOURCE_IRQ,
336         },
337 };
338
339 static struct platform_device tegra_rtc_device = {
340         .name = "tegra_rtc",
341         .id   = -1,
342         .resource = tegra_rtc_resources,
343         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
344 };
345
346 static struct tegra_asoc_platform_data pluto_audio_pdata = {
347         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
348         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
349         .gpio_hp_mute           = -1,
350         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
351         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
352         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
353         .i2s_param[HIFI_CODEC]  = {
354                 .audio_port_id  = 1,
355                 .is_i2s_master  = 0,
356                 .i2s_mode       = TEGRA_DAIFMT_I2S,
357                 .sample_size    = 16,
358                 .channels       = 2,
359         },
360         .i2s_param[BASEBAND]    = {
361                 .audio_port_id  = 2,
362                 .is_i2s_master  = 1,
363                 .i2s_mode       = TEGRA_DAIFMT_I2S,
364                 .sample_size    = 16,
365                 .rate           = 16000,
366                 .channels       = 2,
367         },
368         .i2s_param[BT_SCO]      = {
369                 .audio_port_id  = 3,
370                 .is_i2s_master  = 1,
371                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
372                 .sample_size    = 16,
373         },
374 };
375
376 static struct platform_device pluto_audio_device = {
377         .name   = "tegra-snd-cs42l73",
378         .id     = 2,
379         .dev    = {
380                 .platform_data = &pluto_audio_pdata,
381         },
382 };
383
384 static struct platform_device tegra_camera = {
385         .name = "tegra_camera",
386         .id = -1,
387 };
388
389 #ifdef CONFIG_MHI_NETDEV
390 struct platform_device mhi_netdevice0 = {
391         .name = "mhi_net_device",
392         .id = 0,
393 };
394 #endif /* CONFIG_MHI_NETDEV */
395
396 static struct platform_device *pluto_devices[] __initdata = {
397         &tegra_pmu_device,
398         &tegra_rtc_device,
399         &tegra_udc_device,
400 #if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
401         &tegra_smmu_device,
402 #endif
403 #if defined(CONFIG_TEGRA_AVP)
404         &tegra_avp_device,
405 #endif
406         &tegra_camera,
407 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
408         &tegra11_se_device,
409 #endif
410         &tegra_ahub_device,
411         &tegra_dam_device0,
412         &tegra_dam_device1,
413         &tegra_dam_device2,
414         &tegra_i2s_device0,
415         &tegra_i2s_device1,
416         &tegra_i2s_device2,
417         &tegra_i2s_device3,
418         &tegra_i2s_device4,
419         &tegra_spdif_device,
420         &spdif_dit_device,
421         &bluetooth_dit_device,
422         &baseband_dit_device,
423         &pluto_audio_device,
424         &tegra_hda_device,
425 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
426         &tegra_aes_device,
427 #endif
428 #ifdef CONFIG_MHI_NETDEV
429         &mhi_netdevice0,  /* MHI netdevice */
430 #endif /* CONFIG_MHI_NETDEV */
431 };
432
433 #ifdef CONFIG_USB_SUPPORT
434 static struct tegra_usb_platform_data tegra_ehci3_hsic_smsc_hub_pdata = {
435         .port_otg = false,
436         .has_hostpc = true,
437         .unaligned_dma_buf_supported = false,
438         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
439         .op_mode        = TEGRA_USB_OPMODE_HOST,
440         .u_data.host = {
441                 .vbus_gpio = -1,
442                 .hot_plug = false,
443                 .remote_wakeup_supported = true,
444                 .power_off_on_suspend = true,
445         },
446 };
447
448 static struct tegra_usb_platform_data tegra_udc_pdata = {
449         .port_otg = true,
450         .has_hostpc = true,
451         .builtin_host_disabled = true,
452         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
453         .op_mode = TEGRA_USB_OPMODE_DEVICE,
454         .u_data.dev = {
455                 .vbus_pmu_irq = 0,
456                 .vbus_gpio = -1,
457                 .charging_supported = false,
458                 .remote_wakeup_supported = false,
459         },
460         .u_cfg.utmi = {
461                 .hssync_start_delay = 0,
462                 .elastic_limit = 16,
463                 .idle_wait_delay = 17,
464                 .term_range_adj = 6,
465                 .xcvr_setup = 8,
466                 .xcvr_lsfslew = 2,
467                 .xcvr_lsrslew = 2,
468                 .xcvr_setup_offset = 0,
469                 .xcvr_use_fuses = 1,
470         },
471 };
472
473 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
474         .port_otg = true,
475         .has_hostpc = true,
476         .builtin_host_disabled = true,
477         .unaligned_dma_buf_supported = false,
478         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
479         .op_mode = TEGRA_USB_OPMODE_HOST,
480         .u_data.host = {
481                 .vbus_gpio = -1,
482                 .hot_plug = true,
483                 .remote_wakeup_supported = true,
484                 .power_off_on_suspend = true,
485         },
486         .u_cfg.utmi = {
487                 .hssync_start_delay = 0,
488                 .elastic_limit = 16,
489                 .idle_wait_delay = 17,
490                 .term_range_adj = 6,
491                 .xcvr_setup = 15,
492                 .xcvr_lsfslew = 2,
493                 .xcvr_lsrslew = 2,
494                 .xcvr_setup_offset = 0,
495                 .xcvr_use_fuses = 1,
496         },
497 };
498
499 static struct tegra_usb_otg_data tegra_otg_pdata = {
500         .ehci_device = &tegra_ehci1_device,
501         .ehci_pdata = &tegra_ehci1_utmi_pdata,
502 };
503
504 static struct regulator *baseband_reg;
505 static struct gpio modem_gpios[] = { /* i500 modem */
506         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
507 };
508
509 static struct gpio modem2_gpios[] = {
510         {MDM2_PWR_ON, GPIOF_OUT_INIT_LOW, "MODEM2 PWR ON"},
511         {MDM2_RST, GPIOF_DIR_OUT, "MODEM2 RESET"},
512         {MDM2_ACK2, GPIOF_OUT_INIT_HIGH, "MODEM2 ACK2"},
513         {MDM2_ACK1, GPIOF_OUT_INIT_LOW, "MODEM2 ACK1"},
514 };
515
516 static void baseband2_post_phy_on(void);
517 static void baseband2_pre_phy_off(void);
518
519 static struct tegra_usb_phy_platform_ops baseband2_plat_ops = {
520         .pre_phy_off = baseband2_pre_phy_off,
521         .post_phy_on = baseband2_post_phy_on,
522 };
523
524 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
525         .port_otg = false,
526         .has_hostpc = true,
527         .unaligned_dma_buf_supported = false,
528         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
529         .op_mode = TEGRA_USB_OPMODE_HOST,
530         .u_data.host = {
531                 .vbus_gpio = -1,
532                 .hot_plug = false,
533                 .remote_wakeup_supported = false,
534                 .power_off_on_suspend = false,
535         },
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 #ifdef CONFIG_TEGRA_BB_OEM1
558 static struct tegra_usb_platform_data tegra_hsic_pdata = {
559         .port_otg = false,
560         .has_hostpc = true,
561         .unaligned_dma_buf_supported = false,
562         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
563         .op_mode        = TEGRA_USB_OPMODE_HOST,
564         .u_data.host = {
565                 .vbus_gpio = -1,
566                 .hot_plug = false,
567                 .remote_wakeup_supported = true,
568                 .power_off_on_suspend = true,
569         },
570 };
571
572 static struct platform_device *
573 tegra_usb_hsic_host_register(struct platform_device *ehci_dev)
574 {
575         struct platform_device *pdev;
576         int val;
577
578         pdev = platform_device_alloc(ehci_dev->name, ehci_dev->id);
579         if (!pdev)
580                 return NULL;
581
582         val = platform_device_add_resources(pdev, ehci_dev->resource,
583                                                 ehci_dev->num_resources);
584         if (val)
585                 goto error;
586
587         pdev->dev.dma_mask =  ehci_dev->dev.dma_mask;
588         pdev->dev.coherent_dma_mask = ehci_dev->dev.coherent_dma_mask;
589
590         val = platform_device_add_data(pdev, &tegra_hsic_pdata,
591                         sizeof(struct tegra_usb_platform_data));
592         if (val)
593                 goto error;
594
595         val = platform_device_add(pdev);
596         if (val)
597                 goto error;
598
599         return pdev;
600
601 error:
602         pr_err("%s: failed to add the host contoller device\n", __func__);
603         platform_device_put(pdev);
604         return NULL;
605 }
606
607 static void tegra_usb_hsic_host_unregister(struct platform_device **platdev)
608 {
609         struct platform_device *pdev = *platdev;
610
611         if (pdev && &pdev->dev) {
612                 platform_device_unregister(pdev);
613                 *platdev = NULL;
614         } else
615                 pr_err("%s: no platform device\n", __func__);
616 }
617
618 static struct tegra_usb_phy_platform_ops oem1_hsic_pops;
619
620 static union tegra_bb_gpio_id bb_gpio_oem1 = {
621         .oem1 = {
622                 .reset = BB_OEM1_GPIO_RST,
623                 .pwron = BB_OEM1_GPIO_ON,
624                 .awr = BB_OEM1_GPIO_AWR,
625                 .cwr = BB_OEM1_GPIO_CWR,
626                 .spare = BB_OEM1_GPIO_SPARE,
627                 .wdi = BB_OEM1_GPIO_WDI,
628         },
629 };
630
631 static struct tegra_bb_pdata bb_pdata_oem1 = {
632         .id = &bb_gpio_oem1,
633         .device = &tegra_ehci3_device,
634         .ehci_register = tegra_usb_hsic_host_register,
635         .ehci_unregister = tegra_usb_hsic_host_unregister,
636         .bb_id = TEGRA_BB_OEM1,
637 };
638
639 static struct platform_device tegra_bb_oem1 = {
640         .name = "tegra_baseband_power",
641         .id = -1,
642         .dev = {
643                 .platform_data = &bb_pdata_oem1,
644         },
645 };
646 #endif
647
648 static int baseband_init(void)
649 {
650         int ret;
651
652         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
653         if (ret) {
654                 pr_warn("%s:gpio request failed\n", __func__);
655                 return ret;
656         }
657
658         baseband_reg = regulator_get(NULL, "vdd_core_bb");
659         if (IS_ERR_OR_NULL(baseband_reg))
660                 pr_warn("%s: baseband regulator get failed\n", __func__);
661         else
662                 regulator_enable(baseband_reg);
663
664         /* enable pull-down for MDM1_COLD_BOOT */
665         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
666                                     TEGRA_PUPD_PULL_DOWN);
667
668         /* export GPIO for user space access through sysfs */
669         gpio_export(MDM_RST, false);
670
671         return 0;
672 }
673
674 static const struct tegra_modem_operations baseband_operations = {
675         .init = baseband_init,
676 };
677
678 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
679         .ops = &baseband_operations,
680         .wake_gpio = -1,
681         .boot_gpio = MDM_COLDBOOT,
682         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
683         .autosuspend_delay = 2000,
684         .short_autosuspend_delay = 50,
685         .tegra_ehci_device = &tegra_ehci2_device,
686         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
687 };
688
689 static struct platform_device icera_baseband_device = {
690         .name = "tegra_usb_modem_power",
691         .id = -1,
692         .dev = {
693                 .platform_data = &baseband_pdata,
694         },
695 };
696
697 static void baseband2_post_phy_on(void)
698 {
699         /* set MDM2_ACK2 low */
700         gpio_set_value(MDM2_ACK2, 0);
701 }
702
703 static void baseband2_pre_phy_off(void)
704 {
705         /* set MDM2_ACK2 high */
706         gpio_set_value(MDM2_ACK2, 1);
707 }
708
709 static void baseband2_start(void)
710 {
711         /*
712          *  Leave baseband powered OFF.
713          *  User-space daemons will take care of powering it up.
714          */
715         pr_info("%s\n", __func__);
716         gpio_set_value(MDM2_PWR_ON, 0);
717 }
718
719 static void baseband2_reset(void)
720 {
721         /* Initiate power cycle on baseband sub system */
722         pr_info("%s\n", __func__);
723         gpio_set_value(MDM2_PWR_ON, 0);
724         mdelay(200);
725         gpio_set_value(MDM2_PWR_ON, 1);
726 }
727
728 static int baseband2_init(void)
729 {
730         int ret;
731
732         ret = gpio_request_array(modem2_gpios, ARRAY_SIZE(modem2_gpios));
733         if (ret)
734                 return ret;
735
736         /* enable pull-up for MDM2_REQ2 */
737         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PV1,
738                                     TEGRA_PUPD_PULL_UP);
739
740         /* export GPIO for user space access through sysfs */
741         gpio_export(MDM2_PWR_ON, false);
742
743         return 0;
744 }
745
746 static const struct tegra_modem_operations baseband2_operations = {
747         .init = baseband2_init,
748         .start = baseband2_start,
749         .reset = baseband2_reset,
750 };
751
752 static struct tegra_usb_modem_power_platform_data baseband2_pdata = {
753         .ops = &baseband2_operations,
754         .wake_gpio = MDM2_REQ2,
755         .wake_irq_flags = IRQF_TRIGGER_FALLING,
756         .boot_gpio = MDM2_COLDBOOT,
757         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
758         .autosuspend_delay = 2000,
759         .short_autosuspend_delay = 50,
760 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
761         .tegra_ehci_device = &tegra_ehci3_device,
762         .tegra_ehci_pdata = &tegra_ehci3_hsic_baseband2_pdata,
763 #else
764         .tegra_ehci_device = &tegra_ehci2_device,
765         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband2_pdata,
766 #endif
767 };
768
769 static struct platform_device icera_baseband2_device = {
770         .name = "tegra_usb_modem_power",
771         .id = -1,
772         .dev = {
773                 .platform_data = &baseband2_pdata,
774         },
775 };
776
777 static void pluto_usb_init(void)
778 {
779         int modem_id = tegra_get_modem_id();
780
781         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
782         platform_device_register(&tegra_otg_device);
783
784         /* Setup the udc platform data */
785         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
786
787         if (!modem_id) {
788                 tegra_ehci3_device.dev.platform_data =
789                         &tegra_ehci3_hsic_smsc_hub_pdata;
790                 platform_device_register(&tegra_ehci3_device);
791         }
792 }
793
794 static void pluto_modem_init(void)
795 {
796         int modem_id = tegra_get_modem_id();
797         struct board_info board_info;
798
799         tegra_get_board_info(&board_info);
800         pr_info("%s: modem_id = %d\n", __func__, modem_id);
801
802         switch (modem_id) {
803         case TEGRA_BB_I500: /* on board i500 HSIC */
804                 platform_device_register(&icera_baseband_device);
805                 break;
806         case TEGRA_BB_I500SWD: /* i500 SWD HSIC */
807                 platform_device_register(&icera_baseband2_device);
808                 break;
809 #ifdef CONFIG_TEGRA_BB_OEM1
810         case TEGRA_BB_OEM1:     /* OEM1 HSIC */
811                 if (board_info.board_id == BOARD_E1575)
812                         bb_gpio_oem1.oem1.pwron = BB_OEM1_GPIO_ON_V;
813                 tegra_hsic_pdata.ops = &oem1_hsic_pops;
814                 tegra_ehci3_device.dev.platform_data
815                         = &tegra_hsic_pdata;
816                 platform_device_register(&tegra_bb_oem1);
817                 break;
818 #endif
819         default:
820                 return;
821         }
822 }
823
824 #else
825 static void pluto_usb_init(void) { }
826 static void pluto_modem_init(void) { }
827 #endif
828
829 static void pluto_audio_init(void)
830 {
831         struct board_info board_info;
832
833         tegra_get_board_info(&board_info);
834
835         pluto_audio_pdata.codec_name = "cs42l73.0-004a";
836         pluto_audio_pdata.codec_dai_name = "cs42l73-vsp";
837 }
838
839 static struct platform_device *pluto_spi_devices[] __initdata = {
840         &tegra11_spi_device4,
841 };
842
843 struct spi_clk_parent spi_parent_clk_pluto[] = {
844         [0] = {.name = "pll_p"},
845 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
846         [1] = {.name = "pll_m"},
847         [2] = {.name = "clk_m"},
848 #else
849         [1] = {.name = "clk_m"},
850 #endif
851 };
852
853 static struct tegra_spi_platform_data pluto_spi_pdata = {
854         .is_dma_based           = false,
855         .max_dma_buffer         = 16 * 1024,
856         .is_clkon_always        = false,
857         .max_rate               = 25000000,
858 };
859
860 static void __init pluto_spi_init(void)
861 {
862         int i;
863         struct clk *c;
864         struct board_info board_info, display_board_info;
865
866         tegra_get_board_info(&board_info);
867         tegra_get_display_board_info(&display_board_info);
868
869         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_pluto); ++i) {
870                 c = tegra_get_clock_by_name(spi_parent_clk_pluto[i].name);
871                 if (IS_ERR_OR_NULL(c)) {
872                         pr_err("Not able to get the clock for %s\n",
873                                                 spi_parent_clk_pluto[i].name);
874                         continue;
875                 }
876                 spi_parent_clk_pluto[i].parent_clk = c;
877                 spi_parent_clk_pluto[i].fixed_clk_rate = clk_get_rate(c);
878         }
879         pluto_spi_pdata.parent_clk_list = spi_parent_clk_pluto;
880         pluto_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_pluto);
881         tegra11_spi_device4.dev.platform_data = &pluto_spi_pdata;
882         platform_add_devices(pluto_spi_devices,
883                                 ARRAY_SIZE(pluto_spi_devices));
884 }
885
886 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
887         /* name         parent          rate            enabled */
888         { "extern2",    "pll_p",        41000000,       false},
889         { "clk_out_2",  "extern2",      40800000,       false},
890         { NULL,         NULL,           0,              0},
891 };
892
893 struct rm_spi_ts_platform_data rm31080ts_pluto_data = {
894         .gpio_reset = 0,
895         .config = 0,
896         .platform_id = RM_PLATFORM_P005,
897         .name_of_clock = "clk_out_2",
898 };
899
900 static struct tegra_spi_device_controller_data dev_cdata = {
901         .rx_clk_tap_delay = 0,
902         .tx_clk_tap_delay = 0,
903 };
904
905 struct spi_board_info rm31080a_pluto_spi_board[1] = {
906         {
907          .modalias = "rm_ts_spidev",
908          .bus_num = 3,
909          .chip_select = 2,
910          .max_speed_hz = 12 * 1000 * 1000,
911          .mode = SPI_MODE_0,
912          .controller_data = &dev_cdata,
913          .platform_data = &rm31080ts_pluto_data,
914          },
915 };
916
917 static int __init pluto_touch_init(void)
918 {
919         tegra_clk_init_from_table(touch_clk_init_table);
920         clk_enable(tegra_get_clock_by_name("clk_out_2"));
921         mdelay(20);
922         rm31080a_pluto_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
923         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
924                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
925                                 &rm31080ts_pluto_data,
926                                 &rm31080a_pluto_spi_board[0],
927                                 ARRAY_SIZE(rm31080a_pluto_spi_board));
928         return 0;
929 }
930
931 static void __init tegra_pluto_init(void)
932 {
933         tegra_battery_edp_init(3250);
934         tegra_clk_init_from_table(pluto_clk_init_table);
935         tegra_soc_device_init("tegra_pluto");
936         tegra_enable_pinmux();
937         pluto_pinmux_init();
938         pluto_i2c_init();
939         pluto_spi_init();
940         pluto_usb_init();
941         pluto_edp_init();
942         pluto_uart_init();
943         pluto_audio_init();
944         platform_add_devices(pluto_devices, ARRAY_SIZE(pluto_devices));
945         //tegra_ram_console_debug_init();
946         tegra_io_dpd_init();
947         pluto_sdhci_init();
948         pluto_regulator_init();
949         pluto_suspend_init();
950         pluto_touch_init();
951         pluto_emc_init();
952         pluto_panel_init();
953         pluto_pmon_init();
954         pluto_kbc_init();
955         pluto_setup_bluesleep();
956         pluto_setup_bt_rfkill();
957         tegra_release_bootloader_fb();
958         pluto_modem_init();
959 #ifdef CONFIG_TEGRA_WDT_RECOVERY
960         tegra_wdt_recovery_init();
961 #endif
962         pluto_sensors_init();
963         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
964         pluto_soctherm_init();
965 }
966
967 static void __init pluto_ramconsole_reserve(unsigned long size)
968 {
969         tegra_ram_console_debug_reserve(SZ_1M);
970 }
971
972 static void __init tegra_pluto_dt_init(void)
973 {
974         tegra_pluto_init();
975
976         of_platform_populate(NULL,
977                 of_default_bus_match_table, NULL, NULL);
978 }
979
980 static void __init tegra_pluto_reserve(void)
981 {
982 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
983         /* for PANEL_5_SHARP_1080p: 1920*1080*4*2 = 16588800 bytes */
984         tegra_reserve(0, SZ_16M, SZ_4M);
985 #else
986         tegra_reserve(SZ_128M, SZ_16M, SZ_4M);
987 #endif
988         pluto_ramconsole_reserve(SZ_1M);
989 }
990
991 static const char * const pluto_dt_board_compat[] = {
992         "nvidia,pluto",
993         NULL
994 };
995
996 MACHINE_START(TEGRA_PLUTO, "tegra_pluto")
997         .atag_offset    = 0x100,
998         .smp            = smp_ops(tegra_smp_ops),
999         .map_io         = tegra_map_common_io,
1000         .reserve        = tegra_pluto_reserve,
1001 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
1002         .init_early     = tegra30_init_early,
1003 #else
1004         .init_early     = tegra11x_init_early,
1005 #endif
1006         .init_irq       = tegra_init_irq,
1007         .handle_irq     = gic_handle_irq,
1008         .timer          = &tegra_timer,
1009         .init_machine   = tegra_pluto_dt_init,
1010         .restart        = tegra_assert_system_reset,
1011         .dt_compat      = pluto_dt_board_compat,
1012 MACHINE_END