ARM: tegra: cardhu: switch off PMU at high temperature
[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_lsfslew = 2,
74                         .xcvr_lsrslew = 2,
75         },
76         [1] = {
77                         .hssync_start_delay = 0,
78                         .idle_wait_delay = 17,
79                         .elastic_limit = 16,
80                         .term_range_adj = 6,
81                         .xcvr_setup = 15,
82                         .xcvr_lsfslew = 2,
83                         .xcvr_lsrslew = 2,
84         },
85         [2] = {
86                         .hssync_start_delay = 0,
87                         .idle_wait_delay = 17,
88                         .elastic_limit = 16,
89                         .term_range_adj = 6,
90                         .xcvr_setup = 8,
91                         .xcvr_lsfslew = 2,
92                         .xcvr_lsrslew = 2,
93         },
94 };
95
96 #ifdef CONFIG_BCM4329_RFKILL
97 static struct resource cardhu_bcm4329_rfkill_resources[] = {
98         {
99                 .name   = "bcm4329_nshutdown_gpio",
100                 .start  = TEGRA_GPIO_PU0,
101                 .end    = TEGRA_GPIO_PU0,
102                 .flags  = IORESOURCE_IO,
103         },
104 };
105
106 static struct platform_device cardhu_bcm4329_rfkill_device = {
107         .name = "bcm4329_rfkill",
108         .id             = -1,
109         .num_resources  = ARRAY_SIZE(cardhu_bcm4329_rfkill_resources),
110         .resource       = cardhu_bcm4329_rfkill_resources,
111 };
112
113 static noinline void __init cardhu_bt_rfkill(void)
114 {
115         platform_device_register(&cardhu_bcm4329_rfkill_device);
116
117         return;
118 }
119 #else
120 static inline void cardhu_bt_rfkill(void) { }
121 #endif
122
123 #ifdef CONFIG_BT_BLUESLEEP
124 static noinline void __init tegra_setup_bluesleep(void)
125 {
126         struct platform_device *pdev = NULL;
127         struct resource *res;
128
129         pdev = platform_device_alloc("bluesleep", 0);
130         if (!pdev) {
131                 pr_err("unable to allocate platform device for bluesleep");
132                 return;
133         }
134
135         res = kzalloc(sizeof(struct resource) * 3, GFP_KERNEL);
136         if (!res) {
137                 pr_err("unable to allocate resource for bluesleep\n");
138                 goto err_free_dev;
139         }
140
141         res[0].name   = "gpio_host_wake";
142         res[0].start  = TEGRA_GPIO_PU6;
143         res[0].end    = TEGRA_GPIO_PU6;
144         res[0].flags  = IORESOURCE_IO;
145
146         res[1].name   = "gpio_ext_wake";
147         res[1].start  = TEGRA_GPIO_PU1;
148         res[1].end    = TEGRA_GPIO_PU1;
149         res[1].flags  = IORESOURCE_IO;
150
151         res[2].name   = "host_wake";
152         res[2].start  = gpio_to_irq(TEGRA_GPIO_PU6);
153         res[2].end    = gpio_to_irq(TEGRA_GPIO_PU6);
154         res[2].flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE ;
155
156         if (platform_device_add_resources(pdev, res, 3)) {
157                 pr_err("unable to add resources to bluesleep device\n");
158                 goto err_free_res;
159         }
160
161         if (platform_device_add(pdev)) {
162                 pr_err("unable to add bluesleep device\n");
163                 goto err_free_res;
164         }
165         tegra_gpio_enable(TEGRA_GPIO_PU6);
166         tegra_gpio_enable(TEGRA_GPIO_PU1);
167
168 return;
169
170 err_free_res:
171         kfree(res);
172 err_free_dev:
173         platform_device_put(pdev);
174         return;
175 }
176 #else
177 static inline void tegra_setup_bluesleep(void) { }
178 #endif
179
180 static __initdata struct tegra_clk_init_table cardhu_clk_init_table[] = {
181         /* name         parent          rate            enabled */
182         { "pll_m",      NULL,           0,              true},
183         { "hda",        "pll_p",        108000000,      false},
184         { "hda2codec_2x","pll_p",       48000000,       false},
185         { "pwm",        "clk_32k",      32768,          false},
186         { "blink",      "clk_32k",      32768,          true},
187         { "i2s1",       "pll_a_out0",   0,              false},
188         { NULL,         NULL,           0,              0},
189 };
190
191 static struct tegra_i2c_platform_data cardhu_i2c1_platform_data = {
192         .adapter_nr     = 0,
193         .bus_count      = 1,
194         .bus_clk_rate   = { 100000, 0 },
195 };
196
197 static struct tegra_i2c_platform_data cardhu_i2c2_platform_data = {
198         .adapter_nr     = 1,
199         .bus_count      = 1,
200         .bus_clk_rate   = { 100000, 0 },
201         .is_clkon_always = true,
202 };
203
204 static struct tegra_i2c_platform_data cardhu_i2c3_platform_data = {
205         .adapter_nr     = 2,
206         .bus_count      = 1,
207         .bus_clk_rate   = { 100000, 0 },
208 };
209
210 static struct tegra_i2c_platform_data cardhu_i2c4_platform_data = {
211         .adapter_nr     = 3,
212         .bus_count      = 1,
213         .bus_clk_rate   = { 100000, 0 },
214 };
215
216 static struct tegra_i2c_platform_data cardhu_i2c5_platform_data = {
217         .adapter_nr     = 4,
218         .bus_count      = 1,
219         .bus_clk_rate   = { 100000, 0 },
220 };
221
222
223 #if 0
224 struct tegra_wired_jack_conf audio_wr_jack_conf = {
225         .hp_det_n = TEGRA_GPIO_PW2,
226         .en_mic_ext = TEGRA_GPIO_PX1,
227         .en_mic_int = TEGRA_GPIO_PX0,
228 };
229 #endif
230
231 static struct wm8903_platform_data cardhu_wm8903_pdata = {
232         .irq_active_low = 0,
233         .micdet_cfg = 0,
234         .micdet_delay = 100,
235         .gpio_base = CARDHU_GPIO_WM8903(0),
236         .gpio_cfg = {
237                 WM8903_GPIO_NO_CONFIG,
238                 WM8903_GPIO_NO_CONFIG,
239                 0,
240                 WM8903_GPIO_NO_CONFIG,
241                 WM8903_GPIO_NO_CONFIG,
242         },
243 };
244
245 static struct i2c_board_info __initdata wm8903_board_info = {
246         I2C_BOARD_INFO("wm8903", 0x1a),
247         .platform_data = &cardhu_wm8903_pdata,
248         .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
249 };
250
251 static void cardhu_i2c_init(void)
252 {
253         tegra_i2c_device1.dev.platform_data = &cardhu_i2c1_platform_data;
254         tegra_i2c_device2.dev.platform_data = &cardhu_i2c2_platform_data;
255         tegra_i2c_device3.dev.platform_data = &cardhu_i2c3_platform_data;
256         tegra_i2c_device4.dev.platform_data = &cardhu_i2c4_platform_data;
257         tegra_i2c_device5.dev.platform_data = &cardhu_i2c5_platform_data;
258
259         platform_device_register(&tegra_i2c_device5);
260         platform_device_register(&tegra_i2c_device4);
261         platform_device_register(&tegra_i2c_device3);
262         platform_device_register(&tegra_i2c_device2);
263         platform_device_register(&tegra_i2c_device1);
264
265         i2c_register_board_info(4, &wm8903_board_info, 1);
266 }
267
268 static struct platform_device *cardhu_uart_devices[] __initdata = {
269         &tegra_uarta_device,
270         &tegra_uartb_device,
271         &tegra_uartc_device,
272         &tegra_uartd_device,
273         &tegra_uarte_device,
274 };
275 static struct uart_clk_parent uart_parent_clk[] = {
276         [0] = {.name = "pll_p"},
277         [1] = {.name = "pll_m"},
278         [2] = {.name = "clk_m"},
279 };
280
281 static struct tegra_uart_platform_data cardhu_uart_pdata;
282
283 static void __init uart_debug_init(void)
284 {
285         struct board_info board_info;
286
287         tegra_get_board_info(&board_info);
288         if (board_info.sku & SKU_SLT_ULPI_SUPPORT) {
289                 if ((board_info.board_id == BOARD_E1186) ||
290                         (board_info.board_id == BOARD_E1187) ||
291                         (board_info.board_id == BOARD_PM269)) {
292                         /* UARTB is the debug port. */
293                         pr_info("Selecting UARTB as the debug console\n");
294                         cardhu_uart_devices[1] = &debug_uartb_device;
295                         debug_uart_clk =  clk_get_sys("serial8250.0", "uartb");
296                         debug_uart_port_base = ((struct plat_serial8250_port *)(
297                                 debug_uartb_device.dev.platform_data))->mapbase;
298                         return;
299                 }
300                 pr_err("%s(): Unhandled SKU information for Board 0x%04x\n",
301                                 __func__, board_info.board_id);
302         }
303         /* UARTA is the debug port. */
304         pr_info("Selecting UARTA as the debug console\n");
305         cardhu_uart_devices[0] = &debug_uarta_device;
306         debug_uart_clk = clk_get_sys("serial8250.0", "uarta");
307         debug_uart_port_base = ((struct plat_serial8250_port *)(
308                         debug_uarta_device.dev.platform_data))->mapbase;
309 }
310
311 static void __init cardhu_uart_init(void)
312 {
313         struct clk *c;
314         int i;
315
316         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
317                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
318                 if (IS_ERR_OR_NULL(c)) {
319                         pr_err("Not able to get the clock for %s\n",
320                                                 uart_parent_clk[i].name);
321                         continue;
322                 }
323                 uart_parent_clk[i].parent_clk = c;
324                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
325         }
326         cardhu_uart_pdata.parent_clk_list = uart_parent_clk;
327         cardhu_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
328         tegra_uarta_device.dev.platform_data = &cardhu_uart_pdata;
329         tegra_uartb_device.dev.platform_data = &cardhu_uart_pdata;
330         tegra_uartc_device.dev.platform_data = &cardhu_uart_pdata;
331         tegra_uartd_device.dev.platform_data = &cardhu_uart_pdata;
332         tegra_uarte_device.dev.platform_data = &cardhu_uart_pdata;
333
334         /* Register low speed only if it is selected */
335         if (!is_tegra_debug_uartport_hs()) {
336                 uart_debug_init();
337                 /* Clock enable for the debug channel */
338                 if (!IS_ERR_OR_NULL(debug_uart_clk)) {
339                         pr_info("The debug console clock name is %s\n",
340                                                 debug_uart_clk->name);
341                         c = tegra_get_clock_by_name("pll_p");
342                         if (IS_ERR_OR_NULL(c))
343                                 pr_err("Not getting the parent clock pll_p\n");
344                         else
345                                 clk_set_parent(debug_uart_clk, c);
346
347                         clk_enable(debug_uart_clk);
348                         clk_set_rate(debug_uart_clk, clk_get_rate(c));
349                 } else {
350                         pr_err("Not getting the clock %s for debug console\n",
351                                         debug_uart_clk->name);
352                 }
353         }
354
355         platform_add_devices(cardhu_uart_devices,
356                                 ARRAY_SIZE(cardhu_uart_devices));
357 }
358
359 static struct platform_device tegra_camera = {
360         .name = "tegra_camera",
361         .id = -1,
362 };
363
364 static struct platform_device *cardhu_spi_devices[] __initdata = {
365         &tegra_spi_device4,
366 };
367
368 struct spi_clk_parent spi_parent_clk[] = {
369         [0] = {.name = "pll_p"},
370         [1] = {.name = "pll_m"},
371         [2] = {.name = "clk_m"},
372 };
373
374 static struct tegra_spi_platform_data cardhu_spi_pdata = {
375         .is_dma_based           = true,
376         .max_dma_buffer         = (16 * 1024),
377         .is_clkon_always        = false,
378         .max_rate               = 100000000,
379 };
380
381 static void __init cardhu_spi_init(void)
382 {
383         int i;
384         struct clk *c;
385
386         for (i = 0; i < ARRAY_SIZE(spi_parent_clk); ++i) {
387                 c = tegra_get_clock_by_name(spi_parent_clk[i].name);
388                 if (IS_ERR_OR_NULL(c)) {
389                         pr_err("Not able to get the clock for %s\n",
390                                                 spi_parent_clk[i].name);
391                         continue;
392                 }
393                 spi_parent_clk[i].parent_clk = c;
394                 spi_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
395         }
396         cardhu_spi_pdata.parent_clk_list = spi_parent_clk;
397         cardhu_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk);
398         tegra_spi_device4.dev.platform_data = &cardhu_spi_pdata;
399         platform_add_devices(cardhu_spi_devices,
400                                 ARRAY_SIZE(cardhu_spi_devices));
401 }
402
403 static struct tegra_wm8903_platform_data cardhu_audio_pdata = {
404         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
405         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
406         .gpio_hp_mute           = -1,
407         .gpio_int_mic_en        = -1,
408         .gpio_ext_mic_en        = -1,
409 };
410
411 static struct platform_device cardhu_audio_device = {
412         .name   = "tegra-snd-wm8903",
413         .id     = 0,
414         .dev    = {
415                 .platform_data  = &cardhu_audio_pdata,
416         },
417 };
418
419 static struct platform_device *cardhu_devices[] __initdata = {
420         &tegra_pmu_device,
421         &tegra_udc_device,
422 #if defined(CONFIG_SND_HDA_TEGRA)
423         &tegra_hda_device,
424 #endif
425 #if defined(CONFIG_TEGRA_IOVMM_SMMU)
426         &tegra_smmu_device,
427 #endif
428         &tegra_wdt_device,
429 #if defined(CONFIG_TEGRA_AVP)
430         &tegra_avp_device,
431 #endif
432         &tegra_camera,
433 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
434         &tegra_se_device,
435 #endif
436         &tegra_ahub_device,
437         &tegra_i2s_device1,
438         &tegra_pcm_device,
439         &cardhu_audio_device,
440 };
441
442 #define MXT_CONFIG_CRC  0xD62DE8
443 static const u8 config[] = {
444         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
445         0xFF, 0xFF, 0x32, 0x0A, 0x00, 0x14, 0x14, 0x00,
446         0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x00, 0x00,
447         0x1B, 0x2A, 0x00, 0x20, 0x3C, 0x04, 0x05, 0x00,
448         0x02, 0x01, 0x00, 0x0A, 0x0A, 0x0A, 0x0A, 0xFF,
449         0x02, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
450         0x00, 0x00, 0x00, 0x64, 0x02, 0x00, 0x00, 0x00,
451         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
452         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
453         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
454         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
455         0x00, 0x00, 0x00, 0x05, 0x0A, 0x15, 0x1E, 0x00,
456         0x00, 0x04, 0xFF, 0x03, 0x3F, 0x64, 0x64, 0x01,
457         0x0A, 0x14, 0x28, 0x4B, 0x00, 0x02, 0x00, 0x64,
458         0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
461         0x00, 0x00, 0x00, 0x08, 0x10, 0x3C, 0x00, 0x00,
462         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
463         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
464 };
465
466 static struct mxt_platform_data atmel_mxt_info = {
467         .x_line         = 27,
468         .y_line         = 42,
469         .x_size         = 768,
470         .y_size         = 1366,
471         .blen           = 0x20,
472         .threshold      = 0x3C,
473         .voltage        = 3300000,              /* 3.3V */
474         .orient         = 5,
475         .config         = config,
476         .config_length  = 157,
477         .config_crc     = MXT_CONFIG_CRC,
478         .irqflags       = IRQF_TRIGGER_FALLING,
479 /*      .read_chg       = &read_chg, */
480         .read_chg       = NULL,
481 };
482
483 static struct i2c_board_info __initdata atmel_i2c_info[] = {
484         {
485                 I2C_BOARD_INFO("atmel_mxt_ts", 0x5A),
486                 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PH4),
487                 .platform_data = &atmel_mxt_info,
488         }
489 };
490
491 static int __init cardhu_touch_init(void)
492 {
493         tegra_gpio_enable(TEGRA_GPIO_PH4);
494         tegra_gpio_enable(TEGRA_GPIO_PH6);
495
496         gpio_request(TEGRA_GPIO_PH4, "atmel-irq");
497         gpio_direction_input(TEGRA_GPIO_PH4);
498
499         gpio_request(TEGRA_GPIO_PH6, "atmel-reset");
500         gpio_direction_output(TEGRA_GPIO_PH6, 0);
501         msleep(1);
502         gpio_set_value(TEGRA_GPIO_PH6, 1);
503         msleep(100);
504
505         i2c_register_board_info(1, atmel_i2c_info, 1);
506
507         return 0;
508 }
509
510 static struct tegra_uhsic_config uhsic_phy_config = {
511         .enable_gpio = EN_HSIC_GPIO,
512         .reset_gpio = -1,
513         .sync_start_delay = 9,
514         .idle_wait_delay = 17,
515         .term_range_adj = 0,
516         .elastic_underrun_limit = 16,
517         .elastic_overrun_limit = 16,
518 };
519
520 static struct tegra_ehci_platform_data tegra_ehci_uhsic_pdata = {
521         .phy_type = TEGRA_USB_PHY_TYPE_HSIC,
522         .phy_config = &uhsic_phy_config,
523         .operating_mode = TEGRA_USB_HOST,
524         .power_down_on_bus_suspend = 1,
525 };
526
527 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
528         [0] = {
529                         .phy_config = &utmi_phy_config[0],
530                         .operating_mode = TEGRA_USB_HOST,
531                         .power_down_on_bus_suspend = 1,
532         },
533         [1] = {
534                         .phy_config = &utmi_phy_config[1],
535                         .operating_mode = TEGRA_USB_HOST,
536                         .power_down_on_bus_suspend = 1,
537         },
538         [2] = {
539                         .phy_config = &utmi_phy_config[2],
540                         .operating_mode = TEGRA_USB_HOST,
541                         .power_down_on_bus_suspend = 1,
542         },
543 };
544
545 static struct platform_device *tegra_usb_otg_host_register(void)
546 {
547         struct platform_device *pdev;
548         void *platform_data;
549         int val;
550
551         pdev = platform_device_alloc(tegra_ehci1_device.name,
552                 tegra_ehci1_device.id);
553         if (!pdev)
554                 return NULL;
555
556         val = platform_device_add_resources(pdev, tegra_ehci1_device.resource,
557                 tegra_ehci1_device.num_resources);
558         if (val)
559                 goto error;
560
561         pdev->dev.dma_mask =  tegra_ehci1_device.dev.dma_mask;
562         pdev->dev.coherent_dma_mask = tegra_ehci1_device.dev.coherent_dma_mask;
563
564         platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data),
565                 GFP_KERNEL);
566         if (!platform_data)
567                 goto error;
568
569         memcpy(platform_data, &tegra_ehci_pdata[0],
570                                 sizeof(struct tegra_ehci_platform_data));
571         pdev->dev.platform_data = platform_data;
572
573         val = platform_device_add(pdev);
574         if (val)
575                 goto error_add;
576
577         return pdev;
578
579 error_add:
580         kfree(platform_data);
581 error:
582         pr_err("%s: failed to add the host contoller device\n", __func__);
583         platform_device_put(pdev);
584         return NULL;
585 }
586
587 static void tegra_usb_otg_host_unregister(struct platform_device *pdev)
588 {
589         platform_device_unregister(pdev);
590 }
591
592 #ifdef CONFIG_USB_SUPPORT
593 static struct usb_phy_plat_data tegra_usb_phy_pdata[] = {
594         [0] = {
595                         .instance = 0,
596                         .vbus_gpio = -1,
597                         .vbus_reg_supply = "vdd_vbus_micro_usb",
598         },
599         [1] = {
600                         .instance = 1,
601                         .vbus_gpio = -1,
602         },
603         [2] = {
604                         .instance = 2,
605                         .vbus_gpio = -1,
606                         .vbus_reg_supply = "vdd_vbus_typea_usb",
607         },
608 };
609
610 static struct tegra_otg_platform_data tegra_otg_pdata = {
611         .host_register = &tegra_usb_otg_host_register,
612         .host_unregister = &tegra_usb_otg_host_unregister,
613 };
614
615 static void cardhu_usb_init(void)
616 {
617         struct board_info bi;
618
619         tegra_get_board_info(&bi);
620
621         tegra_usb_phy_init(tegra_usb_phy_pdata,
622                         ARRAY_SIZE(tegra_usb_phy_pdata));
623
624         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
625         platform_device_register(&tegra_otg_device);
626         if (bi.board_id == BOARD_PM267) {
627                 uhsic_phy_config.reset_gpio =
628                         PM267_SMSC4640_HSIC_HUB_RESET_GPIO;
629                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
630                 platform_device_register(&tegra_ehci2_device);
631         } else if ((bi.board_id == BOARD_PM269) ||
632                         (bi.board_id == BOARD_E1256)) {
633                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
634                 platform_device_register(&tegra_ehci2_device);
635         } else if (bi.board_id == BOARD_E1186) {
636                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_uhsic_pdata;
637                 /* baseband registartion happens in baseband-xmm-power  */
638         } else {
639                 tegra_ehci2_device.dev.platform_data = &tegra_ehci_pdata[1];
640                 platform_device_register(&tegra_ehci2_device);
641         }
642
643         tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
644         platform_device_register(&tegra_ehci3_device);
645
646 }
647 #else
648 static void cardhu_usb_init(void) { }
649 #endif
650
651 static void cardhu_gps_init(void)
652 {
653         tegra_gpio_enable(TEGRA_GPIO_PU2);
654         tegra_gpio_enable(TEGRA_GPIO_PU3);
655 }
656
657 static struct baseband_power_platform_data tegra_baseband_power_data = {
658         .baseband_type = BASEBAND_XMM,
659         .modem = {
660         .xmm = {
661                         .bb_rst = XMM_GPIO_BB_RST,
662                         .bb_on = XMM_GPIO_BB_ON,
663                         .ipc_bb_wake = XMM_GPIO_IPC_BB_WAKE,
664                         .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
665                         .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
666                         .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
667                         .hsic_device = &tegra_ehci2_device,
668                 },
669         },
670 };
671
672 static struct platform_device tegra_baseband_power_device = {
673         .name = "baseband_xmm_power",
674         .id = -1,
675         .dev = {
676                 .platform_data = &tegra_baseband_power_data,
677         },
678 };
679
680 static void cardhu_modem_init(void)
681 {
682         struct board_info board_info;
683         int w_disable_gpio, ret;
684
685         tegra_get_board_info(&board_info);
686         switch (board_info.board_id) {
687         case BOARD_E1291:
688                 if (board_info.fab < 0x3) {
689                         w_disable_gpio = TEGRA_GPIO_PH5;
690                 } else {
691                         w_disable_gpio = TEGRA_GPIO_PDD5;
692                 }
693                 tegra_gpio_enable(w_disable_gpio);
694                 ret = gpio_request(w_disable_gpio, "w_disable_gpio");
695                 if (ret < 0)
696                         pr_err("%s: gpio_request failed for gpio %d\n",
697                                 __func__, w_disable_gpio);
698                 else
699                         gpio_direction_input(w_disable_gpio);
700                 break;
701         case BOARD_E1186:
702                 tegra_gpio_enable(
703                         tegra_baseband_power_data.modem.xmm.bb_rst);
704                 tegra_gpio_enable(
705                         tegra_baseband_power_data.modem.xmm.bb_on);
706                 tegra_gpio_enable(
707                         tegra_baseband_power_data.modem.xmm.ipc_bb_wake);
708                 tegra_gpio_enable(
709                         tegra_baseband_power_data.modem.xmm.ipc_ap_wake);
710                 tegra_gpio_enable(
711                         tegra_baseband_power_data.modem.xmm.ipc_hsic_active);
712                 tegra_gpio_enable(
713                         tegra_baseband_power_data.modem.xmm.ipc_hsic_sus_req);
714                 platform_device_register(&tegra_baseband_power_device);
715                 break;
716         default:
717                 break;
718         }
719
720 }
721
722 #ifdef CONFIG_SATA_AHCI_TEGRA
723 static void cardhu_sata_init(void)
724 {
725         platform_device_register(&tegra_sata_device);
726 }
727 #else
728 static void cardhu_sata_init(void) { }
729 #endif
730
731 static void __init tegra_cardhu_init(void)
732 {
733         tegra_clk_init_from_table(cardhu_clk_init_table);
734         cardhu_pinmux_init();
735         cardhu_i2c_init();
736         cardhu_spi_init();
737         cardhu_usb_init();
738 #ifdef CONFIG_TEGRA_EDP_LIMITS
739         cardhu_edp_init();
740 #endif
741         cardhu_uart_init();
742         cardhu_tsensor_init();
743         platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
744         cardhu_sdhci_init();
745         cardhu_regulator_init();
746         cardhu_gpio_switch_regulator_init();
747         cardhu_suspend_init();
748         cardhu_power_off_init();
749         cardhu_touch_init();
750         cardhu_gps_init();
751         cardhu_modem_init();
752         cardhu_kbc_init();
753         cardhu_scroll_init();
754         cardhu_keys_init();
755         cardhu_panel_init();
756         cardhu_pmon_init();
757         cardhu_sensors_init();
758         cardhu_bt_rfkill();
759         tegra_setup_bluesleep();
760         cardhu_sata_init();
761         //audio_wired_jack_init();
762         cardhu_pins_state_init();
763         cardhu_emc_init();
764         tegra_release_bootloader_fb();
765 }
766
767 static void __init tegra_cardhu_reserve(void)
768 {
769 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
770         tegra_reserve(0, SZ_8M, SZ_8M);
771 #else
772         tegra_reserve(SZ_128M, SZ_8M, SZ_8M);
773 #endif
774 }
775
776 MACHINE_START(CARDHU, "cardhu")
777         .boot_params    = 0x80000100,
778         .map_io         = tegra_map_common_io,
779         .reserve        = tegra_cardhu_reserve,
780         .init_early     = tegra_init_early,
781         .init_irq       = tegra_init_irq,
782         .timer          = &tegra_timer,
783         .init_machine   = tegra_cardhu_init,
784 MACHINE_END