rk30:add backlight config
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / devices.c
1 /* arch/arm/mach-rk30/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 #include <linux/delay.h>
20 #include <linux/dma-mapping.h>
21 #include <asm/pmu.h>
22 #include <mach/irqs.h>
23 #include <mach/board.h>
24 #include <plat/dma-pl330.h>
25 #include <mach/gpio.h>
26 #include <mach/iomux.h>
27 static u64 dma_dmamask = DMA_BIT_MASK(32);
28
29 static struct resource resource_dmac1[] = {
30         [0] = {
31                 .start  = RK30_DMACS1_PHYS,
32                 .end    = RK30_DMACS1_PHYS + RK30_DMACS1_SIZE -1,
33                 .flags  = IORESOURCE_MEM,
34         },
35         [1] = {
36                 .start  = IRQ_DMAC1_0,
37                 .end    = IRQ_DMAC1_1,
38                 .flags  = IORESOURCE_IRQ,
39         },
40 };
41
42 static struct rk29_pl330_platdata dmac1_pdata = {
43         .peri = {
44                 [0] = DMACH_UART0_TX,
45                 [1] = DMACH_UART0_RX,
46                 [2] = DMACH_UART1_TX,
47                 [3] = DMACH_UART1_RX,
48                 [4] = DMACH_I2S0_8CH_TX,
49                 [5] = DMACH_I2S0_8CH_RX,
50                 [6] = DMACH_I2S1_2CH_TX,
51                 [7] = DMACH_I2S1_2CH_RX,
52                 [8] = DMACH_SPDIF_TX,
53                 [9] = DMACH_I2S2_2CH_TX,
54                 [10] = DMACH_I2S2_2CH_RX,
55                 [11] = DMACH_MAX,
56                 [12] = DMACH_MAX,
57                 [13] = DMACH_MAX,
58                 [14] = DMACH_MAX,
59                 [15] = DMACH_MAX,
60                 [16] = DMACH_MAX,
61                 [17] = DMACH_MAX,
62                 [18] = DMACH_MAX,
63                 [19] = DMACH_MAX,
64                 [20] = DMACH_MAX,
65                 [21] = DMACH_MAX,
66                 [22] = DMACH_MAX,
67                 [23] = DMACH_MAX,
68                 [24] = DMACH_MAX,
69                 [25] = DMACH_MAX,
70                 [26] = DMACH_MAX,
71                 [27] = DMACH_MAX,
72                 [28] = DMACH_MAX,
73                 [29] = DMACH_MAX,
74                 [30] = DMACH_MAX,
75                 [31] = DMACH_MAX,
76         },
77 };
78
79 static struct platform_device device_dmac1 = {
80         .name           = "rk29-pl330",
81         .id             = 1,
82         .num_resources  = ARRAY_SIZE(resource_dmac1),
83         .resource       = resource_dmac1,
84         .dev            = {
85                 .dma_mask = &dma_dmamask,
86                 .coherent_dma_mask = DMA_BIT_MASK(32),
87                 .platform_data = &dmac1_pdata,
88         },
89 };
90
91 static struct resource resource_dmac2[] = {
92         [0] = {
93                 .start  = RK30_DMAC2_PHYS,
94                 .end    = RK30_DMAC2_PHYS + RK30_DMAC2_SIZE - 1,
95                 .flags  = IORESOURCE_MEM,
96         },
97         [1] = {
98                 .start  = IRQ_DMAC2_0,
99                 .end    = IRQ_DMAC2_1,
100                 .flags  = IORESOURCE_IRQ,
101         },
102 };
103
104 static struct rk29_pl330_platdata dmac2_pdata = {
105         .peri = {
106                 [0] = DMACH_HSADC,
107                 [1] = DMACH_SDMMC,
108                 [2] = DMACH_MAX,
109                 [3] = DMACH_SDIO,
110                 [4] = DMACH_EMMC,
111                 [5] = DMACH_PID_FILTER,
112                 [6] = DMACH_UART2_TX,
113                 [7] = DMACH_UART2_RX,
114                 [8] = DMACH_UART3_TX,
115                 [9] = DMACH_UART3_RX,
116                 [10] = DMACH_SPI0_TX,
117                 [11] = DMACH_SPI0_RX,
118                 [12] = DMACH_SPI1_TX,
119                 [13] = DMACH_SPI1_RX,
120                 [14] = DMACH_DMAC2_MEMTOMEM,
121                 [15] = DMACH_MAX,
122                 [16] = DMACH_MAX,
123                 [17] = DMACH_MAX,
124                 [18] = DMACH_MAX,
125                 [19] = DMACH_MAX,
126                 [20] = DMACH_MAX,
127                 [21] = DMACH_MAX,
128                 [22] = DMACH_MAX,
129                 [23] = DMACH_MAX,
130                 [24] = DMACH_MAX,
131                 [25] = DMACH_MAX,
132                 [26] = DMACH_MAX,
133                 [27] = DMACH_MAX,
134                 [28] = DMACH_MAX,
135                 [29] = DMACH_MAX,
136                 [30] = DMACH_MAX,
137                 [31] = DMACH_MAX,
138         },
139 };
140
141 static struct platform_device device_dmac2 = {
142         .name           = "rk29-pl330",
143         .id             = 2,
144         .num_resources  = ARRAY_SIZE(resource_dmac2),
145         .resource       = resource_dmac2,
146         .dev            = {
147                 .dma_mask = &dma_dmamask,
148                 .coherent_dma_mask = DMA_BIT_MASK(32),
149                 .platform_data = &dmac2_pdata,
150         },
151 };
152
153 static struct platform_device *rk30_dmacs[] __initdata = {
154         &device_dmac1,
155         &device_dmac2,
156 };
157
158 static void __init rk30_init_dma(void)
159 {
160         platform_add_devices(rk30_dmacs, ARRAY_SIZE(rk30_dmacs));
161 }
162
163 #ifdef CONFIG_UART0_RK29
164 static struct resource resources_uart0[] = {
165         {
166                 .start  = IRQ_UART0,
167                 .end    = IRQ_UART0,
168                 .flags  = IORESOURCE_IRQ,
169         },
170         {
171                 .start  = RK30_UART0_PHYS,
172                 .end    = RK30_UART0_PHYS + RK30_UART0_SIZE - 1,
173                 .flags  = IORESOURCE_MEM,
174         },
175 };
176
177 static struct platform_device device_uart0 = {
178         .name   = "rk_serial",
179         .id     = 0,
180         .num_resources  = ARRAY_SIZE(resources_uart0),
181         .resource       = resources_uart0,
182 };
183 #endif
184
185 #ifdef CONFIG_UART1_RK29
186 static struct resource resources_uart1[] = {
187         {
188                 .start  = IRQ_UART1,
189                 .end    = IRQ_UART1,
190                 .flags  = IORESOURCE_IRQ,
191         },
192         {
193                 .start  = RK30_UART1_PHYS,
194                 .end    = RK30_UART1_PHYS + RK30_UART1_SIZE - 1,
195                 .flags  = IORESOURCE_MEM,
196         },
197 };
198
199 static struct platform_device device_uart1 = {
200         .name   = "rk_serial",
201         .id     = 1,
202         .num_resources  = ARRAY_SIZE(resources_uart1),
203         .resource       = resources_uart1,
204 };
205 #endif
206
207 #ifdef CONFIG_UART2_RK29
208 static struct resource resources_uart2[] = {
209         {
210                 .start  = IRQ_UART2,
211                 .end    = IRQ_UART2,
212                 .flags  = IORESOURCE_IRQ,
213         },
214         {
215                 .start  = RK30_UART2_PHYS,
216                 .end    = RK30_UART2_PHYS + RK30_UART2_SIZE - 1,
217                 .flags  = IORESOURCE_MEM,
218         },
219 };
220
221 static struct platform_device device_uart2 = {
222         .name   = "rk_serial",
223         .id     = 2,
224         .num_resources  = ARRAY_SIZE(resources_uart2),
225         .resource       = resources_uart2,
226 };
227 #endif
228
229 #ifdef CONFIG_UART3_RK29
230 static struct resource resources_uart3[] = {
231         {
232                 .start  = IRQ_UART3,
233                 .end    = IRQ_UART3,
234                 .flags  = IORESOURCE_IRQ,
235         },
236         {
237                 .start  = RK30_UART3_PHYS,
238                 .end    = RK30_UART3_PHYS + RK30_UART3_SIZE - 1,
239                 .flags  = IORESOURCE_MEM,
240         },
241 };
242
243 static struct platform_device device_uart3 = {
244         .name   = "rk_serial",
245         .id     = 3,
246         .num_resources  = ARRAY_SIZE(resources_uart3),
247         .resource       = resources_uart3,
248 };
249 #endif
250
251 static void __init rk30_init_uart(void)
252 {
253 #ifdef CONFIG_UART0_RK29
254         platform_device_register(&device_uart0);
255 #endif
256 #ifdef CONFIG_UART1_RK29
257         platform_device_register(&device_uart1);
258 #endif
259 #ifdef CONFIG_UART2_RK29
260         platform_device_register(&device_uart2);
261 #endif
262 #ifdef CONFIG_UART3_RK29
263         platform_device_register(&device_uart3);
264 #endif
265 }
266
267 // i2c
268 #ifdef CONFIG_I2C0_CONTROLLER_RK29
269 #define I2C0_ADAP_TYPE  I2C_RK29_ADAP
270 #define I2C0_START      RK30_I2C0_PHYS
271 #define I2C0_END        RK30_I2C0_PHYS + SZ_4K - 1
272 #endif
273 #ifdef CONFIG_I2C0_CONTROLLER_RK30
274 #define I2C0_ADAP_TYPE   I2C_RK30_ADAP
275 #define I2C0_START      RK30_I2C0_PHYS + SZ_4K
276 #define I2C0_END        RK30_I2C0_PHYS + SZ_8K - 1
277 #endif
278
279 #ifdef CONFIG_I2C1_CONTROLLER_RK29
280 #define I2C1_ADAP_TYPE  I2C_RK29_ADAP
281 #define I2C1_START      RK30_I2C1_PHYS
282 #define I2C1_END        RK30_I2C1_PHYS + SZ_4K - 1
283 #endif
284 #ifdef CONFIG_I2C1_CONTROLLER_RK30
285 #define I2C1_ADAP_TYPE   I2C_RK30_ADAP
286 #define I2C1_START      RK30_I2C1_PHYS + SZ_4K
287 #define I2C1_END        RK30_I2C1_PHYS + SZ_8K - 1
288 #endif
289
290 #ifdef CONFIG_I2C2_CONTROLLER_RK29
291 #define I2C2_ADAP_TYPE  I2C_RK29_ADAP
292 #define I2C2_START      RK30_I2C2_PHYS
293 #define I2C2_END        RK30_I2C2_PHYS + SZ_4K - 1
294 #endif
295 #ifdef CONFIG_I2C2_CONTROLLER_RK30
296 #define I2C2_ADAP_TYPE   I2C_RK30_ADAP
297 #define I2C2_START      RK30_I2C2_PHYS + SZ_4K
298 #define I2C2_END        RK30_I2C2_PHYS + SZ_8K - 1
299 #endif
300
301 #ifdef CONFIG_I2C3_CONTROLLER_RK29
302 #define I2C3_ADAP_TYPE  I2C_RK29_ADAP
303 #define I2C3_START      RK30_I2C3_PHYS
304 #define I2C3_END        RK30_I2C3_PHYS + SZ_4K - 1
305 #endif
306 #ifdef CONFIG_I2C3_CONTROLLER_RK30
307 #define I2C3_ADAP_TYPE   I2C_RK30_ADAP
308 #define I2C3_START      RK30_I2C3_PHYS + SZ_4K
309 #define I2C3_END        RK30_I2C3_PHYS + SZ_8K - 1
310 #endif
311
312 #ifdef CONFIG_I2C4_CONTROLLER_RK29
313 #define I2C4_ADAP_TYPE  I2C_RK29_ADAP
314 #define I2C4_START      RK30_I2C4_PHYS
315 #define I2C4_END        RK30_I2C4_PHYS + SZ_4K - 1
316 #endif
317 #ifdef CONFIG_I2C4_CONTROLLER_RK30
318 #define I2C4_ADAP_TYPE   I2C_RK30_ADAP
319 #define I2C4_START      RK30_I2C4_PHYS + SZ_4K
320 #define I2C4_END        RK30_I2C4_PHYS + SZ_8K - 1
321 #endif
322
323 #ifdef CONFIG_I2C0_RK30
324 static struct rk30_i2c_platform_data default_i2c0_data = {
325         .bus_num = 0,
326         .is_div_from_arm = 1,
327         .adap_type = I2C0_ADAP_TYPE,
328 };
329
330 static struct resource resources_i2c0[] = {
331         {
332                 .start  = IRQ_I2C0,
333                 .end    = IRQ_I2C0,
334                 .flags  = IORESOURCE_IRQ,
335         },
336         {
337                 .start  = I2C0_START,
338         .end    = I2C0_END,    
339                 .flags  = IORESOURCE_MEM,
340         },
341 };
342
343 static struct platform_device device_i2c0 = {
344         .name   = "rk30_i2c",
345         .id     = 0,
346         .num_resources  = ARRAY_SIZE(resources_i2c0),
347         .resource       = resources_i2c0,
348         .dev            = {
349                 .platform_data = &default_i2c0_data,
350         },
351 };
352 #endif
353
354 #ifdef CONFIG_I2C1_RK30
355 static struct rk30_i2c_platform_data default_i2c1_data = {
356         .bus_num = 1,
357         .is_div_from_arm = 1,
358         .adap_type = I2C1_ADAP_TYPE,
359 };
360
361 static struct resource resources_i2c1[] = {
362         {
363                 .start  = IRQ_I2C1,
364                 .end    = IRQ_I2C1,
365                 .flags  = IORESOURCE_IRQ,
366         },
367         {
368                 .start  = I2C1_START,
369         .end    = I2C1_END,    
370                 .flags  = IORESOURCE_MEM,
371         },
372 };
373
374 static struct platform_device device_i2c1 = {
375         .name   = "rk30_i2c",
376         .id     = 1,
377         .num_resources  = ARRAY_SIZE(resources_i2c1),
378         .resource       = resources_i2c1,
379         .dev            = {
380                 .platform_data = &default_i2c1_data,
381         },
382 };
383 #endif
384
385 #ifdef CONFIG_I2C2_RK30
386 static struct rk30_i2c_platform_data default_i2c2_data = {
387         .bus_num = 2,
388         .is_div_from_arm = 0,
389         .adap_type = I2C2_ADAP_TYPE,
390 };
391
392 static struct resource resources_i2c2[] = {
393         {
394                 .start  = IRQ_I2C2,
395                 .end    = IRQ_I2C2,
396                 .flags  = IORESOURCE_IRQ,
397         },
398         {
399                 .start  = I2C2_START,
400         .end    = I2C2_END,    
401                 .flags  = IORESOURCE_MEM,
402         },
403 };
404
405 static struct platform_device device_i2c2 = {
406         .name   = "rk30_i2c",
407         .id     = 2,
408         .num_resources  = ARRAY_SIZE(resources_i2c2),
409         .resource       = resources_i2c2,
410         .dev            = {
411                 .platform_data = &default_i2c2_data,
412         },
413 };
414 #endif
415
416 #ifdef CONFIG_I2C3_RK30
417 static struct rk30_i2c_platform_data default_i2c3_data = {
418         .bus_num = 3,
419         .is_div_from_arm = 0,
420         .adap_type = I2C3_ADAP_TYPE,
421 };
422
423 static struct resource resources_i2c3[] = {
424         {
425                 .start  = IRQ_I2C3,
426                 .end    = IRQ_I2C3,
427                 .flags  = IORESOURCE_IRQ,
428         },
429         {
430                 .start  = I2C3_START,
431         .end    = I2C3_END,    
432                 .flags  = IORESOURCE_MEM,
433         },
434 };
435
436 static struct platform_device device_i2c3 = {
437         .name   = "rk30_i2c",
438         .id     = 3,
439         .num_resources  = ARRAY_SIZE(resources_i2c3),
440         .resource       = resources_i2c3,
441         .dev            = {
442                 .platform_data = &default_i2c3_data,
443         },
444 };
445 #endif
446
447 #ifdef CONFIG_I2C4_RK30
448 static struct rk30_i2c_platform_data default_i2c4_data = {
449         .bus_num = 4,
450         .is_div_from_arm = 0,
451         .adap_type = I2C4_ADAP_TYPE,
452 };
453
454 static struct resource resources_i2c4[] = {
455         {
456                 .start  = IRQ_I2C4,
457                 .end    = IRQ_I2C4,
458                 .flags  = IORESOURCE_IRQ,
459         },
460         {
461                 .start  = I2C4_START,
462         .end    = I2C4_END,    
463                 .flags  = IORESOURCE_MEM,
464         },
465 };
466
467 static struct platform_device device_i2c4 = {
468         .name   = "rk30_i2c",
469         .id     = 4,
470         .num_resources  = ARRAY_SIZE(resources_i2c4),
471         .resource       = resources_i2c4,
472         .dev            = {
473                 .platform_data = &default_i2c4_data,
474         },
475 };
476 #endif
477
478 static void __init rk30_init_i2c(void)
479 {
480 #ifdef CONFIG_I2C0_RK30
481         platform_device_register(&device_i2c0);
482 #endif
483 #ifdef CONFIG_I2C1_RK30
484         platform_device_register(&device_i2c1);
485 #endif
486 #ifdef CONFIG_I2C2_RK30
487         platform_device_register(&device_i2c2);
488 #endif
489 #ifdef CONFIG_I2C3_RK30
490         platform_device_register(&device_i2c3);
491 #endif
492 #ifdef CONFIG_I2C4_RK30
493         platform_device_register(&device_i2c4);
494 #endif
495 }
496 //end of i2c
497
498 /*****************************************************************************************
499  * spi devices
500  * author: cmc@rock-chips.com
501  *****************************************************************************************/
502 #define SPI_CHIPSELECT_NUM 2
503 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
504         {
505                 .name = "spi0 cs0",
506                 .cs_gpio = RK30_PIN1_PA4,
507                 .cs_iomux_name = GPIO1A4_UART1SIN_SPI0CSN0_NAME,
508                 .cs_iomux_mode = GPIO1A_SPI0_CSN0,
509         },
510         {
511                 .name = "spi0 cs1",
512                 .cs_gpio = RK30_PIN4_PB7,
513                 .cs_iomux_name = GPIO4B7_SPI0CSN1_NAME,//if no iomux,set it NULL
514                 .cs_iomux_mode = GPIO4B_SPI0_CSN1,
515         }
516 };
517
518 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
519         {
520                 .name = "spi1 cs0",
521                 .cs_gpio = RK30_PIN2_PC4,
522                 .cs_iomux_name = GPIO2C4_LCDC1DATA20_SPI1CSN0_HSADCDATA1_NAME,
523                 .cs_iomux_mode = GPIO2C_SPI1_CSN0,
524         },
525         {
526                 .name = "spi1 cs1",
527                 .cs_gpio = RK30_PIN2_PC7,
528                 .cs_iomux_name = GPIO2C7_LCDC1DATA23_SPI1CSN1_HSADCDATA4_NAME,//if no iomux,set it NULL
529                 .cs_iomux_mode = GPIO2C_SPI1_CSN1,
530         }
531 };
532
533 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
534 {
535         int i;
536         if (cs_gpios) {
537                 for (i=0; i<cs_num; i++) {
538                 rk30_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
539                 }
540         }
541         return 0;
542 }
543
544 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
545 {
546         return 0;
547 }
548
549 static int spi_io_fix_leakage_bug(void)
550 {
551 #if 0
552         gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
553 #endif
554         return 0;
555 }
556
557 static int spi_io_resume_leakage_bug(void)
558 {
559 #if 0
560         gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
561 #endif
562         return 0;
563 }
564
565 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
566         .num_chipselect = SPI_CHIPSELECT_NUM,
567         .chipselect_gpios = rk29xx_spi0_cs_gpios,
568         .io_init = spi_io_init,
569         .io_deinit = spi_io_deinit,
570         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
571         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
572 };
573
574 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
575         .num_chipselect = SPI_CHIPSELECT_NUM,
576         .chipselect_gpios = rk29xx_spi1_cs_gpios,
577         .io_init = spi_io_init,
578         .io_deinit = spi_io_deinit,
579         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
580         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
581 };
582
583
584
585 /*
586  * rk29xx spi master device
587  */
588 #ifdef CONFIG_SPIM0_RK29
589 static struct resource rk29_spi0_resources[] = {
590         {
591                 .start  = IRQ_SPI0,
592                 .end    = IRQ_SPI0,
593                 .flags  = IORESOURCE_IRQ,
594         },
595         {
596                 .start  = RK30_SPI0_PHYS,
597                 .end    = RK30_SPI0_PHYS + RK30_SPI0_SIZE - 1,
598                 .flags  = IORESOURCE_MEM,
599         },
600         {
601                 .start  = DMACH_SPI0_TX,
602                 .end    = DMACH_SPI0_TX,
603                 .flags  = IORESOURCE_DMA,
604         },
605         {
606                 .start  = DMACH_SPI0_RX,
607                 .end    = DMACH_SPI0_RX,
608                 .flags  = IORESOURCE_DMA,
609         },
610 };
611
612 struct platform_device rk29xx_device_spi0m = {
613         .name   = "rk29xx_spim",
614         .id     = 0,
615         .num_resources  = ARRAY_SIZE(rk29_spi0_resources),
616         .resource       = rk29_spi0_resources,
617         .dev                    = {
618                 .dma_mask = &dma_dmamask,
619                 .coherent_dma_mask = DMA_BIT_MASK(32),
620                 .platform_data  = &rk29xx_spi0_platdata,
621         },
622 };
623 #endif
624
625 #ifdef CONFIG_SPIM1_RK29
626 static struct resource rk29_spi1_resources[] = {
627         {
628                 .start  = IRQ_SPI1,
629                 .end    = IRQ_SPI1,
630                 .flags  = IORESOURCE_IRQ,
631         },
632         {
633                 .start  = RK30_SPI1_PHYS,
634                 .end    = RK30_SPI1_PHYS + RK30_SPI1_SIZE - 1,
635                 .flags  = IORESOURCE_MEM,
636         },
637         {
638                 .start  = DMACH_SPI1_TX,
639                 .end    = DMACH_SPI1_TX,
640                 .flags  = IORESOURCE_DMA,
641         },
642         {
643                 .start  = DMACH_SPI1_RX,
644                 .end    = DMACH_SPI1_RX,
645                 .flags  = IORESOURCE_DMA,
646         },
647 };
648
649 struct platform_device rk29xx_device_spi1m = {
650         .name   = "rk29xx_spim",
651         .id     = 1,
652         .num_resources  = ARRAY_SIZE(rk29_spi1_resources),
653         .resource       = rk29_spi1_resources,
654         .dev                    = {
655                 .dma_mask = &dma_dmamask,
656                 .coherent_dma_mask = DMA_BIT_MASK(32),
657                 .platform_data  = &rk29xx_spi1_platdata,
658         },
659 };
660 #endif
661
662 static void __init rk30_init_spim(void)
663 {
664 #ifdef CONFIG_SPIM0_RK29
665         platform_device_register(&rk29xx_device_spi0m);
666 #endif
667 #ifdef CONFIG_SPIM1_RK29
668         platform_device_register(&rk29xx_device_spi1m);
669 #endif
670 }
671
672
673 #ifdef CONFIG_MTD_NAND_RK29XX
674 static struct resource resources_nand[] = {
675         {
676                 .start  = RK30_NANDC_PHYS,
677                 .end    = RK30_NANDC_PHYS + RK30_NANDC_SIZE - 1,
678                 .flags  = IORESOURCE_MEM,
679         }
680 };
681
682 static struct platform_device device_nand = {
683         .name           = "rk30xxnand",
684         .id             = -1,
685         .resource       = resources_nand,
686         .num_resources  = ARRAY_SIZE(resources_nand),
687 };
688 #endif
689
690 #ifdef CONFIG_KEYS_RK29
691 extern struct rk29_keys_platform_data rk29_keys_pdata;
692 static struct platform_device device_keys = {
693         .name           = "rk29-keypad",
694         .id             = -1,
695         .dev            = {
696                 .platform_data  = &rk29_keys_pdata,
697         },
698 };
699 #endif
700
701 static int __init rk30_init_devices(void)
702 {
703         rk30_init_dma();
704         rk30_init_uart();
705         rk30_init_i2c();
706         rk30_init_spim();       
707 #ifdef CONFIG_MTD_NAND_RK29XX
708         platform_device_register(&device_nand);
709 #endif
710 #ifdef CONFIG_KEYS_RK29
711         platform_device_register(&device_keys);
712 #endif
713         return 0;
714 }
715 arch_initcall(rk30_init_devices);