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/power/smb347-charger.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/rfkill-rk.h>
46 #include <linux/sensor-dev.h>
47 #include <linux/regulator/rk29-pwm-regulator.h>
49 #include "../../../drivers/headset_observe/rk_headset.h"
50 #if defined(CONFIG_MFD_RK610)
51 #include <linux/mfd/rk610_core.h>
54 #if defined(CONFIG_RK_HDMI)
55 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
58 #if defined(CONFIG_SPIM_RK29)
59 #include "../../../drivers/spi/rk29_spim.h"
62 #if defined (CONFIG_BP_AUTO)
63 #include <linux/bp-auto.h>
65 #if defined(CONFIG_ANDROID_TIMED_GPIO)
66 #include "../../../drivers/staging/android/timed_gpio.h"
69 /* Android Parameter */
70 static int ap_mdm = 0;
71 module_param(ap_mdm, int, 0644);
72 static int ap_has_alsa = 0;
73 module_param(ap_has_alsa, int, 0644);
74 static int ap_data_only = 2;
75 module_param(ap_data_only, int, 0644);
76 static int ap_has_earphone = 0;
77 module_param(ap_has_earphone, int, 0644);
78 #if defined(CONFIG_MT6620)
79 #include <linux/gps.h>
82 #if defined(CONFIG_DP501) //for display port transmitter dp501
83 #include<linux/dp501.h>
86 #include "board-rk30-sdk-camera.c"
89 static struct rk29_keys_button key_button[] = {
92 .code = KEY_VOLUMEDOWN,
93 .gpio = RK30_PIN4_PC5,
94 .active_low = PRESS_LEV_LOW,
99 .gpio = RK30_PIN6_PA2,
100 .active_low = PRESS_LEV_LOW,
101 //.code_long_press = EV_ENCALL,
106 .code = KEY_VOLUMEUP,
108 .gpio = INVALID_GPIO,
109 .active_low = PRESS_LEV_LOW,
116 .gpio = INVALID_GPIO,
117 .active_low = PRESS_LEV_LOW,
123 .gpio = INVALID_GPIO,
124 .active_low = PRESS_LEV_LOW,
130 .gpio = INVALID_GPIO,
131 .active_low = PRESS_LEV_LOW,
137 .gpio = INVALID_GPIO,
138 .active_low = PRESS_LEV_LOW,
145 .gpio = INVALID_GPIO,
146 .active_low = PRESS_LEV_LOW,
152 .gpio = INVALID_GPIO,
153 .active_low = PRESS_LEV_LOW,
159 .gpio = INVALID_GPIO,
160 .active_low = PRESS_LEV_LOW,
166 .gpio = INVALID_GPIO,
167 .active_low = PRESS_LEV_LOW,
172 struct rk29_keys_platform_data rk29_keys_pdata = {
173 .buttons = key_button,
174 .nbuttons = ARRAY_SIZE(key_button),
175 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
178 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
180 static int rk_headset_io_init(int gpio, char *iomux_name, int iomux_mode)
183 ret = gpio_request(gpio, NULL);
187 rk30_mux_api_set(iomux_name, iomux_mode);
188 gpio_pull_updown(gpio, PullDisable);
189 gpio_direction_input(gpio);
194 struct rk_headset_pdata rk_headset_info = {
195 .Headset_gpio = RK30_PIN0_PC7,
196 .headset_in_type = HEADSET_IN_LOW,
198 .hook_key_code = KEY_MEDIA,
199 .headset_gpio_info = {GPIO0C7_TRACECTL_SMCADDR3_NAME, GPIO0C_GPIO0C7},
200 .headset_io_init = rk_headset_io_init,
203 struct platform_device rk_device_headset = {
204 .name = "rk_headsetdet",
207 .platform_data = &rk_headset_info,
211 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
212 #define TOUCH_RESET_PIN RK30_PIN4_PD0
213 #define TOUCH_PWR_PIN INVALID_GPIO
214 int goodix_init_platform_hw(void)
218 rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
219 rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
220 printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
222 if (TOUCH_PWR_PIN != INVALID_GPIO) {
223 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
225 gpio_free(TOUCH_PWR_PIN);
226 printk("goodix power error\n");
229 gpio_direction_output(TOUCH_PWR_PIN, 0);
230 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
234 if (TOUCH_RESET_PIN != INVALID_GPIO) {
235 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
237 gpio_free(TOUCH_RESET_PIN);
238 printk("goodix gpio_request error\n");
241 gpio_direction_output(TOUCH_RESET_PIN, 1);
243 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
245 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
251 struct goodix_platform_data goodix_info = {
253 .irq_pin = RK30_PIN4_PC2,
254 .rest_pin = TOUCH_RESET_PIN,
255 .init_platform_hw = goodix_init_platform_hw,
259 #if defined (CONFIG_TOUCHSCREEN_FT5506)
260 #define TOUCH_RESET_PIN RK30_PIN4_PD0
261 #define TOUCH_INT_PIN RK30_PIN4_PC2
262 int ft5506_init_platform_hw(void)
264 printk("ft5506_init_platform_hw\n");
265 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
266 gpio_free(TOUCH_RESET_PIN);
267 printk("ft5506_init_platform_hw gpio_request error\n");
271 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
272 gpio_free(TOUCH_INT_PIN);
273 printk("ift5506_init_platform_hw gpio_request error\n");
277 gpio_direction_output(TOUCH_RESET_PIN, 0);
278 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
280 gpio_direction_input(TOUCH_INT_PIN);
282 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
287 void ft5506_exit_platform_hw(void)
289 printk("ft5506_exit_platform_hw\n");
290 gpio_free(TOUCH_RESET_PIN);
291 gpio_free(TOUCH_INT_PIN);
295 int ft5506_platform_sleep(void)
297 printk("ft5506_platform_sleep\n");
298 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
301 int ft5506_platform_wakeup(void)
303 printk("ft5506_platform_wakeup\n");
304 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
309 struct ft5506_platform_data ft5506_info = {
311 .init_platform_hw= ft5506_init_platform_hw,
312 .exit_platform_hw= ft5506_exit_platform_hw,
313 .platform_sleep = ft5506_platform_sleep,
314 .platform_wakeup = ft5506_platform_wakeup,
318 static struct spi_board_info board_spi_devices[] = {
321 /***********************************************************
323 ************************************************************/
324 #ifdef CONFIG_BACKLIGHT_RK29_BL
326 #define PWM_MUX_NAME GPIO0D6_PWM2_NAME
327 #define PWM_MUX_MODE GPIO0D_PWM2
328 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
329 #define PWM_GPIO RK30_PIN0_PD6
330 #define PWM_EFFECT_VALUE 1
332 #define LCD_DISP_ON_PIN
334 #ifdef LCD_DISP_ON_PIN
335 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
336 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
338 #define BL_EN_PIN RK30_PIN6_PB3
339 #define BL_EN_VALUE GPIO_HIGH
341 static int rk29_backlight_io_init(void)
344 //rk30_mux_api_set(GPIO0D6_PWM2_NAME, GPIO0D_GPIO0D6);
345 //gpio_request(RK30_PIN0_PD6, NULL);
346 //gpio_direction_output(RK30_PIN0_PD6, GPIO_HIGH);
350 rk30_mux_api_set(GPIO0D6_PWM2_NAME, GPIO0D_PWM2);
351 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
352 #ifdef LCD_DISP_ON_PIN
353 // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
355 ret = gpio_request(BL_EN_PIN, NULL);
357 gpio_free(BL_EN_PIN);
360 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
361 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
366 static int rk29_backlight_io_deinit(void)
369 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
370 if (gpio_request(PWM_GPIO, NULL)) {
371 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
374 gpio_direction_output(PWM_GPIO, GPIO_LOW);
375 #ifdef LCD_DISP_ON_PIN
376 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
377 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
378 gpio_free(BL_EN_PIN);
383 static int rk29_backlight_pwm_suspend(void)
386 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
387 if (gpio_request(PWM_GPIO, NULL)) {
388 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
391 gpio_direction_output(PWM_GPIO, GPIO_LOW);
392 #ifdef LCD_DISP_ON_PIN
393 gpio_direction_output(BL_EN_PIN, 0);
394 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
399 static int rk29_backlight_pwm_resume(void)
402 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
403 #ifdef LCD_DISP_ON_PIN
405 gpio_direction_output(BL_EN_PIN, 1);
406 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
411 static struct rk29_bl_info rk29_bl_info = {
413 .bl_ref = PWM_EFFECT_VALUE,
414 .io_init = rk29_backlight_io_init,
415 .io_deinit = rk29_backlight_io_deinit,
416 .pwm_suspend = rk29_backlight_pwm_suspend,
417 .pwm_resume = rk29_backlight_pwm_resume,
420 .min_brightness = 150,
423 static struct platform_device rk29_device_backlight = {
424 .name = "rk29_backlight",
427 .platform_data = &rk29_bl_info,
433 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
435 #define DIFFERENTIAL 1
441 SPK_AMPLIFY_ZERO_POINT_FIVE_WATT=1,
442 SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
443 SPK_AMPLIFY_ZERO_POINT_EIGHT_WATT,
444 SPK_AMPLIFY_ONE_WATT,
454 static int rt3261_io_init(int gpio, char *iomux_name, int iomux_mode)
456 gpio_request(gpio,NULL);
457 rk30_mux_api_set(iomux_name, iomux_mode);
458 gpio_direction_output(gpio,1);
462 static struct rt3261_platform_data rt3261_info = {
463 .codec_en_gpio = RK30_PIN4_PD7,
464 .codec_en_gpio_info = {GPIO4D7_SMCDATA15_TRACEDATA15_NAME,GPIO4D_GPIO4D7},
465 .io_init = rt3261_io_init,
467 .modem_input_mode = DIFFERENTIAL,
468 .lout_to_modem_mode = DIFFERENTIAL,
469 .spk_amplify = SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
470 .playback_if1_data_control = LR_NORMAL,
471 .playback_if2_data_control = LR_NORMAL,
475 #if defined(CONFIG_BP_AUTO)
476 static int bp_io_init(void)
478 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
479 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
480 rk30_mux_api_set(GPIO4C6_SMCDATA6_TRACEDATA6_NAME, GPIO4C_GPIO4C6);
481 rk30_mux_api_set(GPIO4C4_SMCDATA4_TRACEDATA4_NAME, GPIO4C_GPIO4C4);
482 //rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
483 //rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
487 static int bp_io_deinit(void)
492 static int bp_id_get(void)
494 return ap_mdm; //internally 3G modem ID, defined in include\linux\Bp-auto.h
497 struct bp_platform_data bp_auto_info = {
498 .init_platform_hw = bp_io_init,
499 .exit_platform_hw = bp_io_deinit,
500 .get_bp_id = bp_id_get,
501 .bp_power = RK30_PIN6_PB2, // 3g_power
502 .bp_en = RK30_PIN2_PB6, // 3g_en
503 .bp_reset = RK30_PIN4_PD2,
504 .bp_usb_en = BP_UNKNOW_DATA, //W_disable
505 .bp_uart_en = BP_UNKNOW_DATA, //EINT9
506 .bp_wakeup_ap = RK30_PIN4_PC6, //
507 .ap_wakeup_bp = RK30_PIN4_PC4,
508 .ap_ready = BP_UNKNOW_DATA, //
509 .bp_ready = BP_UNKNOW_DATA,
510 .gpio_valid = 1, //if 1:gpio is define in bp_auto_info,if 0:is not use gpio in bp_auto_info
513 struct platform_device device_bp_auto = {
517 .platform_data = &bp_auto_info,
521 #ifdef CONFIG_RK29_SUPPORT_MODEM
523 #define RK30_MODEM_POWER RK30_PIN4_PD1
524 #define RK30_MODEM_POWER_IOMUX rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
526 static int rk30_modem_io_init(void)
528 printk("%s\n", __FUNCTION__);
529 RK30_MODEM_POWER_IOMUX;
534 static struct rk29_io_t rk30_modem_io = {
535 .io_addr = RK30_MODEM_POWER,
538 .io_init = rk30_modem_io_init,
541 static struct platform_device rk30_device_modem = {
542 .name = "rk30_modem",
545 .platform_data = &rk30_modem_io,
552 #if defined (CONFIG_GS_MMA8452)
553 #define MMA8452_INT_PIN RK30_PIN4_PC0
555 static int mma8452_init_platform_hw(void)
557 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
562 static struct sensor_platform_data mma8452_info = {
563 .type = SENSOR_TYPE_ACCEL,
566 .init_platform_hw = mma8452_init_platform_hw,
567 .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
570 #if defined (CONFIG_GS_LIS3DH)
571 #define LIS3DH_INT_PIN RK30_PIN4_PC0
573 static int lis3dh_init_platform_hw(void)
575 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
580 static struct sensor_platform_data lis3dh_info = {
581 .type = SENSOR_TYPE_ACCEL,
584 .init_platform_hw = lis3dh_init_platform_hw,
585 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
588 #if defined (CONFIG_GS_KXTIK)
589 #define KXTIK_INT_PIN RK30_PIN4_PC0
591 static int kxtik_init_platform_hw(void)
593 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
598 static struct sensor_platform_data kxtik_info = {
599 .type = SENSOR_TYPE_ACCEL,
602 .init_platform_hw = kxtik_init_platform_hw,
603 .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
607 #if defined(CONFIG_CHARGER_SMB347)
608 struct smb347_info smb347_info = {
609 .chg_en_pin = RK30_PIN4_PD5, // charge enable pin (smb347's c4 pin)
610 .chg_ctl_pin = RK30_PIN0_PC6, // charge control pin (smb347's d2 pin)
611 .chg_stat_pin = RK30_PIN6_PA6, // charge stat pin (smb347's f5 pin)
612 .chg_susp_pin = RK30_PIN4_PD1, // charge usb suspend pin (smb347's d3 pin)
613 .max_current = 1800, // dc and hc input current limit can set 300/500/700/900/1200/1500/1800/2000/2200/2500(ma)
614 .otg_power_form_smb = 0, // if otg 5v power form smb347 set 1 otherwise set 0
617 #if defined (CONFIG_COMPASS_AK8975)
618 static struct sensor_platform_data akm8975_info =
620 .type = SENSOR_TYPE_COMPASS,
653 #if defined(CONFIG_GYRO_L3G4200D)
655 #include <linux/l3g4200d.h>
656 #define L3G4200D_INT_PIN RK30_PIN4_PC3
658 static int l3g4200d_init_platform_hw(void)
660 rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
665 static struct sensor_platform_data l3g4200d_info = {
666 .type = SENSOR_TYPE_GYROSCOPE,
669 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
670 .init_platform_hw = l3g4200d_init_platform_hw,
671 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
678 #ifdef CONFIG_LS_CM3217
679 static struct sensor_platform_data cm3217_info = {
680 .type = SENSOR_TYPE_LIGHT,
682 .poll_delay_ms = 500,
687 #ifdef CONFIG_LS_CM3231
688 static struct sensor_platform_data cm3231_info = {
689 .type = SENSOR_TYPE_LIGHT,
691 .poll_delay_ms = 500,
695 #if defined(CONFIG_PS_AL3006)
696 static struct sensor_platform_data proximity_al3006_info = {
697 .type = SENSOR_TYPE_PROXIMITY,
699 .poll_delay_ms = 200,
703 #if defined(CONFIG_PS_STK3171)
704 static struct sensor_platform_data proximity_stk3171_info = {
705 .type = SENSOR_TYPE_PROXIMITY,
707 .poll_delay_ms = 200,
712 #if defined(CONFIG_LS_AL3006)
713 static struct sensor_platform_data light_al3006_info = {
714 .type = SENSOR_TYPE_LIGHT,
716 .poll_delay_ms = 200,
720 #if defined(CONFIG_LS_STK3171)
721 static struct sensor_platform_data light_stk3171_info = {
722 .type = SENSOR_TYPE_LIGHT,
724 .poll_delay_ms = 200,
727 #ifdef CONFIG_FB_ROCKCHIP
729 #define LCD_CS_MUX_NAME GPIO4C7_SMCDATA7_TRACEDATA7_NAME
730 #define LCD_CS_PIN RK30_PIN4_PC7
731 #define LCD_CS_VALUE GPIO_HIGH
733 #define LCD_STANDBY_MUX_NAME GPIO4D6_SMCDATA14_TRACEDATA14_NAME
734 #define LCD_STANDBY_PIN RK30_PIN4_PD6
735 #define LCD_STANDBY_VALUE GPIO_HIGH
738 #define LCD_EN_MUX_NAME GPIO4C7_SMCDATA7_TRACEDATA7_NAME
739 #define LCD_EN_PIN RK30_PIN6_PB4
740 #define LCD_EN_VALUE GPIO_LOW
742 #define HDMI11_MUX_NAME GPIO3A6_SDMMC0RSTNOUT_NAME
743 #define HDMI11_EN_PIN RK30_PIN3_PA6
744 #define HDMI11_EN_VALUE GPIO_HIGH
747 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
751 rk30_mux_api_set(LCD_STANDBY_MUX_NAME, GPIO4D_GPIO4D6);
752 ret = gpio_request(LCD_STANDBY_PIN, NULL);
755 gpio_free(LCD_STANDBY_PIN);
756 printk(KERN_ERR "request lcd cs pin fail!\n");
761 gpio_direction_output(LCD_STANDBY_PIN, LCD_STANDBY_VALUE);
764 rk30_mux_api_set(GPIO3A6_SDMMC0RSTNOUT_NAME, GPIO3A_GPIO3A6);
765 ret = gpio_request(HDMI11_EN_PIN, NULL);
768 gpio_free(HDMI11_EN_PIN);
769 printk(KERN_ERR "hdmi gpio fail!\n");
774 gpio_direction_output(HDMI11_EN_PIN, HDMI11_EN_VALUE);
777 rk30_mux_api_set(LCD_CS_MUX_NAME, GPIO4C_GPIO4C7);
778 ret = gpio_request(LCD_CS_PIN, NULL);
781 gpio_free(LCD_CS_PIN);
782 printk(KERN_ERR "request lcd cs pin fail!\n");
787 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
789 ret = gpio_request(LCD_EN_PIN, NULL);
792 gpio_free(LCD_EN_PIN);
793 printk(KERN_ERR "request lcd en pin fail!\n");
798 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
802 static int rk_fb_io_disable(void)
804 msleep(100); //Response Time (Rising + Falling)
805 gpio_set_value(HDMI11_EN_PIN, HDMI11_EN_VALUE? 0:1);
806 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE? 0:1);
807 gpio_set_value(LCD_STANDBY_PIN, LCD_CS_VALUE? 0:1);
808 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE? 0:1);
812 static int rk_fb_io_enable(void)
814 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
815 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
816 gpio_set_value(LCD_STANDBY_PIN, LCD_CS_VALUE);
817 gpio_set_value(HDMI11_EN_PIN, HDMI11_EN_VALUE);
818 msleep(150); //wait for power stable
823 #if defined(CONFIG_LCDC0_RK30)
824 struct rk29fb_info lcdc0_screen_info = {
825 .prop = PRMRY, //primary display device
826 .io_init = rk_fb_io_init,
827 .io_disable = rk_fb_io_disable,
828 .io_enable = rk_fb_io_enable,
829 .set_screen_info = set_lcd_info,
833 #if defined(CONFIG_LCDC1_RK30)
834 struct rk29fb_info lcdc1_screen_info = {
835 #if defined(CONFIG_RK_HDMI)
836 .prop = EXTEND, //extend display device
838 .set_screen_info = hdmi_init_lcdc,
843 static struct resource resource_fb[] = {
847 .end = 0,//RK30_FB0_MEM_SIZE - 1,
848 .flags = IORESOURCE_MEM,
851 .name = "ipp buf", //for rotate
853 .end = 0,//RK30_FB0_MEM_SIZE - 1,
854 .flags = IORESOURCE_MEM,
859 .end = 0,//RK30_FB0_MEM_SIZE - 1,
860 .flags = IORESOURCE_MEM,
864 static struct platform_device device_fb = {
867 .num_resources = ARRAY_SIZE(resource_fb),
868 .resource = resource_fb,
872 #if defined(CONFIG_LCDC0_RK30)
873 static struct resource resource_lcdc0[] = {
876 .start = RK30_LCDC0_PHYS,
877 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
878 .flags = IORESOURCE_MEM,
885 .flags = IORESOURCE_IRQ,
889 static struct platform_device device_lcdc0 = {
892 .num_resources = ARRAY_SIZE(resource_lcdc0),
893 .resource = resource_lcdc0,
895 .platform_data = &lcdc0_screen_info,
899 #if defined(CONFIG_LCDC1_RK30)
900 extern struct rk29fb_info lcdc1_screen_info;
901 static struct resource resource_lcdc1[] = {
904 .start = RK30_LCDC1_PHYS,
905 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
906 .flags = IORESOURCE_MEM,
912 .flags = IORESOURCE_IRQ,
916 static struct platform_device device_lcdc1 = {
919 .num_resources = ARRAY_SIZE(resource_lcdc1),
920 .resource = resource_lcdc1,
922 .platform_data = &lcdc1_screen_info,
927 #if defined(CONFIG_DP501)
928 #define DVDD33_EN_PIN RK30_PIN6_PB4
929 #define DVDD33_EN_VALUE GPIO_LOW
931 #define DVDD12_EN_PIN RK30_PIN4_PC7
932 #define DVDD12_EN_VALUE GPIO_HIGH
934 #define EDP_RST_PIN RK30_PIN2_PC4
935 static int rk_edp_power_ctl(void)
938 ret = gpio_request(DVDD33_EN_PIN, "dvdd33_en_pin");
941 gpio_free(DVDD33_EN_PIN);
942 printk(KERN_ERR "request dvdd33 en pin fail!\n");
947 gpio_direction_output(DVDD33_EN_PIN, DVDD33_EN_VALUE);
950 ret = gpio_request(DVDD12_EN_PIN, "dvdd18_en_pin");
953 gpio_free(DVDD12_EN_PIN);
954 printk(KERN_ERR "request dvdd18 en pin fail!\n");
959 gpio_direction_output(DVDD12_EN_PIN, DVDD12_EN_VALUE);
962 ret = gpio_request(EDP_RST_PIN, "edp_rst_pin");
965 gpio_free(EDP_RST_PIN);
966 printk(KERN_ERR "request rst pin fail!\n");
971 gpio_direction_output(EDP_RST_PIN, GPIO_LOW);
973 gpio_direction_output(EDP_RST_PIN, GPIO_HIGH);
978 static struct dp501_platform_data dp501_platform_data = {
979 .power_ctl = rk_edp_power_ctl,
980 .dvdd33_en_pin = DVDD33_EN_PIN,
981 .dvdd33_en_val = DVDD33_EN_VALUE,
982 .dvdd18_en_pin = DVDD12_EN_PIN,
983 .dvdd18_en_val = DVDD12_EN_VALUE,
984 .edp_rst_pin = EDP_RST_PIN,
988 #if defined(CONFIG_MFD_RK610)
989 #define RK610_RST_PIN_MUX_NAME GPIO0C6_TRACECLK_SMCADDR2_NAME
990 #define RK610_RST_PIN_MUX_MODE GPIO0C_GPIO0C6
991 #define RK610_RST_PIN RK30_PIN0_PC6
992 static int rk610_power_on_init(void)
995 if(RK610_RST_PIN != INVALID_GPIO)
997 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
998 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
1001 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
1005 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
1007 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
1009 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
1018 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
1019 .rk610_power_on_init = rk610_power_on_init,
1022 #ifdef CONFIG_SND_SOC_RK610
1023 static int rk610_codec_io_init(void)
1026 //Must not gpio_request
1030 static struct rk610_codec_platform_data rk610_codec_pdata = {
1031 .spk_ctl_io = RK30_PIN4_PC6,
1032 .io_init = rk610_codec_io_init,
1035 #ifdef CONFIG_ANDROID_TIMED_GPIO
1036 static struct timed_gpio timed_gpios[] = {
1039 .gpio = RK30_PIN0_PA4,
1040 .max_timeout = 1000,
1042 .adjust_time =20, //adjust for diff product
1046 static struct timed_gpio_platform_data rk29_vibrator_info = {
1048 .gpios = timed_gpios,
1051 static struct platform_device rk29_device_vibrator = {
1052 .name = "timed-gpio",
1055 .platform_data = &rk29_vibrator_info,
1061 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1062 static struct gpio_led rk29_leds[] = {
1064 .name = "button-backlight",
1065 .gpio = RK30_PIN4_PD7,
1066 .default_trigger = "timer",
1068 .retain_state_suspended = 0,
1069 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1073 static struct gpio_led_platform_data rk29_leds_pdata = {
1075 .num_leds = ARRAY_SIZE(rk29_leds),
1078 static struct platform_device rk29_device_gpio_leds = {
1079 .name = "leds-gpio",
1082 .platform_data = &rk29_leds_pdata,
1087 #ifdef CONFIG_RK_IRDA
1088 #define IRDA_IRQ_PIN RK30_PIN6_PA1
1090 static int irda_iomux_init(void)
1095 ret = gpio_request(IRDA_IRQ_PIN, NULL);
1097 gpio_free(IRDA_IRQ_PIN);
1098 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1100 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1101 gpio_direction_input(IRDA_IRQ_PIN);
1106 static int irda_iomux_deinit(void)
1108 gpio_free(IRDA_IRQ_PIN);
1112 static struct irda_info rk29_irda_info = {
1113 .intr_pin = IRDA_IRQ_PIN,
1114 .iomux_init = irda_iomux_init,
1115 .iomux_deinit = irda_iomux_deinit,
1116 //.irda_pwr_ctl = bu92747guw_power_ctl,
1119 static struct platform_device irda_device = {
1120 #ifdef CONFIG_RK_IRDA_NET
1123 .name = "bu92747_irda",
1127 .platform_data = &rk29_irda_info,
1133 #define ION_RESERVE_SIZE (80 * SZ_1M)
1134 static struct ion_platform_data rk30_ion_pdata = {
1138 .type = ION_HEAP_TYPE_CARVEOUT,
1139 .id = ION_NOR_HEAP_ID,
1141 .size = ION_RESERVE_SIZE,
1146 static struct platform_device device_ion = {
1147 .name = "ion-rockchip",
1150 .platform_data = &rk30_ion_pdata,
1155 /**************************************************************************************************
1156 * SDMMC devices, include the module of SD,MMC,and SDIO.noted by xbw at 2012-03-05
1157 **************************************************************************************************/
1158 #ifdef CONFIG_SDMMC_RK29
1159 #include "board-rk30-sdk-sdmmc.c"
1162 #ifdef CONFIG_SDMMC0_RK29
1163 static int rk29_sdmmc0_cfg_gpio(void)
1165 #ifdef CONFIG_SDMMC_RK29_OLD
1166 rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1167 rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1168 rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1169 rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1170 rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1171 rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1173 rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1175 rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1176 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1177 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1180 rk29_sdmmc_set_iomux(0, 0xFFFF);
1182 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
1183 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
1185 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
1188 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1189 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1190 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1198 #define CONFIG_SDMMC0_USE_DMA
1199 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1201 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1202 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1203 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1205 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1206 .io_init = rk29_sdmmc0_cfg_gpio,
1208 #if !defined(CONFIG_SDMMC_RK29_OLD)
1209 .set_iomux = rk29_sdmmc_set_iomux,
1212 .dma_name = "sd_mmc",
1213 #ifdef CONFIG_SDMMC0_USE_DMA
1219 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1220 .status = rk29sdk_wifi_mmc0_status,
1221 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1224 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1225 .power_en = RK29SDK_SD_CARD_PWR_EN,
1226 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1228 .power_en = INVALID_GPIO,
1229 .power_en_level = GPIO_LOW,
1231 .enable_sd_wakeup = 0,
1233 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1234 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1235 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1237 .write_prt = INVALID_GPIO,
1241 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1242 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1243 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1244 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1246 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1247 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1248 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1250 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1251 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1262 #endif // CONFIG_SDMMC0_RK29
1264 #ifdef CONFIG_SDMMC1_RK29
1265 #define CONFIG_SDMMC1_USE_DMA
1266 static int rk29_sdmmc1_cfg_gpio(void)
1268 #if defined(CONFIG_SDMMC_RK29_OLD)
1269 rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1270 rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1271 rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1272 rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1273 rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1274 rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1277 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1278 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1279 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1287 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1289 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1290 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1293 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1294 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1295 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1298 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1301 .io_init = rk29_sdmmc1_cfg_gpio,
1303 #if !defined(CONFIG_SDMMC_RK29_OLD)
1304 .set_iomux = rk29_sdmmc_set_iomux,
1308 #ifdef CONFIG_SDMMC1_USE_DMA
1314 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1315 .status = rk29sdk_wifi_status,
1316 .register_status_notify = rk29sdk_wifi_status_register,
1319 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1320 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1321 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1323 .write_prt = INVALID_GPIO,
1326 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1327 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1331 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1332 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1333 .io = RK29SDK_SD_CARD_DETECT_N,
1338 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1339 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1341 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1342 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1343 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1345 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1346 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1356 .enable_sd_wakeup = 0,
1358 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1360 /**************************************************************************************************
1361 * the end of setting for SDMMC devices
1362 **************************************************************************************************/
1365 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1366 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1367 .dc_det_pin = RK30_PIN6_PA5,//INVALID_GPIO,
1368 .batt_low_pin = RK30_PIN6_PA0,
1369 .charge_set_pin = INVALID_GPIO,
1370 .charge_ok_pin = INVALID_GPIO,
1371 .dc_det_level = GPIO_LOW,
1372 .charge_ok_level = GPIO_HIGH,
1373 .usb_det_pin = RK30_PIN6_PA3,
1374 .usb_det_level = GPIO_LOW,
1376 .charging_sleep = 0 ,
1377 .save_capacity = 1 ,
1379 .spport_usb_charging = 1,
1382 static struct platform_device rk30_device_adc_battery = {
1383 .name = "rk30-battery",
1386 .platform_data = &rk30_adc_battery_platdata,
1391 #if defined(CONFIG_BATTERY_RK30_ADC)
1392 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1393 .dc_det_pin = RK30_PIN6_PA5,
1394 .batt_low_pin = RK30_PIN6_PA0,
1395 .charge_set_pin = INVALID_GPIO,
1396 .charge_ok_pin = RK30_PIN6_PA6,
1397 .dc_det_level = GPIO_LOW,
1398 .charge_ok_level = GPIO_HIGH,
1401 static struct platform_device rk30_device_adc_battery = {
1402 .name = "rk30-battery",
1405 .platform_data = &rk30_adc_battery_platdata,
1410 #ifdef CONFIG_RK30_PWM_REGULATOR
1411 const static int pwm_voltage_map[] = {
1412 950000,975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1415 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1417 .supply = "vdd_core",
1421 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1425 .name = "PWM_DCDC1",
1427 .max_uV = 1800000, //0.6-1.8V
1429 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1431 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1432 .consumer_supplies = pwm_dcdc1_consumers,
1436 static struct pwm_platform_data pwm_regulator_info[1] = {
1439 .pwm_gpio = RK30_PIN0_PD7,
1440 .pwm_iomux_name = GPIO0D7_PWM3_NAME,
1441 .pwm_iomux_pwm = GPIO0D_PWM3,
1442 .pwm_iomux_gpio = GPIO0D_GPIO0D6,
1443 .pwm_voltage = 1100000,
1444 .suspend_voltage = 1050000,
1447 .coefficient = 455, //45.5%
1448 .pwm_voltage_map = pwm_voltage_map,
1449 .init_data = &pwm_regulator_init_dcdc[0],
1453 struct platform_device pwm_regulator_device[1] = {
1455 .name = "pwm-voltage-regulator",
1458 .platform_data = &pwm_regulator_info[0],
1464 #ifdef CONFIG_RK29_VMAC
1465 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1466 #include "board-rk30-sdk-vmac.c"
1469 #ifdef CONFIG_RFKILL_RK
1470 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1471 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1472 .type = RFKILL_TYPE_BLUETOOTH,
1474 .poweron_gpio = { // BT_REG_ON
1475 .io = RK30_PIN3_PC7,
1476 .enable = GPIO_HIGH,
1478 .name = GPIO3C7_SDMMC1WRITEPRT_NAME,
1479 .fgpio = GPIO3C_GPIO3C7,
1483 .reset_gpio = { // BT_RST
1484 .io = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1487 .name = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1488 .fgpio = GPIO3D_GPIO3D1,
1492 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1493 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1494 .enable = GPIO_HIGH,
1496 .name = GPIO3C6_SDMMC1DETECTN_NAME,
1497 .fgpio = GPIO3C_GPIO3C6,
1501 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1503 .io = RK30_PIN6_PA7, // set io to INVALID_GPIO for disable it
1504 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1511 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1512 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1515 .name = GPIO1A3_UART0RTSN_NAME,
1516 .fgpio = GPIO1A_GPIO1A3,
1517 .fmux = GPIO1A_UART0_RTS_N,
1522 static struct platform_device device_rfkill_rk = {
1523 .name = "rfkill_rk",
1526 .platform_data = &rfkill_rk_platdata,
1531 #if defined(CONFIG_MT5931_MT6622)
1532 static struct mt6622_platform_data mt6622_platdata = {
1533 .power_gpio = { // BT_REG_ON
1534 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1535 .enable = GPIO_HIGH,
1541 .reset_gpio = { // BT_RST
1542 .io = RK30_PIN3_PD1,
1550 .io = RK30_PIN6_PA7,
1551 .enable = GPIO_HIGH,
1558 static struct platform_device device_mt6622 = {
1562 .platform_data = &mt6622_platdata,
1567 static struct platform_device *devices[] __initdata = {
1571 #ifdef CONFIG_ANDROID_TIMED_GPIO
1572 &rk29_device_vibrator,
1574 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1575 &rk29_device_gpio_leds,
1577 #ifdef CONFIG_RK_IRDA
1580 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1581 &rk29sdk_wifi_device,
1584 #if defined(CONFIG_MT6620)
1588 #ifdef CONFIG_RK29_SUPPORT_MODEM
1591 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
1595 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1596 &rk30_device_adc_battery,
1598 #ifdef CONFIG_RFKILL_RK
1601 #ifdef CONFIG_MT5931_MT6622
1604 #if defined(CONFIG_BP_AUTO)
1610 static int rk_platform_add_display_devices(void)
1612 struct platform_device *fb = NULL; //fb
1613 struct platform_device *lcdc0 = NULL; //lcdc0
1614 struct platform_device *lcdc1 = NULL; //lcdc1
1615 struct platform_device *bl = NULL; //backlight
1616 #ifdef CONFIG_FB_ROCKCHIP
1620 #if defined(CONFIG_LCDC0_RK30)
1621 lcdc0 = &device_lcdc0,
1624 #if defined(CONFIG_LCDC1_RK30)
1625 lcdc1 = &device_lcdc1,
1628 #ifdef CONFIG_BACKLIGHT_RK29_BL
1629 bl = &rk29_device_backlight,
1631 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1637 #ifdef CONFIG_I2C0_RK30
1638 static struct i2c_board_info __initdata i2c0_info[] = {
1639 #if defined (CONFIG_GS_MMA8452)
1641 .type = "gs_mma8452",
1644 .irq = MMA8452_INT_PIN,
1645 .platform_data = &mma8452_info,
1648 #if defined (CONFIG_GS_LIS3DH)
1650 .type = "gs_lis3dh",
1651 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1653 .irq = LIS3DH_INT_PIN,
1654 .platform_data = &lis3dh_info,
1657 #if defined (CONFIG_GS_KXTIK)
1662 .irq = KXTIK_INT_PIN,
1663 .platform_data = &kxtik_info,
1666 #if defined (CONFIG_COMPASS_AK8975)
1671 .irq = RK30_PIN4_PC1,
1672 .platform_data = &akm8975_info,
1675 #if defined (CONFIG_GYRO_L3G4200D)
1677 .type = "l3g4200d_gryo",
1680 .irq = L3G4200D_INT_PIN,
1681 .platform_data = &l3g4200d_info,
1684 #if defined (CONFIG_LS_AL3006)
1686 .type = "light_al3006",
1687 .addr = 0x1c, //sel = 0; if sel =1, then addr = 0x1D
1689 .irq = RK30_PIN6_PA2,
1690 .platform_data = &light_al3006_info,
1693 #if defined (CONFIG_LS_STK3171)
1695 .type = "ls_stk3171",
1698 .irq = RK30_PIN6_PA2,
1699 .platform_data = &light_stk3171_info,
1704 #if defined (CONFIG_PS_AL3006)
1706 .type = "proximity_al3006",
1707 .addr = 0x1c, //sel = 0; if sel =1, then addr = 0x1D
1709 .irq = RK30_PIN6_PA2,
1710 .platform_data = &proximity_al3006_info,
1714 #if defined (CONFIG_PS_STK3171)
1716 .type = "ps_stk3171",
1719 .irq = RK30_PIN6_PA2,
1720 .platform_data = &proximity_stk3171_info,
1723 #if defined (CONFIG_SND_SOC_RK1000)
1725 .type = "rk1000_i2c_codec",
1730 .type = "rk1000_control",
1735 #if defined (CONFIG_SND_SOC_RT5631)
1742 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
1747 .platform_data = &rt3261_info,
1751 #ifdef CONFIG_MFD_RK610
1753 .type = "rk610_ctl",
1756 .platform_data = &rk610_ctl_pdata,
1758 #ifdef CONFIG_RK610_TVOUT
1760 .type = "rk610_tvout",
1765 #ifdef CONFIG_HDMI_RK610
1767 .type = "rk610_hdmi",
1770 .irq = INVALID_GPIO,
1773 #ifdef CONFIG_SND_SOC_RK610
1774 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1775 .type = "rk610_i2c_codec",
1778 .platform_data = &rk610_codec_pdata,
1785 int __sramdata g_pmic_type = 0;
1786 #ifdef CONFIG_I2C1_RK30
1787 #ifdef CONFIG_MFD_WM831X_I2C
1788 #include "board-rk30-sdk-wm8326.c"
1790 #ifdef CONFIG_MFD_TPS65910
1791 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1792 #include "board-rk30-sdk-tps65910.c"
1795 static struct i2c_board_info __initdata i2c1_info[] = {
1796 #if defined (CONFIG_MFD_WM831X_I2C)
1801 .irq = RK30_PIN6_PA4,
1802 .platform_data = &wm831x_platdata,
1805 #if defined (CONFIG_CHARGER_SMB347)
1810 .platform_data = &smb347_info,
1813 #if defined (CONFIG_MFD_TPS65910)
1816 .addr = TPS65910_I2C_ID0,
1818 .irq = TPS65910_HOST_IRQ,
1819 .platform_data = &tps65910_data,
1825 void __sramfunc board_pmu_suspend(void)
1827 #if defined (CONFIG_MFD_WM831X_I2C)
1828 if(pmic_is_wm8326())
1829 board_pmu_wm8326_suspend();
1831 #if defined (CONFIG_MFD_TPS65910)
1832 if(pmic_is_tps65910())
1833 board_pmu_tps65910_suspend();
1837 void __sramfunc board_pmu_resume(void)
1839 #if defined (CONFIG_MFD_WM831X_I2C)
1840 if(pmic_is_wm8326())
1841 board_pmu_wm8326_resume();
1843 #if defined (CONFIG_MFD_TPS65910)
1844 if(pmic_is_tps65910())
1845 board_pmu_tps65910_resume();
1849 #ifdef CONFIG_I2C2_RK30
1850 static struct i2c_board_info __initdata i2c2_info[] = {
1851 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1853 .type = "Goodix-TS",
1856 .irq = RK30_PIN4_PC2,
1857 .platform_data = &goodix_info,
1860 #if defined (CONFIG_LS_CM3217)
1862 .type = "light_cm3217",
1865 .platform_data = &cm3217_info,
1868 #if defined (CONFIG_LS_CM3231)
1873 .platform_data = &cm3231_info,
1877 #if defined(CONFIG_DP501)
1882 .platform_data = &dp501_platform_data,
1885 #if defined (CONFIG_TOUCHSCREEN_FT5506)
1887 .type = "laibao_touch",
1890 .irq = RK30_PIN4_PC2,
1891 .platform_data = &ft5506_info,
1897 #ifdef CONFIG_I2C3_RK30
1898 static struct i2c_board_info __initdata i2c3_info[] = {
1902 #ifdef CONFIG_I2C4_RK30
1903 static struct i2c_board_info __initdata i2c4_info[] = {
1907 #ifdef CONFIG_I2C_GPIO_RK30
1908 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1909 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1910 static int rk30_i2c_io_init(void)
1912 //set iomux (gpio) here
1913 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1914 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1918 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1919 .sda_pin = I2C_SDA_PIN,
1920 .scl_pin = I2C_SCL_PIN,
1921 .udelay = 5, // clk = 500/udelay = 100Khz
1922 .timeout = 100,//msecs_to_jiffies(100),
1924 .io_init = rk30_i2c_io_init,
1926 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1930 static void __init rk30_i2c_register_board_info(void)
1932 #ifdef CONFIG_I2C0_RK30
1933 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1935 #ifdef CONFIG_I2C1_RK30
1936 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1938 #ifdef CONFIG_I2C2_RK30
1939 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1941 #ifdef CONFIG_I2C3_RK30
1942 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1944 #ifdef CONFIG_I2C4_RK30
1945 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1947 #ifdef CONFIG_I2C_GPIO_RK30
1948 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1953 #define POWER_ON_PIN RK30_PIN6_PB0 //power_hold
1954 static void rk30_pm_power_off(void)
1956 printk(KERN_ERR "rk30_pm_power_off start...\n");
1957 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1958 #if defined(CONFIG_MFD_WM831X)
1959 if(pmic_is_wm8326())
1961 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
1962 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1965 #if defined(CONFIG_MFD_TPS65910)
1966 if(pmic_is_tps65910())
1968 tps65910_device_shutdown();//tps65910 shutdown
1975 static void __init machine_rk30_board_init(void)
1978 gpio_request(POWER_ON_PIN, "poweronpin");
1979 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1981 pm_power_off = rk30_pm_power_off;
1983 rk30_i2c_register_board_info();
1984 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1985 platform_add_devices(devices, ARRAY_SIZE(devices));
1986 rk_platform_add_display_devices();
1987 board_usb_detect_init(RK30_PIN6_PA3);
1989 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1990 rk29sdk_wifi_bt_gpio_control_init();
1991 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1992 rk29sdk_wifi_combo_module_gpio_init();
1995 #if defined(CONFIG_MT6620)
1996 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
1998 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
2000 gpio_request(RK30_PIN4_PD7, "codec_en");
2001 rk30_mux_api_set(GPIO4D7_SMCDATA15_TRACEDATA15_NAME, GPIO4D_GPIO4D7);
2002 gpio_direction_output(RK30_PIN4_PD7, GPIO_HIGH);
2006 static void __init rk30_reserve(void)
2009 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2011 #ifdef CONFIG_FB_ROCKCHIP
2012 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2013 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2015 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2016 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2019 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2020 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2021 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2024 #ifdef CONFIG_VIDEO_RK29
2025 rk30_camera_request_reserve_mem();
2027 board_mem_reserved();
2031 * dvfs_cpu_logic_table: table for arm and logic dvfs
2032 * @frequency : arm frequency
2033 * @cpu_volt : arm voltage depend on frequency
2034 * @logic_volt : logic voltage arm requests depend on frequency
2035 * comments : min arm/logic voltage
2037 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
2038 {.frequency = 252 * 1000, .cpu_volt = 1075 * 1000, .logic_volt = 1125 * 1000},//0.975V/1.000V
2039 {.frequency = 504 * 1000, .cpu_volt = 1100 * 1000, .logic_volt = 1125 * 1000},//0.975V/1.000V
2040 {.frequency = 816 * 1000, .cpu_volt = 1125 * 1000, .logic_volt = 1150 * 1000},//1.000V/1.025V
2041 {.frequency = 1008 * 1000, .cpu_volt = 1125 * 1000, .logic_volt = 1150 * 1000},//1.025V/1.050V
2042 {.frequency = 1200 * 1000, .cpu_volt = 1175 * 1000, .logic_volt = 1200 * 1000},//1.100V/1.050V
2043 {.frequency = 1272 * 1000, .cpu_volt = 1225 * 1000, .logic_volt = 1200 * 1000},//1.150V/1.100V
2044 {.frequency = 1416 * 1000, .cpu_volt = 1300 * 1000, .logic_volt = 1200 * 1000},//1.225V/1.100V
2045 {.frequency = 1512 * 1000, .cpu_volt = 1350 * 1000, .logic_volt = 1250 * 1000},//1.300V/1.150V
2046 {.frequency = 1608 * 1000, .cpu_volt = 1425 * 1000, .logic_volt = 1300 * 1000},//1.325V/1.175V
2047 {.frequency = CPUFREQ_TABLE_END},
2050 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2051 {.frequency = 266 * 1000, .index = 1050 * 1000},
2052 {.frequency = 400 * 1000, .index = 1275 * 1000},
2053 {.frequency = CPUFREQ_TABLE_END},
2056 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2057 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1050 * 1000},
2058 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2059 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1125 * 1000},
2060 {.frequency = CPUFREQ_TABLE_END},
2063 #define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2064 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2065 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2067 void __init board_clock_init(void)
2069 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2070 dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2071 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2072 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2075 MACHINE_START(RK30, "RK30board")
2076 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2077 .fixup = rk30_fixup,
2078 .reserve = &rk30_reserve,
2079 .map_io = rk30_map_io,
2080 .init_irq = rk30_init_irq,
2081 .timer = &rk30_timer,
2082 .init_machine = machine_rk30_board_init,