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