76e8cb6cae04add1bb40e0257a4161f0f616663b
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu.c
1 /*
2  * arch/arm/mach-tegra/board-cardhu.c
3  *
4  * Copyright (c) 2011, NVIDIA Corporation.
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 as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/slab.h>
24 #include <linux/ctype.h>
25 #include <linux/platform_device.h>
26 #include <linux/clk.h>
27 #include <linux/serial_8250.h>
28 #include <linux/i2c.h>
29 #include <linux/i2c/panjit_ts.h>
30 #include <linux/dma-mapping.h>
31 #include <linux/delay.h>
32 #include <linux/i2c-tegra.h>
33 #include <linux/gpio.h>
34 #include <linux/input.h>
35 #include <linux/platform_data/tegra_usb.h>
36 #include <linux/spi/spi.h>
37 #include <linux/i2c/atmel_mxt_ts.h>
38 #include <linux/tegra_uart.h>
39 #include <linux/spi-tegra.h>
40
41 #include <sound/wm8903.h>
42
43 #include <mach/clk.h>
44 #include <mach/iomap.h>
45 #include <mach/irqs.h>
46 #include <mach/pinmux.h>
47 #include <mach/iomap.h>
48 #include <mach/io.h>
49 #include <mach/i2s.h>
50 #include <mach/tegra_wm8903_pdata.h>
51 #include <asm/mach-types.h>
52 #include <asm/mach/arch.h>
53 #include <mach/usb_phy.h>
54
55 #include "board.h"
56 #include "clock.h"
57 #include "board-cardhu.h"
58 #include "devices.h"
59 #include "gpio-names.h"
60 #include "fuse.h"
61 #include "pm.h"
62 #include "baseband-xmm-power.h"
63
64
65 /* !!!TODO: Change for cardhu (Taken from Ventana) */
66 static struct tegra_utmip_config utmi_phy_config[] = {
67         [0] = {
68                         .hssync_start_delay = 0,
69                         .idle_wait_delay = 17,
70                         .elastic_limit = 16,
71                         .term_range_adj = 6,
72                         .xcvr_setup = 15,
73                         .xcvr_setup_offset = 0,
74                         .xcvr_use_fuses = 1,
75                         .xcvr_lsfslew = 2,
76                         .xcvr_lsrslew = 2,
77         },
78         [1] = {
79                         .hssync_start_delay = 0,
80                         .idle_wait_delay = 17,
81                         .elastic_limit = 16,
82                         .term_range_adj = 6,
83                         .xcvr_setup = 15,
84                         .xcvr_setup_offset = 0,
85                         .xcvr_use_fuses = 1,
86                         .xcvr_lsfslew = 2,
87                         .xcvr_lsrslew = 2,
88         },
89         [2] = {
90                         .hssync_start_delay = 0,
91                         .idle_wait_delay = 17,
92                         .elastic_limit = 16,
93                         .term_range_adj = 6,
94                         .xcvr_setup = 8,
95                         .xcvr_setup_offset = 0,
96                         .xcvr_use_fuses = 1,
97                         .xcvr_lsfslew = 2,
98                         .xcvr_lsrslew = 2,
99         },
100 };
101
102 #ifdef CONFIG_BCM4329_RFKILL
103 static struct resource cardhu_bcm4329_rfkill_resources[] = {
104         {
105                 .name   = "bcm4329_nshutdown_gpio",
106                 .start  = TEGRA_GPIO_PU0,
107                 .end    = TEGRA_GPIO_PU0,
108                 .flags  = IORESOURCE_IO,
109         },
110 };
111
112 static struct platform_device cardhu_bcm4329_rfkill_device = {
113         .name = "bcm4329_rfkill",
114         .id             = -1,
115         .num_resources  = ARRAY_SIZE(cardhu_bcm4329_rfkill_resources),
116         .resource       = cardhu_bcm4329_rfkill_resources,
117 };
118
119 static noinline void __init cardhu_bt_rfkill(void)
120 {
121         platform_device_register(&cardhu_bcm4329_rfkill_device);
122
123         return;
124 }
125 #else
126 static inline void cardhu_bt_rfkill(void) { }
127 #endif
128
129 #ifdef CONFIG_BT_BLUESLEEP
130 static noinline void __init tegra_setup_bluesleep(void)
131 {
132         struct platform_device *pdev = NULL;
133         struct resource *res;
134
135         pdev = platform_device_alloc("bluesleep", 0);
136         if (!pdev) {
137                 pr_err("unable to allocate platform device for bluesleep");
138                 return;
139         }
140
141         res = kzalloc(sizeof(struct resource) * 3, GFP_KERNEL);
142         if (!res) {
143                 pr_err("unable to allocate resource for bluesleep\n");
144                 goto err_free_dev;
145         }
146
147         res[0].name   = "gpio_host_wake";
148         res[0].start  = TEGRA_GPIO_PU6;
149         res[0].end    = TEGRA_GPIO_PU6;
150         res[0].flags  = IORESOURCE_IO;
151
152         res[1].name   = "gpio_ext_wake";
153         res[1].start  = TEGRA_GPIO_PU1;
154         res[1].end    = TEGRA_GPIO_PU1;
155         res[1].flags  = IORESOURCE_IO;
156
157         res[2].name   = "host_wake";
158         res[2].start  = gpio_to_irq(TEGRA_GPIO_PU6);
159         res[2].end    = gpio_to_irq(TEGRA_GPIO_PU6);
160         res[2].flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE ;
161
162         if (platform_device_add_resources(pdev, res, 3)) {
163                 pr_err("unable to add resources to bluesleep device\n");
164                 goto err_free_res;
165         }
166
167         if (platform_device_add(pdev)) {
168                 pr_err("unable to add bluesleep device\n");
169                 goto err_free_res;
170         }
171         tegra_gpio_enable(TEGRA_GPIO_PU6);
172         tegra_gpio_enable(TEGRA_GPIO_PU1);
173
174 return;
175
176 err_free_res:
177         kfree(res);
178 err_free_dev:
179         platform_device_put(pdev);
180         return;
181 }
182 #else
183 static inline void tegra_setup_bluesleep(void) { }
184 #endif
185
186 static __initdata struct tegra_clk_init_table cardhu_clk_init_table[] = {
187         /* name         parent          rate            enabled */
188         { "pll_m",      NULL,           0,              false},
189         { "hda",        "pll_p",        108000000,      false},
190         { "hda2codec_2x","pll_p",       48000000,       false},
191         { "pwm",        "pll_p",        3187500,        false},
192         { "blink",      "clk_32k",      32768,          true},
193         { "i2s1",       "pll_a_out0",   0,              false},
194         { "spdif_out",  "pll_a_out0",   0,              false},
195         { "vi_sensor",  "pll_p",        150000000,      false},
196         { "i2c1",       "pll_p",        3200000,        false},
197         { "i2c2",       "pll_p",        3200000,        false},
198         { "i2c3",       "pll_p",        3200000,        false},
199         { "i2c4",       "pll_p",        3200000,        false},
200         { "i2c5",       "pll_p",        3200000,        false},
201         { NULL,         NULL,           0,              0},
202 };
203
204 static struct tegra_i2c_platform_data cardhu_i2c1_platform_data = {
205         .adapter_nr     = 0,
206         .bus_count      = 1,
207         .bus_clk_rate   = { 100000, 0 },
208         .scl_gpio               = {TEGRA_GPIO_PC4, 0},
209         .sda_gpio               = {TEGRA_GPIO_PC5, 0},
210         .arb_recovery = arb_lost_recovery,
211 };
212
213 static struct tegra_i2c_platform_data cardhu_i2c2_platform_data = {
214         .adapter_nr     = 1,
215         .bus_count      = 1,
216         .bus_clk_rate   = { 100000, 0 },
217         .is_clkon_always = true,
218         .scl_gpio               = {TEGRA_GPIO_PT5, 0},
219         .sda_gpio               = {TEGRA_GPIO_PT6, 0},
220         .arb_recovery = arb_lost_recovery,
221 };
222
223 static struct tegra_i2c_platform_data cardhu_i2c3_platform_data = {
224         .adapter_nr     = 2,
225         .bus_count      = 1,
226         .bus_clk_rate   = { 100000, 0 },
227         .scl_gpio               = {TEGRA_GPIO_PBB1, 0},
228         .sda_gpio               = {TEGRA_GPIO_PBB2, 0},
229         .arb_recovery = arb_lost_recovery,
230 };
231
232 static struct tegra_i2c_platform_data cardhu_i2c4_platform_data = {
233         .adapter_nr     = 3,
234         .bus_count      = 1,
235         .bus_clk_rate   = { 100000, 0 },
236         .scl_gpio               = {TEGRA_GPIO_PV4, 0},
237         .sda_gpio               = {TEGRA_GPIO_PV5, 0},
238         .arb_recovery = arb_lost_recovery,
239 };
240
241 static struct tegra_i2c_platform_data cardhu_i2c5_platform_data = {
242         .adapter_nr     = 4,
243         .bus_count      = 1,
244         .bus_clk_rate   = { 400000, 0 },
245         .scl_gpio               = {TEGRA_GPIO_PZ6, 0},
246         .sda_gpio               = {TEGRA_GPIO_PZ7, 0},
247         .arb_recovery = arb_lost_recovery,
248 };
249
250
251 #if 0
252 struct tegra_wired_jack_conf audio_wr_jack_conf = {
253         .hp_det_n = TEGRA_GPIO_PW2,
254         .en_mic_ext = TEGRA_GPIO_PX1,
255         .en_mic_int = TEGRA_GPIO_PX0,
256 };
257 #endif
258
259 static struct wm8903_platform_data cardhu_wm8903_pdata = {
260         .irq_active_low = 0,
261         .micdet_cfg = 0,
262         .micdet_delay = 100,
263         .gpio_base = CARDHU_GPIO_WM8903(0),
264         .gpio_cfg = {
265                 (WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT << WM8903_GP1_FN_SHIFT),
266                 (WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT << WM8903_GP2_FN_SHIFT) |
267                         WM8903_GP2_DIR,
268                 0,
269                 WM8903_GPIO_NO_CONFIG,
270                 WM8903_GPIO_NO_CONFIG,
271         },
272 };
273
274 static struct i2c_board_info __initdata wm8903_board_info = {
275         I2C_BOARD_INFO("wm8903", 0x1a),
276         .platform_data = &cardhu_wm8903_pdata,
277         .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
278 };
279
280 static void cardhu_i2c_init(void)
281 {
282         tegra_i2c_device1.dev.platform_data = &cardhu_i2c1_platform_data;
283         tegra_i2c_device2.dev.platform_data = &cardhu_i2c2_platform_data;
284         tegra_i2c_device3.dev.platform_data = &cardhu_i2c3_platform_data;
285         tegra_i2c_device4.dev.platform_data = &cardhu_i2c4_platform_data;
286         tegra_i2c_device5.dev.platform_data = &cardhu_i2c5_platform_data;
287
288         platform_device_register(&tegra_i2c_device5);
289         platform_device_register(&tegra_i2c_device4);
290         platform_device_register(&tegra_i2c_device3);
291         platform_device_register(&tegra_i2c_device2);
292         platform_device_register(&tegra_i2c_device1);
293
294         i2c_register_board_info(4, &wm8903_board_info, 1);
295 }
296
297 static struct platform_device *cardhu_uart_devices[] __initdata = {
298         &tegra_uarta_device,
299         &tegra_uartb_device,
300         &tegra_uartc_device,
301         &tegra_uartd_device,
302         &tegra_uarte_device,
303 };
304 static struct uart_clk_parent uart_parent_clk[] = {
305         [0] = {.name = "clk_m"},
306         [1] = {.name = "pll_p"},
307         [2] = {.name = "pll_m"},
308 };
309
310 static struct tegra_uart_platform_data cardhu_uart_pdata;
311
312 static void __init uart_debug_init(void)
313 {
314         struct board_info board_info;
315
316         tegra_get_board_info(&board_info);
317         /* UARTB is debug port
318          *       for SLT - E1186/E1187/PM269
319          *       for E1256/E1257
320          */
321         if (((board_info.sku & SKU_SLT_ULPI_SUPPORT) &&
322                 ((board_info.board_id == BOARD_E1186) ||
323                 (board_info.board_id == BOARD_E1187) ||
324                 (board_info.board_id == BOARD_PM269))) ||
325                 (board_info.board_id == BOARD_E1256) ||
326                 (board_info.board_id == BOARD_E1257)) {
327                         /* UARTB is the debug port. */
328                         pr_info("Selecting UARTB as the debug console\n");
329                         cardhu_uart_devices[1] = &debug_uartb_device;
330                         debug_uart_clk =  clk_get_sys("serial8250.0", "uartb");
331                         debug_uart_port_base = ((struct plat_serial8250_port *)(
332                                 debug_uartb_device.dev.platform_data))->mapbase;
333                         return;
334         }
335         /* UARTA is the debug port. */
336         pr_info("Selecting UARTA as the debug console\n");
337         cardhu_uart_devices[0] = &debug_uarta_device;
338         debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
339         debug_uart_port_base = ((struct plat_serial8250_port *)(
340                         debug_uarta_device.dev.platform_data))->mapbase;
341 }
342
343 static void __init cardhu_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         cardhu_uart_pdata.parent_clk_list = uart_parent_clk;
359         cardhu_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
360         tegra_uarta_device.dev.platform_data = &cardhu_uart_pdata;
361         tegra_uartb_device.dev.platform_data = &cardhu_uart_pdata;
362         tegra_uartc_device.dev.platform_data = &cardhu_uart_pdata;
363         tegra_uartd_device.dev.platform_data = &cardhu_uart_pdata;
364         tegra_uarte_device.dev.platform_data = &cardhu_uart_pdata;
365
366         /* Register low speed only if it is selected */
367         if (!is_tegra_debug_uartport_hs()) {
368                 uart_debug_init();
369                 /* Clock enable for the debug channel */
370                 if (!IS_ERR_OR_NULL(debug_uart_clk)) {
371                         pr_info("The debug console clock name is %s\n",
372                                                 debug_uart_clk->name);
373                         c = tegra_get_clock_by_name("pll_p");
374                         if (IS_ERR_OR_NULL(c))
375                                 pr_err("Not getting the parent clock pll_p\n");
376                         else
377                                 clk_set_parent(debug_uart_clk, c);
378
379                         clk_enable(debug_uart_clk);
380                         clk_set_rate(debug_uart_clk, clk_get_rate(c));
381                 } else {
382                         pr_err("Not getting the clock %s for debug console\n",
383                                         debug_uart_clk->name);
384                 }
385         }
386
387         platform_add_devices(cardhu_uart_devices,
388                                 ARRAY_SIZE(cardhu_uart_devices));
389 }
390
391 static struct platform_device tegra_camera = {
392         .name = "tegra_camera",
393         .id = -1,
394 };
395
396 static struct platform_device *cardhu_spi_devices[] __initdata = {
397         &tegra_spi_device4,
398 };
399
400 struct spi_clk_parent spi_parent_clk[] = {
401         [0] = {.name = "pll_p"},
402         [1] = {.name = "pll_m"},
403         [2] = {.name = "clk_m"},
404 };
405
406 static struct tegra_spi_platform_data cardhu_spi_pdata = {
407         .is_dma_based           = true,
408         .max_dma_buffer         = (16 * 1024),
409         .is_clkon_always        = false,
410         .max_rate               = 100000000,
411 };
412
413 static void __init cardhu_spi_init(void)
414 {
415         int i;
416         struct clk *c;
417         struct board_info board_info;
418
419         tegra_get_board_info(&board_info);
420
421         for (i = 0; i < ARRAY_SIZE(spi_parent_clk); ++i) {
422                 c = tegra_get_clock_by_name(spi_parent_clk[i].name);
423                 if (IS_ERR_OR_NULL(c)) {
424                         pr_err("Not able to get the clock for %s\n",
425                                                 spi_parent_clk[i].name);
426                         continue;
427                 }
428                 spi_parent_clk[i].parent_clk = c;
429                 spi_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
430         }
431         cardhu_spi_pdata.parent_clk_list = spi_parent_clk;
432         cardhu_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk);
433         tegra_spi_device4.dev.platform_data = &cardhu_spi_pdata;
434         platform_add_devices(cardhu_spi_devices,
435                                 ARRAY_SIZE(cardhu_spi_devices));
436
437         if (board_info.board_id == BOARD_E1198) {
438                 tegra_spi_device2.dev.platform_data = &cardhu_spi_pdata;
439                 platform_device_register(&tegra_spi_device2);
440         }
441 }
442
443 static struct resource tegra_rtc_resources[] = {
444         [0] = {
445                 .start = TEGRA_RTC_BASE,
446                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
447                 .flags = IORESOURCE_MEM,
448         },
449         [1] = {
450                 .start = INT_RTC,
451                 .end = INT_RTC,
452                 .flags = IORESOURCE_IRQ,
453         },
454 };
455
456 static struct platform_device tegra_rtc_device = {
457         .name = "tegra_rtc",
458         .id   = -1,
459         .resource = tegra_rtc_resources,
460         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
461 };
462
463 static struct tegra_wm8903_platform_data cardhu_audio_pdata = {
464         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
465         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
466         .gpio_hp_mute           = -1,
467         .gpio_int_mic_en        = -1,
468         .gpio_ext_mic_en        = -1,
469 };
470
471 static struct platform_device cardhu_audio_device = {
472         .name   = "tegra-snd-wm8903",
473         .id     = 0,
474         .dev    = {
475                 .platform_data  = &cardhu_audio_pdata,
476         },
477 };
478
479 static struct platform_device *cardhu_devices[] __initdata = {
480         &tegra_pmu_device,
481         &tegra_rtc_device,
482         &tegra_udc_device,
483 #if defined(CONFIG_SND_HDA_TEGRA)
484         &tegra_hda_device,
485 #endif
486 #if defined(CONFIG_TEGRA_IOVMM_SMMU)
487         &tegra_smmu_device,
488 #endif
489         &tegra_wdt_device,
490 #if defined(CONFIG_TEGRA_AVP)
491         &tegra_avp_device,
492 #endif
493         &tegra_camera,
494 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
495         &tegra_se_device,
496 #endif
497         &tegra_ahub_device,
498         &tegra_i2s_device1,
499         &tegra_spdif_device,
500         &spdif_dit_device,
501         &tegra_pcm_device,
502         &cardhu_audio_device,
503 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
504         &tegra_aes_device,
505 #endif
506 };
507
508 #define MXT_CONFIG_CRC  0xD62DE8
509 static const u8 config[] = {
510         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
511         0xFF, 0xFF, 0x32, 0x0A, 0x00, 0x14, 0x14, 0x00,
512         0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x00, 0x00,
513         0x1B, 0x2A, 0x00, 0x20, 0x3C, 0x04, 0x05, 0x00,
514         0x02, 0x01, 0x00, 0x0A, 0x0A, 0x0A, 0x0A, 0xFF,
515         0x02, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
516         0x00, 0x00, 0x00, 0x64, 0x02, 0x00, 0x00, 0x00,
517         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
518         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
519         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
520         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
521         0x00, 0x00, 0x00, 0x05, 0x0A, 0x15, 0x1E, 0x00,
522         0x00, 0x04, 0xFF, 0x03, 0x3F, 0x64, 0x64, 0x01,
523         0x0A, 0x14, 0x28, 0x4B, 0x00, 0x02, 0x00, 0x64,
524         0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
525         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
526         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
527         0x00, 0x00, 0x00, 0x08, 0x10, 0x3C, 0x00, 0x00,
528         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
529         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
530 };
531
532 #define MXT_CONFIG_CRC_SKU2000  0xA24D9A
533 static const u8 config_sku2000[] = {
534         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
535         0xFF, 0xFF, 0x32, 0x0A, 0x00, 0x14, 0x14, 0x19,
536         0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x00, 0x00,
537         0x1B, 0x2A, 0x00, 0x20, 0x3A, 0x04, 0x05, 0x00,  //23=thr  2 di
538         0x04, 0x04, 0x41, 0x0A, 0x0A, 0x0A, 0x0A, 0xFF,
539         0x02, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
540         0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,  //0A=limit
541         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
542         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
543         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
544         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
545         0x00, 0x00, 0x00, 0x05, 0x0A, 0x15, 0x1E, 0x00,
546         0x00, 0x04, 0x00, 0x03, 0x3F, 0x64, 0x64, 0x01,
547         0x0A, 0x14, 0x28, 0x4B, 0x00, 0x02, 0x00, 0x64,
548         0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
549         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
550         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
551         0x00, 0x00, 0x00, 0x08, 0x10, 0x3C, 0x00, 0x00,
552         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
553         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
554 };
555
556 static struct mxt_platform_data atmel_mxt_info = {
557         .x_line         = 27,
558         .y_line         = 42,
559         .x_size         = 768,
560         .y_size         = 1366,
561         .blen           = 0x20,
562         .threshold      = 0x3C,
563         .voltage        = 3300000,              /* 3.3V */
564         .orient         = 5,
565         .config         = config,
566         .config_length  = 157,
567         .config_crc     = MXT_CONFIG_CRC,
568         .irqflags       = IRQF_TRIGGER_FALLING,
569 /*      .read_chg       = &read_chg, */
570         .read_chg       = NULL,
571 };
572
573 static struct i2c_board_info __initdata atmel_i2c_info[] = {
574         {
575                 I2C_BOARD_INFO("atmel_mxt_ts", 0x5A),
576                 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PH4),
577                 .platform_data = &atmel_mxt_info,
578         }
579 };
580
581 static int __init cardhu_touch_init(void)
582 {
583         struct board_info BoardInfo;
584
585         tegra_gpio_enable(TEGRA_GPIO_PH4);
586         tegra_gpio_enable(TEGRA_GPIO_PH6);
587
588         gpio_request(TEGRA_GPIO_PH4, "atmel-irq");
589         gpio_direction_input(TEGRA_GPIO_PH4);
590
591         gpio_request(TEGRA_GPIO_PH6, "atmel-reset");
592         gpio_direction_output(TEGRA_GPIO_PH6, 0);
593         msleep(1);
594         gpio_set_value(TEGRA_GPIO_PH6, 1);
595         msleep(100);
596
597         tegra_get_board_info(&BoardInfo);
598         if ((BoardInfo.sku & SKU_TOUCH_MASK) == SKU_TOUCH_2000) {
599                 atmel_mxt_info.config = config_sku2000;
600                 atmel_mxt_info.config_crc = MXT_CONFIG_CRC_SKU2000;
601         }
602
603         i2c_register_board_info(1, atmel_i2c_info, 1);
604
605         return 0;
606 }
607
608 static struct tegra_uhsic_config uhsic_phy_config = {
609         .enable_gpio = EN_HSIC_GPIO,
610         .reset_gpio = -1,
611         .sync_start_delay = 9,
612         .idle_wait_delay = 17,
613         .term_range_adj = 0,
614         .elastic_underrun_limit = 16,
615         .elastic_overrun_limit = 16,
616 };
617
618 static struct tegra_ehci_platform_data tegra_ehci_uhsic_pdata = {
619         .phy_type = TEGRA_USB_PHY_TYPE_HSIC,
620         .phy_config = &uhsic_phy_config,
621         .operating_mode = TEGRA_USB_HOST,
622         .power_down_on_bus_suspend = 1,
623 };
624
625 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
626         [0] = {
627                         .phy_config = &utmi_phy_config[0],
628                         .operating_mode = TEGRA_USB_HOST,
629                         .power_down_on_bus_suspend = 1,
630         },
631         [1] = {
632                         .phy_config = &utmi_phy_config[1],
633                         .operating_mode = TEGRA_USB_HOST,
634                         .power_down_on_bus_suspend = 1,
635         },
636         [2] = {
637                         .phy_config = &utmi_phy_config[2],
638                         .operating_mode = TEGRA_USB_HOST,
639                         .power_down_on_bus_suspend = 1,
640                         .hotplug = 1,
641         },
642 };
643
644 static struct platform_device *tegra_usb_otg_host_register(void)
645 {
646         struct platform_device *pdev;
647         void *platform_data;
648         int val;
649
650         pdev = platform_device_alloc(tegra_ehci1_device.name,
651                 tegra_ehci1_device.id);
652         if (!pdev)
653                 return NULL;
654
655         val = platform_device_add_resources(pdev, tegra_ehci1_device.resource,
656                 tegra_ehci1_device.num_resources);
657         if (val)
658                 goto error;
659
660         pdev->dev.dma_mask =  tegra_ehci1_device.dev.dma_mask;
661         pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask;
662
663         platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data),
664                 GFP_KERNEL);
665         if (!platform_data)
666                 goto error;
667
668         memcpy(platform_data, &tegra_ehci_pdata[0],
669                                 sizeof(struct tegra_ehci_platform_data));
670         pdev->dev.platform_data = platform_data;
671
672         val = platform_device_add(pdev);
673         if (val)
674                 goto error_add;
675
676         return pdev;
677
678 error_add:
679         kfree(platform_data);
680 error:
681         pr_err("%s: failed to add the host contoller device\n", __func__);
682         platform_device_put(pdev);
683         return NULL;
684 }
685
686 static void tegra_usb_otg_host_unregister(struct platform_device *pdev)
687 {
688         platform_device_unregister(pdev);
689 }
690
691 #ifdef CONFIG_USB_SUPPORT
692 static struct usb_phy_plat_data tegra_usb_phy_pdata[] = {
693         [0] = {
694                         .instance = 0,
695                         .vbus_gpio = -1,
696                         .vbus_reg_supply = "vdd_vbus_micro_usb",
697         },
698         [1] = {
699                         .instance = 1,
700                         .vbus_gpio = -1,
701         },
702         [2] = {
703                         .instance = 2,
704                         .vbus_gpio = -1,
705                         .vbus_reg_supply = "vdd_vbus_typea_usb",
706         },
707 };
708
709 static struct tegra_otg_platform_data tegra_otg_pdata = {
710         .host_register = &tegra_usb_otg_host_register,
711         .host_unregister = &tegra_usb_otg_host_unregister,
712 };
713
714 static void cardhu_usb_init(void)
715 {
716         struct board_info bi;
717
718         tegra_get_board_info(&bi);
719
720         tegra_usb_phy_init(tegra_usb_phy_pdata,
721                         ARRAY_SIZE(tegra_usb_phy_pdata));
722
723         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
724         platform_device_register(&tegra_otg_device);
725         if (bi.board_id == BOARD_PM267) {
726                 uhsic_phy_config.reset_gpio =
727                         PM267_SMSC4640_HSIC_HUB_RESET_GPIO;
728                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
729                 platform_device_register(&tegra_ehci2_device);
730         } else if (bi.board_id == BOARD_E1256) {
731                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
732                 platform_device_register(&tegra_ehci2_device);
733         } else if (bi.board_id == BOARD_E1186) {
734                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
735                 /* baseband registration happens in baseband-xmm-power  */
736         } else {
737                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_pdata[1];
738                 platform_device_register(&tegra_ehci2_device);
739         }
740
741         tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
742         platform_device_register(&tegra_ehci3_device);
743
744 }
745 #else
746 static void cardhu_usb_init(void) { }
747 #endif
748
749 static void cardhu_gps_init(void)
750 {
751         tegra_gpio_enable(TEGRA_GPIO_PU2);
752         tegra_gpio_enable(TEGRA_GPIO_PU3);
753 }
754
755 static struct baseband_power_platform_data tegra_baseband_power_data = {
756         .baseband_type = BASEBAND_XMM,
757         .modem = {
758         .xmm = {
759                         .bb_rst = XMM_GPIO_BB_RST,
760                         .bb_on = XMM_GPIO_BB_ON,
761                         .ipc_bb_wake = XMM_GPIO_IPC_BB_WAKE,
762                         .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
763                         .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
764                         .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
765                         .hsic_device = &tegra_ehci2_device,
766                 },
767         },
768 };
769
770 static struct platform_device tegra_baseband_power_device = {
771         .name = "baseband_xmm_power",
772         .id = -1,
773         .dev = {
774                 .platform_data = &tegra_baseband_power_data,
775         },
776 };
777
778 static struct platform_device tegra_baseband_power2_device = {
779         .name = "baseband_xmm_power2",
780         .id = -1,
781         .dev = {
782                 .platform_data = &tegra_baseband_power_data,
783         },
784 };
785
786 static void cardhu_modem_init(void)
787 {
788         struct board_info board_info;
789         int w_disable_gpio, ret;
790
791         tegra_get_board_info(&board_info);
792         switch (board_info.board_id) {
793         case BOARD_E1291:
794         case BOARD_E1198:
795                 if (((board_info.board_id == BOARD_E1291) &&
796                                 (board_info.fab < BOARD_FAB_A03)) ||
797                         ((board_info.board_id == BOARD_E1198) &&
798                                         (board_info.fab < BOARD_FAB_A02))) {
799                         w_disable_gpio = TEGRA_GPIO_PH5;
800                 } else {
801                         w_disable_gpio = TEGRA_GPIO_PDD5;
802                 }
803                 tegra_gpio_enable(w_disable_gpio);
804                 ret = gpio_request(w_disable_gpio, "w_disable_gpio");
805                 if (ret < 0)
806                         pr_err("%s: gpio_request failed for gpio %d\n",
807                                 __func__, w_disable_gpio);
808                 else
809                         gpio_direction_input(w_disable_gpio);
810
811                 /* E1291-A04 & E1198:A02: Set PERST signal to low */
812                 if (((board_info.board_id == BOARD_E1291) &&
813                                 (board_info.fab >= BOARD_FAB_A04)) ||
814                         ((board_info.board_id == BOARD_E1198) &&
815                                         (board_info.fab >= BOARD_FAB_A02))) {
816                         ret = gpio_request(TEGRA_GPIO_PH7, "modem_perst");
817                         if (ret < 0) {
818                                 pr_err("%s(): Error in allocating gpio "
819                                         "TEGRA_GPIO_PH7\n", __func__);
820                                 break;
821                         }
822                         gpio_direction_output(TEGRA_GPIO_PH7, 0);
823                         tegra_gpio_enable(TEGRA_GPIO_PH7);
824                 }
825                 break;
826         case BOARD_E1186:
827                 tegra_gpio_enable(
828                         tegra_baseband_power_data.modem.xmm.bb_rst);
829                 tegra_gpio_enable(
830                         tegra_baseband_power_data.modem.xmm.bb_on);
831                 tegra_gpio_enable(
832                         tegra_baseband_power_data.modem.xmm.ipc_bb_wake);
833                 tegra_gpio_enable(
834                         tegra_baseband_power_data.modem.xmm.ipc_ap_wake);
835                 tegra_gpio_enable(
836                         tegra_baseband_power_data.modem.xmm.ipc_hsic_active);
837                 tegra_gpio_enable(
838                         tegra_baseband_power_data.modem.xmm.ipc_hsic_sus_req);
839                 platform_device_register(&tegra_baseband_power_device);
840                 platform_device_register(&tegra_baseband_power2_device);
841                 break;
842         default:
843                 break;
844         }
845
846 }
847
848 #ifdef CONFIG_SATA_AHCI_TEGRA
849 static void cardhu_sata_init(void)
850 {
851         platform_device_register(&tegra_sata_device);
852 }
853 #else
854 static void cardhu_sata_init(void) { }
855 #endif
856
857 static void __init tegra_cardhu_init(void)
858 {
859         tegra_clk_init_from_table(cardhu_clk_init_table);
860         cardhu_pinmux_init();
861         cardhu_i2c_init();
862         cardhu_spi_init();
863         cardhu_usb_init();
864 #ifdef CONFIG_TEGRA_EDP_LIMITS
865         cardhu_edp_init();
866 #endif
867         cardhu_uart_init();
868         cardhu_tsensor_init();
869         platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
870         cardhu_sdhci_init();
871         cardhu_regulator_init();
872         cardhu_gpio_switch_regulator_init();
873         cardhu_suspend_init();
874         cardhu_power_off_init();
875         cardhu_touch_init();
876         cardhu_gps_init();
877         cardhu_modem_init();
878         cardhu_kbc_init();
879         cardhu_scroll_init();
880         cardhu_keys_init();
881         cardhu_panel_init();
882         cardhu_pmon_init();
883         cardhu_sensors_init();
884         cardhu_bt_rfkill();
885         tegra_setup_bluesleep();
886         cardhu_sata_init();
887         //audio_wired_jack_init();
888         cardhu_pins_state_init();
889         cardhu_emc_init();
890         tegra_release_bootloader_fb();
891 }
892
893 static void __init tegra_cardhu_reserve(void)
894 {
895 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
896         /* support 1920X1200 with 24bpp */
897         tegra_reserve(0, SZ_8M + SZ_1M, SZ_8M + SZ_1M);
898 #else
899         tegra_reserve(SZ_128M, SZ_8M, SZ_8M);
900 #endif
901 }
902
903 MACHINE_START(CARDHU, "cardhu")
904         .boot_params    = 0x80000100,
905         .map_io         = tegra_map_common_io,
906         .reserve        = tegra_cardhu_reserve,
907         .init_early     = tegra_init_early,
908         .init_irq       = tegra_init_irq,
909         .timer          = &tegra_timer,
910         .init_machine   = tegra_cardhu_init,
911 MACHINE_END