K97 项目相关修改
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk29 / devices.c
1 /* arch/arm/mach-rk29/devices.c
2  *
3  * Copyright (C) 2010 ROCKCHIP, Inc.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15  
16 #include <linux/fs.h>
17 #include <linux/kernel.h>
18 #include <linux/platform_device.h>
19 #ifdef CONFIG_USB_ANDROID
20 #include <linux/usb/android_composite.h>
21 #endif
22 #include <linux/delay.h>
23 #include <linux/dma-mapping.h>
24 #include <asm/pmu.h>
25 #include <mach/irqs.h>
26 #include <mach/rk29_iomap.h>
27 #include <mach/rk29-dma-pl330.h> 
28 #include <mach/rk29_camera.h>                          /* ddl@rock-chips.com : camera support */
29 #include <mach/board.h>
30 #include <mach/loader.h>
31 #include "devices.h"
32 #ifdef CONFIG_ADC_RK29
33 static struct resource rk29_adc_resource[] = {
34         {
35                 .start = IRQ_SARADC,
36                 .end   = IRQ_SARADC,
37                 .flags = IORESOURCE_IRQ,
38         },
39         {
40                 .start = RK29_ADC_PHYS,
41                 .end   = RK29_ADC_PHYS + RK29_ADC_SIZE - 1,
42                 .flags = IORESOURCE_MEM,
43         },
44
45 };
46
47 struct platform_device rk29_device_adc = {
48         .name             = "rk29-adc",
49         .id               = -1,
50         .num_resources    = ARRAY_SIZE(rk29_adc_resource),
51         .resource         = rk29_adc_resource,
52 };
53
54 #endif
55
56 #ifdef CONFIG_BATTERY_RK29_ADC
57 struct platform_device rk29_adc_device_battery = {
58                 .name   = "rk2918-battery",
59                 .id     = -1,
60                 .dev = {
61                         .platform_data = &rk29_adc_battery_platdata,
62                 },
63 };
64 #endif
65 #ifdef CONFIG_RK29_VMAC
66 static u64 eth_dmamask = DMA_BIT_MASK(32);
67 static struct resource rk29_vmac_resource[] = {
68         [0] = {
69                 .start = RK29_MAC_PHYS,    
70                 .end   = RK29_MAC_PHYS + RK29_MAC_SIZE - 1,
71                 .flags = IORESOURCE_MEM,
72         },
73         [1] = {
74                 .start = IRQ_MAC,
75                 .end   = IRQ_MAC,
76                 .flags = IORESOURCE_IRQ,
77         }
78
79 };
80
81 struct platform_device rk29_device_vmac = {
82         .name           = "rk29 vmac",
83         .id             = 0,
84         .dev = {
85                 .dma_mask               = &eth_dmamask,
86                 .coherent_dma_mask      = DMA_BIT_MASK(32),
87                 .platform_data = &rk29_vmac_pdata,
88         },
89         .num_resources  = ARRAY_SIZE(rk29_vmac_resource),
90         .resource       = rk29_vmac_resource,
91 };
92 #endif
93
94 #ifdef CONFIG_I2C_RK29
95 #ifdef CONFIG_RK29_I2C0_CONTROLLER
96 static struct resource resources_i2c0[] = {
97         {
98                 .start  = IRQ_I2C0,
99                 .end    = IRQ_I2C0,
100                 .flags  = IORESOURCE_IRQ,
101         },
102         {
103                 .start  = RK29_I2C0_PHYS,
104                 .end    = RK29_I2C0_PHYS + SZ_4K - 1,
105                 .flags  = IORESOURCE_MEM,
106         },
107 };
108 #endif
109 #ifdef CONFIG_RK29_I2C1_CONTROLLER
110 static struct resource resources_i2c1[] = {
111         {
112                 .start  = IRQ_I2C1,
113                 .end    = IRQ_I2C1,
114                 .flags  = IORESOURCE_IRQ,
115         },
116         {
117                 .start  = RK29_I2C1_PHYS,
118                 .end    = RK29_I2C1_PHYS + SZ_4K - 1,
119                 .flags  = IORESOURCE_MEM,
120         },
121 };
122 #endif
123 #ifdef CONFIG_RK29_I2C2_CONTROLLER
124 static struct resource resources_i2c2[] = {
125         {
126                 .start  = IRQ_I2C2,
127                 .end    = IRQ_I2C2,
128                 .flags  = IORESOURCE_IRQ,
129         },
130         {
131                 .start  = RK29_I2C2_PHYS,
132                 .end    = RK29_I2C2_PHYS + SZ_4K - 1,
133                 .flags  = IORESOURCE_MEM,
134         },
135 };
136 #endif
137 #ifdef CONFIG_RK29_I2C3_CONTROLLER
138 static struct resource resources_i2c3[] = {
139         {
140                 .start  = IRQ_I2C3,
141                 .end    = IRQ_I2C3,
142                 .flags  = IORESOURCE_IRQ,
143         },
144         {
145                 .start  = RK29_I2C3_PHYS,
146                 .end    = RK29_I2C3_PHYS + SZ_4K - 1,
147                 .flags  = IORESOURCE_MEM,
148         },
149 };
150 #endif
151 struct platform_device rk29_device_i2c0 = {
152 #ifdef CONFIG_RK29_I2C0_CONTROLLER
153         .name   = "rk29_i2c",
154         .id     = 0,
155         .num_resources  = ARRAY_SIZE(resources_i2c0),
156         .resource       = resources_i2c0,
157         .dev                    = {
158                 .platform_data = &default_i2c0_data,
159         },
160 #else
161         .name   = "i2c-gpio",
162         .id = 0,
163         .dev                    = {
164                 .platform_data = &default_i2c0_data,
165         },
166 #endif
167 };
168 struct platform_device rk29_device_i2c1 = {
169 #ifdef CONFIG_RK29_I2C1_CONTROLLER
170         .name   = "rk29_i2c",
171         .id     = 1,
172         .num_resources  = ARRAY_SIZE(resources_i2c1),
173         .resource       = resources_i2c1,
174         .dev                    = {
175                 .platform_data = &default_i2c1_data,
176         },
177 #else
178         .name   = "i2c-gpio",
179         .id = 1,
180         .dev                    = {
181                 .platform_data = &default_i2c1_data,
182         },
183 #endif
184 };
185 struct platform_device rk29_device_i2c2 = {
186 #ifdef CONFIG_RK29_I2C2_CONTROLLER
187         .name   = "rk29_i2c",
188         .id     = 2,
189         .num_resources  = ARRAY_SIZE(resources_i2c2),
190         .resource       = resources_i2c2,
191         .dev                    = {
192                 .platform_data = &default_i2c2_data,
193         },
194 #else
195         .name   = "i2c-gpio",
196         .id = 2,
197         .dev                    = {
198                 .platform_data = &default_i2c2_data,
199         },
200 #endif
201 };
202 struct platform_device rk29_device_i2c3 = {
203 #ifdef CONFIG_RK29_I2C3_CONTROLLER
204         .name   = "rk29_i2c",
205         .id     = 3,
206         .num_resources  = ARRAY_SIZE(resources_i2c3),
207         .resource       = resources_i2c3,
208         .dev                    = {
209                 .platform_data = &default_i2c3_data,
210         },
211 #else
212         .name   = "i2c-gpio",
213         .id = 3,
214         .dev                    = {
215                 .platform_data = &default_i2c3_data,
216         },
217 #endif
218 };
219 #endif
220
221 /***********************************************************
222 *         backlight
223 ***************************************************************/
224 #ifdef CONFIG_BACKLIGHT_RK29_BL
225 struct platform_device rk29_device_backlight = {
226                 .name   = "rk29_backlight",
227                 .id     = -1,
228         .dev    = {
229            .platform_data  = &rk29_bl_info,
230         }
231 };
232 #endif
233
234 #ifdef CONFIG_BUTTON_LIGHT
235 struct platform_device rk29_device_buttonlight = {
236                 .name = "rk29_button_light",
237                 .id = -1,
238                 .dev = {
239                         .platform_data = &rk29_button_light_info,
240                 }
241 };
242 #endif
243 #ifdef CONFIG_SDMMC0_RK29 
244 #ifndef CONFIG_EMMC_RK29 
245 static struct resource resources_sdmmc0[] = {
246         {
247                 .start  = IRQ_SDMMC,
248                 .end    = IRQ_SDMMC,
249                 .flags  = IORESOURCE_IRQ,
250         },
251         {
252                 .start  = RK29_SDMMC0_PHYS,   
253                 .end    = RK29_SDMMC0_PHYS + RK29_SDMMC0_SIZE -1,
254                 .flags  = IORESOURCE_MEM,
255         }
256 };
257 #else
258 static struct resource resources_sdmmc0[] = {
259         {
260                 .start  = IRQ_EMMC,
261                 .end    = IRQ_EMMC,
262                 .flags  = IORESOURCE_IRQ,
263         },
264         {
265                 .start  = RK29_EMMC_PHYS,   
266                 .end    = RK29_EMMC_PHYS + RK29_EMMC_SIZE -1,
267                 .flags  = IORESOURCE_MEM,
268         }
269 };
270 #endif
271 #endif
272 #ifdef CONFIG_SDMMC1_RK29
273 static struct resource resources_sdmmc1[] = {
274         {
275                 .start  = IRQ_SDIO,
276                 .end    = IRQ_SDIO,
277                 .flags  = IORESOURCE_IRQ,
278         },
279         {
280                 .start  = RK29_SDMMC1_PHYS,
281                 .end    = RK29_SDMMC1_PHYS + RK29_SDMMC1_SIZE -1,
282                 .flags  = IORESOURCE_MEM,
283         }
284 }; 
285 #endif
286 /* sdmmc */
287 #ifdef CONFIG_SDMMC0_RK29
288 struct platform_device rk29_device_sdmmc0 = {
289         .name                   = "rk29_sdmmc",
290         .id                             = 0,
291         .num_resources  = ARRAY_SIZE(resources_sdmmc0),
292         .resource               = resources_sdmmc0,
293         .dev                    = {
294                 .platform_data = &default_sdmmc0_data,
295         },
296 };
297 #endif
298 #ifdef CONFIG_SDMMC1_RK29
299 struct platform_device rk29_device_sdmmc1 = {
300         .name                   = "rk29_sdmmc",
301         .id                             = 1,
302         .num_resources  = ARRAY_SIZE(resources_sdmmc1),
303         .resource               = resources_sdmmc1,
304         .dev                    = {
305                 .platform_data = &default_sdmmc1_data,
306         },
307 };
308 #endif
309
310 /*
311  * rk29 wdt device  ADDED BY HHB@ROCK-CHIPS.COM
312  */
313
314 #ifdef CONFIG_RK29_WATCHDOG
315
316 static struct resource resources_wdt[] = {
317         {
318                 .start  = IRQ_WDT,
319                 .end    = IRQ_WDT,
320                 .flags  = IORESOURCE_IRQ,
321         },
322         {
323                 .start  = RK29_WDT_PHYS,
324                 .end    = RK29_WDT_PHYS + RK29_WDT_SIZE - 1,
325                 .flags  = IORESOURCE_MEM,
326         },
327 };
328
329 struct platform_device rk29_device_wdt = {
330         .name   = "rk29-wdt",
331         .id     = 0,
332         .num_resources  = ARRAY_SIZE(resources_wdt),
333         .resource       = resources_wdt,
334 };
335
336 #endif
337
338
339 /*
340  * rk29 4 uarts device
341  */
342 #ifdef CONFIG_UART0_RK29
343 static struct resource resources_uart0[] = {
344         {
345                 .start  = IRQ_UART0,
346                 .end    = IRQ_UART0,
347                 .flags  = IORESOURCE_IRQ,
348         },
349         {
350                 .start  = RK29_UART0_PHYS,
351                 .end    = RK29_UART0_PHYS + RK29_UART0_SIZE - 1,
352                 .flags  = IORESOURCE_MEM,
353         },
354 };
355 #endif
356 #ifdef CONFIG_UART1_RK29
357 static struct resource resources_uart1[] = {
358         {
359                 .start  = IRQ_UART1,
360                 .end    = IRQ_UART1,
361                 .flags  = IORESOURCE_IRQ,
362         },
363         {
364                 .start  = RK29_UART1_PHYS,
365                 .end    = RK29_UART1_PHYS + RK29_UART1_SIZE - 1,
366                 .flags  = IORESOURCE_MEM,
367         },
368 };
369 #endif
370 #ifdef CONFIG_UART2_RK29
371 static struct resource resources_uart2[] = {
372         {
373                 .start  = IRQ_UART2,
374                 .end    = IRQ_UART2,
375                 .flags  = IORESOURCE_IRQ,
376         },
377         {
378                 .start  = RK29_UART2_PHYS,
379                 .end    = RK29_UART2_PHYS + RK29_UART2_SIZE - 1,
380                 .flags  = IORESOURCE_MEM,
381         },
382 };
383 #endif
384 #ifdef CONFIG_UART3_RK29
385 static struct resource resources_uart3[] = {
386         {
387                 .start  = IRQ_UART3,
388                 .end    = IRQ_UART3,
389                 .flags  = IORESOURCE_IRQ,
390         },
391         {
392                 .start  = RK29_UART3_PHYS,
393                 .end    = RK29_UART3_PHYS + RK29_UART3_SIZE - 1,
394                 .flags  = IORESOURCE_MEM,
395         },
396 };
397 #endif
398 #ifdef CONFIG_UART0_RK29
399 struct platform_device rk29_device_uart0 = {
400         .name   = "rk29_serial",
401         .id     = 0,
402         .num_resources  = ARRAY_SIZE(resources_uart0),
403         .resource       = resources_uart0,
404 };
405 #endif
406 #ifdef CONFIG_UART1_RK29
407 struct platform_device rk29_device_uart1 = {
408         .name   = "rk29_serial",
409         .id     = 1,
410         .num_resources  = ARRAY_SIZE(resources_uart1),
411         .resource       = resources_uart1,
412 };
413 #endif
414 #ifdef CONFIG_UART2_RK29
415 struct platform_device rk29_device_uart2 = {
416         .name   = "rk29_serial",
417         .id     = 2,
418         .num_resources  = ARRAY_SIZE(resources_uart2),
419         .resource       = resources_uart2,
420 };
421 #endif
422 #ifdef CONFIG_UART3_RK29
423 struct platform_device rk29_device_uart3 = {
424         .name   = "rk29_serial",
425         .id     = 3,
426         .num_resources  = ARRAY_SIZE(resources_uart3),
427         .resource       = resources_uart3,
428 };
429 #endif
430
431 /*
432  * rk29xx spi master device
433  */
434 static struct resource rk29_spi0_resources[] = {
435         {
436                 .start  = IRQ_SPI0,
437                 .end    = IRQ_SPI0,
438                 .flags  = IORESOURCE_IRQ,
439         },
440         {
441                 .start  = RK29_SPI0_PHYS,
442                 .end    = RK29_SPI0_PHYS + RK29_SPI0_SIZE - 1,
443                 .flags  = IORESOURCE_MEM,
444         },
445         {
446                 .start  = DMACH_SPI0_TX,
447                 .end    = DMACH_SPI0_TX,
448                 .flags  = IORESOURCE_DMA,
449         },
450         {
451                 .start  = DMACH_SPI0_RX,
452                 .end    = DMACH_SPI0_RX,
453                 .flags  = IORESOURCE_DMA,
454         },
455 };
456
457 struct platform_device rk29xx_device_spi0m = {
458         .name   = "rk29xx_spim",
459         .id     = 0,
460         .num_resources  = ARRAY_SIZE(rk29_spi0_resources),
461         .resource       = rk29_spi0_resources,
462         .dev                    = {
463                 .platform_data  = &rk29xx_spi0_platdata,
464         },
465 };
466
467 static struct resource rk29_spi1_resources[] = {
468         {
469                 .start  = IRQ_SPI1,
470                 .end    = IRQ_SPI1,
471                 .flags  = IORESOURCE_IRQ,
472         },
473         {
474                 .start  = RK29_SPI1_PHYS,
475                 .end    = RK29_SPI1_PHYS + RK29_SPI1_SIZE - 1,
476                 .flags  = IORESOURCE_MEM,
477         },
478         {
479                 .start  = DMACH_SPI1_TX,
480                 .end    = DMACH_SPI1_TX,
481                 .flags  = IORESOURCE_DMA,
482         },
483         {
484                 .start  = DMACH_SPI1_RX,
485                 .end    = DMACH_SPI1_RX,
486                 .flags  = IORESOURCE_DMA,
487         },
488 };
489
490 struct platform_device rk29xx_device_spi1m = {
491         .name   = "rk29xx_spim",
492         .id     = 1,
493         .num_resources  = ARRAY_SIZE(rk29_spi1_resources),
494         .resource       = rk29_spi1_resources,
495         .dev                    = {
496                 .platform_data  = &rk29xx_spi1_platdata,
497         },
498 };
499
500 #if defined(CONFIG_MTD_NAND_RK29XX)  
501 static struct resource rk29xxnand_resources[] = {
502         {
503                 .start  = RK29_NANDC_PHYS,
504                 .end    =       RK29_NANDC_PHYS+RK29_NANDC_SIZE -1,
505                 .flags  = IORESOURCE_MEM,
506         }
507 };
508
509 struct platform_device rk29xx_device_nand = {
510         .name   = "rk29xxnand", 
511         .id             =  -1, 
512         .resource       = rk29xxnand_resources,
513         .num_resources= ARRAY_SIZE(rk29xxnand_resources),
514         .dev    = {
515                 .platform_data= &rk29_nand_data,
516         },
517         
518 };
519 #endif
520
521
522 #if defined(CONFIG_MTD_NAND_RK29)  
523 static struct resource nand_resources[] = {
524         {
525                 .start  = RK29_NANDC_PHYS,
526                 .end    =       RK29_NANDC_PHYS+RK29_NANDC_SIZE -1,
527                 .flags  = IORESOURCE_MEM,
528         }
529 };
530
531 struct platform_device rk29_device_nand = {
532         .name   = "rk29-nand",
533         .id             =  -1, 
534         .resource       = nand_resources,
535         .num_resources= ARRAY_SIZE(nand_resources),
536         .dev    = {
537                 .platform_data= &rk29_nand_data,
538         },
539         
540 };
541 #endif
542
543 #if defined(CONFIG_SND_RK29_SOC_I2S)
544 static struct resource rk29_iis_2ch_resource[] = {
545         [0] = {
546                 .start = RK29_I2S_2CH_PHYS,
547                 .end   = RK29_I2S_2CH_PHYS + RK29_I2S_2CH_SIZE -1,
548                 .flags = IORESOURCE_MEM,
549         },
550         [1] = {
551                 .start = DMACH_I2S_2CH_TX,
552                 .end   = DMACH_I2S_2CH_TX,
553                 .flags = IORESOURCE_DMA,
554         },
555         [2] = {
556                 .start = DMACH_I2S_2CH_RX,
557                 .end   = DMACH_I2S_2CH_RX,
558                 .flags = IORESOURCE_DMA,
559         },
560         [3] = {
561                 .start = IRQ_I2S_2CH,
562                 .end   = IRQ_I2S_2CH,
563                 .flags = IORESOURCE_IRQ,        
564         },
565 };
566
567 struct platform_device rk29_device_iis_2ch = {
568         .name           = "rk29_i2s",
569         .id             = 1,
570         .num_resources  = ARRAY_SIZE(rk29_iis_2ch_resource),
571         .resource       = rk29_iis_2ch_resource,
572 };
573
574 static struct resource rk29_iis_8ch_resource[] = {
575         [0] = {
576                 .start = RK29_I2S_8CH_PHYS,
577                 .end   = RK29_I2S_8CH_PHYS + RK29_I2S_8CH_SIZE - 1,
578                 .flags = IORESOURCE_MEM,
579         },
580         [1] = {
581                 .start = DMACH_I2S_8CH_TX,
582                 .end   = DMACH_I2S_8CH_TX,
583                 .flags = IORESOURCE_DMA,
584         },
585         [2] = {
586                 .start = DMACH_I2S_8CH_RX,
587                 .end   = DMACH_I2S_8CH_RX,
588                 .flags = IORESOURCE_DMA,
589         },
590         [3] = {
591                 .start = IRQ_I2S_8CH,
592                 .end   = IRQ_I2S_8CH,
593                 .flags = IORESOURCE_IRQ,        
594         },
595 };
596
597 struct platform_device rk29_device_iis_8ch = {
598         .name           = "rk29_i2s",
599         .id             = 0,
600         .num_resources  = ARRAY_SIZE(rk29_iis_8ch_resource),
601         .resource       = rk29_iis_8ch_resource,
602 };
603 #endif
604
605 static struct platform_device rk29_device_pcm = {
606         .name = "rockchip-audio",
607         .id = -1,
608 };
609
610 #ifdef CONFIG_RK29_IPP
611 /* rk29 ipp resource */
612 static struct resource rk29_ipp_resource[] = {
613         [0] = {
614                 .start = RK29_IPP_PHYS,
615                 .end   = RK29_IPP_PHYS + RK29_IPP_SIZE - 1,
616                 .flags = IORESOURCE_MEM,
617         },
618         [1] = {
619                 .start = IRQ_IPP,
620                 .end   = IRQ_IPP,
621                 .flags = IORESOURCE_IRQ,
622         },
623 };
624
625 /*platform_device*/
626 //extern struct rk29ipp_info rk29_ipp_info;
627 struct platform_device rk29_device_ipp = {
628         .name             = "rk29-ipp",
629         .id               = -1,
630         .num_resources    = ARRAY_SIZE(rk29_ipp_resource),
631         .resource         = rk29_ipp_resource,
632 };
633 #endif
634
635 #ifdef CONFIG_USB20_OTG
636 /*DWC_OTG*/
637 static struct resource usb20_otg_resource[] = {
638         {
639                 .start = IRQ_USB_OTG0,
640                 .end   = IRQ_USB_OTG0,
641                 .flags = IORESOURCE_IRQ,
642         },
643         {
644                 .start = RK29_USBOTG0_PHYS,
645                 .end   = RK29_USBOTG0_PHYS + RK29_USBOTG0_SIZE - 1,
646                 .flags = IORESOURCE_MEM,
647         },
648
649 };
650
651 struct platform_device rk29_device_usb20_otg = {
652         .name             = "usb20_otg",
653         .id               = -1,
654         .num_resources    = ARRAY_SIZE(usb20_otg_resource),
655         .resource         = usb20_otg_resource,
656 };
657 #endif
658 #ifdef CONFIG_USB_ANDROID
659
660 static char *usb_functions_rockchip[] = {
661         "usb_mass_storage",
662 };
663
664 static char *usb_functions_rockchip_adb[] = {
665         "usb_mass_storage",
666         "adb",
667 };
668
669 static char *usb_functions_rndis_rockchip[] = {
670         "rndis",
671         "usb_mass_storage",
672 };
673
674 static char *usb_functions_rndis_rockchip_adb[] = {
675         "rndis",
676         "usb_mass_storage",
677         "adb",
678 };
679
680 #ifdef CONFIG_USB_ANDROID_DIAG
681 static char *usb_functions_adb_diag[] = {
682         "usb_mass_storage",
683         "adb",
684         "diag",
685 };
686 #endif
687
688 static char *usb_functions_all[] = {
689 #ifdef CONFIG_USB_ANDROID_RNDIS
690         "rndis",
691 #endif
692         "usb_mass_storage",
693 #ifdef CONFIG_USB_ANDROID_ADB
694         "adb",
695 #endif
696 #ifdef CONFIG_USB_ANDROID_ACM
697         "acm",
698 #endif
699 #ifdef CONFIG_USB_ANDROID_DIAG
700         "diag",
701 #endif
702 };
703
704 static struct android_usb_product usb_products[] = {
705         {
706                 .product_id     = 0x2910,//0x0c02,//0x4e11,
707                 .num_functions  = ARRAY_SIZE(usb_functions_rockchip),
708                 .functions      = usb_functions_rockchip,
709         },
710         {
711                 .product_id     = 0x0c02,//0x0c02,//0x4e12,
712                 .num_functions  = ARRAY_SIZE(usb_functions_rockchip_adb),
713                 .functions      = usb_functions_rockchip_adb,
714         },
715         {
716                 .product_id     = 0x4e13,
717                 .num_functions  = ARRAY_SIZE(usb_functions_rndis_rockchip),
718                 .functions      = usb_functions_rndis_rockchip,
719         },
720         {
721                 .product_id     = 0x4e14,
722                 .num_functions  = ARRAY_SIZE(usb_functions_rndis_rockchip_adb),
723                 .functions      = usb_functions_rndis_rockchip_adb,
724         },
725 #ifdef CONFIG_USB_ANDROID_DIAG
726         {
727                 .product_id     = 0x4e17,
728                 .num_functions  = ARRAY_SIZE(usb_functions_adb_diag),
729                 .functions      = usb_functions_adb_diag,
730         },
731 #endif
732 };
733 /*
734  * if anyone want to use adb driver of HTC G1,
735  * please change vendor_id to 0x0bb4 and product_id to 0x0c02.
736  */
737 static struct android_usb_platform_data android_usb_pdata = {
738         .vendor_id      = 0x0bb4,//0x2207,//0x0bb4,//0x18d1,
739         .product_id     = 0x4e11,//0x2910,//0x4e11,
740         .version        = 0x0100,
741         .product_name           = "rk2918 sdk",
742         .manufacturer_name      = "RockChip",
743         .num_products = ARRAY_SIZE(usb_products),
744         .products = usb_products,
745         .num_functions = ARRAY_SIZE(usb_functions_all),
746         .functions = usb_functions_all,
747 };
748
749 //static 
750 struct platform_device android_usb_device = {
751         .name   = "android_usb",
752         .id             = -1,
753         .dev            = {
754                 .platform_data = &android_usb_pdata,
755         },
756 };
757
758 /********************usb*********************/
759 struct usb_mass_storage_platform_data mass_storage_pdata = {
760         .nluns          = 2,
761         .vendor         = "RockChip",
762         .product        = "rk29 sdk",
763         .release        = 0x0100,
764 };
765
766 //static 
767 struct platform_device usb_mass_storage_device = {
768         .name   = "usb_mass_storage",
769         .id     = -1,
770         .dev    = {
771                 .platform_data = &mass_storage_pdata,
772         },
773 };
774 #endif
775
776 #ifdef CONFIG_USB_ANDROID_RNDIS
777 static struct usb_ether_platform_data rndis_pdata = {
778         /* ethaddr is filled by board_serialno_setup */
779         .ethaddr    = {0xf0, 0xde, 0xf1, 0x42, 0xe8, 0x10},
780         .vendorID       = 0x22b8,// moto xt701 //0x2207,
781         .vendorDescr    = "RockChip",
782 };
783
784 struct platform_device rk29_device_rndis = {
785         .name   = "rndis",
786         .id     = -1,
787         .dev    = {
788                 .platform_data = &rndis_pdata,
789         },
790 };
791 #endif
792
793 #ifdef CONFIG_USB11_HOST
794 static struct resource usb11_host_resource[] = {
795     {
796         .start = IRQ_USB_HOST,
797         .end   = IRQ_USB_HOST,
798         .flags = IORESOURCE_IRQ,
799     },
800     {
801         .start = RK29_USBHOST_PHYS,
802         .end   = RK29_USBHOST_PHYS + RK29_USBHOST_SIZE - 1,
803         .flags = IORESOURCE_MEM,
804     },
805
806 };
807
808 struct platform_device rk29_device_usb11_host = {
809     .name             = "usb11_host",
810     .id               = -1,
811     .num_resources    = ARRAY_SIZE(usb11_host_resource),
812     .resource         = usb11_host_resource,
813 };
814 #endif
815 #ifdef CONFIG_USB20_HOST
816 static struct resource usb20_host_resource[] = {
817     {
818         .start = IRQ_USB_OTG1,
819         .end   = IRQ_USB_OTG1,
820         .flags = IORESOURCE_IRQ,
821     },
822     {
823         .start = RK29_USBOTG1_PHYS,
824         .end   = RK29_USBOTG1_PHYS + RK29_USBOTG1_SIZE - 1,
825         .flags = IORESOURCE_MEM,
826     },
827
828 };
829
830 struct platform_device rk29_device_usb20_host = {
831     .name             = "usb20_host",
832     .id               = -1,
833     .num_resources    = ARRAY_SIZE(usb20_host_resource),
834     .resource         = usb20_host_resource,
835 };
836 #endif
837
838 static struct resource rk29_pmu_resource = {
839         .start          = IRQ_A8IRQ3,
840         .end            = IRQ_A8IRQ3,
841         .flags          = IORESOURCE_IRQ,
842 };
843
844 struct platform_device rk29_device_pmu = {
845         .name           = "arm-pmu",
846         .id             = ARM_PMU_DEVICE_CPU,
847         .num_resources  = 1,
848         .resource       = &rk29_pmu_resource,
849 };
850
851 static int boot_mode;
852 static int __init boot_mode_init(char *s)
853 {
854         if (!strcmp(s, "normal"))
855                 boot_mode = BOOT_MODE_NORMAL;
856         else if (!strcmp(s, "factory2"))
857                 boot_mode = BOOT_MODE_FACTORY2;
858         else if (!strcmp(s, "recovery"))
859                 boot_mode = BOOT_MODE_RECOVERY;
860         else if (!strcmp(s, "charge"))
861                 boot_mode = BOOT_MODE_CHARGE;
862         else if (!strcmp(s, "power_test"))
863                 boot_mode = BOOT_MODE_POWER_TEST;
864         else if (!strcmp(s, "offmode_charging"))
865                 boot_mode = BOOT_MODE_OFFMODE_CHARGING;
866
867         return 1;
868 }
869 __setup("androidboot.mode=", boot_mode_init);
870
871 __init void rk29_boot_mode_init_by_register(void)
872 {
873         u32 flag = readl(RK29_TIMER0_BASE);
874         if (flag == (SYS_KERNRL_REBOOT_FLAG | BOOT_RECOVER)) {
875                 boot_mode = BOOT_MODE_RECOVERY;
876         } else if (strstr(boot_command_line, "(parameter)")) {
877                 boot_mode = BOOT_MODE_RECOVERY;
878         } else {
879                 boot_mode = readl(RK29_GRF_BASE + 0xdc); // GRF_OS_REG3
880         }
881         if (boot_mode)
882                 printk("Boot mode: %d\n", boot_mode);
883 }
884
885 int board_boot_mode(void)
886 {
887         return boot_mode;
888 }
889 EXPORT_SYMBOL(board_boot_mode);
890
891 static int __init rk29_init_devices(void)
892 {
893         platform_device_register(&rk29_device_pmu);
894         platform_device_register(&rk29_device_pcm);
895         return 0;
896 }
897 arch_initcall(rk29_init_devices);