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, char *iomux_name, int iomux_mode)
194 ret = gpio_request(gpio, NULL);
198 rk30_mux_api_set(iomux_name, iomux_mode);
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_gpio_info = {GPIO0C7_TRACECTL_SMCADDR3_NAME, GPIO0C_GPIO0C7},
211 .headset_io_init = rk_headset_io_init,
214 struct platform_device rk_device_headset = {
215 .name = "rk_headsetdet",
218 .platform_data = &rk_headset_info,
222 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
223 #define TOUCH_RESET_PIN RK30_PIN4_PD0
224 #define TOUCH_PWR_PIN INVALID_GPIO
225 int goodix_init_platform_hw(void)
229 rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
230 rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
231 printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
233 if (TOUCH_PWR_PIN != INVALID_GPIO) {
234 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
236 gpio_free(TOUCH_PWR_PIN);
237 printk("goodix power error\n");
240 gpio_direction_output(TOUCH_PWR_PIN, 0);
241 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
245 if (TOUCH_RESET_PIN != INVALID_GPIO) {
246 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
248 gpio_free(TOUCH_RESET_PIN);
249 printk("goodix gpio_request error\n");
252 gpio_direction_output(TOUCH_RESET_PIN, 1);
254 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
256 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
262 struct goodix_platform_data goodix_info = {
264 .irq_pin = RK30_PIN4_PC2,
265 .rest_pin = TOUCH_RESET_PIN,
266 .init_platform_hw = goodix_init_platform_hw,
270 static struct spi_board_info board_spi_devices[] = {
273 /***********************************************************
275 ************************************************************/
276 #ifdef CONFIG_BACKLIGHT_RK29_BL
278 #define PWM_MUX_NAME GPIO0A3_PWM0_NAME
279 #define PWM_MUX_MODE GPIO0A_PWM0
280 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
281 #define PWM_GPIO RK30_PIN0_PA3
282 #define PWM_EFFECT_VALUE 1
284 #define LCD_DISP_ON_PIN
286 #ifdef LCD_DISP_ON_PIN
287 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
288 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
290 #define BL_EN_PIN RK30_PIN6_PB3
291 #define BL_EN_VALUE GPIO_HIGH
293 static int rk29_backlight_io_init(void)
296 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
297 #ifdef LCD_DISP_ON_PIN
298 // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
300 ret = gpio_request(BL_EN_PIN, NULL);
302 gpio_free(BL_EN_PIN);
305 gpio_direction_output(BL_EN_PIN, 0);
306 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
311 static int rk29_backlight_io_deinit(void)
314 #ifdef LCD_DISP_ON_PIN
315 gpio_free(BL_EN_PIN);
317 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
321 static int rk29_backlight_pwm_suspend(void)
324 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
325 if (gpio_request(PWM_GPIO, NULL)) {
326 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
329 gpio_direction_input(PWM_GPIO);
330 #ifdef LCD_DISP_ON_PIN
331 gpio_direction_output(BL_EN_PIN, 0);
332 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
337 static int rk29_backlight_pwm_resume(void)
340 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
341 #ifdef LCD_DISP_ON_PIN
343 gpio_direction_output(BL_EN_PIN, 1);
344 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
349 static struct rk29_bl_info rk29_bl_info = {
351 .bl_ref = PWM_EFFECT_VALUE,
352 .io_init = rk29_backlight_io_init,
353 .io_deinit = rk29_backlight_io_deinit,
354 .pwm_suspend = rk29_backlight_pwm_suspend,
355 .pwm_resume = rk29_backlight_pwm_resume,
358 static struct platform_device rk29_device_backlight = {
359 .name = "rk29_backlight",
362 .platform_data = &rk29_bl_info,
368 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
370 #define DIFFERENTIAL 1
376 SPK_AMPLIFY_ZERO_POINT_FIVE_WATT=1,
377 SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
378 SPK_AMPLIFY_ZERO_POINT_EIGHT_WATT,
379 SPK_AMPLIFY_ONE_WATT,
389 static int rt3261_io_init(int gpio, char *iomux_name, int iomux_mode)
391 gpio_request(gpio,NULL);
392 rk30_mux_api_set(iomux_name, iomux_mode);
393 gpio_direction_output(gpio,1);
397 static struct rt3261_platform_data rt3261_info = {
398 .codec_en_gpio = RK30_PIN4_PD7,
399 .codec_en_gpio_info = {GPIO4D7_SMCDATA15_TRACEDATA15_NAME,GPIO4D_GPIO4D7},
400 .io_init = rt3261_io_init,
402 .modem_input_mode = DIFFERENTIAL,
403 .lout_to_modem_mode = DIFFERENTIAL,
404 .spk_amplify = SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
405 .playback_if1_data_control = LR_NORMAL,
406 .playback_if2_data_control = LR_NORMAL,
410 #if defined(CONFIG_BP_AUTO)
411 static int bp_io_init(void)
413 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
414 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
415 rk30_mux_api_set(GPIO4C6_SMCDATA6_TRACEDATA6_NAME, GPIO4C_GPIO4C6);
416 rk30_mux_api_set(GPIO4C4_SMCDATA4_TRACEDATA4_NAME, GPIO4C_GPIO4C4);
417 //rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
418 //rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
422 static int bp_io_deinit(void)
427 static int bp_id_get(void)
429 return ap_mdm; //internally 3G modem ID, defined in include\linux\Bp-auto.h
432 struct bp_platform_data bp_auto_info = {
433 .init_platform_hw = bp_io_init,
434 .exit_platform_hw = bp_io_deinit,
435 .get_bp_id = bp_id_get,
436 .bp_power = RK30_PIN6_PB2, // 3g_power
437 .bp_en = RK30_PIN2_PB6, // 3g_en
438 .bp_reset = RK30_PIN4_PD2,
439 .bp_usb_en = BP_UNKNOW_DATA, //W_disable
440 .bp_uart_en = BP_UNKNOW_DATA, //EINT9
441 .bp_wakeup_ap = RK30_PIN4_PC6, //
442 .ap_wakeup_bp = RK30_PIN4_PC4,
443 .ap_ready = BP_UNKNOW_DATA, //
444 .bp_ready = BP_UNKNOW_DATA,
445 .gpio_valid = 1, //if 1:gpio is define in bp_auto_info,if 0:is not use gpio in bp_auto_info
448 struct platform_device device_bp_auto = {
452 .platform_data = &bp_auto_info,
456 #ifdef CONFIG_RK29_SUPPORT_MODEM
458 #define RK30_MODEM_POWER RK30_PIN4_PD1
459 #define RK30_MODEM_POWER_IOMUX rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
461 static int rk30_modem_io_init(void)
463 printk("%s\n", __FUNCTION__);
464 RK30_MODEM_POWER_IOMUX;
469 static struct rk29_io_t rk30_modem_io = {
470 .io_addr = RK30_MODEM_POWER,
473 .io_init = rk30_modem_io_init,
476 static struct platform_device rk30_device_modem = {
477 .name = "rk30_modem",
480 .platform_data = &rk30_modem_io,
484 #if defined(CONFIG_MU509)
485 static int mu509_io_init(void)
488 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
489 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
490 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
491 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
495 static int mu509_io_deinit(void)
501 struct rk29_mu509_data rk29_mu509_info = {
502 .io_init = mu509_io_init,
503 .io_deinit = mu509_io_deinit,
504 .modem_power_en = RK30_PIN6_PB2,//RK30_PIN4_PD1,
505 .bp_power = RK30_PIN2_PB6,//RK30_PIN4_PD1,
506 .bp_reset = RK30_PIN4_PD2,
507 .ap_wakeup_bp = RK30_PIN2_PB7,
508 .bp_wakeup_ap = RK30_PIN6_PA0,
510 struct platform_device rk29_device_mu509 = {
514 .platform_data = &rk29_mu509_info,
518 #if defined(CONFIG_MW100)
519 static int mw100_io_init(void)
521 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
522 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
523 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
524 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
528 static int mw100_io_deinit(void)
534 struct rk29_mw100_data rk29_mw100_info = {
535 .io_init = mw100_io_init,
536 .io_deinit = mw100_io_deinit,
537 .modem_power_en = RK30_PIN6_PB2,
538 .bp_power = RK30_PIN2_PB6,
539 .bp_reset = RK30_PIN4_PD2,
540 .ap_wakeup_bp = RK30_PIN2_PB7,
541 .bp_wakeup_ap = RK30_PIN6_PA0,
543 struct platform_device rk29_device_mw100 = {
547 .platform_data = &rk29_mw100_info,
551 #if defined(CONFIG_MT6229)
552 static int mt6229_io_init(void)
554 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
555 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
556 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
557 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
558 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
559 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
565 static int mt6229_io_deinit(void)
571 struct rk29_mt6229_data rk29_mt6229_info = {
572 .io_init = mt6229_io_init,
573 .io_deinit = mt6229_io_deinit,
574 .modem_power_en = RK30_PIN6_PB2,
575 .bp_power = RK30_PIN2_PB6,
576 .modem_usb_en = RK30_PIN2_PC0,
577 .modem_uart_en = RK30_PIN2_PC1,
578 .bp_wakeup_ap = RK30_PIN6_PA1,
579 .ap_ready = RK30_PIN2_PB7,
582 struct platform_device rk29_device_mt6229 = {
586 .platform_data = &rk29_mt6229_info,
590 #if defined(CONFIG_SEW868)
591 static int sew868_io_init(void)
593 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
594 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
595 rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4);
598 static int sew868_io_deinit(void)
602 struct rk30_sew868_data rk30_sew868_info = {
603 .io_init = sew868_io_init,
604 .io_deinit = sew868_io_deinit,
605 .bp_power = RK30_PIN6_PB2,
606 .bp_power_active_low = 1,
607 .bp_sys = RK30_PIN2_PB6,
608 .bp_reset = RK30_PIN4_PD2,
609 .bp_reset_active_low = 1,
610 .bp_wakeup_ap = RK30_PIN4_PD4,
611 .ap_wakeup_bp = NULL,
614 struct platform_device rk30_device_sew868 = {
618 .platform_data = &rk30_sew868_info,
624 #if defined (CONFIG_GS_MMA8452)
625 #define MMA8452_INT_PIN RK30_PIN4_PC0
627 static int mma8452_init_platform_hw(void)
629 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
634 static struct sensor_platform_data mma8452_info = {
635 .type = SENSOR_TYPE_ACCEL,
638 .init_platform_hw = mma8452_init_platform_hw,
639 .orientation = {-1, 0, 0, 0,-1, 0, 0, 0, 1},
642 #if defined (CONFIG_GS_LIS3DH)
643 #define LIS3DH_INT_PIN RK30_PIN4_PC0
645 static int lis3dh_init_platform_hw(void)
647 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
652 static struct sensor_platform_data lis3dh_info = {
653 .type = SENSOR_TYPE_ACCEL,
656 .init_platform_hw = lis3dh_init_platform_hw,
657 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
660 #if defined (CONFIG_GS_KXTIK)
661 #define KXTIK_INT_PIN RK30_PIN4_PC0
663 static int kxtik_init_platform_hw(void)
665 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
670 static struct sensor_platform_data kxtik_info = {
671 .type = SENSOR_TYPE_ACCEL,
674 .init_platform_hw = kxtik_init_platform_hw,
675 .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
679 #if defined (CONFIG_COMPASS_AK8975)
680 static struct sensor_platform_data akm8975_info =
682 .type = SENSOR_TYPE_COMPASS,
715 #if defined(CONFIG_GYRO_L3G4200D)
717 #include <linux/l3g4200d.h>
718 #define L3G4200D_INT_PIN RK30_PIN4_PC3
720 static int l3g4200d_init_platform_hw(void)
722 rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
727 static struct sensor_platform_data l3g4200d_info = {
728 .type = SENSOR_TYPE_GYROSCOPE,
731 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
732 .init_platform_hw = l3g4200d_init_platform_hw,
733 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
740 #ifdef CONFIG_LS_CM3217
741 static struct sensor_platform_data cm3217_info = {
742 .type = SENSOR_TYPE_LIGHT,
744 .poll_delay_ms = 500,
749 #if defined(CONFIG_PS_AL3006)
750 static struct sensor_platform_data proximity_al3006_info = {
751 .type = SENSOR_TYPE_PROXIMITY,
753 .poll_delay_ms = 200,
757 #if defined(CONFIG_PS_STK3171)
758 static struct sensor_platform_data proximity_stk3171_info = {
759 .type = SENSOR_TYPE_PROXIMITY,
761 .poll_delay_ms = 200,
766 #if defined(CONFIG_LS_AL3006)
767 static struct sensor_platform_data light_al3006_info = {
768 .type = SENSOR_TYPE_LIGHT,
770 .poll_delay_ms = 200,
774 #if defined(CONFIG_LS_STK3171)
775 static struct sensor_platform_data light_stk3171_info = {
776 .type = SENSOR_TYPE_LIGHT,
778 .poll_delay_ms = 200,
781 #ifdef CONFIG_FB_ROCKCHIP
783 #define LCD_CS_PIN RK30_PIN4_PC7
784 #define LCD_CS_VALUE GPIO_HIGH
786 #define LCD_EN_PIN RK30_PIN6_PB4
787 #define LCD_EN_VALUE GPIO_LOW
789 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
793 if(LCD_CS_PIN != INVALID_GPIO)
795 ret = gpio_request(LCD_CS_PIN, NULL);
798 gpio_free(LCD_CS_PIN);
799 printk(KERN_ERR "request lcd cs pin fail!\n");
804 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
808 if(LCD_EN_PIN != INVALID_GPIO)
810 ret = gpio_request(LCD_EN_PIN, NULL);
813 gpio_free(LCD_EN_PIN);
814 printk(KERN_ERR "request lcd en pin fail!\n");
819 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
824 static int rk_fb_io_disable(void)
826 if(LCD_CS_PIN != INVALID_GPIO)
828 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
831 if(LCD_EN_PIN != INVALID_GPIO)
833 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
837 static int rk_fb_io_enable(void)
839 if(LCD_CS_PIN != INVALID_GPIO)
841 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
843 if(LCD_EN_PIN != INVALID_GPIO)
845 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
850 #if defined(CONFIG_LCDC0_RK30)
851 struct rk29fb_info lcdc0_screen_info = {
852 .prop = PRMRY, //primary display device
853 .io_init = rk_fb_io_init,
854 .io_disable = rk_fb_io_disable,
855 .io_enable = rk_fb_io_enable,
856 .set_screen_info = set_lcd_info,
860 #if defined(CONFIG_LCDC1_RK30)
861 struct rk29fb_info lcdc1_screen_info = {
862 #if defined(CONFIG_RK_HDMI)
863 .prop = EXTEND, //extend display device
865 .set_screen_info = hdmi_init_lcdc,
870 static struct resource resource_fb[] = {
874 .end = 0,//RK30_FB0_MEM_SIZE - 1,
875 .flags = IORESOURCE_MEM,
878 .name = "ipp buf", //for rotate
880 .end = 0,//RK30_FB0_MEM_SIZE - 1,
881 .flags = IORESOURCE_MEM,
886 .end = 0,//RK30_FB0_MEM_SIZE - 1,
887 .flags = IORESOURCE_MEM,
891 static struct platform_device device_fb = {
894 .num_resources = ARRAY_SIZE(resource_fb),
895 .resource = resource_fb,
899 #if defined(CONFIG_LCDC0_RK30)
900 static struct resource resource_lcdc0[] = {
903 .start = RK30_LCDC0_PHYS,
904 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
905 .flags = IORESOURCE_MEM,
912 .flags = IORESOURCE_IRQ,
916 static struct platform_device device_lcdc0 = {
919 .num_resources = ARRAY_SIZE(resource_lcdc0),
920 .resource = resource_lcdc0,
922 .platform_data = &lcdc0_screen_info,
926 #if defined(CONFIG_LCDC1_RK30)
927 extern struct rk29fb_info lcdc1_screen_info;
928 static struct resource resource_lcdc1[] = {
931 .start = RK30_LCDC1_PHYS,
932 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
933 .flags = IORESOURCE_MEM,
939 .flags = IORESOURCE_IRQ,
943 static struct platform_device device_lcdc1 = {
946 .num_resources = ARRAY_SIZE(resource_lcdc1),
947 .resource = resource_lcdc1,
949 .platform_data = &lcdc1_screen_info,
954 #if defined(CONFIG_DP501)
955 #define DVDD33_EN_PIN RK30_PIN6_PB4
956 #define DVDD33_EN_VALUE GPIO_LOW
958 #define DVDD12_EN_PIN RK30_PIN4_PC7
959 #define DVDD12_EN_VALUE GPIO_HIGH
961 #define EDP_RST_PIN RK30_PIN2_PC4
962 static int rk_edp_power_ctl(void)
965 ret = gpio_request(DVDD33_EN_PIN, "dvdd33_en_pin");
968 gpio_free(DVDD33_EN_PIN);
969 printk(KERN_ERR "request dvdd33 en pin fail!\n");
974 gpio_direction_output(DVDD33_EN_PIN, DVDD33_EN_VALUE);
977 ret = gpio_request(DVDD12_EN_PIN, "dvdd18_en_pin");
980 gpio_free(DVDD12_EN_PIN);
981 printk(KERN_ERR "request dvdd18 en pin fail!\n");
986 gpio_direction_output(DVDD12_EN_PIN, DVDD12_EN_VALUE);
989 ret = gpio_request(EDP_RST_PIN, "edp_rst_pin");
992 gpio_free(EDP_RST_PIN);
993 printk(KERN_ERR "request rst pin fail!\n");
998 gpio_direction_output(EDP_RST_PIN, GPIO_LOW);
1000 gpio_direction_output(EDP_RST_PIN, GPIO_HIGH);
1005 static struct dp501_platform_data dp501_platform_data = {
1006 .power_ctl = rk_edp_power_ctl,
1007 .dvdd33_en_pin = DVDD33_EN_PIN,
1008 .dvdd33_en_val = DVDD33_EN_VALUE,
1009 .dvdd18_en_pin = DVDD12_EN_PIN,
1010 .dvdd18_en_val = DVDD12_EN_VALUE,
1011 .edp_rst_pin = EDP_RST_PIN,
1015 #if defined(CONFIG_MFD_RK610)
1016 #define RK610_RST_PIN_MUX_NAME GPIO0C6_TRACECLK_SMCADDR2_NAME
1017 #define RK610_RST_PIN_MUX_MODE GPIO0C_GPIO0C6
1018 #define RK610_RST_PIN RK30_PIN0_PC6
1019 static int rk610_power_on_init(void)
1022 if(RK610_RST_PIN != INVALID_GPIO)
1024 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
1025 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
1028 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
1032 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
1034 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
1036 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
1045 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
1046 .rk610_power_on_init = rk610_power_on_init,
1049 #ifdef CONFIG_SND_SOC_RK610
1050 static int rk610_codec_io_init(void)
1053 //Must not gpio_request
1057 static struct rk610_codec_platform_data rk610_codec_pdata = {
1058 .spk_ctl_io = RK30_PIN4_PC6,
1059 .io_init = rk610_codec_io_init,
1062 #ifdef CONFIG_ANDROID_TIMED_GPIO
1063 static struct timed_gpio timed_gpios[] = {
1066 .gpio = RK30_PIN0_PA4,
1067 .max_timeout = 1000,
1069 .adjust_time =20, //adjust for diff product
1073 static struct timed_gpio_platform_data rk29_vibrator_info = {
1075 .gpios = timed_gpios,
1078 static struct platform_device rk29_device_vibrator = {
1079 .name = "timed-gpio",
1082 .platform_data = &rk29_vibrator_info,
1088 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1089 static struct gpio_led rk29_leds[] = {
1091 .name = "button-backlight",
1092 .gpio = RK30_PIN4_PD7,
1093 .default_trigger = "timer",
1095 .retain_state_suspended = 0,
1096 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1100 static struct gpio_led_platform_data rk29_leds_pdata = {
1102 .num_leds = ARRAY_SIZE(rk29_leds),
1105 static struct platform_device rk29_device_gpio_leds = {
1106 .name = "leds-gpio",
1109 .platform_data = &rk29_leds_pdata,
1114 #ifdef CONFIG_RK_IRDA
1115 #define IRDA_IRQ_PIN RK30_PIN6_PA1
1117 static int irda_iomux_init(void)
1122 ret = gpio_request(IRDA_IRQ_PIN, NULL);
1124 gpio_free(IRDA_IRQ_PIN);
1125 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1127 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1128 gpio_direction_input(IRDA_IRQ_PIN);
1133 static int irda_iomux_deinit(void)
1135 gpio_free(IRDA_IRQ_PIN);
1139 static struct irda_info rk29_irda_info = {
1140 .intr_pin = IRDA_IRQ_PIN,
1141 .iomux_init = irda_iomux_init,
1142 .iomux_deinit = irda_iomux_deinit,
1143 //.irda_pwr_ctl = bu92747guw_power_ctl,
1146 static struct platform_device irda_device = {
1147 #ifdef CONFIG_RK_IRDA_NET
1150 .name = "bu92747_irda",
1154 .platform_data = &rk29_irda_info,
1160 #define ION_RESERVE_SIZE (80 * SZ_1M)
1161 static struct ion_platform_data rk30_ion_pdata = {
1165 .type = ION_HEAP_TYPE_CARVEOUT,
1166 .id = ION_NOR_HEAP_ID,
1168 .size = ION_RESERVE_SIZE,
1173 static struct platform_device device_ion = {
1174 .name = "ion-rockchip",
1177 .platform_data = &rk30_ion_pdata,
1182 /**************************************************************************************************
1183 * SDMMC devices, include the module of SD,MMC,and SDIO.noted by xbw at 2012-03-05
1184 **************************************************************************************************/
1185 #ifdef CONFIG_SDMMC_RK29
1186 #include "board-rk30-sdk-sdmmc.c"
1189 #ifdef CONFIG_SDMMC0_RK29
1190 static int rk29_sdmmc0_cfg_gpio(void)
1192 #ifdef CONFIG_SDMMC_RK29_OLD
1193 rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1194 rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1195 rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1196 rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1197 rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1198 rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1200 rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1202 rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1203 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1204 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1207 rk29_sdmmc_set_iomux(0, 0xFFFF);
1209 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
1210 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
1212 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
1215 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1216 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1217 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1225 #define CONFIG_SDMMC0_USE_DMA
1226 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1228 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1229 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1230 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1232 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1233 .io_init = rk29_sdmmc0_cfg_gpio,
1235 #if !defined(CONFIG_SDMMC_RK29_OLD)
1236 .set_iomux = rk29_sdmmc_set_iomux,
1239 .dma_name = "sd_mmc",
1240 #ifdef CONFIG_SDMMC0_USE_DMA
1246 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1247 .status = rk29sdk_wifi_mmc0_status,
1248 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1251 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1252 .power_en = RK29SDK_SD_CARD_PWR_EN,
1253 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1255 .power_en = INVALID_GPIO,
1256 .power_en_level = GPIO_LOW,
1258 .enable_sd_wakeup = 0,
1260 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1261 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1262 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1264 .write_prt = INVALID_GPIO,
1268 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1269 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1270 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1271 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1273 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1274 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1275 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1277 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1278 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1289 #endif // CONFIG_SDMMC0_RK29
1291 #ifdef CONFIG_SDMMC1_RK29
1292 #define CONFIG_SDMMC1_USE_DMA
1293 static int rk29_sdmmc1_cfg_gpio(void)
1295 #if defined(CONFIG_SDMMC_RK29_OLD)
1296 rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1297 rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1298 rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1299 rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1300 rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1301 rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1304 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1305 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1306 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1314 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1316 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1317 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1320 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1321 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1322 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1325 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1328 .io_init = rk29_sdmmc1_cfg_gpio,
1330 #if !defined(CONFIG_SDMMC_RK29_OLD)
1331 .set_iomux = rk29_sdmmc_set_iomux,
1335 #ifdef CONFIG_SDMMC1_USE_DMA
1341 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1342 .status = rk29sdk_wifi_status,
1343 .register_status_notify = rk29sdk_wifi_status_register,
1346 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1347 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1348 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1350 .write_prt = INVALID_GPIO,
1353 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1354 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1358 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1359 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1360 .io = RK29SDK_SD_CARD_DETECT_N,
1365 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1366 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1368 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1369 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1370 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1372 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1373 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1383 .enable_sd_wakeup = 0,
1385 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1387 /**************************************************************************************************
1388 * the end of setting for SDMMC devices
1389 **************************************************************************************************/
1391 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
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_MU509)
1594 #if defined(CONFIG_MW100)
1597 #if defined(CONFIG_MT6229)
1598 &rk29_device_mt6229,
1600 #if defined(CONFIG_SEW868)
1601 &rk30_device_sew868,
1603 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
1607 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1608 &rk30_device_adc_battery,
1610 #ifdef CONFIG_RFKILL_RK
1613 #ifdef CONFIG_MT5931_MT6622
1616 #if defined(CONFIG_BP_AUTO)
1622 static int rk_platform_add_display_devices(void)
1624 struct platform_device *fb = NULL; //fb
1625 struct platform_device *lcdc0 = NULL; //lcdc0
1626 struct platform_device *lcdc1 = NULL; //lcdc1
1627 struct platform_device *bl = NULL; //backlight
1628 #ifdef CONFIG_FB_ROCKCHIP
1632 #if defined(CONFIG_LCDC0_RK30)
1633 lcdc0 = &device_lcdc0,
1636 #if defined(CONFIG_LCDC1_RK30)
1637 lcdc1 = &device_lcdc1,
1640 #ifdef CONFIG_BACKLIGHT_RK29_BL
1641 bl = &rk29_device_backlight,
1643 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1649 #ifdef CONFIG_I2C0_RK30
1650 static struct i2c_board_info __initdata i2c0_info[] = {
1651 #if defined (CONFIG_GS_MMA8452)
1653 .type = "gs_mma8452",
1656 .irq = MMA8452_INT_PIN,
1657 .platform_data = &mma8452_info,
1660 #if defined (CONFIG_GS_LIS3DH)
1662 .type = "gs_lis3dh",
1663 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1665 .irq = LIS3DH_INT_PIN,
1666 .platform_data = &lis3dh_info,
1669 #if defined (CONFIG_GS_KXTIK)
1674 .irq = KXTIK_INT_PIN,
1675 .platform_data = &kxtik_info,
1678 #if defined (CONFIG_COMPASS_AK8975)
1683 .irq = RK30_PIN4_PC1,
1684 .platform_data = &akm8975_info,
1687 #if defined (CONFIG_GYRO_L3G4200D)
1689 .type = "l3g4200d_gryo",
1692 .irq = L3G4200D_INT_PIN,
1693 .platform_data = &l3g4200d_info,
1696 #if defined (CONFIG_LS_AL3006)
1698 .type = "light_al3006",
1699 .addr = 0x1c, //sel = 0; if sel =1, then addr = 0x1D
1701 .irq = RK30_PIN6_PA2,
1702 .platform_data = &light_al3006_info,
1705 #if defined (CONFIG_LS_STK3171)
1707 .type = "ls_stk3171",
1710 .irq = RK30_PIN6_PA2,
1711 .platform_data = &light_stk3171_info,
1716 #if defined (CONFIG_PS_AL3006)
1718 .type = "proximity_al3006",
1719 .addr = 0x1c, //sel = 0; if sel =1, then addr = 0x1D
1721 .irq = RK30_PIN6_PA2,
1722 .platform_data = &proximity_al3006_info,
1726 #if defined (CONFIG_PS_STK3171)
1728 .type = "ps_stk3171",
1731 .irq = RK30_PIN6_PA2,
1732 .platform_data = &proximity_stk3171_info,
1735 #if defined (CONFIG_SND_SOC_RK1000)
1737 .type = "rk1000_i2c_codec",
1742 .type = "rk1000_control",
1747 #if defined (CONFIG_SND_SOC_RT5631) || defined (CONFIG_SND_SOC_RT5631_PHONE)
1754 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
1759 .platform_data = &rt3261_info,
1763 #ifdef CONFIG_MFD_RK610
1765 .type = "rk610_ctl",
1768 .platform_data = &rk610_ctl_pdata,
1770 #ifdef CONFIG_RK610_TVOUT
1772 .type = "rk610_tvout",
1777 #ifdef CONFIG_HDMI_RK610
1779 .type = "rk610_hdmi",
1782 .irq = INVALID_GPIO,
1785 #ifdef CONFIG_SND_SOC_RK610
1786 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1787 .type = "rk610_i2c_codec",
1790 .platform_data = &rk610_codec_pdata,
1797 int __sramdata g_pmic_type = 0;
1798 #ifdef CONFIG_I2C1_RK30
1799 #ifdef CONFIG_MFD_WM831X_I2C
1800 #include "board-rk30-sdk-wm8326.c"
1802 #ifdef CONFIG_MFD_TPS65910
1803 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1804 #include "board-rk30-sdk-tps65910.c"
1807 static struct i2c_board_info __initdata i2c1_info[] = {
1808 #if defined (CONFIG_MFD_WM831X_I2C)
1813 .irq = RK30_PIN6_PA4,
1814 .platform_data = &wm831x_platdata,
1817 #if defined (CONFIG_MFD_TPS65910)
1820 .addr = TPS65910_I2C_ID0,
1822 .irq = TPS65910_HOST_IRQ,
1823 .platform_data = &tps65910_data,
1829 void __sramfunc board_pmu_suspend(void)
1831 #if defined (CONFIG_MFD_WM831X_I2C)
1832 if(pmic_is_wm8326())
1833 board_pmu_wm8326_suspend();
1835 #if defined (CONFIG_MFD_TPS65910)
1836 if(pmic_is_tps65910())
1837 board_pmu_tps65910_suspend();
1841 void __sramfunc board_pmu_resume(void)
1843 #if defined (CONFIG_MFD_WM831X_I2C)
1844 if(pmic_is_wm8326())
1845 board_pmu_wm8326_resume();
1847 #if defined (CONFIG_MFD_TPS65910)
1848 if(pmic_is_tps65910())
1849 board_pmu_tps65910_resume();
1853 #ifdef CONFIG_I2C2_RK30
1854 static struct i2c_board_info __initdata i2c2_info[] = {
1855 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1857 .type = "Goodix-TS",
1860 .irq = RK30_PIN4_PC2,
1861 .platform_data = &goodix_info,
1864 #if defined (CONFIG_LS_CM3217)
1866 .type = "light_cm3217",
1869 .platform_data = &cm3217_info,
1873 #if defined(CONFIG_DP501)
1878 .platform_data = &dp501_platform_data,
1884 #ifdef CONFIG_I2C3_RK30
1885 static struct i2c_board_info __initdata i2c3_info[] = {
1889 #ifdef CONFIG_I2C4_RK30
1890 static struct i2c_board_info __initdata i2c4_info[] = {
1894 #ifdef CONFIG_I2C_GPIO_RK30
1895 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1896 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1897 static int rk30_i2c_io_init(void)
1899 //set iomux (gpio) here
1900 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1901 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1905 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1906 .sda_pin = I2C_SDA_PIN,
1907 .scl_pin = I2C_SCL_PIN,
1908 .udelay = 5, // clk = 500/udelay = 100Khz
1909 .timeout = 100,//msecs_to_jiffies(100),
1911 .io_init = rk30_i2c_io_init,
1913 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1917 static void __init rk30_i2c_register_board_info(void)
1919 #ifdef CONFIG_I2C0_RK30
1920 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1922 #ifdef CONFIG_I2C1_RK30
1923 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1925 #ifdef CONFIG_I2C2_RK30
1926 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1928 #ifdef CONFIG_I2C3_RK30
1929 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1931 #ifdef CONFIG_I2C4_RK30
1932 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1934 #ifdef CONFIG_I2C_GPIO_RK30
1935 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1940 #define POWER_ON_PIN RK30_PIN6_PB0 //power_hold
1941 static void rk30_pm_power_off(void)
1943 printk(KERN_ERR "rk30_pm_power_off start...\n");
1944 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1945 #if defined(CONFIG_MFD_WM831X)
1946 if(pmic_is_wm8326())
1948 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
1949 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1952 #if defined(CONFIG_MFD_TPS65910)
1953 if(pmic_is_tps65910())
1955 tps65910_device_shutdown();//tps65910 shutdown
1962 static void __init machine_rk30_board_init(void)
1965 gpio_request(POWER_ON_PIN, "poweronpin");
1966 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1968 pm_power_off = rk30_pm_power_off;
1970 rk30_i2c_register_board_info();
1971 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1972 platform_add_devices(devices, ARRAY_SIZE(devices));
1973 rk_platform_add_display_devices();
1974 board_usb_detect_init(RK30_PIN6_PA3);
1976 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1977 rk29sdk_wifi_bt_gpio_control_init();
1978 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1979 rk29sdk_wifi_combo_module_gpio_init();
1982 #if defined(CONFIG_MT6620)
1983 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
1985 #if defined(CONFIG_MT5931_MT6622)
1986 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
1988 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
1990 gpio_request(RK30_PIN4_PD7, "codec_en");
1991 rk30_mux_api_set(GPIO4D7_SMCDATA15_TRACEDATA15_NAME, GPIO4D_GPIO4D7);
1992 gpio_direction_output(RK30_PIN4_PD7, GPIO_HIGH);
1996 static void __init rk30_reserve(void)
1999 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2001 #ifdef CONFIG_FB_ROCKCHIP
2002 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2003 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2005 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2006 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2009 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2010 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2011 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2014 #ifdef CONFIG_VIDEO_RK29
2015 rk30_camera_request_reserve_mem();
2017 board_mem_reserved();
2021 * dvfs_cpu_logic_table: table for arm and logic dvfs
2022 * @frequency : arm frequency
2023 * @cpu_volt : arm voltage depend on frequency
2024 * @logic_volt : logic voltage arm requests depend on frequency
2025 * comments : min arm/logic voltage
2027 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
2028 {.frequency = 252 * 1000, .cpu_volt = 1075 * 1000, .logic_volt = 1125 * 1000},//0.975V/1.000V
2029 {.frequency = 504 * 1000, .cpu_volt = 1100 * 1000, .logic_volt = 1125 * 1000},//0.975V/1.000V
2030 {.frequency = 816 * 1000, .cpu_volt = 1125 * 1000, .logic_volt = 1150 * 1000},//1.000V/1.025V
2031 {.frequency = 1008 * 1000, .cpu_volt = 1125 * 1000, .logic_volt = 1150 * 1000},//1.025V/1.050V
2032 {.frequency = 1200 * 1000, .cpu_volt = 1175 * 1000, .logic_volt = 1200 * 1000},//1.100V/1.050V
2033 {.frequency = 1272 * 1000, .cpu_volt = 1225 * 1000, .logic_volt = 1200 * 1000},//1.150V/1.100V
2034 {.frequency = 1416 * 1000, .cpu_volt = 1300 * 1000, .logic_volt = 1200 * 1000},//1.225V/1.100V
2035 {.frequency = 1512 * 1000, .cpu_volt = 1350 * 1000, .logic_volt = 1250 * 1000},//1.300V/1.150V
2036 {.frequency = 1608 * 1000, .cpu_volt = 1425 * 1000, .logic_volt = 1300 * 1000},//1.325V/1.175V
2037 {.frequency = CPUFREQ_TABLE_END},
2040 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2041 {.frequency = 266 * 1000, .index = 1050 * 1000},
2042 {.frequency = 400 * 1000, .index = 1275 * 1000},
2043 {.frequency = CPUFREQ_TABLE_END},
2046 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2047 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1050 * 1000},
2048 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2049 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1125 * 1000},
2050 {.frequency = CPUFREQ_TABLE_END},
2053 #define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2054 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2055 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2057 void __init board_clock_init(void)
2059 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2060 dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2061 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2062 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2065 MACHINE_START(RK30, "RK30board")
2066 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2067 .fixup = rk30_fixup,
2068 .reserve = &rk30_reserve,
2069 .map_io = rk30_map_io,
2070 .init_irq = rk30_init_irq,
2071 .timer = &rk30_timer,
2072 .init_machine = machine_rk30_board_init,