dc753d662cff4d84d73c885652d2bb1ea4247c33
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / board-rk30-sdk.c
1 /* arch/arm/mach-rk30/board-rk30-sdk.c
2  *
3  * Copyright (C) 2012 ROCKCHIP, Inc.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #include <linux/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/skbuff.h>
24 #include <linux/spi/spi.h>
25 #include <linux/mmc/host.h>
26 #include <linux/ion.h>
27 #include <linux/cpufreq.h>
28 #include <linux/clk.h>
29 #include <mach/dvfs.h>
30
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
37
38 #include <mach/board.h>
39 #include <mach/hardware.h>
40 #include <mach/io.h>
41 #include <mach/gpio.h>
42 #include <mach/iomux.h>
43 #include <linux/fb.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/rfkill-rk.h>
46 #include <linux/sensor-dev.h>
47 #if defined(CONFIG_HDMI_RK30)
48         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
49 #endif
50
51 #if defined(CONFIG_SPIM_RK29)
52 #include "../../../drivers/spi/rk29_spim.h"
53 #endif
54 #if defined(CONFIG_MU509)
55 #include <linux/mu509.h>
56 #endif
57 #if defined(CONFIG_MW100)
58 #include <linux/mw100.h>
59 #endif
60 #if defined(CONFIG_MT6229)
61 #include <linux/mt6229.h>
62 #endif
63 #if defined(CONFIG_SEW868)
64 #include <linux/sew868.h>
65 #endif
66 #if defined(CONFIG_ANDROID_TIMED_GPIO)
67 #include "../../../drivers/staging/android/timed_gpio.h"
68 #endif
69
70 #if defined(CONFIG_MT6620)
71 #include <linux/gps.h>
72 #endif
73
74 #ifdef  CONFIG_THREE_FB_BUFFER
75 #define RK30_FB0_MEM_SIZE 12*SZ_1M
76 #else
77 #define RK30_FB0_MEM_SIZE 8*SZ_1M
78 #endif
79
80 #ifdef CONFIG_VIDEO_RK29
81 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
82 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
83 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642                                          /* back camera sensor */
84 #define CONFIG_SENSOR_IIC_ADDR_0                0x78
85 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    4
86 #define CONFIG_SENSOR_CIF_INDEX_0                    1
87 #define CONFIG_SENSOR_ORIENTATION_0       90
88 #define CONFIG_SENSOR_POWER_PIN_0                 INVALID_GPIO
89 #define CONFIG_SENSOR_RESET_PIN_0                 INVALID_GPIO
90 #define CONFIG_SENSOR_POWERDN_PIN_0       RK30_PIN1_PD6
91 #define CONFIG_SENSOR_FALSH_PIN_0                 INVALID_GPIO
92 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
93 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
94 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
95 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
96
97 #define CONFIG_SENSOR_QCIF_FPS_FIXED_0          15000
98 #define CONFIG_SENSOR_240X160_FPS_FIXED_0   15000
99 #define CONFIG_SENSOR_QVGA_FPS_FIXED_0          15000
100 #define CONFIG_SENSOR_CIF_FPS_FIXED_0           15000
101 #define CONFIG_SENSOR_VGA_FPS_FIXED_0           15000
102 #define CONFIG_SENSOR_480P_FPS_FIXED_0          15000
103 #define CONFIG_SENSOR_SVGA_FPS_FIXED_0          15000
104 #define CONFIG_SENSOR_720P_FPS_FIXED_0          30000
105
106 #define CONFIG_SENSOR_01  RK29_CAM_SENSOR_OV5642                   /* back camera sensor 1 */
107 #define CONFIG_SENSOR_IIC_ADDR_01           0x00
108 #define CONFIG_SENSOR_CIF_INDEX_01                    1
109 #define CONFIG_SENSOR_IIC_ADAPTER_ID_01    4
110 #define CONFIG_SENSOR_ORIENTATION_01       90
111 #define CONFIG_SENSOR_POWER_PIN_01         INVALID_GPIO
112 #define CONFIG_SENSOR_RESET_PIN_01         INVALID_GPIO
113 #define CONFIG_SENSOR_POWERDN_PIN_01       RK30_PIN1_PD6
114 #define CONFIG_SENSOR_FALSH_PIN_01         INVALID_GPIO
115 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_01 RK29_CAM_POWERACTIVE_L
116 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_01 RK29_CAM_RESETACTIVE_L
117 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_01 RK29_CAM_POWERDNACTIVE_H
118 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_01 RK29_CAM_FLASHACTIVE_L
119
120 #define CONFIG_SENSOR_QCIF_FPS_FIXED_01      15000
121 #define CONFIG_SENSOR_240X160_FPS_FIXED_01   15000
122 #define CONFIG_SENSOR_QVGA_FPS_FIXED_01      15000
123 #define CONFIG_SENSOR_CIF_FPS_FIXED_01       15000
124 #define CONFIG_SENSOR_VGA_FPS_FIXED_01       15000
125 #define CONFIG_SENSOR_480P_FPS_FIXED_01      15000
126 #define CONFIG_SENSOR_SVGA_FPS_FIXED_01      15000
127 #define CONFIG_SENSOR_720P_FPS_FIXED_01     30000
128
129 #define CONFIG_SENSOR_02 RK29_CAM_SENSOR_OV5640                      /* back camera sensor 2 */
130 #define CONFIG_SENSOR_IIC_ADDR_02           0x00
131 #define CONFIG_SENSOR_CIF_INDEX_02                    1
132 #define CONFIG_SENSOR_IIC_ADAPTER_ID_02    4
133 #define CONFIG_SENSOR_ORIENTATION_02       90
134 #define CONFIG_SENSOR_POWER_PIN_02         INVALID_GPIO
135 #define CONFIG_SENSOR_RESET_PIN_02         INVALID_GPIO
136 #define CONFIG_SENSOR_POWERDN_PIN_02       RK30_PIN1_PD6
137 #define CONFIG_SENSOR_FALSH_PIN_02         INVALID_GPIO
138 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_02 RK29_CAM_POWERACTIVE_L
139 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_02 RK29_CAM_RESETACTIVE_L
140 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_02 RK29_CAM_POWERDNACTIVE_H
141 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_02 RK29_CAM_FLASHACTIVE_L
142
143 #define CONFIG_SENSOR_QCIF_FPS_FIXED_02      15000
144 #define CONFIG_SENSOR_240X160_FPS_FIXED_02   15000
145 #define CONFIG_SENSOR_QVGA_FPS_FIXED_02      15000
146 #define CONFIG_SENSOR_CIF_FPS_FIXED_02       15000
147 #define CONFIG_SENSOR_VGA_FPS_FIXED_02       15000
148 #define CONFIG_SENSOR_480P_FPS_FIXED_02      15000
149 #define CONFIG_SENSOR_SVGA_FPS_FIXED_02      15000
150 #define CONFIG_SENSOR_720P_FPS_FIXED_02      30000
151
152 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659                      /* front camera sensor 0 */
153 #define CONFIG_SENSOR_IIC_ADDR_1            0x60
154 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    3
155 #define CONFIG_SENSOR_CIF_INDEX_1                                 0
156 #define CONFIG_SENSOR_ORIENTATION_1       270
157 #define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
158 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
159 #define CONFIG_SENSOR_POWERDN_PIN_1       RK30_PIN1_PB7
160 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
161 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
162 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
163 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
164 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
165
166 #define CONFIG_SENSOR_QCIF_FPS_FIXED_1          15000
167 #define CONFIG_SENSOR_240X160_FPS_FIXED_1   15000
168 #define CONFIG_SENSOR_QVGA_FPS_FIXED_1          15000
169 #define CONFIG_SENSOR_CIF_FPS_FIXED_1           15000
170 #define CONFIG_SENSOR_VGA_FPS_FIXED_1           15000
171 #define CONFIG_SENSOR_480P_FPS_FIXED_1          15000
172 #define CONFIG_SENSOR_SVGA_FPS_FIXED_1          15000
173 #define CONFIG_SENSOR_720P_FPS_FIXED_1          30000
174
175 #define CONFIG_SENSOR_11 RK29_CAM_SENSOR_OV2659                      /* front camera sensor 1 */
176 #define CONFIG_SENSOR_IIC_ADDR_11           0x00
177 #define CONFIG_SENSOR_IIC_ADAPTER_ID_11    3
178 #define CONFIG_SENSOR_CIF_INDEX_11                                0
179 #define CONFIG_SENSOR_ORIENTATION_11       270
180 #define CONFIG_SENSOR_POWER_PIN_11         INVALID_GPIO
181 #define CONFIG_SENSOR_RESET_PIN_11         INVALID_GPIO
182 #define CONFIG_SENSOR_POWERDN_PIN_11       INVALID_GPIO//RK30_PIN1_PB7
183 #define CONFIG_SENSOR_FALSH_PIN_11         INVALID_GPIO
184 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_11 RK29_CAM_POWERACTIVE_L
185 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_11 RK29_CAM_RESETACTIVE_L
186 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_11 RK29_CAM_POWERDNACTIVE_H
187 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_11 RK29_CAM_FLASHACTIVE_L
188
189 #define CONFIG_SENSOR_QCIF_FPS_FIXED_11      15000
190 #define CONFIG_SENSOR_240X160_FPS_FIXED_11   15000
191 #define CONFIG_SENSOR_QVGA_FPS_FIXED_11      15000
192 #define CONFIG_SENSOR_CIF_FPS_FIXED_11       15000
193 #define CONFIG_SENSOR_VGA_FPS_FIXED_11       15000
194 #define CONFIG_SENSOR_480P_FPS_FIXED_11      15000
195 #define CONFIG_SENSOR_SVGA_FPS_FIXED_11      15000
196 #define CONFIG_SENSOR_720P_FPS_FIXED_11      30000
197
198 #define CONFIG_SENSOR_12 RK29_CAM_SENSOR_OV2659//RK29_CAM_SENSOR_OV2655                      /* front camera sensor 2 */
199 #define CONFIG_SENSOR_IIC_ADDR_12          0x00
200 #define CONFIG_SENSOR_IIC_ADAPTER_ID_12    3
201 #define CONFIG_SENSOR_CIF_INDEX_12                                0
202 #define CONFIG_SENSOR_ORIENTATION_12       270
203 #define CONFIG_SENSOR_POWER_PIN_12         INVALID_GPIO
204 #define CONFIG_SENSOR_RESET_PIN_12         INVALID_GPIO
205 #define CONFIG_SENSOR_POWERDN_PIN_12       INVALID_GPIO//RK30_PIN1_PB7
206 #define CONFIG_SENSOR_FALSH_PIN_12         INVALID_GPIO
207 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_12 RK29_CAM_POWERACTIVE_L
208 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_12 RK29_CAM_RESETACTIVE_L
209 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_12 RK29_CAM_POWERDNACTIVE_H
210 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_12 RK29_CAM_FLASHACTIVE_L
211
212 #define CONFIG_SENSOR_QCIF_FPS_FIXED_12      15000
213 #define CONFIG_SENSOR_240X160_FPS_FIXED_12   15000
214 #define CONFIG_SENSOR_QVGA_FPS_FIXED_12      15000
215 #define CONFIG_SENSOR_CIF_FPS_FIXED_12       15000
216 #define CONFIG_SENSOR_VGA_FPS_FIXED_12       15000
217 #define CONFIG_SENSOR_480P_FPS_FIXED_12      15000
218 #define CONFIG_SENSOR_SVGA_FPS_FIXED_12      15000
219 #define CONFIG_SENSOR_720P_FPS_FIXED_12      30000
220
221
222 #endif  //#ifdef CONFIG_VIDEO_RK29
223 /*---------------- Camera Sensor Configuration Macro End------------------------*/
224 #include "../../../drivers/media/video/rk30_camera.c"
225 /*---------------- Camera Sensor Macro Define End  ---------*/
226
227 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
228 /*****************************************************************************************
229  * camera  devices
230  * author: ddl@rock-chips.com
231  *****************************************************************************************/
232 #ifdef CONFIG_VIDEO_RK29
233 #define CONFIG_SENSOR_POWER_IOCTL_USR      1 //define this refer to your board layout
234 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
235 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR          0
236 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
237
238 static void rk_cif_power(int on)
239 {
240     struct regulator *ldo_18,*ldo_28;
241         ldo_28 = regulator_get(NULL, "ldo7");   // vcc28_cif
242         ldo_18 = regulator_get(NULL, "ldo1");   // vcc18_cif
243         if (ldo_28 == NULL || IS_ERR(ldo_28) || ldo_18 == NULL || IS_ERR(ldo_18)){
244         printk("get cif ldo failed!\n");
245                 return;
246             }
247     if(on == 0){        
248         regulator_disable(ldo_28);
249         regulator_put(ldo_28);
250         regulator_disable(ldo_18);
251         regulator_put(ldo_18);
252         mdelay(500);
253         }
254     else{
255         regulator_set_voltage(ldo_28, 2800000, 2800000);
256         regulator_enable(ldo_28);
257    //   printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28));
258         regulator_put(ldo_28);
259
260         regulator_set_voltage(ldo_18, 1800000, 1800000);
261     //  regulator_set_suspend_voltage(ldo, 1800000);
262         regulator_enable(ldo_18);
263     //  printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_18));
264         regulator_put(ldo_18);
265         }
266 }
267
268 #if CONFIG_SENSOR_POWER_IOCTL_USR
269 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
270 {
271         //#error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
272     rk_cif_power(on);
273 }
274 #endif
275
276 #if CONFIG_SENSOR_RESET_IOCTL_USR
277 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
278 {
279         #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
280 }
281 #endif
282
283 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
284 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
285 {
286         #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
287 }
288 #endif
289
290 #if CONFIG_SENSOR_FLASH_IOCTL_USR
291 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
292 {
293         #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
294 }
295 #endif
296
297 static struct rk29camera_platform_ioctl_cb      sensor_ioctl_cb = {
298         #if CONFIG_SENSOR_POWER_IOCTL_USR
299         .sensor_power_cb = sensor_power_usr_cb,
300         #else
301         .sensor_power_cb = NULL,
302         #endif
303
304         #if CONFIG_SENSOR_RESET_IOCTL_USR
305         .sensor_reset_cb = sensor_reset_usr_cb,
306         #else
307         .sensor_reset_cb = NULL,
308         #endif
309
310         #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
311         .sensor_powerdown_cb = sensor_powerdown_usr_cb,
312         #else
313         .sensor_powerdown_cb = NULL,
314         #endif
315
316         #if CONFIG_SENSOR_FLASH_IOCTL_USR
317         .sensor_flash_cb = sensor_flash_usr_cb,
318         #else
319         .sensor_flash_cb = NULL,
320         #endif
321 };
322
323 #if CONFIG_SENSOR_IIC_ADDR_0
324 static struct reginfo_t rk_init_data_sensor_reg_0[] =
325 {
326                 {0x0000, 0x00,0,0}
327         };
328 static struct reginfo_t rk_init_data_sensor_winseqreg_0[] ={
329         {0x0000, 0x00,0,0}
330         };
331 #endif
332
333 #if CONFIG_SENSOR_IIC_ADDR_1
334 static struct reginfo_t rk_init_data_sensor_reg_1[] =
335 {
336     {0x0000, 0x00,0,0}
337 };
338 static struct reginfo_t rk_init_data_sensor_winseqreg_1[] =
339 {
340        {0x0000, 0x00,0,0}
341 };
342 #endif
343 #if CONFIG_SENSOR_IIC_ADDR_01
344 static struct reginfo_t rk_init_data_sensor_reg_01[] =
345 {
346     {0x0000, 0x00,0,0}
347 };
348 static struct reginfo_t rk_init_data_sensor_winseqreg_01[] =
349 {
350        {0x0000, 0x00,0,0}
351 };
352 #endif
353 #if CONFIG_SENSOR_IIC_ADDR_02
354 static struct reginfo_t rk_init_data_sensor_reg_02[] =
355 {
356     {0x0000, 0x00,0,0}
357 };
358 static struct reginfo_t rk_init_data_sensor_winseqreg_02[] =
359 {
360        {0x0000, 0x00,0,0}
361 };
362 #endif
363 #if CONFIG_SENSOR_IIC_ADDR_11
364 static struct reginfo_t rk_init_data_sensor_reg_11[] =
365 {
366     {0x0000, 0x00,0,0}
367 };
368 static struct reginfo_t rk_init_data_sensor_winseqreg_11[] =
369 {
370        {0x0000, 0x00,0,0}
371 };
372 #endif
373 #if CONFIG_SENSOR_IIC_ADDR_12
374 static struct reginfo_t rk_init_data_sensor_reg_12[] =
375 {
376     {0x0000, 0x00,0,0}
377 };
378 static struct reginfo_t rk_init_data_sensor_winseqreg_12[] =
379 {
380        {0x0000, 0x00,0,0}
381 };
382 #endif
383 static rk_sensor_user_init_data_s rk_init_data_sensor[RK_CAM_NUM] = 
384 {
385     #if CONFIG_SENSOR_IIC_ADDR_0
386     {
387        .rk_sensor_init_width = INVALID_VALUE,
388        .rk_sensor_init_height = INVALID_VALUE,
389        .rk_sensor_init_bus_param = INVALID_VALUE,
390        .rk_sensor_init_pixelcode = INVALID_VALUE,
391        .rk_sensor_init_data = rk_init_data_sensor_reg_0,
392        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_0,
393        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_0) / sizeof(struct reginfo_t),
394        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_0) / sizeof(struct reginfo_t),
395     },
396     #else
397     {
398        .rk_sensor_init_width = INVALID_VALUE,
399        .rk_sensor_init_height = INVALID_VALUE,
400        .rk_sensor_init_bus_param = INVALID_VALUE,
401        .rk_sensor_init_pixelcode = INVALID_VALUE,
402        .rk_sensor_init_data = NULL,
403        .rk_sensor_init_winseq = NULL,
404        .rk_sensor_winseq_size = 0,
405        .rk_sensor_init_data_size = 0,
406     },
407     #endif
408     #if CONFIG_SENSOR_IIC_ADDR_1
409     {
410        .rk_sensor_init_width = INVALID_VALUE,
411        .rk_sensor_init_height = INVALID_VALUE,
412        .rk_sensor_init_bus_param = INVALID_VALUE,
413        .rk_sensor_init_pixelcode = INVALID_VALUE,
414        .rk_sensor_init_data = rk_init_data_sensor_reg_1,
415        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_1,
416        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_1) / sizeof(struct reginfo_t),
417        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_1) / sizeof(struct reginfo_t),
418     },
419     #else
420     {
421        .rk_sensor_init_width = INVALID_VALUE,
422        .rk_sensor_init_height = INVALID_VALUE,
423        .rk_sensor_init_bus_param = INVALID_VALUE,
424        .rk_sensor_init_pixelcode = INVALID_VALUE,
425        .rk_sensor_init_data = NULL,
426        .rk_sensor_init_winseq = NULL,
427        .rk_sensor_winseq_size = 0,
428        .rk_sensor_init_data_size = 0,
429     },
430     #endif
431     #if CONFIG_SENSOR_IIC_ADDR_01
432     {
433        .rk_sensor_init_width = INVALID_VALUE,
434        .rk_sensor_init_height = INVALID_VALUE,
435        .rk_sensor_init_bus_param = INVALID_VALUE,
436        .rk_sensor_init_pixelcode = INVALID_VALUE,
437        .rk_sensor_init_data = rk_init_data_sensor_reg_01,
438        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_01,
439        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_01) / sizeof(struct reginfo_t),
440        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_01) / sizeof(struct reginfo_t),
441     },
442     #else
443     {
444        .rk_sensor_init_width = INVALID_VALUE,
445        .rk_sensor_init_height = INVALID_VALUE,
446        .rk_sensor_init_bus_param = INVALID_VALUE,
447        .rk_sensor_init_pixelcode = INVALID_VALUE,
448        .rk_sensor_init_data = NULL,
449        .rk_sensor_init_winseq = NULL,
450        .rk_sensor_winseq_size = 0,
451        .rk_sensor_init_data_size = 0,
452     },
453     #endif
454     #if CONFIG_SENSOR_IIC_ADDR_02
455     {
456        .rk_sensor_init_width = INVALID_VALUE,
457        .rk_sensor_init_height = INVALID_VALUE,
458        .rk_sensor_init_bus_param = INVALID_VALUE,
459        .rk_sensor_init_pixelcode = INVALID_VALUE,
460        .rk_sensor_init_data = rk_init_data_sensor_reg_02,
461        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_02,
462        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_02) / sizeof(struct reginfo_t),
463        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_02) / sizeof(struct reginfo_t),
464     },
465     #else
466     {
467        .rk_sensor_init_width = INVALID_VALUE,
468        .rk_sensor_init_height = INVALID_VALUE,
469        .rk_sensor_init_bus_param = INVALID_VALUE,
470        .rk_sensor_init_pixelcode = INVALID_VALUE,
471        .rk_sensor_init_data = NULL,
472        .rk_sensor_init_winseq = NULL,
473        .rk_sensor_winseq_size = 0,
474        .rk_sensor_init_data_size = 0,
475     },
476     #endif
477     #if CONFIG_SENSOR_IIC_ADDR_11
478     {
479        .rk_sensor_init_width = INVALID_VALUE,
480        .rk_sensor_init_height = INVALID_VALUE,
481        .rk_sensor_init_bus_param = INVALID_VALUE,
482        .rk_sensor_init_pixelcode = INVALID_VALUE,
483        .rk_sensor_init_data = rk_init_data_sensor_reg_11,
484        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_11,
485        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_11) / sizeof(struct reginfo_t),
486        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_11) / sizeof(struct reginfo_t),
487     },
488     #else
489     {
490        .rk_sensor_init_width = INVALID_VALUE,
491        .rk_sensor_init_height = INVALID_VALUE,
492        .rk_sensor_init_bus_param = INVALID_VALUE,
493        .rk_sensor_init_pixelcode = INVALID_VALUE,
494        .rk_sensor_init_data = NULL,
495        .rk_sensor_init_winseq = NULL,
496        .rk_sensor_winseq_size = 0,
497        .rk_sensor_init_data_size = 0,
498     },
499     #endif
500     #if CONFIG_SENSOR_IIC_ADDR_12
501     {
502        .rk_sensor_init_width = INVALID_VALUE,
503        .rk_sensor_init_height = INVALID_VALUE,
504        .rk_sensor_init_bus_param = INVALID_VALUE,
505        .rk_sensor_init_pixelcode = INVALID_VALUE,
506        .rk_sensor_init_data = rk_init_data_sensor_reg_12,
507        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_12,
508        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_12) / sizeof(struct reginfo_t),
509        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_12) / sizeof(struct reginfo_t),
510     },
511     #else
512     {
513        .rk_sensor_init_width = INVALID_VALUE,
514        .rk_sensor_init_height = INVALID_VALUE,
515        .rk_sensor_init_bus_param = INVALID_VALUE,
516        .rk_sensor_init_pixelcode = INVALID_VALUE,
517        .rk_sensor_init_data = NULL,
518        .rk_sensor_init_winseq = NULL,
519        .rk_sensor_winseq_size = 0,
520        .rk_sensor_init_data_size = 0,
521     },
522     #endif
523
524  };
525 #include "../../../drivers/media/video/rk30_camera.c"
526
527 #endif /* CONFIG_VIDEO_RK29 */
528
529 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
530 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
531 #define TOUCH_PWR_PIN    INVALID_GPIO
532 int goodix_init_platform_hw(void)
533 {
534         int ret;
535         
536         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
537         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
538         printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
539
540         if (TOUCH_PWR_PIN != INVALID_GPIO) {
541                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
542                 if (ret != 0) {
543                         gpio_free(TOUCH_PWR_PIN);
544                         printk("goodix power error\n");
545                         return -EIO;
546                 }
547                 gpio_direction_output(TOUCH_PWR_PIN, 0);
548                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
549                 msleep(100);
550         }
551
552         if (TOUCH_RESET_PIN != INVALID_GPIO) {
553                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
554                 if (ret != 0) {
555                         gpio_free(TOUCH_RESET_PIN);
556                         printk("goodix gpio_request error\n");
557                         return -EIO;
558                 }
559                 gpio_direction_output(TOUCH_RESET_PIN, 1);
560                 msleep(100);
561                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
562                 //msleep(100);
563                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
564                 //msleep(500);
565         }
566         return 0;
567 }
568
569 struct goodix_platform_data goodix_info = {
570         .model = 8105,
571         .irq_pin = RK30_PIN4_PC2,
572         .rest_pin = TOUCH_RESET_PIN,
573         .init_platform_hw = goodix_init_platform_hw,
574 };
575 #endif
576
577 static struct spi_board_info board_spi_devices[] = {
578 };
579
580 /***********************************************************
581 *       rk30  backlight
582 ************************************************************/
583 #ifdef CONFIG_BACKLIGHT_RK29_BL
584 #define PWM_ID            0
585 #define PWM_MUX_NAME      GPIO0A3_PWM0_NAME
586 #define PWM_MUX_MODE      GPIO0A_PWM0
587 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
588 #define PWM_GPIO          RK30_PIN0_PA3
589 #define PWM_EFFECT_VALUE  1
590
591 #define LCD_DISP_ON_PIN
592
593 #ifdef  LCD_DISP_ON_PIN
594 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
595 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
596
597 #define BL_EN_PIN         RK30_PIN6_PB3
598 #define BL_EN_VALUE       GPIO_HIGH
599 #endif
600 static int rk29_backlight_io_init(void)
601 {
602         int ret = 0;
603         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
604 #ifdef  LCD_DISP_ON_PIN
605         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
606
607         ret = gpio_request(BL_EN_PIN, NULL);
608         if (ret != 0) {
609                 gpio_free(BL_EN_PIN);
610         }
611
612         gpio_direction_output(BL_EN_PIN, 0);
613         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
614 #endif
615         return ret;
616 }
617
618 static int rk29_backlight_io_deinit(void)
619 {
620         int ret = 0;
621 #ifdef  LCD_DISP_ON_PIN
622         gpio_free(BL_EN_PIN);
623 #endif
624         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
625         return ret;
626 }
627
628 static int rk29_backlight_pwm_suspend(void)
629 {
630         int ret = 0;
631         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
632         if (gpio_request(PWM_GPIO, NULL)) {
633                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
634                 return -1;
635         }
636         gpio_direction_output(PWM_GPIO, GPIO_LOW);
637 #ifdef  LCD_DISP_ON_PIN
638         gpio_direction_output(BL_EN_PIN, 0);
639         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
640 #endif
641         return ret;
642 }
643
644 static int rk29_backlight_pwm_resume(void)
645 {
646         gpio_free(PWM_GPIO);
647         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
648 #ifdef  LCD_DISP_ON_PIN
649         msleep(30);
650         gpio_direction_output(BL_EN_PIN, 1);
651         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
652 #endif
653         return 0;
654 }
655
656 static struct rk29_bl_info rk29_bl_info = {
657         .pwm_id = PWM_ID,
658         .bl_ref = PWM_EFFECT_VALUE,
659         .io_init = rk29_backlight_io_init,
660         .io_deinit = rk29_backlight_io_deinit,
661         .pwm_suspend = rk29_backlight_pwm_suspend,
662         .pwm_resume = rk29_backlight_pwm_resume,
663 };
664
665 static struct platform_device rk29_device_backlight = {
666         .name   = "rk29_backlight",
667         .id     = -1,
668         .dev    = {
669                 .platform_data  = &rk29_bl_info,
670         }
671 };
672
673 #endif
674
675 #ifdef CONFIG_RK29_SUPPORT_MODEM
676
677 #define RK30_MODEM_POWER        RK30_PIN4_PD1
678 #define RK30_MODEM_POWER_IOMUX  rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
679
680 static int rk30_modem_io_init(void)
681 {
682     printk("%s\n", __FUNCTION__);
683     RK30_MODEM_POWER_IOMUX;
684
685         return 0;
686 }
687
688 static struct rk29_io_t rk30_modem_io = {
689     .io_addr    = RK30_MODEM_POWER,
690     .enable     = GPIO_HIGH,
691     .disable    = GPIO_LOW,
692     .io_init    = rk30_modem_io_init,
693 };
694
695 static struct platform_device rk30_device_modem = {
696         .name   = "rk30_modem",
697         .id     = -1,
698         .dev    = {
699                 .platform_data  = &rk30_modem_io,
700         }
701 };
702 #endif
703 #if defined(CONFIG_MU509)
704 static int mu509_io_init(void)
705 {
706
707         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
708         rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
709         rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
710         rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
711         return 0;
712 }
713
714 static int mu509_io_deinit(void)
715 {
716         
717         return 0;
718 }
719  
720 struct rk29_mu509_data rk29_mu509_info = {
721         .io_init = mu509_io_init,
722         .io_deinit = mu509_io_deinit,
723         .modem_power_en = RK30_PIN6_PB2,//RK30_PIN4_PD1,
724         .bp_power = RK30_PIN2_PB6,//RK30_PIN4_PD1,
725         .bp_reset = RK30_PIN4_PD2,
726         .ap_wakeup_bp = RK30_PIN2_PB7,
727         .bp_wakeup_ap = RK30_PIN6_PA0, 
728 };
729 struct platform_device rk29_device_mu509 = {    
730         .name = "mu509",        
731         .id = -1,       
732         .dev            = {
733                 .platform_data = &rk29_mu509_info,
734         }       
735     };
736 #endif
737 #if defined(CONFIG_MW100)
738 static int mw100_io_init(void)
739 {
740          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
741          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
742          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
743          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
744         return 0;
745 }
746
747 static int mw100_io_deinit(void)
748 {
749         
750         return 0;
751 }
752  
753 struct rk29_mw100_data rk29_mw100_info = {
754         .io_init = mw100_io_init,
755         .io_deinit = mw100_io_deinit,
756         .modem_power_en = RK30_PIN6_PB2,
757         .bp_power = RK30_PIN2_PB6,
758         .bp_reset = RK30_PIN4_PD2,
759         .ap_wakeup_bp = RK30_PIN2_PB7,
760         .bp_wakeup_ap = RK30_PIN6_PA0,
761 };
762 struct platform_device rk29_device_mw100 = {    
763         .name = "mw100",        
764         .id = -1,       
765         .dev            = {
766                 .platform_data = &rk29_mw100_info,
767         }       
768     };
769 #endif
770 #if defined(CONFIG_MT6229)
771 static int mt6229_io_init(void)
772 {
773          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
774          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
775          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
776          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
777         return 0;
778 }
779
780 static int mt6229_io_deinit(void)
781 {
782         
783         return 0;
784 }
785  
786 struct rk29_mt6229_data rk29_mt6229_info = {
787         .io_init = mt6229_io_init,
788         .io_deinit = mt6229_io_deinit,
789         .modem_power_en = RK30_PIN6_PB2,
790         .bp_power = RK30_PIN2_PB7,
791         .bp_reset = RK30_PIN4_PD2,
792         .ap_wakeup_bp = RK30_PIN2_PC0,
793         .bp_wakeup_ap = RK30_PIN6_PA0,
794 };
795 struct platform_device rk29_device_mt6229 = {   
796         .name = "mt6229",       
797         .id = -1,       
798         .dev            = {
799                 .platform_data = &rk29_mt6229_info,
800         }       
801     };
802 #endif
803 #if defined(CONFIG_SEW868)
804 static int sew868_io_init(void)
805 {
806         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
807     rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
808         rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4);
809         return 0;
810 }
811 static int sew868_io_deinit(void)
812 {
813         return 0;
814 }
815 struct rk30_sew868_data rk30_sew868_info = {
816         .io_init = sew868_io_init,
817         .io_deinit = sew868_io_deinit,
818         .bp_power = RK30_PIN6_PB2, 
819         .bp_power_active_low = 1,
820         .bp_sys = RK30_PIN2_PB6, 
821         .bp_reset = RK30_PIN4_PD2, 
822         .bp_reset_active_low = 1,
823         .bp_wakeup_ap = RK30_PIN4_PD4, 
824         .ap_wakeup_bp = NULL,
825 };
826
827 struct platform_device rk30_device_sew868 = {   
828         .name = "sew868",       
829         .id = -1,       
830         .dev            = {
831                 .platform_data = &rk30_sew868_info,
832         }       
833     };
834 #endif
835
836 /*MMA8452 gsensor*/
837 #if defined (CONFIG_GS_MMA8452)
838 #define MMA8452_INT_PIN   RK30_PIN4_PC0
839
840 static int mma8452_init_platform_hw(void)
841 {
842         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
843
844         return 0;
845 }
846
847 static struct sensor_platform_data mma8452_info = {
848         .type = SENSOR_TYPE_ACCEL,
849         .irq_enable = 1,
850         .poll_delay_ms = 30,
851         .init_platform_hw = mma8452_init_platform_hw,
852         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
853 };
854 #endif
855 #if defined (CONFIG_GS_LIS3DH)
856 #define LIS3DH_INT_PIN   RK30_PIN4_PC0
857
858 static int lis3dh_init_platform_hw(void)
859 {
860         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
861
862         return 0;
863 }
864
865 static struct sensor_platform_data lis3dh_info = {
866         .type = SENSOR_TYPE_ACCEL,
867         .irq_enable = 1,
868         .poll_delay_ms = 30,
869         .init_platform_hw = lis3dh_init_platform_hw,
870         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
871 };
872 #endif
873 #if defined (CONFIG_GS_KXTIK)
874 #define KXTIK_INT_PIN   RK30_PIN4_PC0
875
876 static int kxtik_init_platform_hw(void)
877 {
878         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
879
880         return 0;
881 }
882
883 static struct sensor_platform_data kxtik_info = {
884         .type = SENSOR_TYPE_ACCEL,
885         .irq_enable = 1,
886         .poll_delay_ms = 30,
887         .init_platform_hw = kxtik_init_platform_hw,
888         .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
889 };
890
891 #endif
892 #if defined (CONFIG_COMPASS_AK8975)
893 static struct sensor_platform_data akm8975_info =
894 {
895         .type = SENSOR_TYPE_COMPASS,
896         .irq_enable = 1,
897         .poll_delay_ms = 30,
898         .m_layout = 
899         {
900                 {
901                         {1, 0, 0},
902                         {0, 1, 0},
903                         {0, 0, 1},
904                 },
905
906                 {
907                         {1, 0, 0},
908                         {0, 1, 0},
909                         {0, 0, 1},
910                 },
911
912                 {
913                         {1, 0, 0},
914                         {0, 1, 0},
915                         {0, 0, 1},
916                 },
917
918                 {
919                         {1, 0, 0},
920                         {0, 1, 0},
921                         {0, 0, 1},
922                 },
923         }
924 };
925
926 #endif
927
928 #if defined(CONFIG_GYRO_L3G4200D)
929
930 #include <linux/l3g4200d.h>
931 #define L3G4200D_INT_PIN  RK30_PIN4_PC3
932
933 static int l3g4200d_init_platform_hw(void)
934 {
935         rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
936         
937         return 0;
938 }
939
940 static struct sensor_platform_data l3g4200d_info = {
941         .type = SENSOR_TYPE_GYROSCOPE,
942         .irq_enable = 1,
943         .poll_delay_ms = 30,
944         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
945         .init_platform_hw = l3g4200d_init_platform_hw,
946         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
947         .y_min = 40,
948         .z_min = 20,
949 };
950
951 #endif
952
953 #ifdef CONFIG_LS_CM3217
954 static struct sensor_platform_data cm3217_info = {
955         .type = SENSOR_TYPE_LIGHT,
956         .irq_enable = 0,
957         .poll_delay_ms = 500,
958 };
959
960 #endif
961
962 #if defined(CONFIG_PS_AL3006)
963 static struct sensor_platform_data proximity_al3006_info = {
964         .type = SENSOR_TYPE_PROXIMITY,
965         .irq_enable = 1,
966         .poll_delay_ms = 200,
967 };
968 #endif
969
970 #if defined(CONFIG_PS_STK3171)
971 static struct sensor_platform_data proximity_stk3171_info = {
972         .type = SENSOR_TYPE_PROXIMITY,
973         .irq_enable = 1,
974         .poll_delay_ms = 200,
975 };
976 #endif
977
978
979 #if defined(CONFIG_LS_AL3006)
980 static struct sensor_platform_data light_al3006_info = {
981         .type = SENSOR_TYPE_LIGHT,
982         .irq_enable = 1,
983         .poll_delay_ms = 200,
984 };
985 #endif
986
987 #if defined(CONFIG_LS_STK3171)
988 static struct sensor_platform_data light_stk3171_info = {
989         .type = SENSOR_TYPE_LIGHT,
990         .irq_enable = 1,
991         .poll_delay_ms = 200,
992 };
993 #endif
994 #ifdef CONFIG_FB_ROCKCHIP
995
996 #define LCD_CS_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
997 #define LCD_CS_PIN         RK30_PIN4_PC7
998 #define LCD_CS_VALUE       GPIO_HIGH
999
1000 #define LCD_EN_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
1001 #define LCD_EN_PIN         RK30_PIN6_PB4
1002 #define LCD_EN_VALUE       GPIO_LOW
1003
1004 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
1005 {
1006         int ret = 0;
1007         rk30_mux_api_set(LCD_CS_MUX_NAME, GPIO4C_GPIO4C7);
1008         ret = gpio_request(LCD_CS_PIN, NULL);
1009         if (ret != 0)
1010         {
1011                 gpio_free(LCD_CS_PIN);
1012                 printk(KERN_ERR "request lcd cs pin fail!\n");
1013                 return -1;
1014         }
1015         else
1016         {
1017                 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
1018         }
1019         ret = gpio_request(LCD_EN_PIN, NULL);
1020         if (ret != 0)
1021         {
1022                 gpio_free(LCD_EN_PIN);
1023                 printk(KERN_ERR "request lcd en pin fail!\n");
1024                 return -1;
1025         }
1026         else
1027         {
1028                 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
1029         }
1030         return 0;
1031 }
1032 static int rk_fb_io_disable(void)
1033 {
1034         gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE? 0:1);
1035         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE? 0:1);
1036         return 0;
1037 }
1038 static int rk_fb_io_enable(void)
1039 {
1040         gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
1041         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
1042         return 0;
1043 }
1044
1045 #if defined(CONFIG_LCDC0_RK30)
1046 struct rk29fb_info lcdc0_screen_info = {
1047         .prop      = PRMRY,             //primary display device
1048         .io_init   = rk_fb_io_init,
1049         .io_disable = rk_fb_io_disable,
1050         .io_enable = rk_fb_io_enable,
1051         .set_screen_info = set_lcd_info,
1052 };
1053 #endif
1054
1055 #if defined(CONFIG_LCDC1_RK30)
1056 struct rk29fb_info lcdc1_screen_info = {
1057         #if defined(CONFIG_HDMI_RK30)
1058         .prop           = EXTEND,       //extend display device
1059         .lcd_info  = NULL,
1060         .set_screen_info = hdmi_init_lcdc,
1061         #endif
1062 };
1063 #endif
1064
1065 static struct resource resource_fb[] = {
1066         [0] = {
1067                 .name  = "fb0 buf",
1068                 .start = 0,
1069                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1070                 .flags = IORESOURCE_MEM,
1071         },
1072         [1] = {
1073                 .name  = "ipp buf",  //for rotate
1074                 .start = 0,
1075                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1076                 .flags = IORESOURCE_MEM,
1077         },
1078         [2] = {
1079                 .name  = "fb2 buf",
1080                 .start = 0,
1081                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1082                 .flags = IORESOURCE_MEM,
1083         },
1084 };
1085
1086 static struct platform_device device_fb = {
1087         .name           = "rk-fb",
1088         .id             = -1,
1089         .num_resources  = ARRAY_SIZE(resource_fb),
1090         .resource       = resource_fb,
1091 };
1092 #endif
1093
1094 #ifdef CONFIG_ANDROID_TIMED_GPIO
1095 static struct timed_gpio timed_gpios[] = {
1096         {
1097                 .name = "vibrator",
1098                 .gpio = RK30_PIN0_PA4,
1099                 .max_timeout = 1000,
1100                 .active_low = 0,
1101                 .adjust_time =20,      //adjust for diff product
1102         },
1103 };
1104
1105 static struct timed_gpio_platform_data rk29_vibrator_info = {
1106         .num_gpios = 1,
1107         .gpios = timed_gpios,
1108 };
1109
1110 static struct platform_device rk29_device_vibrator = {
1111         .name = "timed-gpio",
1112         .id = -1,
1113         .dev = {
1114                 .platform_data = &rk29_vibrator_info,
1115         },
1116
1117 };
1118 #endif
1119
1120 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1121 static struct gpio_led rk29_leds[] = {
1122         {
1123                 .name = "button-backlight",
1124                 .gpio = RK30_PIN4_PD7,
1125                 .default_trigger = "timer",
1126                 .active_low = 0,
1127                 .retain_state_suspended = 0,
1128                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1129         },
1130 };
1131
1132 static struct gpio_led_platform_data rk29_leds_pdata = {
1133         .leds = rk29_leds,
1134         .num_leds = ARRAY_SIZE(rk29_leds),
1135 };
1136
1137 static struct platform_device rk29_device_gpio_leds = {
1138         .name   = "leds-gpio",
1139         .id     = -1,
1140         .dev    = {
1141                 .platform_data  = &rk29_leds_pdata,
1142         },
1143 };
1144 #endif
1145
1146 #ifdef CONFIG_RK_IRDA
1147 #define IRDA_IRQ_PIN           RK30_PIN6_PA1
1148
1149 static int irda_iomux_init(void)
1150 {
1151         int ret = 0;
1152
1153         //irda irq pin
1154         ret = gpio_request(IRDA_IRQ_PIN, NULL);
1155         if (ret != 0) {
1156                 gpio_free(IRDA_IRQ_PIN);
1157                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1158         }
1159         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1160         gpio_direction_input(IRDA_IRQ_PIN);
1161
1162         return 0;
1163 }
1164
1165 static int irda_iomux_deinit(void)
1166 {
1167         gpio_free(IRDA_IRQ_PIN);
1168         return 0;
1169 }
1170
1171 static struct irda_info rk29_irda_info = {
1172         .intr_pin = IRDA_IRQ_PIN,
1173         .iomux_init = irda_iomux_init,
1174         .iomux_deinit = irda_iomux_deinit,
1175         //.irda_pwr_ctl = bu92747guw_power_ctl,
1176 };
1177
1178 static struct platform_device irda_device = {
1179 #ifdef CONFIG_RK_IRDA_NET
1180         .name = "rk_irda",
1181 #else
1182         .name = "bu92747_irda",
1183 #endif
1184         .id = -1,
1185         .dev = {
1186                 .platform_data = &rk29_irda_info,
1187         }
1188 };
1189 #endif
1190
1191 #ifdef CONFIG_ION
1192 #define ION_RESERVE_SIZE        (80 * SZ_1M)
1193 static struct ion_platform_data rk30_ion_pdata = {
1194         .nr = 1,
1195         .heaps = {
1196                 {
1197                         .type = ION_HEAP_TYPE_CARVEOUT,
1198                         .id = ION_NOR_HEAP_ID,
1199                         .name = "norheap",
1200                         .size = ION_RESERVE_SIZE,
1201                 }
1202         },
1203 };
1204
1205 static struct platform_device device_ion = {
1206         .name = "ion-rockchip",
1207         .id = 0,
1208         .dev = {
1209                 .platform_data = &rk30_ion_pdata,
1210         },
1211 };
1212 #endif
1213
1214 /**************************************************************************************************
1215  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
1216 **************************************************************************************************/
1217 #ifdef CONFIG_SDMMC_RK29
1218 #include "board-rk30-sdk-sdmmc.c"
1219
1220 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1221 #define SDMMC0_WRITE_PROTECT_PIN        RK30_PIN3_PB2   //According to your own project to set the value of write-protect-pin.
1222 #endif
1223
1224 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1225 #define SDMMC1_WRITE_PROTECT_PIN        RK30_PIN3_PB3   //According to your own project to set the value of write-protect-pin.
1226 #endif
1227
1228 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
1229 #define RK29SDK_WIFI_SDIO_CARD_INT         RK30_PIN3_PD2
1230
1231 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
1232
1233 #ifdef CONFIG_SDMMC0_RK29
1234 static int rk29_sdmmc0_cfg_gpio(void)
1235 {
1236 #ifdef CONFIG_SDMMC_RK29_OLD
1237         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1238         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1239         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1240         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1241         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1242         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1243
1244         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1245
1246         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1247         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1248         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1249
1250 #else
1251         rk29_sdmmc_set_iomux(0, 0xFFFF);
1252
1253         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
1254
1255 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1256         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1257         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1258 #endif
1259
1260 #endif
1261
1262         return 0;
1263 }
1264
1265 #define CONFIG_SDMMC0_USE_DMA
1266 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1267         .host_ocr_avail =
1268             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1269              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1270              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1271         .host_caps =
1272             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1273         .io_init = rk29_sdmmc0_cfg_gpio,
1274
1275 #if !defined(CONFIG_SDMMC_RK29_OLD)
1276         .set_iomux = rk29_sdmmc_set_iomux,
1277 #endif
1278
1279         .dma_name = "sd_mmc",
1280 #ifdef CONFIG_SDMMC0_USE_DMA
1281         .use_dma = 1,
1282 #else
1283         .use_dma = 0,
1284 #endif
1285
1286 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1287     .status = rk29sdk_wifi_mmc0_status,
1288     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1289 #endif
1290
1291         .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
1292         .enable_sd_wakeup = 0,
1293
1294 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1295         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1296 #else
1297         .write_prt = INVALID_GPIO,
1298 #endif
1299 };
1300 #endif // CONFIG_SDMMC0_RK29
1301
1302 #ifdef CONFIG_SDMMC1_RK29
1303 #define CONFIG_SDMMC1_USE_DMA
1304 static int rk29_sdmmc1_cfg_gpio(void)
1305 {
1306 #if defined(CONFIG_SDMMC_RK29_OLD)
1307         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1308         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1309         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1310         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1311         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1312         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1313         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
1314
1315 #else
1316
1317 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1318         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1319         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1320 #endif
1321
1322 #endif
1323
1324         return 0;
1325 }
1326
1327 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1328         .host_ocr_avail =
1329             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1330              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1331              MMC_VDD_33_34),
1332
1333 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1334         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1335                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1336 #else
1337         .host_caps =
1338             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1339 #endif
1340
1341         .io_init = rk29_sdmmc1_cfg_gpio,
1342
1343 #if !defined(CONFIG_SDMMC_RK29_OLD)
1344         .set_iomux = rk29_sdmmc_set_iomux,
1345 #endif
1346
1347         .dma_name = "sdio",
1348 #ifdef CONFIG_SDMMC1_USE_DMA
1349         .use_dma = 1,
1350 #else
1351         .use_dma = 0,
1352 #endif
1353
1354 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1355 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1356         .status = rk29sdk_wifi_status,
1357         .register_status_notify = rk29sdk_wifi_status_register,
1358 #endif
1359 #if 0
1360         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1361 #endif
1362
1363 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1364         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1365 #else
1366         .write_prt = INVALID_GPIO,
1367 #endif
1368
1369 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1370     .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1371 #endif
1372
1373 #else
1374         .detect_irq = INVALID_GPIO,
1375         .enable_sd_wakeup = 0,
1376 #endif
1377
1378 };
1379 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1380
1381 /**************************************************************************************************
1382  * the end of setting for SDMMC devices
1383 **************************************************************************************************/
1384
1385 #ifdef CONFIG_BATTERY_RK30_ADC
1386 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1387         .dc_det_pin      = RK30_PIN6_PA5,
1388         .batt_low_pin    = RK30_PIN6_PA0,
1389         .charge_set_pin  = INVALID_GPIO,
1390         .charge_ok_pin   = RK30_PIN6_PA6,
1391         .dc_det_level    = GPIO_LOW,
1392         .charge_ok_level = GPIO_HIGH,
1393 };
1394
1395 static struct platform_device rk30_device_adc_battery = {
1396         .name   = "rk30-battery",
1397         .id     = -1,
1398         .dev = {
1399                 .platform_data = &rk30_adc_battery_platdata,
1400         },
1401 };
1402 #endif
1403
1404 #ifdef CONFIG_RK29_VMAC
1405 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1406 #include "board-rk30-sdk-vmac.c"
1407 #endif
1408
1409 #ifdef CONFIG_RFKILL_RK
1410 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1411 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1412     .type               = RFKILL_TYPE_BLUETOOTH,
1413
1414     .poweron_gpio       = { // BT_REG_ON
1415         .io             = RK30_PIN3_PC7,
1416         .enable         = GPIO_HIGH,
1417         .iomux          = {
1418             .name       = GPIO3C7_SDMMC1WRITEPRT_NAME,
1419             .fgpio      = GPIO3C_GPIO3C7,
1420         },
1421     },
1422
1423     .reset_gpio         = { // BT_RST
1424         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1425         .enable         = GPIO_LOW,
1426         .iomux          = {
1427             .name       = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1428             .fgpio      = GPIO3D_GPIO3D1,
1429         },
1430     },
1431
1432     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1433         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1434         .enable         = GPIO_HIGH,
1435         .iomux          = {
1436             .name       = GPIO3C6_SDMMC1DETECTN_NAME,
1437             .fgpio      = GPIO3C_GPIO3C6,
1438         },
1439     },
1440
1441     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1442         .gpio           = {
1443             .io         = RK30_PIN6_PA7, // set io to INVALID_GPIO for disable it
1444             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1445             .iomux      = {
1446                 .name   = NULL,
1447             },
1448         },
1449     },
1450
1451     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1452         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1453         .enable         = GPIO_LOW,
1454         .iomux          = {
1455             .name       = GPIO1A3_UART0RTSN_NAME,
1456             .fgpio      = GPIO1A_GPIO1A3,
1457             .fmux       = GPIO1A_UART0_RTS_N,
1458         },
1459     },
1460 };
1461
1462 static struct platform_device device_rfkill_rk = {
1463     .name   = "rfkill_rk",
1464     .id     = -1,
1465     .dev    = {
1466         .platform_data = &rfkill_rk_platdata,
1467     },
1468 };
1469 #endif
1470
1471 static struct platform_device *devices[] __initdata = {
1472 #ifdef CONFIG_BACKLIGHT_RK29_BL
1473         &rk29_device_backlight,
1474 #endif
1475 #ifdef CONFIG_FB_ROCKCHIP
1476         &device_fb,
1477 #endif
1478 #ifdef CONFIG_ION
1479         &device_ion,
1480 #endif
1481 #ifdef CONFIG_ANDROID_TIMED_GPIO
1482         &rk29_device_vibrator,
1483 #endif
1484 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1485         &rk29_device_gpio_leds,
1486 #endif
1487 #ifdef CONFIG_RK_IRDA
1488         &irda_device,
1489 #endif
1490 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1491         &rk29sdk_wifi_device,
1492 #endif
1493
1494 #if defined(CONFIG_MT6620)
1495     &mt3326_device_gps,
1496 #endif   
1497
1498 #ifdef CONFIG_RK29_SUPPORT_MODEM
1499         &rk30_device_modem,
1500 #endif
1501 #if defined(CONFIG_MU509)
1502         &rk29_device_mu509,
1503 #endif
1504 #if defined(CONFIG_MW100)
1505         &rk29_device_mw100,
1506 #endif
1507 #if defined(CONFIG_MT6229)
1508         &rk29_device_mt6229,
1509 #endif
1510 #if defined(CONFIG_SEW868)
1511         &rk30_device_sew868,
1512 #endif
1513 #ifdef CONFIG_BATTERY_RK30_ADC
1514         &rk30_device_adc_battery,
1515 #endif
1516 #ifdef CONFIG_RFKILL_RK
1517         &device_rfkill_rk,
1518 #endif
1519 };
1520
1521 // i2c
1522 #ifdef CONFIG_I2C0_RK30
1523 static struct i2c_board_info __initdata i2c0_info[] = {
1524 #if defined (CONFIG_GS_MMA8452)
1525         {
1526                 .type           = "gs_mma8452",
1527                 .addr           = 0x1d,
1528                 .flags          = 0,
1529                 .irq            = MMA8452_INT_PIN,
1530                 .platform_data = &mma8452_info,
1531         },
1532 #endif
1533 #if defined (CONFIG_GS_LIS3DH)
1534         {
1535                 .type           = "gs_lis3dh",
1536                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1537                 .flags          = 0,
1538                 .irq            = LIS3DH_INT_PIN,
1539                 .platform_data = &lis3dh_info,
1540         },
1541 #endif
1542 #if defined (CONFIG_GS_KXTIK)
1543         {
1544                 .type           = "gs_kxtik",
1545                 .addr           = 0x0F,
1546                 .flags          = 0,
1547                 .irq            = KXTIK_INT_PIN,
1548                 .platform_data = &kxtik_info,
1549         },
1550 #endif
1551 #if defined (CONFIG_COMPASS_AK8975)
1552         {
1553                 .type          = "ak8975",
1554                 .addr          = 0x0d,
1555                 .flags         = 0,
1556                 .irq           = RK30_PIN4_PC1,
1557                 .platform_data = &akm8975_info,
1558         },
1559 #endif
1560 #if defined (CONFIG_GYRO_L3G4200D)
1561         {
1562                 .type          = "l3g4200d_gryo",
1563                 .addr          = 0x69,
1564                 .flags         = 0,
1565                 .irq           = L3G4200D_INT_PIN,
1566                 .platform_data = &l3g4200d_info,
1567         },
1568 #endif
1569 #if defined (CONFIG_LS_AL3006)
1570         {
1571                 .type           = "light_al3006",
1572                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1573                 .flags          = 0,
1574                 .irq            = RK30_PIN6_PA2,        
1575                 .platform_data = &light_al3006_info,
1576         },
1577 #endif
1578 #if defined (CONFIG_LS_STK3171)
1579         {
1580                 .type           = "ls_stk3171",
1581                 .addr           = 0x48,            
1582                 .flags          = 0,
1583                 .irq            = RK30_PIN6_PA2,        
1584                 .platform_data = &light_stk3171_info,
1585         },
1586 #endif
1587
1588
1589 #if defined (CONFIG_PS_AL3006)
1590         {
1591                 .type           = "proximity_al3006",
1592                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1593                 .flags          = 0,
1594                 .irq            = RK30_PIN6_PA2,        
1595                 .platform_data = &proximity_al3006_info,
1596         },
1597 #endif
1598
1599 #if defined (CONFIG_PS_STK3171)
1600         {
1601                 .type           = "ps_stk3171",
1602                 .addr           = 0x48,            
1603                 .flags          = 0,
1604                 .irq            = RK30_PIN6_PA2,        
1605                 .platform_data = &proximity_stk3171_info,
1606         },
1607 #endif
1608 #if defined (CONFIG_SND_SOC_RK1000)
1609         {
1610                 .type          = "rk1000_i2c_codec",
1611                 .addr          = 0x60,
1612                 .flags         = 0,
1613         },
1614         {
1615                 .type          = "rk1000_control",
1616                 .addr          = 0x40,
1617                 .flags         = 0,
1618         },
1619 #endif
1620 #if defined (CONFIG_SND_SOC_RT5631)
1621         {
1622                 .type                   = "rt5631",
1623                 .addr                   = 0x1a,
1624                 .flags                  = 0,
1625         },
1626 #endif
1627
1628 #ifdef CONFIG_MFD_RK610
1629                 {
1630                         .type                   = "rk610_ctl",
1631                         .addr                   = 0x40,
1632                         .flags                  = 0,
1633                 },
1634 #ifdef CONFIG_RK610_TVOUT
1635                 {
1636                         .type                   = "rk610_tvout",
1637                         .addr                   = 0x42,
1638                         .flags                  = 0,
1639                 },
1640 #endif
1641 #ifdef CONFIG_RK610_HDMI
1642                 {
1643                         .type                   = "rk610_hdmi",
1644                         .addr                   = 0x46,
1645                         .flags                  = 0,
1646                         .irq                    = RK29_PIN5_PA2,
1647                 },
1648 #endif
1649 #ifdef CONFIG_SND_SOC_RK610
1650                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1651                         .type                   = "rk610_i2c_codec",
1652                         .addr                   = 0x60,
1653                         .flags                  = 0,
1654                 },
1655 #endif
1656 #endif
1657
1658 };
1659 #endif
1660 #define PMIC_TYPE_WM8326        1
1661 #define PMIC_TYPE_TPS65910      2
1662 int __sramdata g_pmic_type =  0;
1663 #ifdef CONFIG_I2C1_RK30
1664 #ifdef CONFIG_MFD_WM831X_I2C
1665 #include "board-rk30-sdk-wm8326.c"
1666 #endif
1667 #ifdef CONFIG_MFD_TPS65910
1668 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
1669 #include "board-rk30-sdk-tps65910.c"
1670 #endif
1671
1672 static struct i2c_board_info __initdata i2c1_info[] = {
1673 #if defined (CONFIG_MFD_WM831X_I2C)
1674         {
1675                 .type          = "wm8326",
1676                 .addr          = 0x34,
1677                 .flags         = 0,
1678                 .irq           = RK30_PIN6_PA4,
1679                 .platform_data = &wm831x_platdata,
1680         },
1681 #endif
1682 #if defined (CONFIG_MFD_TPS65910)
1683         {
1684         .type           = "tps65910",
1685         .addr           = TPS65910_I2C_ID0,
1686         .flags          = 0,
1687         .irq            = TPS65910_HOST_IRQ,
1688         .platform_data = &tps65910_data,
1689         },
1690 #endif
1691 };
1692 #endif
1693
1694 void __sramfunc board_pmu_suspend(void)
1695 {      
1696         #if defined (CONFIG_MFD_WM831X_I2C)
1697        if(g_pmic_type == PMIC_TYPE_WM8326)
1698        board_pmu_wm8326_suspend();
1699         #endif
1700         #if defined (CONFIG_MFD_TPS65910)
1701        if(g_pmic_type == PMIC_TYPE_TPS65910)
1702        board_pmu_tps65910_suspend(); 
1703     #endif   
1704 }
1705
1706 void __sramfunc board_pmu_resume(void)
1707 {      
1708         #if defined (CONFIG_MFD_WM831X_I2C)
1709        if(g_pmic_type == PMIC_TYPE_WM8326)
1710        board_pmu_wm8326_resume();
1711         #endif
1712         #if defined (CONFIG_MFD_TPS65910)
1713        if(g_pmic_type == PMIC_TYPE_TPS65910)
1714        board_pmu_tps65910_resume(); 
1715         #endif
1716 }
1717
1718 #ifdef CONFIG_I2C2_RK30
1719 static struct i2c_board_info __initdata i2c2_info[] = {
1720 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1721         {
1722                 .type          = "Goodix-TS",
1723                 .addr          = 0x55,
1724                 .flags         = 0,
1725                 .irq           = RK30_PIN4_PC2,
1726                 .platform_data = &goodix_info,
1727         },
1728 #endif
1729 #if defined (CONFIG_LS_CM3217)
1730         {
1731                 .type          = "light_cm3217",
1732                 .addr          = 0x10,
1733                 .flags         = 0,
1734                 .platform_data = &cm3217_info,
1735         },
1736 #endif
1737 };
1738 #endif
1739
1740 #ifdef CONFIG_I2C3_RK30
1741 static struct i2c_board_info __initdata i2c3_info[] = {
1742 };
1743 #endif
1744
1745 #ifdef CONFIG_I2C4_RK30
1746 static struct i2c_board_info __initdata i2c4_info[] = {
1747 };
1748 #endif
1749
1750 #ifdef CONFIG_I2C_GPIO_RK30
1751 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1752 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1753 static int rk30_i2c_io_init(void)
1754 {
1755         //set iomux (gpio) here
1756         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1757         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1758
1759         return 0;
1760 }
1761 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1762        .sda_pin = I2C_SDA_PIN,
1763        .scl_pin = I2C_SCL_PIN,
1764        .udelay = 5, // clk = 500/udelay = 100Khz
1765        .timeout = 100,//msecs_to_jiffies(100),
1766        .bus_num    = 5,
1767        .io_init = rk30_i2c_io_init,
1768 };
1769 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1770 };
1771 #endif
1772
1773 static void __init rk30_i2c_register_board_info(void)
1774 {
1775 #ifdef CONFIG_I2C0_RK30
1776         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1777 #endif
1778 #ifdef CONFIG_I2C1_RK30
1779         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1780 #endif
1781 #ifdef CONFIG_I2C2_RK30
1782         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1783 #endif
1784 #ifdef CONFIG_I2C3_RK30
1785         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1786 #endif
1787 #ifdef CONFIG_I2C4_RK30
1788         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1789 #endif
1790 #ifdef CONFIG_I2C_GPIO_RK30
1791         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1792 #endif
1793 }
1794 //end of i2c
1795
1796 #define POWER_ON_PIN RK30_PIN6_PB0   //power_hold
1797 static void rk30_pm_power_off(void)
1798 {
1799         printk(KERN_ERR "rk30_pm_power_off start...\n");
1800         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1801         #if defined(CONFIG_MFD_WM831X)  
1802         if(g_pmic_type == PMIC_TYPE_WM8326)
1803         {
1804                 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
1805                 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1806         }
1807         #endif
1808         #if defined(CONFIG_MFD_TPS65910)
1809         if(g_pmic_type == PMIC_TYPE_TPS65910)
1810         {
1811                 tps65910_device_shutdown();//tps65910 shutdown
1812         }
1813         #endif
1814
1815         while (1);
1816 }
1817
1818 static void __init machine_rk30_board_init(void)
1819 {
1820         avs_init();
1821         gpio_request(POWER_ON_PIN, "poweronpin");
1822         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1823         
1824         pm_power_off = rk30_pm_power_off;
1825         
1826         rk30_i2c_register_board_info();
1827         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1828         platform_add_devices(devices, ARRAY_SIZE(devices));
1829         board_usb_detect_init(RK30_PIN6_PA3);
1830
1831 #ifdef CONFIG_WIFI_CONTROL_FUNC
1832         rk29sdk_wifi_bt_gpio_control_init();
1833 #endif
1834
1835 #if defined(CONFIG_MT6620)
1836     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 16*1000000);
1837 #endif
1838 }
1839
1840 static void __init rk30_reserve(void)
1841 {
1842 #ifdef CONFIG_ION
1843         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1844 #endif
1845 #ifdef CONFIG_FB_ROCKCHIP
1846         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1847         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1848         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1849         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1850         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1851         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1852 #endif
1853 #ifdef CONFIG_VIDEO_RK29
1854         rk30_camera_request_reserve_mem();
1855 #endif
1856         board_mem_reserved();
1857 }
1858
1859 /**
1860  * dvfs_cpu_logic_table: table for arm and logic dvfs 
1861  * @frequency   : arm frequency
1862  * @cpu_volt    : arm voltage depend on frequency
1863  * @logic_volt  : logic voltage arm requests depend on frequency
1864  * comments     : min arm/logic voltage
1865  */
1866 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1867         {.frequency = 252 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
1868         {.frequency = 504 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
1869         {.frequency = 816 * 1000,       .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.000V/1.025V
1870         {.frequency = 1008 * 1000,      .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.025V/1.050V
1871         {.frequency = 1200 * 1000,      .cpu_volt = 1175 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1872         {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
1873         {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},//1.225V/1.100V
1874         {.frequency = 1512 * 1000,      .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},//1.300V/1.150V
1875         {.frequency = 1608 * 1000,      .cpu_volt = 1425 * 1000,        .logic_volt = 1300 * 1000},//1.325V/1.175V
1876         {.frequency = CPUFREQ_TABLE_END},
1877 };
1878
1879 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1880         {.frequency = 266 * 1000,       .index = 1050 * 1000},
1881         {.frequency = 400 * 1000,       .index = 1275 * 1000},
1882         {.frequency = CPUFREQ_TABLE_END},
1883 };
1884
1885 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1886         {.frequency = 300 * 1000,       .index = 1050 * 1000},
1887         {.frequency = 400 * 1000,       .index = 1125 * 1000},
1888         {.frequency = CPUFREQ_TABLE_END},
1889 };
1890
1891 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
1892 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1893 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1894
1895 void __init board_clock_init(void)
1896 {
1897         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1898         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1899         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1900         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1901 }
1902
1903 MACHINE_START(RK30, "RK30board")
1904         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1905         .fixup          = rk30_fixup,
1906         .reserve        = &rk30_reserve,
1907         .map_io         = rk30_map_io,
1908         .init_irq       = rk30_init_irq,
1909         .timer          = &rk30_timer,
1910         .init_machine   = machine_rk30_board_init,
1911 MACHINE_END