2155190642eda29c39ca1099587db1d8e08d8c2e
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2818 / board-raho-0928.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 #include <linux/circ_buf.h>
26 #include <linux/miscdevice.h>
27 #include <linux/usb/android_composite.h>
28
29 #include <mach/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/flash.h>
34
35 #include <mach/irqs.h>
36 #include <mach/board.h>
37 #include <mach/rk2818_iomap.h>
38 #include <mach/iomux.h>
39 #include <mach/gpio.h>
40 #include <mach/spi_fpga.h>
41 #include <mach/rk2818_camera.h>                          /* ddl@rock-chips.com : camera support */
42 #include <linux/pda_power.h>
43 #include <linux/regulator/charge-regulator.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/usb/gpio_vbus.h>
46 #include <mach/rk2818_nand.h>
47
48 #include <linux/mtd/nand.h>
49 #include <linux/mtd/partitions.h>
50 #include <linux/dm9000.h>
51 #include <linux/capella_cm3602.h>
52
53 #include <media/soc_camera.h>                               /* ddl@rock-chips.com : camera support */
54
55
56 #include "devices.h"
57
58 #include "../../../drivers/spi/rk2818_spim.h"
59 #include <linux/regulator/rk2818_lp8725.h>
60 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
61 #include "../../../drivers/staging/android/timed_gpio.h"
62 #include "../../../sound/soc/codecs/wm8994.h"
63 #include "../../../drivers/headset_observe/rk2818_headset.h"
64 #include <mach/rk2818-socpm.h>
65 #include <asm/tcm.h>
66
67 #include "../../../drivers/cmmb/siano/smsspiphy.h"
68 /* --------------------------------------------------------------------
69  *  ÉùÃ÷ÁËrk2818_gpioBankÊý×飬²¢¶¨ÒåÁËGPIO¼Ä´æÆ÷×éIDºÍ¼Ä´æÆ÷»ùµØÖ·¡£
70  * -------------------------------------------------------------------- */
71
72 static struct rk2818_gpio_bank rk2818_gpioBank[] = {
73                 {
74                 .id             = RK2818_ID_PIOA,
75                 .offset         = RK2818_GPIO0_BASE,
76                 .clock          = NULL,
77         }, 
78                 {
79                 .id             = RK2818_ID_PIOB,
80                 .offset         = RK2818_GPIO0_BASE,
81                 .clock          = NULL,
82         }, 
83                 {
84                 .id             = RK2818_ID_PIOC,
85                 .offset         = RK2818_GPIO0_BASE,
86                 .clock          = NULL,
87         }, 
88                 {
89                 .id             = RK2818_ID_PIOD,
90                 .offset         = RK2818_GPIO0_BASE,
91                 .clock          = NULL,
92         },
93                 {
94                 .id             = RK2818_ID_PIOE,
95                 .offset         = RK2818_GPIO1_BASE,
96                 .clock          = NULL,
97         },
98                 {
99                 .id             = RK2818_ID_PIOF,
100                 .offset         = RK2818_GPIO1_BASE,
101                 .clock          = NULL,
102         },
103                 {
104                 .id             = RK2818_ID_PIOG,
105                 .offset         = RK2818_GPIO1_BASE,
106                 .clock          = NULL,
107         },
108                 {
109                 .id             = RK2818_ID_PIOH,
110                 .offset         = RK2818_GPIO1_BASE,
111                 .clock          = NULL,
112         }
113 };
114
115 //IOÓ³É䷽ʽÃèÊö £¬Ã¿¸öΪһ¶ÎÏßÐÔÁ¬ÐøÓ³Éä
116 static struct map_desc rk2818_io_desc[] __initdata = {
117
118         {
119                 .virtual        = RK2818_MCDMA_BASE,                                    //ÐéÄâµØÖ·
120                 .pfn            = __phys_to_pfn(RK2818_MCDMA_PHYS),    //ÎïÀíµØÖ·£¬ÐëÓëÒ³±í¶ÔÆë
121                 .length         = RK2818_MCDMA_SIZE,                                                    //³¤¶È
122                 .type           = MT_DEVICE                                                     //Ó³É䷽ʽ
123         },
124         
125         {
126                 .virtual        = RK2818_DWDMA_BASE,                                    
127                 .pfn            = __phys_to_pfn(RK2818_DWDMA_PHYS),    
128                 .length         = RK2818_DWDMA_SIZE,                                            
129                 .type           = MT_DEVICE                                                     
130         },
131         
132         {
133                 .virtual        = RK2818_INTC_BASE,                                     
134                 .pfn            = __phys_to_pfn(RK2818_INTC_PHYS),   
135                 .length         = RK2818_INTC_SIZE,                                     
136                 .type           = MT_DEVICE                                             
137         },
138
139         {
140                 .virtual        = RK2818_NANDC_BASE,                            
141                 .pfn            = __phys_to_pfn(RK2818_NANDC_PHYS),      
142                 .length         = RK2818_NANDC_SIZE,                            
143                 .type           = MT_DEVICE                                     
144         },
145
146         {
147                 .virtual        = RK2818_SDRAMC_BASE,
148                 .pfn            = __phys_to_pfn(RK2818_SDRAMC_PHYS),
149                 .length         = RK2818_SDRAMC_SIZE,
150                 .type           = MT_DEVICE
151         },
152
153         {
154                 .virtual        = RK2818_ARMDARBITER_BASE,                                      
155                 .pfn            = __phys_to_pfn(RK2818_ARMDARBITER_PHYS),    
156                 .length         = RK2818_ARMDARBITER_SIZE,                                              
157                 .type           = MT_DEVICE                                                     
158         },
159         
160         {
161                 .virtual        = RK2818_APB_BASE,
162                 .pfn            = __phys_to_pfn(RK2818_APB_PHYS),
163                 .length         = 0xa0000,                     
164                 .type           = MT_DEVICE
165         },
166         
167         {
168                 .virtual        = RK2818_WDT_BASE,
169                 .pfn            = __phys_to_pfn(RK2818_WDT_PHYS),
170                 .length         = 0xa0000,                      ///apb bus i2s i2c spi no map in this
171                 .type           = MT_DEVICE
172         },
173 };
174
175 /*****************************************************************************************
176  * sd/mmc devices
177  * author: kfx@rock-chips.com
178 *****************************************************************************************/
179 static int rk2818_sdmmc0_io_init(void)
180 {
181     rk2818_mux_api_set(GPIOH_MMC0D_SEL_NAME, IOMUXA_SDMMC0_DATA123);
182         rk2818_mux_api_set(GPIOH_MMC0_SEL_NAME, IOMUXA_SDMMC0_CMD_DATA0_CLKOUT);
183
184     return 0;
185 }
186
187 static int rk2818_sdmmc1_io_init(void)
188 {
189         rk2818_mux_api_set(GPIOG_MMC1_SEL_NAME, IOMUXA_SDMMC1_CMD_DATA0_CLKOUT);
190         rk2818_mux_api_set(GPIOG_MMC1D_SEL_NAME, IOMUXA_SDMMC1_DATA123);
191
192     return 0;
193 }
194 #define CONFIG_SDMMC0_USE_DMA
195 #define CONFIG_SDMMC1_USE_DMA
196 struct rk2818_sdmmc_platform_data default_sdmmc0_data = {
197         .host_ocr_avail = (MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
198                                            MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33| 
199                                            MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
200         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
201         .io_init = rk2818_sdmmc0_io_init,
202         .no_detect = 0,
203         .dma_name = "sd_mmc",
204 #ifdef CONFIG_SDMMC0_USE_DMA
205         .use_dma  = 1,
206 #else
207         .use_dma = 0,
208 #endif
209 };
210
211 static int raho_wifi_status(struct device *dev);
212 static int raho_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
213 struct rk2818_sdmmc_platform_data default_sdmmc1_data = {
214         .host_ocr_avail = (MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
215                                            MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
216                                            MMC_VDD_32_33|MMC_VDD_33_34),
217         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
218                                    MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
219         .io_init = rk2818_sdmmc1_io_init,
220         .no_detect = 1,
221         .dma_name = "sdio",
222 #ifdef CONFIG_SDMMC1_USE_DMA
223         .use_dma  = 1,
224 #else
225         .use_dma = 0,
226 #endif
227         .status = raho_wifi_status,
228         .register_status_notify = raho_wifi_status_register,
229 };
230
231 static int raho_wifi_cd;   /* wifi virtual 'card detect' status */
232 static void (*wifi_status_cb)(int card_present, void *dev_id);
233 static void *wifi_status_cb_devid;
234
235 static int raho_wifi_status(struct device *dev)
236 {
237         return raho_wifi_cd;
238 }
239
240 static int raho_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
241 {
242         if(wifi_status_cb)
243                 return -EAGAIN;
244         wifi_status_cb = callback;
245         wifi_status_cb_devid = dev_id;
246         return 0;
247 }
248
249 #define RAHO_WIFI_GPIO_POWER_N  FPGA_PIO1_06
250 #define RAHO_WIFI_GPIO_RESET_N  FPGA_PIO1_03
251
252 int raho_wifi_power_state = 0;
253 int raho_bt_power_state = 0;
254
255 static int raho_wifi_power(int on)
256 {
257         pr_info("%s: %d\n", __func__, on);
258         if (on){
259                 gpio_set_value(RAHO_WIFI_GPIO_POWER_N, on);
260                 mdelay(100);
261                 pr_info("wifi turn on power\n");
262         }else{
263                 if (!raho_bt_power_state){
264                         gpio_set_value(RAHO_WIFI_GPIO_POWER_N, on);
265                         mdelay(100);
266                         pr_info("wifi shut off power\n");
267                 }else
268                 {
269                         pr_info("wifi shouldn't shut off power, bt is using it!\n");
270                 }
271
272         }
273
274         raho_wifi_power_state = on;
275         return 0;
276 }
277
278 static int raho_wifi_reset_state;
279 static int raho_wifi_reset(int on)
280 {
281         pr_info("%s: %d\n", __func__, on);
282         gpio_set_value(RAHO_WIFI_GPIO_RESET_N, on);
283         mdelay(100);
284         raho_wifi_reset_state = on;
285         return 0;
286 }
287
288 static int raho_wifi_set_carddetect(int val)
289 {
290         pr_info("%s:%d\n", __func__, val);
291         raho_wifi_cd = val;
292         if (wifi_status_cb){
293                 wifi_status_cb(val, wifi_status_cb_devid);
294         }else {
295                 pr_warning("%s, nobody to notify\n", __func__);
296         }
297         return 0;
298 }
299
300 static struct wifi_platform_data raho_wifi_control = {
301         .set_power = raho_wifi_power,
302         .set_reset = raho_wifi_reset,
303         .set_carddetect = raho_wifi_set_carddetect,
304 };
305 static struct platform_device raho_wifi_device = {
306         .name = "bcm4329_wlan",
307         .id = 1,
308         .dev = {
309                 .platform_data = &raho_wifi_control,
310          },
311 };
312
313 /* bluetooth rfkill device */
314 static struct platform_device raho_rfkill = {
315         .name = "raho_rfkill",
316         .id = -1,
317 };
318
319 /*****************************************************************************************
320  * extern gpio devices
321  * author: xxx@rock-chips.com
322  *****************************************************************************************/
323 #if defined (CONFIG_GPIO_PCA9554)
324 struct rk2818_gpio_expander_info  extern_gpio_settinginfo[] = {
325         {
326                 .gpio_num               =RK2818_PIN_PI0,
327                 .pin_type           = GPIO_IN,
328                 //.pin_value                    =GPIO_HIGH,
329          },
330
331         {
332                 .gpio_num               =RK2818_PIN_PI4,// tp3
333                 .pin_type           = GPIO_IN,
334                 //.pin_value                    =GPIO_HIGH,
335          },
336          
337          {
338                 .gpio_num               =RK2818_PIN_PI5,//tp4
339                 .pin_type           = GPIO_IN,
340                 //.pin_value                    =GPIO_HIGH,
341          },
342          {
343                 .gpio_num               =RK2818_PIN_PI6,//tp2
344                 .pin_type           = GPIO_OUT,
345                 //.pin_value                    =GPIO_HIGH,
346          },
347          {
348                 .gpio_num               =RK2818_PIN_PI7,//tp1
349                 .pin_type           = GPIO_OUT,
350                 .pin_value                      =GPIO_HIGH,
351          },
352
353
354                 
355 };
356
357 struct pca9554_platform_data rk2818_pca9554_data={
358         .gpio_base=GPIO_EXPANDER_BASE,
359         .gpio_pin_num=CONFIG_EXPANDED_GPIO_NUM,
360         .gpio_irq_start=NR_AIC_IRQS + 2*NUM_GROUP,
361         .irq_pin_num=CONFIG_EXPANDED_GPIO_IRQ_NUM,
362         .pca9954_irq_pin=RK2818_PIN_PE2,
363         .settinginfo=extern_gpio_settinginfo,
364         .settinginfolen=ARRAY_SIZE(extern_gpio_settinginfo),
365 };
366 #endif
367
368 /*****************************************************************************************
369  *regulator devices  drivers/regulator/rk2818_lp8725.c  linux/regulator/rk2818_lp8725.h
370  *author: cym
371 *****************************************************************************************/
372 #if defined (CONFIG_RK2818_REGULATOR_LP8725)
373
374 /*DVS pin control, make sure it is high level at start.*/
375 int rk2818_lp8725_pm_control(void)
376 {
377         rk2818_mux_api_set(GPIOC_LCDC24BIT_SEL_NAME, IOMUXB_GPIO0_C2_7);
378         gpio_request(RK2818_PIN_PC2,NULL);
379         gpio_direction_output(RK2818_PIN_PC2,1);
380         gpio_set_value(RK2818_PIN_PC2,1);
381         return 0;
382 }
383
384 /*ldo1 2V8OUT USB2.5V LCD_VCC*/
385 static struct regulator_consumer_supply ldo1_consumers[] = {
386         {
387                 .supply = "ldo1",
388         }
389 };
390
391 static struct regulator_init_data rk2818_lp8725_ldo1_data = {
392         .constraints = {
393                 .name = "LDO1",
394                 .min_uV = 1200000,
395                 .max_uV = 3300000,
396                 .apply_uV = 1,          
397                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
398         },
399         .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
400         .consumer_supplies = ldo1_consumers,
401 };
402
403 /*ldo2 CAMERA_1V8 SD_CARD*/
404 static struct regulator_consumer_supply ldo2_consumers[] = {
405         {
406                 .supply = "ldo2",
407         }
408 };
409
410 static struct regulator_init_data rk2818_lp8725_ldo2_data = {
411         .constraints = {
412                 .name = "LDO2",
413                 .min_uV = 1200000,
414                 .max_uV = 3300000,
415                 .apply_uV = 1,
416                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
417         },
418         .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
419         .consumer_supplies = ldo2_consumers,
420 };
421
422 /*ldo3 VCC_NAND WIFI/BT/FM_BCM4325*/
423 static struct regulator_consumer_supply ldo3_consumers[] = {
424         {
425                 .supply = "ldo3",
426         }
427 };
428
429 static struct regulator_init_data rk2818_lp8725_ldo3_data = {
430         .constraints = {
431                 .name = "LDO3",
432                 .min_uV = 1200000,
433                 .max_uV = 3300000,
434                 .apply_uV = 1,
435                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
436         },
437         .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
438         .consumer_supplies = ldo3_consumers,
439 };
440
441 /*ldo4 VCCA CODEC_WM8994*/
442 static struct regulator_consumer_supply ldo4_consumers[] = {
443         {
444                 .supply = "ldo4",
445         }
446 };
447
448 static struct regulator_init_data rk2818_lp8725_ldo4_data = {
449         .constraints = {
450                 .name = "LDO4",
451                 .min_uV = 1200000,
452                 .max_uV = 3300000,
453                 .apply_uV = 1,
454                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
455         },
456         .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
457         .consumer_supplies = ldo4_consumers,
458 };
459
460 /*ldo5 AVDD18 CODEC_WM8994*/
461 static struct regulator_consumer_supply ldo5_consumers[] = {
462         {
463                 .supply = "ldo5",
464         }
465 };
466
467 static struct regulator_init_data rk2818_lp8725_ldo5_data = {
468         .constraints = {
469                 .name = "LDO5",
470                 .min_uV = 1200000,
471                 .max_uV = 3300000,
472                 .apply_uV = 1,
473                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
474         },
475         .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
476         .consumer_supplies = ldo5_consumers,
477 };
478
479 /*lilo1 VCCIO Sensor£¨3M£©*/
480 static struct regulator_consumer_supply lilo1_consumers[] = {
481         {
482                 .supply = "lilo1",
483         }
484 };
485
486 static struct regulator_init_data rk2818_lp8725_lilo1_data = {
487         .constraints = {
488                 .name = "LILO1",
489                 .min_uV = 800000,
490                 .max_uV = 3300000,
491                 .apply_uV = 1,
492                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
493         },
494         .num_consumer_supplies = ARRAY_SIZE(lilo1_consumers),
495         .consumer_supplies = lilo1_consumers
496 };
497
498 /*lilo2 VCC33_SD Sensor£¨3M£©*/
499 static struct regulator_consumer_supply lilo2_consumers[] = {
500         {
501                 .supply = "lilo2",
502         }
503 };
504
505 static struct regulator_init_data rk2818_lp8725_lilo2_data = {
506         .constraints = {
507                 .name = "LILO2",
508                 .min_uV = 800000,
509                 .max_uV = 3300000,
510                 .apply_uV = 1,
511                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
512         },
513         .num_consumer_supplies = ARRAY_SIZE(lilo2_consumers),
514         .consumer_supplies = lilo2_consumers
515 };
516
517 /*buck1 VDD12 Core*/
518 static struct regulator_consumer_supply buck1_consumers[] = {
519         {
520                 .supply = "vdd12",
521         }
522 };
523
524 static struct regulator_init_data rk2818_lp8725_buck1_data = {
525         .constraints = {
526                 .name = "VDD12",
527                 .min_uV = 800000,
528                 .max_uV = 1500000,
529                 .apply_uV = 1,
530                 .always_on = 1,
531                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
532                 .valid_modes_mask = REGULATOR_MODE_IDLE | REGULATOR_MODE_NORMAL,
533         },
534         .num_consumer_supplies = ARRAY_SIZE(buck1_consumers),
535         .consumer_supplies = buck1_consumers
536 };
537
538 /*buck2 VDDDR MobileDDR VCC*/
539 static struct regulator_consumer_supply buck2_consumers[] = {
540         {
541                 .supply = "vccdr",
542         }
543 };
544
545 static struct regulator_init_data rk2818_lp8725_buck2_data = {
546         .constraints = {
547                 .name = "VCCDR",
548                 .min_uV = 1800000,
549                 .max_uV = 1800000,
550                 .apply_uV = 1,
551                 .always_on = 1,
552                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
553         },
554         .num_consumer_supplies = ARRAY_SIZE(buck2_consumers),
555         .consumer_supplies = buck2_consumers
556 };
557
558 /*buck1_v2 VDD12 Core*/
559 static struct regulator_consumer_supply buck1_v2_consumers[] = {
560         {
561                 .supply = "vdd12_v2",
562         }
563 };
564
565 static struct regulator_init_data rk2818_lp8725_buck1_v2_data = {
566         .constraints = {
567                 .name = "VDD12_V2",
568                 .min_uV = 800000,
569                 .max_uV = 1500000,
570                 .apply_uV = 1,
571                 //.always_on = 1,
572                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
573         },
574         .num_consumer_supplies = ARRAY_SIZE(buck1_v2_consumers),
575         .consumer_supplies = buck1_v2_consumers
576 };
577
578 /*buck2_v2 VDDDR MobileDDR VCC*/
579 static struct regulator_consumer_supply buck2_v2_consumers[] = {
580         {
581                 .supply = "vccdr_v2",
582         }
583 };
584
585 static struct regulator_init_data rk2818_lp8725_buck2_v2_data = {
586         .constraints = {
587                 .name = "VCCDR_V2",
588                 .min_uV = 1800000,
589                 .max_uV = 1800000,
590                 .apply_uV = 1,
591                 //.always_on = 1,
592                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
593         },
594         .num_consumer_supplies = ARRAY_SIZE(buck2_v2_consumers),
595         .consumer_supplies = buck2_v2_consumers
596 };
597
598 struct lp8725_regulator_subdev rk2818_lp8725_regulator_subdev[] = {
599         {
600                 .id=LP8725_LDO1,
601                 .initdata=&rk2818_lp8725_ldo1_data,             
602          },
603
604         {
605                 .id=LP8725_LDO2,
606                 .initdata=&rk2818_lp8725_ldo2_data,             
607          },
608
609         {
610                 .id=LP8725_LDO3,
611                 .initdata=&rk2818_lp8725_ldo3_data,             
612          },
613
614         {
615                 .id=LP8725_LDO4,
616                 .initdata=&rk2818_lp8725_ldo4_data,             
617          },
618
619         {
620                 .id=LP8725_LDO5,
621                 .initdata=&rk2818_lp8725_ldo5_data,             
622          },
623
624         {
625                 .id=LP8725_LILO1,
626                 .initdata=&rk2818_lp8725_lilo1_data,            
627          },
628
629         {
630                 .id=LP8725_LILO2,
631                 .initdata=&rk2818_lp8725_lilo2_data,            
632          },
633
634         {
635                 .id=LP8725_DCDC1,
636                 .initdata=&rk2818_lp8725_buck1_data,            
637          },
638
639         {
640                 .id=LP8725_DCDC2,
641                 .initdata=&rk2818_lp8725_buck2_data,            
642          },
643         {
644                 .id=LP8725_DCDC1_V2,
645                 .initdata=&rk2818_lp8725_buck1_v2_data,         
646          },
647
648         {
649                 .id=LP8725_DCDC2_V2,
650                 .initdata=&rk2818_lp8725_buck2_v2_data,         
651          },
652 };
653
654 struct lp8725_platform_data rk2818_lp8725_data={
655         .num_regulators=LP8725_NUM_REGULATORS,
656         .regulators=rk2818_lp8725_regulator_subdev,
657 };
658 #endif
659
660 /*****************************************************************************************
661  * gsensor devices
662 *****************************************************************************************/
663 #define GS_IRQ_PIN RK2818_PIN_PE3
664
665 struct rk2818_gs_platform_data rk2818_gs_platdata = {
666         .gsensor_irq_pin = GS_IRQ_PIN,
667         .swap_xy           = 0,
668 };
669
670 /*****************************************************************************************
671  * wm8994  codec
672  * author: cjq@rock-chips.com
673  *****************************************************************************************/
674 static struct wm8994_platform_data wm8994_data = {
675     .mic_input = 0,
676     .micBase_vcc = 0,
677     .bb_input = 0, 
678     .bb_output = 0,
679     .frequence = 0,
680     .enable_pin = 0,
681     .headset_pin = 0,
682     .headset_call_vol = 0,
683     .speaker_call_vol = 0,
684     .earpiece_call_vol = 0,
685     .bt_call_vol = 0,
686 };// must initialize 
687
688 /*****************************************************************************************
689  * rtc
690  *****************************************************************************************/
691 #define RTC_IRQ_PIN RK2818_PIN_PE2
692
693 static int rk2818_rtc_io_init(void)
694 {
695         return 0;
696 }
697
698 static int rk2818_rtc_io_deinit(void)
699 {
700         return 0;
701 }
702
703 static struct rk2818_rtc_platform_data rtc_data = {
704         .irq_type = GPIO_LOW,//irq type
705         .io_init = rk2818_rtc_io_init,
706         .io_deinit = rk2818_rtc_io_deinit,
707 };
708
709 /*****************************************************************************************
710  * i2c devices
711  * author: kfx@rock-chips.com
712 *****************************************************************************************/
713 static int rk2818_i2c0_io_init(void)
714 {
715         rk2818_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
716         return 0;
717 }
718
719 static int rk2818_i2c1_io_init(void)
720 {
721         rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1);
722         return 0;
723 }
724
725 struct rk2818_i2c_platform_data default_i2c0_data = { 
726         .bus_num    = 0,
727         .flags      = 0,
728         .slave_addr = 0xff,
729         .scl_rate  = 400*1000,
730         .mode       = I2C_MODE_IRQ, //I2C_MODE_POLL
731         .io_init = rk2818_i2c0_io_init,
732 };
733 struct rk2818_i2c_platform_data default_i2c1_data = { 
734 #ifdef CONFIG_I2C0_RK2818
735         .bus_num    = 1,
736 #else
737         .bus_num        = 0,
738 #endif
739         .flags      = 0,
740         .slave_addr = 0xff,
741         .scl_rate  = 400*1000,
742         .mode       = I2C_MODE_POLL, //I2C_MODE_POLL
743         .io_init = rk2818_i2c1_io_init,
744 };
745
746 struct rk2818_i2c_spi_data default_i2c2_data = { 
747         .bus_num    = 2,
748         .flags      = 0,
749         .slave_addr = 0xff,
750         .scl_rate  = 400*1000,
751         
752 };
753 struct rk2818_i2c_spi_data default_i2c3_data = { 
754
755         .bus_num    = 3,
756         .flags      = 0,
757         .slave_addr = 0xff,
758         .scl_rate  = 400*1000,
759         
760 };
761 static struct i2c_board_info __initdata board_i2c0_devices[] = {
762 #if defined (CONFIG_RK1000_CONTROL)
763         {
764                 .type                   = "rk1000_control",
765                 .addr           = 0x40,
766                 .flags                  = 0,
767         },
768 #endif
769
770 #if defined (CONFIG_RK1000_TVOUT)
771         {
772                 .type                   = "rk1000_tvout",
773                 .addr           = 0x42,
774                 .flags                  = 0,
775         },
776 #endif
777 #if defined (CONFIG_SND_SOC_RK1000)
778         {
779                 .type                   = "rk1000_i2c_codec",
780                 .addr           = 0x60,
781                 .flags                  = 0,
782         },
783 #endif
784 #if defined (CONFIG_SND_SOC_WM8988)
785         {
786                 .type                   = "wm8988",
787                 .addr           = 0x1a,
788                 .flags                  = 0,
789         }
790 #endif
791 #if defined (CONFIG_TOUCHSCREEN_IT7250)  //add by robert for ctp_it7250
792     {
793         .type           = "Ctp_it7250",
794         .addr           = 0x46,
795         .flags          = 0,
796         .irq            = RK2818_PIN_PE1,
797     },
798 #endif  //end add       
799 };
800 static struct i2c_board_info __initdata board_i2c1_devices[] = {
801 #if defined (CONFIG_RTC_HYM8563)
802         {
803                 .type                   = "rtc_hym8563",
804                 .addr           = 0x51,
805                 .flags                  = 0,
806         },
807 #endif
808 #if defined (CONFIG_RTC_DRV_S35392A)
809         {
810                 .type                   = "rtc-s35392a",
811                 .addr           = 0x30,
812                 .flags                  = 0,
813                 .irq            = RTC_IRQ_PIN,
814                 .platform_data = &rtc_data,
815         },
816 #endif
817 #if defined (CONFIG_FM_QN8006)
818         {
819                 .type                   = "fm_qn8006",
820                 .addr           = 0x2b, 
821                 .flags                  = 0,
822         },
823 #endif
824 #if defined (CONFIG_GPIO_PCA9554)
825         {
826                 .type                   = "extend_gpio_pca9554",
827                 .addr           = 0x3c, 
828                 .flags                  = 0,
829                 .platform_data=&rk2818_pca9554_data.gpio_base,
830         },
831 #endif
832 #if defined (CONFIG_RK2818_REGULATOR_LP8725)
833         {
834                 .type                   = "lp8725",
835                 .addr           = 0x79, 
836                 .flags                  = 0,
837                 .platform_data=&rk2818_lp8725_data,
838         },
839 #endif
840 #if defined (CONFIG_GS_MMA7660)
841     {
842         .type           = "gs_mma7660",
843         .addr           = 0x4c,
844         .flags          = 0,
845         .irq            = GS_IRQ_PIN,
846                 .platform_data = &rk2818_gs_platdata,
847     },
848 #endif
849
850 };
851
852 static struct i2c_board_info __initdata board_i2c2_devices[] = {
853
854 };
855
856 static struct i2c_board_info __initdata board_i2c3_devices[] = {
857 #if defined (CONFIG_SND_SOC_WM8994)
858         {
859                 .type                   = "wm8994",
860                 .addr           = 0x1a,
861                 .flags                  = 0,
862                 .platform_data  = &wm8994_data,
863         },
864 #endif
865 };      
866
867 /*
868  * External power
869  */
870
871 static int power_supply_init(struct device *dev)
872 {
873         return gpio_request(FPGA_PIO2_08, "AC charger detect");
874 }
875
876 static int rk2818_is_ac_online(void)
877 {
878         return !gpio_get_value(FPGA_PIO2_08);
879 }
880
881 static void power_supply_exit(struct device *dev)
882 {
883         gpio_free(FPGA_PIO2_08);
884 }
885
886 static char *rk2818_supplicant[] = {
887         "rk2818-battery"
888 };
889
890 static struct pda_power_pdata power_supply_info = {
891         .init            = power_supply_init,
892         .is_ac_online    = rk2818_is_ac_online,
893         .exit            = power_supply_exit,
894         .supplied_to     = rk2818_supplicant,
895         .num_supplicants = ARRAY_SIZE(rk2818_supplicant),
896 };
897
898 static struct resource power_supply_resources[] = {
899         [0] = {
900                 .name  = "ac",
901                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
902                          IORESOURCE_IRQ_LOWEDGE,
903         },
904         [1] = {
905                 .name  = "usb",
906                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
907                          IORESOURCE_IRQ_LOWEDGE,
908         },
909 };
910
911 static struct platform_device power_supply = {
912         .name = "pda-power",
913         .id   = -1,
914         .dev  = {
915                 .platform_data = &power_supply_info,
916         },
917         .resource      = power_supply_resources,
918         .num_resources = ARRAY_SIZE(power_supply_resources),
919 };
920
921 /*
922  * USB "Transceiver"
923  */
924
925 static struct resource gpio_vbus_resource = {
926         .flags = IORESOURCE_IRQ,
927         .start =  IRQ_NR_OTG,
928         .end   = IRQ_NR_OTG,
929 };
930
931 static struct gpio_vbus_mach_info gpio_vbus_info = {
932         .gpio_vbus   = FPGA_PIO4_06,
933 };
934
935 static struct platform_device gpio_vbus = {
936         .name          = "gpio-vbus",
937         .id            = -1,
938         .num_resources = 1,
939         .resource      = &gpio_vbus_resource,
940         .dev = {
941                 .platform_data = &gpio_vbus_info,
942         },
943 };
944
945 /*
946  * Battery charger
947  */
948
949 static struct regulator_consumer_supply rk2818_consumers[] = {
950         {
951                 .dev=&rk2818_device_battery.dev,
952                 .supply = "battery",
953         },
954         {
955                 .dev = &gpio_vbus.dev,
956                 .supply = "vbus_draw",
957         },
958         {
959                 .dev = &power_supply.dev,
960                 .supply = "ac_draw",
961         },
962 };
963
964 static struct regulator_init_data charge_init_data = {
965         .constraints = {
966                 .max_uA         = 1200000,
967                 .valid_ops_mask = REGULATOR_CHANGE_CURRENT,
968         },
969         .num_consumer_supplies  = ARRAY_SIZE(rk2818_consumers),
970         .consumer_supplies      = rk2818_consumers,
971 };
972
973 static struct charge_platform_data charge_current_info = {
974         .gpio_charge = FPGA_PIO2_08,
975         .init_data  = &charge_init_data,
976 };
977
978 static struct platform_device charge_current = {
979         .name = "charge-regulator",
980         .id   = -1,
981         .dev  = {
982                 .platform_data = &charge_current_info,
983         },
984 };
985
986 /*****************************************************************************************
987  * camera  devices
988  * author: ddl@rock-chips.com
989  *****************************************************************************************/ 
990 #ifdef CONFIG_VIDEO_RK2818
991 /* Board-raho camera configuration */
992 #define SENSOR_NAME_0 RK28_CAM_SENSOR_NAME_OV2655
993 #define SENSOR_IIC_ADDR_0           0x60
994 #define SENSOR_IIC_ADAPTER_ID_0    2
995 #define SENSOR_POWER_PIN_0         FPGA_PIO1_05
996 #define SENSOR_RESET_PIN_0         FPGA_PIO1_14
997 #define SENSOR_POWERACTIVE_LEVEL_0 RK28_CAM_POWERACTIVE_L
998 #define SENSOR_RESETACTIVE_LEVEL_0 RK28_CAM_RESETACTIVE_L
999
1000
1001 #define SENSOR_NAME_1 NULL
1002 #define SENSOR_IIC_ADDR_1           0x00
1003 #define SENSOR_IIC_ADAPTER_ID_1    0xff
1004 #define SENSOR_POWER_PIN_1         INVALID_GPIO
1005 #define SENSOR_RESET_PIN_1         INVALID_GPIO
1006 #define SENSOR_POWERACTIVE_LEVEL_1 RK28_CAM_POWERACTIVE_L
1007 #define SENSOR_RESETACTIVE_LEVEL_1 RK28_CAM_RESETACTIVE_L
1008
1009 static int rk28_sensor_io_init(void);
1010 static int rk28_sensor_io_deinit(void);
1011
1012 struct rk28camera_platform_data rk28_camera_platform_data = {
1013     .io_init = rk28_sensor_io_init,
1014     .io_deinit = rk28_sensor_io_deinit,
1015     .gpio_res = {
1016         {
1017             .gpio_reset = SENSOR_RESET_PIN_0,
1018             .gpio_power = SENSOR_POWER_PIN_0,
1019             .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0),
1020             .dev_name = SENSOR_NAME_0,
1021         }, {
1022             .gpio_reset = SENSOR_RESET_PIN_1,
1023             .gpio_power = SENSOR_POWER_PIN_1,
1024             .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
1025             .dev_name = SENSOR_NAME_1,
1026         }
1027     }
1028 };
1029
1030 static int rk28_sensor_io_init(void)
1031 {
1032     int ret = 0, i;
1033     unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1034         unsigned int camera_ioflag;
1035     //printk("\n%s....%d    ******** ddl *********\n",__FUNCTION__,__LINE__);
1036
1037     for (i=0; i<2; i++) {
1038         camera_reset = rk28_camera_platform_data.gpio_res[i].gpio_reset;
1039         camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power;
1040                 camera_ioflag = rk28_camera_platform_data.gpio_res[i].gpio_flag;
1041
1042         if (camera_power != INVALID_GPIO) {
1043             ret = gpio_request(camera_power, "camera power");
1044             if (ret)
1045                 continue;
1046
1047             gpio_set_value(camera_reset, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
1048             gpio_direction_output(camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
1049
1050                         //printk("\n%s....%d  %x   ******** ddl *********\n",__FUNCTION__,__LINE__,(((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
1051
1052         }
1053
1054         if (camera_reset != INVALID_GPIO) {
1055             ret = gpio_request(camera_reset, "camera reset");
1056             if (ret) {
1057                 if (camera_power != INVALID_GPIO)
1058                     gpio_free(camera_power);
1059
1060                 continue;
1061             }
1062
1063             gpio_set_value(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
1064             gpio_direction_output(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
1065
1066                         //printk("\n%s....%d  %x   ******** ddl *********\n",__FUNCTION__,__LINE__,((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
1067
1068         }
1069     }
1070
1071     return 0;
1072 }
1073
1074 static int rk28_sensor_io_deinit(void)
1075 {
1076     unsigned int i;
1077     unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1078
1079     //printk("\n%s....%d    ******** ddl *********\n",__FUNCTION__,__LINE__);
1080
1081     for (i=0; i<2; i++) {
1082         camera_reset = rk28_camera_platform_data.gpio_res[i].gpio_reset;
1083         camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power;
1084
1085         if (camera_power != INVALID_GPIO){
1086             gpio_direction_input(camera_power);
1087             gpio_free(camera_power);
1088         }
1089
1090         if (camera_reset != INVALID_GPIO)  {
1091             gpio_direction_input(camera_reset);
1092             gpio_free(camera_reset);
1093         }
1094     }
1095
1096     return 0;
1097 }
1098
1099
1100 static int rk28_sensor_power(struct device *dev, int on)
1101 {
1102     unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1103         unsigned int camera_ioflag;
1104
1105     if(rk28_camera_platform_data.gpio_res[0].dev_name &&  (strcmp(rk28_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
1106         camera_reset = rk28_camera_platform_data.gpio_res[0].gpio_reset;
1107         camera_power = rk28_camera_platform_data.gpio_res[0].gpio_power;
1108                 camera_ioflag = rk28_camera_platform_data.gpio_res[0].gpio_flag;
1109     } else if (rk28_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk28_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
1110         camera_reset = rk28_camera_platform_data.gpio_res[1].gpio_reset;
1111         camera_power = rk28_camera_platform_data.gpio_res[1].gpio_power;
1112                 camera_ioflag = rk28_camera_platform_data.gpio_res[1].gpio_flag;
1113     }
1114
1115     if (camera_reset != INVALID_GPIO) {
1116         gpio_set_value(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
1117         //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
1118     }
1119     if (camera_power != INVALID_GPIO)  {
1120         if (on) {
1121                 gpio_set_value(camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
1122                         //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x   \n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
1123                 } else {
1124                         gpio_set_value(camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
1125                         //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x   \n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
1126                 }
1127         }
1128     if (camera_reset != INVALID_GPIO) {
1129         msleep(3);          /* delay 3 ms */
1130         gpio_set_value(camera_reset,(((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
1131         //printk("\n%s..%s..ResetPin= %d..PinLevel = %x   \n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
1132     }
1133     return 0;
1134 }
1135
1136 static struct i2c_board_info rk2818_i2c_cam_info[] = {
1137         {
1138                 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
1139         },
1140 };
1141
1142 struct soc_camera_link rk2818_iclink = {
1143         .bus_id         = RK28_CAM_PLATFORM_DEV_ID,
1144         .power          = rk28_sensor_power,
1145         .board_info     = &rk2818_i2c_cam_info[0],
1146         .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
1147         .module_name    = SENSOR_NAME_0,
1148 };
1149
1150 /*platform_device : soc-camera need  */
1151 struct platform_device rk2818_soc_camera_pdrv = {
1152         .name   = "soc-camera-pdrv",
1153         .id     = -1,
1154         .dev    = {
1155                 .init_name = SENSOR_NAME_0,
1156                 .platform_data = &rk2818_iclink,
1157         },
1158 };
1159 #endif
1160 /*****************************************************************************************
1161  * battery  devices
1162  * author: lw@rock-chips.com
1163  *****************************************************************************************/
1164 #define CHARGEOK_PIN    FPGA_PIO0_06
1165 struct rk2818_battery_platform_data rk2818_battery_platdata = {
1166         .charge_ok_pin = CHARGEOK_PIN,
1167         .charge_ok_level = 0,
1168 };
1169
1170
1171 /*****************************************************************************************
1172  * serial devices
1173  * author: lhh@rock-chips.com
1174  *****************************************************************************************/
1175 static int serial_io_init(void)
1176 {
1177         int ret;
1178 #if 1   
1179         //cz@rock-chips.com
1180         //20100808 
1181         //UART0µÄËĸö¹Ü½ÅÏÈIOMUX³ÉGPIO
1182         //È»ºó·Ö±ðÉèÖÃÊäÈëÊä³ö/À­¸ßÀ­µÍ´¦Àí
1183         //×îºóÔÙIOMUX³ÉUART
1184         //·ÀÖ¹Ö±½ÓIOMUX³ÉUARTºóËĸö¹Ü½ÅµÄ״̬²»¶Ôʱ
1185         //²Ù×÷UARTµ¼ÖÂUART_USR_BUSYʼÖÕΪ1Ôì³ÉÈçÏÂËÀÑ­»·
1186         //while(rk2818_uart_read(port,UART_USR)&UART_USR_BUSY)
1187         //UARTËĸö¹Ü½ÅÔÚδ´«ÊäʱÕý³£×´Ì¬Ó¦¸ÃΪ£º
1188         //RX/TX£ºHIGH
1189         //CTS/RTS£ºLOW
1190         //×¢Ò⣺CTS/RTSΪµÍÓÐЧ£¬Ó²¼þÉϲ»Ó¦¸ÃÇ¿ÐÐ×öÉÏÀ­
1191                 rk2818_mux_api_set(GPIOG1_UART0_MMC1WPT_NAME, IOMUXA_GPIO1_C1 /*IOMUXA_UART0_SOUT*/);  
1192                 rk2818_mux_api_set(GPIOG0_UART0_MMC1DET_NAME, IOMUXA_GPIO1_C0 /*IOMUXA_UART0_SIN*/);
1193                 
1194                 ret = gpio_request(RK2818_PIN_PG0, NULL); 
1195                 if(ret != 0)
1196                 {
1197                   gpio_free(RK2818_PIN_PG0);
1198                 }
1199                 gpio_direction_output(RK2818_PIN_PG0,GPIO_HIGH); 
1200         
1201                 
1202                 ret = gpio_request(RK2818_PIN_PG1, NULL); 
1203                 if(ret != 0)
1204                 {
1205                   gpio_free(RK2818_PIN_PG1);
1206                 }
1207                 gpio_direction_output(RK2818_PIN_PG1,GPIO_HIGH); 
1208         
1209                 gpio_pull_updown(RK2818_PIN_PG1,GPIOPullUp);
1210                 gpio_pull_updown(RK2818_PIN_PG0,GPIOPullUp);
1211         
1212                 rk2818_mux_api_set(GPIOG1_UART0_MMC1WPT_NAME, IOMUXA_UART0_SOUT);  
1213                 rk2818_mux_api_set(GPIOG0_UART0_MMC1DET_NAME, IOMUXA_UART0_SIN);
1214         
1215                 rk2818_mux_api_set(GPIOB2_U0CTSN_SEL_NAME, IOMUXB_GPIO0_B2/*IOMUXB_UART0_CTS_N*/);
1216                 rk2818_mux_api_set(GPIOB3_U0RTSN_SEL_NAME, IOMUXB_GPIO0_B3/*IOMUXB_UART0_RTS_N*/);
1217         
1218                 ret = gpio_request(RK2818_PIN_PB2, NULL); 
1219                 if(ret != 0)
1220                 {
1221                   gpio_free(RK2818_PIN_PB2);
1222                 }
1223                 gpio_direction_input(RK2818_PIN_PB2); 
1224         //        gpio_direction_output(RK2818_PIN_PB2,GPIO_LOW); 
1225                 
1226                 ret = gpio_request(RK2818_PIN_PB3, NULL); 
1227                 if(ret != 0)
1228                 {
1229                   gpio_free(RK2818_PIN_PB3);
1230                 }
1231                 gpio_direction_output(RK2818_PIN_PB3,GPIO_LOW); 
1232 #endif
1233
1234         rk2818_mux_api_set(GPIOB2_U0CTSN_SEL_NAME, IOMUXB_UART0_CTS_N);
1235         rk2818_mux_api_set(GPIOB3_U0RTSN_SEL_NAME, IOMUXB_UART0_RTS_N);
1236
1237         return 0;
1238 }
1239
1240 struct rk2818_serial_platform_data rk2818_serial0_platdata = {
1241         .io_init = serial_io_init,
1242 };
1243
1244 /*****************************************************************************************
1245  * i2s devices
1246  * author: lhhrock-chips.com
1247  *****************************************************************************************/
1248 static int i2s_io_init(void)
1249 {
1250     /* Configure the I2S pins in correct mode */
1251     rk2818_mux_api_set(CXGPIO_I2S_SEL_NAME,IOMUXB_I2S_INTERFACE);
1252         return 0;
1253 }
1254
1255 struct rk2818_i2s_platform_data rk2818_i2s_platdata = {
1256         .io_init = i2s_io_init,
1257 };
1258
1259
1260 /*****************************************************************************************
1261  * spi devices
1262  * author: lhhrock-chips.com
1263  *****************************************************************************************/
1264 #define SPI_CHIPSELECT_NUM 3
1265 struct spi_cs_gpio rk2818_spi_cs_gpios[SPI_CHIPSELECT_NUM] = {
1266         {
1267                 .name = "spi cs0",
1268                 .cs_gpio = RK2818_PIN_PB4,
1269                 .cs_iomux_name = GPIOB4_SPI0CS0_MMC0D4_NAME,//if no iomux,set it NULL
1270                 .cs_iomux_mode = IOMUXA_GPIO0_B4,
1271         },
1272         {
1273                 .name = "spi cs1",
1274                 .cs_gpio = RK2818_PIN_PB0,
1275                 .cs_iomux_name = GPIOB0_SPI0CSN1_MMC1PCA_NAME,
1276                 .cs_iomux_mode = IOMUXA_GPIO0_B0,
1277         },
1278         {
1279                 .name = "spi cs2",
1280                 .cs_gpio = RK2818_PIN_PF5,
1281                 .cs_iomux_name = GPIOF5_APWM3_DPWM3_NAME,
1282                 .cs_iomux_mode = IOMUXB_GPIO1_B5,
1283         }
1284 };
1285
1286 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1287 {       
1288         int i,j,ret;
1289         //clk
1290         rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME, IOMUXA_SPI0);
1291         //cs
1292         if (cs_gpios) {
1293                 for (i=0; i<cs_num; i++) {
1294                         rk2818_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1295                         ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
1296                         if (ret) {
1297                                 for (j=0;j<i;j++) {
1298                                         gpio_free(cs_gpios[j].cs_gpio);
1299                                         rk2818_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
1300                                 }
1301                                 printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
1302                                 return -1;
1303                         }                       
1304                         gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
1305                 }
1306         }
1307         return 0;
1308 }
1309
1310 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1311 {
1312         int i;
1313         rk2818_mux_api_mode_resume(GPIOB_SPI0_MMC0_NAME);       
1314         
1315         if (cs_gpios) {
1316                 for (i=0; i<cs_num; i++) {
1317                         gpio_free(cs_gpios[i].cs_gpio);
1318                         rk2818_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
1319                 }
1320         }
1321         
1322         return 0;
1323 }
1324
1325 static int spi_io_fix_leakage_bug(void)
1326 {
1327         gpio_direction_output(RK2818_PIN_PB4,GPIO_LOW); 
1328         return 0;
1329 }
1330
1331 static int spi_io_resume_leakage_bug(void)
1332 {
1333         gpio_direction_output(RK2818_PIN_PB4,GPIO_HIGH);
1334         return 0;
1335 }
1336
1337 struct rk2818_spi_platform_data rk2818_spi_platdata = {
1338         .num_chipselect = SPI_CHIPSELECT_NUM,//raho ´ó°åÐèÒªÖ§³Ö3¸öƬѡ dxj
1339         .chipselect_gpios = rk2818_spi_cs_gpios,
1340         .io_init = spi_io_init,
1341         .io_deinit = spi_io_deinit,
1342         .io_fix_leakage_bug=spi_io_fix_leakage_bug,
1343         .io_resume_leakage_bug=spi_io_resume_leakage_bug,
1344 };
1345
1346
1347 /*****************************************************************************************
1348  * xpt2046 touch panel
1349  * author: dxjrock-chips.com
1350  *****************************************************************************************/
1351 #define XPT2046_GPIO_INT           RK2818_PIN_PE1
1352 #define DEBOUNCE_REPTIME  3
1353
1354 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) 
1355 static struct xpt2046_platform_data xpt2046_info = {
1356         .model                  = 2046,
1357         .keep_vref_on   = 1,
1358         .swap_xy                = 0,
1359         .x_min                  = 0,
1360         .x_max                  = 320,
1361         .y_min                  = 0,
1362         .y_max                  = 480,
1363         .debounce_max           = 7,
1364         .debounce_rep           = DEBOUNCE_REPTIME,
1365         .debounce_tol           = 20,
1366         .gpio_pendown           = XPT2046_GPIO_INT,
1367         .penirq_recheck_delay_usecs = 1,
1368 };
1369 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1370 static struct xpt2046_platform_data xpt2046_info = {
1371         .model                  = 2046,
1372         .keep_vref_on   = 1,
1373         .swap_xy                = 0,
1374         .x_min                  = 0,
1375         .x_max                  = 320,
1376         .y_min                  = 0,
1377         .y_max                  = 480,
1378         .debounce_max           = 7,
1379         .debounce_rep           = DEBOUNCE_REPTIME,
1380         .debounce_tol           = 20,
1381         .gpio_pendown           = XPT2046_GPIO_INT,
1382         .penirq_recheck_delay_usecs = 1,
1383 };
1384 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) 
1385 static struct xpt2046_platform_data xpt2046_info = {
1386         .model                  = 2046,
1387         .keep_vref_on   = 1,
1388         .swap_xy                = 1,
1389         .x_min                  = 0,
1390         .x_max                  = 800,
1391         .y_min                  = 0,
1392         .y_max                  = 480,
1393         .debounce_max           = 7,
1394         .debounce_rep           = DEBOUNCE_REPTIME,
1395         .debounce_tol           = 20,
1396         .gpio_pendown           = XPT2046_GPIO_INT,
1397         
1398         .penirq_recheck_delay_usecs = 1,
1399 };
1400 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1401 static struct xpt2046_platform_data xpt2046_info = {
1402         .model                  = 2046,
1403         .keep_vref_on   = 1,
1404         .swap_xy                = 1,
1405         .x_min                  = 0,
1406         .x_max                  = 800,
1407         .y_min                  = 0,
1408         .y_max                  = 480,
1409         .debounce_max           = 7,
1410         .debounce_rep           = DEBOUNCE_REPTIME,
1411         .debounce_tol           = 20,
1412         .gpio_pendown           = XPT2046_GPIO_INT,
1413         
1414         .penirq_recheck_delay_usecs = 1,
1415 };
1416 #endif
1417
1418 static struct rk2818_spi_chip cmb_spi_chip = {
1419         .transfer_mode = RK2818_SPI_FULL_DUPLEX,
1420 };
1421
1422 /*****************************************************************************************
1423  * CMMB IO CONFIG
1424  
1425  *****************************************************************************************/
1426
1427 #define CMMB_1186_SPIIRQ RK2818_PIN_PA1
1428
1429 void cmmb_io_init_mux(void)
1430 {
1431         rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, 0);
1432
1433 }
1434
1435 static struct cmmb_io_def_s cmmb_io = {
1436         .cmmb_pw_en = FPGA_PIO4_03,
1437         .cmmb_pw_dwn = FPGA_PIO2_09,
1438         .cmmb_pw_rst = FPGA_PIO2_06,
1439         .cmmb_irq = CMMB_1186_SPIIRQ,
1440         .io_init_mux = cmmb_io_init_mux
1441 };
1442
1443 static struct spi_board_info board_spi_devices[] = {
1444 #if defined(CONFIG_SPI_FPGA)
1445         {       /* fpga ice65l08xx */
1446                 .modalias       = "spi_fpga",
1447                 .chip_select    = 1,
1448                 .max_speed_hz   = 12 * 1000 * 1000,
1449                 .bus_num        = 0,
1450                 .mode   = SPI_MODE_0,
1451                 //.platform_data = &rk2818_spi_platdata,
1452         },
1453 #endif
1454 #if defined(CONFIG_ENC28J60)    
1455         {       /* net chip */
1456                 .modalias       = "enc28j60",
1457                 .chip_select    = 1,
1458                 .max_speed_hz   = 12 * 1000 * 1000,
1459                 .bus_num        = 0,
1460                 .mode   = SPI_MODE_0,
1461         },
1462 #endif  
1463 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1464     ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1465         {
1466                 .modalias       = "xpt2046_ts",
1467                 .chip_select    = 2,
1468                 .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1469                 .bus_num        = 0,
1470                 .irq = XPT2046_GPIO_INT,
1471                 .platform_data = &xpt2046_info,
1472         },
1473 #endif
1474 #if defined(CONFIG_SMS_SPI_ROCKCHIP)
1475         {
1476                 .modalias       = "siano1186",           
1477                 .chip_select    = 0,                                  
1478                 .max_speed_hz   = 12*1000*1000,         
1479                 .bus_num        = 0,
1480                 .irq            =CMMB_1186_SPIIRQ,
1481                 .controller_data = &cmb_spi_chip,
1482                 .platform_data = &cmmb_io,
1483         },
1484 #endif
1485 }; 
1486
1487 /*****************************************************************************************
1488  * lcd  devices
1489  * author: zyw@rock-chips.com
1490  *****************************************************************************************/
1491 //#ifdef  CONFIG_LCD_TD043MGEA1
1492 #define LCD_TXD_PIN          RK2818_PIN_PE4
1493 #define LCD_CLK_PIN          RK2818_PIN_PE5
1494 #define LCD_CS_PIN           RK2818_PIN_PH6
1495 #define LCD_TXD_MUX_NAME     GPIOE_I2C0_SEL_NAME
1496 #define LCD_CLK_MUX_NAME     NULL
1497 #define LCD_CS_MUX_NAME      GPIOH6_IQ_SEL_NAME
1498 #define LCD_TXD_MUX_MODE     1
1499 #define LCD_CLK_MUX_MODE     1
1500 #define LCD_CS_MUX_MODE      0
1501
1502 #define LCD_RESET_PIN RK2818_PIN_PC3
1503 #define LCD_RESET_IOMUX_NAME GPIOC_LCDC24BIT_SEL_NAME
1504 #define LCD_RESET_IOMUX_VALUE 0
1505 //#endif
1506 static int rk2818_lcd_io_init(void)
1507 {
1508     int ret = 0;
1509     
1510     rk2818_mux_api_set(LCD_CS_MUX_NAME, LCD_CS_MUX_MODE);
1511     if (LCD_CS_PIN != INVALID_GPIO) {
1512         ret = gpio_request(LCD_CS_PIN, NULL); 
1513         if(ret != 0)
1514         {
1515             goto err1;
1516             printk(">>>>>> lcd cs gpio_request err \n ");                    
1517         } 
1518     }
1519     
1520     rk2818_mux_api_set(LCD_CLK_MUX_NAME, LCD_CLK_MUX_MODE);
1521     if (LCD_CLK_PIN != INVALID_GPIO) {
1522         ret = gpio_request(LCD_CLK_PIN, NULL); 
1523         if(ret != 0)
1524         {
1525             goto err2;
1526             printk(">>>>>> lcd clk gpio_request err \n ");             
1527         }  
1528     }
1529     
1530     rk2818_mux_api_set(LCD_TXD_MUX_NAME, LCD_TXD_MUX_MODE); 
1531     if (LCD_TXD_PIN != INVALID_GPIO) {
1532         ret = gpio_request(LCD_TXD_PIN, NULL); 
1533         if(ret != 0)
1534         {
1535             goto err3;
1536             printk(">>>>>> lcd txd gpio_request err \n ");             
1537         } 
1538     }
1539
1540     return 0;
1541     
1542 err3:
1543     if (LCD_CLK_PIN != INVALID_GPIO) {
1544         gpio_free(LCD_CLK_PIN);
1545     }
1546 err2:
1547     if (LCD_CS_PIN != INVALID_GPIO) {
1548         gpio_free(LCD_CS_PIN);
1549     }
1550 err1:
1551     return ret;
1552 }
1553
1554 static int rk2818_lcd_io_deinit(void)
1555 {
1556     int ret = 0;
1557     gpio_free(LCD_CS_PIN); 
1558     rk2818_mux_api_mode_resume(LCD_CS_MUX_NAME);
1559     gpio_free(LCD_CLK_PIN);   
1560     gpio_free(LCD_TXD_PIN); 
1561     rk2818_mux_api_mode_resume(LCD_TXD_MUX_NAME);
1562     rk2818_mux_api_mode_resume(LCD_CLK_MUX_NAME);
1563     
1564     return ret;
1565 }
1566
1567 static int rk2818_lcd_reset(void)
1568 {
1569         int ret;
1570     rk2818_mux_api_set(LCD_RESET_IOMUX_NAME, LCD_RESET_IOMUX_VALUE);
1571         ret = gpio_request(LCD_RESET_PIN, "lcd reset");
1572         if(ret != 0)
1573         {
1574                 gpio_free(LCD_RESET_PIN);
1575                 rk2818_mux_api_mode_resume(LCD_RESET_IOMUX_NAME);
1576                 printk(">>>>>> lcd gpio_request err \n ");
1577                 return -1;
1578         } 
1579         gpio_set_value(LCD_RESET_PIN, GPIO_LOW);
1580         gpio_direction_output(LCD_RESET_PIN, GPIO_LOW); 
1581         mdelay(3);
1582         gpio_set_value(LCD_RESET_PIN, GPIO_HIGH);
1583         gpio_direction_output(LCD_RESET_PIN, GPIO_HIGH); 
1584         
1585         printk(">>>>>> lcd reset  ok \n ");                                      
1586         
1587         return 0;
1588 }
1589
1590 struct rk2818lcd_info rk2818_lcd_info = {
1591     .txd_pin  = LCD_TXD_PIN,
1592     .clk_pin = LCD_CLK_PIN,
1593     .cs_pin = LCD_CS_PIN,
1594     .io_init   = rk2818_lcd_io_init,
1595     .io_deinit = rk2818_lcd_io_deinit, 
1596 };
1597
1598
1599 /*****************************************************************************************
1600  * frame buffe  devices
1601  * author: zyw@rock-chips.com
1602  *****************************************************************************************/
1603 #define FB_ID                       0
1604 #define FB_DISPLAY_ON_PIN           INVALID_GPIO
1605 #define FB_LCD_STANDBY_PIN          INVALID_GPIO
1606 #define FB_MCU_FMK_PIN              INVALID_GPIO
1607
1608 #define FB_DISPLAY_ON_VALUE         GPIO_LOW
1609 #define FB_LCD_STANDBY_VALUE        0
1610
1611 #define FB_DISPLAY_ON_MUX_NAME      NULL
1612 #define FB_DISPLAY_ON_MUX_MODE      0
1613
1614 #define FB_LCD_STANDBY_MUX_NAME     NULL
1615 #define FB_LCD_STANDBY_MUX_MODE     1
1616
1617 #define FB_MCU_FMK_PIN_MUX_NAME     NULL
1618 #define FB_MCU_FMK_MUX_MODE         0
1619
1620 #define FB_DATA0_16_MUX_NAME       GPIOC_LCDC16BIT_SEL_NAME
1621 #define FB_DATA0_16_MUX_MODE        1
1622
1623 #define FB_DATA17_18_MUX_NAME      GPIOC_LCDC18BIT_SEL_NAME
1624 #define FB_DATA17_18_MUX_MODE       1
1625
1626 #define FB_DATA19_24_MUX_NAME      GPIOC_LCDC24BIT_SEL_NAME
1627 #define FB_DATA19_24_MUX_MODE       1
1628
1629 #define FB_DEN_MUX_NAME            CXGPIO_LCDDEN_SEL_NAME
1630 #define FB_DEN_MUX_MODE             1
1631
1632 #define FB_VSYNC_MUX_NAME          CXGPIO_LCDVSYNC_SEL_NAME
1633 #define FB_VSYNC_MUX_MODE           1
1634
1635 #define FB_MCU_FMK_MUX_NAME        NULL
1636 #define FB_MCU_FMK_MUX_MODE         0
1637
1638 static int rk2818_fb_io_init(struct rk2818_fb_setting_info *fb_setting)
1639 {
1640     int ret = 0;
1641     if(fb_setting->data_num <=16)
1642         rk2818_mux_api_set(FB_DATA0_16_MUX_NAME, FB_DATA0_16_MUX_MODE);
1643     if(fb_setting->data_num >16 && fb_setting->data_num<=18)
1644         rk2818_mux_api_set(FB_DATA17_18_MUX_NAME, FB_DATA17_18_MUX_MODE);
1645     if(fb_setting->data_num >18)
1646         rk2818_mux_api_set(FB_DATA19_24_MUX_NAME, FB_DATA19_24_MUX_MODE);
1647     
1648     if(fb_setting->vsync_en)
1649         rk2818_mux_api_set(FB_VSYNC_MUX_NAME, FB_VSYNC_MUX_MODE);
1650     
1651     if(fb_setting->den_en)
1652         rk2818_mux_api_set(FB_DEN_MUX_NAME, FB_DEN_MUX_MODE);
1653     
1654     if(fb_setting->mcu_fmk_en && FB_MCU_FMK_MUX_NAME && (FB_MCU_FMK_PIN != INVALID_GPIO))
1655     {
1656         rk2818_mux_api_set(FB_MCU_FMK_MUX_NAME, FB_MCU_FMK_MUX_MODE);
1657         ret = gpio_request(FB_MCU_FMK_PIN, NULL);         
1658         if(ret != 0)
1659         {
1660             gpio_free(FB_MCU_FMK_PIN);
1661             printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");             
1662         } 
1663         gpio_direction_input(FB_MCU_FMK_PIN);
1664     }
1665
1666     if(fb_setting->disp_on_en && FB_DISPLAY_ON_MUX_NAME && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
1667     {
1668         rk2818_mux_api_set(FB_DISPLAY_ON_MUX_NAME, FB_DISPLAY_ON_MUX_MODE);
1669         ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);         
1670         if(ret != 0)
1671         {
1672             gpio_free(FB_DISPLAY_ON_PIN);
1673             printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");             
1674         }         
1675     }
1676
1677     if(fb_setting->disp_on_en && FB_LCD_STANDBY_MUX_NAME && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
1678     {
1679         rk2818_mux_api_set(FB_LCD_STANDBY_MUX_NAME, FB_LCD_STANDBY_MUX_MODE);
1680         ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);         
1681         if(ret != 0)
1682         {
1683             gpio_free(FB_LCD_STANDBY_PIN);
1684             printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");             
1685         }
1686     }
1687
1688     return ret;
1689 }
1690
1691 struct rk2818fb_info rk2818_fb_info = {
1692     .fb_id   = FB_ID,  
1693     .disp_on_pin = FB_DISPLAY_ON_PIN,
1694     .disp_on_value = FB_DISPLAY_ON_VALUE,
1695     .standby_pin = FB_LCD_STANDBY_PIN,
1696     .standby_value = FB_LCD_STANDBY_VALUE,
1697     .mcu_fmk_pin = FB_MCU_FMK_PIN,  
1698     .lcd_info = &rk2818_lcd_info,
1699     .io_init   = rk2818_fb_io_init,
1700 };
1701
1702 /*****************************************************************************************
1703  * backlight  devices
1704  * author: nzy@rock-chips.com
1705  *****************************************************************************************/
1706  /*
1707  GPIOF2_APWM0_SEL_NAME,       IOMUXB_PWM0
1708  GPIOF3_APWM1_MMC0DETN_NAME,  IOMUXA_PWM1
1709  GPIOF4_APWM2_MMC0WPT_NAME,   IOMUXA_PWM2
1710  GPIOF5_APWM3_DPWM3_NAME,     IOMUXB_PWM3
1711  */
1712  
1713 #define PWM_ID            0  
1714 #define PWM_MUX_NAME      GPIOF2_APWM0_SEL_NAME
1715 #define PWM_MUX_MODE      IOMUXB_PWM0
1716 #define PWM_EFFECT_VALUE  0
1717
1718
1719 #define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
1720 #define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
1721
1722 #define BL_EN_PIN         RK2818_PIN_PF3
1723 #define BL_EN_VALUE       GPIO_HIGH
1724
1725
1726
1727 static int rk2818_backlight_io_init(void)
1728 {
1729     int ret = 0;
1730     
1731     rk2818_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1732
1733     rk2818_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE); 
1734
1735     ret = gpio_request(BL_EN_PIN, NULL); 
1736     if(ret != 0)
1737     {
1738         gpio_free(BL_EN_PIN);
1739         printk(KERN_ERR ">>>>>> lcd_cs gpio_request err \n ");        
1740     }
1741     
1742     gpio_direction_output(BL_EN_PIN, 0);
1743     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1744
1745     return ret;
1746 }
1747
1748 static int rk2818_backlight_io_deinit(void)
1749 {
1750     int ret = 0;
1751     
1752     gpio_free(BL_EN_PIN);
1753     
1754     rk2818_mux_api_mode_resume(PWM_MUX_NAME);
1755
1756     rk2818_mux_api_mode_resume(BL_EN_MUX_NAME);
1757
1758     return ret;
1759 }
1760
1761 struct rk2818_bl_info rk2818_bl_info = {
1762     .pwm_id   = PWM_ID,
1763     .bl_ref   = PWM_EFFECT_VALUE,
1764     .io_init   = rk2818_backlight_io_init,
1765     .io_deinit = rk2818_backlight_io_deinit, 
1766 };
1767
1768
1769 /*****************************************************************************************
1770  * netcard  devices
1771  * author: lyx@rock-chips.com
1772  *****************************************************************************************/
1773 #ifdef CONFIG_DM9000
1774 /*
1775 GPIOA5_FLASHCS1_SEL_NAME     IOMUXB_FLASH_CS1
1776 GPIOA6_FLASHCS2_SEL_NAME     IOMUXB_FLASH_CS2
1777 GPIOA7_FLASHCS3_SEL_NAME     IOMUXB_FLASH_CS3
1778 GPIOE_SPI1_FLASH_SEL1_NAME   IOMUXA_FLASH_CS45
1779 GPIOE_SPI1_FLASH_SEL_NAME    IOMUXA_FLASH_CS67
1780 */
1781 #define DM9000_USE_NAND_CS 1     //cs can be 1,2,3,4,5,6 or 7
1782 #define DM9000_CS_IOMUX_NAME GPIOA5_FLASHCS1_SEL_NAME
1783 #define DM9000_CS_IOMUX_MODE IOMUXB_FLASH_CS1
1784 #define DM9000_NET_INT_PIN RK2818_PIN_PA1
1785 #define DM9000_INT_IOMUX_NAME GPIOA1_HOSTDATA17_SEL_NAME
1786 #define DM9000_INT_IOMUX_MODE IOMUXB_GPIO0_A1
1787 #define DM9000_INT_INIT_VALUE GPIOPullDown
1788 #define DM9000_IRQ IRQF_TRIGGER_HIGH
1789 #define DM9000_IO_ADDR (RK2818_NANDC_PHYS + 0x800 + DM9000_USE_NAND_CS*0x100 + 0x8)
1790 #define DM9000_DATA_ADDR (RK2818_NANDC_PHYS + 0x800 + DM9000_USE_NAND_CS*0x100 + 0x4)
1791
1792 static int dm9k_gpio_set(void)
1793 {
1794         //cs
1795         rk2818_mux_api_set(DM9000_CS_IOMUX_NAME, DM9000_CS_IOMUX_MODE);
1796         //int
1797         rk2818_mux_api_set(DM9000_INT_IOMUX_NAME, DM9000_INT_IOMUX_MODE);
1798                 
1799         return 0;
1800 }
1801 static int dm9k_gpio_free(void)
1802 {
1803         rk2818_mux_api_mode_resume(DM9000_INT_IOMUX_NAME);
1804         rk2818_mux_api_mode_resume(DM9000_CS_IOMUX_NAME);
1805         return 0;
1806 }
1807
1808 static struct resource dm9k_resource[] = {
1809         [0] = {
1810                 .start = DM9000_IO_ADDR,    
1811                 .end   = DM9000_IO_ADDR + 3,
1812                 .flags = IORESOURCE_MEM,
1813         },
1814         [1] = {
1815                 .start = DM9000_DATA_ADDR,      
1816                 .end   = DM9000_DATA_ADDR + 3,
1817                 .flags = IORESOURCE_MEM,
1818         },
1819         [2] = {
1820                 .start = DM9000_NET_INT_PIN,
1821                 .end   = DM9000_NET_INT_PIN,
1822                 .flags = IORESOURCE_IRQ | DM9000_IRQ,
1823         }
1824
1825 };
1826
1827 /* for the moment we limit ourselves to 8bit IO until some
1828  * better IO routines can be written and tested
1829 */
1830 struct dm9000_plat_data dm9k_platdata = {       
1831         .flags = DM9000_PLATF_8BITONLY,
1832         .irq_pin = DM9000_NET_INT_PIN,
1833         .irq_pin_value = DM9000_INT_INIT_VALUE,
1834         .io_init = dm9k_gpio_set,
1835         .io_deinit = dm9k_gpio_free,
1836 };
1837
1838 struct platform_device rk2818_device_dm9k = {
1839         .name           = "dm9000",
1840         .id             = 0,
1841         .num_resources  = ARRAY_SIZE(dm9k_resource),
1842         .resource       = dm9k_resource,
1843         .dev            = {
1844                 .platform_data = &dm9k_platdata,
1845         }
1846 };
1847 #endif
1848
1849 #ifdef CONFIG_HEADSET_DET
1850 struct rk2818_headset_data rk2818_headset_info = {
1851         .irq            = FPGA_PIO0_00,
1852         .irq_type       = IRQF_TRIGGER_FALLING,
1853         .headset_in_type= HEADSET_IN_HIGH,
1854 };
1855
1856 struct platform_device rk28_device_headset = {
1857                 .name   = "rk2818_headsetdet",
1858                 .id     = 0,
1859                 .dev    = {
1860                     .platform_data = &rk2818_headset_info,
1861                 }
1862 };
1863 #endif
1864
1865 #ifdef CONFIG_INPUT_LPSENSOR_CM3602 
1866 static int capella_cm3602_power(int on);
1867
1868 static struct capella_cm3602_platform_data capella_cm3602_pdata = {     
1869         .power = capella_cm3602_power,
1870         .irq_pin = FPGA_PIO0_04,
1871         .pwd_out_pin = FPGA_PIO4_07,
1872         .ps_shutdown_pin = FPGA_PIO5_00,
1873         //.p_out = MAHIMAHI_GPIO_PROXIMITY_INT_N
1874         };
1875
1876 static int capella_cm3602_power(int on)
1877 {       /* TODO eolsen Add Voltage reg control */       
1878     if (on) {           
1879         printk("[%s]:on---\n",__FUNCTION__);
1880        gpio_direction_output(capella_cm3602_pdata.pwd_out_pin, SPI_GPIO_LOW);
1881         gpio_direction_output(capella_cm3602_pdata.ps_shutdown_pin, SPI_GPIO_LOW);  
1882     }
1883     else {
1884             printk("[%s]:off---\n",__FUNCTION__);
1885        gpio_direction_output(capella_cm3602_pdata.pwd_out_pin, SPI_GPIO_HIGH);
1886         gpio_direction_output(capella_cm3602_pdata.ps_shutdown_pin, SPI_GPIO_HIGH);  
1887     }   
1888     return 0;
1889 }
1890
1891 struct platform_device rk2818_device_cm3605 = { 
1892             .name = CAPELLA_CM3602,
1893                 .id = -1,
1894                 .dev = {                
1895                 .platform_data = &capella_cm3602_pdata  
1896                         }
1897         };
1898 #endif
1899
1900 /*****************************************************************************************
1901  * nand flash devices
1902  * author: hxy@rock-chips.com
1903  *****************************************************************************************/
1904 /*
1905 GPIOA5_FLASHCS1_SEL_NAME,   IOMUXB_FLASH_CS1
1906 GPIOA6_FLASHCS2_SEL_NAME,   IOMUXB_FLASH_CS2
1907 GPIOA7_FLASHCS3_SEL_NAME,   IOMUXB_FLASH_CS3
1908 GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45  
1909 GPIOE_SPI1_FLASH_SEL_NAME,  IOMUXA_FLASH_CS67  
1910 */
1911
1912 #define NAND_CS_MAX_NUM     1  /*form 0 to 8, it is 0 when no nand flash */
1913
1914 int rk2818_nand_io_init(void)
1915 {
1916 #if (NAND_CS_MAX_NUM == 2)
1917     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
1918 #elif (NAND_CS_MAX_NUM == 3)
1919     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
1920     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
1921 #elif (NAND_CS_MAX_NUM == 4)
1922     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
1923     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
1924     rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
1925 #elif ((NAND_CS_MAX_NUM == 5) || (NAND_CS_MAX_NUM == 6))
1926     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
1927     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
1928     rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
1929     rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45);  
1930 #elif ((NAND_CS_MAX_NUM == 7) || (NAND_CS_MAX_NUM == 8))
1931     rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
1932     rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
1933     rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
1934     rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45);  
1935     rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL_NAME, IOMUXA_FLASH_CS67);  
1936 #endif
1937     return 0;
1938 }
1939
1940 struct rk2818_nand_platform_data rk2818_nand_data = {
1941     .width      = 1,     /* data bus width in bytes */
1942     .hw_ecc     = 1,     /* hw ecc 0: soft ecc */
1943     .num_flash    = 1,
1944     .io_init   = rk2818_nand_io_init,
1945 };
1946
1947
1948 /********************usb*********************/
1949 struct usb_mass_storage_platform_data mass_storage_pdata = {
1950         .nluns          = 1,
1951         .vendor         = "RockChip",
1952         .product        = "rk2818 sdk",
1953         .release        = 0x0100,
1954 };
1955
1956
1957
1958 static struct platform_device *devices[] __initdata = {
1959 #ifdef CONFIG_BT
1960         &raho_rfkill,
1961 #endif
1962 #ifdef CONFIG_UART0_RK2818
1963         &rk2818_device_uart0,
1964 #endif  
1965 #ifdef CONFIG_UART1_RK2818      
1966         &rk2818_device_uart1,
1967 #endif  
1968 #ifdef CONFIG_I2C0_RK2818
1969         &rk2818_device_i2c0,
1970 #endif
1971 #ifdef CONFIG_I2C1_RK2818
1972         &rk2818_device_i2c1,
1973 #endif
1974 #ifdef CONFIG_SDMMC0_RK2818     
1975         &rk2818_device_sdmmc0,
1976 #endif
1977 #ifdef CONFIG_SDMMC1_RK2818
1978         &rk2818_device_sdmmc1,
1979 #endif
1980         &raho_wifi_device,
1981         &rk2818_device_spim,
1982         &rk2818_device_i2s,
1983 #if defined(CONFIG_ANDROID_PMEM)
1984         &rk2818_device_pmem,
1985         &rk2818_device_pmem_dsp,
1986 #endif
1987         &rk2818_device_adc,
1988         &rk2818_device_adckey,
1989 #if defined(CONFIG_RK2818_REGULATOR_CHARGE)
1990         &power_supply,
1991         &charge_current,
1992 #endif
1993         &rk2818_device_battery,
1994     &rk2818_device_fb,    
1995     &rk2818_device_backlight,
1996         &rk2818_device_dsp,
1997
1998 #ifdef CONFIG_VIDEO_RK2818
1999         &rk2818_device_camera,      /* ddl@rock-chips.com : camera support  */
2000         &rk2818_soc_camera_pdrv,
2001  #endif
2002  
2003 #ifdef CONFIG_MTD_NAND_RK2818
2004         &rk2818_nand_device,
2005 #endif
2006 #ifdef CONFIG_DM9000
2007         &rk2818_device_dm9k,
2008 #endif
2009 #ifdef CONFIG_INPUT_LPSENSOR_CM3602 
2010     &rk2818_device_cm3605,
2011 #endif
2012 #ifdef CONFIG_HEADSET_DET
2013     &rk28_device_headset,
2014 #endif
2015 #ifdef CONFIG_DWC_OTG
2016         &rk2818_device_dwc_otg,
2017 #endif
2018 #ifdef CONFIG_RK2818_HOST11
2019         &rk2818_device_host11,
2020 #endif
2021 #ifdef CONFIG_USB_ANDROID
2022         &android_usb_device,
2023         &usb_mass_storage_device,
2024 #endif
2025 #ifdef CONFIG_ANDROID_TIMED_GPIO
2026         &rk28_device_vibrator,
2027 #endif
2028 };
2029
2030 extern struct sys_timer rk2818_timer;
2031 #define POWER_PIN       RK2818_PIN_PB1
2032 static void rk2818_power_on(void)
2033 {
2034         int ret;
2035         ret = gpio_request(POWER_PIN, NULL);
2036         if (ret) {
2037                 printk("failed to request power_off gpio\n");
2038                 goto err_free_gpio;
2039         }
2040
2041         gpio_pull_updown(POWER_PIN, GPIOPullUp);
2042         ret = gpio_direction_output(POWER_PIN, GPIO_HIGH);
2043         if (ret) {
2044                 printk("failed to set power_off gpio output\n");
2045                 goto err_free_gpio;
2046         }
2047
2048         gpio_set_value(POWER_PIN, 1);/*power on*/
2049         
2050 err_free_gpio:
2051         gpio_free(POWER_PIN);
2052 }
2053
2054 static void rk2818_power_off(void)
2055 {
2056         printk("shut down system now ...\n");
2057         gpio_set_value(POWER_PIN, 0);/*power down*/
2058 }
2059
2060 //      adc      ---> key       
2061 #define PLAY_ON_PIN RK2818_PIN_PA3
2062 #define PLAY_ON_LEVEL 1
2063 static  ADC_keyst gAdcValueTab[] = 
2064 {
2065         {0x65,  AD2KEY1},///VOLUME_DOWN
2066         {0xd3,  AD2KEY2},///VOLUME_UP
2067         {0x130, AD2KEY3},///MENU
2068         {0x19d, AD2KEY4},///HOME
2069         {0x202, AD2KEY5},///BACK
2070         {0x2d0, AD2KEY6},///CALL
2071         {0x267, AD2KEY7},///SEARCH
2072         {0,     0}///table end
2073 };
2074
2075 static unsigned char gInitKeyCode[] = 
2076 {
2077         AD2KEY1,AD2KEY2,AD2KEY3,AD2KEY4,AD2KEY5,AD2KEY6,AD2KEY7,
2078         ENDCALL,KEYSTART,KEY_WAKEUP,
2079 };
2080
2081 struct adc_key_data rk2818_adc_key = {
2082     .pin_playon     = PLAY_ON_PIN,
2083     .playon_level   = PLAY_ON_LEVEL,
2084     .adc_empty      = 1000,
2085     .adc_invalid    = 20,
2086     .adc_drift      = 50,
2087     .adc_chn        = 1,
2088     .adc_key_table  = gAdcValueTab,
2089     .initKeyCode    = gInitKeyCode,
2090     .adc_key_cnt    = 10,
2091 };
2092
2093 struct rk2818_adckey_platform_data rk2818_adckey_platdata = {
2094         .adc_key = &rk2818_adc_key,
2095 };
2096
2097 #if CONFIG_ANDROID_TIMED_GPIO
2098 static struct timed_gpio timed_gpios[] = {
2099         {
2100                 .name = "vibrator",
2101                 .gpio = FPGA_PIO1_12,
2102                 .max_timeout = 1000,
2103                 .active_low = 1,
2104         },
2105 };
2106
2107 struct timed_gpio_platform_data rk28_vibrator_info = {
2108         .num_gpios = 1,
2109         .gpios = timed_gpios,
2110 };
2111 #endif
2112 #if defined (CONFIG_RK2818_SOC_PM)
2113 void __tcmfunc rk2818_pm_scu_suspend(unsigned int *reg,int regoff)
2114 {
2115
2116         switch(regoff)
2117         {
2118                 case PM_SCU_CLKGATE0_CON:
2119                         {
2120                         }
2121
2122
2123         }
2124                 
2125 }
2126
2127
2128
2129 void __tcmfunc rk2818_soc_general_reg_suspend(void)
2130 {
2131         struct rk2818_pm_soc_st *general=rk2818_soc_pm.general;
2132         
2133         unsigned int *general_reg_addr=general->reg_base_addr;
2134         #if 1
2135         general->reg_ctrbit|=(0x1<<PM_GPIO0_AB_PU_CON);
2136         general_reg_addr[PM_GPIO0_AB_PU_CON] =GPIO0_AB_NORMAL;
2137         
2138         general->reg_ctrbit|=(0x1<<PM_GPIO0_CD_PU_CON);
2139         general_reg_addr[PM_GPIO0_CD_PU_CON] = GPIO0_CD_NORMAL;
2140         
2141         general->reg_ctrbit|=(0x1<<PM_GPIO1_AB_PU_CON);
2142         general_reg_addr[PM_GPIO1_AB_PU_CON] = GPIO1_AB_NORMAL;
2143         
2144         general->reg_ctrbit|=(0x1<<PM_GPIO1_CD_PU_CON);
2145         general_reg_addr[PM_GPIO1_CD_PU_CON] = GPIO1_CD_NORMAL;
2146         #endif
2147         
2148         general->reg_ctrbit|=(0x1<<PM_IOMUX_A_CON);
2149         general->reg_ctrbit|=(0x1<<PM_IOMUX_B_CON);
2150
2151         rk2818_socpm_gpio_pullupdown(RK2818_PIN_PA3,GPIOPullDown);// ´¦Àí°´¼ü
2152
2153         #if 1  //set uart0 pin
2154                 
2155                 general_reg_addr[PM_IOMUX_A_CON] &=(~(0x3<<PM_UART0_OUT))&(~(0x3<<PM_UART0_IN));// 00 gpio 01uart
2156                 general_reg_addr[PM_IOMUX_B_CON] &=(~(0x1<<PM_UART0_RTS))&(~(0x1<<PM_UART0_CTS));//
2157                 rk2818_socpm_set_gpio(RK2818_PIN_PG0,0,0);//uart0 sin pin
2158                 rk2818_socpm_set_gpio(RK2818_PIN_PG1,0,0);//uart0 sout pin
2159                 
2160                 rk2818_socpm_set_gpio(RK2818_PIN_PG0,0,0);//uart0 sin pin
2161                 rk2818_socpm_set_gpio(RK2818_PIN_PG1,0,0);//uart0 sout pin
2162
2163                 rk2818_socpm_set_gpio(RK2818_PIN_PB2,0,0);//uart0 cts pin
2164                 rk2818_socpm_set_gpio(RK2818_PIN_PB3,0,0);//uart0 rts pin
2165
2166                 rk2818_socpm_set_gpio(RK2818_PIN_PF7,0,0);//uart0 dtr pin
2167                 rk2818_socpm_set_gpio(RK2818_PIN_PC5,0,0);//uart0 dsr pin
2168
2169                 
2170         #endif
2171
2172         #if 1  //set uart1 pin
2173                 
2174                 general_reg_addr[PM_IOMUX_A_CON] &=(~(0x3<<PM_UART1_OUT))&(~(0x3<<PM_UART1_IN));// 00 gpio 01uart
2175                 rk2818_socpm_set_gpio(RK2818_PIN_PF0,0,0);//uart0 sin pin
2176                 rk2818_socpm_set_gpio(RK2818_PIN_PG1,0,0);//uart0 sout pin
2177         #endif
2178
2179
2180         #if 1  //set i2c0 pin
2181                 general_reg_addr[PM_IOMUX_A_CON] |=(0x1<<PM_I2C0);// 1 gpio;0 i2c
2182                 rk2818_socpm_set_gpio(RK2818_PIN_PE4,0,0);//sda pin
2183                 rk2818_socpm_set_gpio(RK2818_PIN_PE5,0,0);//scl dsr pin
2184         #endif
2185
2186         #if 1  //set i2c1 pin
2187                 general_reg_addr[PM_IOMUX_A_CON] &=(~(0x3<<PM_I2C1));// 0 gpio;1 i2c
2188                 rk2818_socpm_set_gpio(RK2818_PIN_PE6,0,0);//sda pin
2189                 rk2818_socpm_set_gpio(RK2818_PIN_PE7,0,0);//scl dsr pin
2190         #endif
2191         #if 1  // sdio0
2192
2193                 general_reg_addr[PM_IOMUX_A_CON] &=(~(0x1<<PM_SDIO0_CMD))&(~(0x1<<PM_SDIO0_DATA));// 1 gpio;0 i2c
2194                 rk2818_socpm_set_gpio(RK2818_PIN_PH0,0,0);
2195                 rk2818_socpm_set_gpio(RK2818_PIN_PH1,0,0);
2196                 rk2818_socpm_set_gpio(RK2818_PIN_PH2,0,0);
2197                 rk2818_socpm_set_gpio(RK2818_PIN_PH3,0,0);
2198                 rk2818_socpm_set_gpio(RK2818_PIN_PH4,0,0);
2199                 rk2818_socpm_set_gpio(RK2818_PIN_PH5,0,0);
2200
2201                 //rk2818_socpm_set_gpio(RK2818_PIN_PF3,0,0);
2202
2203
2204         #endif
2205         #if 1 // sdio1
2206                 general_reg_addr[PM_IOMUX_A_CON] &=(~(0x1<<PM_SDIO1_CMD))&(~(0x1<<PM_SDIO1_DATA));// 1 gpio;0 i2c
2207                 rk2818_socpm_set_gpio(RK2818_PIN_PG2,0,0);
2208                 rk2818_socpm_set_gpio(RK2818_PIN_PG3,0,0);
2209                 rk2818_socpm_set_gpio(RK2818_PIN_PG4,0,0);
2210                 rk2818_socpm_set_gpio(RK2818_PIN_PG5,0,0);
2211                 rk2818_socpm_set_gpio(RK2818_PIN_PG6,0,0);
2212                 rk2818_socpm_set_gpio(RK2818_PIN_PG7,0,0);
2213         #endif
2214 }
2215 void __tcmfunc rk2818_pm_set_vol(void)
2216 {
2217         rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,0);
2218 }
2219 void __tcmfunc rk2818_pm_resume_vol(void)
2220 {
2221         rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,1);
2222 }
2223 #else
2224 #define pm_set_general_cpu_reg(a)
2225 #define rk2818_pm_set_vol()
2226 #define rk2818_pm_resume_vol()
2227 #endif
2228 static void __init machine_rk2818_init_irq(void)
2229 {
2230         rk2818_init_irq();
2231         rk2818_gpio_init(rk2818_gpioBank, 8);
2232         rk2818_gpio_irq_setup();
2233 }
2234
2235 static void __init machine_rk2818_board_init(void)
2236 {       
2237         printk("3x machine_rk2818_board_init\n");
2238         
2239         rk2818_socpm_int( (pm_scu_suspend) rk2818_pm_scu_suspend,(pm_general_reg_suspend) rk2818_soc_general_reg_suspend,
2240         (pm_set_suspendvol) rk2818_pm_set_vol,(pm_resume_vol) rk2818_pm_resume_vol);
2241         rk2818_power_on();
2242         pm_power_off = rk2818_power_off;
2243 #ifdef CONFIG_SPI_FPGA_FW
2244         fpga_dl_fw();
2245 #endif
2246 #ifdef CONFIG_I2C0_RK2818
2247         i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2248                         ARRAY_SIZE(board_i2c0_devices));
2249 #endif
2250 #ifdef CONFIG_I2C1_RK2818
2251         i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2252                         ARRAY_SIZE(board_i2c1_devices));
2253 #endif
2254 #ifdef CONFIG_SPI_FPGA_I2C
2255         i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2256                         ARRAY_SIZE(board_i2c2_devices));
2257         i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2258                         ARRAY_SIZE(board_i2c3_devices));
2259 #endif
2260         platform_add_devices(devices, ARRAY_SIZE(devices));     
2261         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2262
2263     rk2818_mux_api_set(GPIOC_LCDC24BIT_SEL_NAME, 0);
2264     rk2818_mux_api_set(GPIOA1_HOSTDATA17_SEL_NAME, IOMUXB_GPIO0_A1);
2265         
2266         rk2818_lcd_reset();
2267 }
2268
2269 static void __init machine_rk2818_mapio(void)
2270 {
2271         iotable_init(rk2818_io_desc, ARRAY_SIZE(rk2818_io_desc));
2272         rk2818_clock_init();
2273         rk2818_iomux_init();    
2274 }
2275
2276 MACHINE_START(RK2818, "RK28board")
2277
2278 /* UART for LL DEBUG */
2279         .phys_io        = 0x18002000,
2280         .io_pg_offst    = ((0xFF100000) >> 18) & 0xfffc,
2281         .boot_params    = RK2818_SDRAM_PHYS + 0xf8000,
2282         .map_io         = machine_rk2818_mapio,
2283         .init_irq       = machine_rk2818_init_irq,
2284         .init_machine   = machine_rk2818_board_init,
2285         .timer          = &rk2818_timer,
2286 MACHINE_END
2287