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