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