d5d8fac99bf0cfb70519226e9bf6c258fb3381c3
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-stingray.c
1 /*
2  * arch/arm/mach-tegra/board-stingray.c
3  *
4  * Copyright (C) 2010 Google, Inc.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #include <linux/console.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21 #include <linux/serial_8250.h>
22 #include <linux/clk.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/dma-mapping.h>
26 #include <linux/fsl_devices.h>
27 #include <linux/platform_data/tegra_usb.h>
28 #include <linux/pda_power.h>
29 #include <linux/gpio.h>
30 #include <linux/delay.h>
31 #include <linux/reboot.h>
32 #include <linux/i2c-tegra.h>
33 #include <linux/spi/cpcap.h>
34 #include <linux/memblock.h>
35
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/time.h>
39 #include <asm/setup.h>
40
41 #include <mach/io.h>
42 #include <mach/w1.h>
43 #include <mach/iomap.h>
44 #include <mach/irqs.h>
45 #include <mach/iomap.h>
46 #include <mach/sdhci.h>
47 #include <mach/gpio.h>
48 #include <mach/clk.h>
49 #include <mach/usb_phy.h>
50 #include <mach/i2s.h>
51 #include <mach/spdif.h>
52 #include <mach/audio.h>
53 #include <mach/cpcap_audio.h>
54 #include <mach/suspend.h>
55 #include <mach/system.h>
56 #include <mach/tegra_fiq_debugger.h>
57 #include <mach/tegra_hsuart.h>
58 #include <mach/nvmap.h>
59 #include <mach/bcm_bt_lpm.h>
60
61 #include <linux/usb/android_composite.h>
62 #include <linux/usb/f_accessory.h>
63
64 #include "board.h"
65 #include "board-stingray.h"
66 #include "clock.h"
67 #include "gpio-names.h"
68 #include "devices.h"
69
70 /* NVidia bootloader tags */
71 #define ATAG_NVIDIA             0x41000801
72
73 #define ATAG_NVIDIA_RM                  0x1
74 #define ATAG_NVIDIA_DISPLAY             0x2
75 #define ATAG_NVIDIA_FRAMEBUFFER         0x3
76 #define ATAG_NVIDIA_CHIPSHMOO           0x4
77 #define ATAG_NVIDIA_CHIPSHMOOPHYS       0x5
78 #define ATAG_NVIDIA_PRESERVED_MEM_0     0x10000
79 #define ATAG_NVIDIA_PRESERVED_MEM_N     2
80 #define ATAG_NVIDIA_FORCE_32            0x7fffffff
81
82 #define USB_MANUFACTURER_NAME           "Motorola"
83 #define USB_PRODUCT_NAME                "MZ600"
84 #define USB_PRODUCT_ID_BLAN             0x70A3
85 #define USB_PRODUCT_ID_MTP              0x70A8
86 #define USB_PRODUCT_ID_MTP_ADB          0x70A9
87 #define USB_PRODUCT_ID_RNDIS            0x70AE
88 #define USB_PRODUCT_ID_RNDIS_ADB        0x70AF
89 #define USB_PRODUCT_ID_BP               0x70B0
90 #define USB_PRODUCT_ID_BP_ADB           0x70B1
91 #define USB_PRODUCT_ID_RNDIS_BP         0x70B2
92 #define USB_PRODUCT_ID_RNDIS_BP_ADB     0x70B3
93 #define USB_VENDOR_ID                   0x22b8
94
95 struct tag_tegra {
96         __u32 bootarg_key;
97         __u32 bootarg_len;
98         char bootarg[1];
99 };
100
101 static int __init parse_tag_nvidia(const struct tag *tag)
102 {
103
104         return 0;
105 }
106 __tagtable(ATAG_NVIDIA, parse_tag_nvidia);
107
108 static unsigned long ramconsole_start = SZ_512M - SZ_1M;
109 static unsigned long ramconsole_size = SZ_1M;
110
111 static struct resource mdm6600_resources[] = {
112         [0] = {
113                 .flags = IORESOURCE_IRQ,
114                 .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PQ6),
115                 .end   = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PQ6),
116         },
117 };
118
119 static struct platform_device mdm6600_modem = {
120         .name = "mdm6600_modem",
121         .id   = -1,
122         .resource = mdm6600_resources,
123         .num_resources = ARRAY_SIZE(mdm6600_resources),
124 };
125
126 /* OTG gadget device */
127 static struct tegra_utmip_config udc_phy_config = {
128         .hssync_start_delay = 0,
129         .idle_wait_delay = 17,
130         .elastic_limit = 16,
131         .term_range_adj = 6,
132         .xcvr_setup = 15,
133         .xcvr_lsfslew = 1,
134         .xcvr_lsrslew = 1,
135 };
136
137 static struct fsl_usb2_platform_data tegra_udc_pdata = {
138         .operating_mode = FSL_USB2_DR_DEVICE,
139         .phy_mode       = FSL_USB2_PHY_UTMI,
140         .phy_config     = &udc_phy_config,
141 };
142
143 /* OTG transceiver */
144 static struct resource cpcap_otg_resources[] = {
145         [0] = {
146                 .start  = TEGRA_USB_BASE,
147                 .end    = TEGRA_USB_BASE + TEGRA_USB_SIZE - 1,
148                 .flags  = IORESOURCE_MEM,
149         },
150 };
151
152 static struct platform_device cpcap_otg = {
153         .name = "cpcap-otg",
154         .id   = -1,
155         .resource = cpcap_otg_resources,
156         .num_resources = ARRAY_SIZE(cpcap_otg_resources),
157         .dev = {
158                 .platform_data = &tegra_ehci1_device,
159         },
160 };
161
162 static struct cpcap_audio_state stingray_cpcap_audio_state = {
163         .cpcap                   = NULL,
164         .mode                    = CPCAP_AUDIO_MODE_NORMAL,
165         .codec_mode              = CPCAP_AUDIO_CODEC_OFF,
166         .codec_rate              = CPCAP_AUDIO_CODEC_RATE_8000_HZ,
167         .codec_mute              = CPCAP_AUDIO_CODEC_MUTE,
168         .stdac_mode              = CPCAP_AUDIO_STDAC_OFF,
169         .stdac_rate              = CPCAP_AUDIO_STDAC_RATE_44100_HZ,
170         .stdac_mute              = CPCAP_AUDIO_STDAC_MUTE,
171         .analog_source           = CPCAP_AUDIO_ANALOG_SOURCE_OFF,
172         .codec_primary_speaker   = CPCAP_AUDIO_OUT_NONE,
173         .codec_secondary_speaker = CPCAP_AUDIO_OUT_NONE,
174         .stdac_primary_speaker   = CPCAP_AUDIO_OUT_NONE,
175         .stdac_secondary_speaker = CPCAP_AUDIO_OUT_NONE,
176         .ext_primary_speaker     = CPCAP_AUDIO_OUT_NONE,
177         .ext_secondary_speaker   = CPCAP_AUDIO_OUT_NONE,
178         .codec_primary_balance   = CPCAP_AUDIO_BALANCE_NEUTRAL,
179         .stdac_primary_balance   = CPCAP_AUDIO_BALANCE_NEUTRAL,
180         .ext_primary_balance     = CPCAP_AUDIO_BALANCE_NEUTRAL,
181         .output_gain             = 7,
182         .microphone              = CPCAP_AUDIO_IN_NONE,
183         .input_gain              = 31,
184         .rat_type                = CPCAP_AUDIO_RAT_NONE
185 };
186
187 /* CPCAP is i2s master; tegra_audio_pdata.master == false */
188 static void init_dac2(bool bluetooth);
189 static struct cpcap_audio_platform_data cpcap_audio_pdata = {
190         .master = true,
191         .regulator = "vaudio",
192         .state = &stingray_cpcap_audio_state,
193         .speaker_gpio = TEGRA_GPIO_PR3,
194         .headset_gpio = -1,
195         .bluetooth_bypass = init_dac2,
196 };
197
198 static struct platform_device cpcap_audio_device = {
199         .name   = "cpcap_audio",
200         .id     = -1,
201         .dev    = {
202                 .platform_data = &cpcap_audio_pdata,
203         },
204 };
205
206 /* This is the CPCAP Stereo DAC interface. */
207 static struct tegra_audio_platform_data tegra_audio_pdata = {
208         .i2s_master     = false, /* CPCAP Stereo DAC */
209         .dsp_master     = false, /* Don't care */
210         .dma_on         = true,  /* use dma by default */
211         .i2s_clk_rate   = 24000000,
212         .dap_clk        = "clk_dev1",
213         .audio_sync_clk = "audio_2x",
214         .mode           = I2S_BIT_FORMAT_I2S,
215         .fifo_fmt       = I2S_FIFO_PACKED,
216         .bit_size       = I2S_BIT_SIZE_16,
217         .i2s_bus_width = 32, /* Using Packed 16 bit data, the dma is 32 bit. */
218         .dsp_bus_width = 16, /* When using DSP mode (unused), this should be 16 bit. */
219         .mask           = TEGRA_AUDIO_ENABLE_TX,
220 };
221
222 /* Connected to CPCAP CODEC - Switchable to Bluetooth Audio. */
223 static struct tegra_audio_platform_data tegra_audio2_pdata = {
224         .i2s_master     = false, /* CPCAP CODEC */
225         .dsp_master     = true,  /* Bluetooth */
226         .dsp_master_clk = 8000,  /* Bluetooth audio speed */
227         .dma_on         = true,  /* use dma by default */
228         .i2s_clk_rate   = 2000000, /* BCM4329 max bitclock is 2048000 Hz */
229         .dap_clk        = "clk_dev1",
230         .audio_sync_clk = "audio_2x",
231         .mode           = I2S_BIT_FORMAT_DSP, /* Using COCEC in network mode */
232         .fifo_fmt       = I2S_FIFO_16_LSB,
233         .bit_size       = I2S_BIT_SIZE_16,
234         .i2s_bus_width = 16, /* Capturing a single timeslot, mono 16 bits */
235         .dsp_bus_width = 16,
236         .mask           = TEGRA_AUDIO_ENABLE_TX | TEGRA_AUDIO_ENABLE_RX,
237 };
238
239 static struct tegra_audio_platform_data tegra_spdif_pdata = {
240         .dma_on         = true,  /* use dma by default */
241         .i2s_clk_rate   = 5644800,
242         .mode           = SPDIF_BIT_MODE_MODE16BIT,
243         .fifo_fmt       = 1,
244 };
245
246
247 static char *usb_functions_mtp[] = { "mtp" };
248 static char *usb_functions_mtp_adb[] = { "mtp", "adb" };
249 #ifdef CONFIG_USB_ANDROID_ACCESSORY
250 static char *usb_functions_accessory[] = { "accessory" };
251 static char *usb_functions_accessory_adb[] = { "accessory", "adb" };
252 #endif
253 #ifdef CONFIG_USB_ANDROID_RNDIS
254 static char *usb_functions_rndis[] = { "rndis" };
255 static char *usb_functions_rndis_adb[] = { "rndis", "adb" };
256 #endif
257 static char *usb_functions_all[] = {
258 #ifdef CONFIG_USB_ANDROID_RNDIS
259         "rndis",
260 #endif
261 #ifdef CONFIG_USB_ANDROID_ACCESSORY
262         "accessory",
263 #endif
264         "mtp",
265         "adb"
266 };
267
268 static struct android_usb_product usb_products[] = {
269         {
270                 .product_id     = USB_PRODUCT_ID_MTP,
271                 .num_functions  = ARRAY_SIZE(usb_functions_mtp),
272                 .functions      = usb_functions_mtp,
273         },
274         {
275                 .product_id     = USB_PRODUCT_ID_MTP_ADB,
276                 .num_functions  = ARRAY_SIZE(usb_functions_mtp_adb),
277                 .functions      = usb_functions_mtp_adb,
278         },
279 #ifdef CONFIG_USB_ANDROID_ACCESSORY
280         {
281                 .vendor_id      = USB_ACCESSORY_VENDOR_ID,
282                 .product_id     = USB_ACCESSORY_PRODUCT_ID,
283                 .num_functions  = ARRAY_SIZE(usb_functions_accessory),
284                 .functions      = usb_functions_accessory,
285         },
286         {
287                 .vendor_id      = USB_ACCESSORY_VENDOR_ID,
288                 .product_id     = USB_ACCESSORY_ADB_PRODUCT_ID,
289                 .num_functions  = ARRAY_SIZE(usb_functions_accessory_adb),
290                 .functions      = usb_functions_accessory_adb,
291         },
292 #endif
293 #ifdef CONFIG_USB_ANDROID_RNDIS
294         {
295                 .product_id     = USB_PRODUCT_ID_RNDIS,
296                 .num_functions  = ARRAY_SIZE(usb_functions_rndis),
297                 .functions      = usb_functions_rndis,
298         },
299         {
300                 .product_id     = USB_PRODUCT_ID_RNDIS_ADB,
301                 .num_functions  = ARRAY_SIZE(usb_functions_rndis_adb),
302                 .functions      = usb_functions_rndis_adb,
303         },
304 #endif
305 };
306
307 /* standard android USB platform data */
308 static struct android_usb_platform_data andusb_plat = {
309         .vendor_id              = USB_VENDOR_ID,
310         .product_id             = USB_PRODUCT_ID_MTP_ADB,
311         .manufacturer_name      = USB_MANUFACTURER_NAME,
312         .product_name           = USB_PRODUCT_NAME,
313         .serial_number          = "0000",
314         .num_products = ARRAY_SIZE(usb_products),
315         .products = usb_products,
316         .num_functions = ARRAY_SIZE(usb_functions_all),
317         .functions = usb_functions_all,
318 };
319
320 static struct platform_device androidusb_device = {
321         .name   = "android_usb",
322         .id     = -1,
323         .dev    = {
324                 .platform_data  = &andusb_plat,
325         },
326 };
327
328 static char *factory_usb_functions[] = {
329         "usbnet"
330 };
331
332 static struct android_usb_product factory_usb_products[] = {
333         {
334                 .product_id     = USB_PRODUCT_ID_BLAN,
335                 .num_functions  = ARRAY_SIZE(factory_usb_functions),
336                 .functions      = factory_usb_functions,
337         },
338 };
339
340 /* android USB platform data for factory test mode*/
341 static struct android_usb_platform_data andusb_plat_factory = {
342         .vendor_id              = USB_VENDOR_ID,
343         .product_id             = USB_PRODUCT_ID_BLAN,
344         .manufacturer_name      = USB_MANUFACTURER_NAME,
345         .product_name           = USB_PRODUCT_NAME,
346         .serial_number          = "000000000",
347         .num_products = ARRAY_SIZE(factory_usb_products),
348         .products = factory_usb_products,
349         .num_functions = ARRAY_SIZE(factory_usb_functions),
350         .functions = factory_usb_functions,
351 };
352
353 static char *bp_usb_functions_bp[] = {
354         "acm", "usbnet"};
355 static char *bp_usb_functions_bp_adb[] = {
356         "acm", "usbnet", "adb"};
357 static char *bp_usb_functions_rndis_bp[] = {
358         "rndis", "acm", "usbnet"};
359 static char *bp_usb_functions_all[] = {
360         "rndis", "acm", "usbnet", "adb"};
361
362 static struct android_usb_product bp_usb_products[] = {
363         {
364                 .product_id     = USB_PRODUCT_ID_BP,
365                 .num_functions  = ARRAY_SIZE(bp_usb_functions_bp),
366                 .functions      = bp_usb_functions_bp,
367         },
368         {
369                 .product_id     = USB_PRODUCT_ID_BP_ADB,
370                 .num_functions  = ARRAY_SIZE(bp_usb_functions_bp_adb),
371                 .functions      = bp_usb_functions_bp_adb,
372         },
373         {
374                 .product_id     = USB_PRODUCT_ID_RNDIS_BP,
375                 .num_functions  = ARRAY_SIZE(bp_usb_functions_rndis_bp),
376                 .functions      = bp_usb_functions_rndis_bp,
377         },
378         {
379                 .product_id     = USB_PRODUCT_ID_RNDIS_BP_ADB,
380                 .num_functions  = ARRAY_SIZE(bp_usb_functions_all),
381                 .functions      = bp_usb_functions_all,
382         },
383 };
384
385 static struct android_usb_platform_data andusb_plat_bp = {
386         .vendor_id              = USB_VENDOR_ID,
387         .product_id             = USB_PRODUCT_ID_BP_ADB,
388         .manufacturer_name      = USB_MANUFACTURER_NAME,
389         .product_name           = USB_PRODUCT_NAME,
390         .serial_number          = "0000",
391         .num_products = ARRAY_SIZE(bp_usb_products),
392         .products = bp_usb_products,
393         .num_functions = ARRAY_SIZE(bp_usb_functions_all),
394         .functions = bp_usb_functions_all,
395 };
396
397 static struct platform_device usbnet_device = {
398         .name = "usbnet",
399 };
400
401 #ifdef CONFIG_USB_ANDROID_RNDIS
402 static struct usb_ether_platform_data rndis_pdata = {
403         /* ethaddr is filled by board_serialno_setup */
404         .vendorID       = USB_VENDOR_ID,
405         .vendorDescr    = USB_MANUFACTURER_NAME,
406 };
407
408 static struct platform_device rndis_device = {
409         .name   = "rndis",
410         .id     = -1,
411         .dev    = {
412                 .platform_data = &rndis_pdata,
413         },
414 };
415 #endif
416
417 static struct acm_platform_data acm_pdata = {
418         /* Modify num_inst at runtime depending on boot_mode */
419         .num_inst       = 1,
420 };
421
422 static struct platform_device acm_device = {
423         .name   = "acm",
424         .id     = -1,
425         .dev    = {
426                 .platform_data = &acm_pdata,
427         },
428 };
429
430 static struct tegra_utmip_config utmi_phy_config[] = {
431         [0] = {
432                 .hssync_start_delay = 0,
433                 .idle_wait_delay = 17,
434                 .elastic_limit = 16,
435                 .term_range_adj = 6,
436                 .xcvr_setup = 15,
437                 .xcvr_lsfslew = 2,
438                 .xcvr_lsrslew = 2,
439         },
440         [1] = {
441                 .hssync_start_delay = 0,
442                 .idle_wait_delay = 17,
443                 .elastic_limit = 16,
444                 .term_range_adj = 6,
445                 .xcvr_setup = 8,
446                 .xcvr_lsfslew = 2,
447                 .xcvr_lsrslew = 2,
448         },
449 };
450
451 static struct tegra_ulpi_config ulpi_phy_config = {
452         .reset_gpio = TEGRA_GPIO_PG2,
453         .clk = "clk_dev2",
454 };
455
456 static struct tegra_ehci_platform_data tegra_ehci_pdata[] = {
457         [0] = {
458                 .phy_config = &utmi_phy_config[0],
459                 .operating_mode = TEGRA_USB_OTG,
460                 .power_down_on_bus_suspend = 0,
461         },
462         [1] = {
463                 .phy_config = &ulpi_phy_config,
464                 .operating_mode = TEGRA_USB_HOST,
465                 .power_down_on_bus_suspend = 1,
466         },
467         [2] = {
468                 .phy_config = &utmi_phy_config[1],
469                 .operating_mode = TEGRA_USB_HOST,
470                 .power_down_on_bus_suspend = 1,
471         },
472 };
473
474 /* bq24617 charger */
475 static struct resource bq24617_resources[] = {
476         [0] = {
477                 .name  = "stat1",
478                 .flags = IORESOURCE_IRQ,
479                 .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV5),
480                 .end   = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV5),
481         },
482         [1] = {
483                 .name  = "stat2",
484                 .flags = IORESOURCE_IRQ,
485                 .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PD1),
486                 .end   = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PD1),
487         },
488         [2] = {
489                 .name  = "detect",
490                 .flags = IORESOURCE_IRQ,
491                 .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
492                 .end   = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
493         },
494 };
495
496 static struct resource bq24617_resources_m1_p0[] = {
497         [0] = {
498                 .name  = "stat1",
499                 .flags = IORESOURCE_IRQ,
500                 .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV5),
501                 .end   = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV5),
502         },
503         [1] = {
504                 .name  = "stat2",
505                 .flags = IORESOURCE_IRQ,
506                 .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
507                 .end   = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV6),
508         },
509 };
510
511 static struct platform_device bq24617_device = {
512         .name           = "bq24617",
513         .id             = -1,
514         .resource       = bq24617_resources,
515         .num_resources  = ARRAY_SIZE(bq24617_resources),
516 };
517
518 static struct resource tegra_gart_resources[] = {
519     {
520         .name = "mc",
521         .flags = IORESOURCE_MEM,
522         .start = TEGRA_MC_BASE,
523         .end = TEGRA_MC_BASE + TEGRA_MC_SIZE - 1,
524     },
525     {
526         .name = "gart",
527         .flags = IORESOURCE_MEM,
528         .start = 0x58000000,
529         .end = 0x58000000 - 1 + 32 * 1024 * 1024,
530     }
531 };
532
533
534 static struct platform_device tegra_gart_dev = {
535     .name = "tegra_gart",
536     .id = -1,
537     .num_resources = ARRAY_SIZE(tegra_gart_resources),
538     .resource = tegra_gart_resources
539 };
540
541 static struct platform_device bcm4329_bluetooth_device = {
542         .name = "bcm4329_bluetooth",
543         .id = -1,
544 };
545
546 static struct platform_device tegra_camera = {
547         .name = "tegra_camera",
548         .id = -1,
549 };
550
551 static struct tegra_w1_timings tegra_w1_platform_timings = {
552         .tsu = 0x1,
553         .trelease = 0xf,
554         .trdv = 0xf,
555         .tlow0 = 0x3c,
556         .tlow1 = 0x1,
557         .tslot = 0x78,
558
559         .tpdl = 0x3c,
560         .tpdh = 0x1e,
561         .trstl = 0x1ea,
562         .trsth = 0x1df,
563
564         .rdsclk = 0x7,
565         .psclk = 0x50,
566 };
567
568 static struct tegra_w1_platform_data tegra_w1_pdata = {
569         .clk_id = NULL,
570         .timings = &tegra_w1_platform_timings,
571 };
572
573 static struct resource ram_console_resources[] = {
574         {
575                 /* .start and .end filled in later */
576                 .flags  = IORESOURCE_MEM,
577         },
578 };
579
580 static struct platform_device ram_console_device = {
581         .name           = "ram_console",
582         .id             = -1,
583         .num_resources  = ARRAY_SIZE(ram_console_resources),
584         .resource       = ram_console_resources,
585 };
586
587 static struct nvmap_platform_carveout stingray_carveouts[] = {
588         [0] = {
589                 .name           = "iram",
590                 .usage_mask     = NVMAP_HEAP_CARVEOUT_IRAM,
591                 .base           = TEGRA_IRAM_BASE,
592                 .size           = TEGRA_IRAM_SIZE,
593                 .buddy_size     = 0,
594         },
595         [1] = {
596                 .name           = "generic-0",
597                 .usage_mask     = NVMAP_HEAP_CARVEOUT_GENERIC,
598                 /* .base and .size to be filled in later */
599                 .buddy_size     = SZ_32K,
600         },
601 };
602
603 static struct nvmap_platform_data stingray_nvmap_data = {
604         .carveouts      = stingray_carveouts,
605         .nr_carveouts   = ARRAY_SIZE(stingray_carveouts),
606 };
607
608 static struct platform_device stingray_nvmap_device = {
609         .name   = "tegra-nvmap",
610         .id     = -1,
611         .dev    = {
612                 .platform_data = &stingray_nvmap_data,
613         },
614 };
615
616 static struct tegra_hsuart_platform_data tegra_uartc_pdata = {
617         .exit_lpm_cb    = bcm_bt_lpm_exit_lpm_locked,
618         .rx_done_cb     = bcm_bt_rx_done_locked,
619 };
620
621 static struct platform_device *stingray_devices[] __initdata = {
622         &cpcap_otg,
623         &bq24617_device,
624         &bcm4329_bluetooth_device,
625         &tegra_uarta_device,
626         &tegra_uartc_device,
627         &tegra_uartd_device,
628         &tegra_uarte_device,
629         &tegra_spi_device1,
630         &tegra_spi_device2,
631         &tegra_spi_device3,
632         &tegra_spi_device4,
633         &tegra_gart_dev,
634         &stingray_nvmap_device,
635         &tegra_grhost_device,
636         &ram_console_device,
637         &tegra_camera,
638         &tegra_i2s_device1,
639         &tegra_i2s_device2,
640         &mdm6600_modem,
641         &tegra_spdif_device,
642         &tegra_avp_device,
643         &pmu_device,
644         &tegra_aes_device,
645         &tegra_wdt_device,
646 };
647
648 extern struct tegra_sdhci_platform_data stingray_wifi_data; /* sdhci2 */
649
650 static struct tegra_sdhci_platform_data stingray_sdhci_platform_data4 = {
651         .clk_id = NULL,
652         .force_hs = 0,
653         .cd_gpio = -1,
654         .wp_gpio = -1,
655         .power_gpio = -1,
656 };
657
658 static struct tegra_i2c_platform_data stingray_i2c1_platform_data = {
659         .adapter_nr   = 0,
660         .bus_count    = 1,
661         .bus_clk_rate = { 400000 },
662 };
663
664 static struct tegra_i2c_platform_data stingray_i2c2_platform_data = {
665         .adapter_nr   = 1,
666         .bus_count    = 1,
667 };
668
669 static struct tegra_i2c_platform_data stingray_i2c3_platform_data = {
670         .adapter_nr   = 2,
671         .bus_count    = 1,
672         .bus_clk_rate = { 400000 },
673 };
674
675 static struct tegra_i2c_platform_data stingray_i2c4_platform_data = {
676         .adapter_nr   = 3,
677         .bus_count    = 1,
678         .bus_clk_rate = { 400000 },
679         .is_dvc       = true,
680 };
681
682 static __initdata struct tegra_clk_init_table stingray_clk_init_table[] = {
683         /* name         parent          rate            enabled */
684         { "uartb",      "clk_m",        26000000,       true},
685         { "uartc",      "pll_m",        600000000,      false},
686         /*{ "emc",      "pll_p",        0,              true},
687         { "emc",        "pll_m",        600000000,      false},*/
688         { "pll_m",      NULL,           600000000,      true},
689         { "mpe",        "pll_m",        250000000,      false},
690         { "pll_a",      NULL,           56448000,       false},
691         { "pll_a_out0", NULL,           11289600,       false},
692         { "i2s1",       "pll_p",        24000000,       false},
693         { "i2s2",       "pll_p",        2000000,        false},
694         { "sdmmc2",     "pll_m",        48000000,       false},
695         { "spdif_out",  "pll_a_out0",   5644800,        false},
696         { NULL,         NULL,           0,              0},
697 };
698
699 static void stingray_i2c_init(void)
700 {
701         tegra_i2c_device1.dev.platform_data = &stingray_i2c1_platform_data;
702         tegra_i2c_device2.dev.platform_data = &stingray_i2c2_platform_data;
703         tegra_i2c_device3.dev.platform_data = &stingray_i2c3_platform_data;
704         tegra_i2c_device4.dev.platform_data = &stingray_i2c4_platform_data;
705
706         platform_device_register(&tegra_i2c_device1);
707         platform_device_register(&tegra_i2c_device2);
708         platform_device_register(&tegra_i2c_device3);
709         platform_device_register(&tegra_i2c_device4);
710 }
711
712 static void stingray_sdhci_init(void)
713 {
714         /* TODO: setup GPIOs for cd, wd, and power */
715         tegra_sdhci_device2.dev.platform_data = &stingray_wifi_data;
716         tegra_sdhci_device4.dev.platform_data = &stingray_sdhci_platform_data4;
717
718         platform_device_register(&tegra_sdhci_device2);
719         platform_device_register(&tegra_sdhci_device4);
720 }
721 #define ATAG_BDADDR 0x43294329  /* stingray bluetooth address tag */
722 #define ATAG_BDADDR_SIZE 4
723 #define BDADDR_STR_SIZE 18
724
725 static char bdaddr[BDADDR_STR_SIZE];
726
727 module_param_string(bdaddr, bdaddr, sizeof(bdaddr), 0400);
728 MODULE_PARM_DESC(bdaddr, "bluetooth address");
729
730 static int __init parse_tag_bdaddr(const struct tag *tag)
731 {
732         unsigned char *b = (unsigned char *)&tag->u;
733
734         if (tag->hdr.size != ATAG_BDADDR_SIZE)
735                 return -EINVAL;
736
737         snprintf(bdaddr, BDADDR_STR_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X",
738                         b[0], b[1], b[2], b[3], b[4], b[5]);
739
740         return 0;
741 }
742 __tagtable(ATAG_BDADDR, parse_tag_bdaddr);
743
744 static DEFINE_SPINLOCK(brcm_4329_enable_lock);
745 static int brcm_4329_enable_count;
746
747 static void stingray_w1_init(void)
748 {
749         tegra_w1_device.dev.platform_data = &tegra_w1_pdata;
750         platform_device_register(&tegra_w1_device);
751 }
752
753 /* powerup reason */
754 #define ATAG_POWERUP_REASON              0xf1000401
755 #define ATAG_POWERUP_REASON_SIZE 3 /* size + tag id + tag data */
756
757 static unsigned int powerup_reason = PU_REASON_PWR_KEY_PRESS;
758
759 unsigned int stingray_powerup_reason (void)
760 {
761         return powerup_reason;
762 }
763
764 static int __init parse_tag_powerup_reason(const struct tag *tag)
765 {
766         if (tag->hdr.size != ATAG_POWERUP_REASON_SIZE)
767                 return -EINVAL;
768         memcpy(&powerup_reason, &tag->u, sizeof(powerup_reason));
769         printk(KERN_INFO "powerup reason=0x%08x\n", powerup_reason);
770         return 0;
771 }
772 __tagtable(ATAG_POWERUP_REASON, parse_tag_powerup_reason);
773
774 #define BOOT_MODE_MAX_LEN 30
775 static char boot_mode[BOOT_MODE_MAX_LEN + 1];
776 int __init board_boot_mode_init(char *s)
777 {
778         strncpy(boot_mode, s, BOOT_MODE_MAX_LEN);
779         boot_mode[BOOT_MODE_MAX_LEN] = '\0';
780         printk(KERN_INFO "boot_mode=%s\n", boot_mode);
781         return 1;
782 }
783 __setup("androidboot.mode=", board_boot_mode_init);
784
785 #define SERIAL_NUMBER_LENGTH 16
786 static char usb_serial_num[SERIAL_NUMBER_LENGTH + 1];
787 static int __init mot_usb_serial_num_setup(char *options)
788 {
789         strncpy(usb_serial_num, options, SERIAL_NUMBER_LENGTH);
790         usb_serial_num[SERIAL_NUMBER_LENGTH] = '\0';
791         printk(KERN_INFO "usb_serial_num=%s\n", usb_serial_num);
792         return 1;
793 }
794 __setup("androidboot.serialno=", mot_usb_serial_num_setup);
795
796 static int mot_boot_recovery = 0;
797 static int __init mot_bm_recovery_setup(char *options)
798 {
799        mot_boot_recovery = 1;
800        return 1;
801 }
802 __setup("rec", mot_bm_recovery_setup);
803
804 #define PRODUCT_TYPE_MAX_LEN 4
805 static char product_type[PRODUCT_TYPE_MAX_LEN + 1] = "cw";
806 static int __init stingray_product_type_parse(char *s)
807 {
808         strncpy(product_type, s, PRODUCT_TYPE_MAX_LEN);
809         product_type[PRODUCT_TYPE_MAX_LEN] = '\0';
810         printk(KERN_INFO "product_type=%s\n", product_type);
811
812         return 1;
813 }
814 __setup("product_type=", stingray_product_type_parse);
815
816 bool stingray_hw_has_cdma(void)
817 {
818         return strstr(product_type, "c") != NULL;
819 }
820
821 bool stingray_hw_has_lte(void)
822 {
823         return strstr(product_type, "l") != NULL;
824 }
825
826 bool stingray_hw_has_wifi(void)
827 {
828         return strstr(product_type, "w") != NULL;
829 }
830
831 bool stingray_hw_has_umts(void)
832 {
833         return strstr(product_type, "u") != NULL;
834 }
835
836 static void stingray_usb_init(void)
837 {
838         char *src;
839         int i;
840
841         struct android_usb_platform_data *platform_data;
842
843         int factorycable = !strncmp(boot_mode, "factorycable",
844                         BOOT_MODE_MAX_LEN);
845
846         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
847         tegra_ehci2_device.dev.platform_data = &tegra_ehci_pdata[1];
848         tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2];
849
850         if (!(factorycable && mot_boot_recovery))
851                 platform_device_register(&tegra_udc_device);
852
853         if (stingray_hw_has_cdma())
854                 platform_device_register(&tegra_ehci2_device);
855
856         platform_device_register(&tegra_ehci3_device);
857
858 #ifdef CONFIG_USB_ANDROID_RNDIS
859         src = usb_serial_num;
860
861         /* create a fake MAC address from our serial number.
862          * first byte is 0x02 to signify locally administered.
863          */
864         rndis_pdata.ethaddr[0] = 0x02;
865         for (i = 0; *src; i++) {
866                 /* XOR the USB serial across the remaining bytes */
867                 rndis_pdata.ethaddr[i % (ETH_ALEN - 1) + 1] ^= *src++;
868         }
869         platform_device_register(&rndis_device);
870 #endif
871
872         if (!(factorycable && mot_boot_recovery)) {
873                 if (factorycable) {
874                         platform_data = &andusb_plat_factory;
875                         platform_device_register(&usbnet_device);
876                 } else if (!strncmp(boot_mode, "bp-tools",
877                                 BOOT_MODE_MAX_LEN)) {
878                         platform_data = &andusb_plat_bp;
879                         platform_device_register(&usbnet_device);
880                         /* acm: LTE Modem + QC Modem + QC Diag */
881                         acm_pdata.num_inst = 3;
882                         platform_device_register(&acm_device);
883                 } else {
884                         platform_data = &andusb_plat;
885                 }
886
887                 platform_data->serial_number = usb_serial_num;
888                 androidusb_device.dev.platform_data = platform_data;
889                 platform_device_register(&androidusb_device);
890         }
891 }
892
893 static void stingray_reset(char mode, const char *cmd)
894 {
895         /* Signal to CPCAP to stop the uC. */
896         gpio_set_value(TEGRA_GPIO_PG3, 0);
897         mdelay(100);
898         gpio_set_value(TEGRA_GPIO_PG3, 1);
899         mdelay(100);
900
901         tegra_assert_system_reset();
902 }
903
904 static void stingray_power_off(void)
905 {
906         printk(KERN_INFO "stingray_pm_power_off...\n");
907
908         local_irq_disable();
909
910         /* signal WDI gpio to shutdown CPCAP, which will
911            cascade to all of the regulators. */
912         gpio_direction_output(TEGRA_GPIO_PV7, 0);
913
914         do {} while (1);
915
916         local_irq_enable();
917 }
918
919 static void __init stingray_power_off_init(void)
920 {
921         tegra_gpio_enable(TEGRA_GPIO_PG3);
922         gpio_request(TEGRA_GPIO_PG3, "sys_restart_b");
923         gpio_direction_output(TEGRA_GPIO_PG3, 1);
924         tegra_reset = stingray_reset;
925
926         tegra_gpio_enable(TEGRA_GPIO_PV7);
927         if (!gpio_request(TEGRA_GPIO_PV7, "wdi"))
928                 pm_power_off = stingray_power_off;
929 }
930
931 static unsigned int stingray_board_revision = STINGRAY_REVISION_UNKNOWN;
932
933 unsigned int stingray_revision(void)
934 {
935         return stingray_board_revision;
936 }
937
938 static int __init stingray_revision_parse(char *options)
939 {
940         if (!strcmp(options, "m1"))
941                 stingray_board_revision = STINGRAY_REVISION_M1;
942         else if (!strcmp(options, "p0"))
943                 stingray_board_revision = STINGRAY_REVISION_P0;
944         else if (!strcmp(options, "p1"))
945                 stingray_board_revision = STINGRAY_REVISION_P1;
946         else if (!strcmp(options, "p2"))
947                 stingray_board_revision = STINGRAY_REVISION_P2;
948         else if (!strcmp(options, "p3"))
949                 stingray_board_revision = STINGRAY_REVISION_P3;
950         else
951                 stingray_board_revision = system_rev;
952
953         printk(KERN_INFO "hw_rev=0x%x\n", stingray_board_revision);
954
955         return 1;
956 }
957 __setup("hw_rev=", stingray_revision_parse);
958
959 int stingray_qbp_usb_hw_bypass_enabled(void)
960 {
961         /* We could use the boot_mode string instead of probing the HW, but
962          * that would not work if we enable run-time switching to this mode
963          * in the future.
964          */
965         if (gpio_get_value(TEGRA_GPIO_PT3) && !gpio_get_value(TEGRA_GPIO_PV4)) {
966                 pr_info("stingray_qbp_usb_hw_bypass enabled\n");
967                 return 1;
968         }
969         return 0;
970 }
971
972 static struct tegra_suspend_platform_data stingray_suspend = {
973         .cpu_timer = 1500,
974         .cpu_off_timer = 1,
975         .core_timer = 0x7e7e,
976         .core_off_timer = 0xf,
977         .separate_req = true,
978         .corereq_high = true,
979         .sysclkreq_high = true,
980         .suspend_mode = TEGRA_SUSPEND_LP0,
981 };
982
983 static void *das_base = IO_ADDRESS(TEGRA_APB_MISC_BASE);
984
985 static inline void das_writel(unsigned long value, unsigned long offset)
986 {
987         writel(value, das_base + offset);
988 }
989
990 #define APB_MISC_DAS_DAP_CTRL_SEL_0             0xc00
991 #define APB_MISC_DAS_DAC_INPUT_DATA_CLK_SEL_0   0xc40
992
993 static void init_dac1(void)
994 {
995         bool master = tegra_audio_pdata.i2s_master;
996         /* DAC1 -> DAP1 */
997         das_writel((!master)<<31, APB_MISC_DAS_DAP_CTRL_SEL_0);
998         das_writel(0, APB_MISC_DAS_DAC_INPUT_DATA_CLK_SEL_0);
999 }
1000
1001 static void init_dac2(bool bluetooth)
1002 {
1003         if (!bluetooth) {
1004                 /* DAC2 -> DAP2 for CPCAP CODEC */
1005                 bool master = tegra_audio2_pdata.i2s_master;
1006                 das_writel((!master)<<31 | 1, APB_MISC_DAS_DAP_CTRL_SEL_0 + 4);
1007                 das_writel(1<<28 | 1<<24 | 1,
1008                                 APB_MISC_DAS_DAC_INPUT_DATA_CLK_SEL_0 + 4);
1009         } else {
1010                 /* DAC2 -> DAP4 for Bluetooth Voice */
1011                 bool master = tegra_audio2_pdata.dsp_master;
1012                 das_writel((!master)<<31 | 1, APB_MISC_DAS_DAP_CTRL_SEL_0 + 12);
1013                 das_writel(3<<28 | 3<<24 | 3,
1014                                 APB_MISC_DAS_DAC_INPUT_DATA_CLK_SEL_0 + 4);
1015         }
1016 }
1017
1018 void change_power_brcm_4329(bool enable) {
1019         unsigned long flags;
1020
1021         spin_lock_irqsave(&brcm_4329_enable_lock, flags);
1022         if (enable) {
1023                 gpio_set_value(TEGRA_GPIO_PU4, enable);
1024                 brcm_4329_enable_count++;
1025                 // The following shouldn't happen but protect
1026                 // if the user doesn't cleanup.
1027                 if (brcm_4329_enable_count > 2)
1028                         brcm_4329_enable_count = 2;
1029         } else {
1030                 if (brcm_4329_enable_count > 0)
1031                         brcm_4329_enable_count--;
1032                 if (!brcm_4329_enable_count)
1033                         gpio_set_value(TEGRA_GPIO_PU4, enable);
1034         }
1035         spin_unlock_irqrestore(&brcm_4329_enable_lock, flags);
1036 }
1037
1038 static void __init tegra_stingray_init(void)
1039 {
1040         struct clk *clk;
1041         struct resource *res;
1042
1043         /* force consoles to stay enabled across suspend/resume */
1044         console_suspend_enabled = 0;
1045
1046         tegra_common_init();
1047         tegra_init_suspend(&stingray_suspend);
1048         stingray_init_emc();
1049
1050         /* Set the SDMMC2 (wifi) tap delay to 6.  This value is determined
1051          * based on propagation delay on the PCB traces. */
1052         clk = clk_get_sys("sdhci-tegra.1", NULL);
1053         if (!IS_ERR(clk)) {
1054                 tegra_sdmmc_tap_delay(clk, 6);
1055                 clk_put(clk);
1056         } else {
1057                 pr_err("Failed to set wifi sdmmc tap delay\n");
1058         }
1059
1060         /* Stingray has a USB switch that disconnects the usb port from the T20
1061            unless a factory cable is used, the factory jumper is set, or the
1062            usb_data_en gpio is set.
1063          */
1064         if (!stingray_qbp_usb_hw_bypass_enabled()) {
1065                 tegra_gpio_enable(TEGRA_GPIO_PV4);
1066                 gpio_request(TEGRA_GPIO_PV4, "usb_data_en");
1067                 gpio_direction_output(TEGRA_GPIO_PV4, 1);
1068         }
1069
1070         /* USB_FORCEON_N (TEGRA_GPIO_PC5) should be forced high at boot
1071            and will be pulled low by the hardware on attach */
1072         tegra_gpio_enable(TEGRA_GPIO_PC5);
1073         gpio_request(TEGRA_GPIO_PC5, "usb_forceon_n");
1074         gpio_direction_output(TEGRA_GPIO_PC5, 1);
1075         gpio_export(TEGRA_GPIO_PC5, false);
1076
1077         tegra_gpio_enable(TEGRA_GPIO_PQ6);
1078         gpio_request(TEGRA_GPIO_PQ6, "usb_bp_rem_wake");
1079         gpio_direction_input(TEGRA_GPIO_PQ6);
1080         gpio_export(TEGRA_GPIO_PQ6, false);
1081
1082         /* Enable charging */
1083         tegra_gpio_enable(TEGRA_GPIO_PV5);
1084         gpio_request(TEGRA_GPIO_PV5, "chg_stat1");
1085         gpio_direction_input(TEGRA_GPIO_PV5);
1086         gpio_export(TEGRA_GPIO_PV5, false);
1087         if (stingray_revision() <= STINGRAY_REVISION_P0) {
1088                 bq24617_device.resource = bq24617_resources_m1_p0;
1089                 bq24617_device.num_resources = ARRAY_SIZE(bq24617_resources_m1_p0);
1090
1091                 tegra_gpio_enable(TEGRA_GPIO_PV6);
1092                 gpio_request(TEGRA_GPIO_PV6, "chg_stat2");
1093                 gpio_direction_input(TEGRA_GPIO_PV6);
1094                 gpio_export(TEGRA_GPIO_PV6, false);
1095
1096                 tegra_gpio_enable(TEGRA_GPIO_PJ0);
1097                 gpio_request(TEGRA_GPIO_PJ0, "chg_disable");
1098                 gpio_direction_output(TEGRA_GPIO_PJ0, 0);
1099                 gpio_export(TEGRA_GPIO_PJ0, false);
1100         } else {
1101                 tegra_gpio_enable(TEGRA_GPIO_PV6);
1102                 gpio_request(TEGRA_GPIO_PV6, "chg_detect");
1103                 gpio_direction_input(TEGRA_GPIO_PV6);
1104                 gpio_export(TEGRA_GPIO_PV6, false);
1105
1106                 tegra_gpio_enable(TEGRA_GPIO_PD1);
1107                 gpio_request(TEGRA_GPIO_PD1, "chg_stat2");
1108                 gpio_direction_input(TEGRA_GPIO_PD1);
1109                 gpio_export(TEGRA_GPIO_PD1, false);
1110
1111                 if (stingray_revision() >= STINGRAY_REVISION_P2) {
1112                         tegra_gpio_enable(TEGRA_GPIO_PS7);
1113                         gpio_request(TEGRA_GPIO_PS7, "chg_disable");
1114                         gpio_direction_output(TEGRA_GPIO_PS7, 0);
1115                         gpio_export(TEGRA_GPIO_PS7, false);
1116                 } else {
1117                         tegra_gpio_enable(TEGRA_GPIO_PI4);
1118                         gpio_request(TEGRA_GPIO_PI4, "chg_disable");
1119                         gpio_direction_output(TEGRA_GPIO_PI4, 0);
1120                         gpio_export(TEGRA_GPIO_PI4, false);
1121                 }
1122         }
1123
1124         /* Enable charge LEDs */
1125         if (stingray_revision() >= STINGRAY_REVISION_P2) {
1126                 tegra_gpio_enable(TEGRA_GPIO_PV0);
1127                 gpio_request(TEGRA_GPIO_PV0, "chg_led_disable");
1128                 gpio_direction_output(TEGRA_GPIO_PV0, 0);
1129                 gpio_export(TEGRA_GPIO_PV0, false);
1130         } else if (stingray_revision() >= STINGRAY_REVISION_P0) {
1131                 /* Set the SYS_CLK_REQ override bit to allow PZ5 to be used
1132                    as a GPIO. */
1133                 writel(0, IO_TO_VIRT(TEGRA_PMC_BASE + 0x01C));
1134                 tegra_gpio_enable(TEGRA_GPIO_PZ5);
1135                 gpio_request(TEGRA_GPIO_PZ5, "chg_led_disable");
1136                 gpio_direction_output(TEGRA_GPIO_PZ5, 0);
1137                 gpio_export(TEGRA_GPIO_PZ5, false);
1138         }
1139
1140         if (stingray_revision() <= STINGRAY_REVISION_P1) {
1141                 pr_info("Disabling core dvfs on P1 hardware\n");
1142                 tegra_dvfs_rail_disable_by_name("vdd_core");
1143         }
1144
1145         /* Enable 4329 Power GPIO */
1146         tegra_gpio_enable(TEGRA_GPIO_PU4);
1147         gpio_request(TEGRA_GPIO_PU4, "4329_pwr");
1148         gpio_direction_output(TEGRA_GPIO_PU4, 0);
1149
1150         stingray_pinmux_init();
1151
1152         tegra_clk_init_from_table(stingray_clk_init_table);
1153
1154         clk = tegra_get_clock_by_name("uartb");
1155         tegra_serial_debug_init(TEGRA_UARTB_BASE, INT_UARTB,
1156                                 clk, INT_QUAD_RES_31, -1);
1157
1158         init_dac1();
1159         init_dac2(false);
1160         tegra_i2s_device1.dev.platform_data = &tegra_audio_pdata;
1161         tegra_i2s_device2.dev.platform_data = &tegra_audio2_pdata;
1162         cpcap_device_register(&cpcap_audio_device);
1163         tegra_spdif_device.dev.platform_data = &tegra_spdif_pdata;
1164
1165         tegra_ehci1_device.dev.platform_data = &tegra_ehci_pdata[0];
1166         tegra_uartc_device.dev.platform_data = &tegra_uartc_pdata;
1167
1168         res = platform_get_resource(&ram_console_device, IORESOURCE_MEM, 0);
1169         res->start = ramconsole_start;
1170         res->end = ramconsole_start + ramconsole_size - 1;
1171
1172         stingray_carveouts[1].base = tegra_carveout_start;
1173         stingray_carveouts[1].size = tegra_carveout_size;
1174
1175         platform_add_devices(stingray_devices, ARRAY_SIZE(stingray_devices));
1176
1177         stingray_i2c_init();
1178         stingray_power_off_init();
1179         stingray_keypad_init();
1180         stingray_touch_init();
1181         stingray_power_init();
1182         stingray_panel_init();
1183         stingray_sdhci_init();
1184         stingray_w1_init();
1185         stingray_sensors_init();
1186         stingray_wlan_init();
1187         stingray_gps_init();
1188         stingray_usb_init();
1189 }
1190
1191 int __init stingray_protected_aperture_init(void)
1192 {
1193         tegra_protected_aperture_init(tegra_grhost_aperture);
1194         memblock_free(tegra_bootloader_fb_start, tegra_bootloader_fb_size);
1195         return 0;
1196 }
1197 late_initcall(stingray_protected_aperture_init);
1198
1199 void __init stingray_map_io(void)
1200 {
1201         tegra_map_common_io();
1202 }
1203
1204 static int __init stingray_ramconsole_arg(char *options)
1205 {
1206         char *p = options;
1207
1208         ramconsole_size = memparse(p, &p);
1209         if (*p == '@')
1210                 ramconsole_start = memparse(p+1, &p);
1211
1212         return 0;
1213 }
1214 early_param("ramconsole", stingray_ramconsole_arg);
1215
1216 void __init stingray_reserve(void)
1217 {
1218         long ret;
1219         if (memblock_reserve(0x0, 4096) < 0)
1220                 pr_warn("Cannot reserve first 4K of memory for safety\n");
1221
1222         ret = memblock_remove(SZ_512M - SZ_2M, SZ_2M);
1223         if (ret)
1224                 pr_info("Failed to remove ram console\n");
1225         else
1226                 pr_info("Reserved %08lx@%08lx for ram console\n",
1227                         ramconsole_start, ramconsole_size);
1228
1229         tegra_reserve(SZ_256M, SZ_8M, SZ_16M);
1230
1231         if (memblock_reserve(tegra_bootloader_fb_start, tegra_bootloader_fb_size))
1232                 pr_info("Failed to reserve old framebuffer location\n");
1233         else
1234                 pr_info("HACK: Old framebuffer:  %08lx - %08lx\n",
1235                         tegra_bootloader_fb_start,
1236                         tegra_bootloader_fb_start + tegra_bootloader_fb_size - 1);
1237 }
1238
1239 MACHINE_START(STINGRAY, "stingray")
1240         .boot_params    = 0x00000100,
1241         .phys_io        = IO_APB_PHYS,
1242         .io_pg_offst    = ((IO_APB_VIRT) >> 18) & 0xfffc,
1243         .init_irq       = tegra_init_irq,
1244         .init_machine   = tegra_stingray_init,
1245         .map_io         = stingray_map_io,
1246         .reserve        = stingray_reserve,
1247         .timer          = &tegra_timer,
1248 MACHINE_END