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>
43 #include <linux/regulator/machine.h>
44 #include <linux/rfkill-rk.h>
45 #include <linux/sensor-dev.h>
46 #include <linux/regulator/rk29-pwm-regulator.h>
48 #include "../../../drivers/headset_observe/rk_headset.h"
49 #if defined(CONFIG_MFD_RK610)
50 #include <linux/mfd/rk610_core.h>
53 #if defined(CONFIG_RK_HDMI)
54 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
57 #if defined(CONFIG_SPIM_RK29)
58 #include "../../../drivers/spi/rk29_spim.h"
60 #if defined(CONFIG_MU509)
61 #include <linux/mu509.h>
63 #if defined(CONFIG_MT6229)
64 #include <linux/mt6229.h>
66 #if defined(CONFIG_MW100)
67 #include <linux/mw100.h>
69 #if defined (CONFIG_BP_AUTO)
70 #include <linux/bp-auto.h>
72 #if defined(CONFIG_SEW868)
73 #include <linux/sew868.h>
75 #if defined(CONFIG_ANDROID_TIMED_GPIO)
76 #include "../../../drivers/staging/android/timed_gpio.h"
79 /* Android Parameter */
80 static int ap_mdm = 0;
81 module_param(ap_mdm, int, 0644);
82 static int ap_has_alsa = 0;
83 module_param(ap_has_alsa, int, 0644);
84 static int ap_data_only = 2;
85 module_param(ap_data_only, int, 0644);
86 static int ap_has_earphone = 0;
87 module_param(ap_has_earphone, int, 0644);
89 #if defined(CONFIG_MT6620)
90 #include <linux/gps.h>
93 #if defined(CONFIG_DP501) //for display port transmitter dp501
94 #include<linux/dp501.h>
97 #include "board-rk30-sdk-camera.c"
100 static struct rk29_keys_button key_button[] = {
103 .code = KEY_VOLUMEDOWN,
104 .gpio = RK30_PIN4_PC5,
105 .active_low = PRESS_LEV_LOW,
110 .gpio = RK30_PIN6_PA2,
111 .active_low = PRESS_LEV_LOW,
112 //.code_long_press = EV_ENCALL,
117 .code = KEY_VOLUMEUP,
119 .gpio = INVALID_GPIO,
120 .active_low = PRESS_LEV_LOW,
127 .gpio = INVALID_GPIO,
128 .active_low = PRESS_LEV_LOW,
134 .gpio = INVALID_GPIO,
135 .active_low = PRESS_LEV_LOW,
141 .gpio = INVALID_GPIO,
142 .active_low = PRESS_LEV_LOW,
148 .gpio = INVALID_GPIO,
149 .active_low = PRESS_LEV_LOW,
156 .gpio = INVALID_GPIO,
157 .active_low = PRESS_LEV_LOW,
163 .gpio = INVALID_GPIO,
164 .active_low = PRESS_LEV_LOW,
170 .gpio = INVALID_GPIO,
171 .active_low = PRESS_LEV_LOW,
177 .gpio = INVALID_GPIO,
178 .active_low = PRESS_LEV_LOW,
183 struct rk29_keys_platform_data rk29_keys_pdata = {
184 .buttons = key_button,
185 .nbuttons = ARRAY_SIZE(key_button),
186 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
189 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
191 static int rk_headset_io_init(int gpio)
194 ret = gpio_request(gpio, "headset_input");
198 rk30_mux_api_set(GPIO0C7_TRACECTL_SMCADDR3_NAME, GPIO0C_GPIO0C7);
199 gpio_pull_updown(gpio, PullDisable);
200 gpio_direction_input(gpio);
205 struct rk_headset_pdata rk_headset_info = {
206 .Headset_gpio = RK30_PIN0_PC7,
207 .headset_in_type = HEADSET_IN_LOW,
209 .hook_key_code = KEY_MEDIA,
210 .headset_io_init = rk_headset_io_init,
213 struct platform_device rk_device_headset = {
214 .name = "rk_headsetdet",
217 .platform_data = &rk_headset_info,
221 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
222 #define TOUCH_RESET_PIN RK30_PIN4_PD0
223 #define TOUCH_PWR_PIN INVALID_GPIO
224 int goodix_init_platform_hw(void)
228 rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
229 rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
230 printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
232 if (TOUCH_PWR_PIN != INVALID_GPIO) {
233 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
235 gpio_free(TOUCH_PWR_PIN);
236 printk("goodix power error\n");
239 gpio_direction_output(TOUCH_PWR_PIN, 0);
240 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
244 if (TOUCH_RESET_PIN != INVALID_GPIO) {
245 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
247 gpio_free(TOUCH_RESET_PIN);
248 printk("goodix gpio_request error\n");
251 gpio_direction_output(TOUCH_RESET_PIN, 1);
253 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
255 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
261 struct goodix_platform_data goodix_info = {
263 .irq_pin = RK30_PIN4_PC2,
264 .rest_pin = TOUCH_RESET_PIN,
265 .init_platform_hw = goodix_init_platform_hw,
269 static struct spi_board_info board_spi_devices[] = {
272 /***********************************************************
274 ************************************************************/
275 #ifdef CONFIG_BACKLIGHT_RK29_BL
277 #define PWM_MUX_NAME GPIO0A3_PWM0_NAME
278 #define PWM_MUX_MODE GPIO0A_PWM0
279 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
280 #define PWM_GPIO RK30_PIN0_PA3
281 #define PWM_EFFECT_VALUE 1
283 #define LCD_DISP_ON_PIN
285 #ifdef LCD_DISP_ON_PIN
286 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
287 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
289 #define BL_EN_PIN RK30_PIN6_PB3
290 #define BL_EN_VALUE GPIO_HIGH
292 static int rk29_backlight_io_init(void)
295 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
296 #ifdef LCD_DISP_ON_PIN
297 // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
299 ret = gpio_request(BL_EN_PIN, NULL);
301 gpio_free(BL_EN_PIN);
304 gpio_direction_output(BL_EN_PIN, 0);
305 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
310 static int rk29_backlight_io_deinit(void)
313 #ifdef LCD_DISP_ON_PIN
314 gpio_free(BL_EN_PIN);
316 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
320 static int rk29_backlight_pwm_suspend(void)
323 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
324 if (gpio_request(PWM_GPIO, NULL)) {
325 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
328 gpio_direction_input(PWM_GPIO);
329 #ifdef LCD_DISP_ON_PIN
330 gpio_direction_output(BL_EN_PIN, 0);
331 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
336 static int rk29_backlight_pwm_resume(void)
339 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
340 #ifdef LCD_DISP_ON_PIN
342 gpio_direction_output(BL_EN_PIN, 1);
343 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
348 static struct rk29_bl_info rk29_bl_info = {
350 .bl_ref = PWM_EFFECT_VALUE,
351 .io_init = rk29_backlight_io_init,
352 .io_deinit = rk29_backlight_io_deinit,
353 .pwm_suspend = rk29_backlight_pwm_suspend,
354 .pwm_resume = rk29_backlight_pwm_resume,
357 static struct platform_device rk29_device_backlight = {
358 .name = "rk29_backlight",
361 .platform_data = &rk29_bl_info,
367 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
369 #define DIFFERENTIAL 1
375 SPK_AMPLIFY_ZERO_POINT_FIVE_WATT=1,
376 SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
377 SPK_AMPLIFY_ZERO_POINT_EIGHT_WATT,
378 SPK_AMPLIFY_ONE_WATT,
388 static int rt3261_io_init(int gpio, char *iomux_name, int iomux_mode)
390 gpio_request(gpio,NULL);
391 rk30_mux_api_set(iomux_name, iomux_mode);
392 gpio_direction_output(gpio,1);
396 static struct rt3261_platform_data rt3261_info = {
397 .codec_en_gpio = RK30_PIN4_PD7,
398 .codec_en_gpio_info = {GPIO4D7_SMCDATA15_TRACEDATA15_NAME,GPIO4D_GPIO4D7},
399 .io_init = rt3261_io_init,
401 .modem_input_mode = DIFFERENTIAL,
402 .lout_to_modem_mode = DIFFERENTIAL,
403 .spk_amplify = SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
404 .playback_if1_data_control = LR_NORMAL,
405 .playback_if2_data_control = LR_NORMAL,
409 #if defined(CONFIG_BP_AUTO)
410 static int bp_io_init(void)
412 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
413 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
414 rk30_mux_api_set(GPIO4C6_SMCDATA6_TRACEDATA6_NAME, GPIO4C_GPIO4C6);
415 rk30_mux_api_set(GPIO4C4_SMCDATA4_TRACEDATA4_NAME, GPIO4C_GPIO4C4);
416 //rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
417 //rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
421 static int bp_io_deinit(void)
426 static int bp_id_get(void)
428 return ap_mdm; //internally 3G modem ID, defined in include\linux\Bp-auto.h
431 struct bp_platform_data bp_auto_info = {
432 .init_platform_hw = bp_io_init,
433 .exit_platform_hw = bp_io_deinit,
434 .get_bp_id = bp_id_get,
435 .bp_power = RK30_PIN6_PB2, // 3g_power
436 .bp_en = RK30_PIN2_PB6, // 3g_en
437 .bp_reset = RK30_PIN4_PD2,
438 .bp_usb_en = BP_UNKNOW_DATA, //W_disable
439 .bp_uart_en = BP_UNKNOW_DATA, //EINT9
440 .bp_wakeup_ap = RK30_PIN4_PC6, //
441 .ap_wakeup_bp = RK30_PIN4_PC4,
442 .ap_ready = BP_UNKNOW_DATA, //
443 .bp_ready = BP_UNKNOW_DATA,
444 .gpio_valid = 1, //if 1:gpio is define in bp_auto_info,if 0:is not use gpio in bp_auto_info
447 struct platform_device device_bp_auto = {
451 .platform_data = &bp_auto_info,
455 #ifdef CONFIG_RK29_SUPPORT_MODEM
457 #define RK30_MODEM_POWER RK30_PIN4_PD1
458 #define RK30_MODEM_POWER_IOMUX rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
460 static int rk30_modem_io_init(void)
462 printk("%s\n", __FUNCTION__);
463 RK30_MODEM_POWER_IOMUX;
468 static struct rk29_io_t rk30_modem_io = {
469 .io_addr = RK30_MODEM_POWER,
472 .io_init = rk30_modem_io_init,
475 static struct platform_device rk30_device_modem = {
476 .name = "rk30_modem",
479 .platform_data = &rk30_modem_io,
483 #if defined(CONFIG_MU509)
484 static int mu509_io_init(void)
487 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
488 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
489 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
490 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
494 static int mu509_io_deinit(void)
500 struct rk29_mu509_data rk29_mu509_info = {
501 .io_init = mu509_io_init,
502 .io_deinit = mu509_io_deinit,
503 .modem_power_en = RK30_PIN6_PB2,//RK30_PIN4_PD1,
504 .bp_power = RK30_PIN2_PB6,//RK30_PIN4_PD1,
505 .bp_reset = RK30_PIN4_PD2,
506 .ap_wakeup_bp = RK30_PIN2_PB7,
507 .bp_wakeup_ap = RK30_PIN6_PA0,
509 struct platform_device rk29_device_mu509 = {
513 .platform_data = &rk29_mu509_info,
517 #if defined(CONFIG_MW100)
518 static int mw100_io_init(void)
520 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
521 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
522 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
523 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
527 static int mw100_io_deinit(void)
533 struct rk29_mw100_data rk29_mw100_info = {
534 .io_init = mw100_io_init,
535 .io_deinit = mw100_io_deinit,
536 .modem_power_en = RK30_PIN6_PB2,
537 .bp_power = RK30_PIN2_PB6,
538 .bp_reset = RK30_PIN4_PD2,
539 .ap_wakeup_bp = RK30_PIN2_PB7,
540 .bp_wakeup_ap = RK30_PIN6_PA0,
542 struct platform_device rk29_device_mw100 = {
546 .platform_data = &rk29_mw100_info,
550 #if defined(CONFIG_MT6229)
551 static int mt6229_io_init(void)
553 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
554 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
555 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
556 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
557 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
558 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
564 static int mt6229_io_deinit(void)
570 struct rk29_mt6229_data rk29_mt6229_info = {
571 .io_init = mt6229_io_init,
572 .io_deinit = mt6229_io_deinit,
573 .modem_power_en = RK30_PIN6_PB2,
574 .bp_power = RK30_PIN2_PB6,
575 .modem_usb_en = RK30_PIN2_PC0,
576 .modem_uart_en = RK30_PIN2_PC1,
577 .bp_wakeup_ap = RK30_PIN6_PA1,
578 .ap_ready = RK30_PIN2_PB7,
581 struct platform_device rk29_device_mt6229 = {
585 .platform_data = &rk29_mt6229_info,
589 #if defined(CONFIG_SEW868)
590 static int sew868_io_init(void)
592 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
593 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
594 rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4);
597 static int sew868_io_deinit(void)
601 struct rk30_sew868_data rk30_sew868_info = {
602 .io_init = sew868_io_init,
603 .io_deinit = sew868_io_deinit,
604 .bp_power = RK30_PIN6_PB2,
605 .bp_power_active_low = 1,
606 .bp_sys = RK30_PIN2_PB6,
607 .bp_reset = RK30_PIN4_PD2,
608 .bp_reset_active_low = 1,
609 .bp_wakeup_ap = RK30_PIN4_PD4,
610 .ap_wakeup_bp = NULL,
613 struct platform_device rk30_device_sew868 = {
617 .platform_data = &rk30_sew868_info,
623 #if defined (CONFIG_GS_MMA8452)
624 #define MMA8452_INT_PIN RK30_PIN4_PC0
626 static int mma8452_init_platform_hw(void)
628 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
633 static struct sensor_platform_data mma8452_info = {
634 .type = SENSOR_TYPE_ACCEL,
637 .init_platform_hw = mma8452_init_platform_hw,
638 .orientation = {-1, 0, 0, 0,-1, 0, 0, 0, 1},
641 #if defined (CONFIG_GS_LIS3DH)
642 #define LIS3DH_INT_PIN RK30_PIN4_PC0
644 static int lis3dh_init_platform_hw(void)
646 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
651 static struct sensor_platform_data lis3dh_info = {
652 .type = SENSOR_TYPE_ACCEL,
655 .init_platform_hw = lis3dh_init_platform_hw,
656 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
659 #if defined (CONFIG_GS_KXTIK)
660 #define KXTIK_INT_PIN RK30_PIN4_PC0
662 static int kxtik_init_platform_hw(void)
664 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
669 static struct sensor_platform_data kxtik_info = {
670 .type = SENSOR_TYPE_ACCEL,
673 .init_platform_hw = kxtik_init_platform_hw,
674 .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
678 #if defined (CONFIG_COMPASS_AK8975)
679 static struct sensor_platform_data akm8975_info =
681 .type = SENSOR_TYPE_COMPASS,
714 #if defined(CONFIG_GYRO_L3G4200D)
716 #include <linux/l3g4200d.h>
717 #define L3G4200D_INT_PIN RK30_PIN4_PC3
719 static int l3g4200d_init_platform_hw(void)
721 rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
726 static struct sensor_platform_data l3g4200d_info = {
727 .type = SENSOR_TYPE_GYROSCOPE,
730 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
731 .init_platform_hw = l3g4200d_init_platform_hw,
732 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
739 #ifdef CONFIG_LS_CM3217
740 static struct sensor_platform_data cm3217_info = {
741 .type = SENSOR_TYPE_LIGHT,
743 .poll_delay_ms = 500,
748 #if defined(CONFIG_PS_AL3006)
749 static struct sensor_platform_data proximity_al3006_info = {
750 .type = SENSOR_TYPE_PROXIMITY,
752 .poll_delay_ms = 200,
756 #if defined(CONFIG_PS_STK3171)
757 static struct sensor_platform_data proximity_stk3171_info = {
758 .type = SENSOR_TYPE_PROXIMITY,
760 .poll_delay_ms = 200,
765 #if defined(CONFIG_LS_AL3006)
766 static struct sensor_platform_data light_al3006_info = {
767 .type = SENSOR_TYPE_LIGHT,
769 .poll_delay_ms = 200,
773 #if defined(CONFIG_LS_STK3171)
774 static struct sensor_platform_data light_stk3171_info = {
775 .type = SENSOR_TYPE_LIGHT,
777 .poll_delay_ms = 200,
780 #ifdef CONFIG_FB_ROCKCHIP
782 #define LCD_CS_PIN RK30_PIN4_PC7
783 #define LCD_CS_VALUE GPIO_HIGH
785 #define LCD_EN_PIN RK30_PIN6_PB4
786 #define LCD_EN_VALUE GPIO_LOW
788 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
792 if(LCD_CS_PIN != INVALID_GPIO)
794 ret = gpio_request(LCD_CS_PIN, NULL);
797 gpio_free(LCD_CS_PIN);
798 printk(KERN_ERR "request lcd cs pin fail!\n");
803 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
807 if(LCD_EN_PIN != INVALID_GPIO)
809 ret = gpio_request(LCD_EN_PIN, NULL);
812 gpio_free(LCD_EN_PIN);
813 printk(KERN_ERR "request lcd en pin fail!\n");
818 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
823 static int rk_fb_io_disable(void)
825 if(LCD_CS_PIN != INVALID_GPIO)
827 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
830 if(LCD_EN_PIN != INVALID_GPIO)
832 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
836 static int rk_fb_io_enable(void)
838 if(LCD_CS_PIN != INVALID_GPIO)
840 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
842 if(LCD_EN_PIN != INVALID_GPIO)
844 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
849 #if defined(CONFIG_LCDC0_RK30)
850 struct rk29fb_info lcdc0_screen_info = {
851 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
852 .prop = EXTEND, //extend display device
856 .set_screen_info = hdmi_init_lcdc,
858 .prop = PRMRY, //primary display device
859 .io_init = rk_fb_io_init,
860 .io_disable = rk_fb_io_disable,
861 .io_enable = rk_fb_io_enable,
862 .set_screen_info = set_lcd_info,
868 #if defined(CONFIG_LCDC1_RK30)
869 struct rk29fb_info lcdc1_screen_info = {
870 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
871 .prop = EXTEND, //extend display device
875 .set_screen_info = hdmi_init_lcdc,
877 .prop = PRMRY, //primary display device
878 .io_init = rk_fb_io_init,
879 .io_disable = rk_fb_io_disable,
880 .io_enable = rk_fb_io_enable,
881 .set_screen_info = set_lcd_info,
887 static struct resource resource_fb[] = {
891 .end = 0,//RK30_FB0_MEM_SIZE - 1,
892 .flags = IORESOURCE_MEM,
895 .name = "ipp buf", //for rotate
897 .end = 0,//RK30_FB0_MEM_SIZE - 1,
898 .flags = IORESOURCE_MEM,
903 .end = 0,//RK30_FB0_MEM_SIZE - 1,
904 .flags = IORESOURCE_MEM,
908 static struct platform_device device_fb = {
911 .num_resources = ARRAY_SIZE(resource_fb),
912 .resource = resource_fb,
916 #if defined(CONFIG_LCDC0_RK30)
917 static struct resource resource_lcdc0[] = {
920 .start = RK30_LCDC0_PHYS,
921 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
922 .flags = IORESOURCE_MEM,
929 .flags = IORESOURCE_IRQ,
933 static struct platform_device device_lcdc0 = {
936 .num_resources = ARRAY_SIZE(resource_lcdc0),
937 .resource = resource_lcdc0,
939 .platform_data = &lcdc0_screen_info,
943 #if defined(CONFIG_LCDC1_RK30)
944 extern struct rk29fb_info lcdc1_screen_info;
945 static struct resource resource_lcdc1[] = {
948 .start = RK30_LCDC1_PHYS,
949 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
950 .flags = IORESOURCE_MEM,
956 .flags = IORESOURCE_IRQ,
960 static struct platform_device device_lcdc1 = {
963 .num_resources = ARRAY_SIZE(resource_lcdc1),
964 .resource = resource_lcdc1,
966 .platform_data = &lcdc1_screen_info,
971 #if defined(CONFIG_DP501)
972 #define DVDD33_EN_PIN RK30_PIN6_PB4
973 #define DVDD33_EN_VALUE GPIO_LOW
975 #define DVDD12_EN_PIN RK30_PIN4_PC7
976 #define DVDD12_EN_VALUE GPIO_HIGH
978 #define EDP_RST_PIN RK30_PIN2_PC4
979 static int rk_edp_power_ctl(void)
982 ret = gpio_request(DVDD33_EN_PIN, "dvdd33_en_pin");
985 gpio_free(DVDD33_EN_PIN);
986 printk(KERN_ERR "request dvdd33 en pin fail!\n");
991 gpio_direction_output(DVDD33_EN_PIN, DVDD33_EN_VALUE);
994 ret = gpio_request(DVDD12_EN_PIN, "dvdd18_en_pin");
997 gpio_free(DVDD12_EN_PIN);
998 printk(KERN_ERR "request dvdd18 en pin fail!\n");
1003 gpio_direction_output(DVDD12_EN_PIN, DVDD12_EN_VALUE);
1006 ret = gpio_request(EDP_RST_PIN, "edp_rst_pin");
1009 gpio_free(EDP_RST_PIN);
1010 printk(KERN_ERR "request rst pin fail!\n");
1015 gpio_direction_output(EDP_RST_PIN, GPIO_LOW);
1017 gpio_direction_output(EDP_RST_PIN, GPIO_HIGH);
1022 static struct dp501_platform_data dp501_platform_data = {
1023 .power_ctl = rk_edp_power_ctl,
1024 .dvdd33_en_pin = DVDD33_EN_PIN,
1025 .dvdd33_en_val = DVDD33_EN_VALUE,
1026 .dvdd18_en_pin = DVDD12_EN_PIN,
1027 .dvdd18_en_val = DVDD12_EN_VALUE,
1028 .edp_rst_pin = EDP_RST_PIN,
1032 #if defined(CONFIG_MFD_RK610)
1033 #define RK610_RST_PIN_MUX_NAME GPIO0C6_TRACECLK_SMCADDR2_NAME
1034 #define RK610_RST_PIN_MUX_MODE GPIO0C_GPIO0C6
1035 #define RK610_RST_PIN RK30_PIN0_PC6
1036 static int rk610_power_on_init(void)
1039 if(RK610_RST_PIN != INVALID_GPIO)
1041 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
1042 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
1045 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
1049 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
1051 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
1053 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
1062 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
1063 .rk610_power_on_init = rk610_power_on_init,
1066 #ifdef CONFIG_SND_SOC_RK610
1067 static int rk610_codec_io_init(void)
1070 //Must not gpio_request
1074 static struct rk610_codec_platform_data rk610_codec_pdata = {
1075 .spk_ctl_io = RK30_PIN4_PC6,
1076 .io_init = rk610_codec_io_init,
1079 #ifdef CONFIG_ANDROID_TIMED_GPIO
1080 static struct timed_gpio timed_gpios[] = {
1083 .gpio = RK30_PIN0_PA4,
1084 .max_timeout = 1000,
1086 .adjust_time =20, //adjust for diff product
1090 static struct timed_gpio_platform_data rk29_vibrator_info = {
1092 .gpios = timed_gpios,
1095 static struct platform_device rk29_device_vibrator = {
1096 .name = "timed-gpio",
1099 .platform_data = &rk29_vibrator_info,
1105 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1106 static struct gpio_led rk29_leds[] = {
1108 .name = "button-backlight",
1109 .gpio = RK30_PIN4_PD7,
1110 .default_trigger = "timer",
1112 .retain_state_suspended = 0,
1113 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1117 static struct gpio_led_platform_data rk29_leds_pdata = {
1119 .num_leds = ARRAY_SIZE(rk29_leds),
1122 static struct platform_device rk29_device_gpio_leds = {
1123 .name = "leds-gpio",
1126 .platform_data = &rk29_leds_pdata,
1131 #ifdef CONFIG_RK_IRDA
1132 #define IRDA_IRQ_PIN RK30_PIN6_PA1
1134 static int irda_iomux_init(void)
1139 ret = gpio_request(IRDA_IRQ_PIN, NULL);
1141 gpio_free(IRDA_IRQ_PIN);
1142 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1144 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1145 gpio_direction_input(IRDA_IRQ_PIN);
1150 static int irda_iomux_deinit(void)
1152 gpio_free(IRDA_IRQ_PIN);
1156 static struct irda_info rk29_irda_info = {
1157 .intr_pin = IRDA_IRQ_PIN,
1158 .iomux_init = irda_iomux_init,
1159 .iomux_deinit = irda_iomux_deinit,
1160 //.irda_pwr_ctl = bu92747guw_power_ctl,
1163 static struct platform_device irda_device = {
1164 #ifdef CONFIG_RK_IRDA_NET
1167 .name = "bu92747_irda",
1171 .platform_data = &rk29_irda_info,
1177 #define ION_RESERVE_SIZE (80 * SZ_1M)
1178 static struct ion_platform_data rk30_ion_pdata = {
1182 .type = ION_HEAP_TYPE_CARVEOUT,
1183 .id = ION_NOR_HEAP_ID,
1185 .size = ION_RESERVE_SIZE,
1190 static struct platform_device device_ion = {
1191 .name = "ion-rockchip",
1194 .platform_data = &rk30_ion_pdata,
1199 /**************************************************************************************************
1200 * SDMMC devices, include the module of SD,MMC,and SDIO.noted by xbw at 2012-03-05
1201 **************************************************************************************************/
1202 #ifdef CONFIG_SDMMC_RK29
1203 #include "board-rk30-sdk-sdmmc.c"
1206 #ifdef CONFIG_SDMMC0_RK29
1207 static int rk29_sdmmc0_cfg_gpio(void)
1209 #ifdef CONFIG_SDMMC_RK29_OLD
1210 rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1211 rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1212 rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1213 rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1214 rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1215 rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1217 rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1219 rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1220 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1221 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1224 rk29_sdmmc_set_iomux(0, 0xFFFF);
1226 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
1227 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
1229 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
1232 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1233 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1234 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1242 #define CONFIG_SDMMC0_USE_DMA
1243 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1245 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1246 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1247 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1249 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1250 .io_init = rk29_sdmmc0_cfg_gpio,
1252 #if !defined(CONFIG_SDMMC_RK29_OLD)
1253 .set_iomux = rk29_sdmmc_set_iomux,
1256 .dma_name = "sd_mmc",
1257 #ifdef CONFIG_SDMMC0_USE_DMA
1263 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1264 .status = rk29sdk_wifi_mmc0_status,
1265 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1268 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1269 .power_en = RK29SDK_SD_CARD_PWR_EN,
1270 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1272 .power_en = INVALID_GPIO,
1273 .power_en_level = GPIO_LOW,
1275 .enable_sd_wakeup = 0,
1277 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1278 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1279 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1281 .write_prt = INVALID_GPIO,
1285 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1286 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1287 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1288 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1290 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1291 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1292 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1294 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1295 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1306 #endif // CONFIG_SDMMC0_RK29
1308 #ifdef CONFIG_SDMMC1_RK29
1309 #define CONFIG_SDMMC1_USE_DMA
1310 static int rk29_sdmmc1_cfg_gpio(void)
1312 #if defined(CONFIG_SDMMC_RK29_OLD)
1313 rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1314 rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1315 rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1316 rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1317 rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1318 rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1321 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1322 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1323 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1331 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1333 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1334 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1337 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1338 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1339 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1342 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1345 .io_init = rk29_sdmmc1_cfg_gpio,
1347 #if !defined(CONFIG_SDMMC_RK29_OLD)
1348 .set_iomux = rk29_sdmmc_set_iomux,
1352 #ifdef CONFIG_SDMMC1_USE_DMA
1358 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1359 .status = rk29sdk_wifi_status,
1360 .register_status_notify = rk29sdk_wifi_status_register,
1363 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1364 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1365 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1367 .write_prt = INVALID_GPIO,
1370 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1371 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1375 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1376 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1377 .io = RK29SDK_SD_CARD_DETECT_N,
1382 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1383 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1385 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1386 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1387 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1389 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1390 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1400 .enable_sd_wakeup = 0,
1402 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1404 /**************************************************************************************************
1405 * the end of setting for SDMMC devices
1406 **************************************************************************************************/
1408 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1409 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1410 .dc_det_pin = RK30_PIN6_PA5,
1411 .batt_low_pin = RK30_PIN6_PA0,
1412 .charge_set_pin = INVALID_GPIO,
1413 .charge_ok_pin = RK30_PIN6_PA6,
1414 .dc_det_level = GPIO_LOW,
1415 .charge_ok_level = GPIO_HIGH,
1418 static struct platform_device rk30_device_adc_battery = {
1419 .name = "rk30-battery",
1422 .platform_data = &rk30_adc_battery_platdata,
1427 #ifdef CONFIG_RK30_PWM_REGULATOR
1428 const static int pwm_voltage_map[] = {
1429 950000,975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1432 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1434 .supply = "vdd_core",
1438 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1442 .name = "PWM_DCDC1",
1444 .max_uV = 1800000, //0.6-1.8V
1446 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1448 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1449 .consumer_supplies = pwm_dcdc1_consumers,
1453 static struct pwm_platform_data pwm_regulator_info[1] = {
1456 .pwm_gpio = RK30_PIN0_PD7,
1457 .pwm_iomux_name = GPIO0D7_PWM3_NAME,
1458 .pwm_iomux_pwm = GPIO0D_PWM3,
1459 .pwm_iomux_gpio = GPIO0D_GPIO0D6,
1460 .pwm_voltage = 1100000,
1461 .suspend_voltage = 1050000,
1464 .coefficient = 455, //45.5%
1465 .pwm_voltage_map = pwm_voltage_map,
1466 .init_data = &pwm_regulator_init_dcdc[0],
1470 struct platform_device pwm_regulator_device[1] = {
1472 .name = "pwm-voltage-regulator",
1475 .platform_data = &pwm_regulator_info[0],
1481 #ifdef CONFIG_RK29_VMAC
1482 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1483 #include "board-rk30-sdk-vmac.c"
1486 #ifdef CONFIG_RFKILL_RK
1487 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1488 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1489 .type = RFKILL_TYPE_BLUETOOTH,
1491 .poweron_gpio = { // BT_REG_ON
1492 .io = RK30_PIN3_PC7,
1493 .enable = GPIO_HIGH,
1495 .name = GPIO3C7_SDMMC1WRITEPRT_NAME,
1496 .fgpio = GPIO3C_GPIO3C7,
1500 .reset_gpio = { // BT_RST
1501 .io = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1504 .name = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1505 .fgpio = GPIO3D_GPIO3D1,
1509 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1510 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1511 .enable = GPIO_HIGH,
1513 .name = GPIO3C6_SDMMC1DETECTN_NAME,
1514 .fgpio = GPIO3C_GPIO3C6,
1518 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1520 .io = RK30_PIN6_PA7, // set io to INVALID_GPIO for disable it
1521 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1528 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1529 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1532 .name = GPIO1A3_UART0RTSN_NAME,
1533 .fgpio = GPIO1A_GPIO1A3,
1534 .fmux = GPIO1A_UART0_RTS_N,
1539 static struct platform_device device_rfkill_rk = {
1540 .name = "rfkill_rk",
1543 .platform_data = &rfkill_rk_platdata,
1548 #if defined(CONFIG_MT5931_MT6622)
1549 static struct mt6622_platform_data mt6622_platdata = {
1550 .power_gpio = { // BT_REG_ON
1551 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1552 .enable = GPIO_HIGH,
1558 .reset_gpio = { // BT_RST
1559 .io = RK30_PIN3_PD1,
1567 .io = RK30_PIN6_PA7,
1568 .enable = GPIO_HIGH,
1575 static struct platform_device device_mt6622 = {
1579 .platform_data = &mt6622_platdata,
1584 static struct platform_device *devices[] __initdata = {
1588 #ifdef CONFIG_ANDROID_TIMED_GPIO
1589 &rk29_device_vibrator,
1591 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1592 &rk29_device_gpio_leds,
1594 #ifdef CONFIG_RK_IRDA
1597 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1598 &rk29sdk_wifi_device,
1601 #if defined(CONFIG_MT6620)
1605 #ifdef CONFIG_RK29_SUPPORT_MODEM
1608 #if defined(CONFIG_MU509)
1611 #if defined(CONFIG_MW100)
1614 #if defined(CONFIG_MT6229)
1615 &rk29_device_mt6229,
1617 #if defined(CONFIG_SEW868)
1618 &rk30_device_sew868,
1620 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
1624 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1625 &rk30_device_adc_battery,
1627 #ifdef CONFIG_RFKILL_RK
1630 #ifdef CONFIG_MT5931_MT6622
1633 #if defined(CONFIG_BP_AUTO)
1639 static int rk_platform_add_display_devices(void)
1641 struct platform_device *fb = NULL; //fb
1642 struct platform_device *lcdc0 = NULL; //lcdc0
1643 struct platform_device *lcdc1 = NULL; //lcdc1
1644 struct platform_device *bl = NULL; //backlight
1645 #ifdef CONFIG_FB_ROCKCHIP
1649 #if defined(CONFIG_LCDC0_RK30)
1650 lcdc0 = &device_lcdc0,
1653 #if defined(CONFIG_LCDC1_RK30)
1654 lcdc1 = &device_lcdc1,
1657 #ifdef CONFIG_BACKLIGHT_RK29_BL
1658 bl = &rk29_device_backlight,
1660 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1666 #ifdef CONFIG_I2C0_RK30
1667 static struct i2c_board_info __initdata i2c0_info[] = {
1668 #if defined (CONFIG_GS_MMA8452)
1670 .type = "gs_mma8452",
1673 .irq = MMA8452_INT_PIN,
1674 .platform_data = &mma8452_info,
1677 #if defined (CONFIG_GS_LIS3DH)
1679 .type = "gs_lis3dh",
1680 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1682 .irq = LIS3DH_INT_PIN,
1683 .platform_data = &lis3dh_info,
1686 #if defined (CONFIG_GS_KXTIK)
1691 .irq = KXTIK_INT_PIN,
1692 .platform_data = &kxtik_info,
1695 #if defined (CONFIG_COMPASS_AK8975)
1700 .irq = RK30_PIN4_PC1,
1701 .platform_data = &akm8975_info,
1704 #if defined (CONFIG_GYRO_L3G4200D)
1706 .type = "l3g4200d_gryo",
1709 .irq = L3G4200D_INT_PIN,
1710 .platform_data = &l3g4200d_info,
1713 #if defined (CONFIG_LS_AL3006)
1715 .type = "light_al3006",
1716 .addr = 0x1c, //sel = 0; if sel =1, then addr = 0x1D
1718 .irq = RK30_PIN6_PA2,
1719 .platform_data = &light_al3006_info,
1722 #if defined (CONFIG_LS_STK3171)
1724 .type = "ls_stk3171",
1727 .irq = RK30_PIN6_PA2,
1728 .platform_data = &light_stk3171_info,
1733 #if defined (CONFIG_PS_AL3006)
1735 .type = "proximity_al3006",
1736 .addr = 0x1c, //sel = 0; if sel =1, then addr = 0x1D
1738 .irq = RK30_PIN6_PA2,
1739 .platform_data = &proximity_al3006_info,
1743 #if defined (CONFIG_PS_STK3171)
1745 .type = "ps_stk3171",
1748 .irq = RK30_PIN6_PA2,
1749 .platform_data = &proximity_stk3171_info,
1752 #if defined (CONFIG_SND_SOC_RK1000)
1754 .type = "rk1000_i2c_codec",
1759 .type = "rk1000_control",
1764 #if defined (CONFIG_SND_SOC_RT5631) || defined (CONFIG_SND_SOC_RT5631_PHONE)
1771 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
1776 .platform_data = &rt3261_info,
1780 #ifdef CONFIG_MFD_RK610
1782 .type = "rk610_ctl",
1785 .platform_data = &rk610_ctl_pdata,
1787 #ifdef CONFIG_RK610_TVOUT
1789 .type = "rk610_tvout",
1794 #ifdef CONFIG_HDMI_RK610
1796 .type = "rk610_hdmi",
1799 .irq = INVALID_GPIO,
1802 #ifdef CONFIG_SND_SOC_RK610
1803 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1804 .type = "rk610_i2c_codec",
1807 .platform_data = &rk610_codec_pdata,
1814 int __sramdata g_pmic_type = 0;
1815 #ifdef CONFIG_I2C1_RK30
1816 #ifdef CONFIG_MFD_WM831X_I2C
1817 #include "board-rk30-sdk-wm8326.c"
1819 #ifdef CONFIG_MFD_TPS65910
1820 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1821 #include "board-rk30-sdk-tps65910.c"
1824 static struct i2c_board_info __initdata i2c1_info[] = {
1825 #if defined (CONFIG_MFD_WM831X_I2C)
1830 .irq = RK30_PIN6_PA4,
1831 .platform_data = &wm831x_platdata,
1834 #if defined (CONFIG_MFD_TPS65910)
1837 .addr = TPS65910_I2C_ID0,
1839 .irq = TPS65910_HOST_IRQ,
1840 .platform_data = &tps65910_data,
1846 void __sramfunc board_pmu_suspend(void)
1848 #if defined (CONFIG_MFD_WM831X_I2C)
1849 if(pmic_is_wm8326())
1850 board_pmu_wm8326_suspend();
1852 #if defined (CONFIG_MFD_TPS65910)
1853 if(pmic_is_tps65910())
1854 board_pmu_tps65910_suspend();
1858 void __sramfunc board_pmu_resume(void)
1860 #if defined (CONFIG_MFD_WM831X_I2C)
1861 if(pmic_is_wm8326())
1862 board_pmu_wm8326_resume();
1864 #if defined (CONFIG_MFD_TPS65910)
1865 if(pmic_is_tps65910())
1866 board_pmu_tps65910_resume();
1870 #ifdef CONFIG_I2C2_RK30
1871 static struct i2c_board_info __initdata i2c2_info[] = {
1872 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1874 .type = "Goodix-TS",
1877 .irq = RK30_PIN4_PC2,
1878 .platform_data = &goodix_info,
1881 #if defined (CONFIG_LS_CM3217)
1883 .type = "light_cm3217",
1886 .platform_data = &cm3217_info,
1890 #if defined(CONFIG_DP501)
1895 .platform_data = &dp501_platform_data,
1901 #ifdef CONFIG_I2C3_RK30
1902 static struct i2c_board_info __initdata i2c3_info[] = {
1906 #ifdef CONFIG_I2C4_RK30
1907 static struct i2c_board_info __initdata i2c4_info[] = {
1911 #ifdef CONFIG_I2C_GPIO_RK30
1912 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1913 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1914 static int rk30_i2c_io_init(void)
1916 //set iomux (gpio) here
1917 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1918 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1922 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1923 .sda_pin = I2C_SDA_PIN,
1924 .scl_pin = I2C_SCL_PIN,
1925 .udelay = 5, // clk = 500/udelay = 100Khz
1926 .timeout = 100,//msecs_to_jiffies(100),
1928 .io_init = rk30_i2c_io_init,
1930 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1934 static void __init rk30_i2c_register_board_info(void)
1936 #ifdef CONFIG_I2C0_RK30
1937 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1939 #ifdef CONFIG_I2C1_RK30
1940 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1942 #ifdef CONFIG_I2C2_RK30
1943 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1945 #ifdef CONFIG_I2C3_RK30
1946 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1948 #ifdef CONFIG_I2C4_RK30
1949 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1951 #ifdef CONFIG_I2C_GPIO_RK30
1952 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1957 #define POWER_ON_PIN RK30_PIN6_PB0 //power_hold
1958 static void rk30_pm_power_off(void)
1960 printk(KERN_ERR "rk30_pm_power_off start...\n");
1961 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1962 #if defined(CONFIG_MFD_WM831X)
1963 if(pmic_is_wm8326())
1965 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
1966 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1969 #if defined(CONFIG_MFD_TPS65910)
1970 if(pmic_is_tps65910())
1972 tps65910_device_shutdown();//tps65910 shutdown
1979 static void __init machine_rk30_board_init(void)
1982 gpio_request(POWER_ON_PIN, "poweronpin");
1983 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1985 pm_power_off = rk30_pm_power_off;
1987 rk30_i2c_register_board_info();
1988 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1989 platform_add_devices(devices, ARRAY_SIZE(devices));
1990 rk_platform_add_display_devices();
1991 board_usb_detect_init(RK30_PIN6_PA3);
1993 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1994 rk29sdk_wifi_bt_gpio_control_init();
1995 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1996 rk29sdk_wifi_combo_module_gpio_init();
1999 #if defined(CONFIG_MT6620)
2000 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2002 #if defined(CONFIG_MT5931_MT6622)
2003 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2005 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
2007 gpio_request(RK30_PIN4_PD7, "codec_en");
2008 rk30_mux_api_set(GPIO4D7_SMCDATA15_TRACEDATA15_NAME, GPIO4D_GPIO4D7);
2009 gpio_direction_output(RK30_PIN4_PD7, GPIO_HIGH);
2013 static void __init rk30_reserve(void)
2016 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2018 #ifdef CONFIG_FB_ROCKCHIP
2019 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2020 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2022 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2023 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2026 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2027 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2028 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2031 #ifdef CONFIG_VIDEO_RK29
2032 rk30_camera_request_reserve_mem();
2034 board_mem_reserved();
2038 * dvfs_cpu_logic_table: table for arm and logic dvfs
2039 * @frequency : arm frequency
2040 * @cpu_volt : arm voltage depend on frequency
2041 * @logic_volt : logic voltage arm requests depend on frequency
2042 * comments : min arm/logic voltage
2044 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
2045 {.frequency = 252 * 1000, .cpu_volt = 1075 * 1000, .logic_volt = 1125 * 1000},//0.975V/1.000V
2046 {.frequency = 504 * 1000, .cpu_volt = 1100 * 1000, .logic_volt = 1125 * 1000},//0.975V/1.000V
2047 {.frequency = 816 * 1000, .cpu_volt = 1125 * 1000, .logic_volt = 1150 * 1000},//1.000V/1.025V
2048 {.frequency = 1008 * 1000, .cpu_volt = 1125 * 1000, .logic_volt = 1150 * 1000},//1.025V/1.050V
2049 {.frequency = 1200 * 1000, .cpu_volt = 1175 * 1000, .logic_volt = 1200 * 1000},//1.100V/1.050V
2050 {.frequency = 1272 * 1000, .cpu_volt = 1225 * 1000, .logic_volt = 1200 * 1000},//1.150V/1.100V
2051 {.frequency = 1416 * 1000, .cpu_volt = 1300 * 1000, .logic_volt = 1200 * 1000},//1.225V/1.100V
2052 {.frequency = 1512 * 1000, .cpu_volt = 1350 * 1000, .logic_volt = 1250 * 1000},//1.300V/1.150V
2053 {.frequency = 1608 * 1000, .cpu_volt = 1425 * 1000, .logic_volt = 1300 * 1000},//1.325V/1.175V
2054 {.frequency = CPUFREQ_TABLE_END},
2057 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2058 {.frequency = 266 * 1000, .index = 1050 * 1000},
2059 {.frequency = 400 * 1000, .index = 1275 * 1000},
2060 {.frequency = CPUFREQ_TABLE_END},
2063 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2064 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1050 * 1000},
2065 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2066 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1125 * 1000},
2067 {.frequency = CPUFREQ_TABLE_END},
2070 #define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2071 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2072 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2074 void __init board_clock_init(void)
2076 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2077 dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2078 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2079 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2082 MACHINE_START(RK30, "RK30board")
2083 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2084 .fixup = rk30_fixup,
2085 .reserve = &rk30_reserve,
2086 .map_io = rk30_map_io,
2087 .init_irq = rk30_init_irq,
2088 .timer = &rk30_timer,
2089 .init_machine = machine_rk30_board_init,