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/rk_fb.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/rfkill-rk.h>
46 #include <linux/sensor-dev.h>
47 #include <linux/mfd/tps65910.h>
48 #include <linux/regulator/act8846.h>
49 #include <linux/regulator/rk29-pwm-regulator.h>
50 #include <linux/regulator/act8931.h>
52 #if defined(CONFIG_MFD_RK610)
53 #include <linux/mfd/rk610_core.h>
56 #if defined(CONFIG_RK_HDMI)
57 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
60 #if defined(CONFIG_SPIM_RK29)
61 #include "../../../drivers/spi/rk29_spim.h"
63 #if defined(CONFIG_GPS_RK)
64 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
67 #if defined(CONFIG_MU509)
68 #include <linux/mu509.h>
70 #if defined(CONFIG_MW100)
71 #include <linux/mw100.h>
73 #if defined(CONFIG_MT6229)
74 #include <linux/mt6229.h>
76 #if defined(CONFIG_ANDROID_TIMED_GPIO)
77 #include "../../../drivers/staging/android/timed_gpio.h"
80 #if defined(CONFIG_MT6620)
81 #include <linux/gps.h>
83 #include "../mach-rk30/board-rk3028-86v-camera.c"
84 #if defined(CONFIG_TOUCHSCREEN_GSLX680_RK3028)
85 #define TOUCH_RESET_PIN RK30_PIN0_PC1
86 #define TOUCH_EN_PIN NULL
87 #define TOUCH_INT_PIN RK30_PIN0_PB4
89 int gslx680_init_platform_hw(void)
92 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
93 gpio_free(TOUCH_RESET_PIN);
94 printk("gslx680_init_platform_hw gpio_request error\n");
97 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
98 gpio_free(TOUCH_INT_PIN);
99 printk("gslx680_init_platform_hw gpio_request error\n");
102 gpio_direction_output(TOUCH_RESET_PIN, GPIO_HIGH);
104 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
106 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
112 struct ts_hw_data gslx680_info = {
113 .reset_gpio = TOUCH_RESET_PIN,
114 .touch_en_gpio = TOUCH_INT_PIN,
115 .init_platform_hw = gslx680_init_platform_hw,
119 #if defined (CONFIG_TOUCHSCREEN_86V_GT811_IIC)
120 #define TOUCH_RESET_PIN RK30_PIN0_PB6
121 #define TOUCH_INT_PIN RK30_PIN1_PB7
122 int gt811_init_platform_hw(void)
124 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
125 gpio_free(TOUCH_RESET_PIN);
126 printk("gt811_init_platform_hw gpio_request error\n");
130 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
131 gpio_free(TOUCH_INT_PIN);
132 printk("gt811_init_platform_hw gpio_request error\n");
135 //gpio_pull_updown(TOUCH_INT_PIN, 1);
136 gpio_direction_output(TOUCH_RESET_PIN, 0);
138 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
140 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
147 static struct goodix_platform_data gt811_info = {
149 .init_platform_hw= gt811_init_platform_hw,
154 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
155 #define TOUCH_RESET_PIN RK30_PIN0_PC1//RK30_PIN0_PB6
156 #define TOUCH_PWR_PIN INVALID_GPIO//RK30_PIN0_PC5 // need to fly line by hardware engineer
157 static int goodix_init_platform_hw(void)
161 if (TOUCH_PWR_PIN != INVALID_GPIO) {
162 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
164 gpio_free(TOUCH_PWR_PIN);
165 printk("goodix power error\n");
168 gpio_direction_output(TOUCH_PWR_PIN, 0);
169 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
173 if (TOUCH_RESET_PIN != INVALID_GPIO) {
174 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
176 gpio_free(TOUCH_RESET_PIN);
177 printk("goodix gpio_request error\n");
180 gpio_direction_output(TOUCH_RESET_PIN, 1);
182 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
184 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
190 struct goodix_platform_data goodix_info = {
192 .irq_pin = RK30_PIN0_PB4,
193 .rest_pin = TOUCH_RESET_PIN,
194 .init_platform_hw = goodix_init_platform_hw,
198 static struct spi_board_info board_spi_devices[] = {
201 /***********************************************************
203 ************************************************************/
204 #ifdef CONFIG_BACKLIGHT_RK29_BL
206 #define PWM_MODE PWM0
207 #define PWM_EFFECT_VALUE GPIO_LOW
209 #define LCD_DISP_ON_PIN
211 #ifdef LCD_DISP_ON_PIN
212 #define BL_EN_PIN RK30_PIN0_PC0
213 #define BL_EN_VALUE GPIO_HIGH
215 static int rk29_backlight_io_init(void)
219 #ifdef LCD_DISP_ON_PIN
220 ret = gpio_request(BL_EN_PIN, NULL);
222 gpio_free(BL_EN_PIN);
224 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
225 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
230 static int rk29_backlight_io_deinit(void)
232 int ret = 0, pwm_gpio;
233 #ifdef LCD_DISP_ON_PIN
234 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
235 gpio_free(BL_EN_PIN);
237 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
239 gpio_request(pwm_gpio, "bl_pwm");
240 gpio_direction_output(pwm_gpio, !PWM_EFFECT_VALUE);
244 static int rk29_backlight_pwm_suspend(void)
246 int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
249 ret = gpio_request(pwm_gpio, "bl_pwm");
251 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
254 gpio_direction_output(pwm_gpio, !PWM_EFFECT_VALUE);
255 #ifdef LCD_DISP_ON_PIN
256 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
261 static int rk29_backlight_pwm_resume(void)
263 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
266 #ifdef LCD_DISP_ON_PIN
268 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
273 static struct rk29_bl_info rk29_bl_info = {
275 .min_brightness = 100,
277 .brightness_mode =BRIGHTNESS_MODE_CONIC,
278 .pre_div = 20 * 1000, // pwm output clk: 20k;
279 .bl_ref = PWM_EFFECT_VALUE,
280 .io_init = rk29_backlight_io_init,
281 .io_deinit = rk29_backlight_io_deinit,
282 .pwm_suspend = rk29_backlight_pwm_suspend,
283 .pwm_resume = rk29_backlight_pwm_resume,
286 static struct platform_device rk29_device_backlight = {
287 .name = "rk29_backlight",
290 .platform_data = &rk29_bl_info,
296 #ifdef CONFIG_RK29_SUPPORT_MODEM
298 #define RK30_MODEM_POWER RK30_PIN0_PC6
299 #define RK30_MODEM_POWER_IOMUX iomux_set(GPIO0_C6)
301 static int rk30_modem_io_init(void)
303 printk("%s\n", __FUNCTION__);
304 RK30_MODEM_POWER_IOMUX;
309 static struct rk29_io_t rk30_modem_io = {
310 .io_addr = RK30_MODEM_POWER,
313 .io_init = rk30_modem_io_init,
316 static struct platform_device rk30_device_modem = {
317 .name = "rk30_modem",
320 .platform_data = &rk30_modem_io,
324 #if defined(CONFIG_MU509)
325 static int mu509_io_init(void)
336 static int mu509_io_deinit(void)
342 struct rk29_mu509_data rk29_mu509_info = {
343 .io_init = mu509_io_init,
344 .io_deinit = mu509_io_deinit,
345 .modem_power_en = RK30_PIN2_PD5,
346 .bp_power = RK30_PIN0_PC6,
347 .bp_reset = RK30_PIN2_PD4,
348 .ap_wakeup_bp = RK30_PIN0_PC4,
349 .bp_wakeup_ap = RK30_PIN0_PC5,
351 struct platform_device rk29_device_mu509 = {
355 .platform_data = &rk29_mu509_info,
359 #if defined(CONFIG_MW100)
360 static int mw100_io_init(void)
370 static int mw100_io_deinit(void)
376 struct rk29_mw100_data rk29_mw100_info = {
377 .io_init = mw100_io_init,
378 .io_deinit = mw100_io_deinit,
379 .modem_power_en = RK30_PIN2_PD5,
380 .bp_power = RK30_PIN0_PC6,
381 .bp_reset = RK30_PIN2_PD4,
382 .ap_wakeup_bp = RK30_PIN0_PC4,
383 .bp_wakeup_ap = RK30_PIN0_PC5,
385 struct platform_device rk29_device_mw100 = {
389 .platform_data = &rk29_mw100_info,
393 #if defined(CONFIG_MT6229)
394 static int mt6229_io_init(void)
404 static int mt6229_io_deinit(void)
410 struct rk29_mt6229_data rk29_mt6229_info = {
411 .io_init = mt6229_io_init,
412 .io_deinit = mt6229_io_deinit,
413 .modem_power_en = RK30_PIN2_PD5,
414 .bp_power = RK30_PIN0_PC6,
415 .bp_reset = RK30_PIN2_PD4,
416 .ap_wakeup_bp = RK30_PIN0_PC4,
417 .bp_wakeup_ap = RK30_PIN0_PC5,
419 struct platform_device rk29_device_mt6229 = {
423 .platform_data = &rk29_mt6229_info,
429 #if defined (CONFIG_GS_MMA8452)
430 #define MMA8452_INT_PIN RK30_PIN0_PB7
432 static int mma8452_init_platform_hw(void)
437 static struct sensor_platform_data mma8452_info = {
438 .type = SENSOR_TYPE_ACCEL,
441 .init_platform_hw = mma8452_init_platform_hw,
442 .orientation = {-1, 0, 0, 0, 0, 1, 0, 1, 0},
447 #if defined (CONFIG_GS_MMA7660)
448 #define MMA7660_INT_PIN RK30_PIN0_PB7
450 static int mma7660_init_platform_hw(void)
452 //rk30_mux_api_set(GPIO1B2_SPI_RXD_UART1_SIN_NAME, GPIO1B_GPIO1B2);
457 static struct sensor_platform_data mma7660_info = {
458 .type = SENSOR_TYPE_ACCEL,
461 .init_platform_hw = mma7660_init_platform_hw,
462 #ifdef CONFIG_TOUCHSCREEN_GSLX680_RK3028
463 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
465 .orientation = {0, -1, 0, -1, 0, 0, 0, 0, -1},
470 #if defined (CONFIG_GS_MXC6225)
471 #define MXC6225_INT_PIN RK30_PIN0_PB1
473 static int mxc6225_init_platform_hw(void)
478 static struct sensor_platform_data mxc6225_info = {
479 .type = SENSOR_TYPE_ACCEL,
482 .init_platform_hw = mxc6225_init_platform_hw,
483 .orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 0},
487 #if defined (CONFIG_GS_LIS3DH)
488 #define LIS3DH_INT_PIN RK30_PIN0_PB7
490 static int lis3dh_init_platform_hw(void)
496 static struct sensor_platform_data lis3dh_info = {
497 .type = SENSOR_TYPE_ACCEL,
500 .init_platform_hw = lis3dh_init_platform_hw,
501 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
504 #if defined (CONFIG_COMPASS_AK8975)
505 static struct sensor_platform_data akm8975_info =
507 .type = SENSOR_TYPE_COMPASS,
540 #if defined(CONFIG_GYRO_L3G4200D)
542 #include <linux/l3g4200d.h>
543 #define L3G4200D_INT_PIN RK30_PIN0_PB4
545 static int l3g4200d_init_platform_hw(void)
550 static struct sensor_platform_data l3g4200d_info = {
551 .type = SENSOR_TYPE_GYROSCOPE,
554 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
555 .init_platform_hw = l3g4200d_init_platform_hw,
556 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
563 #ifdef CONFIG_LS_CM3217
564 static struct sensor_platform_data cm3217_info = {
565 .type = SENSOR_TYPE_LIGHT,
567 .poll_delay_ms = 500,
572 #ifdef CONFIG_FB_ROCKCHIP
574 #define LCD_CS_PIN INVALID_GPIO
575 #define LCD_CS_VALUE GPIO_HIGH
577 #define LCD_EN_PIN RK30_PIN0_PB6
578 #define LCD_EN_VALUE GPIO_LOW
580 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
584 if(LCD_CS_PIN !=INVALID_GPIO)
586 ret = gpio_request(LCD_CS_PIN, NULL);
589 gpio_free(LCD_CS_PIN);
590 printk(KERN_ERR "request lcd cs pin fail!\n");
595 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
599 if(LCD_EN_PIN !=INVALID_GPIO)
601 ret = gpio_request(LCD_EN_PIN, NULL);
604 gpio_free(LCD_EN_PIN);
605 printk(KERN_ERR "request lcd en pin fail!\n");
610 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
615 static int rk_fb_io_disable(void)
617 if(LCD_CS_PIN !=INVALID_GPIO)
619 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
621 if(LCD_EN_PIN !=INVALID_GPIO)
623 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
627 static int rk_fb_io_enable(void)
629 if(LCD_CS_PIN !=INVALID_GPIO)
631 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
633 if(LCD_EN_PIN !=INVALID_GPIO)
635 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
640 #if defined(CONFIG_LCDC0_RK3066B)
641 struct rk29fb_info lcdc0_screen_info = {
642 .prop = EXTEND, //extend display device
646 .set_screen_info = hdmi_init_lcdc,
650 #if defined(CONFIG_LCDC1_RK3066B)
651 struct rk29fb_info lcdc1_screen_info = {
652 .prop = PRMRY, //primary display device
653 .io_init = rk_fb_io_init,
654 .io_disable = rk_fb_io_disable,
655 .io_enable = rk_fb_io_enable,
656 .set_screen_info = set_lcd_info,
660 static struct resource resource_fb[] = {
664 .end = 0,//RK30_FB0_MEM_SIZE - 1,
665 .flags = IORESOURCE_MEM,
668 .name = "ipp buf", //for rotate
670 .end = 0,//RK30_FB0_MEM_SIZE - 1,
671 .flags = IORESOURCE_MEM,
676 .end = 0,//RK30_FB0_MEM_SIZE - 1,
677 .flags = IORESOURCE_MEM,
681 static struct platform_device device_fb = {
684 .num_resources = ARRAY_SIZE(resource_fb),
685 .resource = resource_fb,
689 #if defined(CONFIG_LCDC0_RK3066B)
690 static struct resource resource_lcdc0[] = {
693 .start = RK30_LCDC0_PHYS,
694 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
695 .flags = IORESOURCE_MEM,
702 .flags = IORESOURCE_IRQ,
706 static struct platform_device device_lcdc0 = {
709 .num_resources = ARRAY_SIZE(resource_lcdc0),
710 .resource = resource_lcdc0,
712 .platform_data = &lcdc0_screen_info,
716 #if defined(CONFIG_LCDC1_RK3066B)
717 static struct resource resource_lcdc1[] = {
720 .start = RK30_LCDC1_PHYS,
721 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
722 .flags = IORESOURCE_MEM,
728 .flags = IORESOURCE_IRQ,
732 static struct platform_device device_lcdc1 = {
735 .num_resources = ARRAY_SIZE(resource_lcdc1),
736 .resource = resource_lcdc1,
738 .platform_data = &lcdc1_screen_info,
743 #if defined(CONFIG_MFD_RK610)
744 #define RK610_RST_PIN RK30_PIN2_PD5
745 #define RK610_TEST_PIN RK30_PIN2_PD6
746 #define RK610_ENABLE_PIN RK30_PIN0_PC5
747 static int rk610_power_on_init(void)
750 if(RK610_ENABLE_PIN != INVALID_GPIO)
752 ret = gpio_request(RK610_ENABLE_PIN, "rk610 reset");
755 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
759 gpio_direction_output(RK610_ENABLE_PIN, GPIO_HIGH);
763 if(RK610_TEST_PIN != INVALID_GPIO)
765 ret = gpio_request(RK610_TEST_PIN, "rk610 reset");
768 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
772 gpio_direction_output(RK610_TEST_PIN, GPIO_LOW);
776 if(RK610_RST_PIN != INVALID_GPIO)
778 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
781 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
785 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
787 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
789 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
798 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
799 .rk610_power_on_init = rk610_power_on_init,
803 #ifdef CONFIG_SND_SOC_RK610
804 static int rk610_codec_io_init(void)
807 //Must not gpio_request
811 static struct rk610_codec_platform_data rk610_codec_pdata = {
812 .spk_ctl_io = RK30_PIN3_PC7,
813 .io_init = rk610_codec_io_init,
818 #ifdef CONFIG_ANDROID_TIMED_GPIO
819 static struct timed_gpio timed_gpios[] = {
822 .gpio = INVALID_GPIO,
825 .adjust_time =20, //adjust for diff product
829 static struct timed_gpio_platform_data rk29_vibrator_info = {
831 .gpios = timed_gpios,
834 static struct platform_device rk29_device_vibrator = {
835 .name = "timed-gpio",
838 .platform_data = &rk29_vibrator_info,
844 #ifdef CONFIG_LEDS_GPIO_PLATFORM
845 static struct gpio_led rk29_leds[] = {
847 .name = "button-backlight",
848 .gpio = INVALID_GPIO,
849 .default_trigger = "timer",
851 .retain_state_suspended = 0,
852 .default_state = LEDS_GPIO_DEFSTATE_OFF,
856 static struct gpio_led_platform_data rk29_leds_pdata = {
858 .num_leds = ARRAY_SIZE(rk29_leds),
861 static struct platform_device rk29_device_gpio_leds = {
865 .platform_data = &rk29_leds_pdata,
870 #ifdef CONFIG_RK_IRDA
871 #define IRDA_IRQ_PIN INVALID_GPIO //RK30_PIN0_PA3
873 static int irda_iomux_init(void)
878 ret = gpio_request(IRDA_IRQ_PIN, NULL);
880 gpio_free(IRDA_IRQ_PIN);
881 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
883 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
884 gpio_direction_input(IRDA_IRQ_PIN);
889 static int irda_iomux_deinit(void)
891 gpio_free(IRDA_IRQ_PIN);
895 static struct irda_info rk29_irda_info = {
896 .intr_pin = IRDA_IRQ_PIN,
897 .iomux_init = irda_iomux_init,
898 .iomux_deinit = irda_iomux_deinit,
899 //.irda_pwr_ctl = bu92747guw_power_ctl,
902 static struct platform_device irda_device = {
903 #ifdef CONFIG_RK_IRDA_NET
906 .name = "bu92747_irda",
910 .platform_data = &rk29_irda_info,
916 #define ION_RESERVE_SIZE (80 * SZ_1M)
917 static struct ion_platform_data rk30_ion_pdata = {
921 .type = ION_HEAP_TYPE_CARVEOUT,
922 .id = ION_NOR_HEAP_ID,
924 .size = ION_RESERVE_SIZE,
929 static struct platform_device device_ion = {
930 .name = "ion-rockchip",
933 .platform_data = &rk30_ion_pdata,
938 /**************************************************************************************************
939 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
940 **************************************************************************************************/
941 #ifdef CONFIG_SDMMC_RK29
942 #include "board-rk3028-86v-sdmmc-conifg.c"
943 #include "../plat-rk/rk-sdmmc-ops.c"
944 #include "../plat-rk/rk-sdmmc-wifi.c"
945 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
947 #ifdef CONFIG_SDMMC0_RK29
948 static int rk29_sdmmc0_cfg_gpio(void)
950 #ifdef CONFIG_SDMMC_RK29_OLD
952 iomux_set(MMC0_CLKOUT);
958 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
960 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
961 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
964 rk29_sdmmc_set_iomux(0, 0xFFFF);
966 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
967 #if SDMMC_USE_NEW_IOMUX_API
968 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
970 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
973 #if SDMMC_USE_NEW_IOMUX_API
974 iomux_set(MMC0_DETN);
976 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
980 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
981 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
982 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
990 #define CONFIG_SDMMC0_USE_DMA
991 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
993 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
994 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
995 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
997 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
998 .io_init = rk29_sdmmc0_cfg_gpio,
1000 #if !defined(CONFIG_SDMMC_RK29_OLD)
1001 .set_iomux = rk29_sdmmc_set_iomux,
1004 .dma_name = "sd_mmc",
1005 #ifdef CONFIG_SDMMC0_USE_DMA
1011 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1012 .status = rk29sdk_wifi_mmc0_status,
1013 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1016 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1017 .power_en = RK29SDK_SD_CARD_PWR_EN,
1018 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1020 .power_en = INVALID_GPIO,
1021 .power_en_level = GPIO_LOW,
1023 .enable_sd_wakeup = 0,
1025 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1026 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1027 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1029 .write_prt = INVALID_GPIO,
1033 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1034 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1035 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1036 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1038 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1039 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1040 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1042 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1043 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1054 #endif // CONFIG_SDMMC0_RK29
1056 #ifdef CONFIG_SDMMC1_RK29
1057 #define CONFIG_SDMMC1_USE_DMA
1058 static int rk29_sdmmc1_cfg_gpio(void)
1060 #if defined(CONFIG_SDMMC_RK29_OLD)
1061 iomux_set(MMC1_CMD);
1062 iomux_set(MMC1_CLKOUT);
1069 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1070 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1071 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1079 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1081 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1082 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1085 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1086 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1087 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1090 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1093 .io_init = rk29_sdmmc1_cfg_gpio,
1095 #if !defined(CONFIG_SDMMC_RK29_OLD)
1096 .set_iomux = rk29_sdmmc_set_iomux,
1100 #ifdef CONFIG_SDMMC1_USE_DMA
1106 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1107 .status = rk29sdk_wifi_status,
1108 .register_status_notify = rk29sdk_wifi_status_register,
1111 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1112 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1113 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1115 .write_prt = INVALID_GPIO,
1118 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1119 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1120 #ifdef USE_SDIO_INT_LEVEL
1121 .sdio_INT_level = RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE,
1126 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1127 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1128 .io = RK29SDK_SD_CARD_DETECT_N,
1133 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1134 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1136 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1137 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1138 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1140 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1141 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1151 .enable_sd_wakeup = 0,
1153 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1155 /**************************************************************************************************
1156 * the end of setting for SDMMC devices
1157 **************************************************************************************************/
1159 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1160 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1161 .dc_det_pin = RK30_PIN0_PB7,
1162 .batt_low_pin = INVALID_GPIO,
1163 .charge_set_pin = INVALID_GPIO,
1164 .charge_ok_pin = RK30_PIN1_PB2,
1165 .usb_det_pin = INVALID_GPIO,
1166 .dc_det_level = GPIO_LOW,
1167 .charge_ok_level = GPIO_HIGH,
1169 .reference_voltage = 1800, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
1170 .pull_up_res = 200, //divider resistance , pull-up resistor
1171 .pull_down_res = 120, //divider resistance , pull-down resistor
1173 .is_reboot_charging = 1,
1174 .save_capacity = 1 ,
1175 .low_voltage_protection = 3600,
1178 static struct platform_device rk30_device_adc_battery = {
1179 .name = "rk30-battery",
1182 .platform_data = &rk30_adc_battery_platdata,
1186 #ifdef CONFIG_RK30_PWM_REGULATOR
1187 static int pwm_voltage_map[] = {
1188 950000,975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1190 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1192 .supply = "vdd_cpu",
1196 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1200 .name = "PWM_DCDC1",
1202 .max_uV = 1800000, //0.6-1.8V
1204 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1206 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1207 .consumer_supplies = pwm_dcdc1_consumers,
1211 static struct pwm_platform_data pwm_regulator_info[1] = {
1213 #if defined (CONFIG_MACH_RK3028_TB)
1215 .pwm_gpio = RK30_PIN3_PD5,
1216 .pwm_iomux_pwm = PWM2,
1217 .pwm_iomux_gpio = GPIO3_D5,
1220 .pwm_gpio = RK30_PIN3_PD4,
1221 .pwm_iomux_pwm = PWM1,
1222 .pwm_iomux_gpio = GPIO3_D4,
1225 .pwm_voltage = 1100000,
1226 .suspend_voltage = 1000000,
1229 .coefficient = 504, //57.5%
1230 .pwm_voltage_map = pwm_voltage_map,
1231 .init_data = &pwm_regulator_init_dcdc[0],
1235 struct platform_device pwm_regulator_device[1] = {
1237 .name = "pwm-voltage-regulator",
1240 .platform_data = &pwm_regulator_info[0],
1246 #ifdef CONFIG_RK29_VMAC
1247 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1248 #include "board-rk30-sdk-vmac.c"
1251 #ifdef CONFIG_RFKILL_RK
1252 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1253 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1254 .type = RFKILL_TYPE_BLUETOOTH,
1256 .poweron_gpio = { // BT_REG_ON
1257 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1258 .enable = GPIO_HIGH,
1260 .name = "bt_poweron",
1265 .reset_gpio = { // BT_RST
1266 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1274 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1275 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1276 .enable = GPIO_HIGH,
1283 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1285 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1286 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1293 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1294 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1304 static struct platform_device device_rfkill_rk = {
1305 .name = "rfkill_rk",
1308 .platform_data = &rfkill_rk_platdata,
1313 #if defined(CONFIG_GPS_RK)
1314 int rk_gps_io_init(void)
1316 printk("%s \n", __FUNCTION__);
1318 gpio_request(RK30_PIN1_PB5, NULL);
1319 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1321 iomux_set(GPS_RFCLK);//GPS_CLK
1322 iomux_set(GPS_MAG);//GPS_MAG
1323 iomux_set(GPS_SIG);//GPS_SIGN
1325 gpio_request(RK30_PIN1_PA6, NULL);
1326 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1328 gpio_request(RK30_PIN1_PA5, NULL);
1329 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1331 gpio_request(RK30_PIN1_PA7, NULL);
1332 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1335 int rk_gps_power_up(void)
1337 printk("%s \n", __FUNCTION__);
1342 int rk_gps_power_down(void)
1344 printk("%s \n", __FUNCTION__);
1349 int rk_gps_reset_set(int level)
1353 int rk_enable_hclk_gps(void)
1355 struct clk *gps_aclk = NULL;
1356 gps_aclk = clk_get(NULL, "aclk_gps");
1358 clk_enable(gps_aclk);
1360 printk("%s \n", __FUNCTION__);
1363 printk("get gps aclk fail\n");
1366 int rk_disable_hclk_gps(void)
1368 struct clk *gps_aclk = NULL;
1369 gps_aclk = clk_get(NULL, "aclk_gps");
1371 //TO wait long enough until GPS ISR is finished.
1373 clk_disable(gps_aclk);
1375 printk("%s \n", __FUNCTION__);
1378 printk("get gps aclk fail\n");
1381 struct rk_gps_data rk_gps_info = {
1382 .io_init = rk_gps_io_init,
1383 .power_up = rk_gps_power_up,
1384 .power_down = rk_gps_power_down,
1385 .reset = rk_gps_reset_set,
1386 .enable_hclk_gps = rk_enable_hclk_gps,
1387 .disable_hclk_gps = rk_disable_hclk_gps,
1388 .GpsSign = RK30_PIN1_PB3,
1389 .GpsMag = RK30_PIN1_PB2, //GPIO index
1390 .GpsClk = RK30_PIN1_PB4, //GPIO index
1391 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1392 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1393 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1394 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1398 .u32GpsPhyAddr = RK30_GPS_PHYS,
1399 .u32GpsPhySize = RK30_GPS_SIZE,
1402 struct platform_device rk_device_gps = {
1403 .name = "gps_hv5820b",
1406 .platform_data = &rk_gps_info,
1411 #if defined(CONFIG_MT5931_MT6622)
1412 static struct mt6622_platform_data mt6622_platdata = {
1413 .power_gpio = { // BT_REG_ON
1414 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1415 .enable = GPIO_HIGH,
1421 .reset_gpio = { // BT_RST
1422 .io = RK30_PIN0_PD7,
1423 .enable = GPIO_HIGH,
1430 .io = RK30_PIN0_PA5,
1437 .rts_gpio = { // UART_RTS
1438 .io = RK30_PIN1_PA3,
1448 static struct platform_device device_mt6622 = {
1452 .platform_data = &mt6622_platdata,
1457 #if defined CONFIG_TCC_BT_DEV
1458 static struct tcc_bt_platform_data tcc_bt_platdata = {
1460 .power_gpio = { // ldoon
1461 .io = RK30_PIN3_PC0,//difined depend on your harware
1462 .enable = GPIO_HIGH,
1468 .wake_host_gpio = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1469 .io = RK30_PIN0_PC5, // set io to INVALID_GPIO for disable it,it's depend on your hardware
1470 .enable = IRQF_TRIGGER_RISING,// set IRQF_TRIGGER_FALLING for falling, set IRQF_TRIGGER_RISING for rising
1477 static struct platform_device device_tcc_bt = {
1478 .name = "tcc_bt_dev",
1481 .platform_data = &tcc_bt_platdata,
1487 static struct platform_device *devices[] __initdata = {
1491 #ifdef CONFIG_ANDROID_TIMED_GPIO
1492 &rk29_device_vibrator,
1494 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1495 &rk29_device_gpio_leds,
1497 #ifdef CONFIG_RK_IRDA
1500 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1501 &rk29sdk_wifi_device,
1504 #if defined(CONFIG_MT6620)
1508 #ifdef CONFIG_RK29_SUPPORT_MODEM
1511 #if defined(CONFIG_MU509)
1514 #if defined(CONFIG_MW100)
1517 #if defined(CONFIG_MT6229)
1518 &rk29_device_mt6229,
1520 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1521 &rk30_device_adc_battery,
1523 #ifdef CONFIG_RFKILL_RK
1526 #ifdef CONFIG_GPS_RK
1530 #ifdef CONFIG_MT5931_MT6622
1533 #ifdef CONFIG_TCC_BT_DEV
1538 static int rk_platform_add_display_devices(void)
1540 struct platform_device *fb = NULL; //fb
1541 struct platform_device *lcdc0 = NULL; //lcdc0
1542 struct platform_device *lcdc1 = NULL; //lcdc1
1543 struct platform_device *bl = NULL; //backlight
1544 #ifdef CONFIG_FB_ROCKCHIP
1548 #if defined(CONFIG_LCDC0_RK3066B)
1549 lcdc0 = &device_lcdc0,
1552 #if defined(CONFIG_LCDC1_RK3066B)
1553 lcdc1 = &device_lcdc1,
1556 #ifdef CONFIG_BACKLIGHT_RK29_BL
1557 bl = &rk29_device_backlight,
1559 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1565 #ifdef CONFIG_MFD_TPS65910
1566 #define TPS65910_HOST_IRQ RK30_PIN0_PB5
1568 #define PMU_POWER_SLEEP RK30_PIN1_PB5
1570 static struct pmu_info tps65910_dcdc_info[] = {
1572 .name = "vdd_core", //logic
1577 .name = "vdd_cpu", //arm
1582 .name = "vio", //vcc_io
1588 static struct pmu_info tps65910_ldo_info[] = {
1590 .name = "vpll", //vdd10
1595 .name = "vdig1", //vcc18_cif
1600 .name = "vdig2", //vdd11
1605 .name = "vaux1", //vcc28_cif
1610 .name = "vaux2", //vcc33
1615 .name = "vaux33", //vcc_tp
1620 .name = "vmmc", //vcca30
1625 .name = "vdac", //vcc18
1631 #include "board-pmu-tps65910.c"
1633 #ifdef CONFIG_REGULATOR_ACT8931
1634 #define ACT8931_HOST_IRQ RK30_PIN0_PB5//depend on your hardware
1637 #define ACT8931_CHGSEL_PIN RK30_PIN0_PD0 //depend on your hardware
1640 static struct pmu_info act8931_dcdc_info[] = {
1642 .name = "vdd_core", //vdd_logic
1647 .name = "act_dcdc2", //ddr
1652 .name = "vdd_cpu", //vdd_arm
1658 static struct pmu_info act8931_ldo_info[] = {
1660 .name = "act_ldo1", //vcc28_cif
1665 .name = "act_ldo2", //vcc18_cif
1670 .name = "act_ldo3", //vcca30
1675 .name = "act_ldo4", //vcc_wl
1680 #include "board-rk30-sdk-act8931.c"
1684 #ifdef CONFIG_I2C0_RK30
1685 static struct i2c_board_info __initdata i2c0_info[] = {
1686 #if defined (CONFIG_MFD_TPS65910)
1689 .addr = TPS65910_I2C_ID0,
1691 .irq = TPS65910_HOST_IRQ,
1692 .platform_data = &tps65910_data,
1695 #if defined (CONFIG_REGULATOR_ACT8931)
1700 .irq = ACT8931_HOST_IRQ,
1701 .platform_data=&act8931_data,
1704 #if defined (CONFIG_GS_MMA8452)
1706 .type = "gs_mma8452",
1709 .irq = MMA8452_INT_PIN,
1710 .platform_data = &mma8452_info,
1713 #if defined (CONFIG_GS_LIS3DH)
1715 .type = "gs_lis3dh",
1716 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1718 .irq = LIS3DH_INT_PIN,
1719 .platform_data = &lis3dh_info,
1722 #if defined (CONFIG_COMPASS_AK8975)
1727 .irq = RK30_PIN3_PD7,
1728 .platform_data = &akm8975_info,
1731 #if defined (CONFIG_GYRO_L3G4200D)
1733 .type = "l3g4200d_gryo",
1736 .irq = L3G4200D_INT_PIN,
1737 .platform_data = &l3g4200d_info,
1740 #if defined (CONFIG_SND_SOC_RK1000)
1742 .type = "rk1000_i2c_codec",
1747 .type = "rk1000_control",
1752 #if defined (CONFIG_SND_SOC_RT5631)
1764 int __sramdata g_pmic_type = 0;
1765 #ifdef CONFIG_I2C1_RK30
1766 #ifdef CONFIG_MFD_WM831X_I2C
1767 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1769 static struct pmu_info wm8326_dcdc_info[] = {
1771 .name = "vdd_core", //logic
1774 .suspend_vol = 950000,
1777 .name = "vdd_cpu", //arm
1780 .suspend_vol = 950000,
1783 .name = "dcdc3", //ddr
1786 .suspend_vol = 1150000,
1788 #ifdef CONFIG_MACH_RK3066_SDK
1790 .name = "dcdc4", //vcc_io
1793 .suspend_vol = 3000000,
1797 .name = "dcdc4", //vcc_io
1800 .suspend_vol = 2800000,
1805 static struct pmu_info wm8326_ldo_info[] = {
1807 .name = "ldo1", //vcc18_cif
1810 .suspend_vol = 1800000,
1813 .name = "ldo2", //vccio_wl
1816 .suspend_vol = 1800000,
1822 .suspend_vol = 1100000,
1825 .name = "ldo4", //vdd11
1828 .suspend_vol = 1000000,
1831 .name = "ldo5", //vcc25
1834 .suspend_vol = 1800000,
1837 .name = "ldo6", //vcc33
1840 .suspend_vol = 3300000,
1843 .name = "ldo7", //vcc28_cif
1846 .suspend_vol = 2800000,
1849 .name = "ldo8", //vcca33
1852 .suspend_vol = 3300000,
1855 .name = "ldo9", //vcc_tp
1858 .suspend_vol = 3300000,
1861 .name = "ldo10", //flash_io
1864 .suspend_vol = 1800000,
1868 #include "../mach-rk30/board-pmu-wm8326.c"
1871 #ifdef CONFIG_REGULATOR_ACT8846
1872 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1873 #define PMU_VSEL RK30_PIN3_PD3
1874 static struct pmu_info act8846_dcdc_info[] = {
1876 .name = "act_dcdc1", //ddr
1879 .suspend_vol = 1200000,
1882 .name = "vdd_core", //logic
1885 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1886 .suspend_vol = 1200000,
1888 .suspend_vol = 900000,
1893 .name = "vdd_cpu", //arm
1896 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1897 .suspend_vol = 1200000,
1899 .suspend_vol = 900000,
1904 .name = "act_dcdc4", //vccio
1907 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1908 .suspend_vol = 3000000,
1910 .suspend_vol = 2800000,
1916 static struct pmu_info act8846_ldo_info[] = {
1918 .name = "act_ldo1", //vdd11
1923 .name = "act_ldo2", //vdd12
1928 .name = "act_ldo3", //vcc18_cif
1933 .name = "act_ldo4", //vcca33
1938 .name = "act_ldo5", //vcctp
1943 .name = "act_ldo6", //vcc33
1948 .name = "act_ldo7", //vccio_wl
1953 .name = "act_ldo8", //vcc28_cif
1959 #include "../mach-rk30/board-pmu-act8846.c"
1963 static struct i2c_board_info __initdata i2c1_info[] = {
1964 #if defined (CONFIG_MFD_WM831X_I2C)
1969 .irq = RK30_PIN0_PB3,
1970 .platform_data = &wm831x_platdata,
1973 #if defined (CONFIG_REGULATOR_ACT8846)
1978 // .irq = ACT8846_HOST_IRQ,
1979 .platform_data=&act8846_data,
1982 #if defined (CONFIG_RTC_HYM8563)
1984 .type = "rtc_hym8563",
1987 .irq = RK30_PIN1_PA4,
1990 #if defined (CONFIG_GS_MXC6225)
1992 .type = "gs_mxc6225",
1995 .irq = MXC6225_INT_PIN,
1996 .platform_data = &mxc6225_info,
2002 void __sramfunc board_pmu_suspend(void)
2004 #if defined (CONFIG_MFD_WM831X_I2C)
2005 if(pmic_is_wm8326())
2006 board_pmu_wm8326_suspend();
2008 #if defined (CONFIG_MFD_TPS65910)
2009 if(pmic_is_tps65910())
2010 board_pmu_tps65910_suspend();
2012 #if defined (CONFIG_REGULATOR_ACT8846)
2013 if(pmic_is_act8846())
2014 board_pmu_act8846_suspend();
2019 void __sramfunc board_pmu_resume(void)
2021 #if defined (CONFIG_MFD_WM831X_I2C)
2022 if(pmic_is_wm8326())
2023 board_pmu_wm8326_resume();
2025 #if defined (CONFIG_MFD_TPS65910)
2026 if(pmic_is_tps65910())
2027 board_pmu_tps65910_resume();
2029 #if defined (CONFIG_REGULATOR_ACT8846)
2030 if(pmic_is_act8846())
2031 board_pmu_act8846_resume();
2035 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
2037 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
2038 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
2040 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
2042 #ifdef CONFIG_RK30_PWM_REGULATOR
2044 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
2046 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
2047 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
2048 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
2049 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
2051 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
2052 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
2053 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
2054 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
2057 void __sramfunc rk30_pwm_logic_resume_voltage(void)
2059 #ifdef CONFIG_RK30_PWM_REGULATOR
2060 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
2061 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
2062 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
2063 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
2069 extern void pwm_suspend_voltage(void);
2070 extern void pwm_resume_voltage(void);
2071 void rk30_pwm_suspend_voltage_set(void)
2073 #ifdef CONFIG_RK30_PWM_REGULATOR
2074 pwm_suspend_voltage();
2077 void rk30_pwm_resume_voltage_set(void)
2079 #ifdef CONFIG_RK30_PWM_REGULATOR
2080 pwm_resume_voltage();
2085 #ifdef CONFIG_I2C2_RK30
2086 static struct i2c_board_info __initdata i2c2_info[] = {
2087 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
2089 .type = "Goodix-TS",
2092 .irq = RK30_PIN0_PB4,
2093 .platform_data = &goodix_info,
2096 #if defined (CONFIG_LS_CM3217)
2098 .type = "lightsensor",
2101 .platform_data = &cm3217_info,
2104 #if defined (CONFIG_TOUCHSCREEN_GSLX680_RK3028)
2109 .platform_data =&gslx680_info,
2116 #ifdef CONFIG_I2C3_RK30
2117 static struct i2c_board_info __initdata i2c3_info[] = {
2121 #ifdef CONFIG_I2C4_RK30
2122 static struct i2c_board_info __initdata i2c4_info[] = {
2123 #ifdef CONFIG_MFD_RK610
2125 .type = "rk610_ctl",
2128 .platform_data = &rk610_ctl_pdata,
2130 #ifdef CONFIG_RK610_TVOUT
2132 .type = "rk610_tvout",
2137 #ifdef CONFIG_HDMI_RK610
2139 .type = "rk610_hdmi",
2142 .irq = INVALID_GPIO,
2145 #ifdef CONFIG_SND_SOC_RK610
2146 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
2147 .type = "rk610_i2c_codec",
2150 .platform_data = &rk610_codec_pdata,
2158 #ifdef CONFIG_I2C_GPIO_RK30
2159 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2160 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2161 static int rk30_i2c_io_init(void)
2163 //set iomux (gpio) here
2164 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2165 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2169 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2170 .sda_pin = I2C_SDA_PIN,
2171 .scl_pin = I2C_SCL_PIN,
2172 .udelay = 5, // clk = 500/udelay = 100Khz
2173 .timeout = 100,//msecs_to_jiffies(100),
2175 .io_init = rk30_i2c_io_init,
2177 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2181 static void __init rk30_i2c_register_board_info(void)
2183 #ifdef CONFIG_I2C0_RK30
2184 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2186 #ifdef CONFIG_I2C1_RK30
2187 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2189 #ifdef CONFIG_I2C2_RK30
2190 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2192 #ifdef CONFIG_I2C3_RK30
2193 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2195 #ifdef CONFIG_I2C4_RK30
2196 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2198 #ifdef CONFIG_I2C_GPIO_RK30
2199 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2204 // ========== Begin of rk3168 top board keypad defination ============
2206 #include <plat/key.h>
2208 static struct rk29_keys_button key_button[] = {
2212 .gpio = RK30_PIN1_PB4,
2213 .active_low = PRESS_LEV_LOW,
2217 struct rk29_keys_platform_data rk29_keys_pdata = {
2218 .buttons = key_button,
2219 .nbuttons = ARRAY_SIZE(key_button),
2220 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
2223 // =========== End of rk3168 top board keypad defination =============
2226 #define POWER_ON_PIN RK30_PIN0_PD5 //power_hold
2227 static void rk30_pm_power_off(void)
2229 printk(KERN_ERR "rk30_pm_power_off start...\n");
2230 #if defined(CONFIG_MFD_WM831X)
2231 if(pmic_is_wm8326()){
2232 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2233 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2237 #if defined(CONFIG_REGULATOR_ACT8846)
2238 if(pmic_is_act8846())
2240 act8846_device_shutdown();
2244 #if defined(CONFIG_MFD_TPS65910)
2245 if(pmic_is_tps65910())
2247 tps65910_device_shutdown();//tps65910 shutdown
2250 #if defined(CONFIG_REGULATOR_ACT8931)
2251 if(pmic_is_act8931())
2253 act8931_device_shutdown();//act8931 shutdown
2257 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2261 static void __init machine_rk30_board_init(void)
2264 gpio_request(POWER_ON_PIN, "poweronpin");
2265 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2267 pm_power_off = rk30_pm_power_off;
2269 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2272 rk30_i2c_register_board_info();
2273 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2274 platform_add_devices(devices, ARRAY_SIZE(devices));
2275 rk_platform_add_display_devices();
2276 board_usb_detect_init(RK30_PIN0_PA4);
2278 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2279 rk29sdk_wifi_bt_gpio_control_init();
2280 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2281 rk29sdk_wifi_combo_module_gpio_init();
2284 #if defined(CONFIG_MT6620)
2285 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2288 #if defined(CONFIG_MT5931_MT6622)
2289 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2293 static void __init rk30_reserve(void)
2296 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2298 #ifdef CONFIG_FB_ROCKCHIP
2299 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2300 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2302 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2303 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2306 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2307 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2308 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2312 #ifdef CONFIG_VIDEO_RK29
2313 rk30_camera_request_reserve_mem();
2316 #ifdef CONFIG_GPS_RK
2317 //it must be more than 8MB
2318 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2320 board_mem_reserved();
2324 * dvfs_cpu_logic_table: table for arm and logic dvfs
2325 * @frequency : arm frequency
2326 * @cpu_volt : arm voltage depend on frequency
2327 * @logic_volt : logic voltage arm requests depend on frequency
2328 * comments : min arm/logic voltage
2330 #ifdef CONFIG_DVFS_WITH_UOC
2332 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2333 {.frequency = 312 * 1000, .index = 950 * 1000},
2334 {.frequency = 504 * 1000, .index = 1000 * 1000},
2335 {.frequency = 816 * 1000, .index = 1050 * 1000},
2336 {.frequency = 1008 * 1000, .index = 1125 * 1000},
2337 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2338 {.frequency = CPUFREQ_TABLE_END},
2341 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2342 {.frequency = 100 * 1000, .index = 1000 * 1000},
2343 {.frequency = 200 * 1000, .index = 1000 * 1000},
2344 {.frequency = 266 * 1000, .index = 1050 * 1000},
2345 //{.frequency = 300 * 1000, .index = 1050 * 1000},
2346 {.frequency = 400 * 1000, .index = 1125 * 1000},
2347 {.frequency = CPUFREQ_TABLE_END},
2350 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2351 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1000 * 1000},
2352 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2353 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2354 {.frequency = CPUFREQ_TABLE_END},
2358 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2359 {.frequency = 312 * 1000, .index = 1000 * 1000},
2360 {.frequency = 504 * 1000, .index = 1050 * 1000},
2361 {.frequency = 816 * 1000, .index = 1100 * 1000},
2362 {.frequency = 1008 * 1000, .index = 1150 * 1000},
2363 //{.frequency = 1200 * 1000, .index = 1200 * 1000},
2364 //{.frequency = 1416 * 1000, .index = 1250 * 1000},
2365 {.frequency = CPUFREQ_TABLE_END},
2368 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2369 {.frequency = 100 * 1000, .index = 1000 * 1000},
2370 {.frequency = 200 * 1000, .index = 1000 * 1000},
2371 {.frequency = 266 * 1000, .index = 1050 * 1000},
2372 {.frequency = 300 * 1000, .index = 1050 * 1000},
2373 {.frequency = 400 * 1000, .index = 1125 * 1000},
2374 {.frequency = CPUFREQ_TABLE_END},
2377 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2378 //{.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1000 * 1000},
2379 //{.frequency = 240 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2380 {.frequency = 336 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2381 {.frequency = CPUFREQ_TABLE_END},
2384 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2385 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2386 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2387 int get_max_freq(struct cpufreq_frequency_table *table)
2391 for(i=0;table[i].frequency!= CPUFREQ_TABLE_END;i++)
2393 if(temp<table[i].frequency)
2394 temp=table[i].frequency;
2396 printk("get_max_freq=%d\n",temp);
2400 void __init board_clock_init(void)
2402 u32 flags=RK30_CLOCKS_DEFAULT_FLAGS;
2403 #if !defined(CONFIG_ARCH_RK3188)
2404 if(get_max_freq(dvfs_gpu_table)<=(400*1000))
2406 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_GPLL;
2409 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_CPLL;
2411 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2412 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2413 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2414 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2415 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2418 MACHINE_START(RK30, "RK30board")
2419 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2420 .fixup = rk30_fixup,
2421 .reserve = &rk30_reserve,
2422 .map_io = rk30_map_io,
2423 .init_irq = rk30_init_irq,
2424 .timer = &rk30_timer,
2425 .init_machine = machine_rk30_board_init,