Ventana: KBC: Removing the KBC usage on ventana
[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,              true},
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         { "vi_sensor",  "pll_p",        150000000,      false},
195         { NULL,         NULL,           0,              0},
196 };
197
198 static struct tegra_i2c_platform_data cardhu_i2c1_platform_data = {
199         .adapter_nr     = 0,
200         .bus_count      = 1,
201         .bus_clk_rate   = { 100000, 0 },
202         .scl_gpio               = {TEGRA_GPIO_PC4, 0},
203         .sda_gpio               = {TEGRA_GPIO_PC5, 0},
204         .arb_recovery = arb_lost_recovery,
205 };
206
207 static struct tegra_i2c_platform_data cardhu_i2c2_platform_data = {
208         .adapter_nr     = 1,
209         .bus_count      = 1,
210         .bus_clk_rate   = { 100000, 0 },
211         .is_clkon_always = true,
212         .scl_gpio               = {TEGRA_GPIO_PT5, 0},
213         .sda_gpio               = {TEGRA_GPIO_PT6, 0},
214         .arb_recovery = arb_lost_recovery,
215 };
216
217 static struct tegra_i2c_platform_data cardhu_i2c3_platform_data = {
218         .adapter_nr     = 2,
219         .bus_count      = 1,
220         .bus_clk_rate   = { 100000, 0 },
221         .scl_gpio               = {TEGRA_GPIO_PBB1, 0},
222         .sda_gpio               = {TEGRA_GPIO_PBB2, 0},
223         .arb_recovery = arb_lost_recovery,
224 };
225
226 static struct tegra_i2c_platform_data cardhu_i2c4_platform_data = {
227         .adapter_nr     = 3,
228         .bus_count      = 1,
229         .bus_clk_rate   = { 100000, 0 },
230         .scl_gpio               = {TEGRA_GPIO_PV4, 0},
231         .sda_gpio               = {TEGRA_GPIO_PV5, 0},
232         .arb_recovery = arb_lost_recovery,
233 };
234
235 static struct tegra_i2c_platform_data cardhu_i2c5_platform_data = {
236         .adapter_nr     = 4,
237         .bus_count      = 1,
238         .bus_clk_rate   = { 100000, 0 },
239         .scl_gpio               = {TEGRA_GPIO_PZ6, 0},
240         .sda_gpio               = {TEGRA_GPIO_PZ7, 0},
241         .arb_recovery = arb_lost_recovery,
242 };
243
244
245 #if 0
246 struct tegra_wired_jack_conf audio_wr_jack_conf = {
247         .hp_det_n = TEGRA_GPIO_PW2,
248         .en_mic_ext = TEGRA_GPIO_PX1,
249         .en_mic_int = TEGRA_GPIO_PX0,
250 };
251 #endif
252
253 static struct wm8903_platform_data cardhu_wm8903_pdata = {
254         .irq_active_low = 0,
255         .micdet_cfg = 0,
256         .micdet_delay = 100,
257         .gpio_base = CARDHU_GPIO_WM8903(0),
258         .gpio_cfg = {
259                 WM8903_GPIO_NO_CONFIG,
260                 WM8903_GPIO_NO_CONFIG,
261                 0,
262                 WM8903_GPIO_NO_CONFIG,
263                 WM8903_GPIO_NO_CONFIG,
264         },
265 };
266
267 static struct i2c_board_info __initdata wm8903_board_info = {
268         I2C_BOARD_INFO("wm8903", 0x1a),
269         .platform_data = &cardhu_wm8903_pdata,
270         .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
271 };
272
273 static void cardhu_i2c_init(void)
274 {
275         tegra_i2c_device1.dev.platform_data = &cardhu_i2c1_platform_data;
276         tegra_i2c_device2.dev.platform_data = &cardhu_i2c2_platform_data;
277         tegra_i2c_device3.dev.platform_data = &cardhu_i2c3_platform_data;
278         tegra_i2c_device4.dev.platform_data = &cardhu_i2c4_platform_data;
279         tegra_i2c_device5.dev.platform_data = &cardhu_i2c5_platform_data;
280
281         platform_device_register(&tegra_i2c_device5);
282         platform_device_register(&tegra_i2c_device4);
283         platform_device_register(&tegra_i2c_device3);
284         platform_device_register(&tegra_i2c_device2);
285         platform_device_register(&tegra_i2c_device1);
286
287         i2c_register_board_info(4, &wm8903_board_info, 1);
288 }
289
290 static struct platform_device *cardhu_uart_devices[] __initdata = {
291         &tegra_uarta_device,
292         &tegra_uartb_device,
293         &tegra_uartc_device,
294         &tegra_uartd_device,
295         &tegra_uarte_device,
296 };
297 static struct uart_clk_parent uart_parent_clk[] = {
298         [0] = {.name = "clk_m"},
299         [1] = {.name = "pll_p"},
300         [2] = {.name = "pll_m"},
301 };
302
303 static struct tegra_uart_platform_data cardhu_uart_pdata;
304
305 static void __init uart_debug_init(void)
306 {
307         struct board_info board_info;
308
309         tegra_get_board_info(&board_info);
310         /* UARTB is debug port
311          *       for SLT - E1186/E1187/PM269
312          *       for E1256
313          */
314         if (((board_info.sku & SKU_SLT_ULPI_SUPPORT) &&
315                 ((board_info.board_id == BOARD_E1186) ||
316                 (board_info.board_id == BOARD_E1187) ||
317                 (board_info.board_id == BOARD_PM269))) ||
318                 (board_info.board_id == BOARD_E1256)) {
319                         /* UARTB is the debug port. */
320                         pr_info("Selecting UARTB as the debug console\n");
321                         cardhu_uart_devices[1] = &debug_uartb_device;
322                         debug_uart_clk =  clk_get_sys("serial8250.0", "uartb");
323                         debug_uart_port_base = ((struct plat_serial8250_port *)(
324                                 debug_uartb_device.dev.platform_data))->mapbase;
325                         return;
326         }
327         /* UARTA is the debug port. */
328         pr_info("Selecting UARTA as the debug console\n");
329         cardhu_uart_devices[0] = &debug_uarta_device;
330         debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
331         debug_uart_port_base = ((struct plat_serial8250_port *)(
332                         debug_uarta_device.dev.platform_data))->mapbase;
333 }
334
335 static void __init cardhu_uart_init(void)
336 {
337         struct clk *c;
338         int i;
339
340         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
341                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
342                 if (IS_ERR_OR_NULL(c)) {
343                         pr_err("Not able to get the clock for %s\n",
344                                                 uart_parent_clk[i].name);
345                         continue;
346                 }
347                 uart_parent_clk[i].parent_clk = c;
348                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
349         }
350         cardhu_uart_pdata.parent_clk_list = uart_parent_clk;
351         cardhu_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
352         tegra_uarta_device.dev.platform_data = &cardhu_uart_pdata;
353         tegra_uartb_device.dev.platform_data = &cardhu_uart_pdata;
354         tegra_uartc_device.dev.platform_data = &cardhu_uart_pdata;
355         tegra_uartd_device.dev.platform_data = &cardhu_uart_pdata;
356         tegra_uarte_device.dev.platform_data = &cardhu_uart_pdata;
357
358         /* Register low speed only if it is selected */
359         if (!is_tegra_debug_uartport_hs()) {
360                 uart_debug_init();
361                 /* Clock enable for the debug channel */
362                 if (!IS_ERR_OR_NULL(debug_uart_clk)) {
363                         pr_info("The debug console clock name is %s\n",
364                                                 debug_uart_clk->name);
365                         c = tegra_get_clock_by_name("pll_p");
366                         if (IS_ERR_OR_NULL(c))
367                                 pr_err("Not getting the parent clock pll_p\n");
368                         else
369                                 clk_set_parent(debug_uart_clk, c);
370
371                         clk_enable(debug_uart_clk);
372                         clk_set_rate(debug_uart_clk, clk_get_rate(c));
373                 } else {
374                         pr_err("Not getting the clock %s for debug console\n",
375                                         debug_uart_clk->name);
376                 }
377         }
378
379         platform_add_devices(cardhu_uart_devices,
380                                 ARRAY_SIZE(cardhu_uart_devices));
381 }
382
383 static struct platform_device tegra_camera = {
384         .name = "tegra_camera",
385         .id = -1,
386 };
387
388 static struct platform_device *cardhu_spi_devices[] __initdata = {
389         &tegra_spi_device4,
390 };
391
392 struct spi_clk_parent spi_parent_clk[] = {
393         [0] = {.name = "pll_p"},
394         [1] = {.name = "pll_m"},
395         [2] = {.name = "clk_m"},
396 };
397
398 static struct tegra_spi_platform_data cardhu_spi_pdata = {
399         .is_dma_based           = true,
400         .max_dma_buffer         = (16 * 1024),
401         .is_clkon_always        = false,
402         .max_rate               = 100000000,
403 };
404
405 static void __init cardhu_spi_init(void)
406 {
407         int i;
408         struct clk *c;
409         struct board_info board_info;
410
411         tegra_get_board_info(&board_info);
412
413         for (i = 0; i < ARRAY_SIZE(spi_parent_clk); ++i) {
414                 c = tegra_get_clock_by_name(spi_parent_clk[i].name);
415                 if (IS_ERR_OR_NULL(c)) {
416                         pr_err("Not able to get the clock for %s\n",
417                                                 spi_parent_clk[i].name);
418                         continue;
419                 }
420                 spi_parent_clk[i].parent_clk = c;
421                 spi_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
422         }
423         cardhu_spi_pdata.parent_clk_list = spi_parent_clk;
424         cardhu_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk);
425         tegra_spi_device4.dev.platform_data = &cardhu_spi_pdata;
426         platform_add_devices(cardhu_spi_devices,
427                                 ARRAY_SIZE(cardhu_spi_devices));
428
429         if (board_info.board_id == BOARD_E1198) {
430                 tegra_spi_device2.dev.platform_data = &cardhu_spi_pdata;
431                 platform_device_register(&tegra_spi_device2);
432         }
433 }
434
435 static struct resource tegra_rtc_resources[] = {
436         [0] = {
437                 .start = TEGRA_RTC_BASE,
438                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
439                 .flags = IORESOURCE_MEM,
440         },
441         [1] = {
442                 .start = INT_RTC,
443                 .end = INT_RTC,
444                 .flags = IORESOURCE_IRQ,
445         },
446 };
447
448 static struct platform_device tegra_rtc_device = {
449         .name = "tegra_rtc",
450         .id   = -1,
451         .resource = tegra_rtc_resources,
452         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
453 };
454
455 static struct tegra_wm8903_platform_data cardhu_audio_pdata = {
456         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
457         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
458         .gpio_hp_mute           = -1,
459         .gpio_int_mic_en        = -1,
460         .gpio_ext_mic_en        = -1,
461 };
462
463 static struct platform_device cardhu_audio_device = {
464         .name   = "tegra-snd-wm8903",
465         .id     = 0,
466         .dev    = {
467                 .platform_data  = &cardhu_audio_pdata,
468         },
469 };
470
471 static struct platform_device *cardhu_devices[] __initdata = {
472         &tegra_pmu_device,
473         &tegra_rtc_device,
474         &tegra_udc_device,
475 #if defined(CONFIG_SND_HDA_TEGRA)
476         &tegra_hda_device,
477 #endif
478 #if defined(CONFIG_TEGRA_IOVMM_SMMU)
479         &tegra_smmu_device,
480 #endif
481         &tegra_wdt_device,
482 #if defined(CONFIG_TEGRA_AVP)
483         &tegra_avp_device,
484 #endif
485         &tegra_camera,
486 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
487         &tegra_se_device,
488 #endif
489         &tegra_ahub_device,
490         &tegra_i2s_device1,
491         &tegra_pcm_device,
492         &cardhu_audio_device,
493 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
494         &tegra_aes_device,
495 #endif
496 };
497
498 #define MXT_CONFIG_CRC  0xD62DE8
499 static const u8 config[] = {
500         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
501         0xFF, 0xFF, 0x32, 0x0A, 0x00, 0x14, 0x14, 0x00,
502         0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x00, 0x00,
503         0x1B, 0x2A, 0x00, 0x20, 0x3C, 0x04, 0x05, 0x00,
504         0x02, 0x01, 0x00, 0x0A, 0x0A, 0x0A, 0x0A, 0xFF,
505         0x02, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
506         0x00, 0x00, 0x00, 0x64, 0x02, 0x00, 0x00, 0x00,
507         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
508         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
509         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
510         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
511         0x00, 0x00, 0x00, 0x05, 0x0A, 0x15, 0x1E, 0x00,
512         0x00, 0x04, 0xFF, 0x03, 0x3F, 0x64, 0x64, 0x01,
513         0x0A, 0x14, 0x28, 0x4B, 0x00, 0x02, 0x00, 0x64,
514         0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
515         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
516         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
517         0x00, 0x00, 0x00, 0x08, 0x10, 0x3C, 0x00, 0x00,
518         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
519         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
520 };
521
522 #define MXT_CONFIG_CRC_SKU2000  0xA24D9A
523 static const u8 config_sku2000[] = {
524         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
525         0xFF, 0xFF, 0x32, 0x0A, 0x00, 0x14, 0x14, 0x19,
526         0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x00, 0x00,
527         0x1B, 0x2A, 0x00, 0x20, 0x3A, 0x04, 0x05, 0x00,  //23=thr  2 di
528         0x04, 0x04, 0x41, 0x0A, 0x0A, 0x0A, 0x0A, 0xFF,
529         0x02, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
530         0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,  //0A=limit
531         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
532         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
533         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
534         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
535         0x00, 0x00, 0x00, 0x05, 0x0A, 0x15, 0x1E, 0x00,
536         0x00, 0x04, 0x00, 0x03, 0x3F, 0x64, 0x64, 0x01,
537         0x0A, 0x14, 0x28, 0x4B, 0x00, 0x02, 0x00, 0x64,
538         0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
539         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
540         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
541         0x00, 0x00, 0x00, 0x08, 0x10, 0x3C, 0x00, 0x00,
542         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
543         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
544 };
545
546 static struct mxt_platform_data atmel_mxt_info = {
547         .x_line         = 27,
548         .y_line         = 42,
549         .x_size         = 768,
550         .y_size         = 1366,
551         .blen           = 0x20,
552         .threshold      = 0x3C,
553         .voltage        = 3300000,              /* 3.3V */
554         .orient         = 5,
555         .config         = config,
556         .config_length  = 157,
557         .config_crc     = MXT_CONFIG_CRC,
558         .irqflags       = IRQF_TRIGGER_FALLING,
559 /*      .read_chg       = &read_chg, */
560         .read_chg       = NULL,
561 };
562
563 static struct i2c_board_info __initdata atmel_i2c_info[] = {
564         {
565                 I2C_BOARD_INFO("atmel_mxt_ts", 0x5A),
566                 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PH4),
567                 .platform_data = &atmel_mxt_info,
568         }
569 };
570
571 static int __init cardhu_touch_init(void)
572 {
573         struct board_info BoardInfo;
574
575         tegra_gpio_enable(TEGRA_GPIO_PH4);
576         tegra_gpio_enable(TEGRA_GPIO_PH6);
577
578         gpio_request(TEGRA_GPIO_PH4, "atmel-irq");
579         gpio_direction_input(TEGRA_GPIO_PH4);
580
581         gpio_request(TEGRA_GPIO_PH6, "atmel-reset");
582         gpio_direction_output(TEGRA_GPIO_PH6, 0);
583         msleep(1);
584         gpio_set_value(TEGRA_GPIO_PH6, 1);
585         msleep(100);
586
587         tegra_get_board_info(&BoardInfo);
588         if ((BoardInfo.sku & SKU_TOUCH_MASK) == SKU_TOUCH_2000) {
589                 atmel_mxt_info.config = config_sku2000;
590                 atmel_mxt_info.config_crc = MXT_CONFIG_CRC_SKU2000;
591         }
592
593         i2c_register_board_info(1, atmel_i2c_info, 1);
594
595         return 0;
596 }
597
598 static struct tegra_uhsic_config uhsic_phy_config = {
599         .enable_gpio = EN_HSIC_GPIO,
600         .reset_gpio = -1,
601         .sync_start_delay = 9,
602         .idle_wait_delay = 17,
603         .term_range_adj = 0,
604         .elastic_underrun_limit = 16,
605         .elastic_overrun_limit = 16,
606 };
607
608 static struct tegra_ehci_platform_data tegra_ehci_uhsic_pdata = {
609         .phy_type = TEGRA_USB_PHY_TYPE_HSIC,
610         .phy_config = &uhsic_phy_config,
611         .operating_mode = TEGRA_USB_HOST,
612         .power_down_on_bus_suspend = 1,
613 };
614
615 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
616         [0] = {
617                         .phy_config = &utmi_phy_config[0],
618                         .operating_mode = TEGRA_USB_HOST,
619                         .power_down_on_bus_suspend = 1,
620         },
621         [1] = {
622                         .phy_config = &utmi_phy_config[1],
623                         .operating_mode = TEGRA_USB_HOST,
624                         .power_down_on_bus_suspend = 1,
625         },
626         [2] = {
627                         .phy_config = &utmi_phy_config[2],
628                         .operating_mode = TEGRA_USB_HOST,
629                         .power_down_on_bus_suspend = 1,
630         },
631 };
632
633 static struct platform_device *tegra_usb_otg_host_register(void)
634 {
635         struct platform_device *pdev;
636         void *platform_data;
637         int val;
638
639         pdev = platform_device_alloc(tegra_ehci1_device.name,
640                 tegra_ehci1_device.id);
641         if (!pdev)
642                 return NULL;
643
644         val = platform_device_add_resources(pdev, tegra_ehci1_device.resource,
645                 tegra_ehci1_device.num_resources);
646         if (val)
647                 goto error;
648
649         pdev->dev.dma_mask =  tegra_ehci1_device.dev.dma_mask;
650         pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask;
651
652         platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data),
653                 GFP_KERNEL);
654         if (!platform_data)
655                 goto error;
656
657         memcpy(platform_data, &tegra_ehci_pdata[0],
658                                 sizeof(struct tegra_ehci_platform_data));
659         pdev->dev.platform_data = platform_data;
660
661         val = platform_device_add(pdev);
662         if (val)
663                 goto error_add;
664
665         return pdev;
666
667 error_add:
668         kfree(platform_data);
669 error:
670         pr_err("%s: failed to add the host contoller device\n", __func__);
671         platform_device_put(pdev);
672         return NULL;
673 }
674
675 static void tegra_usb_otg_host_unregister(struct platform_device *pdev)
676 {
677         platform_device_unregister(pdev);
678 }
679
680 #ifdef CONFIG_USB_SUPPORT
681 static struct usb_phy_plat_data tegra_usb_phy_pdata[] = {
682         [0] = {
683                         .instance = 0,
684                         .vbus_gpio = -1,
685                         .vbus_reg_supply = "vdd_vbus_micro_usb",
686         },
687         [1] = {
688                         .instance = 1,
689                         .vbus_gpio = -1,
690         },
691         [2] = {
692                         .instance = 2,
693                         .vbus_gpio = -1,
694                         .vbus_reg_supply = "vdd_vbus_typea_usb",
695         },
696 };
697
698 static struct tegra_otg_platform_data tegra_otg_pdata = {
699         .host_register = &tegra_usb_otg_host_register,
700         .host_unregister = &tegra_usb_otg_host_unregister,
701 };
702
703 static void cardhu_usb_init(void)
704 {
705         struct board_info bi;
706
707         tegra_get_board_info(&bi);
708
709         tegra_usb_phy_init(tegra_usb_phy_pdata,
710                         ARRAY_SIZE(tegra_usb_phy_pdata));
711
712         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
713         platform_device_register(&tegra_otg_device);
714         if (bi.board_id == BOARD_PM267) {
715                 uhsic_phy_config.reset_gpio =
716                         PM267_SMSC4640_HSIC_HUB_RESET_GPIO;
717                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
718                 platform_device_register(&tegra_ehci2_device);
719         } else if (bi.board_id == BOARD_E1256) {
720                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
721                 platform_device_register(&tegra_ehci2_device);
722         } else if (bi.board_id == BOARD_E1186) {
723                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
724                 /* baseband registration happens in baseband-xmm-power  */
725         } else {
726                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_pdata[1];
727                 platform_device_register(&tegra_ehci2_device);
728         }
729
730         tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
731         platform_device_register(&tegra_ehci3_device);
732
733 }
734 #else
735 static void cardhu_usb_init(void) { }
736 #endif
737
738 static void cardhu_gps_init(void)
739 {
740         tegra_gpio_enable(TEGRA_GPIO_PU2);
741         tegra_gpio_enable(TEGRA_GPIO_PU3);
742 }
743
744 static struct baseband_power_platform_data tegra_baseband_power_data = {
745         .baseband_type = BASEBAND_XMM,
746         .modem = {
747         .xmm = {
748                         .bb_rst = XMM_GPIO_BB_RST,
749                         .bb_on = XMM_GPIO_BB_ON,
750                         .ipc_bb_wake = XMM_GPIO_IPC_BB_WAKE,
751                         .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
752                         .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
753                         .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
754                         .hsic_device = &tegra_ehci2_device,
755                 },
756         },
757 };
758
759 static struct platform_device tegra_baseband_power_device = {
760         .name = "baseband_xmm_power",
761         .id = -1,
762         .dev = {
763                 .platform_data = &tegra_baseband_power_data,
764         },
765 };
766
767 static struct platform_device tegra_baseband_power2_device = {
768         .name = "baseband_xmm_power2",
769         .id = -1,
770         .dev = {
771                 .platform_data = &tegra_baseband_power_data,
772         },
773 };
774
775 static void cardhu_modem_init(void)
776 {
777         struct board_info board_info;
778         int w_disable_gpio, ret;
779
780         tegra_get_board_info(&board_info);
781         switch (board_info.board_id) {
782         case BOARD_E1291:
783                 if (board_info.fab < BOARD_FAB_A03) {
784                         w_disable_gpio = TEGRA_GPIO_PH5;
785                 } else {
786                         w_disable_gpio = TEGRA_GPIO_PDD5;
787                 }
788                 tegra_gpio_enable(w_disable_gpio);
789                 ret = gpio_request(w_disable_gpio, "w_disable_gpio");
790                 if (ret < 0)
791                         pr_err("%s: gpio_request failed for gpio %d\n",
792                                 __func__, w_disable_gpio);
793                 else
794                         gpio_direction_input(w_disable_gpio);
795
796                 /* E1291-A04: Set PERST signal to low */
797                 if (board_info.fab >= BOARD_FAB_A04) {
798                         ret = gpio_request(TEGRA_GPIO_PH7, "modem_perst");
799                         if (ret < 0) {
800                                 pr_err("%s(): Error in allocating gpio "
801                                         "TEGRA_GPIO_PH7\n", __func__);
802                                 break;
803                         }
804                         gpio_direction_output(TEGRA_GPIO_PH7, 0);
805                         tegra_gpio_enable(TEGRA_GPIO_PH7);
806                 }
807                 break;
808         case BOARD_E1186:
809                 tegra_gpio_enable(
810                         tegra_baseband_power_data.modem.xmm.bb_rst);
811                 tegra_gpio_enable(
812                         tegra_baseband_power_data.modem.xmm.bb_on);
813                 tegra_gpio_enable(
814                         tegra_baseband_power_data.modem.xmm.ipc_bb_wake);
815                 tegra_gpio_enable(
816                         tegra_baseband_power_data.modem.xmm.ipc_ap_wake);
817                 tegra_gpio_enable(
818                         tegra_baseband_power_data.modem.xmm.ipc_hsic_active);
819                 tegra_gpio_enable(
820                         tegra_baseband_power_data.modem.xmm.ipc_hsic_sus_req);
821                 platform_device_register(&tegra_baseband_power_device);
822                 platform_device_register(&tegra_baseband_power2_device);
823                 break;
824         default:
825                 break;
826         }
827
828 }
829
830 #ifdef CONFIG_SATA_AHCI_TEGRA
831 static void cardhu_sata_init(void)
832 {
833         platform_device_register(&tegra_sata_device);
834 }
835 #else
836 static void cardhu_sata_init(void) { }
837 #endif
838
839 static void __init tegra_cardhu_init(void)
840 {
841         tegra_clk_init_from_table(cardhu_clk_init_table);
842         cardhu_pinmux_init();
843         cardhu_i2c_init();
844         cardhu_spi_init();
845         cardhu_usb_init();
846 #ifdef CONFIG_TEGRA_EDP_LIMITS
847         cardhu_edp_init();
848 #endif
849         cardhu_uart_init();
850         cardhu_tsensor_init();
851         platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
852         cardhu_sdhci_init();
853         cardhu_regulator_init();
854         cardhu_gpio_switch_regulator_init();
855         cardhu_suspend_init();
856         cardhu_power_off_init();
857         cardhu_touch_init();
858         cardhu_gps_init();
859         cardhu_modem_init();
860         cardhu_kbc_init();
861         cardhu_scroll_init();
862         cardhu_keys_init();
863         cardhu_panel_init();
864         cardhu_pmon_init();
865         cardhu_sensors_init();
866         cardhu_bt_rfkill();
867         tegra_setup_bluesleep();
868         cardhu_sata_init();
869         //audio_wired_jack_init();
870         cardhu_pins_state_init();
871         cardhu_emc_init();
872         tegra_release_bootloader_fb();
873 }
874
875 static void __init tegra_cardhu_reserve(void)
876 {
877 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
878         tegra_reserve(0, SZ_8M, SZ_8M);
879 #else
880         tegra_reserve(SZ_128M, SZ_8M, SZ_8M);
881 #endif
882 }
883
884 MACHINE_START(CARDHU, "cardhu")
885         .boot_params    = 0x80000100,
886         .map_io         = tegra_map_common_io,
887         .reserve        = tegra_cardhu_reserve,
888         .init_early     = tegra_init_early,
889         .init_irq       = tegra_init_irq,
890         .timer          = &tegra_timer,
891         .init_machine   = tegra_cardhu_init,
892 MACHINE_END