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/mfd/rk808.h>
50 #include <linux/regulator/rk29-pwm-regulator.h>
52 #ifdef CONFIG_CW2015_BATTERY
53 #include <linux/power/cw2015_battery.h>
55 #if defined(CONFIG_MFD_RK610)
56 #include <linux/mfd/rk610_core.h>
59 #if defined(CONFIG_MFD_RK616)
60 #include <linux/mfd/rk616.h>
64 #if defined(CONFIG_RK_HDMI)
65 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
68 #if defined(CONFIG_SPIM_RK29)
69 #include "../../../drivers/spi/rk29_spim.h"
71 #if defined(CONFIG_GPS_RK)
72 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
74 #if defined(CONFIG_MU509)
75 #include <linux/mu509.h>
77 #if defined(CONFIG_MW100)
78 #include <linux/mw100.h>
80 #if defined(CONFIG_MT6229)
81 #include <linux/mt6229.h>
83 #if defined(CONFIG_ANDROID_TIMED_GPIO)
84 #include "../../../drivers/staging/android/timed_gpio.h"
87 #if defined(CONFIG_MT6620)
88 #include <linux/gps.h>
90 #include "../mach-rk30/board-rk3168-tb-camera.c"
92 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
93 #define TOUCH_RESET_PIN RK30_PIN0_PB6
94 #define TOUCH_PWR_PIN RK30_PIN0_PC5 // need to fly line by hardware engineer
96 /* Android Parameter */
97 static int ap_mdm = 0;
98 module_param(ap_mdm, int, 0644);
99 static int ap_has_alsa = 0;
100 module_param(ap_has_alsa, int, 0644);
101 static int ap_data_only = 2;
102 module_param(ap_data_only, int, 0644);
103 static int ap_has_earphone = 0;
104 module_param(ap_has_earphone, int, 0644);
107 static int goodix_init_platform_hw(void)
111 if (TOUCH_PWR_PIN != INVALID_GPIO) {
112 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
114 gpio_free(TOUCH_PWR_PIN);
115 printk("goodix power error\n");
118 gpio_direction_output(TOUCH_PWR_PIN, 0);
119 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
123 if (TOUCH_RESET_PIN != INVALID_GPIO) {
124 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
126 gpio_free(TOUCH_RESET_PIN);
127 printk("goodix gpio_request error\n");
130 gpio_direction_output(TOUCH_RESET_PIN, 1);
132 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
134 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
140 struct goodix_platform_data goodix_info = {
142 .irq_pin = RK30_PIN1_PB7,
143 .rest_pin = TOUCH_RESET_PIN,
144 .init_platform_hw = goodix_init_platform_hw,
148 static struct spi_board_info board_spi_devices[] = {
151 /***********************************************************
153 ************************************************************/
154 #ifdef CONFIG_BACKLIGHT_RK29_BL
156 #define PWM_MODE PWM3
157 #define PWM_EFFECT_VALUE 1
159 #define LCD_DISP_ON_PIN
161 #ifdef LCD_DISP_ON_PIN
162 #define BL_EN_PIN RK30_PIN0_PA2
163 #define BL_EN_VALUE GPIO_HIGH
165 static int rk29_backlight_io_init(void)
170 #ifdef LCD_DISP_ON_PIN
171 ret = gpio_request(BL_EN_PIN, "bl_en");
173 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
179 static int rk29_backlight_io_deinit(void)
181 int ret = 0, pwm_gpio;
182 #ifdef LCD_DISP_ON_PIN
183 gpio_free(BL_EN_PIN);
185 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
186 gpio_request(pwm_gpio, "bl_pwm");
187 gpio_direction_output(pwm_gpio, GPIO_LOW);
191 static int rk29_backlight_pwm_suspend(void)
193 int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
195 ret = gpio_request(pwm_gpio, "bl_pwm");
197 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
200 gpio_direction_output(pwm_gpio, GPIO_LOW);
201 #ifdef LCD_DISP_ON_PIN
202 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
207 static int rk29_backlight_pwm_resume(void)
209 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
213 #ifdef LCD_DISP_ON_PIN
215 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
220 static struct rk29_bl_info rk29_bl_info = {
224 .brightness_mode =BRIGHTNESS_MODE_CONIC,
225 .bl_ref = PWM_EFFECT_VALUE,
226 .io_init = rk29_backlight_io_init,
227 .io_deinit = rk29_backlight_io_deinit,
228 .pwm_suspend = rk29_backlight_pwm_suspend,
229 .pwm_resume = rk29_backlight_pwm_resume,
232 static struct platform_device rk29_device_backlight = {
233 .name = "rk29_backlight",
236 .platform_data = &rk29_bl_info,
242 #ifdef CONFIG_RK29_SUPPORT_MODEM
244 #define RK30_MODEM_POWER RK30_PIN0_PC6
245 #define RK30_MODEM_POWER_IOMUX iomux_set(GPIO0_C6)
247 static int rk30_modem_io_init(void)
249 printk("%s\n", __FUNCTION__);
250 RK30_MODEM_POWER_IOMUX;
255 static struct rk29_io_t rk30_modem_io = {
256 .io_addr = RK30_MODEM_POWER,
259 .io_init = rk30_modem_io_init,
262 static struct platform_device rk30_device_modem = {
263 .name = "rk30_modem",
266 .platform_data = &rk30_modem_io,
270 #if defined(CONFIG_MU509)
271 static int mu509_io_init(void)
282 static int mu509_io_deinit(void)
288 struct rk29_mu509_data rk29_mu509_info = {
289 .io_init = mu509_io_init,
290 .io_deinit = mu509_io_deinit,
291 .modem_power_en = RK30_PIN2_PD5,
292 .bp_power = RK30_PIN0_PC6,
293 .bp_reset = RK30_PIN2_PD4,
294 .ap_wakeup_bp = RK30_PIN0_PC4,
295 .bp_wakeup_ap = RK30_PIN0_PC5,
297 struct platform_device rk29_device_mu509 = {
301 .platform_data = &rk29_mu509_info,
305 #if defined(CONFIG_MW100)
306 static int mw100_io_init(void)
316 static int mw100_io_deinit(void)
322 struct rk29_mw100_data rk29_mw100_info = {
323 .io_init = mw100_io_init,
324 .io_deinit = mw100_io_deinit,
325 .modem_power_en = RK30_PIN2_PD5,
326 .bp_power = RK30_PIN0_PC6,
327 .bp_reset = RK30_PIN2_PD4,
328 .ap_wakeup_bp = RK30_PIN0_PC4,
329 .bp_wakeup_ap = RK30_PIN0_PC5,
331 struct platform_device rk29_device_mw100 = {
335 .platform_data = &rk29_mw100_info,
339 #if defined(CONFIG_MT6229)
340 static int mt6229_io_init(void)
350 static int mt6229_io_deinit(void)
356 struct rk29_mt6229_data rk29_mt6229_info = {
357 .io_init = mt6229_io_init,
358 .io_deinit = mt6229_io_deinit,
359 .modem_power_en = RK30_PIN2_PD5,
360 .bp_power = RK30_PIN0_PC6,
361 .bp_reset = RK30_PIN2_PD4,
362 .ap_wakeup_bp = RK30_PIN0_PC4,
363 .bp_wakeup_ap = RK30_PIN0_PC5,
365 struct platform_device rk29_device_mt6229 = {
369 .platform_data = &rk29_mt6229_info,
375 #if defined (CONFIG_GS_MMA8452)
376 #define MMA8452_INT_PIN RK30_PIN0_PB7
378 static int mma8452_init_platform_hw(void)
383 static struct sensor_platform_data mma8452_info = {
384 .type = SENSOR_TYPE_ACCEL,
387 .init_platform_hw = mma8452_init_platform_hw,
388 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
391 #if defined (CONFIG_GS_LIS3DH)
392 #define LIS3DH_INT_PIN RK30_PIN0_PB7
394 static int lis3dh_init_platform_hw(void)
400 static struct sensor_platform_data lis3dh_info = {
401 .type = SENSOR_TYPE_ACCEL,
404 .init_platform_hw = lis3dh_init_platform_hw,
405 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
408 #if defined (CONFIG_COMPASS_AK8975)
409 static struct sensor_platform_data akm8975_info =
411 .type = SENSOR_TYPE_COMPASS,
444 #if defined(CONFIG_GYRO_L3G4200D)
446 #include <linux/l3g4200d.h>
447 #define L3G4200D_INT_PIN RK30_PIN0_PB4
449 static int l3g4200d_init_platform_hw(void)
454 static struct sensor_platform_data l3g4200d_info = {
455 .type = SENSOR_TYPE_GYROSCOPE,
458 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
459 .init_platform_hw = l3g4200d_init_platform_hw,
460 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
467 #ifdef CONFIG_LS_CM3217
468 static struct sensor_platform_data cm3217_info = {
469 .type = SENSOR_TYPE_LIGHT,
471 .poll_delay_ms = 500,
476 #ifdef CONFIG_FB_ROCKCHIP
478 #define LCD_CS_PIN INVALID_GPIO
479 #define LCD_CS_VALUE GPIO_HIGH
481 #define LCD_EN_PIN RK30_PIN0_PB0
482 #if defined(CONFIG_MACH_RK3188_RK618)
483 #define MIPI_LCD_RST_PIN RK30_PIN0_PC3 //mipi lcd's reset pin, if no reset pin, set's INVALID_GPIO
484 #define LCD_EN_VALUE GPIO_LOW
486 #define LCD_EN_VALUE GPIO_HIGH
489 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
494 if(LCD_CS_PIN !=INVALID_GPIO)
496 ret = gpio_request(LCD_CS_PIN, NULL);
499 gpio_free(LCD_CS_PIN);
500 printk(KERN_ERR "request lcd cs pin fail!\n");
505 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
509 if(LCD_EN_PIN !=INVALID_GPIO)
511 ret = gpio_request(LCD_EN_PIN, NULL);
514 gpio_free(LCD_EN_PIN);
515 printk(KERN_ERR "request lcd en pin fail!\n");
520 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
524 if(MIPI_LCD_RST_PIN !=INVALID_GPIO)
526 ret = gpio_request(MIPI_LCD_RST_PIN, NULL);
529 gpio_free(MIPI_LCD_RST_PIN);
530 printk(KERN_ERR "request mipi lcd rst pin fail!\n");
536 gpio_set_value(MIPI_LCD_RST_PIN, !GPIO_LOW);
542 static int rk_fb_io_disable(void)
544 if(LCD_CS_PIN !=INVALID_GPIO)
546 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
549 if(LCD_EN_PIN !=INVALID_GPIO)
551 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
554 if(MIPI_LCD_RST_PIN !=INVALID_GPIO)
556 gpio_set_value(MIPI_LCD_RST_PIN, GPIO_LOW);
562 static int rk_fb_io_enable(void)
564 if(LCD_CS_PIN !=INVALID_GPIO)
566 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
569 if(LCD_EN_PIN !=INVALID_GPIO)
571 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
574 if(MIPI_LCD_RST_PIN !=INVALID_GPIO)
576 gpio_set_value(MIPI_LCD_RST_PIN, !GPIO_LOW);
582 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
583 struct rk29fb_info lcdc0_screen_info = {
584 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
585 .prop = EXTEND, //extend display device
589 .set_screen_info = hdmi_init_lcdc,
591 .prop = PRMRY, //primary display device
592 .io_init = rk_fb_io_init,
593 .io_disable = rk_fb_io_disable,
594 .io_enable = rk_fb_io_enable,
595 .set_screen_info = set_lcd_info,
600 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
601 struct rk29fb_info lcdc1_screen_info = {
602 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
603 .prop = EXTEND, //extend display device
607 .set_screen_info = hdmi_init_lcdc,
609 .prop = PRMRY, //primary display device
610 .io_init = rk_fb_io_init,
611 .io_disable = rk_fb_io_disable,
612 .io_enable = rk_fb_io_enable,
613 .set_screen_info = set_lcd_info,
619 static struct resource resource_fb[] = {
623 .end = 0,//RK30_FB0_MEM_SIZE - 1,
624 .flags = IORESOURCE_MEM,
627 .name = "ipp buf", //for rotate
629 .end = 0,//RK30_FB0_MEM_SIZE - 1,
630 .flags = IORESOURCE_MEM,
635 .end = 0,//RK30_FB0_MEM_SIZE - 1,
636 .flags = IORESOURCE_MEM,
640 static struct platform_device device_fb = {
643 .num_resources = ARRAY_SIZE(resource_fb),
644 .resource = resource_fb,
647 #if defined(CONFIG_ARCH_RK3188)
648 static struct resource resource_mali[] = {
653 .flags = IORESOURCE_MEM,
658 static struct platform_device device_mali= {
659 .name = "mali400_ump",
661 .num_resources = ARRAY_SIZE(resource_mali),
662 .resource = resource_mali,
666 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
667 static struct resource resource_lcdc0[] = {
670 .start = RK30_LCDC0_PHYS,
671 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
672 .flags = IORESOURCE_MEM,
679 .flags = IORESOURCE_IRQ,
683 static struct platform_device device_lcdc0 = {
686 .num_resources = ARRAY_SIZE(resource_lcdc0),
687 .resource = resource_lcdc0,
689 .platform_data = &lcdc0_screen_info,
693 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
694 static struct resource resource_lcdc1[] = {
697 .start = RK30_LCDC1_PHYS,
698 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
699 .flags = IORESOURCE_MEM,
705 .flags = IORESOURCE_IRQ,
709 static struct platform_device device_lcdc1 = {
712 .num_resources = ARRAY_SIZE(resource_lcdc1),
713 .resource = resource_lcdc1,
715 .platform_data = &lcdc1_screen_info,
720 #if defined(CONFIG_MFD_RK610)
721 #define RK610_RST_PIN RK30_PIN2_PC5
722 static int rk610_power_on_init(void)
725 if(RK610_RST_PIN != INVALID_GPIO)
727 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
730 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
734 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
736 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
738 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
747 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
748 .rk610_power_on_init = rk610_power_on_init,
752 #if defined(CONFIG_MFD_RK616)
753 #define RK616_RST_PIN RK30_PIN3_PB2
755 #if defined(CONFIG_MACH_RK3188_RK618)
756 #define RK616_PWREN_PIN INVALID_GPIO
758 #define RK616_PWREN_PIN RK30_PIN0_PA3
760 #define RK616_SCL_RATE (100*1000) //i2c scl rate
761 static int rk616_power_on_init(void)
765 if(RK616_PWREN_PIN != INVALID_GPIO)
767 ret = gpio_request(RK616_PWREN_PIN, "rk616 pwren");
770 printk(KERN_ERR "rk616 pwren gpio request fail\n");
774 gpio_direction_output(RK616_PWREN_PIN,GPIO_HIGH);
778 if(RK616_RST_PIN != INVALID_GPIO)
780 ret = gpio_request(RK616_RST_PIN, "rk616 reset");
783 printk(KERN_ERR "rk616 reset gpio request fail\n");
787 gpio_direction_output(RK616_RST_PIN, GPIO_HIGH);
789 gpio_direction_output(RK616_RST_PIN, GPIO_LOW);
791 gpio_set_value(RK616_RST_PIN, GPIO_HIGH);
800 static int rk616_power_deinit(void)
802 gpio_set_value(RK616_PWREN_PIN,GPIO_LOW);
803 gpio_set_value(RK616_RST_PIN,GPIO_LOW);
804 gpio_free(RK616_PWREN_PIN);
805 gpio_free(RK616_RST_PIN);
810 static struct rk616_platform_data rk616_pdata = {
811 .power_init = rk616_power_on_init,
812 .power_deinit = rk616_power_deinit,
813 .scl_rate = RK616_SCL_RATE,
814 .lcd0_func = INPUT, //port lcd0 as input
815 .lcd1_func = INPUT, //port lcd1 as input
816 .lvds_ch_nr = 1, //the number of used lvds channel
817 .hdmi_irq = RK30_PIN2_PD6,
818 .spk_ctl_gpio = RK30_PIN2_PD7,
819 .hp_ctl_gpio = RK30_PIN2_PD7,
823 #ifdef CONFIG_SND_SOC_RK610
824 static int rk610_codec_io_init(void)
827 //Must not gpio_request
831 static struct rk610_codec_platform_data rk610_codec_pdata = {
832 .spk_ctl_io = RK30_PIN2_PD7,
833 .io_init = rk610_codec_io_init,
837 #ifdef CONFIG_ANDROID_TIMED_GPIO
838 static struct timed_gpio timed_gpios[] = {
841 .gpio = INVALID_GPIO,
844 .adjust_time =20, //adjust for diff product
848 static struct timed_gpio_platform_data rk29_vibrator_info = {
850 .gpios = timed_gpios,
853 static struct platform_device rk29_device_vibrator = {
854 .name = "timed-gpio",
857 .platform_data = &rk29_vibrator_info,
863 #ifdef CONFIG_LEDS_GPIO_PLATFORM
864 static struct gpio_led rk29_leds[] = {
866 .name = "button-backlight",
867 .gpio = INVALID_GPIO,
868 .default_trigger = "timer",
870 .retain_state_suspended = 0,
871 .default_state = LEDS_GPIO_DEFSTATE_OFF,
875 static struct gpio_led_platform_data rk29_leds_pdata = {
877 .num_leds = ARRAY_SIZE(rk29_leds),
880 static struct platform_device rk29_device_gpio_leds = {
884 .platform_data = &rk29_leds_pdata,
889 #ifdef CONFIG_RK_IRDA
890 #define IRDA_IRQ_PIN INVALID_GPIO //RK30_PIN0_PA3
892 static int irda_iomux_init(void)
897 ret = gpio_request(IRDA_IRQ_PIN, NULL);
899 gpio_free(IRDA_IRQ_PIN);
900 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
902 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
903 gpio_direction_input(IRDA_IRQ_PIN);
908 static int irda_iomux_deinit(void)
910 gpio_free(IRDA_IRQ_PIN);
914 static struct irda_info rk29_irda_info = {
915 .intr_pin = IRDA_IRQ_PIN,
916 .iomux_init = irda_iomux_init,
917 .iomux_deinit = irda_iomux_deinit,
918 //.irda_pwr_ctl = bu92747guw_power_ctl,
921 static struct platform_device irda_device = {
922 #ifdef CONFIG_RK_IRDA_NET
925 .name = "bu92747_irda",
929 .platform_data = &rk29_irda_info,
935 #define ION_RESERVE_SIZE (80 * SZ_1M)
936 static struct ion_platform_data rk30_ion_pdata = {
940 .type = ION_HEAP_TYPE_CARVEOUT,
941 .id = ION_NOR_HEAP_ID,
943 .size = ION_RESERVE_SIZE,
948 static struct platform_device device_ion = {
949 .name = "ion-rockchip",
952 .platform_data = &rk30_ion_pdata,
957 /**************************************************************************************************
958 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
959 **************************************************************************************************/
960 #ifdef CONFIG_SDMMC_RK29
961 #include "../mach-rk30/board-rk3168-tb-sdmmc-conifg.c"
962 #include "../plat-rk/rk-sdmmc-ops.c"
963 #include "../plat-rk/rk-sdmmc-wifi.c"
964 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
966 #ifdef CONFIG_SDMMC0_RK29
967 static int rk29_sdmmc0_cfg_gpio(void)
969 #ifdef CONFIG_SDMMC_RK29_OLD
971 iomux_set(MMC0_CLKOUT);
977 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
979 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
980 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
983 rk29_sdmmc_set_iomux(0, 0xFFFF);
985 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
986 #if SDMMC_USE_NEW_IOMUX_API
987 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
989 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
992 #if SDMMC_USE_NEW_IOMUX_API
993 iomux_set(MMC0_DETN);
995 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
999 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1000 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1001 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1009 #define CONFIG_SDMMC0_USE_DMA
1010 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1012 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1013 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1014 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1016 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1017 .io_init = rk29_sdmmc0_cfg_gpio,
1019 #if !defined(CONFIG_SDMMC_RK29_OLD)
1020 .set_iomux = rk29_sdmmc_set_iomux,
1023 .dma_name = "sd_mmc",
1024 #ifdef CONFIG_SDMMC0_USE_DMA
1030 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1031 .status = rk29sdk_wifi_mmc0_status,
1032 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1035 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1036 .power_en = RK29SDK_SD_CARD_PWR_EN,
1037 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1039 .power_en = INVALID_GPIO,
1040 .power_en_level = GPIO_LOW,
1042 .enable_sd_wakeup = 0,
1044 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1045 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1046 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1048 .write_prt = INVALID_GPIO,
1052 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1053 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1054 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1055 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1057 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1058 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1059 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1061 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1062 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1073 #endif // CONFIG_SDMMC0_RK29
1075 #ifdef CONFIG_SDMMC1_RK29
1076 #define CONFIG_SDMMC1_USE_DMA
1077 static int rk29_sdmmc1_cfg_gpio(void)
1079 #if defined(CONFIG_SDMMC_RK29_OLD)
1080 iomux_set(MMC1_CMD);
1081 iomux_set(MMC1_CLKOUT);
1088 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1089 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1090 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1098 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1100 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1101 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1104 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1105 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1106 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1109 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1112 .io_init = rk29_sdmmc1_cfg_gpio,
1114 #if !defined(CONFIG_SDMMC_RK29_OLD)
1115 .set_iomux = rk29_sdmmc_set_iomux,
1119 #ifdef CONFIG_SDMMC1_USE_DMA
1125 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1126 .status = rk29sdk_wifi_status,
1127 .register_status_notify = rk29sdk_wifi_status_register,
1130 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1131 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1132 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1134 .write_prt = INVALID_GPIO,
1137 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1138 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1142 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1143 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1144 .io = RK29SDK_SD_CARD_DETECT_N,
1149 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1150 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1152 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1153 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1154 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1156 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1157 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1167 .enable_sd_wakeup = 0,
1169 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1171 /**************************************************************************************************
1172 * the end of setting for SDMMC devices
1173 **************************************************************************************************/
1175 #ifdef CONFIG_BATTERY_RK30_ADC
1176 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1177 .dc_det_pin = RK30_PIN0_PB2,
1178 .batt_low_pin = RK30_PIN0_PB1,
1179 .charge_set_pin = INVALID_GPIO,
1180 .charge_ok_pin = RK30_PIN0_PA6,
1181 .dc_det_level = GPIO_LOW,
1182 .charge_ok_level = GPIO_HIGH,
1185 static struct platform_device rk30_device_adc_battery = {
1186 .name = "rk30-battery",
1189 .platform_data = &rk30_adc_battery_platdata,
1193 #ifdef CONFIG_CW2015_BATTERY
1195 note the follow array must set depend on the battery that you use
1196 you must send the battery to cellwise-semi the contact information:
1197 name: chen gan; tel:13416876079; E-mail: ben.chen@cellwise-semi.com
1199 static u8 config_info[SIZE_BATINFO] = {
1200 0x15, 0x42, 0x60, 0x59, 0x52,
1201 0x58, 0x4D, 0x48, 0x48, 0x44,
1202 0x44, 0x46, 0x49, 0x48, 0x32,
1203 0x24, 0x20, 0x17, 0x13, 0x0F,
1204 0x19, 0x3E, 0x51, 0x45, 0x08,
1205 0x76, 0x0B, 0x85, 0x0E, 0x1C,
1206 0x2E, 0x3E, 0x4D, 0x52, 0x52,
1207 0x57, 0x3D, 0x1B, 0x6A, 0x2D,
1208 0x25, 0x43, 0x52, 0x87, 0x8F,
1209 0x91, 0x94, 0x52, 0x82, 0x8C,
1210 0x92, 0x96, 0xFF, 0x7B, 0xBB,
1211 0xCB, 0x2F, 0x7D, 0x72, 0xA5,
1212 0xB5, 0xC1, 0x46, 0xAE
1215 static struct cw_bat_platform_data cw_bat_platdata = {
1216 .dc_det_pin = RK30_PIN0_PB2,
1217 .bat_low_pin = RK30_PIN0_PB1,
1218 .chg_ok_pin = RK30_PIN0_PA6,
1219 .dc_det_level = GPIO_LOW,
1220 .bat_low_level = GPIO_LOW,
1221 .chg_ok_level = GPIO_HIGH,
1223 .cw_bat_config_info = config_info,
1228 #ifdef CONFIG_RK30_PWM_REGULATOR
1229 static int pwm_voltage_map[] = {
1230 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1232 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1234 .supply = "vdd_cpu",
1238 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1242 .name = "PWM_DCDC1",
1244 .max_uV = 1800000, //0.6-1.8V
1246 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1248 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1249 .consumer_supplies = pwm_dcdc1_consumers,
1253 static struct pwm_platform_data pwm_regulator_info[1] = {
1256 .pwm_gpio = RK30_PIN3_PD4,
1257 .pwm_iomux_pwm = PWM1,
1258 .pwm_iomux_gpio = GPIO3_D4,
1259 .pwm_voltage = 1100000,
1260 .suspend_voltage = 1000000,
1263 .coefficient = 575, //57.5%
1264 .pwm_voltage_map = pwm_voltage_map,
1265 .init_data = &pwm_regulator_init_dcdc[0],
1269 struct platform_device pwm_regulator_device[1] = {
1271 .name = "pwm-voltage-regulator",
1274 .platform_data = &pwm_regulator_info[0],
1280 #ifdef CONFIG_RK29_VMAC
1281 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1282 #include "board-rk30-sdk-vmac.c"
1285 #ifdef CONFIG_RFKILL_RK
1286 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1287 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1288 .type = RFKILL_TYPE_BLUETOOTH,
1290 .poweron_gpio = { // BT_REG_ON
1291 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1292 .enable = GPIO_HIGH,
1294 .name = "bt_poweron",
1299 .reset_gpio = { // BT_RST
1300 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1308 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1309 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1310 .enable = GPIO_HIGH,
1317 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1319 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1320 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1327 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1328 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1338 static struct platform_device device_rfkill_rk = {
1339 .name = "rfkill_rk",
1342 .platform_data = &rfkill_rk_platdata,
1347 #if defined(CONFIG_GPS_RK)
1348 int rk_gps_io_init(void)
1350 printk("%s \n", __FUNCTION__);
1352 gpio_request(RK30_PIN1_PB5, NULL);
1353 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1355 iomux_set(GPS_RFCLK);//GPS_CLK
1356 iomux_set(GPS_MAG);//GPS_MAG
1357 iomux_set(GPS_SIG);//GPS_SIGN
1359 gpio_request(RK30_PIN1_PA6, NULL);
1360 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1362 gpio_request(RK30_PIN1_PA5, NULL);
1363 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1365 gpio_request(RK30_PIN1_PA7, NULL);
1366 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1369 int rk_gps_power_up(void)
1371 printk("%s \n", __FUNCTION__);
1376 int rk_gps_power_down(void)
1378 printk("%s \n", __FUNCTION__);
1383 int rk_gps_reset_set(int level)
1387 int rk_enable_hclk_gps(void)
1389 struct clk *gps_aclk = NULL;
1390 gps_aclk = clk_get(NULL, "aclk_gps");
1392 clk_enable(gps_aclk);
1394 printk("%s \n", __FUNCTION__);
1397 printk("get gps aclk fail\n");
1400 int rk_disable_hclk_gps(void)
1402 struct clk *gps_aclk = NULL;
1403 gps_aclk = clk_get(NULL, "aclk_gps");
1405 //TO wait long enough until GPS ISR is finished.
1407 clk_disable(gps_aclk);
1409 printk("%s \n", __FUNCTION__);
1412 printk("get gps aclk fail\n");
1415 struct rk_gps_data rk_gps_info = {
1416 .io_init = rk_gps_io_init,
1417 .power_up = rk_gps_power_up,
1418 .power_down = rk_gps_power_down,
1419 .reset = rk_gps_reset_set,
1420 .enable_hclk_gps = rk_enable_hclk_gps,
1421 .disable_hclk_gps = rk_disable_hclk_gps,
1422 .GpsSign = RK30_PIN1_PB3,
1423 .GpsMag = RK30_PIN1_PB2, //GPIO index
1424 .GpsClk = RK30_PIN1_PB4, //GPIO index
1425 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1426 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1427 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1428 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1432 .u32GpsPhyAddr = RK30_GPS_PHYS,
1433 .u32GpsPhySize = RK30_GPS_SIZE,
1436 struct platform_device rk_device_gps = {
1437 .name = "gps_hv5820b",
1440 .platform_data = &rk_gps_info,
1445 #if defined(CONFIG_MT5931_MT6622)
1446 static struct mt6622_platform_data mt6622_platdata = {
1447 .power_gpio = { // BT_REG_ON
1448 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1449 .enable = GPIO_HIGH,
1455 .reset_gpio = { // BT_RST
1456 .io = RK30_PIN0_PD7,
1457 .enable = GPIO_HIGH,
1464 .io = RK30_PIN3_PD2,
1465 .enable = GPIO_HIGH,
1472 static struct platform_device device_mt6622 = {
1476 .platform_data = &mt6622_platdata,
1481 static struct platform_device *devices[] __initdata = {
1485 #ifdef CONFIG_ANDROID_TIMED_GPIO
1486 &rk29_device_vibrator,
1488 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1489 &rk29_device_gpio_leds,
1491 #ifdef CONFIG_RK_IRDA
1494 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1495 &rk29sdk_wifi_device,
1498 #if defined(CONFIG_MT6620)
1502 #ifdef CONFIG_RK29_SUPPORT_MODEM
1505 #if defined(CONFIG_MU509)
1508 #if defined(CONFIG_MW100)
1511 #if defined(CONFIG_MT6229)
1512 &rk29_device_mt6229,
1514 #ifdef CONFIG_BATTERY_RK30_ADC
1515 &rk30_device_adc_battery,
1517 #ifdef CONFIG_RFKILL_RK
1520 #ifdef CONFIG_GPS_RK
1523 #if defined(CONFIG_ARCH_RK3188)
1526 #ifdef CONFIG_MT5931_MT6622
1531 static int rk_platform_add_display_devices(void)
1533 struct platform_device *fb = NULL; //fb
1534 struct platform_device *lcdc0 = NULL; //lcdc0
1535 struct platform_device *lcdc1 = NULL; //lcdc1
1536 struct platform_device *bl = NULL; //backlight
1537 #ifdef CONFIG_FB_ROCKCHIP
1541 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1542 lcdc0 = &device_lcdc0,
1545 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1546 lcdc1 = &device_lcdc1,
1549 #ifdef CONFIG_BACKLIGHT_RK29_BL
1550 bl = &rk29_device_backlight,
1552 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1559 #ifdef CONFIG_I2C0_RK30
1560 static struct i2c_board_info __initdata i2c0_info[] = {
1561 #if defined (CONFIG_GS_MMA8452)
1563 .type = "gs_mma8452",
1566 .irq = MMA8452_INT_PIN,
1567 .platform_data = &mma8452_info,
1570 #if defined (CONFIG_GS_LIS3DH)
1572 .type = "gs_lis3dh",
1573 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1575 .irq = LIS3DH_INT_PIN,
1576 .platform_data = &lis3dh_info,
1579 #if defined (CONFIG_COMPASS_AK8975)
1584 .irq = RK30_PIN3_PD7,
1585 .platform_data = &akm8975_info,
1588 #if defined (CONFIG_GYRO_L3G4200D)
1590 .type = "l3g4200d_gryo",
1593 .irq = L3G4200D_INT_PIN,
1594 .platform_data = &l3g4200d_info,
1597 #if defined (CONFIG_SND_SOC_RK1000)
1599 .type = "rk1000_i2c_codec",
1604 .type = "rk1000_control",
1609 #if defined (CONFIG_SND_SOC_RT5631)
1617 #if defined (CONFIG_SND_SOC_RT5640)
1625 #ifdef CONFIG_MFD_RK610
1627 .type = "rk610_ctl",
1630 .platform_data = &rk610_ctl_pdata,
1632 #ifdef CONFIG_RK610_TVOUT
1634 .type = "rk610_tvout",
1639 #ifdef CONFIG_HDMI_RK610
1641 .type = "rk610_hdmi",
1644 .irq = INVALID_GPIO,
1647 #ifdef CONFIG_SND_SOC_RK610
1648 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1649 .type = "rk610_i2c_codec",
1652 .platform_data = &rk610_codec_pdata,
1660 int __sramdata g_pmic_type = 0;
1661 #ifdef CONFIG_I2C1_RK30
1662 #ifdef CONFIG_MFD_WM831X_I2C
1663 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1665 static struct pmu_info wm8326_dcdc_info[] = {
1667 .name = "vdd_core", //logic
1670 .suspend_vol = 950000,
1673 .name = "vdd_cpu", //arm
1676 .suspend_vol = 950000,
1679 .name = "dcdc3", //ddr
1682 .suspend_vol = 1150000,
1684 #ifdef CONFIG_MACH_RK3066_SDK
1686 .name = "dcdc4", //vcc_io
1689 .suspend_vol = 3000000,
1693 .name = "dcdc4", //vcc_io
1696 .suspend_vol = 2800000,
1701 static struct pmu_info wm8326_ldo_info[] = {
1703 .name = "ldo1", //vcc18_cif
1706 .suspend_vol = 1800000,
1709 .name = "ldo2", //vccio_wl
1712 .suspend_vol = 1800000,
1718 .suspend_vol = 1100000,
1721 .name = "ldo4", //vdd11
1724 .suspend_vol = 1000000,
1727 .name = "ldo5", //vcc25
1730 .suspend_vol = 1800000,
1733 .name = "ldo6", //vcc33
1736 .suspend_vol = 3300000,
1739 .name = "ldo7", //vcc28_cif
1742 .suspend_vol = 2800000,
1745 .name = "ldo8", //vcca33
1748 .suspend_vol = 3300000,
1751 .name = "ldo9", //vcc_tp
1754 .suspend_vol = 3300000,
1757 .name = "ldo10", //flash_io
1760 .suspend_vol = 1800000,
1764 #include "../mach-rk30/board-pmu-wm8326.c"
1767 #ifdef CONFIG_MFD_TPS65910
1768 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1770 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1772 static struct pmu_info tps65910_dcdc_info[] = {
1774 .name = "vdd_core", //logic
1779 .name = "vdd2", //ddr
1784 .name = "vio", //vcc_io
1790 static struct pmu_info tps65910_ldo_info[] = {
1792 .name = "vpll", //vdd10
1797 .name = "vdig1", //vcc18_cif
1802 .name = "vdig2", //vdd_jetta
1807 .name = "vaux1", //vcc28_cif
1812 .name = "vaux2", //vcca33
1817 .name = "vaux33", //vcc_tp
1822 .name = "vmmc", //vcc30
1827 .name = "vdac", //vcc18
1833 #include "../mach-rk30/board-pmu-tps65910.c"
1836 #ifdef CONFIG_REGULATOR_ACT8846
1837 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1838 #define PMU_VSEL RK30_PIN3_PD3
1839 static struct pmu_info act8846_dcdc_info[] = {
1841 .name = "act_dcdc1", //ddr
1844 .suspend_vol = 1200000,
1847 .name = "vdd_core", //logic
1850 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1851 .suspend_vol = 1200000,
1853 .suspend_vol = 900000,
1858 .name = "vdd_cpu", //arm
1861 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1862 .suspend_vol = 1200000,
1864 .suspend_vol = 900000,
1869 .name = "act_dcdc4", //vccio
1872 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1873 .suspend_vol = 3000000,
1875 .suspend_vol = 2800000,
1881 static struct pmu_info act8846_ldo_info[] = {
1883 .name = "act_ldo1", //vdd11
1888 .name = "act_ldo2", //vdd12
1893 .name = "act_ldo3", //vcc18_cif
1898 .name = "act_ldo4", //vcca33
1903 .name = "act_ldo5", //vcctp
1908 .name = "act_ldo6", //vcc33
1913 .name = "act_ldo7", //vccio_wl
1918 .name = "act_ldo8", //vcc28_cif
1924 #include "../mach-rk30/board-pmu-act8846.c"
1927 #ifdef CONFIG_MFD_RK808
1928 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1929 #define RK808_HOST_IRQ RK30_PIN0_PB3
1931 static struct pmu_info rk808_dcdc_info[] = {
1933 .name = "vdd_cpu", //arm
1936 .suspend_vol = 900000,
1939 .name = "vdd_core", //logic
1942 .suspend_vol = 900000,
1945 .name = "rk_dcdc3", //ddr
1948 .suspend_vol = 1200000,
1951 .name = "rk_dcdc4", //vccio
1954 .suspend_vol = 3000000,
1958 static struct pmu_info rk808_ldo_info[] = {
1960 .name = "rk_ldo1", //vcc33
1963 .suspend_vol = 3300000,
1966 .name = "rk_ldo2", //vcctp
1969 .suspend_vol = 3300000,
1973 .name = "rk_ldo3", //vdd10
1976 .suspend_vol = 1000000,
1979 .name = "rk_ldo4", //vcc18
1982 .suspend_vol = 1800000,
1985 .name = "rk_ldo5", //vcc28_cif
1988 .suspend_vol = 2800000,
1991 .name = "rk_ldo6", //vdd12
1994 .suspend_vol = 1200000,
1997 .name = "rk_ldo7", //vcc18_cif
2000 .suspend_vol = 1800000,
2003 .name = "rk_ldo8", //vcca_33
2006 .suspend_vol = 3300000,
2010 #include "board-pmu-rk808.c"
2014 static struct i2c_board_info __initdata i2c1_info[] = {
2015 #if defined (CONFIG_MFD_WM831X_I2C)
2020 .irq = RK30_PIN0_PB3,
2021 .platform_data = &wm831x_platdata,
2024 #if defined (CONFIG_MFD_TPS65910)
2027 .addr = TPS65910_I2C_ID0,
2029 .irq = TPS65910_HOST_IRQ,
2030 .platform_data = &tps65910_data,
2034 #if defined (CONFIG_REGULATOR_ACT8846)
2039 // .irq = ACT8846_HOST_IRQ,
2040 .platform_data=&act8846_data,
2043 #if defined (CONFIG_MFD_RK808)
2048 // .irq = ACT8846_HOST_IRQ,
2049 .platform_data=&rk808_data,
2053 #if defined (CONFIG_RTC_HYM8563)
2055 .type = "rtc_hym8563",
2058 .irq = RK30_PIN1_PA4,
2060 #if defined (CONFIG_CW2015_BATTERY)
2065 .platform_data = &cw_bat_platdata,
2073 void __sramfunc board_pmu_suspend(void)
2075 #if defined (CONFIG_MFD_WM831X_I2C)
2076 if(pmic_is_wm8326())
2077 board_pmu_wm8326_suspend();
2079 #if defined (CONFIG_MFD_TPS65910)
2080 if(pmic_is_tps65910())
2081 board_pmu_tps65910_suspend();
2083 #if defined (CONFIG_REGULATOR_ACT8846)
2084 if(pmic_is_act8846())
2085 board_pmu_act8846_suspend();
2087 #if defined (CONFIG_MFD_RK808)
2089 board_pmu_rk808_suspend();
2094 void __sramfunc board_pmu_resume(void)
2096 #if defined (CONFIG_MFD_WM831X_I2C)
2097 if(pmic_is_wm8326())
2098 board_pmu_wm8326_resume();
2100 #if defined (CONFIG_MFD_TPS65910)
2101 if(pmic_is_tps65910())
2102 board_pmu_tps65910_resume();
2104 #if defined (CONFIG_REGULATOR_ACT8846)
2105 if(pmic_is_act8846())
2106 board_pmu_act8846_resume();
2108 #if defined (CONFIG_MFD_RK808)
2110 board_pmu_rk808_resume();
2115 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
2117 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
2118 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
2120 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
2122 #ifdef CONFIG_RK30_PWM_REGULATOR
2124 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
2126 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
2127 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
2128 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
2129 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
2131 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
2132 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
2133 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
2134 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
2137 void __sramfunc rk30_pwm_logic_resume_voltage(void)
2139 #ifdef CONFIG_RK30_PWM_REGULATOR
2140 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
2141 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
2142 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
2143 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
2149 extern void pwm_suspend_voltage(void);
2150 extern void pwm_resume_voltage(void);
2151 void rk30_pwm_suspend_voltage_set(void)
2153 #ifdef CONFIG_RK30_PWM_REGULATOR
2154 pwm_suspend_voltage();
2157 void rk30_pwm_resume_voltage_set(void)
2159 #ifdef CONFIG_RK30_PWM_REGULATOR
2160 pwm_resume_voltage();
2165 #ifdef CONFIG_I2C2_RK30
2166 static struct i2c_board_info __initdata i2c2_info[] = {
2167 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
2169 .type = "Goodix-TS",
2172 .irq = RK30_PIN1_PB7,
2173 .platform_data = &goodix_info,
2176 #if defined (CONFIG_LS_CM3217)
2178 .type = "lightsensor",
2181 .platform_data = &cm3217_info,
2187 #ifdef CONFIG_I2C3_RK30
2188 static struct i2c_board_info __initdata i2c3_info[] = {
2192 #ifdef CONFIG_I2C4_RK30
2193 static struct i2c_board_info __initdata i2c4_info[] = {
2194 #if defined (CONFIG_MFD_RK616)
2199 .platform_data = &rk616_pdata,
2206 #ifdef CONFIG_I2C_GPIO_RK30
2207 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2208 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2209 static int rk30_i2c_io_init(void)
2211 //set iomux (gpio) here
2212 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2213 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2217 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2218 .sda_pin = I2C_SDA_PIN,
2219 .scl_pin = I2C_SCL_PIN,
2220 .udelay = 5, // clk = 500/udelay = 100Khz
2221 .timeout = 100,//msecs_to_jiffies(100),
2223 .io_init = rk30_i2c_io_init,
2225 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2229 static void __init rk30_i2c_register_board_info(void)
2231 #ifdef CONFIG_I2C0_RK30
2232 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2234 #ifdef CONFIG_I2C1_RK30
2235 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2237 #ifdef CONFIG_I2C2_RK30
2238 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2240 #ifdef CONFIG_I2C3_RK30
2241 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2243 #ifdef CONFIG_I2C4_RK30
2244 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2246 #ifdef CONFIG_I2C_GPIO_RK30
2247 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2252 // ========== Begin of rk3168 top board keypad defination ============
2254 #include <plat/key.h>
2257 #if defined(CONFIG_MACH_RK3188_RK618)
2258 static struct rk29_keys_button key_button[] = {
2262 .gpio = RK30_PIN0_PA4,
2263 .active_low = PRESS_LEV_LOW,
2268 .code = KEY_VOLUMEUP,
2270 .gpio = INVALID_GPIO,
2271 .active_low = PRESS_LEV_LOW,
2275 .code = KEY_VOLUMEDOWN,
2277 .gpio = INVALID_GPIO,
2278 .active_low = PRESS_LEV_LOW,
2284 .gpio = INVALID_GPIO,
2285 .active_low = PRESS_LEV_LOW,
2291 .gpio = INVALID_GPIO,
2292 .active_low = PRESS_LEV_LOW,
2298 .gpio = INVALID_GPIO,
2299 .active_low = PRESS_LEV_LOW,
2304 static struct rk29_keys_button key_button[] = {
2307 .code = KEY_VOLUMEDOWN,
2309 .gpio = INVALID_GPIO,
2310 .active_low = PRESS_LEV_LOW,
2315 .gpio = RK30_PIN0_PA4,
2316 .active_low = PRESS_LEV_LOW,
2321 .code = KEY_VOLUMEUP,
2323 .gpio = INVALID_GPIO,
2324 .active_low = PRESS_LEV_LOW,
2330 .gpio = INVALID_GPIO,
2331 .active_low = PRESS_LEV_LOW,
2337 .gpio = INVALID_GPIO,
2338 .active_low = PRESS_LEV_LOW,
2344 .gpio = INVALID_GPIO,
2345 .active_low = PRESS_LEV_LOW,
2351 .gpio = INVALID_GPIO,
2352 .active_low = PRESS_LEV_LOW,
2356 struct rk29_keys_platform_data rk29_keys_pdata = {
2357 .buttons = key_button,
2358 .nbuttons = ARRAY_SIZE(key_button),
2359 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
2362 // =========== End of rk3168 top board keypad defination =============
2365 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2366 static void rk30_pm_power_off(void)
2368 printk(KERN_ERR "rk30_pm_power_off start...\n");
2369 #if defined(CONFIG_MFD_WM831X)
2370 if(pmic_is_wm8326()){
2371 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2372 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2376 #if defined(CONFIG_REGULATOR_ACT8846)
2377 if(pmic_is_act8846())
2379 act8846_device_shutdown();
2383 #if defined(CONFIG_MFD_TPS65910)
2384 if(pmic_is_tps65910())
2386 tps65910_device_shutdown();//tps65910 shutdown
2390 #if defined(CONFIG_MFD_RK808)
2393 rk808_device_shutdown();//rk808 shutdown
2397 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2401 static void __init machine_rk30_board_init(void)
2404 gpio_request(POWER_ON_PIN, "poweronpin");
2405 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2407 pm_power_off = rk30_pm_power_off;
2409 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2412 rk30_i2c_register_board_info();
2413 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2414 platform_add_devices(devices, ARRAY_SIZE(devices));
2415 rk_platform_add_display_devices();
2416 board_usb_detect_init(RK30_PIN0_PA7);
2418 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2419 rk29sdk_wifi_bt_gpio_control_init();
2420 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2421 rk29sdk_wifi_combo_module_gpio_init();
2424 #if defined(CONFIG_MT6620)
2425 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2428 #if defined(CONFIG_MT5931_MT6622)
2429 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2432 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2433 static void __init rk30_reserve(void)
2435 #if defined(CONFIG_ARCH_RK3188)
2436 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2437 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2439 int ump_mem_phy_size=512UL*1024UL*1024UL;
2440 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2441 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2445 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2447 #ifdef CONFIG_FB_ROCKCHIP
2448 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2449 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2451 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2452 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2455 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2456 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2457 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2461 #ifdef CONFIG_VIDEO_RK29
2462 rk30_camera_request_reserve_mem();
2465 #ifdef CONFIG_GPS_RK
2466 //it must be more than 8MB
2467 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2469 board_mem_reserved();
2471 /******************************** arm dvfs frequency volt table **********************************/
2473 * dvfs_cpu_logic_table: table for arm and logic dvfs
2474 * @frequency : arm frequency
2475 * @cpu_volt : arm voltage depend on frequency
2478 #if defined(CONFIG_ARCH_RK3188)
2480 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2481 {.frequency = 312 * 1000, .index = 850 * 1000},
2482 {.frequency = 504 * 1000, .index = 900 * 1000},
2483 {.frequency = 816 * 1000, .index = 950 * 1000},
2484 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2485 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2486 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2487 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2488 {.frequency = CPUFREQ_TABLE_END},
2491 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2492 {.frequency = 312 * 1000, .index = 875 * 1000},
2493 {.frequency = 504 * 1000, .index = 925 * 1000},
2494 {.frequency = 816 * 1000, .index = 975 * 1000},
2495 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2496 {.frequency = 1200 * 1000, .index = 1150 * 1000},
2497 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2498 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2499 {.frequency = CPUFREQ_TABLE_END},
2502 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2503 {.frequency = 312 * 1000, .index = 900 * 1000},
2504 {.frequency = 504 * 1000, .index = 925 * 1000},
2505 {.frequency = 816 * 1000, .index = 1000 * 1000},
2506 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2507 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2508 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2509 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2510 {.frequency = CPUFREQ_TABLE_END},
2513 /******************************** gpu dvfs frequency volt table **********************************/
2515 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {
2516 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2517 {.frequency = 200 * 1000, .index = 975 * 1000},
2518 {.frequency = 266 * 1000, .index = 1000 * 1000},
2519 {.frequency = 300 * 1000, .index = 1050 * 1000},
2520 {.frequency = 400 * 1000, .index = 1100 * 1000},
2521 {.frequency = 600 * 1000, .index = 1200 * 1000},
2522 {.frequency = CPUFREQ_TABLE_END},
2525 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {
2526 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2527 {.frequency = 200 * 1000, .index = 1000 * 1000},
2528 {.frequency = 266 * 1000, .index = 1025 * 1000},
2529 {.frequency = 300 * 1000, .index = 1050 * 1000},
2530 {.frequency = 400 * 1000, .index = 1100 * 1000},
2531 {.frequency = 600 * 1000, .index = 1250 * 1000},
2532 {.frequency = CPUFREQ_TABLE_END},
2535 /******************************** ddr dvfs frequency volt table **********************************/
2536 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2537 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2538 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2539 {.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2540 {.frequency = 460 * 1000 + DDR_FREQ_DUALVIEW, .index = 1150 * 1000},
2541 {.frequency = CPUFREQ_TABLE_END},
2544 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2545 #define dvfs_arm_table dvfs_arm_table_volt_level1
2546 #define dvfs_gpu_table dvfs_gpu_table_volt_level1
2547 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2550 //for RK3168 && RK3066B
2551 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2552 {.frequency = 312 * 1000, .index = 950 * 1000},
2553 {.frequency = 504 * 1000, .index = 1000 * 1000},
2554 {.frequency = 816 * 1000, .index = 1050 * 1000},
2555 {.frequency = 1008 * 1000, .index = 1125 * 1000},
2556 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2557 //{.frequency = 1416 * 1000, .index = 1250 * 1000},
2558 //{.frequency = 1608 * 1000, .index = 1300 * 1000},
2559 {.frequency = CPUFREQ_TABLE_END},
2562 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2563 {.frequency = 100 * 1000, .index = 1000 * 1000},
2564 {.frequency = 200 * 1000, .index = 1000 * 1000},
2565 {.frequency = 266 * 1000, .index = 1050 * 1000},
2566 //{.frequency = 300 * 1000, .index = 1050 * 1000},
2567 {.frequency = 400 * 1000, .index = 1125 * 1000},
2568 {.frequency = CPUFREQ_TABLE_END},
2571 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2572 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1000 * 1000},
2573 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2574 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2575 {.frequency = CPUFREQ_TABLE_END},
2578 /******************************** arm dvfs frequency volt table end **********************************/
2579 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2580 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2581 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2583 void __init board_clock_init(void)
2585 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2586 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2587 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2588 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2589 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2592 MACHINE_START(RK30, "RK30board")
2593 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2594 .fixup = rk30_fixup,
2595 .reserve = &rk30_reserve,
2596 .map_io = rk30_map_io,
2597 .init_irq = rk30_init_irq,
2598 .timer = &rk30_timer,
2599 .init_machine = machine_rk30_board_init,