1 /* arch/arm/mach-rk30/board-rk30-sdk.c
3 * Copyright (C) 2012 ROCKCHIP, Inc.
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.
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.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.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>
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>
38 #include <mach/board.h>
39 #include <mach/hardware.h>
41 #include <mach/gpio.h>
42 #include <mach/iomux.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"
51 #if defined(CONFIG_SPIM_RK29)
52 #include "../../../drivers/spi/rk29_spim.h"
54 #if defined(CONFIG_MU509)
55 #include <linux/mu509.h>
57 #if defined(CONFIG_MW100)
58 #include <linux/mw100.h>
60 #if defined(CONFIG_MT6229)
61 #include <linux/mt6229.h>
63 #if defined(CONFIG_SEW868)
64 #include <linux/sew868.h>
66 #if defined(CONFIG_ANDROID_TIMED_GPIO)
67 #include "../../../drivers/staging/android/timed_gpio.h"
70 #ifdef CONFIG_THREE_FB_BUFFER
71 #define RK30_FB0_MEM_SIZE 12*SZ_1M
73 #define RK30_FB0_MEM_SIZE 8*SZ_1M
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
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
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
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
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
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
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
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
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
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
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
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
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 ---------*/
223 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
224 /*****************************************************************************************
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
234 static void rk_cif_power(int on)
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");
244 regulator_disable(ldo_28);
245 regulator_put(ldo_28);
246 regulator_disable(ldo_18);
247 regulator_put(ldo_18);
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);
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);
264 #if CONFIG_SENSOR_POWER_IOCTL_USR
265 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
267 //#error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
272 #if CONFIG_SENSOR_RESET_IOCTL_USR
273 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
275 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
279 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
280 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
282 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
286 #if CONFIG_SENSOR_FLASH_IOCTL_USR
287 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
289 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
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,
297 .sensor_power_cb = NULL,
300 #if CONFIG_SENSOR_RESET_IOCTL_USR
301 .sensor_reset_cb = sensor_reset_usr_cb,
303 .sensor_reset_cb = NULL,
306 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
307 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
309 .sensor_powerdown_cb = NULL,
312 #if CONFIG_SENSOR_FLASH_IOCTL_USR
313 .sensor_flash_cb = sensor_flash_usr_cb,
315 .sensor_flash_cb = NULL,
319 #if CONFIG_SENSOR_IIC_ADDR_0
320 static struct reginfo_t rk_init_data_sensor_reg_0[] =
324 static struct reginfo_t rk_init_data_sensor_winseqreg_0[] ={
329 #if CONFIG_SENSOR_IIC_ADDR_1
330 static struct reginfo_t rk_init_data_sensor_reg_1[] =
334 static struct reginfo_t rk_init_data_sensor_winseqreg_1[] =
339 #if CONFIG_SENSOR_IIC_ADDR_01
340 static struct reginfo_t rk_init_data_sensor_reg_01[] =
344 static struct reginfo_t rk_init_data_sensor_winseqreg_01[] =
349 #if CONFIG_SENSOR_IIC_ADDR_02
350 static struct reginfo_t rk_init_data_sensor_reg_02[] =
354 static struct reginfo_t rk_init_data_sensor_winseqreg_02[] =
359 #if CONFIG_SENSOR_IIC_ADDR_11
360 static struct reginfo_t rk_init_data_sensor_reg_11[] =
364 static struct reginfo_t rk_init_data_sensor_winseqreg_11[] =
369 #if CONFIG_SENSOR_IIC_ADDR_12
370 static struct reginfo_t rk_init_data_sensor_reg_12[] =
374 static struct reginfo_t rk_init_data_sensor_winseqreg_12[] =
379 static rk_sensor_user_init_data_s rk_init_data_sensor[RK_CAM_NUM] =
381 #if CONFIG_SENSOR_IIC_ADDR_0
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),
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,
404 #if CONFIG_SENSOR_IIC_ADDR_1
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),
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,
427 #if CONFIG_SENSOR_IIC_ADDR_01
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),
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,
450 #if CONFIG_SENSOR_IIC_ADDR_02
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),
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,
473 #if CONFIG_SENSOR_IIC_ADDR_11
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),
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,
496 #if CONFIG_SENSOR_IIC_ADDR_12
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),
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,
521 #include "../../../drivers/media/video/rk30_camera.c"
523 #endif /* CONFIG_VIDEO_RK29 */
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)
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));
536 if (TOUCH_PWR_PIN != INVALID_GPIO) {
537 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
539 gpio_free(TOUCH_PWR_PIN);
540 printk("goodix power error\n");
543 gpio_direction_output(TOUCH_PWR_PIN, 0);
544 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
548 if (TOUCH_RESET_PIN != INVALID_GPIO) {
549 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
551 gpio_free(TOUCH_RESET_PIN);
552 printk("goodix gpio_request error\n");
555 gpio_direction_output(TOUCH_RESET_PIN, 1);
557 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
559 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
565 struct goodix_platform_data goodix_info = {
567 .irq_pin = RK30_PIN4_PC2,
568 .rest_pin = TOUCH_RESET_PIN,
569 .init_platform_hw = goodix_init_platform_hw,
573 static struct spi_board_info board_spi_devices[] = {
576 /***********************************************************
578 ************************************************************/
579 #ifdef CONFIG_BACKLIGHT_RK29_BL
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
587 #define LCD_DISP_ON_PIN
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
593 #define BL_EN_PIN RK30_PIN6_PB3
594 #define BL_EN_VALUE GPIO_HIGH
596 static int rk29_backlight_io_init(void)
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);
603 ret = gpio_request(BL_EN_PIN, NULL);
605 gpio_free(BL_EN_PIN);
608 gpio_direction_output(BL_EN_PIN, 0);
609 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
614 static int rk29_backlight_io_deinit(void)
617 #ifdef LCD_DISP_ON_PIN
618 gpio_free(BL_EN_PIN);
620 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
624 static int rk29_backlight_pwm_suspend(void)
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__);
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);
640 static int rk29_backlight_pwm_resume(void)
643 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
644 #ifdef LCD_DISP_ON_PIN
646 gpio_direction_output(BL_EN_PIN, 1);
647 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
652 static struct rk29_bl_info rk29_bl_info = {
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,
661 static struct platform_device rk29_device_backlight = {
662 .name = "rk29_backlight",
665 .platform_data = &rk29_bl_info,
671 #ifdef CONFIG_RK29_SUPPORT_MODEM
673 #define RK30_MODEM_POWER RK30_PIN4_PD1
674 #define RK30_MODEM_POWER_IOMUX rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
676 static int rk30_modem_io_init(void)
678 printk("%s\n", __FUNCTION__);
679 RK30_MODEM_POWER_IOMUX;
684 static struct rk29_io_t rk30_modem_io = {
685 .io_addr = RK30_MODEM_POWER,
688 .io_init = rk30_modem_io_init,
691 static struct platform_device rk30_device_modem = {
692 .name = "rk30_modem",
695 .platform_data = &rk30_modem_io,
699 #if defined(CONFIG_MU509)
700 static int mu509_io_init(void)
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);
710 static int mu509_io_deinit(void)
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,
725 struct platform_device rk29_device_mu509 = {
729 .platform_data = &rk29_mu509_info,
733 #if defined(CONFIG_MW100)
734 static int mw100_io_init(void)
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);
743 static int mw100_io_deinit(void)
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,
758 struct platform_device rk29_device_mw100 = {
762 .platform_data = &rk29_mw100_info,
766 #if defined(CONFIG_MT6229)
767 static int mt6229_io_init(void)
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);
776 static int mt6229_io_deinit(void)
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,
791 struct platform_device rk29_device_mt6229 = {
795 .platform_data = &rk29_mt6229_info,
799 #if defined(CONFIG_SEW868)
800 static int sew868_io_init(void)
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);
807 static int sew868_io_deinit(void)
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,
823 struct platform_device rk30_device_sew868 = {
827 .platform_data = &rk30_sew868_info,
833 #if defined (CONFIG_GS_MMA8452)
834 #define MMA8452_INT_PIN RK30_PIN4_PC0
836 static int mma8452_init_platform_hw(void)
838 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
843 static struct sensor_platform_data mma8452_info = {
844 .type = SENSOR_TYPE_ACCEL,
847 .init_platform_hw = mma8452_init_platform_hw,
848 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
851 #if defined (CONFIG_GS_LIS3DH)
852 #define LIS3DH_INT_PIN RK30_PIN4_PC0
854 static int lis3dh_init_platform_hw(void)
856 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
861 static struct sensor_platform_data lis3dh_info = {
862 .type = SENSOR_TYPE_ACCEL,
865 .init_platform_hw = lis3dh_init_platform_hw,
866 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
869 #if defined (CONFIG_COMPASS_AK8975)
870 static struct sensor_platform_data akm8975_info =
872 .type = SENSOR_TYPE_COMPASS,
905 #if defined(CONFIG_GYRO_L3G4200D)
907 #include <linux/l3g4200d.h>
908 #define L3G4200D_INT_PIN RK30_PIN4_PC3
910 static int l3g4200d_init_platform_hw(void)
912 rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
917 static struct sensor_platform_data l3g4200d_info = {
918 .type = SENSOR_TYPE_GYROSCOPE,
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
930 #ifdef CONFIG_LS_CM3217
931 static struct sensor_platform_data cm3217_info = {
932 .type = SENSOR_TYPE_LIGHT,
934 .poll_delay_ms = 500,
939 #ifdef CONFIG_FB_ROCKCHIP
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
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
949 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
952 rk30_mux_api_set(LCD_CS_MUX_NAME, GPIO4C_GPIO4C7);
953 ret = gpio_request(LCD_CS_PIN, NULL);
956 gpio_free(LCD_CS_PIN);
957 printk(KERN_ERR "request lcd cs pin fail!\n");
962 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
964 ret = gpio_request(LCD_EN_PIN, NULL);
967 gpio_free(LCD_EN_PIN);
968 printk(KERN_ERR "request lcd en pin fail!\n");
973 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
977 static int rk_fb_io_disable(void)
979 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE? 0:1);
980 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE? 0:1);
983 static int rk_fb_io_enable(void)
985 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
986 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
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,
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
1005 .set_screen_info = hdmi_init_lcdc,
1010 static struct resource resource_fb[] = {
1014 .end = 0,//RK30_FB0_MEM_SIZE - 1,
1015 .flags = IORESOURCE_MEM,
1018 .name = "ipp buf", //for rotate
1020 .end = 0,//RK30_FB0_MEM_SIZE - 1,
1021 .flags = IORESOURCE_MEM,
1026 .end = 0,//RK30_FB0_MEM_SIZE - 1,
1027 .flags = IORESOURCE_MEM,
1031 static struct platform_device device_fb = {
1034 .num_resources = ARRAY_SIZE(resource_fb),
1035 .resource = resource_fb,
1039 #ifdef CONFIG_ANDROID_TIMED_GPIO
1040 static struct timed_gpio timed_gpios[] = {
1043 .gpio = RK30_PIN0_PA4,
1044 .max_timeout = 1000,
1046 .adjust_time =20, //adjust for diff product
1050 static struct timed_gpio_platform_data rk29_vibrator_info = {
1052 .gpios = timed_gpios,
1055 static struct platform_device rk29_device_vibrator = {
1056 .name = "timed-gpio",
1059 .platform_data = &rk29_vibrator_info,
1065 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1066 static struct gpio_led rk29_leds[] = {
1068 .name = "button-backlight",
1069 .gpio = RK30_PIN4_PD7,
1070 .default_trigger = "timer",
1072 .retain_state_suspended = 0,
1073 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1077 static struct gpio_led_platform_data rk29_leds_pdata = {
1079 .num_leds = ARRAY_SIZE(rk29_leds),
1082 static struct platform_device rk29_device_gpio_leds = {
1083 .name = "leds-gpio",
1086 .platform_data = &rk29_leds_pdata,
1091 #ifdef CONFIG_RK_IRDA
1092 #define IRDA_IRQ_PIN RK30_PIN6_PA1
1094 static int irda_iomux_init(void)
1099 ret = gpio_request(IRDA_IRQ_PIN, NULL);
1101 gpio_free(IRDA_IRQ_PIN);
1102 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1104 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1105 gpio_direction_input(IRDA_IRQ_PIN);
1110 static int irda_iomux_deinit(void)
1112 gpio_free(IRDA_IRQ_PIN);
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,
1123 static struct platform_device irda_device = {
1124 #ifdef CONFIG_RK_IRDA_NET
1127 .name = "bu92747_irda",
1131 .platform_data = &rk29_irda_info,
1137 #define ION_RESERVE_SIZE (80 * SZ_1M)
1138 static struct ion_platform_data rk30_ion_pdata = {
1142 .type = ION_HEAP_TYPE_CARVEOUT,
1143 .id = ION_NOR_HEAP_ID,
1145 .size = ION_RESERVE_SIZE,
1150 static struct platform_device device_ion = {
1151 .name = "ion-rockchip",
1154 .platform_data = &rk30_ion_pdata,
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"
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.
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.
1173 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK30_PIN6_PB2
1175 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
1177 #ifdef CONFIG_SDMMC0_RK29
1178 static int rk29_sdmmc0_cfg_gpio(void)
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);
1188 rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
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);
1195 rk29_sdmmc_set_iomux(0, 0xFFFF);
1197 rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
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);
1209 #define CONFIG_SDMMC0_USE_DMA
1210 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
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),
1216 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1217 .io_init = rk29_sdmmc0_cfg_gpio,
1219 #if !defined(CONFIG_SDMMC_RK29_OLD)
1220 .set_iomux = rk29_sdmmc_set_iomux,
1223 .dma_name = "sd_mmc",
1224 #ifdef CONFIG_SDMMC0_USE_DMA
1229 .detect_irq = RK30_PIN3_PB6, // INVALID_GPIO
1230 .enable_sd_wakeup = 0,
1232 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1233 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1235 .write_prt = INVALID_GPIO,
1238 #endif // CONFIG_SDMMC0_RK29
1240 #ifdef CONFIG_SDMMC1_RK29
1241 #define CONFIG_SDMMC1_USE_DMA
1242 static int rk29_sdmmc1_cfg_gpio(void)
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);
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);
1265 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
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 |
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),
1276 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1279 .io_init = rk29_sdmmc1_cfg_gpio,
1281 #if !defined(CONFIG_SDMMC_RK29_OLD)
1282 .set_iomux = rk29_sdmmc_set_iomux,
1286 #ifdef CONFIG_SDMMC1_USE_DMA
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,
1298 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1301 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1302 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1304 .write_prt = INVALID_GPIO,
1308 .detect_irq = INVALID_GPIO,
1309 .enable_sd_wakeup = 0,
1313 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1315 /**************************************************************************************************
1316 * the end of setting for SDMMC devices
1317 **************************************************************************************************/
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,
1329 static struct platform_device rk30_device_adc_battery = {
1330 .name = "rk30-battery",
1333 .platform_data = &rk30_adc_battery_platdata,
1338 #ifdef CONFIG_RK29_VMAC
1339 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1340 #include "board-rk30-sdk-vmac.c"
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,
1348 .poweron_gpio = { // BT_REG_ON
1349 .io = RK30_PIN3_PC7,
1350 .enable = GPIO_HIGH,
1352 .name = GPIO3C7_SDMMC1WRITEPRT_NAME,
1353 .fgpio = GPIO3C_GPIO3C7,
1357 .reset_gpio = { // BT_RST
1358 .io = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1361 .name = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1362 .fgpio = GPIO3D_GPIO3D1,
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,
1370 .name = GPIO3C6_SDMMC1DETECTN_NAME,
1371 .fgpio = GPIO3C_GPIO3C6,
1375 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
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
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
1389 .name = GPIO1A3_UART0RTSN_NAME,
1390 .fgpio = GPIO1A_GPIO1A3,
1391 .fmux = GPIO1A_UART0_RTS_N,
1396 static struct platform_device device_rfkill_rk = {
1397 .name = "rfkill_rk",
1400 .platform_data = &rfkill_rk_platdata,
1405 static struct platform_device *devices[] __initdata = {
1406 #ifdef CONFIG_BACKLIGHT_RK29_BL
1407 &rk29_device_backlight,
1409 #ifdef CONFIG_FB_ROCKCHIP
1415 #ifdef CONFIG_ANDROID_TIMED_GPIO
1416 &rk29_device_vibrator,
1418 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1419 &rk29_device_gpio_leds,
1421 #ifdef CONFIG_RK_IRDA
1424 #ifdef CONFIG_WIFI_CONTROL_FUNC
1425 &rk29sdk_wifi_device,
1427 #ifdef CONFIG_RK29_SUPPORT_MODEM
1430 #if defined(CONFIG_MU509)
1433 #if defined(CONFIG_MW100)
1436 #if defined(CONFIG_MT6229)
1437 &rk29_device_mt6229,
1439 #if defined(CONFIG_SEW868)
1440 &rk30_device_sew868,
1442 #ifdef CONFIG_BATTERY_RK30_ADC
1443 &rk30_device_adc_battery,
1445 #ifdef CONFIG_RFKILL_RK
1451 #ifdef CONFIG_I2C0_RK30
1452 static struct i2c_board_info __initdata i2c0_info[] = {
1453 #if defined (CONFIG_GS_MMA8452)
1455 .type = "gs_mma8452",
1458 .irq = MMA8452_INT_PIN,
1459 .platform_data = &mma8452_info,
1462 #if defined (CONFIG_GS_LIS3DH)
1464 .type = "gs_lis3dh",
1465 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1467 .irq = LIS3DH_INT_PIN,
1468 .platform_data = &lis3dh_info,
1471 #if defined (CONFIG_COMPASS_AK8975)
1476 .irq = RK30_PIN4_PC1,
1477 .platform_data = &akm8975_info,
1480 #if defined (CONFIG_GYRO_L3G4200D)
1482 .type = "l3g4200d_gryo",
1485 .irq = L3G4200D_INT_PIN,
1486 .platform_data = &l3g4200d_info,
1489 #if defined (CONFIG_SND_SOC_RK1000)
1491 .type = "rk1000_i2c_codec",
1496 .type = "rk1000_control",
1501 #if defined (CONFIG_SND_SOC_RT5631)
1509 #ifdef CONFIG_MFD_RK610
1511 .type = "rk610_ctl",
1515 #ifdef CONFIG_RK610_TVOUT
1517 .type = "rk610_tvout",
1522 #ifdef CONFIG_RK610_HDMI
1524 .type = "rk610_hdmi",
1527 .irq = RK29_PIN5_PA2,
1530 #ifdef CONFIG_SND_SOC_RK610
1531 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1532 .type = "rk610_i2c_codec",
1542 #ifdef CONFIG_I2C1_RK30
1543 #include "board-rk30-sdk-wm8326.c"
1545 static struct i2c_board_info __initdata i2c1_info[] = {
1546 #if defined (CONFIG_MFD_WM831X_I2C)
1551 .irq = RK30_PIN6_PA4,
1552 .platform_data = &wm831x_platdata,
1558 #ifdef CONFIG_I2C2_RK30
1559 static struct i2c_board_info __initdata i2c2_info[] = {
1560 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1562 .type = "Goodix-TS",
1565 .irq = RK30_PIN4_PC2,
1566 .platform_data = &goodix_info,
1569 #if defined (CONFIG_LS_CM3217)
1571 .type = "lightsensor",
1574 .platform_data = &cm3217_info,
1580 #ifdef CONFIG_I2C3_RK30
1581 static struct i2c_board_info __initdata i2c3_info[] = {
1585 #ifdef CONFIG_I2C4_RK30
1586 static struct i2c_board_info __initdata i2c4_info[] = {
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)
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);
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),
1607 .io_init = rk30_i2c_io_init,
1609 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1613 static void __init rk30_i2c_register_board_info(void)
1615 #ifdef CONFIG_I2C0_RK30
1616 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1618 #ifdef CONFIG_I2C1_RK30
1619 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1621 #ifdef CONFIG_I2C2_RK30
1622 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1624 #ifdef CONFIG_I2C3_RK30
1625 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1627 #ifdef CONFIG_I2C4_RK30
1628 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1630 #ifdef CONFIG_I2C_GPIO_RK30
1631 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1636 #define POWER_ON_PIN RK30_PIN6_PB0 //power_hold
1637 static void rk30_pm_power_off(void)
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
1648 static void __init machine_rk30_board_init(void)
1651 gpio_request(POWER_ON_PIN, "poweronpin");
1652 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1654 pm_power_off = rk30_pm_power_off;
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);
1661 #ifdef CONFIG_WIFI_CONTROL_FUNC
1662 rk29sdk_wifi_bt_gpio_control_init();
1666 static void __init rk30_reserve(void)
1669 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
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;
1679 #ifdef CONFIG_VIDEO_RK29
1680 rk30_camera_request_reserve_mem();
1682 board_mem_reserved();
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
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},
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},
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},
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];
1721 void __init board_clock_init(void)
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);
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,