ARM64: DTS: Add rk3399-firefly uart4 device, node as /dev/ttyS1
[firefly-linux-kernel-4.4.55.git] / board-rk30-phone-loquat.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
45 #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_S3202
46 #include <linux/interrupt.h>
47 #include <linux/rmi.h>
48 #endif
49 #include <linux/sensor-dev.h>
50 #include <linux/regulator/machine.h>
51 #include <linux/rfkill-rk.h>
52
53 #if defined(CONFIG_HDMI_RK30)
54         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
55 #endif
56 #include "../../../drivers/headset_observe/rk_headset.h"
57 #include <linux/mfd/tlv320aic3262-core.h>
58 #include <linux/mfd/tlv320aic3262-registers.h>
59
60 #if defined(CONFIG_SPIM_RK29)
61 #include "../../../drivers/spi/rk29_spim.h"
62 #endif
63 #if defined(CONFIG_ANDROID_TIMED_GPIO)
64 #include "../../../drivers/staging/android/timed_gpio.h"
65 #endif
66 #include <linux/mtk23d.h>
67 #include "../../../drivers/tty/serial/sc8800.h"
68 #define BP_VOL_PIN                      RK30_PIN6_PB2
69 #define RK30_FB0_MEM_SIZE 8*SZ_1M
70
71 #ifdef CONFIG_VIDEO_RK29
72 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
73 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
74
75 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5640                                          /* back camera sensor */
76 #define CONFIG_SENSOR_IIC_ADDR_0                  0x78
77 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    3
78 #define CONFIG_SENSOR_CIF_INDEX_0         0
79 #define CONFIG_SENSOR_ORIENTATION_0       90
80 #define CONFIG_SENSOR_POWER_PIN_0                 RK30_PIN4_PC6
81 #define CONFIG_SENSOR_RESET_PIN_0                 INVALID_GPIO
82 #define CONFIG_SENSOR_POWERDN_PIN_0       RK30_PIN1_PB6
83 #define CONFIG_SENSOR_FALSH_PIN_0                 RK30_PIN4_PD6
84 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_H
85 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
86 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
87 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_H
88
89 #define CONFIG_SENSOR_QCIF_FPS_FIXED_0          15000
90 #define CONFIG_SENSOR_240X160_FPS_FIXED_0   15000
91 #define CONFIG_SENSOR_QVGA_FPS_FIXED_0          15000
92 #define CONFIG_SENSOR_CIF_FPS_FIXED_0           15000
93 #define CONFIG_SENSOR_VGA_FPS_FIXED_0           15000
94 #define CONFIG_SENSOR_480P_FPS_FIXED_0          15000
95 #define CONFIG_SENSOR_SVGA_FPS_FIXED_0          15000
96 #define CONFIG_SENSOR_720P_FPS_FIXED_0          30000
97
98 #define CONFIG_SENSOR_01  RK29_CAM_SENSOR_OV5642                   /* back camera sensor 1 */
99 #define CONFIG_SENSOR_IIC_ADDR_01           0x00
100 #define CONFIG_SENSOR_CIF_INDEX_01                    1
101 #define CONFIG_SENSOR_IIC_ADAPTER_ID_01    4
102 #define CONFIG_SENSOR_ORIENTATION_01       90
103 #define CONFIG_SENSOR_POWER_PIN_01         INVALID_GPIO
104 #define CONFIG_SENSOR_RESET_PIN_01         INVALID_GPIO
105 #define CONFIG_SENSOR_POWERDN_PIN_01       RK30_PIN1_PD6
106 #define CONFIG_SENSOR_FALSH_PIN_01         INVALID_GPIO
107 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_01 RK29_CAM_POWERACTIVE_L
108 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_01 RK29_CAM_RESETACTIVE_L
109 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_01 RK29_CAM_POWERDNACTIVE_H
110 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_01 RK29_CAM_FLASHACTIVE_L
111
112 #define CONFIG_SENSOR_QCIF_FPS_FIXED_01      15000
113 #define CONFIG_SENSOR_240X160_FPS_FIXED_01   15000
114 #define CONFIG_SENSOR_QVGA_FPS_FIXED_01      15000
115 #define CONFIG_SENSOR_CIF_FPS_FIXED_01       15000
116 #define CONFIG_SENSOR_VGA_FPS_FIXED_01       15000
117 #define CONFIG_SENSOR_480P_FPS_FIXED_01      15000
118 #define CONFIG_SENSOR_SVGA_FPS_FIXED_01      15000
119 #define CONFIG_SENSOR_720P_FPS_FIXED_01     30000
120
121 #define CONFIG_SENSOR_02 RK29_CAM_SENSOR_OV5640                      /* back camera sensor 2 */
122 #define CONFIG_SENSOR_IIC_ADDR_02           0x00
123 #define CONFIG_SENSOR_CIF_INDEX_02                    1
124 #define CONFIG_SENSOR_IIC_ADAPTER_ID_02    4
125 #define CONFIG_SENSOR_ORIENTATION_02       90
126 #define CONFIG_SENSOR_POWER_PIN_02         INVALID_GPIO
127 #define CONFIG_SENSOR_RESET_PIN_02         INVALID_GPIO
128 #define CONFIG_SENSOR_POWERDN_PIN_02       RK30_PIN1_PD6
129 #define CONFIG_SENSOR_FALSH_PIN_02         INVALID_GPIO
130 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_02 RK29_CAM_POWERACTIVE_L
131 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_02 RK29_CAM_RESETACTIVE_L
132 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_02 RK29_CAM_POWERDNACTIVE_H
133 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_02 RK29_CAM_FLASHACTIVE_L
134
135 #define CONFIG_SENSOR_QCIF_FPS_FIXED_02      15000
136 #define CONFIG_SENSOR_240X160_FPS_FIXED_02   15000
137 #define CONFIG_SENSOR_QVGA_FPS_FIXED_02      15000
138 #define CONFIG_SENSOR_CIF_FPS_FIXED_02       15000
139 #define CONFIG_SENSOR_VGA_FPS_FIXED_02       15000
140 #define CONFIG_SENSOR_480P_FPS_FIXED_02      15000
141 #define CONFIG_SENSOR_SVGA_FPS_FIXED_02      15000
142 #define CONFIG_SENSOR_720P_FPS_FIXED_02      30000
143
144 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_GT2005                      /* front camera sensor 0 */
145 #define CONFIG_SENSOR_IIC_ADDR_1              0x78
146 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    3
147 #define CONFIG_SENSOR_CIF_INDEX_1                 0
148 #define CONFIG_SENSOR_ORIENTATION_1       270
149 #define CONFIG_SENSOR_POWER_PIN_1         RK30_PIN4_PC6
150 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
151 #define CONFIG_SENSOR_POWERDN_PIN_1       RK30_PIN1_PB7
152 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
153 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_H
154 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
155 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_L
156 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
157
158 #define CONFIG_SENSOR_QCIF_FPS_FIXED_1          15000
159 #define CONFIG_SENSOR_240X160_FPS_FIXED_1   15000
160 #define CONFIG_SENSOR_QVGA_FPS_FIXED_1          15000
161 #define CONFIG_SENSOR_CIF_FPS_FIXED_1           15000
162 #define CONFIG_SENSOR_VGA_FPS_FIXED_1           15000
163 #define CONFIG_SENSOR_480P_FPS_FIXED_1          15000
164 #define CONFIG_SENSOR_SVGA_FPS_FIXED_1          15000
165 #define CONFIG_SENSOR_720P_FPS_FIXED_1          30000
166
167 #define CONFIG_SENSOR_11 RK29_CAM_SENSOR_OV2659                      /* front camera sensor 1 */
168 #define CONFIG_SENSOR_IIC_ADDR_11           0x00
169 #define CONFIG_SENSOR_IIC_ADAPTER_ID_11    3
170 #define CONFIG_SENSOR_CIF_INDEX_11                                0
171 #define CONFIG_SENSOR_ORIENTATION_11       270
172 #define CONFIG_SENSOR_POWER_PIN_11         INVALID_GPIO
173 #define CONFIG_SENSOR_RESET_PIN_11         INVALID_GPIO
174 #define CONFIG_SENSOR_POWERDN_PIN_11       INVALID_GPIO//RK30_PIN1_PB7
175 #define CONFIG_SENSOR_FALSH_PIN_11         INVALID_GPIO
176 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_11 RK29_CAM_POWERACTIVE_L
177 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_11 RK29_CAM_RESETACTIVE_L
178 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_11 RK29_CAM_POWERDNACTIVE_H
179 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_11 RK29_CAM_FLASHACTIVE_L
180
181 #define CONFIG_SENSOR_QCIF_FPS_FIXED_11      15000
182 #define CONFIG_SENSOR_240X160_FPS_FIXED_11   15000
183 #define CONFIG_SENSOR_QVGA_FPS_FIXED_11      15000
184 #define CONFIG_SENSOR_CIF_FPS_FIXED_11       15000
185 #define CONFIG_SENSOR_VGA_FPS_FIXED_11       15000
186 #define CONFIG_SENSOR_480P_FPS_FIXED_11      15000
187 #define CONFIG_SENSOR_SVGA_FPS_FIXED_11      15000
188 #define CONFIG_SENSOR_720P_FPS_FIXED_11      30000
189
190 #define CONFIG_SENSOR_12 RK29_CAM_SENSOR_OV2659//RK29_CAM_SENSOR_OV2655                      /* front camera sensor 2 */
191 #define CONFIG_SENSOR_IIC_ADDR_12          0x00
192 #define CONFIG_SENSOR_IIC_ADAPTER_ID_12    3
193 #define CONFIG_SENSOR_CIF_INDEX_12                                0
194 #define CONFIG_SENSOR_ORIENTATION_12       270
195 #define CONFIG_SENSOR_POWER_PIN_12         INVALID_GPIO
196 #define CONFIG_SENSOR_RESET_PIN_12         INVALID_GPIO
197 #define CONFIG_SENSOR_POWERDN_PIN_12       INVALID_GPIO//RK30_PIN1_PB7
198 #define CONFIG_SENSOR_FALSH_PIN_12         INVALID_GPIO
199 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_12 RK29_CAM_POWERACTIVE_L
200 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_12 RK29_CAM_RESETACTIVE_L
201 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_12 RK29_CAM_POWERDNACTIVE_H
202 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_12 RK29_CAM_FLASHACTIVE_L
203
204 #define CONFIG_SENSOR_QCIF_FPS_FIXED_12      15000
205 #define CONFIG_SENSOR_240X160_FPS_FIXED_12   15000
206 #define CONFIG_SENSOR_QVGA_FPS_FIXED_12      15000
207 #define CONFIG_SENSOR_CIF_FPS_FIXED_12       15000
208 #define CONFIG_SENSOR_VGA_FPS_FIXED_12       15000
209 #define CONFIG_SENSOR_480P_FPS_FIXED_12      15000
210 #define CONFIG_SENSOR_SVGA_FPS_FIXED_12      15000
211 #define CONFIG_SENSOR_720P_FPS_FIXED_12      30000
212
213
214 #endif  //#ifdef CONFIG_VIDEO_RK29
215 /*---------------- Camera Sensor Configuration Macro End------------------------*/
216 #include "../../../drivers/media/video/rk30_camera.c"
217 /*---------------- Camera Sensor Macro Define End  ---------*/
218
219 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
220 /*****************************************************************************************
221  * camera  devices
222  * author: ddl@rock-chips.com
223  *****************************************************************************************/
224 #ifdef CONFIG_VIDEO_RK29
225 #define CONFIG_SENSOR_POWER_IOCTL_USR      0
226 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
227 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR          0
228 #define CONFIG_SENSOR_FLASH_IOCTL_USR      1
229
230 #if CONFIG_SENSOR_POWER_IOCTL_USR
231 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
232 {
233         #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
234 }
235 #endif
236
237 #if CONFIG_SENSOR_RESET_IOCTL_USR
238 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
239 {
240         #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
241 }
242 #endif
243
244 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
245 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
246 {
247         #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
248 }
249 #endif
250 //hhb@rock-chips.com
251 #if CONFIG_SENSOR_FLASH_IOCTL_USR
252 //sgm3140 LED driver
253 #define CONFIG_SENSOR_FALSH_EN_PIN_0              RK30_PIN4_PD6    //high:enable
254 #define CONFIG_SENSOR_FALSH_MODE_PIN_0            RK30_PIN0_PD6    //high:FLASH, low:torch
255 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res, int on)
256 {
257         static int init_flag = 0;
258         if(init_flag == 0) {
259                 gpio_request(CONFIG_SENSOR_FALSH_MODE_PIN_0, "camera_falsh_mode");
260                 rk30_mux_api_set(GPIO0D6_PWM2_NAME, GPIO0D_GPIO0D6);
261                 gpio_request(CONFIG_SENSOR_FALSH_EN_PIN_0, "camera_falsh_en");
262                 rk30_mux_api_set(GPIO4D6_SMCDATA14_TRACEDATA14_NAME, GPIO4D_GPIO4D6);
263                 init_flag = 1;
264         }
265         switch (on) {
266                 case Flash_Off: {
267                         gpio_direction_output(CONFIG_SENSOR_FALSH_EN_PIN_0, 0);
268                         gpio_direction_output(CONFIG_SENSOR_FALSH_MODE_PIN_0, 1);
269                         break;
270                 }
271
272                 case Flash_On: {
273                         gpio_direction_output(CONFIG_SENSOR_FALSH_EN_PIN_0, 1);
274                         gpio_direction_output(CONFIG_SENSOR_FALSH_MODE_PIN_0, 1);
275                         break;
276                 }
277
278                 case Flash_Torch: {
279                         gpio_direction_output(CONFIG_SENSOR_FALSH_EN_PIN_0, 1);
280                         gpio_direction_output(CONFIG_SENSOR_FALSH_MODE_PIN_0, 0);
281                         break;
282                 }
283
284                 default: {
285                         printk("%s..Flash command(%d) is invalidate \n",__FUNCTION__, on);
286                         gpio_direction_output(CONFIG_SENSOR_FALSH_EN_PIN_0, 0);
287                         break;
288                 }
289         }
290         return 0;
291 }
292 #endif
293
294 static struct rk29camera_platform_ioctl_cb      sensor_ioctl_cb = {
295         #if CONFIG_SENSOR_POWER_IOCTL_USR
296         .sensor_power_cb = sensor_power_usr_cb,
297         #else
298         .sensor_power_cb = NULL,
299         #endif
300
301         #if CONFIG_SENSOR_RESET_IOCTL_USR
302         .sensor_reset_cb = sensor_reset_usr_cb,
303         #else
304         .sensor_reset_cb = NULL,
305         #endif
306
307         #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
308         .sensor_powerdown_cb = sensor_powerdown_usr_cb,
309         #else
310         .sensor_powerdown_cb = NULL,
311         #endif
312
313         #if CONFIG_SENSOR_FLASH_IOCTL_USR
314         .sensor_flash_cb = sensor_flash_usr_cb,
315         #else
316         .sensor_flash_cb = NULL,
317         #endif
318 };
319
320 #if CONFIG_SENSOR_IIC_ADDR_0
321 static struct reginfo_t rk_init_data_sensor_reg_0[] =
322 {
323                 {0x0000, 0x00,0,0}
324         };
325 static struct reginfo_t rk_init_data_sensor_winseqreg_0[] ={
326         {0x0000, 0x00,0,0}
327         };
328 #endif
329
330 #if CONFIG_SENSOR_IIC_ADDR_1
331 static struct reginfo_t rk_init_data_sensor_reg_1[] =
332 {
333     {0x0000, 0x00,0,0}
334 };
335 static struct reginfo_t rk_init_data_sensor_winseqreg_1[] =
336 {
337        {0x0000, 0x00,0,0}
338 };
339 #endif
340 #if CONFIG_SENSOR_IIC_ADDR_01
341 static struct reginfo_t rk_init_data_sensor_reg_01[] =
342 {
343     {0x0000, 0x00,0,0}
344 };
345 static struct reginfo_t rk_init_data_sensor_winseqreg_01[] =
346 {
347        {0x0000, 0x00,0,0}
348 };
349 #endif
350 #if CONFIG_SENSOR_IIC_ADDR_02
351 static struct reginfo_t rk_init_data_sensor_reg_02[] =
352 {
353     {0x0000, 0x00,0,0}
354 };
355 static struct reginfo_t rk_init_data_sensor_winseqreg_02[] =
356 {
357        {0x0000, 0x00,0,0}
358 };
359 #endif
360 #if CONFIG_SENSOR_IIC_ADDR_11
361 static struct reginfo_t rk_init_data_sensor_reg_11[] =
362 {
363     {0x0000, 0x00,0,0}
364 };
365 static struct reginfo_t rk_init_data_sensor_winseqreg_11[] =
366 {
367        {0x0000, 0x00,0,0}
368 };
369 #endif
370 #if CONFIG_SENSOR_IIC_ADDR_12
371 static struct reginfo_t rk_init_data_sensor_reg_12[] =
372 {
373     {0x0000, 0x00,0,0}
374 };
375 static struct reginfo_t rk_init_data_sensor_winseqreg_12[] =
376 {
377        {0x0000, 0x00,0,0}
378 };
379 #endif
380 static rk_sensor_user_init_data_s rk_init_data_sensor[RK_CAM_NUM] = 
381 {
382     #if CONFIG_SENSOR_IIC_ADDR_0
383     {
384        .rk_sensor_init_width = INVALID_VALUE,
385        .rk_sensor_init_height = INVALID_VALUE,
386        .rk_sensor_init_bus_param = INVALID_VALUE,
387        .rk_sensor_init_pixelcode = INVALID_VALUE,
388        .rk_sensor_init_data = rk_init_data_sensor_reg_0,
389        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_0,
390        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_0) / sizeof(struct reginfo_t),
391        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_0) / sizeof(struct reginfo_t),
392     },
393     #else
394     {
395        .rk_sensor_init_width = INVALID_VALUE,
396        .rk_sensor_init_height = INVALID_VALUE,
397        .rk_sensor_init_bus_param = INVALID_VALUE,
398        .rk_sensor_init_pixelcode = INVALID_VALUE,
399        .rk_sensor_init_data = NULL,
400        .rk_sensor_init_winseq = NULL,
401        .rk_sensor_winseq_size = 0,
402        .rk_sensor_init_data_size = 0,
403     },
404     #endif
405     #if CONFIG_SENSOR_IIC_ADDR_1
406     {
407        .rk_sensor_init_width = INVALID_VALUE,
408        .rk_sensor_init_height = INVALID_VALUE,
409        .rk_sensor_init_bus_param = INVALID_VALUE,
410        .rk_sensor_init_pixelcode = INVALID_VALUE,
411        .rk_sensor_init_data = rk_init_data_sensor_reg_1,
412        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_1,
413        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_1) / sizeof(struct reginfo_t),
414        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_1) / sizeof(struct reginfo_t),
415     },
416     #else
417     {
418        .rk_sensor_init_width = INVALID_VALUE,
419        .rk_sensor_init_height = INVALID_VALUE,
420        .rk_sensor_init_bus_param = INVALID_VALUE,
421        .rk_sensor_init_pixelcode = INVALID_VALUE,
422        .rk_sensor_init_data = NULL,
423        .rk_sensor_init_winseq = NULL,
424        .rk_sensor_winseq_size = 0,
425        .rk_sensor_init_data_size = 0,
426     },
427     #endif
428     #if CONFIG_SENSOR_IIC_ADDR_01
429     {
430        .rk_sensor_init_width = INVALID_VALUE,
431        .rk_sensor_init_height = INVALID_VALUE,
432        .rk_sensor_init_bus_param = INVALID_VALUE,
433        .rk_sensor_init_pixelcode = INVALID_VALUE,
434        .rk_sensor_init_data = rk_init_data_sensor_reg_01,
435        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_01,
436        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_01) / sizeof(struct reginfo_t),
437        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_01) / sizeof(struct reginfo_t),
438     },
439     #else
440     {
441        .rk_sensor_init_width = INVALID_VALUE,
442        .rk_sensor_init_height = INVALID_VALUE,
443        .rk_sensor_init_bus_param = INVALID_VALUE,
444        .rk_sensor_init_pixelcode = INVALID_VALUE,
445        .rk_sensor_init_data = NULL,
446        .rk_sensor_init_winseq = NULL,
447        .rk_sensor_winseq_size = 0,
448        .rk_sensor_init_data_size = 0,
449     },
450     #endif
451     #if CONFIG_SENSOR_IIC_ADDR_02
452     {
453        .rk_sensor_init_width = INVALID_VALUE,
454        .rk_sensor_init_height = INVALID_VALUE,
455        .rk_sensor_init_bus_param = INVALID_VALUE,
456        .rk_sensor_init_pixelcode = INVALID_VALUE,
457        .rk_sensor_init_data = rk_init_data_sensor_reg_02,
458        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_02,
459        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_02) / sizeof(struct reginfo_t),
460        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_02) / sizeof(struct reginfo_t),
461     },
462     #else
463     {
464        .rk_sensor_init_width = INVALID_VALUE,
465        .rk_sensor_init_height = INVALID_VALUE,
466        .rk_sensor_init_bus_param = INVALID_VALUE,
467        .rk_sensor_init_pixelcode = INVALID_VALUE,
468        .rk_sensor_init_data = NULL,
469        .rk_sensor_init_winseq = NULL,
470        .rk_sensor_winseq_size = 0,
471        .rk_sensor_init_data_size = 0,
472     },
473     #endif
474     #if CONFIG_SENSOR_IIC_ADDR_11
475     {
476        .rk_sensor_init_width = INVALID_VALUE,
477        .rk_sensor_init_height = INVALID_VALUE,
478        .rk_sensor_init_bus_param = INVALID_VALUE,
479        .rk_sensor_init_pixelcode = INVALID_VALUE,
480        .rk_sensor_init_data = rk_init_data_sensor_reg_11,
481        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_11,
482        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_11) / sizeof(struct reginfo_t),
483        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_11) / sizeof(struct reginfo_t),
484     },
485     #else
486     {
487        .rk_sensor_init_width = INVALID_VALUE,
488        .rk_sensor_init_height = INVALID_VALUE,
489        .rk_sensor_init_bus_param = INVALID_VALUE,
490        .rk_sensor_init_pixelcode = INVALID_VALUE,
491        .rk_sensor_init_data = NULL,
492        .rk_sensor_init_winseq = NULL,
493        .rk_sensor_winseq_size = 0,
494        .rk_sensor_init_data_size = 0,
495     },
496     #endif
497     #if CONFIG_SENSOR_IIC_ADDR_12
498     {
499        .rk_sensor_init_width = INVALID_VALUE,
500        .rk_sensor_init_height = INVALID_VALUE,
501        .rk_sensor_init_bus_param = INVALID_VALUE,
502        .rk_sensor_init_pixelcode = INVALID_VALUE,
503        .rk_sensor_init_data = rk_init_data_sensor_reg_12,
504        .rk_sensor_init_winseq = rk_init_data_sensor_winseqreg_12,
505        .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_12) / sizeof(struct reginfo_t),
506        .rk_sensor_init_data_size = sizeof(rk_init_data_sensor_reg_12) / sizeof(struct reginfo_t),
507     },
508     #else
509     {
510        .rk_sensor_init_width = INVALID_VALUE,
511        .rk_sensor_init_height = INVALID_VALUE,
512        .rk_sensor_init_bus_param = INVALID_VALUE,
513        .rk_sensor_init_pixelcode = INVALID_VALUE,
514        .rk_sensor_init_data = NULL,
515        .rk_sensor_init_winseq = NULL,
516        .rk_sensor_winseq_size = 0,
517        .rk_sensor_init_data_size = 0,
518     },
519     #endif
520
521  };
522 #include "../../../drivers/media/video/rk30_camera.c"
523
524 #endif /* CONFIG_VIDEO_RK29 */
525
526 //hhb@rock-chips.com 2012-04-27
527
528 #if defined(CONFIG_TOUCHSCREEN_FT5306)
529
530 #define TOUCH_RESET_PIN  RK30_PIN6_PB1
531 #define TOUCH_INT_PIN    RK30_PIN4_PD7
532 int ft5306_init_platform_hw(void)
533 {
534
535         printk("ft5406_init_platform_hw\n");
536     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
537       gpio_free(TOUCH_RESET_PIN);
538       printk("ft5406_init_platform_hw gpio_request error\n");
539       return -EIO;
540     }
541
542     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
543       gpio_free(TOUCH_INT_PIN);
544       printk("ift5406_init_platform_hw gpio_request error\n");
545       return -EIO;
546     }
547     rk30_mux_api_set(GPIO4D7_SMCDATA15_TRACEDATA15_NAME, 0);
548
549         gpio_direction_output(TOUCH_RESET_PIN, 0);
550         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
551         mdelay(10);
552         gpio_direction_input(TOUCH_INT_PIN);
553         mdelay(10);
554         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
555         msleep(300);
556     return 0;
557
558 }
559
560 void ft5306_exit_platform_hw(void)
561 {
562         printk("ft5306_exit_platform_hw\n");
563         gpio_free(TOUCH_RESET_PIN);
564         gpio_free(TOUCH_INT_PIN);
565 }
566
567 int ft5306_platform_sleep(void)
568 {
569         //printk("ft5306_platform_sleep\n");
570         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
571         return 0;
572 }
573
574 int ft5306_platform_wakeup(void)
575 {
576         //printk("ft5306_platform_wakeup\n");
577         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
578         msleep(300);
579         return 0;
580 }
581
582 struct ft5x0x_platform_data ft5306_info = {
583
584   .init_platform_hw= ft5306_init_platform_hw,
585   .exit_platform_hw= ft5306_exit_platform_hw,
586   .ft5x0x_platform_sleep  = ft5306_platform_sleep,
587   .ft5x0x_platform_wakeup = ft5306_platform_wakeup,
588 };
589
590
591 #endif
592
593 #if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_S3202)
594
595 #define TOUCH_RESET_PIN -1
596 #define TOUCH_INT_PIN   RK30_PIN4_PC2
597 #define TOUCH_POWER_PIN -1
598 #define TOUCH_IO_POWER_PIN -1
599
600 struct syna_gpio_data {
601         u16 gpio_number;
602         char* gpio_name;
603 };
604
605 int syna_init_platform_hw(void)
606 {
607     return 0;
608 }
609
610 static int synaptics_touchpad_gpio_setup(void *gpio_data, bool configure)
611 {
612         int retval=0;
613         struct syna_gpio_data *data = gpio_data;
614
615         if (configure) {
616                 retval = gpio_request(data->gpio_number, "rmi4_attn");
617                 if (retval) {
618                         pr_err("%s: Failed to get attn gpio %d. Code: %d.",
619                                __func__, data->gpio_number, retval);
620                         return retval;
621                 }
622                 rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, 0);
623                 retval = gpio_direction_input(data->gpio_number);
624                 if (retval) {
625                         pr_err("%s: Failed to setup attn gpio %d. Code: %d.",
626                                __func__, data->gpio_number, retval);
627                         gpio_free(data->gpio_number);
628                 }
629         } else {
630                 printk("%s: No way to deconfigure gpio %d.",
631                        __func__, data->gpio_number);
632         }
633
634         return retval;
635
636 }
637
638 static struct syna_gpio_data s3202_gpiodata = {
639         .gpio_number = TOUCH_INT_PIN,
640         .gpio_name = "GPIO4_C2",
641 };
642 static unsigned char s3202_key_array[4]={ KEY_BACK, KEY_MENU, KEY_HOMEPAGE, KEY_SEARCH };
643
644 struct rmi_f1a_button_map s3202_buttons = {
645                 .nbuttons = 4,
646                 .map = s3202_key_array,
647 };
648
649 static struct rmi_device_platform_data s3202_platformdata = {
650         .sensor_name = "Espresso",
651         .driver_name = "rmi_generic",
652         .attn_gpio = TOUCH_INT_PIN,
653         .attn_polarity = RMI_ATTN_ACTIVE_LOW,
654         .level_triggered = false,       /* For testing */
655         .gpio_data = &s3202_gpiodata,
656         .gpio_config = synaptics_touchpad_gpio_setup,
657         .init_hw = syna_init_platform_hw,
658         .axis_align = {
659                 .flip_x = 1,
660                 .flip_y = 1,
661                 .clip_X_low = 0,
662                 .clip_Y_low = 0,
663                 .clip_X_high = 0,
664                 .clip_Y_high = 0,
665         },
666         .f1a_button_map = &s3202_buttons,
667 };
668
669 #endif
670
671
672 /***********************************************************
673 *       rk30  backlight
674 ************************************************************/
675 #ifdef CONFIG_BACKLIGHT_RK29_BL
676 #define PWM_ID            0
677 #define PWM_MUX_NAME      GPIO0A3_PWM0_NAME
678 #define PWM_MUX_MODE      GPIO0A_PWM0
679 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
680 #define PWM_GPIO          RK30_PIN0_PA3
681 #define PWM_EFFECT_VALUE  0
682
683 #define LCD_DISP_ON_PIN
684
685 #ifdef  LCD_DISP_ON_PIN
686 #define BL_EN_MUX_NAME    GPIO4D2_SMCDATA10_TRACEDATA10_NAME
687 #define BL_EN_MUX_MODE    GPIO4D_GPIO4D2
688 #define BL_EN_PIN         RK30_PIN4_PD2
689 #define BL_EN_VALUE       GPIO_HIGH
690 #endif
691 static int rk29_backlight_io_init(void)
692 {
693         int ret = 0;
694         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
695 #ifdef  LCD_DISP_ON_PIN
696         rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
697         ret = gpio_request(BL_EN_PIN, NULL);
698         if (ret != 0) {
699                 gpio_free(BL_EN_PIN);
700         }
701
702         gpio_direction_output(BL_EN_PIN, 0);
703         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
704 #endif
705         return ret;
706 }
707
708 static int rk29_backlight_io_deinit(void)
709 {
710         int ret = 0;
711 #ifdef  LCD_DISP_ON_PIN
712         gpio_free(BL_EN_PIN);
713 #endif
714         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
715         return ret;
716 }
717
718 static int rk29_backlight_pwm_suspend(void)
719 {
720         int ret = 0;
721         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
722         if (gpio_request(PWM_GPIO, NULL)) {
723                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
724                 return -1;
725         }
726         gpio_direction_output(PWM_GPIO, GPIO_HIGH);
727 #ifdef  LCD_DISP_ON_PIN
728         gpio_direction_output(BL_EN_PIN, 0);
729         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
730 #endif
731         return ret;
732 }
733
734 static int rk29_backlight_pwm_resume(void)
735 {
736         gpio_direction_output(PWM_GPIO, GPIO_LOW);
737         gpio_free(PWM_GPIO);
738         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
739 #ifdef  LCD_DISP_ON_PIN
740         msleep(30);
741         gpio_direction_output(BL_EN_PIN, 1);
742         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
743 #endif
744         return 0;
745 }
746
747 static struct rk29_bl_info rk29_bl_info = {
748         .pwm_id = PWM_ID,
749         .bl_ref = PWM_EFFECT_VALUE,
750         .io_init = rk29_backlight_io_init,
751         .io_deinit = rk29_backlight_io_deinit,
752         .pwm_suspend = rk29_backlight_pwm_suspend,
753         .pwm_resume = rk29_backlight_pwm_resume,
754 };
755
756 static struct platform_device rk29_device_backlight = {
757         .name   = "rk29_backlight",
758         .id     = -1,
759         .dev    = {
760                 .platform_data  = &rk29_bl_info,
761         }
762 };
763
764 #endif
765
766 #ifdef CONFIG_RK29_SUPPORT_MODEM
767
768 #define RK30_MODEM_POWER        RK30_PIN4_PD1
769 #define RK30_MODEM_POWER_IOMUX  rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
770
771 static int rk30_modem_io_init(void)
772 {
773     printk("%s\n", __FUNCTION__);
774     RK30_MODEM_POWER_IOMUX;
775
776         return 0;
777 }
778
779 static struct rk29_io_t rk30_modem_io = {
780     .io_addr    = RK30_MODEM_POWER,
781     .enable     = GPIO_HIGH,
782     .disable    = GPIO_LOW,
783     .io_init    = rk30_modem_io_init,
784 };
785
786 static struct platform_device rk30_device_modem = {
787         .name   = "rk30_modem",
788         .id     = -1,
789         .dev    = {
790                 .platform_data  = &rk30_modem_io,
791         }
792 };
793 #endif
794 #if defined(CONFIG_RK29_SC8800)
795 // tdsc8800
796 static int tdsc8800_io_init(void)
797 {
798
799         return 0;
800 }
801
802 static int tdsc8800_io_deinit(void)
803 {
804
805         return 0;
806 }
807
808 struct rk2818_23d_data rk29_tdsc8800_info = {
809         .io_init = tdsc8800_io_init,
810        .io_deinit = tdsc8800_io_deinit,
811         .bp_power = BP_VOL_PIN,
812         .bp_power_active_low = 1,
813 };
814 struct platform_device rk29_device_tdsc8800 = {
815         .name = "tdsc8800",
816         .id = -1,
817         .dev            = {
818                 .platform_data = &rk29_tdsc8800_info,
819         }
820     };
821 //sc8800
822 static int sc8800_io_init(void)
823 {
824         rk30_mux_api_set(GPIO2B5_LCDC1DATA13_SMCADDR17_HSADCDATA8_NAME, GPIO2B_GPIO2B5);
825         rk30_mux_api_set(GPIO2A2_LCDCDATA2_SMCADDR6_NAME, GPIO2A_GPIO2A2);
826
827         rk30_mux_api_set(GPIO2C2_LCDC1DATA18_SMCBLSN1_HSADCDATA5_NAME, GPIO2C_GPIO2C2);//AP_ASK_BP_TEST1
828         gpio_request(RK30_PIN2_PC2, NULL);
829         gpio_direction_output(RK30_PIN2_PC2, 0);
830         gpio_request(RK30_PIN6_PB0, NULL);//AP_ON/OFF_BP
831         gpio_direction_output(RK30_PIN6_PB0, 0);
832
833
834         rk30_mux_api_set(GPIO2C3_LCDC1DATA19_SPI1CLK_HSADCDATA0_NAME, GPIO2C_SPI1_CLK);//spi 1
835         rk30_mux_api_set(GPIO2C4_LCDC1DATA20_SPI1CSN0_HSADCDATA1_NAME, GPIO2C_SPI1_CSN0);
836         rk30_mux_api_set(GPIO2C5_LCDC1DATA21_SPI1TXD_HSADCDATA2_NAME, GPIO2C_SPI1_TXD);
837         rk30_mux_api_set(GPIO2C6_LCDC1DATA22_SPI1RXD_HSADCDATA3_NAME, GPIO2C_SPI1_RXD);
838         return 0;
839 }
840
841 static int sc8800_io_deinit(void)
842 {
843
844         return 0;
845 }
846
847 static struct plat_sc8800 sc8800_plat_data = {
848         .slav_rts_pin = RK30_PIN6_PA0,
849         .slav_rdy_pin = RK30_PIN6_PA1,
850         .master_rts_pin = RK30_PIN2_PB5,
851         .master_rdy_pin = RK30_PIN2_PA2,
852         //.poll_time = 100,
853         .io_init = sc8800_io_init,
854     .io_deinit = sc8800_io_deinit,
855 };
856 static struct rk29xx_spi_chip sc8800_spi_chip = {
857         //.poll_mode = 1,
858         .enable_dma = 1,
859 };
860
861 #endif
862
863 static struct spi_board_info board_spi_devices[] = {
864
865 #if defined(CONFIG_RK29_SC8800)
866                 {
867                         .modalias  = "sc8800",
868                         .bus_num = 1,
869                         .platform_data = &sc8800_plat_data,
870                         .max_speed_hz  = 13*1000*1000,
871                         .chip_select   = 0,             
872                         .controller_data = &sc8800_spi_chip,
873                 },
874 #endif
875
876 };
877
878 /*MMA8452 gsensor*/
879 #if defined (CONFIG_GS_MMA8452)
880 #define MMA8452_INT_PIN   RK30_PIN4_PC0
881
882 static int mma8452_init_platform_hw(void)
883 {
884         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
885
886         return 0;
887 }
888
889 static struct sensor_platform_data mma8452_info = {
890         .type = SENSOR_TYPE_ACCEL,
891         .irq_enable = 1,
892         .poll_delay_ms = 30,
893         .init_platform_hw = mma8452_init_platform_hw,
894         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
895 };
896 #endif
897
898 #if defined (CONFIG_GS_LIS3DH)
899 #define LIS3DH_INT_PIN   RK30_PIN4_PC0
900
901 static int lis3dh_init_platform_hw(void)
902 {
903         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
904
905         return 0;
906 }
907
908 static struct gsensor_platform_data lis3dh_info = {
909         .model = 8452,
910         .swap_xy = 0,
911         .swap_xyz = 1,
912         .init_platform_hw = lis3dh_init_platform_hw,
913         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
914 };
915 #endif
916
917
918 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
919
920 static int rk_headset_io_init(int gpio, char *iomux_name, int iomux_mode)
921 {
922         int ret;
923         ret = gpio_request(gpio, NULL);
924         if(ret) 
925                 return ret;
926
927         rk30_mux_api_set(iomux_name, iomux_mode);
928         gpio_pull_updown(gpio, PullDisable);
929         gpio_direction_input(gpio);
930         return 0;
931 };
932
933 struct rk_headset_pdata rk_headset_info = {
934         .Headset_gpio           = RK30_PIN0_PD3,
935         .headset_in_type = HEADSET_IN_LOW,
936         .Hook_adc_chn = 2,
937         .hook_key_code = KEY_MEDIA,
938         .headset_gpio_info = {GPIO0D3_I2S22CHLRCKTX_SMCADVN_NAME, GPIO0D_GPIO0D3},
939         .headset_io_init = rk_headset_io_init,
940 };
941
942 struct platform_device rk_device_headset = {
943                 .name   = "rk_headsetdet",
944                 .id     = 0,
945                 .dev    = {
946                     .platform_data = &rk_headset_info,
947                 }
948 };
949 #endif
950
951 #if defined (CONFIG_COMPASS_AK8975)
952 static struct sensor_platform_data akm8975_info =
953 {
954         .type = SENSOR_TYPE_COMPASS,
955         .irq_enable = 1,
956         .poll_delay_ms = 30,
957         .m_layout = 
958         {
959                 {
960                         {0, 0, 1},
961                         {1, 0, 0},
962                         {0, 1, 0},
963                 },
964
965                 {
966                         {1, 0, 0},
967                         {0, 1, 0},
968                         {0, 0, 1},
969                 },
970
971                 {
972                         {1, 0, 0},
973                         {0, 1, 0},
974                         {0, 0, 1},
975                 },
976
977                 {
978                         {1, 0, 0},
979                         {0, 1, 0},
980                         {0, 0, 1},
981                 },
982         }
983 };
984
985 #endif
986
987 #if defined(CONFIG_GYRO_L3G4200D)
988
989 #include <linux/l3g4200d.h>
990 #define L3G4200D_INT_PIN  RK30_PIN4_PC3
991
992 static int l3g4200d_init_platform_hw(void)
993 {
994         rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
995         
996         return 0;
997 }
998
999 static struct sensor_platform_data l3g4200d_info = {
1000         .type = SENSOR_TYPE_GYROSCOPE,
1001         .irq_enable = 1,
1002         .poll_delay_ms = 30,
1003         .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
1004         .init_platform_hw = l3g4200d_init_platform_hw,
1005         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
1006         .y_min = 40,
1007         .z_min = 20,
1008 };
1009
1010 #endif
1011
1012 #ifdef CONFIG_LS_CM3217
1013
1014 #define CM3217_POWER_PIN        INVALID_GPIO
1015 #define CM3217_IRQ_PIN          INVALID_GPIO
1016 static int cm3217_init_hw(void)
1017 {
1018 #if 0
1019         if (gpio_request(CM3217_POWER_PIN, NULL) != 0) {
1020                 gpio_free(CM3217_POWER_PIN);
1021                 printk("%s: request cm3217 power pin error\n", __func__);
1022                 return -EIO;
1023         }
1024         gpio_pull_updown(CM3217_POWER_PIN, PullDisable);
1025
1026         if (gpio_request(CM3217_IRQ_PIN, NULL) != 0) {
1027                 gpio_free(CM3217_IRQ_PIN);
1028                 printk("%s: request cm3217 int pin error\n", __func__);
1029                 return -EIO;
1030         }
1031         gpio_pull_updown(CM3217_IRQ_PIN, PullDisable);
1032 #endif
1033         return 0;
1034 }
1035
1036 static void cm3217_exit_hw(void)
1037 {
1038 #if 0
1039         gpio_free(CM3217_POWER_PIN);
1040         gpio_free(CM3217_IRQ_PIN);
1041 #endif
1042         return;
1043 }
1044
1045 static struct cm3217_platform_data cm3217_info = {
1046         .irq_pin = CM3217_IRQ_PIN,
1047         .power_pin = CM3217_POWER_PIN,
1048         .init_platform_hw = cm3217_init_hw,
1049         .exit_platform_hw = cm3217_exit_hw,
1050 };
1051 #endif
1052
1053 #if defined(CONFIG_PS_AL3006)
1054 static struct sensor_platform_data proximity_info = {
1055         .type = SENSOR_TYPE_PROXIMITY,
1056         .irq_enable = 1,
1057         .poll_delay_ms = 200,
1058 };
1059 #endif
1060
1061 #if defined(CONFIG_LS_AL3006)
1062 static struct sensor_platform_data light_info = {
1063         .type = SENSOR_TYPE_LIGHT,
1064         .irq_enable = 1,
1065         .poll_delay_ms = 200,
1066 };
1067 #endif
1068
1069
1070 #ifdef CONFIG_FB_ROCKCHIP
1071
1072 /*****************************************************************************************
1073  * lcd  devices
1074  * author: hhb@rock-chips.com
1075  *****************************************************************************************/
1076
1077 #define LCD_TXD_PIN             RK30_PIN1_PA7
1078 #define LCD_CLK_PIN             RK30_PIN1_PA5
1079 #define LCD_CS_PIN              RK30_PIN1_PA4
1080 #define LCD_RST_PIN             RK30_PIN4_PC7
1081
1082 /*****************************************************************************************
1083 * frame buffer  devices
1084 * author: hhb@rock-chips.com
1085 *****************************************************************************************/
1086 #define FB_ID                       0
1087 #define FB_DISPLAY_ON_PIN           INVALID_GPIO//RK29_PIN6_PD0
1088 #define FB_LCD_STANDBY_PIN          INVALID_GPIO//RK29_PIN6_PD1
1089 #define FB_LCD_CABC_EN_PIN          INVALID_GPIO//RK29_PIN6_PD2
1090 #define FB_MCU_FMK_PIN              INVALID_GPIO
1091
1092 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
1093 #define FB_LCD_STANDBY_VALUE        GPIO_HIGH
1094
1095
1096 //#endif
1097 static int rk29_lcd_io_init(void)
1098 {
1099         int ret = 0;
1100
1101         //printk("rk29_lcd_io_init\n");
1102
1103         ret = gpio_request(LCD_TXD_PIN, NULL);
1104         if (ret != 0) {
1105                 gpio_free(LCD_TXD_PIN);
1106                 printk("%s: request LCD_TXD_PIN error\n", __func__);
1107                 return -EIO;
1108         }
1109
1110         ret = gpio_request(LCD_CLK_PIN, NULL);
1111         if (ret != 0) {
1112                 gpio_free(LCD_CLK_PIN);
1113                 printk("%s: request LCD_CLK_PIN error\n", __func__);
1114                 return -EIO;
1115         }
1116
1117         ret = gpio_request(LCD_CS_PIN, NULL);
1118         if (ret != 0) {
1119                 gpio_free(LCD_CS_PIN);
1120                 printk("%s: request LCD_CS_PIN error\n", __func__);
1121                 return -EIO;
1122         }
1123
1124         rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0TXD_NAME, GPIO1A_GPIO1A7);
1125         rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0CLK_NAME, GPIO1A_GPIO1A5);
1126         rk30_mux_api_set(GPIO1A4_UART1SIN_SPI0CSN0_NAME, GPIO1A_GPIO1A4);
1127         //rk30_mux_api_set(GPIO4C7_SMCDATA7_TRACEDATA7_NAME, GPIO4C_GPIO4C7);
1128         gpio_direction_output(LCD_CS_PIN, 1);
1129         gpio_direction_output(LCD_CLK_PIN, 1);
1130         gpio_direction_output(LCD_TXD_PIN, 1);
1131         return ret;
1132 }
1133
1134 #if defined (CONFIG_RK29_WORKING_POWER_MANAGEMENT)
1135 static int rk29_lcd_io_deinit(void)
1136 {
1137         int ret = 0;
1138
1139         gpio_direction_input(LCD_TXD_PIN);
1140         gpio_direction_input(LCD_CLK_PIN);
1141         gpio_direction_input(LCD_CS_PIN);
1142
1143         gpio_free(LCD_CS_PIN);
1144         gpio_free(LCD_CLK_PIN);
1145         gpio_free(LCD_TXD_PIN);
1146         return ret;
1147 }
1148 #else
1149 static int rk29_lcd_io_deinit(void)
1150 {
1151         int ret = 0;
1152         //printk("rk29_lcd_io_deinit\n");
1153
1154         gpio_direction_input(LCD_TXD_PIN);
1155         gpio_direction_input(LCD_CLK_PIN);
1156         gpio_direction_input(LCD_CS_PIN);
1157
1158         gpio_free(LCD_CS_PIN);
1159         gpio_free(LCD_CLK_PIN);
1160         gpio_free(LCD_TXD_PIN);
1161         //gpio_free(LCD_RXD_PIN);
1162
1163         //rk30_mux_api_set(GPIO0B7_I2S8CHSDO3_NAME, GPIO0B_GPIO0B7);
1164         //rk30_mux_api_set(GPIO0B6_I2S8CHSDO2_NAME, GPIO0B_GPIO0B6);
1165         //rk30_mux_api_set(GPIO0B5_I2S8CHSDO1_NAME, GPIO0B_GPIO0B5);
1166
1167         return ret;
1168 }
1169 #endif
1170
1171
1172 static struct rk29lcd_info rk29_lcd_info = {
1173     .txd_pin  = LCD_TXD_PIN,
1174     .clk_pin = LCD_CLK_PIN,
1175     .cs_pin = LCD_CS_PIN,
1176     .reset_pin = LCD_RST_PIN,
1177     .io_init   = rk29_lcd_io_init,
1178     .io_deinit = rk29_lcd_io_deinit,
1179 };
1180
1181
1182 #define LCD_EN_MUX_NAME    GPIO0D4_I2S22CHSDI_SMCADDR0_NAME
1183 #define LCD_EN_PIN         RK30_PIN0_PD4
1184 #define LCD_EN_VALUE       GPIO_HIGH
1185
1186 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
1187 {
1188         int ret = 0;
1189         rk30_mux_api_set(LCD_EN_MUX_NAME, GPIO0D_GPIO0D4);
1190         ret = gpio_request(LCD_EN_PIN, NULL);
1191         if (ret != 0)
1192         {
1193                 gpio_free(LCD_EN_PIN);
1194                 printk(KERN_ERR "request lcd en pin fail!\n");
1195                 return -1;
1196         }
1197         else
1198         {
1199                 gpio_direction_output(LCD_EN_PIN, 1);
1200                 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
1201         }
1202         return 0;
1203 }
1204 static int rk_fb_io_disable(void)
1205 {
1206         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE ? 0:1);
1207         return 0;
1208 }
1209 static int rk_fb_io_enable(void)
1210 {
1211         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
1212         return 0;
1213 }
1214
1215 #if defined(CONFIG_LCDC0_RK30)
1216 struct rk29fb_info lcdc0_screen_info = {
1217         .fb_id   = FB_ID,
1218         .prop      = PRMRY,             //primary display device
1219         .lcd_info = &rk29_lcd_info,
1220         .io_init   = rk_fb_io_init,
1221         .io_disable = rk_fb_io_disable,
1222         .io_enable = rk_fb_io_enable,
1223         .set_screen_info = set_lcd_info,
1224 };
1225 #endif
1226
1227 #if defined(CONFIG_LCDC1_RK30)
1228 struct rk29fb_info lcdc1_screen_info = {
1229         #if defined(CONFIG_HDMI_RK30)
1230         .prop           = EXTEND,       //extend display device
1231         .lcd_info  = NULL,
1232         .set_screen_info = hdmi_set_info,
1233         #endif
1234 };
1235 #endif
1236
1237 static struct resource resource_fb[] = {
1238         [0] = {
1239                 .name  = "fb0 buf",
1240                 .start = 0,
1241                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1242                 .flags = IORESOURCE_MEM,
1243         },
1244         [1] = {
1245                 .name  = "ipp buf",  //for rotate
1246                 .start = 0,
1247                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1248                 .flags = IORESOURCE_MEM,
1249         },
1250         [2] = {
1251                 .name  = "fb2 buf",
1252                 .start = 0,
1253                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1254                 .flags = IORESOURCE_MEM,
1255         },
1256 };
1257
1258 static struct platform_device device_fb = {
1259         .name           = "rk-fb",
1260         .id             = -1,
1261         .num_resources  = ARRAY_SIZE(resource_fb),
1262         .resource       = resource_fb,
1263 };
1264 #endif
1265
1266 #ifdef CONFIG_ANDROID_TIMED_GPIO
1267 static struct timed_gpio timed_gpios[] = {
1268         {
1269                 .name = "vibrator",
1270                 .gpio = RK30_PIN0_PA4,
1271                 .max_timeout = 1000,
1272                 .active_low = 0,
1273                 .adjust_time =20,      //adjust for diff product
1274         },
1275 };
1276
1277 static struct timed_gpio_platform_data rk29_vibrator_info = {
1278         .num_gpios = 1,
1279         .gpios = timed_gpios,
1280 };
1281
1282 static struct platform_device rk29_device_vibrator = {
1283         .name = "timed-gpio",
1284         .id = -1,
1285         .dev = {
1286                 .platform_data = &rk29_vibrator_info,
1287         },
1288
1289 };
1290 #endif
1291
1292 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1293 static struct gpio_led rk29_leds[] = {
1294         {
1295                 .name = "button-backlight",
1296                 .gpio = RK30_PIN4_PD7,
1297                 .default_trigger = "timer",
1298                 .active_low = 0,
1299                 .retain_state_suspended = 0,
1300                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1301         },
1302 };
1303
1304 static struct gpio_led_platform_data rk29_leds_pdata = {
1305         .leds = rk29_leds,
1306         .num_leds = ARRAY_SIZE(rk29_leds),
1307 };
1308
1309 static struct platform_device rk29_device_gpio_leds = {
1310         .name   = "leds-gpio",
1311         .id     = -1,
1312         .dev    = {
1313                 .platform_data  = &rk29_leds_pdata,
1314         },
1315 };
1316 #endif
1317
1318 #ifdef CONFIG_RK_IRDA
1319 #define IRDA_IRQ_PIN           RK30_PIN6_PA1
1320
1321 static int irda_iomux_init(void)
1322 {
1323         int ret = 0;
1324
1325         //irda irq pin
1326         ret = gpio_request(IRDA_IRQ_PIN, NULL);
1327         if (ret != 0) {
1328                 gpio_free(IRDA_IRQ_PIN);
1329                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1330         }
1331         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1332         gpio_direction_input(IRDA_IRQ_PIN);
1333
1334         return 0;
1335 }
1336
1337 static int irda_iomux_deinit(void)
1338 {
1339         gpio_free(IRDA_IRQ_PIN);
1340         return 0;
1341 }
1342
1343 static struct irda_info rk29_irda_info = {
1344         .intr_pin = IRDA_IRQ_PIN,
1345         .iomux_init = irda_iomux_init,
1346         .iomux_deinit = irda_iomux_deinit,
1347         //.irda_pwr_ctl = bu92747guw_power_ctl,
1348 };
1349
1350 static struct platform_device irda_device = {
1351 #ifdef CONFIG_RK_IRDA_NET
1352         .name = "rk_irda",
1353 #else
1354         .name = "bu92747_irda",
1355 #endif
1356         .id = -1,
1357         .dev = {
1358                 .platform_data = &rk29_irda_info,
1359         }
1360 };
1361 #endif
1362
1363 #ifdef CONFIG_ION
1364 #define ION_RESERVE_SIZE        (80 * SZ_1M)
1365 static struct ion_platform_data rk30_ion_pdata = {
1366         .nr = 1,
1367         .heaps = {
1368                 {
1369                         .type = ION_HEAP_TYPE_CARVEOUT,
1370                         .id = ION_NOR_HEAP_ID,
1371                         .name = "norheap",
1372                         .size = ION_RESERVE_SIZE,
1373                 }
1374         },
1375 };
1376
1377 static struct platform_device device_ion = {
1378         .name = "ion-rockchip",
1379         .id = 0,
1380         .dev = {
1381                 .platform_data = &rk30_ion_pdata,
1382         },
1383 };
1384 #endif
1385
1386 /**************************************************************************************************
1387  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
1388 **************************************************************************************************/
1389 #ifdef CONFIG_SDMMC_RK29
1390 #include "board-rk30-phone-sdmmc.c"
1391
1392 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1393 #define SDMMC0_WRITE_PROTECT_PIN        RK30_PIN3_PB7   //According to your own project to set the value of write-protect-pin.
1394 #endif
1395
1396 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1397 #define SDMMC1_WRITE_PROTECT_PIN        RK30_PIN3_PC7   //According to your own project to set the value of write-protect-pin.
1398 #endif
1399
1400 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
1401
1402 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
1403
1404 #ifdef CONFIG_SDMMC0_RK29
1405 static int rk29_sdmmc0_cfg_gpio(void)
1406 {
1407 #ifdef CONFIG_SDMMC_RK29_OLD
1408         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1409         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1410         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1411         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1412         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1413         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1414
1415         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1416
1417         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1418         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1419         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1420
1421 #else
1422         rk29_sdmmc_set_iomux(0, 0xFFFF);
1423
1424         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
1425
1426 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1427         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1428         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1429 #endif
1430
1431 #endif
1432
1433         return 0;
1434 }
1435
1436 #define CONFIG_SDMMC0_USE_DMA
1437 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1438         .host_ocr_avail =
1439             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1440              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1441              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1442         .host_caps =
1443             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1444         .io_init = rk29_sdmmc0_cfg_gpio,
1445
1446 #if !defined(CONFIG_SDMMC_RK29_OLD)
1447         .set_iomux = rk29_sdmmc_set_iomux,
1448 #endif
1449
1450         .dma_name = "sd_mmc",
1451 #ifdef CONFIG_SDMMC0_USE_DMA
1452         .use_dma = 1,
1453 #else
1454         .use_dma = 0,
1455 #endif
1456         .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
1457         .enable_sd_wakeup = 0,
1458
1459 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1460         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1461 #else
1462         .write_prt = INVALID_GPIO,
1463 #endif
1464 };
1465 #endif // CONFIG_SDMMC0_RK29
1466
1467 #ifdef CONFIG_SDMMC1_RK29
1468 #define CONFIG_SDMMC1_USE_DMA
1469 static int rk29_sdmmc1_cfg_gpio(void)
1470 {
1471 #if defined(CONFIG_SDMMC_RK29_OLD)
1472         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1473         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1474         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1475         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1476         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1477         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1478         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
1479
1480 #else
1481
1482 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1483         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1484         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1485 #endif
1486
1487 #endif
1488
1489         return 0;
1490 }
1491
1492 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1493         .host_ocr_avail =
1494             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1495              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1496              MMC_VDD_33_34),
1497
1498 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1499         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1500                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1501 #else
1502         .host_caps =
1503             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1504 #endif
1505
1506         .io_init = rk29_sdmmc1_cfg_gpio,
1507
1508 #if !defined(CONFIG_SDMMC_RK29_OLD)
1509         .set_iomux = rk29_sdmmc_set_iomux,
1510 #endif
1511
1512         .dma_name = "sdio",
1513 #ifdef CONFIG_SDMMC1_USE_DMA
1514         .use_dma = 1,
1515 #else
1516         .use_dma = 0,
1517 #endif
1518
1519 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1520 #ifdef CONFIG_WIFI_CONTROL_FUNC
1521         .status = rk29sdk_wifi_status,
1522         .register_status_notify = rk29sdk_wifi_status_register,
1523 #endif
1524 #if 0
1525         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1526 #endif
1527
1528 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1529         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1530 #else
1531         .write_prt = INVALID_GPIO,
1532 #endif
1533
1534 #else
1535         .detect_irq = INVALID_GPIO,
1536         .enable_sd_wakeup = 0,
1537 #endif
1538
1539 };
1540 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1541
1542
1543 #ifdef CONFIG_BATTERY_RK30_ADC
1544 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1545         .dc_det_pin      = RK30_PIN6_PA5,
1546         .batt_low_pin    = RK30_PIN6_PA0,
1547         .charge_set_pin  = INVALID_GPIO,
1548         .charge_ok_pin   = RK30_PIN6_PA6,
1549         .dc_det_level    = GPIO_LOW,
1550         .charge_ok_level = GPIO_HIGH,
1551 };
1552
1553 static struct platform_device rk30_device_adc_battery = {
1554         .name   = "rk30-battery",
1555         .id     = -1,
1556         .dev = {
1557                 .platform_data = &rk30_adc_battery_platdata,
1558         },
1559 };
1560 #endif
1561
1562
1563 #ifdef CONFIG_RFKILL_RK
1564 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1565 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1566     .type               = RFKILL_TYPE_BLUETOOTH,
1567
1568     .poweron_gpio       = { // BT_REG_ON
1569         .io             = RK30_PIN4_PD5,
1570         .enable         = GPIO_HIGH,
1571         .iomux          = {
1572             .name       = GPIO4D5_SMCDATA13_TRACEDATA13_NAME,
1573             .fgpio      = GPIO4D_GPIO4D5,
1574         },
1575     },
1576
1577     .reset_gpio         = { // BT_RST
1578         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1579         .enable         = GPIO_LOW,
1580         .iomux          = {
1581             .name       = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1582             .fgpio      = GPIO3D_GPIO3D1,
1583         },
1584     },
1585
1586     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1587         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1588         .enable         = GPIO_HIGH,
1589         .iomux          = {
1590             .name       = GPIO3C6_SDMMC1DETECTN_NAME,
1591             .fgpio      = GPIO3C_GPIO3C6,
1592         },
1593     },
1594
1595     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1596         .gpio           = {
1597             .io         = RK30_PIN3_PD2, // set io to INVALID_GPIO for disable it
1598             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1599             .iomux      = {
1600                 .name   = GPIO3D2_SDMMC1INTN_NAME,
1601                 .fgpio  = RK30_PIN3_PD2,
1602             },
1603         },
1604     },
1605
1606     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1607         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1608         .enable         = GPIO_LOW,
1609         .iomux          = {
1610             .name       = GPIO1A3_UART0RTSN_NAME,
1611             .fgpio      = GPIO1A_GPIO1A3,
1612             .fmux       = GPIO1A_UART0_RTS_N,
1613         },
1614     },
1615 };
1616
1617 static struct platform_device device_rfkill_rk = {
1618     .name   = "rfkill_rk",
1619     .id     = -1,
1620     .dev    = {
1621         .platform_data = &rfkill_rk_platdata,
1622     },
1623 };
1624 #endif
1625
1626 /**************************************************************************************************
1627  * the end of setting for SDMMC devices
1628 **************************************************************************************************/
1629
1630 static struct platform_device *devices[] __initdata = {
1631 #ifdef CONFIG_BACKLIGHT_RK29_BL
1632         &rk29_device_backlight,
1633 #endif
1634 #ifdef CONFIG_FB_ROCKCHIP
1635         &device_fb,
1636 #endif
1637 #ifdef CONFIG_ION
1638         &device_ion,
1639 #endif
1640 #ifdef CONFIG_ANDROID_TIMED_GPIO
1641         &rk29_device_vibrator,
1642 #endif
1643 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1644         &rk29_device_gpio_leds,
1645 #endif
1646 #ifdef CONFIG_RK_IRDA
1647         &irda_device,
1648 #endif
1649 #ifdef CONFIG_WIFI_CONTROL_FUNC
1650         &rk29sdk_wifi_device,
1651 #endif
1652 #ifdef CONFIG_RFKILL_RK
1653         &device_rfkill_rk,
1654 #endif
1655 #ifdef CONFIG_RK29_SUPPORT_MODEM
1656     &rk30_device_modem,
1657 #endif
1658 #if defined(CONFIG_TDSC8800)
1659 &rk29_device_tdsc8800,
1660 #endif
1661 #if defined (CONFIG_RK_HEADSET_DET) ||  defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
1662     &rk_device_headset,
1663 #endif
1664 #ifdef CONFIG_BATTERY_RK30_ADC
1665         &rk30_device_adc_battery,
1666 #endif
1667 };
1668
1669 static struct aic3262_gpio_setup aic3262_gpio[] = {
1670         { // GPIO1
1671                 .used           = 0,
1672                 .in             = 0,
1673                 .value          = AIC3262_GPIO1_FUNC_INT1_OUTPUT ,
1674                 
1675         },
1676         {// GPIO2
1677                 .used           = 0,
1678                 .in             = 0,
1679                 .value          = AIC3262_GPIO2_FUNC_CLOCK_OUTPUT,
1680         },
1681         {// GPI1
1682                 .used           = 1,
1683                 .in             = 1,
1684                 .value          = 0,
1685         },
1686         {// GPI2
1687                 .used           = 1,
1688                 .in             = 1,
1689                 .value          = AIC3262_GPO1_FUNC_DISABLED,
1690         },
1691         {// GPO1
1692                 .used           = 0,
1693                 .in             = 0,
1694                 .value          = AIC3262_GPO1_FUNC_ADC_MOD_CLK_OUTPUT,
1695         },
1696 };
1697 static struct aic3262_pdata aic3262_codec_pdata = {
1698         .gpio           = aic3262_gpio,
1699         .gpio_reset = RK30_PIN0_PB7,
1700 };
1701
1702 // i2c
1703 #ifdef CONFIG_I2C0_RK30
1704 static struct i2c_board_info __initdata i2c0_info[] = {
1705 #if defined (CONFIG_GS_MMA8452)
1706         {
1707                 .type           = "gs_mma8452",
1708                 .addr           = 0x1d,
1709                 .flags          = 0,
1710                 .irq            = MMA8452_INT_PIN,
1711                 .platform_data = &mma8452_info,
1712         },
1713 #endif
1714 #if defined (CONFIG_GS_LIS3DH)
1715         {
1716                 .type           = "lis3dh",
1717                 .addr           = 0x19,
1718                 .flags          = 0,
1719                 .irq            = LIS3DH_INT_PIN,
1720                 .platform_data = &lis3dh_info,
1721         },
1722 #endif
1723
1724 #if defined (CONFIG_COMPASS_AK8975)
1725         {
1726                 .type          = "ak8975",
1727                 .addr          = 0x0d,
1728                 .flags         = 0,
1729                 .irq           = RK30_PIN4_PC1,
1730                 .platform_data = &akm8975_info,
1731         },
1732 #endif
1733 #if defined (CONFIG_GYRO_L3G4200D)
1734         {
1735                 .type          = "l3g4200d_gryo",
1736                 .addr          = 0x69,
1737                 .flags         = 0,
1738                 .irq           = L3G4200D_INT_PIN,
1739                 .platform_data = &l3g4200d_info,
1740         },
1741 #endif
1742 #if defined (CONFIG_INPUT_LPSENSOR_AL3006)
1743         {
1744                 .type           = "al3006",
1745                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1746                 .flags          = 0,
1747                 .irq            = RK30_PIN6_PA2,
1748         },
1749 #endif
1750 #if defined (CONFIG_LS_AL3006)
1751         {
1752                 .type           = "light_al3006",
1753                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1754                 .flags          = 0,
1755                 .irq            = RK30_PIN6_PA2,        
1756                 .platform_data = &light_info,
1757         },
1758 #endif
1759
1760 #if defined (CONFIG_PS_AL3006)
1761         {
1762                 .type           = "proximity_al3006",
1763                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1764                 .flags          = 0,
1765                 .irq            = RK30_PIN6_PA2,        
1766                 .platform_data = &proximity_info,
1767         },
1768 #endif
1769
1770 #if defined (CONFIG_SND_SOC_RK1000)
1771         {
1772                 .type          = "rk1000_i2c_codec",
1773                 .addr          = 0x60,
1774                 .flags         = 0,
1775         },
1776         {
1777                 .type          = "rk1000_control",
1778                 .addr          = 0x40,
1779                 .flags         = 0,
1780         },
1781 #endif
1782
1783 #if defined (CONFIG_SND_SOC_TLV320AIC326X)
1784         {
1785                 .type                   = "tlv320aic3262",
1786                 .addr           = 0x18,
1787                 .flags                  = 0,
1788                 .platform_data = &aic3262_codec_pdata,
1789         },
1790 #endif
1791
1792 #if defined (CONFIG_SND_SOC_RT5631)
1793         {
1794                 .type                   = "rt5631",
1795                 .addr                   = 0x1a,
1796                 .flags                  = 0,
1797         },
1798 #endif
1799
1800 #ifdef CONFIG_MFD_RK610
1801                 {
1802                         .type                   = "rk610_ctl",
1803                         .addr                   = 0x40,
1804                         .flags                  = 0,
1805                 },
1806 #ifdef CONFIG_RK610_TVOUT
1807                 {
1808                         .type                   = "rk610_tvout",
1809                         .addr                   = 0x42,
1810                         .flags                  = 0,
1811                 },
1812 #endif
1813 #ifdef CONFIG_HDMI_RK610
1814                 {
1815                         .type                   = "rk610_hdmi",
1816                         .addr                   = 0x46,
1817                         .flags                  = 0,
1818                         .irq                    = RK29_PIN5_PA2,
1819                 },
1820 #endif
1821 #ifdef CONFIG_SND_SOC_RK610
1822                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1823                         .type                   = "rk610_i2c_codec",
1824                         .addr                   = 0x60,
1825                         .flags                  = 0,
1826                 },
1827 #endif
1828 #endif
1829
1830 };
1831 #endif
1832
1833 #ifdef CONFIG_I2C1_RK30
1834 #define DC3_VCC_DDR_VOL 1800000   //for vcc_lpddr2_1v8
1835 #define DC5_VCC_DDR_VOL 1200000 //for vcc_lpddr2_1v2
1836 #include "board-rk30-phone-twl60xx.c"
1837 static struct i2c_board_info __initdata i2c1_info[] = {
1838
1839 #if defined (CONFIG_TWL4030_CORE)
1840         {
1841                 .type = "twl6032",
1842                 .addr = 0x48,
1843                 .flags = 0,
1844                 .irq            = RK30_PIN6_PA4, 
1845                 .platform_data = &tps80032_data,
1846
1847         },
1848
1849 #endif
1850 };
1851 #endif
1852
1853 #ifdef CONFIG_I2C2_RK30
1854 static struct i2c_board_info __initdata i2c2_info[] = {
1855
1856 #if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_S3202)
1857 {
1858         .type           = "rmi_i2c",
1859         .addr           = 0x20,
1860         .flags          = 0,
1861         .irq            = RK30_PIN4_PC2,
1862         .platform_data = &s3202_platformdata,
1863 },
1864 #endif
1865
1866
1867 #if defined (CONFIG_TOUCHSCREEN_FT5306)
1868 {
1869         .type           = "ft5x0x_ts",
1870         .addr           = 0x38,
1871         .flags          = 0,
1872         .irq            = RK30_PIN4_PD7,//RK30_PIN2_PC2,
1873         .platform_data = &ft5306_info,
1874 },
1875 #endif
1876
1877 #if defined (CONFIG_LS_CM3217)
1878         {
1879                 .type          = "lightsensor",
1880                 .addr          = 0x10,
1881                 .flags         = 0,
1882                 .irq           = CM3217_IRQ_PIN,
1883                 .platform_data = &cm3217_info,
1884         },
1885 #endif
1886 };
1887 #endif
1888
1889 #ifdef CONFIG_I2C3_RK30
1890
1891 static struct i2c_board_info __initdata i2c3_info[] = {
1892
1893
1894 };
1895 #endif
1896
1897 #ifdef CONFIG_I2C4_RK30
1898 static struct i2c_board_info __initdata i2c4_info[] = {
1899 };
1900 #endif
1901
1902 #ifdef CONFIG_I2C_GPIO_RK30
1903 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1904 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1905 static int rk30_i2c_io_init(void)
1906 {
1907         //set iomux (gpio) here
1908         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1909         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1910
1911         return 0;
1912 }
1913 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1914        .sda_pin = I2C_SDA_PIN,
1915        .scl_pin = I2C_SCL_PIN,
1916        .udelay = 5, // clk = 500/udelay = 100Khz
1917        .timeout = 100,//msecs_to_jiffies(100),
1918        .bus_num    = 5,
1919        .io_init = rk30_i2c_io_init,
1920 };
1921 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1922 };
1923 #endif
1924
1925 static void __init rk30_i2c_register_board_info(void)
1926 {
1927 #ifdef CONFIG_I2C0_RK30
1928         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1929 #endif
1930 #ifdef CONFIG_I2C1_RK30
1931         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1932 #endif
1933 #ifdef CONFIG_I2C2_RK30
1934         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1935 #endif
1936 #ifdef CONFIG_I2C3_RK30
1937         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1938 #endif
1939 #ifdef CONFIG_I2C4_RK30
1940         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1941 #endif
1942 #ifdef CONFIG_I2C_GPIO_RK30
1943         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1944 #endif
1945 }
1946 //end of i2c
1947
1948 static void rk30_pm_power_off(void)
1949 {
1950         printk(KERN_ERR "rk30_pm_power_off start...\n");
1951 #if defined(CONFIG_TWL4030_CORE)
1952         twl6030_poweroff();
1953 #endif
1954         while (1);
1955 }
1956
1957 #if 0
1958 /**********************************************************************************************
1959  *
1960  * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
1961  * on the touch screen panel. (added by hhb@rock-chips.com 2011.04.21)
1962  * attention please: kobj_attribute.attr.name virtualkeys.synaptics_rmi4_i2c should be the same as
1963  * the input device in the touch screen driver.
1964  ***********************************************************************************************/
1965 static ssize_t rk_virtual_keys_show(struct kobject *kobj,
1966                         struct kobj_attribute *attr, char *buf)
1967 {
1968 #if (defined(CONFIG_TOUCHSCREEN_SYNAPTICS_S3202))
1969          printk("rk_virtual_keys_show S3202\n");
1970     /* centerx;centery;width;height; */
1971         return sprintf(buf,
1972                 __stringify(EV_KEY) ":" __stringify(KEY_BACK)        ":100:980:100:40"
1973                 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU)   ":200:980:100:40"
1974                 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOMEPAGE)   ":300:980:100:40"
1975                 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":400:980:100:40"
1976                 "\n");
1977 #endif
1978         return 0;
1979 }
1980
1981 static struct kobj_attribute rk_virtual_keys_attr = {
1982         .attr = {
1983 #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_S3202)
1984                 .name = "virtualkeys.synaptics_rmi4_i2c",
1985 #else
1986                 .name = "virtualkeys",
1987 #endif
1988                 .mode = S_IRUGO,
1989         },
1990         .show = rk_virtual_keys_show,
1991 };
1992
1993 static struct attribute *rk_properties_attrs[] = {
1994         &rk_virtual_keys_attr.attr,
1995         NULL
1996 };
1997
1998 static struct attribute_group rk_properties_attr_group = {
1999         .attrs = rk_properties_attrs,
2000 };
2001 static int rk_virtual_keys_init(void)
2002 {
2003         int ret;
2004         struct kobject *properties_kobj;
2005         printk("rk_virtual_keys_init \n");
2006         properties_kobj = kobject_create_and_add("board_properties", NULL);
2007         if (properties_kobj)
2008                 ret = sysfs_create_group(properties_kobj,
2009                                 &rk_properties_attr_group);
2010         if (!properties_kobj || ret)
2011         {
2012                 printk("failed to create board_properties for virtual key\n");
2013         }
2014         return ret;
2015 }
2016
2017 /*************************end of virtual_keys************************/
2018 #endif
2019
2020 void board_gpio_suspend(void) {
2021         gpio_request(RK30_PIN2_PC3, NULL);
2022         rk30_mux_api_set(GPIO2C3_LCDC1DATA19_SPI1CLK_HSADCDATA0_NAME,GPIO2C_GPIO2C3);
2023         gpio_direction_input(RK30_PIN2_PC3);
2024         gpio_pull_updown(RK30_PIN2_PC3, 0);
2025         
2026         gpio_request(RK30_PIN2_PC5, NULL);
2027         rk30_mux_api_set(GPIO2C5_LCDC1DATA21_SPI1TXD_HSADCDATA2_NAME,GPIO2C_GPIO2C5);
2028         gpio_direction_input(RK30_PIN2_PC5);
2029         gpio_pull_updown(RK30_PIN2_PC5, 0);
2030         
2031         gpio_request(RK30_PIN2_PC6, NULL);
2032         rk30_mux_api_set(GPIO2C6_LCDC1DATA22_SPI1RXD_HSADCDATA3_NAME,GPIO2C_GPIO2C6);
2033         gpio_direction_input(RK30_PIN2_PC6);
2034         gpio_pull_updown(RK30_PIN2_PC6, 0);
2035         
2036 }
2037  void board_gpio_resume(void) {
2038
2039         gpio_request(RK30_PIN2_PC3, NULL);
2040         gpio_pull_updown(RK30_PIN2_PC3, 1);
2041         rk30_mux_api_set(GPIO2C3_LCDC1DATA19_SPI1CLK_HSADCDATA0_NAME,GPIO2C_SPI1_CLK);
2042         
2043         gpio_request(RK30_PIN2_PC5, NULL);
2044         gpio_pull_updown(RK30_PIN2_PC5, 1);
2045         rk30_mux_api_set(GPIO2C5_LCDC1DATA21_SPI1TXD_HSADCDATA2_NAME,GPIO2C_SPI1_TXD);
2046         
2047         gpio_request(RK30_PIN2_PC6, NULL);
2048         gpio_pull_updown(RK30_PIN2_PC6, 1);
2049         rk30_mux_api_set(GPIO2C6_LCDC1DATA22_SPI1RXD_HSADCDATA3_NAME,GPIO2C_SPI1_RXD);
2050
2051         gpio_free(RK30_PIN2_PC3);
2052         gpio_free(RK30_PIN2_PC5);
2053         gpio_free(RK30_PIN2_PC6);
2054 }
2055
2056 static void __init machine_rk30_board_init(void)
2057 {
2058         pm_power_off = rk30_pm_power_off;
2059         
2060         rk30_i2c_register_board_info();
2061         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2062         platform_add_devices(devices, ARRAY_SIZE(devices));
2063         board_usb_detect_init(RK30_PIN6_PA3);
2064
2065 #ifdef CONFIG_WIFI_CONTROL_FUNC
2066         rk29sdk_wifi_bt_gpio_control_init();
2067 #endif
2068 }
2069
2070 static void __init rk30_reserve(void)
2071 {
2072 #ifdef CONFIG_ION
2073         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2074 #endif
2075 #ifdef CONFIG_FB_ROCKCHIP
2076         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
2077         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
2078         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2079         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2080         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
2081         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
2082 #endif
2083 #ifdef CONFIG_VIDEO_RK29
2084         rk30_camera_request_reserve_mem();
2085 #endif
2086         board_mem_reserved();
2087 }
2088
2089 /**
2090  * dvfs_cpu_logic_table: table for arm and logic dvfs 
2091  * @frequency   : arm frequency
2092  * @cpu_volt    : arm voltage depend on frequency
2093  * @logic_volt  : logic voltage arm requests depend on frequency
2094  * comments     : min arm/logic voltage
2095  */
2096 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
2097         //{.frequency = 252 * 1000,     .cpu_volt = 1050 * 1000,        .logic_volt = 1050 * 1000},//0.975V/1.000V
2098         //{.frequency = 504 * 1000,     .cpu_volt = 1050 * 1000,        .logic_volt = 1050 * 1000},//0.975V/1.000V
2099         {.frequency = 816 * 1000,       .cpu_volt = 1050 * 1000,        .logic_volt = 1050 * 1000},//1.000V/1.025V
2100         {.frequency = 1008 * 1000,      .cpu_volt = 1050 * 1000,        .logic_volt = 1050 * 1000},//1.025V/1.050V
2101         {.frequency = 1200 * 1000,      .cpu_volt = 1150 * 1000,        .logic_volt = 1100 * 1000},//1.100V/1.050V
2102         {.frequency = 1272 * 1000,      .cpu_volt = 1200 * 1000,        .logic_volt = 1150 * 1000},//1.150V/1.100V
2103         {.frequency = 1416 * 1000,      .cpu_volt = 1275 * 1000,        .logic_volt = 1150 * 1000},//1.225V/1.100V
2104         //{.frequency = 1512 * 1000,    .cpu_volt = 1325 * 1000,        .logic_volt = 1200 * 1000},//1.300V/1.150V
2105         //{.frequency = 1608 * 1000,    .cpu_volt = 1350 * 1000,        .logic_volt = 1200 * 1000},//1.325V/1.175V
2106         {.frequency = CPUFREQ_TABLE_END},
2107 };
2108
2109 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
2110 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2111 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2112
2113 void __init board_clock_init(void)
2114 {
2115         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2116         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2117 }
2118
2119 MACHINE_START(RK30, "RK30board")
2120         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
2121         .fixup          = rk30_fixup,
2122         .reserve        = &rk30_reserve,
2123         .map_io         = rk30_map_io,
2124         .init_irq       = rk30_init_irq,
2125         .timer          = &rk30_timer,
2126         .init_machine   = machine_rk30_board_init,
2127 MACHINE_END