arm: tegra: fuse: Registered tegra-fuse device in T114 board files
[linux-3.10.git] / arch / arm / mach-tegra / board-dalmore.c
1 /*
2  * arch/arm/mach-tegra/board-dalmore.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/of_platform.h>
49 #include <linux/edp.h>
50
51 #include <asm/hardware/gic.h>
52
53 #include <mach/clk.h>
54 #include <mach/iomap.h>
55 #include <mach/irqs.h>
56 #include <mach/pinmux.h>
57 #include <mach/pinmux-tegra30.h>
58 #include <mach/iomap.h>
59 #include <mach/io.h>
60 #include <mach/io_dpd.h>
61 #include <mach/i2s.h>
62 #include <mach/tegra_asoc_pdata.h>
63 #include <asm/mach-types.h>
64 #include <asm/mach/arch.h>
65 #include <mach/usb_phy.h>
66 #include <mach/gpio-tegra.h>
67 #include <mach/tegra_fiq_debugger.h>
68 #include <mach/tegra_usb_modem_power.h>
69
70 #include "board-touch-raydium.h"
71 #include "board.h"
72 #include "board-common.h"
73 #include "clock.h"
74 #include "board-dalmore.h"
75 #include "devices.h"
76 #include "gpio-names.h"
77 #include "fuse.h"
78 #include "pm.h"
79 #include "pm-irq.h"
80 #include "common.h"
81 #include "tegra-board-id.h"
82
83 static struct board_info board_info, display_board_info;
84
85 #ifdef CONFIG_BT_BLUESLEEP
86 static struct rfkill_gpio_platform_data dalmore_bt_rfkill_pdata = {
87                 .name           = "bt_rfkill",
88                 .shutdown_gpio  = TEGRA_GPIO_PQ7,
89                 .reset_gpio     = TEGRA_GPIO_PQ6,
90                 .type           = RFKILL_TYPE_BLUETOOTH,
91 };
92
93 static struct platform_device dalmore_bt_rfkill_device = {
94         .name = "rfkill_gpio",
95         .id             = -1,
96         .dev = {
97                 .platform_data = &dalmore_bt_rfkill_pdata,
98         },
99 };
100
101 static struct resource dalmore_bluesleep_resources[] = {
102         [0] = {
103                 .name = "gpio_host_wake",
104                         .start  = TEGRA_GPIO_PU6,
105                         .end    = TEGRA_GPIO_PU6,
106                         .flags  = IORESOURCE_IO,
107         },
108         [1] = {
109                 .name = "gpio_ext_wake",
110                         .start  = TEGRA_GPIO_PEE1,
111                         .end    = TEGRA_GPIO_PEE1,
112                         .flags  = IORESOURCE_IO,
113         },
114         [2] = {
115                 .name = "host_wake",
116                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
117         },
118 };
119
120 static struct platform_device dalmore_bluesleep_device = {
121         .name           = "bluesleep",
122         .id             = -1,
123         .num_resources  = ARRAY_SIZE(dalmore_bluesleep_resources),
124         .resource       = dalmore_bluesleep_resources,
125 };
126
127 static noinline void __init dalmore_setup_bt_rfkill(void)
128 {
129         platform_device_register(&dalmore_bt_rfkill_device);
130 }
131
132 static noinline void __init dalmore_setup_bluesleep(void)
133 {
134         dalmore_bluesleep_resources[2].start =
135                 dalmore_bluesleep_resources[2].end =
136                         gpio_to_irq(TEGRA_GPIO_PU6);
137         platform_device_register(&dalmore_bluesleep_device);
138         return;
139 }
140 #elif defined CONFIG_BLUEDROID_PM
141 static struct resource dalmore_bluedroid_pm_resources[] = {
142         [0] = {
143                 .name   = "shutdown_gpio",
144                 .start  = TEGRA_GPIO_PQ7,
145                 .end    = TEGRA_GPIO_PQ7,
146                 .flags  = IORESOURCE_IO,
147         },
148         [1] = {
149                 .name = "host_wake",
150                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
151         },
152         [2] = {
153                 .name = "gpio_ext_wake",
154                 .start  = TEGRA_GPIO_PEE1,
155                 .end    = TEGRA_GPIO_PEE1,
156                 .flags  = IORESOURCE_IO,
157         },
158         [3] = {
159                 .name = "gpio_host_wake",
160                 .start  = TEGRA_GPIO_PU6,
161                 .end    = TEGRA_GPIO_PU6,
162                 .flags  = IORESOURCE_IO,
163         },
164         [4] = {
165                 .name = "reset_gpio",
166                 .start  = TEGRA_GPIO_PQ6,
167                 .end    = TEGRA_GPIO_PQ6,
168                 .flags  = IORESOURCE_IO,
169         },
170 };
171
172 static struct platform_device dalmore_bluedroid_pm_device = {
173         .name = "bluedroid_pm",
174         .id             = 0,
175         .num_resources  = ARRAY_SIZE(dalmore_bluedroid_pm_resources),
176         .resource       = dalmore_bluedroid_pm_resources,
177 };
178
179 static noinline void __init dalmore_setup_bluedroid_pm(void)
180 {
181         dalmore_bluedroid_pm_resources[1].start =
182                 dalmore_bluedroid_pm_resources[1].end =
183                                 gpio_to_irq(TEGRA_GPIO_PU6);
184         platform_device_register(&dalmore_bluedroid_pm_device);
185 }
186 #endif
187
188 static __initdata struct tegra_clk_init_table dalmore_clk_init_table[] = {
189         /* name         parent          rate            enabled */
190         { "pll_m",      NULL,           0,              false},
191         { "hda",        "pll_p",        108000000,      false},
192         { "hda2codec_2x", "pll_p",      48000000,       false},
193         { "pwm",        "pll_p",        3187500,        false},
194         { "blink",      "clk_32k",      32768,          true},
195         { "i2s1",       "pll_a_out0",   0,              false},
196         { "i2s3",       "pll_a_out0",   0,              false},
197         { "i2s4",       "pll_a_out0",   0,              false},
198         { "spdif_out",  "pll_a_out0",   0,              false},
199         { "d_audio",    "clk_m",        12000000,       false},
200         { "dam0",       "clk_m",        12000000,       false},
201         { "dam1",       "clk_m",        12000000,       false},
202         { "dam2",       "clk_m",        12000000,       false},
203         { "audio1",     "i2s1_sync",    0,              false},
204         { "audio3",     "i2s3_sync",    0,              false},
205         /* Setting vi_sensor-clk to true for validation purpose, will imapact
206          * power, later set to be false.*/
207         { "vi_sensor",  "pll_p",        150000000,      false},
208         { "cilab",      "pll_p",        150000000,      false},
209         { "cilcd",      "pll_p",        150000000,      false},
210         { "cile",       "pll_p",        150000000,      false},
211         { "i2c1",       "pll_p",        3200000,        false},
212         { "i2c2",       "pll_p",        3200000,        false},
213         { "i2c3",       "pll_p",        3200000,        false},
214         { "i2c4",       "pll_p",        3200000,        false},
215         { "i2c5",       "pll_p",        3200000,        false},
216         { NULL,         NULL,           0,              0},
217 };
218
219 static struct tegra_i2c_platform_data dalmore_i2c1_platform_data = {
220         .adapter_nr     = 0,
221         .bus_count      = 1,
222         .bus_clk_rate   = { 100000, 0 },
223         .scl_gpio               = {TEGRA_GPIO_I2C1_SCL, 0},
224         .sda_gpio               = {TEGRA_GPIO_I2C1_SDA, 0},
225         .arb_recovery = arb_lost_recovery,
226 };
227
228 static struct tegra_i2c_platform_data dalmore_i2c2_platform_data = {
229         .adapter_nr     = 1,
230         .bus_count      = 1,
231         .bus_clk_rate   = { 100000, 0 },
232         .is_clkon_always = true,
233         .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
234         .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
235         .arb_recovery = arb_lost_recovery,
236 };
237
238 static struct tegra_i2c_platform_data dalmore_i2c3_platform_data = {
239         .adapter_nr     = 2,
240         .bus_count      = 1,
241         .bus_clk_rate   = { 100000, 0 },
242         .scl_gpio               = {TEGRA_GPIO_I2C3_SCL, 0},
243         .sda_gpio               = {TEGRA_GPIO_I2C3_SDA, 0},
244         .arb_recovery = arb_lost_recovery,
245 };
246
247 static struct tegra_i2c_platform_data dalmore_i2c4_platform_data = {
248         .adapter_nr     = 3,
249         .bus_count      = 1,
250         .bus_clk_rate   = { 10000, 0 },
251         .scl_gpio               = {TEGRA_GPIO_I2C4_SCL, 0},
252         .sda_gpio               = {TEGRA_GPIO_I2C4_SDA, 0},
253         .arb_recovery = arb_lost_recovery,
254 };
255
256 static struct tegra_i2c_platform_data dalmore_i2c5_platform_data = {
257         .adapter_nr     = 4,
258         .bus_count      = 1,
259         .bus_clk_rate   = { 400000, 0 },
260         .scl_gpio               = {TEGRA_GPIO_I2C5_SCL, 0},
261         .sda_gpio               = {TEGRA_GPIO_I2C5_SDA, 0},
262         .arb_recovery = arb_lost_recovery,
263 };
264
265 static struct i2c_board_info __initdata rt5640_board_info = {
266         I2C_BOARD_INFO("rt5640", 0x1c),
267 };
268
269 static struct pn544_i2c_platform_data nfc_pdata = {
270         .irq_gpio = TEGRA_GPIO_PW2,
271         .ven_gpio = TEGRA_GPIO_PQ3,
272         .firm_gpio = TEGRA_GPIO_PH0,
273 };
274
275 static struct i2c_board_info __initdata nfc_board_info = {
276         I2C_BOARD_INFO("pn544", 0x28),
277         .platform_data = &nfc_pdata,
278 };
279
280 static void dalmore_i2c_init(void)
281 {
282         tegra11_i2c_device1.dev.platform_data = &dalmore_i2c1_platform_data;
283         tegra11_i2c_device2.dev.platform_data = &dalmore_i2c2_platform_data;
284         tegra11_i2c_device3.dev.platform_data = &dalmore_i2c3_platform_data;
285         tegra11_i2c_device4.dev.platform_data = &dalmore_i2c4_platform_data;
286         tegra11_i2c_device5.dev.platform_data = &dalmore_i2c5_platform_data;
287
288         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
289         i2c_register_board_info(0, &nfc_board_info, 1);
290
291         platform_device_register(&tegra11_i2c_device5);
292         platform_device_register(&tegra11_i2c_device4);
293         platform_device_register(&tegra11_i2c_device3);
294         platform_device_register(&tegra11_i2c_device2);
295         platform_device_register(&tegra11_i2c_device1);
296
297         i2c_register_board_info(0, &rt5640_board_info, 1);
298 }
299
300 static struct platform_device *dalmore_uart_devices[] __initdata = {
301         &tegra_uarta_device,
302         &tegra_uartb_device,
303         &tegra_uartc_device,
304         &tegra_uartd_device,
305 };
306 static struct uart_clk_parent uart_parent_clk[] = {
307         [0] = {.name = "clk_m"},
308         [1] = {.name = "pll_p"},
309 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
310         [2] = {.name = "pll_m"},
311 #endif
312 };
313
314 static struct tegra_uart_platform_data dalmore_uart_pdata;
315 static struct tegra_uart_platform_data dalmore_loopback_uart_pdata;
316
317 static void __init uart_debug_init(void)
318 {
319         int debug_port_id;
320
321         debug_port_id = uart_console_debug_init(3);
322         if (debug_port_id < 0)
323                 return;
324
325         dalmore_uart_devices[debug_port_id] = uart_console_debug_device;
326 }
327
328 static void __init dalmore_uart_init(void)
329 {
330         struct clk *c;
331         int i;
332
333         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
334                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
335                 if (IS_ERR_OR_NULL(c)) {
336                         pr_err("Not able to get the clock for %s\n",
337                                                 uart_parent_clk[i].name);
338                         continue;
339                 }
340                 uart_parent_clk[i].parent_clk = c;
341                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
342         }
343         dalmore_uart_pdata.parent_clk_list = uart_parent_clk;
344         dalmore_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
345         dalmore_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
346         dalmore_loopback_uart_pdata.parent_clk_count =
347                                                 ARRAY_SIZE(uart_parent_clk);
348         dalmore_loopback_uart_pdata.is_loopback = true;
349         tegra_uarta_device.dev.platform_data = &dalmore_uart_pdata;
350         tegra_uartb_device.dev.platform_data = &dalmore_uart_pdata;
351         tegra_uartc_device.dev.platform_data = &dalmore_uart_pdata;
352         tegra_uartd_device.dev.platform_data = &dalmore_uart_pdata;
353
354         /* Register low speed only if it is selected */
355         if (!is_tegra_debug_uartport_hs())
356                 uart_debug_init();
357
358         platform_add_devices(dalmore_uart_devices,
359                                 ARRAY_SIZE(dalmore_uart_devices));
360 }
361
362 static struct resource tegra_rtc_resources[] = {
363         [0] = {
364                 .start = TEGRA_RTC_BASE,
365                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
366                 .flags = IORESOURCE_MEM,
367         },
368         [1] = {
369                 .start = INT_RTC,
370                 .end = INT_RTC,
371                 .flags = IORESOURCE_IRQ,
372         },
373 };
374
375 static struct platform_device tegra_rtc_device = {
376         .name = "tegra_rtc",
377         .id   = -1,
378         .resource = tegra_rtc_resources,
379         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
380 };
381
382 static struct tegra_asoc_platform_data dalmore_audio_pdata = {
383         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
384         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
385         .gpio_hp_mute           = -1,
386         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
387         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
388         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
389         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
390         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
391         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
392         .i2s_param[HIFI_CODEC]  = {
393                 .audio_port_id  = 1,
394                 .is_i2s_master  = 1,
395                 .i2s_mode       = TEGRA_DAIFMT_I2S,
396         },
397         .i2s_param[BT_SCO]      = {
398                 .audio_port_id  = 3,
399                 .is_i2s_master  = 1,
400                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
401         },
402 };
403
404 static struct platform_device dalmore_audio_device = {
405         .name   = "tegra-snd-rt5640",
406         .id     = 0,
407         .dev    = {
408                 .platform_data = &dalmore_audio_pdata,
409         },
410 };
411
412 static struct platform_device tegra_camera = {
413         .name = "tegra_camera",
414         .id = -1,
415 };
416
417 static struct platform_device *dalmore_devices[] __initdata = {
418         &tegra_pmu_device,
419         &tegra_rtc_device,
420         &tegra_udc_device,
421 #if defined(CONFIG_TEGRA_AVP)
422         &tegra_avp_device,
423 #endif
424         &tegra_camera,
425 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
426         &tegra11_se_device,
427 #endif
428         &tegra_ahub_device,
429         &tegra_dam_device0,
430         &tegra_dam_device1,
431         &tegra_dam_device2,
432         &tegra_i2s_device1,
433         &tegra_i2s_device3,
434         &tegra_i2s_device4,
435         &tegra_spdif_device,
436         &spdif_dit_device,
437         &bluetooth_dit_device,
438         &dalmore_audio_device,
439         &tegra_hda_device,
440 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
441         &tegra_aes_device,
442 #endif
443 };
444
445 #ifdef CONFIG_USB_SUPPORT
446 static struct tegra_usb_platform_data tegra_udc_pdata = {
447         .port_otg = true,
448         .has_hostpc = true,
449         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
450         .op_mode = TEGRA_USB_OPMODE_DEVICE,
451         .u_data.dev = {
452                 .vbus_pmu_irq = 0,
453                 .vbus_gpio = -1,
454                 .charging_supported = false,
455                 .remote_wakeup_supported = false,
456         },
457         .u_cfg.utmi = {
458                 .hssync_start_delay = 0,
459                 .elastic_limit = 16,
460                 .idle_wait_delay = 17,
461                 .term_range_adj = 6,
462                 .xcvr_setup = 8,
463                 .xcvr_lsfslew = 2,
464                 .xcvr_lsrslew = 2,
465                 .xcvr_setup_offset = 0,
466                 .xcvr_use_fuses = 1,
467         },
468 };
469
470 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
471         .port_otg = true,
472         .has_hostpc = true,
473         .unaligned_dma_buf_supported = false,
474         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
475         .op_mode = TEGRA_USB_OPMODE_HOST,
476         .u_data.host = {
477                 .vbus_gpio = -1,
478                 .hot_plug = false,
479                 .remote_wakeup_supported = true,
480                 .power_off_on_suspend = true,
481         },
482         .u_cfg.utmi = {
483                 .hssync_start_delay = 0,
484                 .elastic_limit = 16,
485                 .idle_wait_delay = 17,
486                 .term_range_adj = 6,
487                 .xcvr_setup = 15,
488                 .xcvr_lsfslew = 2,
489                 .xcvr_lsrslew = 2,
490                 .xcvr_setup_offset = 0,
491                 .xcvr_use_fuses = 1,
492                 .vbus_oc_map = 0x4,
493         },
494 };
495
496 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
497         .port_otg = false,
498         .has_hostpc = true,
499         .unaligned_dma_buf_supported = false,
500         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
501         .op_mode = TEGRA_USB_OPMODE_HOST,
502         .u_data.host = {
503                 .vbus_gpio = -1,
504                 .hot_plug = false,
505                 .remote_wakeup_supported = true,
506                 .power_off_on_suspend = true,
507         },
508         .u_cfg.utmi = {
509         .hssync_start_delay = 0,
510                 .elastic_limit = 16,
511                 .idle_wait_delay = 17,
512                 .term_range_adj = 6,
513                 .xcvr_setup = 8,
514                 .xcvr_lsfslew = 2,
515                 .xcvr_lsrslew = 2,
516                 .xcvr_setup_offset = 0,
517                 .xcvr_use_fuses = 1,
518                 .vbus_oc_map = 0x5,
519         },
520 };
521
522 static struct tegra_usb_otg_data tegra_otg_pdata = {
523         .ehci_device = &tegra_ehci1_device,
524         .ehci_pdata = &tegra_ehci1_utmi_pdata,
525 };
526
527 static void dalmore_usb_init(void)
528 {
529         int usb_port_owner_info = tegra_get_usb_port_owner_info();
530
531         /* Set USB wake sources for dalmore */
532         tegra_set_usb_wake_source();
533
534         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
535                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
536                 platform_device_register(&tegra_otg_device);
537                 /* Setup the udc platform data */
538                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
539         }
540
541         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
542                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
543                 platform_device_register(&tegra_ehci3_device);
544         }
545 }
546
547 static struct gpio modem_gpios[] = { /* Nemo modem */
548         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
549         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
550 };
551
552 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
553         .port_otg = false,
554         .has_hostpc = true,
555         .unaligned_dma_buf_supported = false,
556         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
557         .op_mode = TEGRA_USB_OPMODE_HOST,
558         .u_data.host = {
559                 .vbus_gpio = -1,
560                 .hot_plug = false,
561                 .remote_wakeup_supported = true,
562                 .power_off_on_suspend = true,
563         },
564 };
565
566 static int baseband_init(void)
567 {
568         int ret;
569
570         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
571         if (ret) {
572                 pr_warn("%s:gpio request failed\n", __func__);
573                 return ret;
574         }
575
576         /* enable pull-down for MDM_COLD_BOOT */
577         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
578                                     TEGRA_PUPD_PULL_DOWN);
579
580         /* export GPIO for user space access through sysfs */
581         gpio_export(MDM_RST, false);
582
583         return 0;
584 }
585
586 static const struct tegra_modem_operations baseband_operations = {
587         .init = baseband_init,
588 };
589
590 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
591         .ops = &baseband_operations,
592         .wake_gpio = -1,
593         .boot_gpio = MDM_COLDBOOT,
594         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
595         .autosuspend_delay = 2000,
596         .short_autosuspend_delay = 50,
597         .tegra_ehci_device = &tegra_ehci2_device,
598         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
599 };
600
601 static struct platform_device icera_nemo_device = {
602         .name = "tegra_usb_modem_power",
603         .id = -1,
604         .dev = {
605                 .platform_data = &baseband_pdata,
606         },
607 };
608
609 static void dalmore_modem_init(void)
610 {
611         int modem_id = tegra_get_modem_id();
612         int usb_port_owner_info = tegra_get_usb_port_owner_info();
613         switch (modem_id) {
614         case TEGRA_BB_NEMO: /* on board i500 HSIC */
615                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
616                         platform_device_register(&icera_nemo_device);
617                 break;
618         }
619 }
620
621 #else
622 static void dalmore_usb_init(void) { }
623 static void dalmore_modem_init(void) { }
624 #endif
625
626 static void dalmore_audio_init(void)
627 {
628         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
629         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
630 }
631
632
633 static struct platform_device *dalmore_spi_devices[] __initdata = {
634         &tegra11_spi_device4,
635 };
636
637 struct spi_clk_parent spi_parent_clk_dalmore[] = {
638         [0] = {.name = "pll_p"},
639 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
640         [1] = {.name = "pll_m"},
641         [2] = {.name = "clk_m"},
642 #else
643         [1] = {.name = "clk_m"},
644 #endif
645 };
646
647 static struct tegra_spi_platform_data dalmore_spi_pdata = {
648         .is_dma_based           = false,
649         .max_dma_buffer         = 16 * 1024,
650         .is_clkon_always        = false,
651         .max_rate               = 25000000,
652 };
653
654 static void __init dalmore_spi_init(void)
655 {
656         int i;
657         struct clk *c;
658
659         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_dalmore); ++i) {
660                 c = tegra_get_clock_by_name(spi_parent_clk_dalmore[i].name);
661                 if (IS_ERR_OR_NULL(c)) {
662                         pr_err("Not able to get the clock for %s\n",
663                                                 spi_parent_clk_dalmore[i].name);
664                         continue;
665                 }
666                 spi_parent_clk_dalmore[i].parent_clk = c;
667                 spi_parent_clk_dalmore[i].fixed_clk_rate = clk_get_rate(c);
668         }
669         dalmore_spi_pdata.parent_clk_list = spi_parent_clk_dalmore;
670         dalmore_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_dalmore);
671         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
672         platform_add_devices(dalmore_spi_devices,
673                                 ARRAY_SIZE(dalmore_spi_devices));
674 }
675
676 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
677         /* name         parent          rate            enabled */
678         { "extern2",    "pll_p",        41000000,       false},
679         { "clk_out_2",  "extern2",      40800000,       false},
680         { NULL,         NULL,           0,              0},
681 };
682
683 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
684         .gpio_reset = 0,
685         .config = 0,
686         .platform_id = RM_PLATFORM_D010,
687         .name_of_clock = "clk_out_2",
688 };
689
690 static struct tegra_spi_device_controller_data dev_cdata = {
691         .rx_clk_tap_delay = 0,
692         .tx_clk_tap_delay = 16,
693 };
694
695 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
696         {
697          .modalias = "rm_ts_spidev",
698          .bus_num = 3,
699          .chip_select = 2,
700          .max_speed_hz = 12 * 1000 * 1000,
701          .mode = SPI_MODE_0,
702          .controller_data = &dev_cdata,
703          .platform_data = &rm31080ts_dalmore_data,
704          },
705 };
706
707 static int __init dalmore_touch_init(void)
708 {
709         tegra_clk_init_from_table(touch_clk_init_table);
710         clk_enable(tegra_get_clock_by_name("clk_out_2"));
711         if (display_board_info.board_id == BOARD_E1582)
712                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
713         else
714                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
715         mdelay(20);
716         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
717         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
718                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
719                                 &rm31080ts_dalmore_data,
720                                 &rm31080a_dalmore_spi_board[0],
721                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
722         return 0;
723 }
724
725 #ifdef CONFIG_EDP_FRAMEWORK
726 static struct edp_manager battery_edp_manager = {
727         .name = "battery",
728         .imax = 2500
729 };
730
731 static void __init dalmore_battery_edp_init(void)
732 {
733         struct edp_governor *g;
734         int r;
735
736         r = edp_register_manager(&battery_edp_manager);
737         if (r)
738                 goto err_ret;
739
740         /* start with priority governor */
741         g = edp_get_governor("priority");
742         if (!g) {
743                 r = -EFAULT;
744                 goto err_ret;
745         }
746
747         r = edp_set_governor(&battery_edp_manager, g);
748         if (r)
749                 goto err_ret;
750
751         return;
752
753 err_ret:
754         pr_err("Battery EDP init failed with error %d\n", r);
755         WARN_ON(1);
756 }
757 #else
758 static inline void dalmore_battery_edp_init(void) {}
759 #endif
760
761 static void __init tegra_dalmore_early_init(void)
762 {
763         dalmore_battery_edp_init();
764         tegra_clk_init_from_table(dalmore_clk_init_table);
765         tegra_clk_vefify_parents();
766         tegra_smmu_init();
767         tegra_soc_device_init("dalmore");
768 }
769
770 static void __init tegra_dalmore_late_init(void)
771 {
772         platform_device_register(&tegra_pinmux_device);
773         dalmore_pinmux_init();
774         dalmore_i2c_init();
775         dalmore_spi_init();
776         dalmore_usb_init();
777         dalmore_uart_init();
778         dalmore_audio_init();
779         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
780         //tegra_ram_console_debug_init();
781         tegra_io_dpd_init();
782         dalmore_regulator_init();
783         dalmore_sdhci_init();
784         dalmore_suspend_init();
785         dalmore_emc_init();
786         dalmore_edp_init();
787         dalmore_touch_init();
788         if (board_info.board_id == BOARD_E1582)
789                 roth_panel_init();
790         else
791                 dalmore_panel_init();
792         dalmore_kbc_init();
793         dalmore_pmon_init();
794 #ifdef CONFIG_BT_BLUESLEEP
795         dalmore_setup_bluesleep();
796         dalmore_setup_bt_rfkill();
797 #elif defined CONFIG_BLUEDROID_PM
798         dalmore_setup_bluedroid_pm();
799 #endif
800         tegra_release_bootloader_fb();
801         dalmore_modem_init();
802 #ifdef CONFIG_TEGRA_WDT_RECOVERY
803         tegra_wdt_recovery_init();
804 #endif
805         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
806         dalmore_sensors_init();
807         dalmore_soctherm_init();
808         tegra_register_fuse();
809 }
810
811 static void __init dalmore_ramconsole_reserve(unsigned long size)
812 {
813         tegra_ram_console_debug_reserve(SZ_1M);
814 }
815
816 static void __init tegra_dalmore_dt_init(void)
817 {
818         tegra_get_board_info(&board_info);
819         tegra_get_display_board_info(&display_board_info);
820
821         tegra_dalmore_early_init();
822
823         of_platform_populate(NULL,
824                 of_default_bus_match_table, NULL, NULL);
825
826         tegra_dalmore_late_init();
827 }
828
829 static void __init tegra_dalmore_reserve(void)
830 {
831 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
832         /* 1920*1200*4*2 = 18432000 bytes */
833         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
834 #else
835         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
836 #endif
837         dalmore_ramconsole_reserve(SZ_1M);
838 }
839
840 static const char * const dalmore_dt_board_compat[] = {
841         "nvidia,dalmore",
842         NULL
843 };
844
845 MACHINE_START(DALMORE, "dalmore")
846         .atag_offset    = 0x100,
847         .smp            = smp_ops(tegra_smp_ops),
848         .map_io         = tegra_map_common_io,
849         .reserve        = tegra_dalmore_reserve,
850         .init_early     = tegra11x_init_early,
851         .init_irq       = tegra_dt_init_irq,
852         .handle_irq     = gic_handle_irq,
853         .timer          = &tegra_timer,
854         .init_machine   = tegra_dalmore_dt_init,
855         .restart        = tegra_assert_system_reset,
856         .dt_compat      = dalmore_dt_board_compat,
857 MACHINE_END