添加tca6424的代码,需要注意的是由于此芯片中断响应必须在I2C的读完成之后操作SDA和SCL脚,在i2c-rk2818.c中添加了一个函数。如果有影响其他器件的工作...
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2818 / board-infosdk.c
1 /* linux/arch/arm/mach-rk2818/board-phonesdk.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/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
20 #include <linux/io.h>
21 #include <linux/delay.h>
22 #include <linux/i2c.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mmc/host.h>
25
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
31
32 #include <mach/irqs.h>
33 #include <mach/board.h>
34 #include <mach/rk2818_iomap.h>
35 #include <mach/iomux.h>
36 #include <mach/gpio.h>
37 #include <mach/rk2818_nand.h>
38
39 #include <linux/mtd/nand.h>
40 #include <linux/mtd/partitions.h>
41 #include <linux/dm9000.h>
42
43 #include "devices.h"
44
45 #include "../../../drivers/spi/rk2818_spim.h"
46 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
47 #include "../../../drivers/staging/android/timed_gpio.h"
48 #include "../../../sound/soc/codecs/wm8994.h"
49
50 /* --------------------------------------------------------------------
51  *  ÉùÃ÷ÁËrk2818_gpioBankÊý×飬²¢¶¨ÒåÁËGPIO¼Ä´æÆ÷×éIDºÍ¼Ä´æÆ÷»ùµØÖ·¡£
52  * -------------------------------------------------------------------- */
53
54 static struct rk2818_gpio_bank rk2818_gpioBank[] = {
55                 {
56                 .id             = RK2818_ID_PIOA,
57                 .offset         = RK2818_GPIO0_BASE,
58                 .clock          = NULL,
59         }, 
60                 {
61                 .id             = RK2818_ID_PIOB,
62                 .offset         = RK2818_GPIO0_BASE,
63                 .clock          = NULL,
64         }, 
65                 {
66                 .id             = RK2818_ID_PIOC,
67                 .offset         = RK2818_GPIO0_BASE,
68                 .clock          = NULL,
69         }, 
70                 {
71                 .id             = RK2818_ID_PIOD,
72                 .offset         = RK2818_GPIO0_BASE,
73                 .clock          = NULL,
74         },
75                 {
76                 .id             = RK2818_ID_PIOE,
77                 .offset         = RK2818_GPIO1_BASE,
78                 .clock          = NULL,
79         },
80                 {
81                 .id             = RK2818_ID_PIOF,
82                 .offset         = RK2818_GPIO1_BASE,
83                 .clock          = NULL,
84         },
85                 {
86                 .id             = RK2818_ID_PIOG,
87                 .offset         = RK2818_GPIO1_BASE,
88                 .clock          = NULL,
89         },
90                 {
91                 .id             = RK2818_ID_PIOH,
92                 .offset         = RK2818_GPIO1_BASE,
93                 .clock          = NULL,
94         }
95 };
96
97 //IOÓ³É䷽ʽÃèÊö £¬Ã¿¸öΪһ¶ÎÏßÐÔÁ¬ÐøÓ³Éä
98 static struct map_desc rk2818_io_desc[] __initdata = {
99
100         {
101                 .virtual        = RK2818_MCDMA_BASE,                                    //ÐéÄâµØÖ·
102                 .pfn            = __phys_to_pfn(RK2818_MCDMA_PHYS),    //ÎïÀíµØÖ·£¬ÐëÓëÒ³±í¶ÔÆë
103                 .length         = RK2818_MCDMA_SIZE,                                                    //³¤¶È
104                 .type           = MT_DEVICE                                                     //Ó³É䷽ʽ
105         },
106         
107         {
108                 .virtual        = RK2818_DWDMA_BASE,                                    
109                 .pfn            = __phys_to_pfn(RK2818_DWDMA_PHYS),    
110                 .length         = RK2818_DWDMA_SIZE,                                            
111                 .type           = MT_DEVICE                                                     
112         },
113         
114         {
115                 .virtual        = RK2818_INTC_BASE,                                     
116                 .pfn            = __phys_to_pfn(RK2818_INTC_PHYS),   
117                 .length         = RK2818_INTC_SIZE,                                     
118                 .type           = MT_DEVICE                                             
119         },
120
121         {
122                 .virtual        = RK2818_NANDC_BASE,                            
123                 .pfn            = __phys_to_pfn(RK2818_NANDC_PHYS),      
124                 .length         = RK2818_NANDC_SIZE,                            
125                 .type           = MT_DEVICE                                     
126         },
127
128         {
129                 .virtual        = RK2818_SDRAMC_BASE,
130                 .pfn            = __phys_to_pfn(RK2818_SDRAMC_PHYS),
131                 .length         = RK2818_SDRAMC_SIZE,
132                 .type           = MT_DEVICE
133         },
134
135         {
136                 .virtual        = RK2818_ARMDARBITER_BASE,                                      
137                 .pfn            = __phys_to_pfn(RK2818_ARMDARBITER_PHYS),    
138                 .length         = RK2818_ARMDARBITER_SIZE,                                              
139                 .type           = MT_DEVICE                                                     
140         },
141         
142         {
143                 .virtual        = RK2818_APB_BASE,
144                 .pfn            = __phys_to_pfn(RK2818_APB_PHYS),
145                 .length         = 0xa0000,                     
146                 .type           = MT_DEVICE
147         },
148         
149         {
150                 .virtual        = RK2818_WDT_BASE,
151                 .pfn            = __phys_to_pfn(RK2818_WDT_PHYS),
152                 .length         = 0xa0000,                      ///apb bus i2s i2c spi no map in this
153                 .type           = MT_DEVICE
154         },
155 };
156 /*****************************************************************************************
157  * SDMMC devices
158  *author: kfx
159 *****************************************************************************************/
160 static int rk2818_sdmmc0_io_init(void)
161 {
162         rk2818_mux_api_set(GPIOF3_APWM1_MMC0DETN_NAME, IOMUXA_SDMMC1_DETECT_N);
163         rk2818_mux_api_set(GPIOH_MMC0D_SEL_NAME, IOMUXA_SDMMC0_DATA123);
164         rk2818_mux_api_set(GPIOH_MMC0_SEL_NAME, IOMUXA_SDMMC0_CMD_DATA0_CLKOUT);
165     return 0;
166 }
167
168 static int rk2818_sdmmc1_io_init(void)
169 {
170         rk2818_mux_api_set(GPIOG_MMC1_SEL_NAME, IOMUXA_SDMMC1_CMD_DATA0_CLKOUT);
171         rk2818_mux_api_set(GPIOG_MMC1D_SEL_NAME, IOMUXA_SDMMC1_DATA123);
172
173     return 0;
174 }
175 #define CONFIG_SDMMC0_USE_DMA
176 #define CONFIG_SDMMC1_USE_DMA
177 struct rk2818_sdmmc_platform_data default_sdmmc0_data = {
178         .host_ocr_avail = (MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
179                                            MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33| 
180                                            MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
181         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
182         .io_init = rk2818_sdmmc0_io_init,
183         .no_detect = 0,
184         .dma_name = "sd_mmc",
185 #ifdef CONFIG_SDMMC0_USE_DMA
186         .use_dma  = 1,
187 #else
188         .use_dma = 0,
189 #endif
190 };
191 struct rk2818_sdmmc_platform_data default_sdmmc1_data = {
192         .host_ocr_avail = (MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
193                                            MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
194                                            MMC_VDD_32_33|MMC_VDD_33_34),
195         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
196                                    MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
197         .io_init = rk2818_sdmmc1_io_init,
198         .no_detect = 1,
199         .dma_name = "sdio",
200 #ifdef CONFIG_SDMMC1_USE_DMA
201         .use_dma  = 1,
202 #else
203         .use_dma = 0,
204 #endif
205 };
206
207 /*****************************************************************************************
208  * extern gpio devices
209  *author: xxx
210  *****************************************************************************************/
211 #if defined (CONFIG_GPIO_PCA9554)
212 struct rk2818_gpio_expander_info  extern_gpio_settinginfo[] = {
213         {
214                 .gpio_num               =RK2818_PIN_PI0,
215                 .pin_type           = GPIO_IN,
216                 //.pin_value                    =GPIO_HIGH,
217          },
218
219         {
220                 .gpio_num               =RK2818_PIN_PI4,// tp3
221                 .pin_type           = GPIO_IN,
222                 //.pin_value                    =GPIO_HIGH,
223          },
224          
225          {
226                 .gpio_num               =RK2818_PIN_PI5,//tp4
227                 .pin_type           = GPIO_IN,
228                 //.pin_value                    =GPIO_HIGH,
229          },
230          {
231                 .gpio_num               =RK2818_PIN_PI6,//tp2
232                 .pin_type           = GPIO_OUT,
233                 //.pin_value                    =GPIO_HIGH,
234          },
235          {
236                 .gpio_num               =RK2818_PIN_PI7,//tp1
237                 .pin_type           = GPIO_OUT,
238                 .pin_value                      =GPIO_HIGH,
239          },
240
241
242                 
243 };
244
245 struct pca9554_platform_data rk2818_pca9554_data={
246         .gpio_base=GPIOS_EXPANDER_BASE,
247         .gpio_pin_num=CONFIG_EXPANDED_GPIO_NUM,
248         .gpio_irq_start=NR_AIC_IRQS + 2*NUM_GROUP,
249         .irq_pin_num=CONFIG_EXPANDED_GPIO_IRQ_NUM,
250         .pca9954_irq_pin=RK2818_PIN_PE2,
251         .settinginfo=extern_gpio_settinginfo,
252         .settinginfolen=ARRAY_SIZE(extern_gpio_settinginfo),
253         .names="pca9554",
254 };
255 #endif
256
257 #if defined (CONFIG_IOEXTEND_TCA6424)
258 struct rk2818_gpio_expander_info  extgpio_tca6424_settinginfo[] = {
259
260         {
261                 .gpio_num               = TCA6424_P01,
262                 .pin_type           = GPIO_OUT,
263                 .pin_value              = GPIO_LOW,
264         },
265
266         {
267                 .gpio_num               = TCA6424_P02,// tp3
268                 .pin_type           = GPIO_OUT,
269                 .pin_value                      = GPIO_LOW,
270          },
271          {
272                 .gpio_num               = TCA6424_P03,
273                 .pin_type           = GPIO_OUT,
274                 .pin_value                      = GPIO_LOW,
275          },
276
277         {
278                 .gpio_num               = TCA6424_P04,// tp3
279                 .pin_type           = GPIO_OUT,
280                 .pin_value                      = GPIO_LOW,
281          },
282          {
283                 .gpio_num               = TCA6424_P05,
284                 .pin_type           = GPIO_OUT,
285                 .pin_value                      = GPIO_LOW,
286          }, 
287          {
288                 .gpio_num               = TCA6424_P12,
289                 .pin_type           = GPIO_IN,
290                 //.pin_value                    =GPIO_HIGH,
291          },
292
293         {
294                 .gpio_num               = TCA6424_P13,// tp3
295                 .pin_type           = GPIO_IN,
296                 //.pin_value                    =GPIO_HIGH,
297          },
298          {
299                 .gpio_num               = TCA6424_P14,
300                 .pin_type           = GPIO_IN,
301                 //.pin_value                    =GPIO_HIGH,
302          },
303
304          {
305                 .gpio_num               = TCA6424_P15,// tp3
306                 .pin_type           = GPIO_IN,
307                 //.pin_value                    =GPIO_HIGH,
308          },
309          
310 };
311
312 struct tca6424_platform_data rk2818_tca6424_data={
313         .gpio_base=GPIO_EXPANDER_BASE,
314         .gpio_pin_num=CONFIG_EXPANDED_GPIO_NUM,
315         .gpio_irq_start=NR_AIC_IRQS + 2*NUM_GROUP + CONFIG_SPI_FPGA_GPIO_IRQ_NUM,
316         .irq_pin_num=CONFIG_EXPANDED_GPIO_IRQ_NUM,
317         .tca6424_irq_pin=RK2818_PIN_PA1,
318         .settinginfo=extgpio_tca6424_settinginfo,
319         .settinginfolen=ARRAY_SIZE(extgpio_tca6424_settinginfo),
320         .names="extend_gpio_tca6424",
321 };
322 #endif
323
324
325
326 /*****************************************************************************************
327  * i2c devices
328  * author: kfx@rock-chips.com
329 *****************************************************************************************/
330 static void rk2818_i2c0_io_init(void)
331 {
332         rk2818_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
333 }
334
335 static void rk2818_i2c1_io_init(void)
336 {
337         rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1);
338 }
339 struct rk2818_i2c_platform_data default_i2c0_data = { 
340         .bus_num    = 0,
341         .flags      = 0,
342         .slave_addr = 0xff,
343         .scl_rate  = 400*1000,
344         .mode           = I2C_MODE_IRQ,
345         .io_init = rk2818_i2c0_io_init,
346 };
347 struct rk2818_i2c_platform_data default_i2c1_data = { 
348 #ifdef CONFIG_I2C0_RK2818
349         .bus_num    = 1,
350 #else
351         .bus_num        = 0,
352 #endif
353         .flags      = 0,
354         .slave_addr = 0xff,
355         .scl_rate  = 400*1000,
356         .mode           = I2C_MODE_IRQ,
357         .io_init = rk2818_i2c1_io_init,
358 };
359
360 struct rk2818_i2c_spi_data default_i2c2_data = { 
361         .bus_num    = 2,
362         .flags      = 0,
363         .slave_addr = 0xff,
364         .scl_rate  = 400*1000,
365         
366 };
367 struct rk2818_i2c_spi_data default_i2c3_data = { 
368
369         .bus_num    = 3,
370         .flags      = 0,
371         .slave_addr = 0xff,
372         .scl_rate  = 400*1000,
373         
374 };
375 static struct i2c_board_info __initdata board_i2c0_devices[] = {
376 #if defined (CONFIG_RK1000_CONTROL)
377         {
378                 .type                   = "rk1000_control",
379                 .addr           = 0x40,
380                 .flags                  = 0,
381         },
382 #endif
383
384 #if defined (CONFIG_RK1000_TVOUT)
385         {
386                 .type                   = "rk1000_tvout",
387                 .addr           = 0x42,
388                 .flags                  = 0,
389         },
390 #endif
391 #if defined (CONFIG_SND_SOC_RK1000)
392         {
393                 .type                   = "rk1000_i2c_codec",
394                 .addr           = 0x60,
395                 .flags                  = 0,
396         },
397 #endif
398 #if defined (CONFIG_SND_SOC_WM8988)
399         {
400                 .type                   = "wm8988",
401                 .addr           = 0x1a,
402                 .flags                  = 0,
403         }
404 #endif  
405 };
406 static struct i2c_board_info __initdata board_i2c1_devices[] = {
407 #if defined (CONFIG_RTC_HYM8563)
408         {
409                 .type                   = "rtc_hym8563",
410                 .addr           = 0x51,
411                 .flags                  = 0,
412         },
413 #endif
414 #if defined (CONFIG_FM_QN8006)
415         {
416                 .type                   = "fm_qn8006",
417                 .addr           = 0x2b, 
418                 .flags                  = 0,
419         },
420 #endif
421 #if defined (CONFIG_GPIO_PCA9554)
422         {
423                 .type                   = "extend_gpio_pca9554",
424                 .addr           = 0x3c, 
425                 .flags                  = 0,
426                 .platform_data=&rk2818_pca9554_data.gpio_base,
427         },
428 #endif
429 #if defined (CONFIG_IOEXTEND_TCA6424)
430         {
431                 .type                   = "extend_gpio_tca6424",
432                 .addr           = 0x23, 
433                 .flags                  = 0,
434                 .platform_data=&rk2818_tca6424_data.gpio_base,
435         },
436 #endif
437
438 #if defined (CONFIG_PMIC_LP8725)
439         {
440                 .type                   = "lp8725",
441                 .addr           = 0x79, 
442                 .flags                  = 0,
443         },
444 #endif
445 #if defined (CONFIG_GS_MMA7660)
446     {
447         .type           = "gs_mma7660",
448         .addr           = 0x4c,
449         .flags          = 0,
450         .irq            = GS_IRQ_PIN,
451                 .platform_data = &rk2818_gs_platdata,
452     },
453 #endif
454         {},
455 };
456
457 static struct i2c_board_info __initdata board_i2c2_devices[] = {
458
459 };
460 /*****************************************************************************************
461  * wm8994  codec
462  * author: cjq@rock-chips.com
463  *****************************************************************************************/
464 static struct wm8994_platform_data wm8994_data = {
465     .mic_input = 0,
466     .micBase_vcc = 0,
467     .bb_input = 0, 
468     .bb_output = 0,
469     .frequence = 0,
470     .enable_pin = 0,
471     .headset_pin = 0,
472     .headset_call_vol = 0,
473     .speaker_call_vol = 0,
474     .earpiece_call_vol = 0,
475     .bt_call_vol = 0,
476 };// must initialize 
477 static struct i2c_board_info __initdata board_i2c3_devices[] = {
478 #if defined (CONFIG_SND_SOC_WM8994)
479         {
480                 .type                   = "wm8994",
481                 .addr           = 0x1a,
482                 .flags                  = 0,
483                 .platform_data  = &wm8994_data,
484         },
485 #endif
486 };      
487
488 /*****************************************************************************************
489  * battery  devices
490  * author: lw@rock-chips.com
491  *****************************************************************************************/
492 #define CHARGEOK_PIN    RK2818_PIN_PB1
493 struct rk2818_battery_platform_data rk2818_battery_platdata = {
494         .charge_ok_pin = CHARGEOK_PIN,
495 };
496 /*****************************************************************************************
497  * serial devices
498  * author: lhh@rock-chips.com
499  *****************************************************************************************/
500 static int serial_io_init(void)
501 {
502         int ret;
503 #if 1   
504         //cz@rock-chips.com
505         //20100808 
506         //UART0µÄËĸö¹Ü½ÅÏÈIOMUX³ÉGPIO
507         //È»ºó·Ö±ðÉèÖÃÊäÈëÊä³ö/À­¸ßÀ­µÍ´¦Àí
508         //×îºóÔÙIOMUX³ÉUART
509         //·ÀÖ¹Ö±½ÓIOMUX³ÉUARTºóËĸö¹Ü½ÅµÄ״̬²»¶Ôʱ
510         //²Ù×÷UARTµ¼ÖÂUART_USR_BUSYʼÖÕΪ1Ôì³ÉÈçÏÂËÀÑ­»·
511         //while(rk2818_uart_read(port,UART_USR)&UART_USR_BUSY)
512         //UARTËĸö¹Ü½ÅÔÚδ´«ÊäʱÕý³£×´Ì¬Ó¦¸ÃΪ£º
513         //RX/TX£ºHIGH
514         //CTS/RTS£ºLOW
515         //×¢Ò⣺CTS/RTSΪµÍÓÐЧ£¬Ó²¼þÉϲ»Ó¦¸ÃÇ¿ÐÐ×öÉÏÀ­
516                 rk2818_mux_api_set(GPIOG1_UART0_MMC1WPT_NAME, IOMUXA_GPIO1_C1 /*IOMUXA_UART0_SOUT*/);  
517                 rk2818_mux_api_set(GPIOG0_UART0_MMC1DET_NAME, IOMUXA_GPIO1_C0 /*IOMUXA_UART0_SIN*/);
518                 
519                 ret = gpio_request(RK2818_PIN_PG0, NULL); 
520                 if(ret != 0)
521                 {
522                   gpio_free(RK2818_PIN_PG0);
523                 }
524                 gpio_direction_output(RK2818_PIN_PG0,GPIO_HIGH); 
525         
526                 
527                 ret = gpio_request(RK2818_PIN_PG1, NULL); 
528                 if(ret != 0)
529                 {
530                   gpio_free(RK2818_PIN_PG1);
531                 }
532                 gpio_direction_output(RK2818_PIN_PG1,GPIO_HIGH); 
533         
534                 gpio_pull_updown(RK2818_PIN_PG1,GPIOPullUp);
535                 gpio_pull_updown(RK2818_PIN_PG0,GPIOPullUp);
536         
537                 rk2818_mux_api_set(GPIOG1_UART0_MMC1WPT_NAME, IOMUXA_UART0_SOUT);  
538                 rk2818_mux_api_set(GPIOG0_UART0_MMC1DET_NAME, IOMUXA_UART0_SIN);
539         
540                 rk2818_mux_api_set(GPIOB2_U0CTSN_SEL_NAME, IOMUXB_GPIO0_B2/*IOMUXB_UART0_CTS_N*/);
541                 rk2818_mux_api_set(GPIOB3_U0RTSN_SEL_NAME, IOMUXB_GPIO0_B3/*IOMUXB_UART0_RTS_N*/);
542         
543                 ret = gpio_request(RK2818_PIN_PB2, NULL); 
544                 if(ret != 0)
545                 {
546                   gpio_free(RK2818_PIN_PB2);
547                 }
548                 gpio_direction_input(RK2818_PIN_PB2); 
549         //        gpio_direction_output(RK2818_PIN_PB2,GPIO_LOW); 
550                 
551                 ret = gpio_request(RK2818_PIN_PB3, NULL); 
552                 if(ret != 0)
553                 {
554                   gpio_free(RK2818_PIN_PB3);
555                 }
556                 gpio_direction_output(RK2818_PIN_PB3,GPIO_LOW); 
557 #endif
558
559         rk2818_mux_api_set(GPIOB2_U0CTSN_SEL_NAME, IOMUXB_UART0_CTS_N);
560         rk2818_mux_api_set(GPIOB3_U0RTSN_SEL_NAME, IOMUXB_UART0_RTS_N);
561
562         return 0;
563 }
564
565 struct rk2818_serial_platform_data rk2818_serial0_platdata = {
566         .io_init = serial_io_init,
567 };
568
569 /*****************************************************************************************
570  * i2s devices
571  * author: lhhrock-chips.com
572  *****************************************************************************************/
573 static int i2s_io_init(void)
574 {
575     /* Configure the I2S pins in correct mode */
576     rk2818_mux_api_set(CXGPIO_I2S_SEL_NAME,IOMUXB_I2S_INTERFACE);
577         return 0;
578 }
579
580 struct rk2818_i2s_platform_data rk2818_i2s_platdata = {
581         .io_init = i2s_io_init,
582 };
583 /*****************************************************************************************
584  * spi devices
585  * author: lhhrock-chips.com
586  *****************************************************************************************/
587 #define SPI_CHIPSELECT_NUM 3
588 static int spi_io_init(void)
589 {       
590         //cs0
591         rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME, IOMUXA_GPIO0_B4);
592         //cs1
593         rk2818_mux_api_set(GPIOB0_SPI0CSN1_MMC1PCA_NAME, IOMUXA_GPIO0_B0);
594         //clk
595         rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME, IOMUXA_SPI0);
596         //cs2
597         rk2818_mux_api_set(GPIOF5_APWM3_DPWM3_NAME,IOMUXB_GPIO1_B5);
598         
599         return 0;
600 }
601 static int spi_io_deinit(void)
602 {
603         rk2818_mux_api_mode_resume(GPIOB4_SPI0CS0_MMC0D4_NAME);
604         rk2818_mux_api_mode_resume(GPIOB0_SPI0CSN1_MMC1PCA_NAME);
605         rk2818_mux_api_mode_resume(GPIOB_SPI0_MMC0_NAME);       
606         rk2818_mux_api_mode_resume(GPIOF5_APWM3_DPWM3_NAME);
607         return 0;
608 }
609
610 struct spi_cs_gpio rk2818_spi_cs_gpios[SPI_CHIPSELECT_NUM] = {
611         {
612                 .name = "spi cs0",
613                 .cs_gpio = RK2818_PIN_PB4,
614         },
615         {
616                 .name = "spi cs1",
617                 .cs_gpio = RK2818_PIN_PB0,
618         },
619         {
620                 .name = "spi cs2",
621                 .cs_gpio = RK2818_PIN_PF5,
622         }
623 };
624
625 struct rk2818_spi_platform_data rk2818_spi_platdata = {
626         .num_chipselect = SPI_CHIPSELECT_NUM,//raho ´ó°åÐèÒªÖ§³Ö3¸öƬѡ dxj
627         .chipselect_gpios = rk2818_spi_cs_gpios,
628         .io_init = spi_io_init,
629         .io_deinit = spi_io_deinit,
630 };
631 /*****************************************************************************************
632  * xpt2046 touch panel
633  * author: dxjrock-chips.com
634  *****************************************************************************************/
635 #define XPT2046_GPIO_INT           RK2818_PIN_PE1
636 #define DEBOUNCE_REPTIME  3
637
638 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) 
639 static struct xpt2046_platform_data xpt2046_info = {
640         .model                  = 2046,
641         .keep_vref_on   = 1,
642         .swap_xy                = 0,
643         .x_min                  = 0,
644         .x_max                  = 320,
645         .y_min                  = 0,
646         .y_max                  = 480,
647         .debounce_max           = 7,
648         .debounce_rep           = DEBOUNCE_REPTIME,
649         .debounce_tol           = 20,
650         .gpio_pendown           = XPT2046_GPIO_INT,
651         .penirq_recheck_delay_usecs = 1,
652 };
653 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
654 static struct xpt2046_platform_data xpt2046_info = {
655         .model                  = 2046,
656         .keep_vref_on   = 1,
657         .swap_xy                = 0,
658         .x_min                  = 0,
659         .x_max                  = 320,
660         .y_min                  = 0,
661         .y_max                  = 480,
662         .debounce_max           = 7,
663         .debounce_rep           = DEBOUNCE_REPTIME,
664         .debounce_tol           = 20,
665         .gpio_pendown           = XPT2046_GPIO_INT,
666         .penirq_recheck_delay_usecs = 1,
667 };
668 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) 
669 static struct xpt2046_platform_data xpt2046_info = {
670         .model                  = 2046,
671         .keep_vref_on   = 1,
672         .swap_xy                = 1,
673         .x_min                  = 0,
674         .x_max                  = 800,
675         .y_min                  = 0,
676         .y_max                  = 480,
677         .debounce_max           = 7,
678         .debounce_rep           = DEBOUNCE_REPTIME,
679         .debounce_tol           = 20,
680 #if defined(CONFIG_MACH_RAHO)   
681     .gpio_pendown               = RK2818_PIN_PE1,
682 #else
683         .gpio_pendown           = RK2818_PIN_PE3,
684 #endif  
685         .penirq_recheck_delay_usecs = 1,
686 };
687 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
688 static struct xpt2046_platform_data xpt2046_info = {
689         .model                  = 2046,
690         .keep_vref_on   = 1,
691         .swap_xy                = 1,
692         .x_min                  = 0,
693         .x_max                  = 800,
694         .y_min                  = 0,
695         .y_max                  = 480,
696         .debounce_max           = 7,
697         .debounce_rep           = DEBOUNCE_REPTIME,
698         .debounce_tol           = 20,
699 #if defined(CONFIG_MACH_RAHO)   
700     .gpio_pendown               = RK2818_PIN_PE1,
701 #else
702         .gpio_pendown           = RK2818_PIN_PE3,
703 #endif  
704         .penirq_recheck_delay_usecs = 1,
705 };
706 #endif
707 static struct spi_board_info board_spi_devices[] = {
708 #if defined(CONFIG_SPI_FPGA)
709         {       /* fpga ice65l08xx */
710                 .modalias       = "spi_fpga",
711                 .chip_select    = 1,
712                 .max_speed_hz   = 8 * 1000 * 1000,
713                 .bus_num        = 0,
714                 .mode   = SPI_MODE_0,
715         },
716 #endif
717 #if defined(CONFIG_ENC28J60)    
718         {       /* net chip */
719                 .modalias       = "enc28j60",
720                 .chip_select    = 1,
721                 .max_speed_hz   = 12 * 1000 * 1000,
722                 .bus_num        = 0,
723                 .mode   = SPI_MODE_0,
724         },
725 #endif  
726 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
727     ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
728         {
729                 .modalias       = "xpt2046_ts",
730                 .chip_select    = 0,
731                 .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
732                 .bus_num        = 0,
733                 .irq = XPT2046_GPIO_INT,
734                 .platform_data = &xpt2046_info,
735         },
736 #endif
737 }; 
738
739 /*rk2818_fb gpio information*/
740 static struct rk2818_fb_gpio rk2818_fb_gpio_info = {
741     .display_on = (GPIO_LOW<<16)|RK2818_PIN_PB1,
742     .lcd_standby = 0,
743     .mcu_fmk_pin = 0,
744 };
745
746 /*rk2818_fb iomux information*/
747 static struct rk2818_fb_iomux rk2818_fb_iomux_info = {
748     .data16     = GPIOC_LCDC16BIT_SEL_NAME,
749     .data18     = GPIOC_LCDC18BIT_SEL_NAME,
750     .data24     = GPIOC_LCDC24BIT_SEL_NAME,
751     .den        = CXGPIO_LCDDEN_SEL_NAME,
752     .vsync      = CXGPIO_LCDVSYNC_SEL_NAME,
753     .mcu_fmk    = 0,
754 };
755 /*rk2818_fb*/
756 struct rk2818_fb_mach_info rk2818_fb_mach_info = {
757     .gpio = &rk2818_fb_gpio_info,
758     .iomux = &rk2818_fb_iomux_info,
759 };
760
761 /*****************************************************************************************
762  * backlight  devices
763  * author: nzy@rock-chips.com
764  *****************************************************************************************/
765  /*
766  GPIOF2_APWM0_SEL_NAME,       IOMUXB_PWM0
767  GPIOF3_APWM1_MMC0DETN_NAME,  IOMUXA_PWM1
768  GPIOF4_APWM2_MMC0WPT_NAME,   IOMUXA_PWM2
769  GPIOF5_APWM3_DPWM3_NAME,     IOMUXB_PWM3
770  */
771  
772 #define PWM_ID            0  
773 #define PWM_MUX_NAME      GPIOF2_APWM0_SEL_NAME
774 #define PWM_MUX_MODE      IOMUXB_PWM0
775 #define PWM_EFFECT_VALUE  0
776
777
778 #define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
779 #define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
780
781 #define BL_EN_PIN         RK2818_PIN_PF3
782 #define BL_EN_VALUE       GPIO_HIGH
783
784
785
786 static int rk2818_backlight_io_init(void)
787 {
788     int ret = 0;
789     
790     rk2818_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
791
792     rk2818_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE); 
793
794     ret = gpio_request(BL_EN_PIN, NULL); 
795     if(ret != 0)
796     {
797         gpio_free(BL_EN_PIN);
798         printk(KERN_ERR ">>>>>> lcd_cs gpio_request err \n ");        
799     }
800     
801     gpio_direction_output(BL_EN_PIN, 0);
802     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
803
804     return ret;
805 }
806
807 static int rk2818_backlight_io_deinit(void)
808 {
809     int ret = 0;
810     
811     gpio_free(BL_EN_PIN);
812     
813     rk2818_mux_api_mode_resume(PWM_MUX_NAME);
814
815     rk2818_mux_api_mode_resume(BL_EN_MUX_NAME);
816
817     return ret;
818 }
819 struct rk2818_bl_info rk2818_bl_info = {
820     .pwm_id   = PWM_ID,
821     .bl_ref   = PWM_EFFECT_VALUE,
822     .io_init   = rk2818_backlight_io_init,
823     .io_deinit = rk2818_backlight_io_deinit, 
824 };
825
826 /********************************************************
827 *                               dm9000 net work devices
828 *                               author:lyx
829 ********************************************************/
830 #ifdef CONFIG_DM9000
831 /*
832 GPIOA5_FLASHCS1_SEL_NAME     IOMUXB_FLASH_CS1
833 GPIOA6_FLASHCS2_SEL_NAME     IOMUXB_FLASH_CS2
834 GPIOA7_FLASHCS3_SEL_NAME     IOMUXB_FLASH_CS3
835 GPIOE_SPI1_FLASH_SEL1_NAME   IOMUXA_FLASH_CS45
836 GPIOE_SPI1_FLASH_SEL_NAME    IOMUXA_FLASH_CS67
837 */
838 #define DM9000_USE_NAND_CS 1     //cs can be 1,2,3,4,5,6 or 7
839 #define DM9000_CS_IOMUX_NAME GPIOA5_FLASHCS1_SEL_NAME
840 #define DM9000_CS_IOMUX_MODE IOMUXB_FLASH_CS1
841 #define DM9000_NET_INT_PIN RK2818_PIN_PA3
842 #define DM9000_INT_IOMUX_NAME GPIOA23_UART2_SEL_NAME
843 #define DM9000_INT_IOMUX_MODE IOMUXB_GPIO0_A23
844 #define DM9000_INT_INIT_VALUE GPIOPullDown
845 #define DM9000_IRQ IRQF_TRIGGER_HIGH
846 #define DM9000_IO_ADDR (RK2818_NANDC_PHYS + 0x800 + DM9000_USE_NAND_CS*0x100 + 0x8)
847 #define DM9000_DATA_ADDR (RK2818_NANDC_PHYS + 0x800 + DM9000_USE_NAND_CS*0x100 + 0x4)
848
849 static int dm9k_gpio_set(void)
850 {
851         //cs
852         rk2818_mux_api_set(DM9000_CS_IOMUX_NAME, DM9000_CS_IOMUX_MODE);
853         //int
854         rk2818_mux_api_set(DM9000_INT_IOMUX_NAME, DM9000_INT_IOMUX_MODE);
855                 
856         return 0;
857 }
858 static int dm9k_gpio_free(void)
859 {
860         rk2818_mux_api_mode_resume(DM9000_INT_IOMUX_NAME);
861         rk2818_mux_api_mode_resume(DM9000_CS_IOMUX_NAME);
862         return 0;
863 }
864
865 static struct resource dm9k_resource[] = {
866         [0] = {
867                 .start = DM9000_IO_ADDR,    
868                 .end   = DM9000_IO_ADDR + 3,
869                 .flags = IORESOURCE_MEM,
870         },
871         [1] = {
872                 .start = DM9000_DATA_ADDR,      
873                 .end   = DM9000_DATA_ADDR + 3,
874                 .flags = IORESOURCE_MEM,
875         },
876         [2] = {
877                 .start = DM9000_NET_INT_PIN,
878                 .end   = DM9000_NET_INT_PIN,
879                 .flags = IORESOURCE_IRQ | DM9000_IRQ,
880         }
881
882 };
883
884 /* for the moment we limit ourselves to 8bit IO until some
885  * better IO routines can be written and tested
886 */
887 struct dm9000_plat_data dm9k_platdata = {       
888         .flags = DM9000_PLATF_8BITONLY,
889         .irq_pin = DM9000_NET_INT_PIN,
890         .irq_pin_value = DM9000_INT_INIT_VALUE,
891         .io_init = dm9k_gpio_set,
892         .io_deinit = dm9k_gpio_free,
893 };
894
895 struct platform_device rk2818_device_dm9k = {
896         .name           = "dm9000",
897         .id             = 0,
898         .num_resources  = ARRAY_SIZE(dm9k_resource),
899         .resource       = dm9k_resource,
900         .dev            = {
901                 .platform_data = &dm9k_platdata,
902         }
903 };
904 #endif
905
906
907 /*****************************************************************************************
908  * nand flash devices
909  * author: hxy@rock-chips.com
910  *****************************************************************************************/
911 /*
912 GPIOA5_FLASHCS1_SEL_NAME,   IOMUXB_FLASH_CS1
913 GPIOA6_FLASHCS2_SEL_NAME,   IOMUXB_FLASH_CS2
914 GPIOA7_FLASHCS3_SEL_NAME,   IOMUXB_FLASH_CS3
915 GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45  
916 GPIOE_SPI1_FLASH_SEL_NAME,  IOMUXA_FLASH_CS67  
917 */
918
919 #define NAND_CS_MAX_NUM     1  /*form 0 to 8, it is 0 when no nand flash */
920
921 int rk2818_nand_io_init(void)
922 {
923 #if (NAND_CS_MAX_NUM == 2)
924     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
925 #elif (NAND_CS_MAX_NUM == 3)
926     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
927     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
928 #elif (NAND_CS_MAX_NUM == 4)
929     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
930     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
931     rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
932 #elif ((NAND_CS_MAX_NUM == 5) || (NAND_CS_MAX_NUM == 6))
933     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
934     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
935     rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
936     rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45);  
937 #elif ((NAND_CS_MAX_NUM == 7) || (NAND_CS_MAX_NUM == 8))
938     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
939     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
940     rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
941     rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45);  
942     rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL_NAME, IOMUXA_FLASH_CS67);  
943 #endif
944     return 0;
945 }
946
947 struct rk2818_nand_platform_data rk2818_nand_data = {
948     .width      = 1,     /* data bus width in bytes */
949     .hw_ecc     = 1,     /* hw ecc 0: soft ecc */
950     .num_flash    = 1,
951     .io_init   = rk2818_nand_io_init,
952 };
953
954
955 /*****************************************/
956
957 static struct platform_device *devices[] __initdata = {
958         &rk2818_device_uart1,
959 #ifdef CONFIG_I2C0_RK2818
960         &rk2818_device_i2c0,
961 #endif
962 #ifdef CONFIG_I2C1_RK2818
963         &rk2818_device_i2c1,
964 #endif
965 #ifdef CONFIG_SDMMC0_RK2818     
966         &rk2818_device_sdmmc0,
967 #endif
968 #ifdef CONFIG_SDMMC1_RK2818
969         &rk2818_device_sdmmc1,
970 #endif
971         &rk2818_device_spim,
972         &rk2818_device_i2s,
973 #if defined(CONFIG_ANDROID_PMEM)
974         &rk2818_device_pmem,
975         &rk2818_device_pmem_dsp,
976 #endif
977         &rk2818_device_adc,
978         &rk2818_device_adckey,
979         &rk2818_device_battery,
980     &rk2818_device_fb,    
981     &rk2818_device_backlight,
982         &rk2818_device_dsp,
983 #ifdef CONFIG_MTD_NAND_RK2818
984         &rk2818_nand_device,
985 #endif
986 #ifdef CONFIG_DM9000
987         &rk2818_device_dm9k,
988 #endif
989
990 #ifdef CONFIG_DWC_OTG
991         &rk2818_device_dwc_otg,
992 #endif
993 #ifdef CONFIG_RK2818_HOST11
994         &rk2818_device_host11,
995 #endif
996 #ifdef CONFIG_USB_ANDROID
997         &android_usb_device,
998         &usb_mass_storage_device,
999 #endif
1000
1001 };
1002
1003 extern struct sys_timer rk2818_timer;
1004 #define POWER_PIN       RK2818_PIN_PH7
1005 static void rk2818_power_on(void)
1006 {
1007         int ret;
1008         ret = gpio_request(POWER_PIN, NULL);
1009         if (ret) {
1010                 printk("failed to request power_off gpio\n");
1011                 goto err_free_gpio;
1012         }
1013
1014         gpio_pull_updown(POWER_PIN, GPIOPullUp);
1015         ret = gpio_direction_output(POWER_PIN, GPIO_HIGH);
1016         if (ret) {
1017                 printk("failed to set power_off gpio output\n");
1018                 goto err_free_gpio;
1019         }
1020
1021         gpio_set_value(POWER_PIN, 1);/*power on*/
1022         
1023 err_free_gpio:
1024         gpio_free(POWER_PIN);
1025 }
1026
1027 static void rk2818_power_off(void)
1028 {
1029         printk("shut down system now ...\n");
1030         gpio_set_value(POWER_PIN, 0);/*power down*/
1031 }
1032
1033 void lcd_set_iomux(u8 enable)
1034 {
1035     int ret=-1;
1036     
1037     if(enable)
1038     {
1039         rk2818_mux_api_set(CXGPIO_HSADC_SEL_NAME, 0);
1040         ret = gpio_request(RK2818_PIN_PA4, NULL); 
1041         if(0)//(ret != 0)
1042         {
1043             gpio_free(RK2818_PIN_PA4);
1044             printk(">>>>>> lcd cs gpio_request err \n ");           
1045             goto pin_err;
1046         }  
1047         
1048         rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, 0);    
1049
1050         ret = gpio_request(RK2818_PIN_PE7, NULL); 
1051         if(0)//(ret != 0)
1052         {
1053             gpio_free(RK2818_PIN_PE7);
1054             printk(">>>>>> lcd clk gpio_request err \n "); 
1055             goto pin_err;
1056         }  
1057         
1058         ret = gpio_request(RK2818_PIN_PE6, NULL); 
1059         if(0)//(ret != 0)
1060         {
1061             gpio_free(RK2818_PIN_PE6);
1062             printk(">>>>>> lcd txd gpio_request err \n "); 
1063             goto pin_err;
1064         }        
1065     }
1066     else
1067     {
1068          gpio_free(RK2818_PIN_PA4); 
1069          //rk2818_mux_api_set(CXGPIO_HSADC_SEL_NAME, 1);
1070          rk2818_mux_api_mode_resume(CXGPIO_HSADC_SEL_NAME);
1071
1072          gpio_free(RK2818_PIN_PE7);   
1073          gpio_free(RK2818_PIN_PE6); 
1074          //rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, 2);
1075          rk2818_mux_api_mode_resume(GPIOE_U1IR_I2C1_NAME);
1076     }
1077     return ;
1078 pin_err:
1079     return ;
1080
1081 }
1082
1083 struct lcd_td043mgea1_data lcd_td043mgea1 = {
1084     .pin_txd    = RK2818_PIN_PE6,
1085     .pin_clk    = RK2818_PIN_PE7,
1086     .pin_cs     = RK2818_PIN_PA4,
1087     .screen_set_iomux = lcd_set_iomux,
1088 };
1089
1090 //      adc      ---> key       
1091 #define PLAY_ON_PIN RK2818_PIN_PE1
1092 #define PLAY_ON_LEVEL 1
1093 static  ADC_keyst gAdcValueTab[] = 
1094 {
1095         {95,  AD2KEY1},///VOLUME_DOWN
1096         {249, AD2KEY2},///VOLUME_UP
1097         {408, AD2KEY3},///MENU
1098         {560, AD2KEY4},///HOME
1099         {725, AD2KEY5},///BACK
1100         {816, AD2KEY6},///CALL
1101         {0,0}
1102 };
1103
1104 static unsigned char gInitKeyCode[] = 
1105 {
1106         AD2KEY1,AD2KEY2,AD2KEY3,AD2KEY4,AD2KEY5,AD2KEY6,
1107         ENDCALL,KEYSTART,KEY_WAKEUP,
1108 };
1109
1110 struct adc_key_data rk2818_adc_key = {
1111     .pin_playon     = PLAY_ON_PIN,
1112     .playon_level   = PLAY_ON_LEVEL,
1113     .adc_empty      = 900,
1114     .adc_invalid    = 20,
1115     .adc_drift      = 50,
1116     .adc_chn        = 1,
1117     .adc_key_table  = gAdcValueTab,
1118     .initKeyCode    = gInitKeyCode,
1119     .adc_key_cnt    = 7,
1120 };
1121 struct rk2818_adckey_platform_data rk2818_adckey_platdata = {
1122         .adc_key = &rk2818_adc_key,
1123 };
1124 #if CONFIG_ANDROID_TIMED_GPIO
1125 struct timed_gpio_platform_data rk28_vibrator_info = {
1126         .num_gpios = 0,
1127 };
1128 #endif
1129
1130 static void __init machine_rk2818_init_irq(void)
1131 {
1132         rk2818_init_irq();
1133         rk2818_gpio_init(rk2818_gpioBank, 8);
1134         rk2818_gpio_irq_setup();
1135 }
1136
1137 static void __init machine_rk2818_board_init(void)
1138 {       
1139         rk2818_power_on();
1140         pm_power_off = rk2818_power_off;
1141 #ifdef CONFIG_I2C0_RK2818
1142         i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1143                         ARRAY_SIZE(board_i2c0_devices));
1144 #endif
1145 #ifdef CONFIG_I2C1_RK2818
1146         i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1147                         ARRAY_SIZE(board_i2c1_devices));
1148 #endif
1149 #ifdef CONFIG_SPI_I2C
1150         i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1151                         ARRAY_SIZE(board_i2c2_devices));
1152         i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1153                         ARRAY_SIZE(board_i2c3_devices));
1154 #endif
1155         platform_add_devices(devices, ARRAY_SIZE(devices));     
1156         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1157         //rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME,IOMUXA_GPIO0_B4); //IOMUXA_SPI0_CSN0);//use for gpio SPI CS0
1158         //rk2818_mux_api_set(GPIOB0_SPI0CSN1_MMC1PCA_NAME,IOMUXA_GPIO0_B0); //IOMUXA_SPI0_CSN1);//use for gpio SPI CS1
1159         //rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME,IOMUXA_SPI0);//use for SPI CLK SDI SDO
1160 }
1161
1162 static void __init machine_rk2818_mapio(void)
1163 {
1164         iotable_init(rk2818_io_desc, ARRAY_SIZE(rk2818_io_desc));
1165         rk2818_clock_init();
1166         rk2818_iomux_init();    
1167 }
1168
1169 MACHINE_START(RK2818, "RK28board")
1170
1171 /* UART for LL DEBUG */
1172         .phys_io        = 0x18002000,
1173         .io_pg_offst    = ((0xFF100000) >> 18) & 0xfffc,
1174         .boot_params    = RK2818_SDRAM_PHYS + 0x88000,
1175         .map_io         = machine_rk2818_mapio,
1176         .init_irq       = machine_rk2818_init_irq,
1177         .init_machine   = machine_rk2818_board_init,
1178         .timer          = &rk2818_timer,
1179 MACHINE_END
1180