rk:move pmic_type to board.h
[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 #ifdef CONFIG_TOUCHSCREEN_GT82X_IIC
56 #include <linux/goodix_touch_82x.h>
57 #endif
58 #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_S3202
59 #include <linux/interrupt.h>
60 #include <linux/rmi.h>
61 #endif
62
63 #if defined(CONFIG_SPIM_RK29)
64 #include "../../../drivers/spi/rk29_spim.h"
65 #endif
66 #if defined(CONFIG_MU509)
67 #include <linux/mu509.h>
68 #endif
69 #if defined(CONFIG_MW100)
70 #include <linux/mw100.h>
71 #endif
72 #if defined(CONFIG_MT6229)
73 #include <linux/mt6229.h>
74 #endif
75 #if defined(CONFIG_SEW868)
76 #include <linux/sew868.h>
77 #endif
78
79 #if defined(CONFIG_MI700)
80 #include <linux/mi700.h>
81 #endif
82
83 #if defined(CONFIG_ANDROID_TIMED_GPIO)
84 #include "../../../drivers/staging/android/timed_gpio.h"
85 #endif
86 #if defined(CONFIG_TOUCHSCREEN_GT8110)
87 #include <linux/gt8110.h>
88 #endif
89
90 #if defined(CONFIG_MT6620)
91 #include <linux/gps.h>
92 #endif
93
94 #if defined (CONFIG_TS_AUTO)
95 #include <linux/ts-auto.h>
96 #endif
97
98
99 #ifdef  CONFIG_THREE_FB_BUFFER
100 #define RK30_FB0_MEM_SIZE 12*SZ_1M
101 #else
102 #define RK30_FB0_MEM_SIZE 8*SZ_1M
103 #endif
104 #define PMIC_IS_WM831X  0
105
106 #ifdef CONFIG_VIDEO_RK29
107 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
108 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
109 #if defined(CONFIG_SOC_CAMERA_SID130B)
110 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_SID130B                                         /* back camera sensor */
111 #define CONFIG_SENSOR_IIC_ADDR_0                0x6e
112 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    3
113 #define CONFIG_SENSOR_CIF_INDEX_0          0         // 1
114 #define CONFIG_SENSOR_ORIENTATION_0       90
115 #define CONFIG_SENSOR_POWER_PIN_0                 INVALID_GPIO
116 #define CONFIG_SENSOR_RESET_PIN_0                 INVALID_GPIO
117 #define CONFIG_SENSOR_POWERDN_PIN_0       RK30_PIN1_PB6
118 #define CONFIG_SENSOR_FALSH_PIN_0                 INVALID_GPIO
119 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
120 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
121 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_L
122 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
123
124 #define CONFIG_SENSOR_QCIF_FPS_FIXED_0          15000
125 #define CONFIG_SENSOR_240X160_FPS_FIXED_0   15000
126 #define CONFIG_SENSOR_QVGA_FPS_FIXED_0          15000
127 #define CONFIG_SENSOR_CIF_FPS_FIXED_0           15000
128 #define CONFIG_SENSOR_VGA_FPS_FIXED_0           15000
129 #define CONFIG_SENSOR_480P_FPS_FIXED_0          15000
130 #define CONFIG_SENSOR_SVGA_FPS_FIXED_0          15000
131 #define CONFIG_SENSOR_720P_FPS_FIXED_0          30000
132 #endif
133
134 #if defined(CONFIG_SOC_CAMERA_GT2005)
135 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_GT2005                                          /* back camera sensor */
136 #define CONFIG_SENSOR_IIC_ADDR_0                0x78
137 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    3
138 #define CONFIG_SENSOR_CIF_INDEX_0          0         // 1
139 #define CONFIG_SENSOR_ORIENTATION_0       90
140 #define CONFIG_SENSOR_POWER_PIN_0                 INVALID_GPIO
141 #define CONFIG_SENSOR_RESET_PIN_0                 INVALID_GPIO
142 #define CONFIG_SENSOR_POWERDN_PIN_0       RK30_PIN1_PB6
143 #define CONFIG_SENSOR_FALSH_PIN_0                 INVALID_GPIO
144 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_H
145 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
146 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_L
147 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
148
149
150 #define CONFIG_SENSOR_QCIF_FPS_FIXED_0          15000
151 #define CONFIG_SENSOR_240X160_FPS_FIXED_0   15000
152 #define CONFIG_SENSOR_QVGA_FPS_FIXED_0          15000
153 #define CONFIG_SENSOR_CIF_FPS_FIXED_0           15000
154 #define CONFIG_SENSOR_VGA_FPS_FIXED_0           15000
155 #define CONFIG_SENSOR_480P_FPS_FIXED_0          15000
156 #define CONFIG_SENSOR_SVGA_FPS_FIXED_0          15000
157 #define CONFIG_SENSOR_720P_FPS_FIXED_0          30000
158 #endif
159
160 #define CONFIG_SENSOR_01  RK29_CAM_SENSOR_HI253                   /* back camera sensor 1 */
161 #define CONFIG_SENSOR_IIC_ADDR_01           0x40
162 #define CONFIG_SENSOR_CIF_INDEX_01                    0
163 #define CONFIG_SENSOR_IIC_ADAPTER_ID_01    3
164 #define CONFIG_SENSOR_ORIENTATION_01       90
165 #define CONFIG_SENSOR_POWER_PIN_01         INVALID_GPIO
166 #define CONFIG_SENSOR_RESET_PIN_01         INVALID_GPIO
167 #define CONFIG_SENSOR_POWERDN_PIN_01       RK30_PIN1_PB6
168 #define CONFIG_SENSOR_FALSH_PIN_01         INVALID_GPIO
169 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_01 RK29_CAM_POWERACTIVE_L
170 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_01 RK29_CAM_RESETACTIVE_L
171 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_01 RK29_CAM_POWERDNACTIVE_H
172 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_01 RK29_CAM_FLASHACTIVE_L
173
174 #define CONFIG_SENSOR_QCIF_FPS_FIXED_01      15000
175 #define CONFIG_SENSOR_240X160_FPS_FIXED_01   15000
176 #define CONFIG_SENSOR_QVGA_FPS_FIXED_01      15000
177 #define CONFIG_SENSOR_CIF_FPS_FIXED_01       15000
178 #define CONFIG_SENSOR_VGA_FPS_FIXED_01       15000
179 #define CONFIG_SENSOR_480P_FPS_FIXED_01      15000
180 #define CONFIG_SENSOR_SVGA_FPS_FIXED_01      15000
181 #define CONFIG_SENSOR_720P_FPS_FIXED_01     30000
182
183 #define CONFIG_SENSOR_02 RK29_CAM_SENSOR_OV5640                      /* back camera sensor 2 */
184 #define CONFIG_SENSOR_IIC_ADDR_02           0x78
185 #define CONFIG_SENSOR_CIF_INDEX_02                    0
186 #define CONFIG_SENSOR_IIC_ADAPTER_ID_02    3
187 #define CONFIG_SENSOR_ORIENTATION_02       90
188 #define CONFIG_SENSOR_POWER_PIN_02         INVALID_GPIO
189 #define CONFIG_SENSOR_RESET_PIN_02         INVALID_GPIO
190 #define CONFIG_SENSOR_POWERDN_PIN_02       RK30_PIN1_PB6
191 #define CONFIG_SENSOR_FALSH_PIN_02         INVALID_GPIO
192 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_02 RK29_CAM_POWERACTIVE_L
193 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_02 RK29_CAM_RESETACTIVE_L
194 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_02 RK29_CAM_POWERDNACTIVE_H
195 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_02 RK29_CAM_FLASHACTIVE_L
196
197 #define CONFIG_SENSOR_QCIF_FPS_FIXED_02      15000
198 #define CONFIG_SENSOR_240X160_FPS_FIXED_02   15000
199 #define CONFIG_SENSOR_QVGA_FPS_FIXED_02      15000
200 #define CONFIG_SENSOR_CIF_FPS_FIXED_02       15000
201 #define CONFIG_SENSOR_VGA_FPS_FIXED_02       15000
202 #define CONFIG_SENSOR_480P_FPS_FIXED_02      15000
203 #define CONFIG_SENSOR_SVGA_FPS_FIXED_02      15000
204 #define CONFIG_SENSOR_720P_FPS_FIXED_02      30000
205
206 #if defined(CONFIG_SOC_CAMERA_SIV121D)
207 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_SIV121D                      /* front camera sensor 0 */
208 #define CONFIG_SENSOR_IIC_ADDR_1            0x66
209 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    3
210 #define CONFIG_SENSOR_CIF_INDEX_1                       0       
211 #define CONFIG_SENSOR_ORIENTATION_1       270
212 #define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
213 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
214 #define CONFIG_SENSOR_POWERDN_PIN_1       RK30_PIN1_PB7
215 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
216 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
217 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
218 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
219 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
220
221 #define CONFIG_SENSOR_QCIF_FPS_FIXED_1          15000
222 #define CONFIG_SENSOR_240X160_FPS_FIXED_1   15000
223 #define CONFIG_SENSOR_QVGA_FPS_FIXED_1          15000
224 #define CONFIG_SENSOR_CIF_FPS_FIXED_1           15000
225 #define CONFIG_SENSOR_VGA_FPS_FIXED_1           15000
226 #define CONFIG_SENSOR_480P_FPS_FIXED_1          15000
227 #define CONFIG_SENSOR_SVGA_FPS_FIXED_1          15000
228 #define CONFIG_SENSOR_720P_FPS_FIXED_1          30000
229 #endif
230
231 #if defined(CONFIG_SOC_CAMERA_GC0308)
232 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_GC0308          /* front camera sensor 0 */
233 #define CONFIG_SENSOR_IIC_ADDR_1            0x42
234 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    3
235 #define CONFIG_SENSOR_CIF_INDEX_1                       0       
236 #define CONFIG_SENSOR_ORIENTATION_1       270
237 #define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
238 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
239 #define CONFIG_SENSOR_POWERDN_PIN_1       RK30_PIN1_PB7
240 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
241 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
242 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
243 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
244 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
245
246
247 #define CONFIG_SENSOR_QCIF_FPS_FIXED_1          15000
248 #define CONFIG_SENSOR_240X160_FPS_FIXED_1   15000
249 #define CONFIG_SENSOR_QVGA_FPS_FIXED_1          15000
250 #define CONFIG_SENSOR_CIF_FPS_FIXED_1           15000
251 #define CONFIG_SENSOR_VGA_FPS_FIXED_1           15000
252 #define CONFIG_SENSOR_480P_FPS_FIXED_1          15000
253 #define CONFIG_SENSOR_SVGA_FPS_FIXED_1          15000
254 #define CONFIG_SENSOR_720P_FPS_FIXED_1          30000
255 #endif
256
257 #define CONFIG_SENSOR_11 RK29_CAM_SENSOR_HI704                      /* front camera sensor 1 */
258 #define CONFIG_SENSOR_IIC_ADDR_11           0x60
259 #define CONFIG_SENSOR_IIC_ADAPTER_ID_11    3
260 #define CONFIG_SENSOR_CIF_INDEX_11                                0
261 #define CONFIG_SENSOR_ORIENTATION_11       270
262 #define CONFIG_SENSOR_POWER_PIN_11         INVALID_GPIO
263 #define CONFIG_SENSOR_RESET_PIN_11         INVALID_GPIO
264 #define CONFIG_SENSOR_POWERDN_PIN_11       RK30_PIN1_PB7
265 #define CONFIG_SENSOR_FALSH_PIN_11         INVALID_GPIO
266 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_11 RK29_CAM_POWERACTIVE_L
267 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_11 RK29_CAM_RESETACTIVE_L
268 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_11 RK29_CAM_POWERDNACTIVE_H
269 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_11 RK29_CAM_FLASHACTIVE_L
270
271 #define CONFIG_SENSOR_QCIF_FPS_FIXED_11      15000
272 #define CONFIG_SENSOR_240X160_FPS_FIXED_11   15000
273 #define CONFIG_SENSOR_QVGA_FPS_FIXED_11      15000
274 #define CONFIG_SENSOR_CIF_FPS_FIXED_11       15000
275 #define CONFIG_SENSOR_VGA_FPS_FIXED_11       15000
276 #define CONFIG_SENSOR_480P_FPS_FIXED_11      15000
277 #define CONFIG_SENSOR_SVGA_FPS_FIXED_11      15000
278 #define CONFIG_SENSOR_720P_FPS_FIXED_11      30000
279
280 #define CONFIG_SENSOR_12 RK29_CAM_SENSOR_OV2659//RK29_CAM_SENSOR_OV2655                      /* front camera sensor 2 */
281 #define CONFIG_SENSOR_IIC_ADDR_12          0x60
282 #define CONFIG_SENSOR_IIC_ADAPTER_ID_12    3
283 #define CONFIG_SENSOR_CIF_INDEX_12                                0
284 #define CONFIG_SENSOR_ORIENTATION_12       270
285 #define CONFIG_SENSOR_POWER_PIN_12         INVALID_GPIO
286 #define CONFIG_SENSOR_RESET_PIN_12         INVALID_GPIO
287 #define CONFIG_SENSOR_POWERDN_PIN_12       RK30_PIN1_PB7
288 #define CONFIG_SENSOR_FALSH_PIN_12         INVALID_GPIO
289 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_12 RK29_CAM_POWERACTIVE_L
290 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_12 RK29_CAM_RESETACTIVE_L
291 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_12 RK29_CAM_POWERDNACTIVE_H
292 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_12 RK29_CAM_FLASHACTIVE_L
293
294 #define CONFIG_SENSOR_QCIF_FPS_FIXED_12      15000
295 #define CONFIG_SENSOR_240X160_FPS_FIXED_12   15000
296 #define CONFIG_SENSOR_QVGA_FPS_FIXED_12      15000
297 #define CONFIG_SENSOR_CIF_FPS_FIXED_12       15000
298 #define CONFIG_SENSOR_VGA_FPS_FIXED_12       15000
299 #define CONFIG_SENSOR_480P_FPS_FIXED_12      15000
300 #define CONFIG_SENSOR_SVGA_FPS_FIXED_12      15000
301 #define CONFIG_SENSOR_720P_FPS_FIXED_12      30000
302
303
304 #endif  //#ifdef CONFIG_VIDEO_RK29
305 /*---------------- Camera Sensor Configuration Macro End------------------------*/
306 #include "../../../drivers/media/video/rk30_camera.c"
307 /*---------------- Camera Sensor Macro Define End  ---------*/
308
309 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
310 /*****************************************************************************************
311  * camera  devices
312  * author: ddl@rock-chips.com
313  *****************************************************************************************/
314 #ifdef CONFIG_VIDEO_RK29
315 #define CONFIG_SENSOR_POWER_IOCTL_USR      1 //define this refer to your board layout
316 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
317 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR          0
318 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
319
320 static void rk_cif_power(int on)
321 {
322     struct regulator *ldo_18,*ldo_28;
323         ldo_28 = regulator_get(NULL, "vmmc");   // vcc28_cif   ldo7
324         ldo_18 = regulator_get(NULL, "vdig1");  // vcc18_cif   ldo1
325         if (ldo_28 == NULL || IS_ERR(ldo_28) || ldo_18 == NULL || IS_ERR(ldo_18)){
326         printk("get cif ldo failed!\n");
327                 return;
328             }
329     if(on == 0){        
330         regulator_disable(ldo_28);
331         regulator_put(ldo_28);
332         regulator_disable(ldo_18);
333         regulator_put(ldo_18);
334         mdelay(500);
335         }
336     else{
337         regulator_set_voltage(ldo_28, 2800000, 2800000);
338         regulator_enable(ldo_28);
339    //   printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28));
340         regulator_put(ldo_28);
341
342         regulator_set_voltage(ldo_18, 1800000, 1800000);
343     //  regulator_set_suspend_voltage(ldo, 1800000);
344         regulator_enable(ldo_18);
345     //  printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_18));
346         regulator_put(ldo_18);
347         }
348 }
349
350 #if CONFIG_SENSOR_POWER_IOCTL_USR
351 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
352 {
353         //#error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
354     rk_cif_power(on);
355 }
356 #endif
357
358 #if CONFIG_SENSOR_RESET_IOCTL_USR
359 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
360 {
361         #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
362 }
363 #endif
364
365 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
366 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
367 {
368         #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
369 }
370 #endif
371
372 #if CONFIG_SENSOR_FLASH_IOCTL_USR
373 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
374 {
375         #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
376 }
377 #endif
378
379 static struct rk29camera_platform_ioctl_cb      sensor_ioctl_cb = {
380         #if CONFIG_SENSOR_POWER_IOCTL_USR
381         .sensor_power_cb = sensor_power_usr_cb,
382         #else
383         .sensor_power_cb = NULL,
384         #endif
385
386         #if CONFIG_SENSOR_RESET_IOCTL_USR
387         .sensor_reset_cb = sensor_reset_usr_cb,
388         #else
389         .sensor_reset_cb = NULL,
390         #endif
391
392         #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
393         .sensor_powerdown_cb = sensor_powerdown_usr_cb,
394         #else
395         .sensor_powerdown_cb = NULL,
396         #endif
397
398         #if CONFIG_SENSOR_FLASH_IOCTL_USR
399         .sensor_flash_cb = sensor_flash_usr_cb,
400         #else
401         .sensor_flash_cb = NULL,
402         #endif
403 };
404
405 #if CONFIG_SENSOR_IIC_ADDR_0
406 static struct reginfo_t rk_init_data_sensor_reg_0[] =
407 {
408                 {0x0000, 0x00,0,0}
409         };
410 static struct reginfo_t rk_init_data_sensor_winseqreg_0[] ={
411         {0x0000, 0x00,0,0}
412         };
413 #endif
414
415 #if CONFIG_SENSOR_IIC_ADDR_1
416 static struct reginfo_t rk_init_data_sensor_reg_1[] =
417 {
418     {0x0000, 0x00,0,0}
419 };
420 static struct reginfo_t rk_init_data_sensor_winseqreg_1[] =
421 {
422        {0x0000, 0x00,0,0}
423 };
424 #endif
425 #if CONFIG_SENSOR_IIC_ADDR_01
426 static struct reginfo_t rk_init_data_sensor_reg_01[] =
427 {
428     {0x0000, 0x00,0,0}
429 };
430 static struct reginfo_t rk_init_data_sensor_winseqreg_01[] =
431 {
432        {0x0000, 0x00,0,0}
433 };
434 #endif
435 #if CONFIG_SENSOR_IIC_ADDR_02
436 static struct reginfo_t rk_init_data_sensor_reg_02[] =
437 {
438     {0x0000, 0x00,0,0}
439 };
440 static struct reginfo_t rk_init_data_sensor_winseqreg_02[] =
441 {
442        {0x0000, 0x00,0,0}
443 };
444 #endif
445 #if CONFIG_SENSOR_IIC_ADDR_11
446 static struct reginfo_t rk_init_data_sensor_reg_11[] =
447 {
448     {0x0000, 0x00,0,0}
449 };
450 static struct reginfo_t rk_init_data_sensor_winseqreg_11[] =
451 {
452        {0x0000, 0x00,0,0}
453 };
454 #endif
455 #if CONFIG_SENSOR_IIC_ADDR_12
456 static struct reginfo_t rk_init_data_sensor_reg_12[] =
457 {
458     {0x0000, 0x00,0,0}
459 };
460 static struct reginfo_t rk_init_data_sensor_winseqreg_12[] =
461 {
462        {0x0000, 0x00,0,0}
463 };
464 #endif
465 static rk_sensor_user_init_data_s rk_init_data_sensor[RK_CAM_NUM] = 
466 {
467     #if CONFIG_SENSOR_IIC_ADDR_0
468     {
469        .rk_sensor_init_width = INVALID_VALUE,
470        .rk_sensor_init_height = INVALID_VALUE,
471        .rk_sensor_init_bus_param = INVALID_VALUE,
472        .rk_sensor_init_pixelcode = INVALID_VALUE,
473        .rk_sensor_init_data = rk_init_data_sensor_reg_0,
474        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_0,
475        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_0) / sizeof(struct reginfo_t),
476        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_0) / sizeof(struct reginfo_t),
477     },
478     #else
479     {
480        .rk_sensor_init_width = INVALID_VALUE,
481        .rk_sensor_init_height = INVALID_VALUE,
482        .rk_sensor_init_bus_param = INVALID_VALUE,
483        .rk_sensor_init_pixelcode = INVALID_VALUE,
484        .rk_sensor_init_data = NULL,
485        .rk_sensor_init_winseq = NULL,
486        .rk_sensor_winseq_size = 0,
487        .rk_sensor_init_data_size = 0,
488     },
489     #endif
490     #if CONFIG_SENSOR_IIC_ADDR_1
491     {
492        .rk_sensor_init_width = INVALID_VALUE,
493        .rk_sensor_init_height = INVALID_VALUE,
494        .rk_sensor_init_bus_param = INVALID_VALUE,
495        .rk_sensor_init_pixelcode = INVALID_VALUE,
496        .rk_sensor_init_data = rk_init_data_sensor_reg_1,
497        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_1,
498        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_1) / sizeof(struct reginfo_t),
499        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_1) / sizeof(struct reginfo_t),
500     },
501     #else
502     {
503        .rk_sensor_init_width = INVALID_VALUE,
504        .rk_sensor_init_height = INVALID_VALUE,
505        .rk_sensor_init_bus_param = INVALID_VALUE,
506        .rk_sensor_init_pixelcode = INVALID_VALUE,
507        .rk_sensor_init_data = NULL,
508        .rk_sensor_init_winseq = NULL,
509        .rk_sensor_winseq_size = 0,
510        .rk_sensor_init_data_size = 0,
511     },
512     #endif
513     #if CONFIG_SENSOR_IIC_ADDR_01
514     {
515        .rk_sensor_init_width = INVALID_VALUE,
516        .rk_sensor_init_height = INVALID_VALUE,
517        .rk_sensor_init_bus_param = INVALID_VALUE,
518        .rk_sensor_init_pixelcode = INVALID_VALUE,
519        .rk_sensor_init_data = rk_init_data_sensor_reg_01,
520        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_01,
521        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_01) / sizeof(struct reginfo_t),
522        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_01) / sizeof(struct reginfo_t),
523     },
524     #else
525     {
526        .rk_sensor_init_width = INVALID_VALUE,
527        .rk_sensor_init_height = INVALID_VALUE,
528        .rk_sensor_init_bus_param = INVALID_VALUE,
529        .rk_sensor_init_pixelcode = INVALID_VALUE,
530        .rk_sensor_init_data = NULL,
531        .rk_sensor_init_winseq = NULL,
532        .rk_sensor_winseq_size = 0,
533        .rk_sensor_init_data_size = 0,
534     },
535     #endif
536     #if CONFIG_SENSOR_IIC_ADDR_02
537     {
538        .rk_sensor_init_width = INVALID_VALUE,
539        .rk_sensor_init_height = INVALID_VALUE,
540        .rk_sensor_init_bus_param = INVALID_VALUE,
541        .rk_sensor_init_pixelcode = INVALID_VALUE,
542        .rk_sensor_init_data = rk_init_data_sensor_reg_02,
543        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_02,
544        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_02) / sizeof(struct reginfo_t),
545        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_02) / sizeof(struct reginfo_t),
546     },
547     #else
548     {
549        .rk_sensor_init_width = INVALID_VALUE,
550        .rk_sensor_init_height = INVALID_VALUE,
551        .rk_sensor_init_bus_param = INVALID_VALUE,
552        .rk_sensor_init_pixelcode = INVALID_VALUE,
553        .rk_sensor_init_data = NULL,
554        .rk_sensor_init_winseq = NULL,
555        .rk_sensor_winseq_size = 0,
556        .rk_sensor_init_data_size = 0,
557     },
558     #endif
559     #if CONFIG_SENSOR_IIC_ADDR_11
560     {
561        .rk_sensor_init_width = INVALID_VALUE,
562        .rk_sensor_init_height = INVALID_VALUE,
563        .rk_sensor_init_bus_param = INVALID_VALUE,
564        .rk_sensor_init_pixelcode = INVALID_VALUE,
565        .rk_sensor_init_data = rk_init_data_sensor_reg_11,
566        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_11,
567        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_11) / sizeof(struct reginfo_t),
568        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_11) / sizeof(struct reginfo_t),
569     },
570     #else
571     {
572        .rk_sensor_init_width = INVALID_VALUE,
573        .rk_sensor_init_height = INVALID_VALUE,
574        .rk_sensor_init_bus_param = INVALID_VALUE,
575        .rk_sensor_init_pixelcode = INVALID_VALUE,
576        .rk_sensor_init_data = NULL,
577        .rk_sensor_init_winseq = NULL,
578        .rk_sensor_winseq_size = 0,
579        .rk_sensor_init_data_size = 0,
580     },
581     #endif
582     #if CONFIG_SENSOR_IIC_ADDR_12
583     {
584        .rk_sensor_init_width = INVALID_VALUE,
585        .rk_sensor_init_height = INVALID_VALUE,
586        .rk_sensor_init_bus_param = INVALID_VALUE,
587        .rk_sensor_init_pixelcode = INVALID_VALUE,
588        .rk_sensor_init_data = rk_init_data_sensor_reg_12,
589        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_12,
590        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_12) / sizeof(struct reginfo_t),
591        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_12) / sizeof(struct reginfo_t),
592     },
593     #else
594     {
595        .rk_sensor_init_width = INVALID_VALUE,
596        .rk_sensor_init_height = INVALID_VALUE,
597        .rk_sensor_init_bus_param = INVALID_VALUE,
598        .rk_sensor_init_pixelcode = INVALID_VALUE,
599        .rk_sensor_init_data = NULL,
600        .rk_sensor_init_winseq = NULL,
601        .rk_sensor_winseq_size = 0,
602        .rk_sensor_init_data_size = 0,
603     },
604     #endif
605
606  };
607 #include "../../../drivers/media/video/rk30_camera.c"
608
609 #endif /* CONFIG_VIDEO_RK29 */
610
611 #ifdef  CONFIG_TOUCHSCREEN_GT82X_IIC
612 #define TOUCH_ENABLE_PIN        INVALID_GPIO
613 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
614 #define TOUCH_INT_PIN    RK30_PIN4_PC2
615 int goodix_init_platform_hw(void)
616 {
617         int ret;
618         
619         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
620         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
621         //printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
622         if (TOUCH_ENABLE_PIN != INVALID_GPIO) {
623                 ret = gpio_request(TOUCH_ENABLE_PIN, "goodix power pin");
624                 if (ret != 0) {
625                         gpio_free(TOUCH_ENABLE_PIN);
626                         printk("goodix power error\n");
627                         return -EIO;
628                 }
629                 gpio_direction_output(TOUCH_ENABLE_PIN, 0);
630                 gpio_set_value(TOUCH_ENABLE_PIN, GPIO_LOW);
631                 msleep(100);
632         }
633
634         if (TOUCH_RESET_PIN != INVALID_GPIO) {
635                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
636                 if (ret != 0) {
637                         gpio_free(TOUCH_RESET_PIN);
638                         printk("goodix gpio_request error\n");
639                         return -EIO;
640                 }
641                 gpio_direction_output(TOUCH_RESET_PIN, 0);
642                 gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
643                 msleep(10);
644                 gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
645                 msleep(500);
646         }
647         return 0;
648 }
649 u8 ts82x_config_data[] = {
650         0x65,0x00,0x04,0x00,0x03,0x00,0x0A,0x0D,0x1E,0xE7,
651         0x32,0x03,0x08,0x10,0x48,0x42,0x42,0x20,0x00,0x01,
652         0x60,0x60,0x4B,0x6E,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,
653         0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,
654         0x1C,0x1B,0x1A,0x19,0x18,0x17,0x16,0x15,0x14,0x13,
655         0x12,0x11,0x10,0x0F,0x50,0x00,0x00,0x00,0x00,0x00,
656         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2B,0x00,0x00,
657         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
658         0x00,0x00,0x00,0x00
659 };
660 static struct goodix_i2c_rmi_platform_data ts82x_pdata = {
661     .gpio_shutdown = TOUCH_ENABLE_PIN,
662     .gpio_irq = TOUCH_INT_PIN,
663     .gpio_reset = TOUCH_RESET_PIN,
664     .irq_edge = 1, /* 0:rising edge, 1:falling edge */
665
666     .ypol = 1,
667         .swap_xy = 1,
668         .xpol = 0,
669         .xmax = 1024,
670     .ymax = 600,
671     .config_info_len =ARRAY_SIZE(ts82x_config_data),
672     .config_info = ts82x_config_data,
673         .init_platform_hw= goodix_init_platform_hw,
674 };
675 #endif
676
677 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
678
679 static int rk_headset_io_init(int gpio, char *iomux_name, int iomux_mode)
680 {
681                 int ret;
682                 ret = gpio_request(gpio, NULL);
683                 if(ret) 
684                         return ret;
685
686                 rk30_mux_api_set(iomux_name, iomux_mode);
687                 gpio_pull_updown(gpio, PullDisable);
688                 gpio_direction_input(gpio);
689                 mdelay(50);
690                 return 0;
691 };
692
693 struct rk_headset_pdata rk_headset_info = {
694                 .Headset_gpio           = RK30_PIN0_PC7,
695                 .headset_in_type = HEADSET_IN_LOW,
696                 .Hook_adc_chn = 2,
697                 .hook_key_code = KEY_MEDIA,
698                 .headset_gpio_info = {GPIO0C7_TRACECTL_SMCADDR3_NAME, GPIO0C_GPIO0C7},
699                 .headset_io_init = rk_headset_io_init,
700 };
701
702 struct platform_device rk_device_headset = {
703                 .name   = "rk_headsetdet",
704                 .id     = 0,
705                 .dev    = {
706                             .platform_data = &rk_headset_info,
707                 }
708 };
709 #endif
710
711 #if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_S3202)
712
713 #define TOUCH_RESET_PIN RK30_PIN4_PD0
714 #define TOUCH_INT_PIN   RK30_PIN4_PC2
715 #define TOUCH_POWER_PIN -1
716 #define TOUCH_IO_POWER_PIN -1
717
718 struct syna_gpio_data {
719         u16 gpio_number;
720         char* gpio_name;
721 };
722
723 int syna_init_platform_hw(void)
724 {
725     return 0;
726 }
727
728 static int synaptics_touchpad_gpio_setup(void *gpio_data, bool configure)
729 {
730         int retval=0;
731         struct syna_gpio_data *data = gpio_data;
732
733         if (configure) {
734                 retval = gpio_request(data->gpio_number, "rmi4_attn");
735                 if (retval) {
736                         pr_err("%s: Failed to get attn gpio %d. Code: %d.",
737                                __func__, data->gpio_number, retval);
738                         return retval;
739                 }
740                 rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, 0);
741                 retval = gpio_direction_input(data->gpio_number);
742                 if (retval) {
743                         pr_err("%s: Failed to setup attn gpio %d. Code: %d.",
744                                __func__, data->gpio_number, retval);
745                         gpio_free(data->gpio_number);
746                 }
747         } else {
748                 printk("%s: No way to deconfigure gpio %d.",
749                        __func__, data->gpio_number);
750         }
751
752         return retval;
753
754 }
755
756 static struct syna_gpio_data s3202_gpiodata = {
757         .gpio_number = TOUCH_INT_PIN,
758         .gpio_name = "GPIO4_C2",
759 };
760 static unsigned char s3202_key_array[4]={ KEY_BACK, KEY_MENU, KEY_HOMEPAGE, KEY_SEARCH };
761
762 struct rmi_f1a_button_map s3202_buttons = {
763                 .nbuttons = 0,
764                 .map = s3202_key_array,
765 };
766
767 static struct rmi_device_platform_data s3202_platformdata = {
768         .sensor_name = "Espresso",
769         .driver_name = "rmi_generic",
770         .attn_gpio = TOUCH_INT_PIN,
771         .attn_polarity = RMI_ATTN_ACTIVE_LOW,
772         .level_triggered = false,       /* For testing */
773         .gpio_data = &s3202_gpiodata,
774         .gpio_config = synaptics_touchpad_gpio_setup,
775         .init_hw = syna_init_platform_hw,
776         .axis_align = {
777                 .swap_axes = 1,
778                 .flip_x = 0,
779                 .flip_y = 0,
780                 .clip_X_low = 0,
781                 .clip_Y_low = 0,
782                 .clip_X_high = 0,
783                 .clip_Y_high = 0,
784         },
785         .f1a_button_map = &s3202_buttons,
786 };
787
788 #endif
789
790
791 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
792 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
793 #define TOUCH_PWR_PIN    INVALID_GPIO
794
795 int goodix_init_platform_hw(void)
796 {
797         int ret;
798         
799         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
800         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
801         printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
802
803         if (TOUCH_PWR_PIN != INVALID_GPIO) {
804                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
805                 if (ret != 0) {
806                         gpio_free(TOUCH_PWR_PIN);
807                         printk("goodix power error\n");
808                         return -EIO;
809                 }
810                 gpio_direction_output(TOUCH_PWR_PIN, 0);
811                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
812                 msleep(100);
813         }
814
815         if (TOUCH_RESET_PIN != INVALID_GPIO) {
816                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
817                 if (ret != 0) {
818                         gpio_free(TOUCH_RESET_PIN);
819                         printk("goodix gpio_request error\n");
820                         return -EIO;
821                 }
822                 gpio_direction_output(TOUCH_RESET_PIN, 1);
823                 msleep(100);
824                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
825                 //msleep(100);
826                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
827                 //msleep(500);
828         }
829         return 0;
830 }
831
832 struct goodix_platform_data goodix_info = {
833         .model = 8105,
834         .irq_pin = RK30_PIN4_PC2,
835         .rest_pin = TOUCH_RESET_PIN,
836         .init_platform_hw = goodix_init_platform_hw,
837 };
838 #endif
839
840 #if defined(CONFIG_TOUCHSCREEN_FT5306)
841
842 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
843 #define TOUCH_INT_PIN    RK30_PIN4_PC2
844 int ft5306_init_platform_hw(void)
845 {
846         printk("ft5306_init_platform_hw\n");
847
848         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, 0);
849         if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
850                 gpio_free(TOUCH_RESET_PIN);
851                 printk("ft5406_init_platform_hw gpio_request error\n");
852                 return -EIO;
853         }
854
855         if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
856                 gpio_free(TOUCH_INT_PIN);
857                 printk("ift5406_init_platform_hw gpio_request error\n");
858                 return -EIO;
859         }
860         
861         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, 0);
862
863         gpio_direction_output(TOUCH_RESET_PIN, 0);
864         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
865         mdelay(10);
866         gpio_direction_input(TOUCH_INT_PIN);
867         mdelay(10);
868         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
869         msleep(300);
870         return 0;
871
872 }
873
874 void ft5306_exit_platform_hw(void)
875 {
876         printk("ft5306_exit_platform_hw\n");
877         gpio_free(TOUCH_RESET_PIN);
878         gpio_free(TOUCH_INT_PIN);
879 }
880
881 int ft5306_platform_sleep(void)
882 {
883         //printk("ft5306_platform_sleep\n");
884         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
885         return 0;
886 }
887
888 int ft5306_platform_wakeup(void)
889 {
890         //printk("ft5306_platform_wakeup\n");
891         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
892         msleep(300);
893         return 0;
894 }
895
896 struct ft5x0x_platform_data ft5306_info = {
897   .model = 5306,
898   .max_x = 1024,
899   .max_y = 768,
900   .key_min_x = 1024,
901   .xy_swap = 1,
902   .x_revert = 1,
903   .y_revert = 0,
904   .init_platform_hw= ft5306_init_platform_hw,
905   .exit_platform_hw= ft5306_exit_platform_hw,
906   .ft5x0x_platform_sleep  = ft5306_platform_sleep,
907   .ft5x0x_platform_wakeup = ft5306_platform_wakeup,
908 };
909
910
911 #endif
912
913 #if defined(CONFIG_TOUCHSCREEN_CT360_IIC)
914 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
915 #define TOUCH_INT_PIN    RK30_PIN4_PC2
916
917 static void ct360_hw_init(void)
918 {
919         int ret;
920
921         printk("%s\n", __FUNCTION__);
922
923         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, 0);
924         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, 0);
925         
926         if(TOUCH_RESET_PIN != INVALID_GPIO){
927                 gpio_request(TOUCH_RESET_PIN, "ct360_reset");
928                 gpio_direction_output(TOUCH_RESET_PIN, GPIO_HIGH);
929         }
930
931         if(TOUCH_INT_PIN != INVALID_GPIO){
932                 ret = gpio_request(TOUCH_INT_PIN, "ct360_irq");
933                 if(ret != 0){
934                         gpio_free(TOUCH_INT_PIN);
935                         printk("%s: ct360 irq request err\n", __func__);
936                 }
937                 else{
938                         gpio_direction_input(TOUCH_INT_PIN);
939                         gpio_pull_updown(TOUCH_INT_PIN, PullEnable);
940                 }
941         }
942 }
943
944 static void ct360_hw_shutdown(int reset)
945 {
946         if(TOUCH_RESET_PIN != INVALID_GPIO){
947                 if(reset){
948                         gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
949                 }
950                 else{
951                         gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
952                 }
953         }
954 }
955
956
957 static struct ct360_platform_data ct360_info = {
958         .model   = 360,
959         .x_max   = 800,
960         .y_max   = 480,
961         .hw_init = ct360_hw_init,
962         .shutdown = ct360_hw_shutdown,
963 };
964
965 #endif
966
967
968 #ifdef CONFIG_TOUCHSCREEN_GT8110 
969 #define TOUCH_ENABLE_PIN        INVALID_GPIO
970 #define TOUCH_INT_PIN           RK30_PIN4_PC2
971 #define TOUCH_RESET_PIN         RK30_PIN4_PD0
972 int goodix_init_platform_hw(void)
973 {
974
975         int ret;
976         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
977         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
978         printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
979
980         if (TOUCH_ENABLE_PIN != INVALID_GPIO) {
981                 ret = gpio_request(TOUCH_ENABLE_PIN, "goodix power pin");
982                 if (ret != 0) {
983                         gpio_free(TOUCH_ENABLE_PIN);
984                         printk("goodix power error\n");
985                         return -EIO;
986                 }
987                 gpio_direction_output(TOUCH_ENABLE_PIN, 0);
988                 gpio_set_value(TOUCH_ENABLE_PIN, GPIO_LOW);
989                 msleep(100);
990         }
991
992         if (TOUCH_RESET_PIN != INVALID_GPIO) {
993                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
994                 if (ret != 0) {
995                         gpio_free(TOUCH_RESET_PIN);
996                         printk("goodix gpio_request error\n");
997                         return -EIO;
998                 }
999                 gpio_direction_output(TOUCH_RESET_PIN, 0);
1000                 //msleep(100);
1001                 gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
1002                 msleep(100);
1003                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
1004                 //msleep(500);
1005         }
1006         return 0;
1007 }
1008
1009 int goodix_exit_platform_hw(void)
1010 {
1011     return 0;
1012 }
1013
1014 struct goodix_8110_platform_data  goodix_info = {
1015         .irq_pin = TOUCH_INT_PIN,
1016         .reset= TOUCH_RESET_PIN,
1017         .hw_init = goodix_init_platform_hw,
1018         .hw_exit = goodix_exit_platform_hw,
1019 };
1020 #endif
1021
1022 #if defined(CONFIG_TS_AUTO_I2C)
1023 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
1024 #define TOUCH_INT_PIN    RK30_PIN4_PC2
1025 int ts_init_platform_hw(void)
1026 {
1027         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, 0);  
1028         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, 0);
1029
1030         gpio_request(TOUCH_INT_PIN, "ts_irq_pin");
1031         gpio_request(TOUCH_RESET_PIN, "ts_reset_pin");
1032         gpio_direction_output(TOUCH_RESET_PIN, GPIO_LOW);
1033         msleep(10);
1034         gpio_direction_output(TOUCH_RESET_PIN, GPIO_HIGH);
1035         msleep(200);
1036         printk("%s\n",__func__);
1037         return 0;
1038 }
1039
1040 struct ts_platform_data  auto_ts_info = {
1041         .irq = TOUCH_INT_PIN,
1042         .power_pin = INVALID_GPIO,
1043         .reset_pin = TOUCH_RESET_PIN,
1044         .init_platform_hw = ts_init_platform_hw,
1045 };
1046
1047 #endif
1048
1049 static struct spi_board_info board_spi_devices[] = {
1050 };
1051
1052 /***********************************************************
1053 *       rk30  backlight
1054 ************************************************************/
1055 #ifdef CONFIG_BACKLIGHT_RK29_BL
1056 #define PWM_ID            2
1057 #define PWM_MUX_NAME      GPIO0D6_PWM2_NAME
1058 #define PWM_MUX_MODE      GPIO0D_PWM2
1059 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
1060 #define PWM_GPIO          RK30_PIN0_PD6
1061 #define PWM_EFFECT_VALUE  1
1062
1063 #define LCD_DISP_ON_PIN
1064
1065 #ifdef  LCD_DISP_ON_PIN
1066 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
1067 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
1068
1069 #define BL_EN_PIN         RK30_PIN6_PB3
1070 #define BL_EN_VALUE       GPIO_HIGH
1071 #endif
1072 static int rk29_backlight_io_init(void)
1073 {
1074         int ret = 0;
1075         //rk30_mux_api_set(GPIO0D6_PWM2_NAME, GPIO0D_GPIO0D6);
1076         //gpio_request(RK30_PIN0_PD6, NULL);
1077         //gpio_direction_output(RK30_PIN0_PD6, GPIO_HIGH);
1078
1079         rk30_mux_api_set(GPIO0D6_PWM2_NAME, GPIO0D_PWM2);
1080         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1081 #ifdef  LCD_DISP_ON_PIN
1082         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1083
1084         ret = gpio_request(BL_EN_PIN, NULL);
1085         if (ret != 0) {
1086                 gpio_free(BL_EN_PIN);
1087         }
1088
1089         gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
1090         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1091 #endif
1092         return ret;
1093 }
1094
1095 static int rk29_backlight_io_deinit(void)
1096 {
1097         int ret = 0;
1098 #ifdef  LCD_DISP_ON_PIN
1099         gpio_free(BL_EN_PIN);
1100 #endif
1101         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1102         return ret;
1103 }
1104
1105 static int rk29_backlight_pwm_suspend(void)
1106 {
1107         int ret = 0;
1108         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1109         if (gpio_request(PWM_GPIO, NULL)) {
1110                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1111                 return -1;
1112         }
1113         gpio_direction_output(PWM_GPIO, !PWM_EFFECT_VALUE);
1114 #ifdef  LCD_DISP_ON_PIN
1115         gpio_direction_output(BL_EN_PIN, 0);
1116         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1117 #endif
1118         return ret;
1119 }
1120
1121 static int rk29_backlight_pwm_resume(void)
1122 {
1123         gpio_free(PWM_GPIO);
1124         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1125 #ifdef  LCD_DISP_ON_PIN
1126         msleep(30);
1127         gpio_direction_output(BL_EN_PIN, 1);
1128         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1129 #endif
1130         return 0;
1131 }
1132
1133 static struct rk29_bl_info rk29_bl_info = {
1134         .pwm_id = PWM_ID,
1135         .bl_ref = PWM_EFFECT_VALUE,
1136         .io_init = rk29_backlight_io_init,
1137         .io_deinit = rk29_backlight_io_deinit,
1138         .pwm_suspend = rk29_backlight_pwm_suspend,
1139         .pwm_resume = rk29_backlight_pwm_resume,
1140         .pre_div = 20000,
1141 };
1142
1143 static struct platform_device rk29_device_backlight = {
1144         .name   = "rk29_backlight",
1145         .id     = -1,
1146         .dev    = {
1147                 .platform_data  = &rk29_bl_info,
1148         }
1149 };
1150
1151 #endif
1152
1153 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
1154
1155 static int rt3261_io_init(int gpio, char *iomux_name, int iomux_mode)
1156 {
1157         gpio_request(gpio,NULL);
1158         rk30_mux_api_set(iomux_name, iomux_mode);
1159         gpio_direction_output(gpio,1);
1160         
1161 };
1162
1163 static struct rt3261_platform_data rt3261_info = {
1164         .codec_en_gpio                  = RK30_PIN4_PD7,
1165         .codec_en_gpio_info             = {GPIO4D7_SMCDATA15_TRACEDATA15_NAME,GPIO4D_GPIO4D7},
1166         .io_init                        = rt3261_io_init,
1167 };
1168
1169 #endif
1170
1171 #ifdef CONFIG_RK29_SUPPORT_MODEM
1172
1173 #define RK30_MODEM_POWER        RK30_PIN4_PD1
1174 #define RK30_MODEM_POWER_IOMUX  rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
1175
1176 static int rk30_modem_io_init(void)
1177 {
1178     printk("%s\n", __FUNCTION__);
1179     RK30_MODEM_POWER_IOMUX;
1180
1181         return 0;
1182 }
1183
1184 static struct rk29_io_t rk30_modem_io = {
1185     .io_addr    = RK30_MODEM_POWER,
1186     .enable     = GPIO_HIGH,
1187     .disable    = GPIO_LOW,
1188     .io_init    = rk30_modem_io_init,
1189 };
1190
1191 static struct platform_device rk30_device_modem = {
1192         .name   = "rk30_modem",
1193         .id     = -1,
1194         .dev    = {
1195                 .platform_data  = &rk30_modem_io,
1196         }
1197 };
1198 #endif
1199 #if defined(CONFIG_MU509)
1200 static int mu509_io_init(void)
1201 {
1202
1203         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
1204         rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
1205         rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
1206         rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
1207         return 0;
1208 }
1209
1210 static int mu509_io_deinit(void)
1211 {
1212         
1213         return 0;
1214 }
1215  
1216 struct rk29_mu509_data rk29_mu509_info = {
1217         .io_init = mu509_io_init,
1218         .io_deinit = mu509_io_deinit,
1219         .modem_power_en = RK30_PIN6_PB2,//RK30_PIN4_PD1,
1220         .bp_power = RK30_PIN2_PB6,//RK30_PIN4_PD1,
1221         .bp_reset = RK30_PIN4_PD2,
1222         .ap_wakeup_bp = RK30_PIN2_PB7,
1223         .bp_wakeup_ap = RK30_PIN6_PA0, 
1224 };
1225 struct platform_device rk29_device_mu509 = {    
1226         .name = "mu509",        
1227         .id = -1,       
1228         .dev            = {
1229                 .platform_data = &rk29_mu509_info,
1230         }       
1231     };
1232 #endif
1233 #if defined(CONFIG_MW100)
1234 static int mw100_io_init(void)
1235 {
1236          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
1237          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
1238          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
1239          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
1240         return 0;
1241 }
1242
1243 static int mw100_io_deinit(void)
1244 {
1245         
1246         return 0;
1247 }
1248  
1249 struct rk29_mw100_data rk29_mw100_info = {
1250         .io_init = mw100_io_init,
1251         .io_deinit = mw100_io_deinit,
1252         .modem_power_en = RK30_PIN6_PB2,
1253         .bp_power = RK30_PIN2_PB6,
1254         .bp_reset = RK30_PIN4_PD2,
1255         .ap_wakeup_bp = RK30_PIN2_PB7,
1256         .bp_wakeup_ap = RK30_PIN6_PA0,
1257 };
1258 struct platform_device rk29_device_mw100 = {    
1259         .name = "mw100",        
1260         .id = -1,       
1261         .dev            = {
1262                 .platform_data = &rk29_mw100_info,
1263         }       
1264     };
1265 #endif
1266 #if defined(CONFIG_MT6229)
1267 static int mt6229_io_init(void)
1268 {
1269          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
1270          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
1271          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
1272          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
1273          rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
1274          rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
1275
1276          return 0;
1277 }
1278
1279 static int mt6229_io_deinit(void)
1280 {
1281         
1282         return 0;
1283 }
1284  
1285 struct rk29_mt6229_data rk29_mt6229_info = {
1286         .io_init = mt6229_io_init,
1287         .io_deinit = mt6229_io_deinit,
1288         .modem_power_en = RK30_PIN6_PB2, // 3g_power
1289         .bp_power = RK30_PIN2_PB6,      // 3g_en
1290         .modem_usb_en = RK30_PIN2_PC0, //W_disable
1291         .modem_uart_en = RK30_PIN2_PC1, //EINT9
1292         .bp_wakeup_ap = RK30_PIN6_PA1,  //
1293         .ap_ready = RK30_PIN2_PB7,      //
1294
1295 };
1296 struct platform_device rk29_device_mt6229 = {   
1297         .name = "mt6229",       
1298         .id = -1,       
1299         .dev            = {
1300                 .platform_data = &rk29_mt6229_info,
1301         }       
1302     };
1303 #endif
1304 #if defined(CONFIG_SEW868)
1305 static int sew868_io_init(void)
1306 {
1307         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
1308     rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
1309         rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4);
1310         return 0;
1311 }
1312 static int sew868_io_deinit(void)
1313 {
1314         return 0;
1315 }
1316 struct rk30_sew868_data rk30_sew868_info = {
1317         .io_init = sew868_io_init,
1318         .io_deinit = sew868_io_deinit,
1319         .bp_power = RK30_PIN6_PB2, 
1320         .bp_power_active_low = 1,
1321         .bp_sys = RK30_PIN2_PB6, 
1322         .bp_reset = RK30_PIN4_PD2, 
1323         .bp_reset_active_low = 1,
1324         .bp_wakeup_ap = RK30_PIN4_PD4, 
1325         .ap_wakeup_bp = NULL,
1326 };
1327
1328 struct platform_device rk30_device_sew868 = {   
1329         .name = "sew868",       
1330         .id = -1,       
1331         .dev            = {
1332                 .platform_data = &rk30_sew868_info,
1333         }       
1334     };
1335 #endif
1336 #if defined(CONFIG_MI700)
1337 #define BP_POWER        RK29_PIN6_PB1   
1338 #define BP_RESET        RK29_PIN6_PC7
1339 static int mi700_io_init(void)
1340 {
1341         int result;
1342         result = gpio_request(BP_RESET, NULL);
1343         if (result)
1344         {
1345                 gpio_free(BP_RESET);
1346                 printk("failed to request BP_RESET gpio\n");
1347         }
1348         result = gpio_request(BP_POWER, NULL);
1349         if (result)
1350         {
1351                 gpio_free(BP_POWER);
1352                 printk("failed to request BP_POWER gpio\n");
1353         }
1354         return 0;
1355 }
1356
1357 static int mi700_io_deinit(void)
1358 {
1359         gpio_free(BP_RESET);
1360         gpio_free(BP_POWER);
1361
1362         return 0;
1363 }
1364
1365 struct rk29_mi700_data rk29_mi700_info = {
1366         .io_init = mi700_io_init,
1367         .io_deinit = mi700_io_deinit,
1368         .bp_power = RK29_PIN6_PB1,//RK29_PIN0_PB4,
1369         .bp_reset = RK29_PIN6_PC7,//RK29_PIN0_PB3,
1370         .bp_wakeup_ap = RK29_PIN6_PC6,//RK29_PIN0_PC2,
1371         .ap_wakeup_bp = NULL,//RK29_PIN0_PB0, 
1372 };
1373 struct platform_device rk29_device_mi700 = {
1374         .name = "MI700",
1375         .id = -1,
1376         .dev            = {
1377                 .platform_data = &rk29_mi700_info,
1378         }
1379     };
1380 #endif
1381 /*MMA8452 gsensor*/
1382 #if defined (CONFIG_GS_MMA8452)
1383 #define MMA8452_INT_PIN   RK30_PIN4_PC0
1384
1385 static int mma8452_init_platform_hw(void)
1386 {
1387         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
1388
1389         return 0;
1390 }
1391
1392 static struct sensor_platform_data mma8452_info = {
1393         .type = SENSOR_TYPE_ACCEL,
1394         .irq_enable = 1,
1395         .poll_delay_ms = 30,
1396         .init_platform_hw = mma8452_init_platform_hw,
1397         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
1398 };
1399 #endif
1400 #if defined (CONFIG_GS_LIS3DH)
1401 #define LIS3DH_INT_PIN   RK30_PIN4_PC0
1402
1403 static int lis3dh_init_platform_hw(void)
1404 {
1405         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
1406
1407         return 0;
1408 }
1409
1410 static struct sensor_platform_data lis3dh_info = {
1411         .type = SENSOR_TYPE_ACCEL,
1412         .irq_enable = 1,
1413         .poll_delay_ms = 30,
1414         .init_platform_hw = lis3dh_init_platform_hw,
1415         .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
1416 };
1417 #endif
1418 #if defined (CONFIG_GS_KXTIK)
1419 #define KXTIK_INT_PIN   RK30_PIN4_PC0
1420
1421 static int kxtik_init_platform_hw(void)
1422 {
1423         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
1424
1425         return 0;
1426 }
1427
1428 static struct sensor_platform_data kxtik_info = {
1429         .type = SENSOR_TYPE_ACCEL,
1430         .irq_enable = 1,
1431         .poll_delay_ms = 30,
1432         .init_platform_hw = kxtik_init_platform_hw,
1433         .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
1434 };
1435
1436 #endif
1437
1438 /*MMA7660 gsensor*/
1439 #if defined (CONFIG_GS_MMA7660)
1440 #define MMA7660_INT_PIN   RK30_PIN4_PC0
1441
1442 static int mma7660_init_platform_hw(void)
1443 {
1444         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
1445
1446         return 0;
1447 }
1448
1449 static struct sensor_platform_data mma7660_info = {
1450         .type = SENSOR_TYPE_ACCEL,
1451         .irq_enable = 1,
1452         .poll_delay_ms = 30,
1453         .init_platform_hw = mma7660_init_platform_hw,
1454         .orientation = {1, 0, 0, 0, 0, -1, 0, -1, 0},
1455 };
1456 #endif
1457
1458 #if defined (CONFIG_COMPASS_AK8975)
1459 static struct sensor_platform_data akm8975_info =
1460 {
1461         .type = SENSOR_TYPE_COMPASS,
1462         .irq_enable = 1,
1463         .poll_delay_ms = 30,
1464         .m_layout = 
1465         {
1466                 {
1467                         {0, 1, 0},
1468                         {1, 0, 0},      
1469                         {0, 0, -1},
1470                 },
1471
1472                 {
1473                         {1, 0, 0},
1474                         {0, 1, 0},
1475                         {0, 0, 1},
1476                 },
1477
1478                 {
1479                         {1, 0, 0},
1480                         {0, 1, 0},
1481                         {0, 0, 1},
1482                 },
1483
1484                 {
1485                         {1, 0, 0},
1486                         {0, 1, 0},
1487                         {0, 0, 1},
1488                 },
1489         }
1490 };
1491
1492 #endif
1493
1494 #if defined(CONFIG_GYRO_L3G4200D)
1495
1496 #include <linux/l3g4200d.h>
1497 #define L3G4200D_INT_PIN  RK30_PIN4_PC3
1498
1499 static int l3g4200d_init_platform_hw(void)
1500 {
1501         rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
1502         
1503         return 0;
1504 }
1505
1506 static struct sensor_platform_data l3g4200d_info = {
1507         .type = SENSOR_TYPE_GYROSCOPE,
1508         .irq_enable = 1,
1509         .poll_delay_ms = 30,
1510         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, -1},
1511         .init_platform_hw = l3g4200d_init_platform_hw,
1512         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
1513         .y_min = 40,
1514         .z_min = 20,
1515 };
1516
1517 #endif
1518
1519 #ifdef CONFIG_LS_CM3217
1520 static struct sensor_platform_data cm3217_info = {
1521         .type = SENSOR_TYPE_LIGHT,
1522         .irq_enable = 0,
1523         .poll_delay_ms = 500,
1524 };
1525
1526 #endif
1527
1528
1529 #if defined(CONFIG_PS_AL3006)
1530 static struct sensor_platform_data proximity_al3006_info = {
1531         .type = SENSOR_TYPE_PROXIMITY,
1532         .irq_enable = 1,
1533         .poll_delay_ms = 200,
1534 };
1535 #endif
1536
1537 #if defined(CONFIG_PS_STK3171)
1538 static struct sensor_platform_data proximity_stk3171_info = {
1539         .type = SENSOR_TYPE_PROXIMITY,
1540         .irq_enable = 1,
1541         .poll_delay_ms = 200,
1542 };
1543 #endif
1544
1545
1546 #if defined(CONFIG_LS_AL3006)
1547 static struct sensor_platform_data light_al3006_info = {
1548         .type = SENSOR_TYPE_LIGHT,
1549         .irq_enable = 1,
1550         .poll_delay_ms = 200,
1551 };
1552 #endif
1553
1554 #if defined(CONFIG_LS_STK3171)
1555 static struct sensor_platform_data light_stk3171_info = {
1556         .type = SENSOR_TYPE_LIGHT,
1557         .irq_enable = 1,
1558         .poll_delay_ms = 200,
1559 };
1560 #endif
1561
1562 #if defined(CONFIG_LS_ISL29023)
1563 static struct sensor_platform_data light_isl29023_info = {
1564         .type = SENSOR_TYPE_LIGHT,
1565         .irq_enable = 1,
1566         .poll_delay_ms = 200,
1567 };
1568 #endif
1569
1570
1571
1572
1573 #ifdef CONFIG_FB_ROCKCHIP
1574
1575 #define LCD_CS_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
1576 #define LCD_CS_PIN         RK30_PIN4_PC7
1577 #define LCD_CS_VALUE       GPIO_HIGH
1578
1579 #define LCD_STANDBY_MUX_NAME    GPIO4D2_SMCDATA10_TRACEDATA10_NAME
1580 #define LCD_STANDBY_PIN         RK30_PIN4_PD2
1581 #define LCD_STANDBY_VALUE       GPIO_HIGH
1582
1583 #define LCD_RST_MUX_NAME    GPIO4D1_SMCDATA9_TRACEDATA9_NAME
1584 #define LCD_RST_PIN         RK30_PIN4_PD1
1585 #define LCD_RST_VALUE       GPIO_HIGH
1586
1587 #define LCD_EN_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
1588 #define LCD_EN_PIN         RK30_PIN6_PB4
1589 #define LCD_EN_VALUE       GPIO_LOW
1590
1591 #define HDMI11_MUX_NAME                GPIO3A6_SDMMC0RSTNOUT_NAME
1592 #define HDMI11_EN_PIN          RK30_PIN3_PA6
1593 #define HDMI11_EN_VALUE        GPIO_HIGH
1594
1595
1596 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
1597 {
1598         int ret = 0;
1599
1600         rk30_mux_api_set(GPIO3A6_SDMMC0RSTNOUT_NAME, GPIO3A_GPIO3A6);
1601         ret = gpio_request(HDMI11_EN_PIN, NULL);
1602         if (ret != 0)
1603         {
1604                 gpio_free(HDMI11_EN_PIN);
1605                 printk(KERN_ERR "hdmi gpio fail!\n");
1606                 return -1;
1607         }
1608         else
1609         {
1610                 gpio_direction_output(HDMI11_EN_PIN, HDMI11_EN_VALUE);
1611         }
1612
1613         rk30_mux_api_set(LCD_CS_MUX_NAME, GPIO4C_GPIO4C7);
1614         ret = gpio_request(LCD_CS_PIN, NULL);
1615         if (ret != 0)
1616         {
1617                 gpio_free(LCD_CS_PIN);
1618                 printk(KERN_ERR "request lcd cs pin fail!\n");
1619                 return -1;
1620         }
1621         else
1622         {
1623                 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
1624         }
1625         ret = gpio_request(LCD_EN_PIN, NULL);
1626         if (ret != 0)
1627         {
1628                 gpio_free(LCD_EN_PIN);
1629                 printk(KERN_ERR "request lcd en pin fail!\n");
1630                 return -1;
1631         }
1632         else
1633         {
1634                 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
1635         }
1636
1637         rk30_mux_api_set(LCD_STANDBY_MUX_NAME, GPIO4D_GPIO4D2);
1638         ret = gpio_request(LCD_STANDBY_PIN, NULL);
1639         if (ret != 0)
1640         {
1641                 gpio_free(LCD_STANDBY_PIN);
1642                 printk(KERN_ERR "request lcd cs pin fail!\n");
1643                 return -1;
1644         }
1645         else
1646         {
1647                 gpio_direction_output(LCD_STANDBY_PIN, LCD_STANDBY_VALUE);
1648         }
1649
1650         rk30_mux_api_set(LCD_RST_MUX_NAME, GPIO4D_GPIO4D1);
1651         ret = gpio_request(LCD_RST_PIN, NULL);
1652         if (ret != 0)
1653         {
1654                 gpio_free(LCD_RST_PIN);
1655                 printk(KERN_ERR "request lcd cs pin fail!\n");
1656                 return -1;
1657         }
1658         else
1659         {
1660                 gpio_direction_output(LCD_RST_PIN, LCD_RST_VALUE);
1661         }
1662         
1663         return 0;
1664 }
1665 static int rk_fb_io_disable(void)
1666 {
1667         msleep(30);             //Response Time (Rising + Falling)
1668         gpio_set_value(HDMI11_EN_PIN, HDMI11_EN_VALUE? 0:1);
1669         gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE? 0:1);
1670         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE? 0:1);  
1671         gpio_set_value(LCD_RST_PIN, LCD_RST_VALUE? 0:1);
1672         gpio_set_value(LCD_STANDBY_PIN, LCD_STANDBY_VALUE? 0:1);        
1673         return 0;
1674 }
1675 static int rk_fb_io_enable(void)
1676 {
1677         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);       
1678         gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
1679         gpio_set_value(HDMI11_EN_PIN, HDMI11_EN_VALUE);
1680         gpio_set_value(LCD_RST_PIN, LCD_RST_VALUE);             
1681         gpio_set_value(LCD_STANDBY_PIN, LCD_STANDBY_VALUE);     
1682         msleep(150);    //wait for power stable
1683         return 0;
1684 }
1685
1686 #if defined(CONFIG_LCDC0_RK30)
1687 struct rk29fb_info lcdc0_screen_info = {
1688         .prop      = PRMRY,             //primary display device
1689         .io_init   = rk_fb_io_init,
1690         .io_disable = rk_fb_io_disable,
1691         .io_enable = rk_fb_io_enable,
1692         .set_screen_info = set_lcd_info,
1693 };
1694 #endif
1695
1696 #if defined(CONFIG_LCDC1_RK30)
1697 struct rk29fb_info lcdc1_screen_info = {
1698         #if defined(CONFIG_HDMI_RK30)
1699         .prop           = EXTEND,       //extend display device
1700         .lcd_info  = NULL,
1701         .set_screen_info = hdmi_init_lcdc,
1702         #endif
1703 };
1704 #endif
1705
1706 static struct resource resource_fb[] = {
1707         [0] = {
1708                 .name  = "fb0 buf",
1709                 .start = 0,
1710                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1711                 .flags = IORESOURCE_MEM,
1712         },
1713         [1] = {
1714                 .name  = "ipp buf",  //for rotate
1715                 .start = 0,
1716                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1717                 .flags = IORESOURCE_MEM,
1718         },
1719         [2] = {
1720                 .name  = "fb2 buf",
1721                 .start = 0,
1722                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1723                 .flags = IORESOURCE_MEM,
1724         },
1725 };
1726
1727 static struct platform_device device_fb = {
1728         .name           = "rk-fb",
1729         .id             = -1,
1730         .num_resources  = ARRAY_SIZE(resource_fb),
1731         .resource       = resource_fb,
1732 };
1733 #endif
1734
1735 #if defined(CONFIG_LCDC0_RK30)
1736 static struct resource resource_lcdc0[] = {
1737         [0] = {
1738                 .name  = "lcdc0 reg",
1739                 .start = RK30_LCDC0_PHYS,
1740                 .end   = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
1741                 .flags = IORESOURCE_MEM,
1742         },
1743         
1744         [1] = {
1745                 .name  = "lcdc0 irq",
1746                 .start = IRQ_LCDC0,
1747                 .end   = IRQ_LCDC0,
1748                 .flags = IORESOURCE_IRQ,
1749         },
1750 };
1751
1752 static struct platform_device device_lcdc0 = {
1753         .name             = "rk30-lcdc",
1754         .id               = 0,
1755         .num_resources    = ARRAY_SIZE(resource_lcdc0),
1756         .resource         = resource_lcdc0,
1757         .dev            = {
1758                 .platform_data = &lcdc0_screen_info,
1759         },
1760 };
1761 #endif
1762 #if defined(CONFIG_LCDC1_RK30) 
1763 extern struct rk29fb_info lcdc1_screen_info;
1764 static struct resource resource_lcdc1[] = {
1765         [0] = {
1766                 .name  = "lcdc1 reg",
1767                 .start = RK30_LCDC1_PHYS,
1768                 .end   = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
1769                 .flags = IORESOURCE_MEM,
1770         },
1771         [1] = {
1772                 .name  = "lcdc1 irq",
1773                 .start = IRQ_LCDC1,
1774                 .end   = IRQ_LCDC1,
1775                 .flags = IORESOURCE_IRQ,
1776         },
1777 };
1778
1779 static struct platform_device device_lcdc1 = {
1780         .name             = "rk30-lcdc",
1781         .id               = 1,
1782         .num_resources    = ARRAY_SIZE(resource_lcdc1),
1783         .resource         = resource_lcdc1,
1784         .dev            = {
1785                 .platform_data = &lcdc1_screen_info,
1786         },
1787 };
1788 #endif
1789
1790 #ifdef CONFIG_ANDROID_TIMED_GPIO
1791 static struct timed_gpio timed_gpios[] = {
1792         {
1793                 .name = "vibrator",
1794                 .gpio = RK30_PIN0_PA4,
1795                 .max_timeout = 1000,
1796                 .active_low = 0,
1797                 .adjust_time =20,      //adjust for diff product
1798         },
1799 };
1800
1801 static struct timed_gpio_platform_data rk29_vibrator_info = {
1802         .num_gpios = 1,
1803         .gpios = timed_gpios,
1804 };
1805
1806 static struct platform_device rk29_device_vibrator = {
1807         .name = "timed-gpio",
1808         .id = -1,
1809         .dev = {
1810                 .platform_data = &rk29_vibrator_info,
1811         },
1812
1813 };
1814 #endif
1815
1816 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1817 static struct gpio_led rk29_leds[] = {
1818         {
1819                 .name = "button-backlight",
1820                 .gpio = RK30_PIN4_PD7,
1821                 .default_trigger = "timer",
1822                 .active_low = 0,
1823                 .retain_state_suspended = 0,
1824                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1825         },
1826 };
1827
1828 static struct gpio_led_platform_data rk29_leds_pdata = {
1829         .leds = rk29_leds,
1830         .num_leds = ARRAY_SIZE(rk29_leds),
1831 };
1832
1833 static struct platform_device rk29_device_gpio_leds = {
1834         .name   = "leds-gpio",
1835         .id     = -1,
1836         .dev    = {
1837                 .platform_data  = &rk29_leds_pdata,
1838         },
1839 };
1840 #endif
1841
1842 #ifdef CONFIG_RK_IRDA
1843 #define IRDA_IRQ_PIN           RK30_PIN6_PA1
1844
1845 static int irda_iomux_init(void)
1846 {
1847         int ret = 0;
1848
1849         //irda irq pin
1850         ret = gpio_request(IRDA_IRQ_PIN, NULL);
1851         if (ret != 0) {
1852                 gpio_free(IRDA_IRQ_PIN);
1853                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1854         }
1855         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1856         gpio_direction_input(IRDA_IRQ_PIN);
1857
1858         return 0;
1859 }
1860
1861 static int irda_iomux_deinit(void)
1862 {
1863         gpio_free(IRDA_IRQ_PIN);
1864         return 0;
1865 }
1866
1867 static struct irda_info rk29_irda_info = {
1868         .intr_pin = IRDA_IRQ_PIN,
1869         .iomux_init = irda_iomux_init,
1870         .iomux_deinit = irda_iomux_deinit,
1871         //.irda_pwr_ctl = bu92747guw_power_ctl,
1872 };
1873
1874 static struct platform_device irda_device = {
1875 #ifdef CONFIG_RK_IRDA_NET
1876         .name = "rk_irda",
1877 #else
1878         .name = "bu92747_irda",
1879 #endif
1880         .id = -1,
1881         .dev = {
1882                 .platform_data = &rk29_irda_info,
1883         }
1884 };
1885 #endif
1886
1887 #ifdef CONFIG_ION
1888 #define ION_RESERVE_SIZE        (80 * SZ_1M)
1889 static struct ion_platform_data rk30_ion_pdata = {
1890         .nr = 1,
1891         .heaps = {
1892                 {
1893                         .type = ION_HEAP_TYPE_CARVEOUT,
1894                         .id = ION_NOR_HEAP_ID,
1895                         .name = "norheap",
1896                         .size = ION_RESERVE_SIZE,
1897                 }
1898         },
1899 };
1900
1901 static struct platform_device device_ion = {
1902         .name = "ion-rockchip",
1903         .id = 0,
1904         .dev = {
1905                 .platform_data = &rk30_ion_pdata,
1906         },
1907 };
1908 #endif
1909
1910 /**************************************************************************************************
1911  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
1912 **************************************************************************************************/
1913 #ifdef CONFIG_SDMMC_RK29
1914 #include "board-rk30-sdk-sdmmc.c"
1915
1916 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1917 #define SDMMC0_WRITE_PROTECT_PIN        RK30_PIN3_PB7   //According to your own project to set the value of write-protect-pin.
1918 #endif
1919
1920 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1921 #define SDMMC1_WRITE_PROTECT_PIN        RK30_PIN3_PC7   //According to your own project to set the value of write-protect-pin.
1922 #endif
1923
1924 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
1925 #define RK29SDK_WIFI_SDIO_CARD_INT         RK30_PIN3_PD2
1926
1927 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
1928
1929 #ifdef CONFIG_SDMMC0_RK29
1930 static int rk29_sdmmc0_cfg_gpio(void)
1931 {
1932 #ifdef CONFIG_SDMMC_RK29_OLD
1933         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1934         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1935         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1936         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1937         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1938         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1939
1940         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1941
1942         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1943         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1944         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1945
1946 #else
1947         rk29_sdmmc_set_iomux(0, 0xFFFF);
1948
1949         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
1950
1951 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1952         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1953         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1954 #endif
1955
1956 #endif
1957
1958         return 0;
1959 }
1960
1961 #define CONFIG_SDMMC0_USE_DMA
1962 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1963         .host_ocr_avail =
1964             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1965              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1966              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1967         .host_caps =
1968             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1969         .io_init = rk29_sdmmc0_cfg_gpio,
1970
1971 #if !defined(CONFIG_SDMMC_RK29_OLD)
1972         .set_iomux = rk29_sdmmc_set_iomux,
1973 #endif
1974
1975         .dma_name = "sd_mmc",
1976 #ifdef CONFIG_SDMMC0_USE_DMA
1977         .use_dma = 1,
1978 #else
1979         .use_dma = 0,
1980 #endif
1981
1982 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1983     .status = rk29sdk_wifi_mmc0_status,
1984     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1985 #endif
1986
1987         .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
1988         .enable_sd_wakeup = 0,
1989
1990 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1991         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1992 #else
1993         .write_prt = INVALID_GPIO,
1994 #endif
1995 };
1996 #endif // CONFIG_SDMMC0_RK29
1997
1998 #ifdef CONFIG_SDMMC1_RK29
1999 #define CONFIG_SDMMC1_USE_DMA
2000 static int rk29_sdmmc1_cfg_gpio(void)
2001 {
2002 #if defined(CONFIG_SDMMC_RK29_OLD)
2003         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
2004         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
2005         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
2006         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
2007         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
2008         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
2009         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
2010
2011 #else
2012
2013 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2014         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
2015         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
2016 #endif
2017
2018 #endif
2019
2020         return 0;
2021 }
2022
2023 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2024         .host_ocr_avail =
2025             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
2026              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
2027              MMC_VDD_33_34),
2028
2029 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
2030         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
2031                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
2032 #else
2033         .host_caps =
2034             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
2035 #endif
2036
2037         .io_init = rk29_sdmmc1_cfg_gpio,
2038
2039 #if !defined(CONFIG_SDMMC_RK29_OLD)
2040         .set_iomux = rk29_sdmmc_set_iomux,
2041 #endif
2042
2043         .dma_name = "sdio",
2044 #ifdef CONFIG_SDMMC1_USE_DMA
2045         .use_dma = 1,
2046 #else
2047         .use_dma = 0,
2048 #endif
2049
2050 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
2051 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2052         .status = rk29sdk_wifi_status,
2053         .register_status_notify = rk29sdk_wifi_status_register,
2054 #endif
2055 #if 0
2056         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2057 #endif
2058
2059 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2060         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
2061 #else
2062         .write_prt = INVALID_GPIO,
2063 #endif
2064
2065 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
2066     .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
2067 #endif
2068
2069 #else
2070         .detect_irq = INVALID_GPIO,
2071         .enable_sd_wakeup = 0,
2072 #endif
2073
2074 };
2075 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
2076
2077 /**************************************************************************************************
2078  * the end of setting for SDMMC devices
2079 **************************************************************************************************/
2080
2081 #ifdef CONFIG_BATTERY_RK30_ADC
2082 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
2083         .dc_det_pin      = RK30_PIN6_PA5,
2084         .batt_low_pin    = RK30_PIN6_PA0,
2085         .charge_set_pin  = INVALID_GPIO,
2086         .charge_ok_pin   = RK30_PIN6_PA6,
2087         .dc_det_level    = GPIO_LOW,
2088         .charge_ok_level = GPIO_HIGH,
2089 };
2090
2091 static struct platform_device rk30_device_adc_battery = {
2092         .name   = "rk30-battery",
2093         .id     = -1,
2094         .dev = {
2095                 .platform_data = &rk30_adc_battery_platdata,
2096         },
2097 };
2098 #endif
2099 #ifdef CONFIG_RK30_PWM_REGULATOR
2100 const static int pwm_voltage_map[] = {
2101         1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
2102 };
2103
2104 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
2105         {
2106                 .supply = "vdd_core",
2107         }
2108 };
2109
2110 struct regulator_init_data pwm_regulator_init_dcdc[1] =
2111 {
2112         {
2113                 .constraints = {
2114                         .name = "PWM_DCDC1",
2115                         .min_uV = 600000,
2116                         .max_uV = 1800000,      //0.6-1.8V
2117                         .apply_uV = true,
2118                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2119                 },
2120                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
2121                 .consumer_supplies = pwm_dcdc1_consumers,
2122         },
2123 };
2124
2125 static struct pwm_platform_data pwm_regulator_info[1] = {
2126         {
2127                 .pwm_id = 3,
2128                 .pwm_gpio = RK30_PIN0_PD7,
2129                 .pwm_iomux_name = GPIO0D7_PWM3_NAME,
2130                 .pwm_iomux_pwm = GPIO0D_PWM3,
2131                 .pwm_iomux_gpio = GPIO0D_GPIO0D6,
2132                 .pwm_voltage = 1100000,
2133                 .suspend_voltage = 1050000,
2134                 .min_uV = 1000000,
2135                 .max_uV = 1400000,
2136                 .coefficient = 455,     //45.5%
2137                 .pwm_voltage_map = pwm_voltage_map,
2138                 .init_data      = &pwm_regulator_init_dcdc[0],
2139         },
2140 };
2141
2142 struct platform_device pwm_regulator_device[1] = {
2143         {
2144                 .name = "pwm-voltage-regulator",
2145                 .id = 0,
2146                 .dev            = {
2147                         .platform_data = &pwm_regulator_info[0],
2148                 }
2149         },
2150 };
2151 #endif
2152
2153 #ifdef CONFIG_RK29_VMAC
2154 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
2155 #include "board-rk30-sdk-vmac.c"
2156 #endif
2157
2158 #ifdef CONFIG_RFKILL_RK
2159 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
2160 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
2161     .type               = RFKILL_TYPE_BLUETOOTH,
2162
2163     .poweron_gpio       = { // BT_REG_ON
2164         .io             = RK30_PIN3_PC7,
2165         .enable         = GPIO_HIGH,
2166         .iomux          = {
2167             .name       = GPIO3C7_SDMMC1WRITEPRT_NAME,
2168             .fgpio      = GPIO3C_GPIO3C7,
2169         },
2170     },
2171
2172     .reset_gpio         = { // BT_RST
2173         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
2174         .enable         = GPIO_LOW,
2175         .iomux          = {
2176             .name       = GPIO3D1_SDMMC1BACKENDPWR_NAME,
2177             .fgpio      = GPIO3D_GPIO3D1,
2178         },
2179     },
2180
2181     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
2182         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
2183         .enable         = GPIO_HIGH,
2184         .iomux          = {
2185             .name       = GPIO3C6_SDMMC1DETECTN_NAME,
2186             .fgpio      = GPIO3C_GPIO3C6,
2187         },
2188     },
2189
2190     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
2191         .gpio           = {
2192             .io         = RK30_PIN6_PA7, // set io to INVALID_GPIO for disable it
2193             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
2194             .iomux      = {
2195                 .name   = NULL,
2196             },
2197         },
2198     },
2199
2200     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
2201         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
2202         .enable         = GPIO_LOW,
2203         .iomux          = {
2204             .name       = GPIO1A3_UART0RTSN_NAME,
2205             .fgpio      = GPIO1A_GPIO1A3,
2206             .fmux       = GPIO1A_UART0_RTS_N,
2207         },
2208     },
2209 };
2210
2211 static struct platform_device device_rfkill_rk = {
2212     .name   = "rfkill_rk",
2213     .id     = -1,
2214     .dev    = {
2215         .platform_data = &rfkill_rk_platdata,
2216     },
2217 };
2218 #endif
2219
2220 #ifdef CONFIG_RK_BOARD_ID
2221 static int board_id_init_platform_hw(void)
2222 {
2223         rk30_mux_api_set(GPIO0D5_I2S22CHSDO_SMCADDR1_NAME, GPIO0D_GPIO0D5);
2224         rk30_mux_api_set(GPIO0D4_I2S22CHSDI_SMCADDR0_NAME, GPIO0D_GPIO0D4);
2225         rk30_mux_api_set(GPIO0D3_I2S22CHLRCKTX_SMCADVN_NAME, GPIO0D_GPIO0D3);
2226         rk30_mux_api_set(GPIO0D2_I2S22CHLRCKRX_SMCOEN_NAME, GPIO0D_GPIO0D2);
2227
2228         return 0;
2229 }
2230
2231 static int board_id_exit_platform_hw(void)
2232 {
2233
2234         return 0;
2235 }
2236
2237 //setting someting according to board id
2238 static int init_paramter_according_id(int id)
2239 {
2240         if(id < 0)
2241                 return -1;
2242         
2243 #if defined(CONFIG_MACH_RK30_PHONE_PAD_C8003)
2244
2245         signed char orientation[4][9] = {
2246                 {0, -1, 0, 0, 0, 1, 1, 0, 0},
2247                 {1, 0, 0, 0, 0, -1, 0, -1, 0},
2248                 {1, 0, 0, 0, 0, -1, 0, -1, 0},
2249                 {0, -1, 0, 0, 0, -1, -1, 0, 0},
2250         };
2251
2252         u32 bl_ref[4] = {1, 0, 0, 0};
2253         
2254         memcpy(mma7660_info.orientation, orientation[id], 9);   
2255         rk29_bl_info.bl_ref = bl_ref[id];
2256 #else
2257
2258
2259 #endif
2260         return 0;
2261 }
2262
2263
2264 static struct board_id_platform_data rk_board_id = {
2265         .gpio_pin = {RK30_PIN0_PD2,RK30_PIN0_PD3,RK30_PIN0_PD4,RK30_PIN0_PD5},
2266         .num_gpio = 4,
2267         .init_platform_hw = board_id_init_platform_hw,
2268         .exit_platform_hw = board_id_exit_platform_hw,
2269         .init_parameter = init_paramter_according_id,
2270 };
2271
2272
2273 static struct platform_device device_board_id = {
2274     .name   = "rk-board-id",
2275     .id     = -1,
2276     .dev    = {
2277         .platform_data = &rk_board_id,
2278     },
2279 };
2280
2281
2282 #endif
2283
2284 static struct platform_device *devices[] __initdata = {
2285 #ifdef CONFIG_FB_ROCKCHIP
2286         &device_fb,
2287 #endif
2288 #if defined(CONFIG_LCDC0_RK30)
2289         &device_lcdc0,
2290 #endif
2291 #if defined(CONFIG_LCDC1_RK30)
2292         &device_lcdc1,
2293 #endif
2294
2295 #ifdef CONFIG_BACKLIGHT_RK29_BL
2296         &rk29_device_backlight,
2297 #endif
2298
2299 #ifdef CONFIG_ION
2300         &device_ion,
2301 #endif
2302 #ifdef CONFIG_ANDROID_TIMED_GPIO
2303         &rk29_device_vibrator,
2304 #endif
2305 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2306         &rk29_device_gpio_leds,
2307 #endif
2308 #ifdef CONFIG_RK_IRDA
2309         &irda_device,
2310 #endif
2311 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2312         &rk29sdk_wifi_device,
2313 #endif
2314
2315 #if defined(CONFIG_MT6620)
2316     &mt3326_device_gps,
2317 #endif   
2318
2319 #ifdef CONFIG_RK29_SUPPORT_MODEM
2320         &rk30_device_modem,
2321 #endif
2322 #if defined(CONFIG_MU509)
2323         &rk29_device_mu509,
2324 #endif
2325 #if defined(CONFIG_MW100)
2326         &rk29_device_mw100,
2327 #endif
2328 #if defined(CONFIG_MT6229)
2329         &rk29_device_mt6229,
2330 #endif
2331 #if defined(CONFIG_SEW868)
2332         &rk30_device_sew868,
2333 #endif
2334 #if defined (CONFIG_RK_HEADSET_DET) ||  defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
2335         &rk_device_headset,
2336 #endif
2337 #if defined(CONFIG_MI700)
2338         &rk29_device_mi700,
2339 #endif
2340 #ifdef CONFIG_BATTERY_RK30_ADC
2341         &rk30_device_adc_battery,
2342 #endif
2343 #ifdef CONFIG_RFKILL_RK
2344         &device_rfkill_rk,
2345 #endif
2346 #ifdef CONFIG_RK_BOARD_ID
2347         &device_board_id,
2348 #endif
2349
2350 };
2351
2352 // i2c
2353 #ifdef CONFIG_I2C0_RK30
2354 static struct i2c_board_info __initdata i2c0_info[] = {
2355 #if defined (CONFIG_GS_MMA8452)
2356         {
2357                 .type           = "gs_mma8452",
2358                 .addr           = 0x1d,
2359                 .flags          = 0,
2360                 .irq            = MMA8452_INT_PIN,
2361                 .platform_data = &mma8452_info,
2362         },
2363 #endif
2364 #if defined (CONFIG_GS_LIS3DH)
2365         {
2366                 .type           = "gs_lis3dh",
2367                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
2368                 .flags          = 0,
2369                 .irq            = LIS3DH_INT_PIN,
2370                 .platform_data = &lis3dh_info,
2371         },
2372 #endif
2373
2374 #if defined (CONFIG_GS_KXTIK)
2375         {
2376                 .type           = "gs_kxtik",
2377                 .addr           = 0x0F,
2378                 .flags          = 0,
2379                 .irq            = KXTIK_INT_PIN,
2380                 .platform_data = &kxtik_info,
2381         },
2382 #endif
2383
2384 #if defined (CONFIG_GS_MMA7660)
2385         {
2386                 .type           = "gs_mma7660",
2387                 .addr           = 0x4c,
2388                 .flags          = 0,
2389                 .irq            = MMA7660_INT_PIN,
2390                 .platform_data = &mma7660_info,
2391         },
2392 #endif
2393
2394 #if defined (CONFIG_COMPASS_AK8975)
2395         {
2396                 .type          = "ak8975",
2397                 .addr          = 0x0d,
2398                 .flags         = 0,
2399                 .irq           = RK30_PIN4_PC1,
2400                 .platform_data = &akm8975_info,
2401         },
2402 #endif
2403 #if defined (CONFIG_GYRO_L3G4200D)
2404         {
2405                 .type          = "l3g4200d_gryo",
2406                 .addr          = 0x69,
2407                 .flags         = 0,
2408                 .irq           = L3G4200D_INT_PIN,
2409                 .platform_data = &l3g4200d_info,
2410         },
2411 #endif
2412 #if defined (CONFIG_INPUT_LPSENSOR_AL3006)
2413         {
2414                 .type           = "al3006",
2415                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
2416                 .flags          = 0,
2417                 .irq            = RK30_PIN6_PA2,
2418         },
2419 #endif
2420
2421 #if defined (CONFIG_LS_AL3006)
2422         {
2423                 .type           = "light_al3006",
2424                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
2425                 .flags          = 0,
2426                 .irq            = RK30_PIN6_PA2,        
2427                 .platform_data = &light_al3006_info,
2428         },
2429 #endif
2430 #if defined (CONFIG_LS_STK3171)
2431         {
2432                 .type           = "ls_stk3171",
2433                 .addr           = 0x48,            
2434                 .flags          = 0,
2435                 .irq            = RK30_PIN6_PA2,        
2436                 .platform_data = &light_stk3171_info,
2437         },
2438 #endif
2439
2440
2441 #if defined (CONFIG_PS_AL3006)
2442         {
2443                 .type           = "proximity_al3006",
2444                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
2445                 .flags          = 0,
2446                 .irq            = RK30_PIN6_PA2,        
2447                 .platform_data = &proximity_al3006_info,
2448         },
2449 #endif
2450
2451 #if defined (CONFIG_PS_STK3171)
2452         {
2453                 .type           = "ps_stk3171",
2454                 .addr           = 0x48,            
2455                 .flags          = 0,
2456                 .irq            = RK30_PIN6_PA2,        
2457                 .platform_data = &proximity_stk3171_info,
2458         },
2459 #endif
2460
2461
2462 #if defined (CONFIG_SND_SOC_RK1000)
2463         {
2464                 .type          = "rk1000_i2c_codec",
2465                 .addr          = 0x60,
2466                 .flags         = 0,
2467         },
2468         {
2469                 .type          = "rk1000_control",
2470                 .addr          = 0x40,
2471                 .flags         = 0,
2472         },
2473 #endif
2474
2475 #if defined (CONFIG_SND_SOC_RT5623)
2476         {
2477                 .type                   = "rt5623",
2478                 .addr                   = 0x1a,
2479                 .flags                  = 0,
2480         },
2481 #endif
2482 #if defined (CONFIG_SND_SOC_RT5631)
2483         {
2484                 .type                   = "rt5631",
2485                 .addr                   = 0x1a,
2486                 .flags                  = 0,
2487         },
2488 #endif
2489 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
2490         {
2491                 .type                   = "rt3261",
2492                 .addr                   = 0x1c,
2493                 .flags                  = 0,
2494                                 .platform_data          = &rt3261_info,
2495         },
2496 #endif
2497
2498 #ifdef CONFIG_MFD_RK610
2499                 {
2500                         .type                   = "rk610_ctl",
2501                         .addr                   = 0x40,
2502                         .flags                  = 0,
2503                 },
2504 #ifdef CONFIG_RK610_TVOUT
2505                 {
2506                         .type                   = "rk610_tvout",
2507                         .addr                   = 0x42,
2508                         .flags                  = 0,
2509                 },
2510 #endif
2511 #ifdef CONFIG_RK610_HDMI
2512                 {
2513                         .type                   = "rk610_hdmi",
2514                         .addr                   = 0x46,
2515                         .flags                  = 0,
2516                         .irq                    = RK29_PIN5_PA2,
2517                 },
2518 #endif
2519 #ifdef CONFIG_SND_SOC_RK610
2520                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
2521                         .type                   = "rk610_i2c_codec",
2522                         .addr                   = 0x60,
2523                         .flags                  = 0,
2524                 },
2525 #endif
2526 #endif
2527
2528 };
2529 #endif
2530
2531 int __sramdata g_pmic_type =  0;
2532 #ifdef CONFIG_I2C1_RK30
2533 #ifdef CONFIG_MFD_WM831X_I2C
2534 #include "board-rk30-sdk-wm8326.c"
2535 #endif
2536 #ifdef CONFIG_MFD_TPS65910
2537 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
2538 #include "board-rk30-sdk-tps65910.c"
2539 #endif
2540
2541 static struct i2c_board_info __initdata i2c1_info[] = {
2542 #if defined (CONFIG_MFD_WM831X_I2C)
2543         {
2544                 .type          = "wm8326",
2545                 .addr          = 0x34,
2546                 .flags         = 0,
2547                 .irq           = RK30_PIN6_PA4,
2548                 .platform_data = &wm831x_platdata,
2549         },
2550 #endif
2551 #if defined (CONFIG_MFD_TPS65910)
2552         {
2553         .type           = "tps65910",
2554         .addr           = TPS65910_I2C_ID0,
2555         .flags          = 0,
2556         .irq            = TPS65910_HOST_IRQ,
2557         .platform_data = &tps65910_data,
2558         },
2559 #endif
2560 };
2561 #endif
2562
2563
2564 void __sramfunc board_pmu_suspend(void)
2565 {      
2566         #if defined (CONFIG_MFD_WM831X_I2C)
2567        if(pmic_is_wm8326())
2568        board_pmu_wm8326_suspend();
2569         #endif
2570         #if defined (CONFIG_MFD_TPS65910)
2571        if(pmic_is_tps65910())
2572        board_pmu_tps65910_suspend(); 
2573     #endif   
2574 }
2575
2576 void __sramfunc board_pmu_resume(void)
2577 {      
2578         #if defined (CONFIG_MFD_WM831X_I2C)
2579        if(pmic_is_wm8326())
2580        board_pmu_wm8326_resume();
2581         #endif
2582         #if defined (CONFIG_MFD_TPS65910)
2583        if(pmic_is_tps65910())
2584        board_pmu_tps65910_resume(); 
2585         #endif
2586 }
2587
2588  int __sramdata gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
2589
2590 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
2591 {
2592 #ifdef CONFIG_RK30_PWM_REGULATOR
2593
2594 //      int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
2595         sram_udelay(10000);
2596         gpio0d7_iomux = readl_relaxed(GRF_GPIO0D_IOMUX);
2597         gpio0d7_do = grf_readl(GRF_GPIO0H_DO);
2598         gpio0d7_dir = grf_readl(GRF_GPIO0H_DIR);
2599         gpio0d7_en = grf_readl(GRF_GPIO0H_EN);
2600
2601         writel_relaxed((1<<30), GRF_GPIO0D_IOMUX);
2602         grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DIR);
2603         grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DO);
2604         grf_writel((1<<31)|(1<<15), GRF_GPIO0H_EN);
2605 #endif 
2606 }
2607 void __sramfunc rk30_pwm_logic_resume_voltage(void)
2608 {
2609 #ifdef CONFIG_RK30_PWM_REGULATOR
2610         writel_relaxed((1<<30)|gpio0d7_iomux, GRF_GPIO0D_IOMUX);
2611         grf_writel((1<<31)|gpio0d7_en, GRF_GPIO0H_EN);
2612         grf_writel((1<<31)|gpio0d7_dir, GRF_GPIO0H_DIR);
2613         grf_writel((1<<31)|gpio0d7_do, GRF_GPIO0H_DO);
2614         sram_udelay(10000);
2615
2616 #endif
2617
2618 }
2619 extern void pwm_suspend_voltage(void);
2620 extern void pwm_resume_voltage(void);
2621 void  rk30_pwm_suspend_voltage_set(void)
2622 {
2623 #ifdef CONFIG_RK30_PWM_REGULATOR
2624         pwm_suspend_voltage();
2625 #endif
2626 }
2627 void  rk30_pwm_resume_voltage_set(void)
2628 {
2629 #ifdef CONFIG_RK30_PWM_REGULATOR
2630         pwm_resume_voltage();
2631 #endif
2632 }
2633
2634
2635 #ifdef CONFIG_I2C2_RK30
2636 static struct i2c_board_info __initdata i2c2_info[] = {
2637 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
2638         {
2639                 .type          = "Goodix-TS",
2640                 .addr          = 0x55,
2641                 .flags         = 0,
2642                 .irq           = RK30_PIN4_PC2,
2643                 .platform_data = &goodix_info,
2644         },
2645 #endif
2646 #if defined(CONFIG_TOUCHSCREEN_GT82X_IIC)
2647         {
2648                 .type          = "Goodix-TS-82X",
2649                 .addr          = 0x5D,
2650                 .flags         = 0,
2651                 .irq           = RK30_PIN4_PC2,
2652                 .platform_data = &ts82x_pdata,
2653         },
2654 #endif
2655 #if defined (CONFIG_LS_CM3217)
2656         {
2657                 .type          = "light_cm3217",
2658                 .addr          = 0x10,
2659                 .flags         = 0,
2660                 .platform_data = &cm3217_info,
2661         },
2662 #endif
2663
2664
2665 #if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_S3202)
2666 {
2667         .type           = "rmi_i2c",
2668         .addr           = 0x20,
2669         .flags          = 0,
2670         .irq            = RK30_PIN4_PC2,
2671         .platform_data = &s3202_platformdata,
2672 },
2673 #endif
2674
2675 #if defined (CONFIG_TOUCHSCREEN_FT5306)
2676 {
2677         .type           = "ft5x0x_ts",
2678         .addr           = 0x3e,
2679         .flags          = 0,
2680         .irq            = RK30_PIN4_PC2,
2681         .platform_data = &ft5306_info,
2682 },
2683 #endif
2684
2685 #if defined (CONFIG_TOUCHSCREEN_CT360_IIC)
2686         {
2687         .type           ="ct360_ts",
2688         .addr           =0x01,
2689         .flags          =0,
2690         .irq            = RK30_PIN4_PC2,
2691         .platform_data = &ct360_info,
2692         },
2693 #endif
2694
2695 #if  defined(CONFIG_TOUCHSCREEN_GT8110)
2696         {
2697                 .type          = "Goodix-TS",
2698                 .addr          = 0x5c,
2699                 .flags         = 0,
2700                 .irq           = TOUCH_INT_PIN,
2701                 .platform_data = &goodix_info,
2702         },
2703 #endif
2704
2705 #if defined (CONFIG_TS_AUTO_I2C)
2706         {
2707                 .type          = "auto_ts_i2c",
2708                 .addr          = 0x3e,
2709                 .flags         = 0,
2710                 .irq           = TOUCH_INT_PIN,
2711                 .platform_data = &auto_ts_info,
2712         },
2713 #endif
2714
2715
2716 #if defined (CONFIG_LS_ISL29023)
2717         {
2718                 .type           = "ls_isl29023",
2719                 .addr           = 0x44,            
2720                 .flags          = 0,
2721                 .irq            = RK30_PIN4_PC6,        
2722                 .platform_data = &light_isl29023_info,
2723         },
2724 #endif
2725
2726 };
2727 #endif
2728
2729 #ifdef CONFIG_I2C3_RK30
2730 static struct i2c_board_info __initdata i2c3_info[] = {
2731 };
2732 #endif
2733
2734 #ifdef CONFIG_I2C4_RK30
2735 static struct i2c_board_info __initdata i2c4_info[] = {
2736 };
2737 #endif
2738
2739 #ifdef CONFIG_I2C_GPIO_RK30
2740 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
2741 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
2742 static int rk30_i2c_io_init(void)
2743 {
2744         //set iomux (gpio) here
2745         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2746         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2747
2748         return 0;
2749 }
2750 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2751        .sda_pin = I2C_SDA_PIN,
2752        .scl_pin = I2C_SCL_PIN,
2753        .udelay = 5, // clk = 500/udelay = 100Khz
2754        .timeout = 100,//msecs_to_jiffies(100),
2755        .bus_num    = 5,
2756        .io_init = rk30_i2c_io_init,
2757 };
2758 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2759 };
2760 #endif
2761
2762 static void __init rk30_i2c_register_board_info(void)
2763 {
2764 #ifdef CONFIG_I2C0_RK30
2765         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2766 #endif
2767 #ifdef CONFIG_I2C1_RK30
2768         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2769 #endif
2770 #ifdef CONFIG_I2C2_RK30
2771         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2772 #endif
2773 #ifdef CONFIG_I2C3_RK30
2774         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2775 #endif
2776 #ifdef CONFIG_I2C4_RK30
2777         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2778 #endif
2779 #ifdef CONFIG_I2C_GPIO_RK30
2780         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2781 #endif
2782 }
2783 //end of i2c
2784
2785 static void dcr_en_low(void)
2786 {
2787   int ret;
2788   ret=gpio_request(RK30_PIN4_PB7,"dcr_en");
2789   if(ret<0){
2790      printk("dcr_en_low request io error");
2791      gpio_free(RK30_PIN4_PB7);
2792      return;
2793   }
2794   gpio_direction_output(RK30_PIN4_PB7, GPIO_LOW);
2795 }
2796
2797 #define POWER_ON_PIN RK30_PIN6_PB0   //power_hold
2798 void rk30_pm_power_off(void)
2799 {
2800   int pwr_cnt;
2801   
2802         printk(KERN_ERR "rk30_pm_power_off start...\n");
2803         
2804 #if 0
2805
2806         if(gpio_get_value (rk30_adc_battery_platdata.dc_det_pin) == rk30_adc_battery_platdata.dc_det_level){
2807                 pwr_cnt=0;
2808                 while(1){
2809                          if(gpio_get_value (rk30_adc_battery_platdata.dc_det_pin) != rk30_adc_battery_platdata.dc_det_level){
2810                                   break;
2811                          }
2812                          if((gpio_get_value(RK30_PIN6_PA2)==GPIO_LOW)){
2813                                  if(pwr_cnt++>40)
2814                                    break;
2815                          }else{
2816                                  //printk("0\n");
2817                                  pwr_cnt=0;
2818                          }              
2819                          mdelay(50);
2820                 }       
2821               arm_pm_restart(0, NULL);
2822         }
2823 #endif
2824         #if defined(CONFIG_MFD_WM831X)  
2825         if(pmic_is_wm8326())
2826         {
2827                 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
2828                 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2829         }
2830         #endif
2831         #if defined(CONFIG_MFD_TPS65910)
2832         if(pmic_is_tps65910())
2833         {
2834                 tps65910_device_shutdown();//tps65910 shutdown
2835         }
2836         #endif
2837   gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2838         while(1);
2839 }
2840 EXPORT_SYMBOL_GPL(rk30_pm_power_off);
2841 static void __init machine_rk30_board_init(void)
2842 {
2843         avs_init();
2844         gpio_request(POWER_ON_PIN, "poweronpin");
2845         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2846
2847         //add for codec_en 
2848         gpio_request(RK30_PIN4_PD7, "codec_en");
2849         rk30_mux_api_set(GPIO4D7_SMCDATA15_TRACEDATA15_NAME, GPIO4D_GPIO4D7);
2850         gpio_direction_output(RK30_PIN4_PD7, GPIO_HIGH);
2851         
2852         pm_power_off = rk30_pm_power_off;
2853         
2854         rk30_i2c_register_board_info();
2855         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2856         platform_add_devices(devices, ARRAY_SIZE(devices));
2857         board_usb_detect_init(RK30_PIN6_PA3);
2858
2859 #ifdef CONFIG_WIFI_CONTROL_FUNC
2860         rk29sdk_wifi_bt_gpio_control_init();
2861 #endif
2862   dcr_en_low();
2863
2864 #if defined(CONFIG_MT6620)
2865     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2866 #endif
2867 }
2868
2869 static void __init rk30_reserve(void)
2870 {
2871 #ifdef CONFIG_ION
2872         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2873 #endif
2874 #ifdef CONFIG_FB_ROCKCHIP
2875         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
2876         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
2877         #if 0
2878         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2879         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2880         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
2881         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
2882         #endif
2883 #endif
2884 #ifdef CONFIG_VIDEO_RK29
2885         rk30_camera_request_reserve_mem();
2886 #endif
2887         board_mem_reserved();
2888 }
2889
2890 /**
2891  * dvfs_cpu_logic_table: table for arm and logic dvfs 
2892  * @frequency   : arm frequency
2893  * @cpu_volt    : arm voltage depend on frequency
2894  * @logic_volt  : logic voltage arm requests depend on frequency
2895  * comments     : min arm/logic voltage
2896  */
2897 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
2898         {.frequency = 252 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
2899         {.frequency = 504 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125* 1000},//0.975V/1.000V
2900         {.frequency = 816 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1150 * 1000},//1.000V/1.025V
2901         {.frequency = 1008 * 1000,      .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.025V/1.050V
2902         {.frequency = 1200 * 1000,      .cpu_volt = 1175 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
2903         {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
2904         {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},//1.225V/1.100V
2905         //{.frequency = 1512 * 1000,    .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},//1.300V/1.150V
2906         //{.frequency = 1608 * 1000,    .cpu_volt = 1375 * 1000,        .logic_volt = 1275 * 1000},//1.325V/1.175V
2907         {.frequency = CPUFREQ_TABLE_END},
2908 };
2909
2910 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2911         {.frequency = 266 * 1000,       .index = 1050 * 1000},
2912         {.frequency = 400 * 1000,       .index = 1275 * 1000},
2913         {.frequency = CPUFREQ_TABLE_END},
2914 };
2915
2916 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2917         {.frequency = 300 * 1000,       .index = 1050 * 1000},
2918         {.frequency = 400 * 1000,       .index = 1125 * 1000},
2919         {.frequency = CPUFREQ_TABLE_END},
2920 };
2921
2922 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
2923 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2924 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2925
2926 void __init board_clock_init(void)
2927 {
2928         //support uart 1-3Mbits/s 
2929         rk30_clock_data_init(periph_pll_default, codec_pll_768mhz, RK30_CLOCKS_DEFAULT_FLAGS | CLK_FLG_UART_1_3M);
2930         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2931         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2932         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2933 }
2934
2935 MACHINE_START(RK30, "RK30board")
2936         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
2937         .fixup          = rk30_fixup,
2938         .reserve        = &rk30_reserve,
2939         .map_io         = rk30_map_io,
2940         .init_irq       = rk30_init_irq,
2941         .timer          = &rk30_timer,
2942         .init_machine   = machine_rk30_board_init,
2943 MACHINE_END