RK2928 USB modified
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2928 / devices.c
1 /* arch/arm/mach-rk2928/devices.c
2  *
3  * Copyright (C) 2012 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/board.h>
27 #include <mach/dma-pl330.h>
28 #include <mach/gpio.h>
29 #include <mach/iomux.h>
30 #include <plat/rk_fiq_debugger.h>
31
32 #ifdef CONFIG_ADC_RK30
33 static struct resource rk30_adc_resource[] = {
34         {
35                 .start  = IRQ_SARADC,
36                 .end    = IRQ_SARADC,
37                 .flags  = IORESOURCE_IRQ,
38         },
39         {
40                 .start  = RK2928_SARADC_PHYS,
41                 .end    = RK2928_SARADC_PHYS + RK2928_SARADC_SIZE - 1,
42                 .flags  = IORESOURCE_MEM,
43         },
44 };
45
46 struct platform_device device_adc = {
47         .name           = "rk30-adc",
48         .id             = -1,
49         .num_resources  = ARRAY_SIZE(rk30_adc_resource),
50         .resource       = rk30_adc_resource,
51 };
52 #endif
53
54 static u64 dma_dmamask = DMA_BIT_MASK(32);
55
56 static struct resource resource_dmac[] = {
57         [0] = {
58                 .start  = RK2928_DMAC_PHYS,
59                 .end    = RK2928_DMAC_PHYS + RK2928_DMAC_SIZE -1,
60                 .flags  = IORESOURCE_MEM,
61         },
62         [1] = {
63                 .start  = IRQ_DMAC_0,
64                 .end    = IRQ_DMAC_1,
65                 .flags  = IORESOURCE_IRQ,
66         },
67 };
68
69 static struct rk29_pl330_platdata dmac_pdata = {
70         .peri = {
71                 [0] = DMACH_I2S0_8CH_TX,
72                 [1] = DMACH_I2S0_8CH_RX,
73                 [2] = DMACH_UART0_TX,
74                 [3] = DMACH_UART0_RX,
75                 [4] = DMACH_UART1_TX,
76                 [5] = DMACH_UART1_RX,
77                 [6] = DMACH_UART2_TX,
78                 [7] = DMACH_UART2_RX,
79                 [8] = DMACH_SPI0_TX,
80                 [9] = DMACH_SPI0_RX,
81                 [10] = DMACH_SDMMC,
82                 [11] = DMACH_SDIO,
83                 [12] = DMACH_EMMC,
84                 [13] = DMACH_DMAC1_MEMTOMEM,
85                 [14] = DMACH_MAX,
86                 [15] = DMACH_MAX,
87                 [16] = DMACH_MAX,
88                 [17] = DMACH_MAX,
89                 [18] = DMACH_MAX,
90                 [19] = DMACH_MAX,
91                 [20] = DMACH_MAX,
92                 [21] = DMACH_MAX,
93                 [22] = DMACH_MAX,
94                 [23] = DMACH_MAX,
95                 [24] = DMACH_MAX,
96                 [25] = DMACH_MAX,
97                 [26] = DMACH_MAX,
98                 [27] = DMACH_MAX,
99                 [28] = DMACH_MAX,
100                 [29] = DMACH_MAX,
101                 [30] = DMACH_MAX,
102                 [31] = DMACH_MAX,
103         },
104 };
105
106 static struct platform_device device_dmac = {
107         .name           = "rk29-pl330",
108         .id             = -1,
109         .num_resources  = ARRAY_SIZE(resource_dmac),
110         .resource       = resource_dmac,
111         .dev            = {
112                 .dma_mask = &dma_dmamask,
113                 .coherent_dma_mask = DMA_BIT_MASK(32),
114                 .platform_data = &dmac_pdata,
115         },
116 };
117
118 static struct platform_device *rk2928_dmacs[] __initdata = {
119         &device_dmac,
120 };
121
122 static void __init rk2928_init_dma(void)
123 {
124         platform_add_devices(rk2928_dmacs, ARRAY_SIZE(rk2928_dmacs));
125 }
126
127 #ifdef CONFIG_UART0_RK29
128 static struct resource resources_uart0[] = {
129         {
130                 .start  = IRQ_UART0,
131                 .end    = IRQ_UART0,
132                 .flags  = IORESOURCE_IRQ,
133         },
134         {
135                 .start  = RK2928_UART0_PHYS,
136                 .end    = RK2928_UART0_PHYS + RK2928_UART0_SIZE - 1,
137                 .flags  = IORESOURCE_MEM,
138         },
139 };
140
141 static struct platform_device device_uart0 = {
142         .name   = "rk_serial",
143         .id     = 0,
144         .num_resources  = ARRAY_SIZE(resources_uart0),
145         .resource       = resources_uart0,
146 };
147 #endif
148
149 #ifdef CONFIG_UART1_RK29
150 static struct resource resources_uart1[] = {
151         {
152                 .start  = IRQ_UART1,
153                 .end    = IRQ_UART1,
154                 .flags  = IORESOURCE_IRQ,
155         },
156         {
157                 .start  = RK2928_UART1_PHYS,
158                 .end    = RK2928_UART1_PHYS + RK2928_UART1_SIZE - 1,
159                 .flags  = IORESOURCE_MEM,
160         },
161 };
162
163 static struct platform_device device_uart1 = {
164         .name   = "rk_serial",
165         .id     = 1,
166         .num_resources  = ARRAY_SIZE(resources_uart1),
167         .resource       = resources_uart1,
168 };
169 #endif
170
171 #ifdef CONFIG_UART2_RK29
172 static struct resource resources_uart2[] = {
173         {
174                 .start  = IRQ_UART2,
175                 .end    = IRQ_UART2,
176                 .flags  = IORESOURCE_IRQ,
177         },
178         {
179                 .start  = RK2928_UART2_PHYS,
180                 .end    = RK2928_UART2_PHYS + RK2928_UART2_SIZE - 1,
181                 .flags  = IORESOURCE_MEM,
182         },
183 };
184
185 static struct platform_device device_uart2 = {
186         .name   = "rk_serial",
187         .id     = 2,
188         .num_resources  = ARRAY_SIZE(resources_uart2),
189         .resource       = resources_uart2,
190 };
191 #endif
192
193 static void __init rk2928_init_uart(void)
194 {
195 #ifdef CONFIG_UART0_RK29
196         platform_device_register(&device_uart0);
197 #endif
198 #ifdef CONFIG_UART1_RK29
199         platform_device_register(&device_uart1);
200 #endif
201 #ifdef CONFIG_UART2_RK29
202         platform_device_register(&device_uart2);
203 #endif
204 }
205
206 // i2c
207 #ifdef CONFIG_I2C_RK30
208 #ifdef CONFIG_I2C0_CONTROLLER_RK29
209 #define I2C0_ADAP_TYPE  I2C_RK29_ADAP
210 #define I2C0_START      RK2928_I2C0_PHYS
211 #define I2C0_END        RK2928_I2C0_PHYS + RK2928_I2C0_SIZE - 1
212 #endif
213 #ifdef CONFIG_I2C0_CONTROLLER_RK30
214 #define I2C0_ADAP_TYPE   I2C_RK30_ADAP
215 #define I2C0_START      RK2928_RKI2C0_PHYS
216 #define I2C0_END        RK2928_RKI2C0_PHYS + RK2928_RKI2C0_SIZE - 1
217 #endif
218
219 #ifdef CONFIG_I2C1_CONTROLLER_RK29
220 #define I2C1_ADAP_TYPE  I2C_RK29_ADAP
221 #define I2C1_START      RK2928_I2C1_PHYS
222 #define I2C1_END        RK2928_I2C1_PHYS + RK2928_I2C1_SIZE - 1
223 #endif
224 #ifdef CONFIG_I2C1_CONTROLLER_RK30
225 #define I2C1_ADAP_TYPE   I2C_RK30_ADAP
226 #define I2C1_START      RK2928_RKI2C1_PHYS 
227 #define I2C1_END        RK2928_RKI2C1_PHYS + RK2928_RKI2C1_SIZE - 1
228 #endif
229
230 #ifdef CONFIG_I2C2_CONTROLLER_RK29
231 #define I2C2_ADAP_TYPE  I2C_RK29_ADAP
232 #define I2C2_START      RK2928_I2C2_PHYS
233 #define I2C2_END        RK2928_I2C2_PHYS + RK2928_I2C2_SIZE - 1
234 #endif
235 #ifdef CONFIG_I2C2_CONTROLLER_RK30
236 #define I2C2_ADAP_TYPE   I2C_RK30_ADAP
237 #define I2C2_START      RK2928_RKI2C2_PHYS
238 #define I2C2_END        RK2928_RKI2C2_PHYS + RK2928_RKI2C2_SIZE - 1
239 #endif
240
241 #ifdef CONFIG_I2C3_CONTROLLER_RK29
242 #define I2C3_ADAP_TYPE  I2C_RK29_ADAP
243 #define I2C3_START      RK2928_I2C3_PHYS
244 #define I2C3_END        RK2928_I2C3_PHYS + RK2928_I2C3_SIZE - 1
245 #endif
246 #ifdef CONFIG_I2C3_CONTROLLER_RK30
247 #define I2C3_ADAP_TYPE   I2C_RK30_ADAP
248 #define I2C3_START      RK2928_RKI2C3_PHYS
249 #define I2C3_END        RK2928_RKI2C3_PHYS + RK2928_RKI2C3_SIZE - 1
250 #endif
251
252 struct i2c_iomux{
253         int scl_pin;
254         char *scl_name;
255         unsigned int scl_i2c_mode;
256         unsigned int scl_gpio_mode;
257
258         int sda_pin;
259         char *sda_name;
260         unsigned int sda_i2c_mode;
261         unsigned int sda_gpio_mode;
262
263         char *req_name;
264 };
265 static struct i2c_iomux iomux[] = {
266         {
267                 .scl_pin = RK2928_PIN0_PA0,
268                 .scl_name = GPIO0A0_I2C0_SCL_NAME,
269                 .scl_i2c_mode = GPIO0A_I2C0_SCL,
270                 .scl_gpio_mode = 0,
271                 .sda_pin = RK2928_PIN0_PA1,
272                 .sda_name = GPIO0A1_I2C0_SDA_NAME,
273                 .sda_i2c_mode = GPIO0A_I2C0_SDA,
274                 .sda_gpio_mode = 0,
275                 .req_name = "i2c.0",
276         },
277         {
278                 .scl_pin = RK2928_PIN0_PA2,
279                 .scl_name = GPIO0A2_I2C1_SCL_NAME,
280                 .scl_i2c_mode = GPIO0A_I2C1_SCL,
281                 .scl_gpio_mode = 0,
282                 .sda_pin = RK2928_PIN0_PA3,
283                 .sda_name = GPIO0A3_I2C1_SDA_NAME,
284                 .sda_i2c_mode = GPIO0A_I2C1_SDA,
285                 .sda_gpio_mode = 0,
286                 .req_name = "i2c.1",
287         },
288         {
289                 .scl_pin = RK2928_PIN2_PC5,
290                 .scl_name = GPIO2C5_LCDC0_D19_LCDC1_D19_I2C2_SCL_NAME,
291                 .scl_i2c_mode = GPIO2C_I2C2_SCL,
292                 .scl_gpio_mode = 0,
293                 .sda_pin = RK2928_PIN2_PC4,
294                 .sda_name = GPIO2C4_LCDC0_D18_LCDC1_D18_I2C2_SDA_NAME,
295                 .sda_i2c_mode = GPIO2C_I2C2_SDA,
296                 .sda_gpio_mode = 0,
297                 .req_name = "i2c.2",
298         },
299         {
300                 .scl_pin = RK2928_PIN0_PA6,
301                 .scl_name = GPIO0A6_I2C3_SCL_HDMI_DDCSCL_NAME,
302                 .scl_i2c_mode = GPIO0A_I2C3_SCL,
303                 .scl_gpio_mode = 0,
304                 .sda_pin = RK2928_PIN0_PA7,
305                 .sda_name = GPIO0A7_I2C3_SDA_HDMI_DDCSDA_NAME,
306                 .sda_i2c_mode = GPIO0A_I2C3_SDA,
307                 .sda_gpio_mode = 0,
308                 .req_name = "i2c.3",
309         },
310 };
311 static int i2c_check_idle(int id)
312 {
313         int sda_level, scl_level;
314         
315         if(id < 0 || id > 3){
316                 printk("Error: id: %d\n", id);
317         }
318
319         rk30_mux_api_set(iomux[id].scl_name, iomux[id].scl_gpio_mode);  
320         rk30_mux_api_set(iomux[id].sda_name, iomux[id].sda_gpio_mode);  
321
322         gpio_request(iomux[id].scl_pin, iomux[id].req_name);
323         gpio_request(iomux[id].sda_pin, iomux[id].req_name);
324         
325         gpio_direction_input(iomux[id].scl_pin);
326         gpio_direction_input(iomux[id].sda_pin);
327
328         scl_level = gpio_get_value(iomux[id].scl_pin);
329         sda_level = gpio_get_value(iomux[id].sda_pin);
330
331         gpio_free(iomux[id].scl_pin);
332         gpio_free(iomux[id].sda_pin);
333
334         rk30_mux_api_set(iomux[id].scl_name, iomux[id].scl_i2c_mode);   
335         rk30_mux_api_set(iomux[id].sda_name, iomux[id].sda_i2c_mode);   
336         
337         if(sda_level == 1 && scl_level == 1)
338                 return I2C_IDLE;
339         else if(sda_level == 0 && scl_level == 1)
340                 return I2C_SDA_LOW;
341         else if(sda_level == 1 && scl_level == 0)
342                 return I2C_SCL_LOW;
343         else
344                 return BOTH_LOW;
345 }
346
347 #ifdef CONFIG_I2C2_RK30
348 static struct rk30_i2c_platform_data default_i2c0_data = {
349         .bus_num = 0,
350         .is_div_from_arm = 1,
351         .adap_type = I2C0_ADAP_TYPE,
352         .check_idle = &i2c_check_idle,
353 };
354
355 static struct resource resources_i2c0[] = {
356         {
357                 .start  = IRQ_I2C0,
358                 .end    = IRQ_I2C0,
359                 .flags  = IORESOURCE_IRQ,
360         },
361         {
362                 .start  = I2C0_START,
363         .end    = I2C0_END,    
364                 .flags  = IORESOURCE_MEM,
365         },
366 };
367
368 static struct platform_device device_i2c0 = {
369         .name   = "rk30_i2c",
370         .id     = 0,
371         .num_resources  = ARRAY_SIZE(resources_i2c0),
372         .resource       = resources_i2c0,
373         .dev            = {
374                 .platform_data = &default_i2c0_data,
375         },
376 };
377 #endif
378
379 #ifdef CONFIG_I2C1_RK30
380 static struct rk30_i2c_platform_data default_i2c1_data = {
381         .bus_num = 1,
382         .is_div_from_arm = 1,
383         .adap_type = I2C1_ADAP_TYPE,
384         .check_idle = &i2c_check_idle,
385 };
386
387 static struct resource resources_i2c1[] = {
388         {
389                 .start  = IRQ_I2C1,
390                 .end    = IRQ_I2C1,
391                 .flags  = IORESOURCE_IRQ,
392         },
393         {
394                 .start  = I2C1_START,
395         .end    = I2C1_END,    
396                 .flags  = IORESOURCE_MEM,
397         },
398 };
399
400 static struct platform_device device_i2c1 = {
401         .name   = "rk30_i2c",
402         .id     = 1,
403         .num_resources  = ARRAY_SIZE(resources_i2c1),
404         .resource       = resources_i2c1,
405         .dev            = {
406                 .platform_data = &default_i2c1_data,
407         },
408 };
409 #endif
410
411 #ifdef CONFIG_I2C2_RK30
412 static struct rk30_i2c_platform_data default_i2c2_data = {
413         .bus_num = 2,
414         .is_div_from_arm = 0,
415         .adap_type = I2C2_ADAP_TYPE,
416         .check_idle = &i2c_check_idle,
417 };
418
419 static struct resource resources_i2c2[] = {
420         {
421                 .start  = IRQ_I2C2,
422                 .end    = IRQ_I2C2,
423                 .flags  = IORESOURCE_IRQ,
424         },
425         {
426                 .start  = I2C2_START,
427         .end    = I2C2_END,    
428                 .flags  = IORESOURCE_MEM,
429         },
430 };
431
432 static struct platform_device device_i2c2 = {
433         .name   = "rk30_i2c",
434         .id     = 2,
435         .num_resources  = ARRAY_SIZE(resources_i2c2),
436         .resource       = resources_i2c2,
437         .dev            = {
438                 .platform_data = &default_i2c2_data,
439         },
440 };
441 #endif
442
443 #ifdef CONFIG_I2C3_RK30
444 static struct rk30_i2c_platform_data default_i2c3_data = {
445         .bus_num = 3,
446         .is_div_from_arm = 0,
447         .adap_type = I2C3_ADAP_TYPE,
448         .check_idle = &i2c_check_idle,
449 };
450
451 static struct resource resources_i2c3[] = {
452         {
453                 .start  = IRQ_I2C3,
454                 .end    = IRQ_I2C3,
455                 .flags  = IORESOURCE_IRQ,
456         },
457         {
458                 .start  = I2C3_START,
459         .end    = I2C3_END,    
460                 .flags  = IORESOURCE_MEM,
461         },
462 };
463
464 static struct platform_device device_i2c3 = {
465         .name   = "rk30_i2c",
466         .id     = 3,
467         .num_resources  = ARRAY_SIZE(resources_i2c3),
468         .resource       = resources_i2c3,
469         .dev            = {
470                 .platform_data = &default_i2c3_data,
471         },
472 };
473 #endif
474
475 #ifdef CONFIG_I2C_GPIO_RK30
476 static struct platform_device device_i2c_gpio = {
477         .name   = "i2c-gpio",
478         .id = 4,
479         .dev            = {
480                 .platform_data = &default_i2c_gpio_data,
481         },
482 };
483 #endif
484
485 static void __init rk2928_init_i2c(void)
486 {
487 #ifdef CONFIG_I2C0_RK30
488         platform_device_register(&device_i2c0);
489 #endif
490 #ifdef CONFIG_I2C1_RK30
491         platform_device_register(&device_i2c1);
492 #endif
493 #ifdef CONFIG_I2C2_RK30
494         platform_device_register(&device_i2c2);
495 #endif
496 #ifdef CONFIG_I2C3_RK30
497         platform_device_register(&device_i2c3);
498 #endif
499 #ifdef CONFIG_I2C_GPIO_RK30
500         platform_device_register(&device_i2c_gpio);
501 #endif
502 }
503 #endif//end of i2c
504
505 #if defined(CONFIG_SPIM0_RK29) || defined(CONFIG_SPIM1_RK29)
506 /*****************************************************************************************
507  * spi devices
508  * author: cmc@rock-chips.com
509  *****************************************************************************************/
510 #define SPI_CHIPSELECT_NUM 2
511
512 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
513 {
514         int i;
515         if (cs_gpios) {
516                 for (i = 0; i < cs_num; i++) {
517                         rk30_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
518                 }
519         }
520         return 0;
521 }
522
523 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
524 {
525         return 0;
526 }
527
528 static int spi_io_fix_leakage_bug(void)
529 {
530 #if 0
531         gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
532 #endif
533         return 0;
534 }
535
536 static int spi_io_resume_leakage_bug(void)
537 {
538 #if 0
539         gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
540 #endif
541         return 0;
542 }
543 #endif
544
545 /*
546  * rk29xx spi master device
547  */
548 #ifdef CONFIG_SPIM0_RK29
549 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
550         {
551                 .name = "spi0 cs0",
552                 .cs_gpio = RK2928_PIN1_PB3,
553                 .cs_iomux_name = GPIO1B3_SPI_CSN0_UART1_RTSN_NAME,
554                 .cs_iomux_mode = GPIO1B_SPI_CSN0,
555         },
556         {
557                 .name = "spi0 cs1",
558                 .cs_gpio = RK2928_PIN1_PB4,
559                 .cs_iomux_name = GPIO1B4_SPI_CSN1_UART1_CTSN_NAME,//if no iomux,set it NULL
560                 .cs_iomux_mode = GPIO1B_SPI_CSN1,
561         },
562 };
563
564 static struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
565         .num_chipselect = SPI_CHIPSELECT_NUM,
566         .chipselect_gpios = rk29xx_spi0_cs_gpios,
567         .io_init = spi_io_init,
568         .io_deinit = spi_io_deinit,
569         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
570         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
571 };
572
573 static struct resource rk29_spi0_resources[] = {
574         {
575                 .start  = IRQ_SPI,
576                 .end    = IRQ_SPI,
577                 .flags  = IORESOURCE_IRQ,
578         },
579         {
580                 .start  = RK2928_SPI_PHYS,
581                 .end    = RK2928_SPI_PHYS + RK2928_SPI_SIZE - 1,
582                 .flags  = IORESOURCE_MEM,
583         },
584         {
585                 .start  = DMACH_SPI0_TX,
586                 .end    = DMACH_SPI0_TX,
587                 .flags  = IORESOURCE_DMA,
588         },
589         {
590                 .start  = DMACH_SPI0_RX,
591                 .end    = DMACH_SPI0_RX,
592                 .flags  = IORESOURCE_DMA,
593         },
594 };
595
596 struct platform_device rk29xx_device_spi0m = {
597         .name   = "rk29xx_spim",
598         .id     = 0,
599         .num_resources  = ARRAY_SIZE(rk29_spi0_resources),
600         .resource       = rk29_spi0_resources,
601         .dev                    = {
602                 .dma_mask = &dma_dmamask,
603                 .coherent_dma_mask = DMA_BIT_MASK(32),
604                 .platform_data  = &rk29xx_spi0_platdata,
605         },
606 };
607 #endif
608
609 static void __init rk2928_init_spim(void)
610 {
611 #ifdef CONFIG_SPIM0_RK29
612         platform_device_register(&rk29xx_device_spi0m);
613 #endif
614 }
615
616 #ifdef CONFIG_MTD_NAND_RK29XX
617 static struct resource resources_nand[] = {
618         {
619                 .start  = RK2928_NANDC_PHYS,
620                 .end    = RK2928_NANDC_PHYS + RK2928_NANDC_SIZE - 1,
621                 .flags  = IORESOURCE_MEM,
622         }
623 };
624
625 static struct platform_device device_nand = {
626         .name           = "rk29xxnand",
627         .id             = -1,
628         .resource       = resources_nand,
629         .num_resources  = ARRAY_SIZE(resources_nand),
630 };
631 #endif
632 #ifdef CONFIG_HDMI_RK2928
633 static struct resource resource_hdmi[] = {
634         [0] = {
635                 .start = RK2928_HDMI_PHYS,
636                 .end   = RK2928_HDMI_PHYS + RK2928_HDMI_SIZE - 1,
637                 .flags = IORESOURCE_MEM,
638         },
639         [1] = {
640                 .start = IRQ_HDMI,
641                 .end   = IRQ_HDMI,
642                 .flags = IORESOURCE_IRQ,
643         },
644 };
645
646 static struct platform_device device_hdmi = {
647         .name                           = "rk2928-hdmi",
648         .id                                     = -1,
649         .num_resources          = ARRAY_SIZE(resource_hdmi),
650         .resource                       = resource_hdmi,
651 };
652 #endif
653 #ifdef CONFIG_RGA_RK30
654 static struct resource resource_rga[] = {
655         [0] = {
656                 .start = RK2928_RGA_PHYS,
657                 .end   = RK2928_RGA_PHYS + RK2928_RGA_SIZE - 1,
658                 .flags = IORESOURCE_MEM,
659         },
660         [1] = {
661                 .start = IRQ_RGA,
662                 .end   = IRQ_RGA,
663                 .flags = IORESOURCE_IRQ,
664         },
665 };
666
667 static struct platform_device device_rga = {
668         .name           = "rga",
669         .id             = -1,
670         .num_resources  = ARRAY_SIZE(resource_rga),
671         .resource       = resource_rga,
672 };
673 #endif
674 #ifdef CONFIG_SND_RK29_SOC_I2S
675 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
676 static struct resource resource_iis0_8ch[] = {
677         [0] = {
678                 .start  = RK2928_I2S_PHYS,
679                 .end    = RK2928_I2S_PHYS + RK2928_I2S_SIZE - 1,
680                 .flags  = IORESOURCE_MEM,
681         },
682         [1] = {
683                 .start  = DMACH_I2S0_8CH_TX,
684                 .end    = DMACH_I2S0_8CH_TX,
685                 .flags  = IORESOURCE_DMA,
686         },
687         [2] = {
688                 .start  = DMACH_I2S0_8CH_RX,
689                 .end    = DMACH_I2S0_8CH_RX,
690                 .flags  = IORESOURCE_DMA,
691         },
692         [3] = {
693                 .start  = IRQ_I2S,
694                 .end    = IRQ_I2S,
695                 .flags  = IORESOURCE_IRQ,
696         },
697 };
698
699 static struct platform_device device_iis0_8ch = {
700         .name           = "rk29_i2s",
701         .id             = 0,
702         .num_resources  = ARRAY_SIZE(resource_iis0_8ch),
703         .resource       = resource_iis0_8ch,
704 };
705 #endif
706 #endif
707 static struct platform_device device_pcm = {
708         .name = "rockchip-audio",
709         .id = -1,
710 };
711
712 static void __init rk2928_init_i2s(void)
713 {
714 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
715         platform_device_register(&device_iis0_8ch);
716 #endif
717         platform_device_register(&device_pcm);
718 }
719 #ifdef CONFIG_KEYS_RK29
720 extern struct rk29_keys_platform_data rk29_keys_pdata;
721 static struct platform_device device_keys = {
722         .name           = "rk29-keypad",
723         .id             = -1,
724         .dev            = {
725                 .platform_data  = &rk29_keys_pdata,
726         },
727 };
728 #endif
729
730 #ifdef CONFIG_SDMMC0_RK29
731 static struct resource resources_sdmmc0[] = {
732         {
733                 .start  = IRQ_SDMMC,
734                 .end    = IRQ_SDMMC,
735                 .flags  = IORESOURCE_IRQ,
736         },
737         {
738                 .start  = RK2928_SDMMC_PHYS,
739                 .end    = RK2928_SDMMC_PHYS + RK2928_SDMMC_SIZE -1,
740                 .flags  = IORESOURCE_MEM,
741         }
742 };
743
744 static struct platform_device device_sdmmc0 = {
745         .name           = "rk29_sdmmc",
746         .id             = 0,
747         .num_resources  = ARRAY_SIZE(resources_sdmmc0),
748         .resource       = resources_sdmmc0,
749         .dev            = {
750                 .platform_data = &default_sdmmc0_data,
751         },
752 };
753 #endif
754
755 #ifdef CONFIG_SDMMC1_RK29
756 static struct resource resources_sdmmc1[] = {
757         {
758                 .start  = IRQ_SDIO,
759                 .end    = IRQ_SDIO,
760                 .flags  = IORESOURCE_IRQ,
761         },
762         {
763                 .start  = RK2928_SDIO_PHYS,
764                 .end    = RK2928_SDIO_PHYS + RK2928_SDIO_SIZE - 1,
765                 .flags  = IORESOURCE_MEM,
766         }
767 };
768
769 static struct platform_device device_sdmmc1 = {
770         .name           = "rk29_sdmmc",
771         .id             = 1,
772         .num_resources  = ARRAY_SIZE(resources_sdmmc1),
773         .resource       = resources_sdmmc1,
774         .dev            = {
775                 .platform_data = &default_sdmmc1_data,
776         },
777 };
778 #endif
779 static void __init rk2928_init_sdmmc(void)
780 {
781 #ifdef CONFIG_SDMMC0_RK29
782         platform_device_register(&device_sdmmc0);
783 #endif
784 #ifdef CONFIG_SDMMC1_RK29
785         platform_device_register(&device_sdmmc1);
786 #endif
787 }
788
789 static struct resource resource_arm_pmu = {
790         .start          = IRQ_ARM_PMU,
791         .end            = IRQ_ARM_PMU,
792         .flags          = IORESOURCE_IRQ,
793 };
794
795 struct platform_device device_arm_pmu = {
796         .name           = "arm-pmu",
797         .id             = ARM_PMU_DEVICE_CPU,
798         .num_resources  = 1,
799         .resource       = &resource_arm_pmu,
800 };
801
802 static int __init rk2928_init_devices(void)
803 {
804         rk2928_init_dma();
805         rk2928_init_uart();
806         rk2928_init_i2c();
807         rk2928_init_spim();
808 #ifdef CONFIG_MTD_NAND_RK29XX
809         platform_device_register(&device_nand);
810 #endif
811 #ifdef CONFIG_ADC_RK30
812         platform_device_register(&device_adc);
813 #endif
814 #ifdef CONFIG_KEYS_RK29
815         platform_device_register(&device_keys);
816 #endif
817 #ifdef CONFIG_RGA_RK30
818         platform_device_register(&device_rga);
819 #endif
820         rk2928_init_sdmmc();
821 #if defined(CONFIG_FIQ_DEBUGGER) && defined(DEBUG_UART_PHYS)
822         rk_serial_debug_init(DEBUG_UART_BASE, IRQ_DEBUG_UART, IRQ_UART_SIGNAL, -1);
823 #endif
824         rk2928_init_i2s();
825 #ifdef CONFIG_HDMI_RK2928
826         platform_device_register(&device_hdmi);
827 #endif
828         platform_device_register(&device_arm_pmu);
829         return 0;
830 }
831 arch_initcall(rk2928_init_devices);