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