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/mfd/ricoh619.h>
51 #include <linux/regulator/rk29-pwm-regulator.h>
53 #ifdef CONFIG_CW2015_BATTERY
54 #include <linux/power/cw2015_battery.h>
56 #if defined(CONFIG_MFD_RK610)
57 #include <linux/mfd/rk610_core.h>
60 #if defined(CONFIG_MFD_RK616)
61 #include <linux/mfd/rk616.h>
65 #if defined(CONFIG_RK_HDMI)
66 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
69 #if defined(CONFIG_SPIM_RK29)
70 #include "../../../drivers/spi/rk29_spim.h"
72 #if defined(CONFIG_GPS_RK)
73 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
75 #if defined(CONFIG_MU509)
76 #include <linux/mu509.h>
78 #if defined(CONFIG_MW100)
79 #include <linux/mw100.h>
81 #if defined(CONFIG_MT6229)
82 #include <linux/mt6229.h>
84 #if defined(CONFIG_ANDROID_TIMED_GPIO)
85 #include "../../../drivers/staging/android/timed_gpio.h"
88 #if defined(CONFIG_MT6620)
89 #include <linux/gps.h>
91 #include "board-rk3168-tb-camera.c"
93 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
94 #define TOUCH_RESET_PIN RK30_PIN0_PB6
95 #define TOUCH_PWR_PIN RK30_PIN0_PC5 // need to fly line by hardware engineer
97 /* Android Parameter */
98 static int ap_mdm = 0;
99 module_param(ap_mdm, int, 0644);
100 static int ap_has_alsa = 0;
101 module_param(ap_has_alsa, int, 0644);
102 static int ap_data_only = 2;
103 module_param(ap_data_only, int, 0644);
104 static int ap_has_earphone = 0;
105 module_param(ap_has_earphone, int, 0644);
108 static int goodix_init_platform_hw(void)
112 if (TOUCH_PWR_PIN != INVALID_GPIO) {
113 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
115 gpio_free(TOUCH_PWR_PIN);
116 printk("goodix power error\n");
119 gpio_direction_output(TOUCH_PWR_PIN, 0);
120 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
124 if (TOUCH_RESET_PIN != INVALID_GPIO) {
125 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
127 gpio_free(TOUCH_RESET_PIN);
128 printk("goodix gpio_request error\n");
131 gpio_direction_output(TOUCH_RESET_PIN, 1);
133 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
135 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
141 struct goodix_platform_data goodix_info = {
143 .irq_pin = RK30_PIN1_PB7,
144 .rest_pin = TOUCH_RESET_PIN,
145 .init_platform_hw = goodix_init_platform_hw,
149 static struct spi_board_info board_spi_devices[] = {
152 /***********************************************************
154 ************************************************************/
155 #ifdef CONFIG_BACKLIGHT_RK29_BL
157 #define PWM_MODE PWM3
158 #define PWM_EFFECT_VALUE 1
160 #define LCD_DISP_ON_PIN
162 #ifdef LCD_DISP_ON_PIN
163 #define BL_EN_PIN RK30_PIN0_PA2
164 #define BL_EN_VALUE GPIO_HIGH
166 static int rk29_backlight_io_init(void)
171 #ifdef LCD_DISP_ON_PIN
172 ret = gpio_request(BL_EN_PIN, "bl_en");
174 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
180 static int rk29_backlight_io_deinit(void)
182 int ret = 0, pwm_gpio;
183 #ifdef LCD_DISP_ON_PIN
184 gpio_free(BL_EN_PIN);
186 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
187 gpio_request(pwm_gpio, "bl_pwm");
188 gpio_direction_output(pwm_gpio, GPIO_LOW);
192 static int rk29_backlight_pwm_suspend(void)
194 int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
196 ret = gpio_request(pwm_gpio, "bl_pwm");
198 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
201 gpio_direction_output(pwm_gpio, GPIO_LOW);
202 #ifdef LCD_DISP_ON_PIN
203 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
208 static int rk29_backlight_pwm_resume(void)
210 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
214 #ifdef LCD_DISP_ON_PIN
216 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
221 static struct rk29_bl_info rk29_bl_info = {
225 .brightness_mode =BRIGHTNESS_MODE_CONIC,
226 .bl_ref = PWM_EFFECT_VALUE,
227 .io_init = rk29_backlight_io_init,
228 .io_deinit = rk29_backlight_io_deinit,
229 .pwm_suspend = rk29_backlight_pwm_suspend,
230 .pwm_resume = rk29_backlight_pwm_resume,
233 static struct platform_device rk29_device_backlight = {
234 .name = "rk29_backlight",
237 .platform_data = &rk29_bl_info,
243 #ifdef CONFIG_RK29_SUPPORT_MODEM
245 #define RK30_MODEM_POWER RK30_PIN0_PC6
246 #define RK30_MODEM_POWER_IOMUX iomux_set(GPIO0_C6)
248 static int rk30_modem_io_init(void)
250 printk("%s\n", __FUNCTION__);
251 RK30_MODEM_POWER_IOMUX;
256 static struct rk29_io_t rk30_modem_io = {
257 .io_addr = RK30_MODEM_POWER,
260 .io_init = rk30_modem_io_init,
263 static struct platform_device rk30_device_modem = {
264 .name = "rk30_modem",
267 .platform_data = &rk30_modem_io,
271 #if defined(CONFIG_MU509)
272 static int mu509_io_init(void)
283 static int mu509_io_deinit(void)
289 struct rk29_mu509_data rk29_mu509_info = {
290 .io_init = mu509_io_init,
291 .io_deinit = mu509_io_deinit,
292 .modem_power_en = RK30_PIN2_PD5,
293 .bp_power = RK30_PIN0_PC6,
294 .bp_reset = RK30_PIN2_PD4,
295 .ap_wakeup_bp = RK30_PIN0_PC4,
296 .bp_wakeup_ap = RK30_PIN0_PC5,
298 struct platform_device rk29_device_mu509 = {
302 .platform_data = &rk29_mu509_info,
306 #if defined(CONFIG_MW100)
307 static int mw100_io_init(void)
317 static int mw100_io_deinit(void)
323 struct rk29_mw100_data rk29_mw100_info = {
324 .io_init = mw100_io_init,
325 .io_deinit = mw100_io_deinit,
326 .modem_power_en = RK30_PIN2_PD5,
327 .bp_power = RK30_PIN0_PC6,
328 .bp_reset = RK30_PIN2_PD4,
329 .ap_wakeup_bp = RK30_PIN0_PC4,
330 .bp_wakeup_ap = RK30_PIN0_PC5,
332 struct platform_device rk29_device_mw100 = {
336 .platform_data = &rk29_mw100_info,
340 #if defined(CONFIG_MT6229)
341 static int mt6229_io_init(void)
351 static int mt6229_io_deinit(void)
357 struct rk29_mt6229_data rk29_mt6229_info = {
358 .io_init = mt6229_io_init,
359 .io_deinit = mt6229_io_deinit,
360 .modem_power_en = RK30_PIN2_PD5,
361 .bp_power = RK30_PIN0_PC6,
362 .bp_reset = RK30_PIN2_PD4,
363 .ap_wakeup_bp = RK30_PIN0_PC4,
364 .bp_wakeup_ap = RK30_PIN0_PC5,
366 struct platform_device rk29_device_mt6229 = {
370 .platform_data = &rk29_mt6229_info,
376 #if defined (CONFIG_GS_MMA8452)
377 #define MMA8452_INT_PIN RK30_PIN0_PB7
379 static int mma8452_init_platform_hw(void)
384 static struct sensor_platform_data mma8452_info = {
385 .type = SENSOR_TYPE_ACCEL,
388 .init_platform_hw = mma8452_init_platform_hw,
389 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
392 #if defined (CONFIG_GS_LIS3DH)
393 #define LIS3DH_INT_PIN RK30_PIN0_PB7
395 static int lis3dh_init_platform_hw(void)
401 static struct sensor_platform_data lis3dh_info = {
402 .type = SENSOR_TYPE_ACCEL,
405 .init_platform_hw = lis3dh_init_platform_hw,
406 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
409 #if defined (CONFIG_COMPASS_AK8975)
410 static struct sensor_platform_data akm8975_info =
412 .type = SENSOR_TYPE_COMPASS,
445 #if defined(CONFIG_GYRO_L3G4200D)
447 #include <linux/l3g4200d.h>
448 #define L3G4200D_INT_PIN RK30_PIN0_PB4
450 static int l3g4200d_init_platform_hw(void)
455 static struct sensor_platform_data l3g4200d_info = {
456 .type = SENSOR_TYPE_GYROSCOPE,
459 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
460 .init_platform_hw = l3g4200d_init_platform_hw,
461 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
468 #ifdef CONFIG_LS_CM3217
469 static struct sensor_platform_data cm3217_info = {
470 .type = SENSOR_TYPE_LIGHT,
472 .poll_delay_ms = 500,
477 #ifdef CONFIG_FB_ROCKCHIP
479 #define LCD_CS_PIN INVALID_GPIO
480 #define LCD_CS_VALUE GPIO_HIGH
482 #define LCD_EN_PIN RK30_PIN0_PB0
483 #define LCD_EN_VALUE GPIO_HIGH
485 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
489 if(LCD_CS_PIN !=INVALID_GPIO)
491 ret = gpio_request(LCD_CS_PIN, NULL);
494 gpio_free(LCD_CS_PIN);
495 printk(KERN_ERR "request lcd cs pin fail!\n");
500 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
504 if(LCD_EN_PIN !=INVALID_GPIO)
506 ret = gpio_request(LCD_EN_PIN, NULL);
509 gpio_free(LCD_EN_PIN);
510 printk(KERN_ERR "request lcd en pin fail!\n");
515 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
520 static int rk_fb_io_disable(void)
522 if(LCD_CS_PIN !=INVALID_GPIO)
524 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
526 if(LCD_EN_PIN !=INVALID_GPIO)
528 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
532 static int rk_fb_io_enable(void)
534 if(LCD_CS_PIN !=INVALID_GPIO)
536 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
538 if(LCD_EN_PIN !=INVALID_GPIO)
540 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
545 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
546 struct rk29fb_info lcdc0_screen_info = {
547 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
548 .prop = EXTEND, //extend display device
552 .set_screen_info = hdmi_init_lcdc,
554 .prop = PRMRY, //primary display device
555 .io_init = rk_fb_io_init,
556 .io_disable = rk_fb_io_disable,
557 .io_enable = rk_fb_io_enable,
558 .set_screen_info = set_lcd_info,
563 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
564 struct rk29fb_info lcdc1_screen_info = {
565 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
566 .prop = EXTEND, //extend display device
570 .set_screen_info = hdmi_init_lcdc,
572 .prop = PRMRY, //primary display device
573 .io_init = rk_fb_io_init,
574 .io_disable = rk_fb_io_disable,
575 .io_enable = rk_fb_io_enable,
576 .set_screen_info = set_lcd_info,
581 static struct resource resource_fb[] = {
585 .end = 0,//RK30_FB0_MEM_SIZE - 1,
586 .flags = IORESOURCE_MEM,
589 .name = "ipp buf", //for rotate
591 .end = 0,//RK30_FB0_MEM_SIZE - 1,
592 .flags = IORESOURCE_MEM,
597 .end = 0,//RK30_FB0_MEM_SIZE - 1,
598 .flags = IORESOURCE_MEM,
602 static struct platform_device device_fb = {
605 .num_resources = ARRAY_SIZE(resource_fb),
606 .resource = resource_fb,
609 #if defined(CONFIG_ARCH_RK3188)
610 static struct resource resource_mali[] = {
615 .flags = IORESOURCE_MEM,
620 static struct platform_device device_mali= {
621 .name = "mali400_ump",
623 .num_resources = ARRAY_SIZE(resource_mali),
624 .resource = resource_mali,
628 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
629 static struct resource resource_lcdc0[] = {
632 .start = RK30_LCDC0_PHYS,
633 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
634 .flags = IORESOURCE_MEM,
641 .flags = IORESOURCE_IRQ,
645 static struct platform_device device_lcdc0 = {
648 .num_resources = ARRAY_SIZE(resource_lcdc0),
649 .resource = resource_lcdc0,
651 .platform_data = &lcdc0_screen_info,
655 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
656 static struct resource resource_lcdc1[] = {
659 .start = RK30_LCDC1_PHYS,
660 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
661 .flags = IORESOURCE_MEM,
667 .flags = IORESOURCE_IRQ,
671 static struct platform_device device_lcdc1 = {
674 .num_resources = ARRAY_SIZE(resource_lcdc1),
675 .resource = resource_lcdc1,
677 .platform_data = &lcdc1_screen_info,
682 #if defined(CONFIG_MFD_RK610)
683 #define RK610_RST_PIN RK30_PIN2_PC5
684 static int rk610_power_on_init(void)
687 if(RK610_RST_PIN != INVALID_GPIO)
689 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
692 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
696 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
698 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
700 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
709 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
710 .rk610_power_on_init = rk610_power_on_init,
714 #if defined(CONFIG_MFD_RK616)
715 #define RK616_RST_PIN RK30_PIN3_PB2
716 #define RK616_PWREN_PIN RK30_PIN0_PA3
717 #define RK616_SCL_RATE (100*1000) //i2c scl rate
718 static int rk616_power_on_init(void)
722 if(RK616_PWREN_PIN != INVALID_GPIO)
724 ret = gpio_request(RK616_PWREN_PIN, "rk616 pwren");
727 printk(KERN_ERR "rk616 pwren gpio request fail\n");
731 gpio_direction_output(RK616_PWREN_PIN,GPIO_HIGH);
735 if(RK616_RST_PIN != INVALID_GPIO)
737 ret = gpio_request(RK616_RST_PIN, "rk616 reset");
740 printk(KERN_ERR "rk616 reset gpio request fail\n");
744 gpio_direction_output(RK616_RST_PIN, GPIO_HIGH);
746 gpio_direction_output(RK616_RST_PIN, GPIO_LOW);
748 gpio_set_value(RK616_RST_PIN, GPIO_HIGH);
757 static int rk616_power_deinit(void)
759 gpio_set_value(RK616_PWREN_PIN,GPIO_LOW);
760 gpio_set_value(RK616_RST_PIN,GPIO_LOW);
761 gpio_free(RK616_PWREN_PIN);
762 gpio_free(RK616_RST_PIN);
767 static struct rk616_platform_data rk616_pdata = {
768 .power_init = rk616_power_on_init,
769 .power_deinit = rk616_power_deinit,
770 .scl_rate = RK616_SCL_RATE,
771 .lcd0_func = INPUT, //port lcd0 as input
772 .lcd1_func = INPUT, //port lcd1 as input
773 .lvds_ch_nr = 1, //the number of used lvds channel
774 .hdmi_irq = RK30_PIN2_PD6,
775 .spk_ctl_gpio = RK30_PIN2_PD7,
776 .hp_ctl_gpio = RK30_PIN2_PD7,
781 #ifdef CONFIG_SND_SOC_RK610
782 static int rk610_codec_io_init(void)
785 //Must not gpio_request
789 static struct rk610_codec_platform_data rk610_codec_pdata = {
790 .spk_ctl_io = RK30_PIN2_PD7,
791 .io_init = rk610_codec_io_init,
795 #ifdef CONFIG_ANDROID_TIMED_GPIO
796 static struct timed_gpio timed_gpios[] = {
799 .gpio = INVALID_GPIO,
802 .adjust_time =20, //adjust for diff product
806 static struct timed_gpio_platform_data rk29_vibrator_info = {
808 .gpios = timed_gpios,
811 static struct platform_device rk29_device_vibrator = {
812 .name = "timed-gpio",
815 .platform_data = &rk29_vibrator_info,
821 #ifdef CONFIG_LEDS_GPIO_PLATFORM
822 static struct gpio_led rk29_leds[] = {
824 .name = "button-backlight",
825 .gpio = INVALID_GPIO,
826 .default_trigger = "timer",
828 .retain_state_suspended = 0,
829 .default_state = LEDS_GPIO_DEFSTATE_OFF,
833 static struct gpio_led_platform_data rk29_leds_pdata = {
835 .num_leds = ARRAY_SIZE(rk29_leds),
838 static struct platform_device rk29_device_gpio_leds = {
842 .platform_data = &rk29_leds_pdata,
847 #ifdef CONFIG_RK_IRDA
848 #define IRDA_IRQ_PIN INVALID_GPIO //RK30_PIN0_PA3
850 static int irda_iomux_init(void)
855 ret = gpio_request(IRDA_IRQ_PIN, NULL);
857 gpio_free(IRDA_IRQ_PIN);
858 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
860 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
861 gpio_direction_input(IRDA_IRQ_PIN);
866 static int irda_iomux_deinit(void)
868 gpio_free(IRDA_IRQ_PIN);
872 static struct irda_info rk29_irda_info = {
873 .intr_pin = IRDA_IRQ_PIN,
874 .iomux_init = irda_iomux_init,
875 .iomux_deinit = irda_iomux_deinit,
876 //.irda_pwr_ctl = bu92747guw_power_ctl,
879 static struct platform_device irda_device = {
880 #ifdef CONFIG_RK_IRDA_NET
883 .name = "bu92747_irda",
887 .platform_data = &rk29_irda_info,
893 #define ION_RESERVE_SIZE (80 * SZ_1M)
894 static struct ion_platform_data rk30_ion_pdata = {
898 .type = ION_HEAP_TYPE_CARVEOUT,
899 .id = ION_NOR_HEAP_ID,
901 .size = ION_RESERVE_SIZE,
906 static struct platform_device device_ion = {
907 .name = "ion-rockchip",
910 .platform_data = &rk30_ion_pdata,
915 /**************************************************************************************************
916 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
917 **************************************************************************************************/
918 #ifdef CONFIG_SDMMC_RK29
919 #include "board-rk3168-tb-sdmmc-conifg.c"
920 #include "../plat-rk/rk-sdmmc-ops.c"
921 #include "../plat-rk/rk-sdmmc-wifi.c"
922 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
924 #ifdef CONFIG_SDMMC0_RK29
925 static int rk29_sdmmc0_cfg_gpio(void)
927 #ifdef CONFIG_SDMMC_RK29_OLD
929 iomux_set(MMC0_CLKOUT);
935 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
937 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
938 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
941 rk29_sdmmc_set_iomux(0, 0xFFFF);
943 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
944 #if SDMMC_USE_NEW_IOMUX_API
945 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
947 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
950 #if SDMMC_USE_NEW_IOMUX_API
951 iomux_set(MMC0_DETN);
953 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
957 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
958 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
959 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
967 #define CONFIG_SDMMC0_USE_DMA
968 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
970 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
971 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
972 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
974 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
975 .io_init = rk29_sdmmc0_cfg_gpio,
977 #if !defined(CONFIG_SDMMC_RK29_OLD)
978 .set_iomux = rk29_sdmmc_set_iomux,
981 .dma_name = "sd_mmc",
982 #ifdef CONFIG_SDMMC0_USE_DMA
988 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
989 .status = rk29sdk_wifi_mmc0_status,
990 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
993 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
994 .power_en = RK29SDK_SD_CARD_PWR_EN,
995 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
997 .power_en = INVALID_GPIO,
998 .power_en_level = GPIO_LOW,
1000 .enable_sd_wakeup = 0,
1002 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1003 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1004 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1006 .write_prt = INVALID_GPIO,
1010 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1011 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1012 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1013 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1015 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1016 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1017 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1019 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1020 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1031 #endif // CONFIG_SDMMC0_RK29
1033 #ifdef CONFIG_SDMMC1_RK29
1034 #define CONFIG_SDMMC1_USE_DMA
1035 static int rk29_sdmmc1_cfg_gpio(void)
1037 #if defined(CONFIG_SDMMC_RK29_OLD)
1038 iomux_set(MMC1_CMD);
1039 iomux_set(MMC1_CLKOUT);
1046 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1047 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1048 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1056 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1058 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1059 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1062 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1063 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1064 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1067 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1070 .io_init = rk29_sdmmc1_cfg_gpio,
1072 #if !defined(CONFIG_SDMMC_RK29_OLD)
1073 .set_iomux = rk29_sdmmc_set_iomux,
1077 #ifdef CONFIG_SDMMC1_USE_DMA
1083 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1084 .status = rk29sdk_wifi_status,
1085 .register_status_notify = rk29sdk_wifi_status_register,
1088 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1089 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1090 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1092 .write_prt = INVALID_GPIO,
1095 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1096 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1100 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1101 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1102 .io = RK29SDK_SD_CARD_DETECT_N,
1107 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1108 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1110 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1111 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1112 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1114 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1115 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1125 .enable_sd_wakeup = 0,
1127 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1129 /**************************************************************************************************
1130 * the end of setting for SDMMC devices
1131 **************************************************************************************************/
1133 #ifdef CONFIG_BATTERY_RK30_ADC
1134 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1135 .dc_det_pin = RK30_PIN0_PB2,
1136 .batt_low_pin = RK30_PIN0_PB1,
1137 .charge_set_pin = INVALID_GPIO,
1138 .charge_ok_pin = RK30_PIN0_PA6,
1139 .dc_det_level = GPIO_LOW,
1140 .charge_ok_level = GPIO_HIGH,
1143 static struct platform_device rk30_device_adc_battery = {
1144 .name = "rk30-battery",
1147 .platform_data = &rk30_adc_battery_platdata,
1151 #ifdef CONFIG_CW2015_BATTERY
1153 note the follow array must set depend on the battery that you use
1154 you must send the battery to cellwise-semi the contact information:
1155 name: chen gan; tel:13416876079; E-mail: ben.chen@cellwise-semi.com
1157 static u8 config_info[SIZE_BATINFO] = {
1158 0x15, 0x42, 0x60, 0x59, 0x52,
1159 0x58, 0x4D, 0x48, 0x48, 0x44,
1160 0x44, 0x46, 0x49, 0x48, 0x32,
1161 0x24, 0x20, 0x17, 0x13, 0x0F,
1162 0x19, 0x3E, 0x51, 0x45, 0x08,
1163 0x76, 0x0B, 0x85, 0x0E, 0x1C,
1164 0x2E, 0x3E, 0x4D, 0x52, 0x52,
1165 0x57, 0x3D, 0x1B, 0x6A, 0x2D,
1166 0x25, 0x43, 0x52, 0x87, 0x8F,
1167 0x91, 0x94, 0x52, 0x82, 0x8C,
1168 0x92, 0x96, 0xFF, 0x7B, 0xBB,
1169 0xCB, 0x2F, 0x7D, 0x72, 0xA5,
1170 0xB5, 0xC1, 0x46, 0xAE
1173 static struct cw_bat_platform_data cw_bat_platdata = {
1174 .dc_det_pin = RK30_PIN0_PB2,
1175 .bat_low_pin = RK30_PIN0_PB1,
1176 .chg_ok_pin = RK30_PIN0_PA6,
1177 .dc_det_level = GPIO_LOW,
1178 .bat_low_level = GPIO_LOW,
1179 .chg_ok_level = GPIO_HIGH,
1181 .cw_bat_config_info = config_info,
1186 #ifdef CONFIG_RK30_PWM_REGULATOR
1187 static int pwm_voltage_map[] = {
1188 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
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] = {
1214 .pwm_gpio = RK30_PIN3_PD4,
1215 .pwm_iomux_pwm = PWM1,
1216 .pwm_iomux_gpio = GPIO3_D4,
1217 .pwm_voltage = 1100000,
1218 .suspend_voltage = 1000000,
1221 .coefficient = 575, //57.5%
1222 .pwm_voltage_map = pwm_voltage_map,
1223 .init_data = &pwm_regulator_init_dcdc[0],
1227 struct platform_device pwm_regulator_device[1] = {
1229 .name = "pwm-voltage-regulator",
1232 .platform_data = &pwm_regulator_info[0],
1238 #ifdef CONFIG_RK29_VMAC
1239 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1240 #include "board-rk30-sdk-vmac.c"
1243 #ifdef CONFIG_RFKILL_RK
1244 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1245 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1246 .type = RFKILL_TYPE_BLUETOOTH,
1248 .poweron_gpio = { // BT_REG_ON
1249 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1250 .enable = GPIO_HIGH,
1252 .name = "bt_poweron",
1257 .reset_gpio = { // BT_RST
1258 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1266 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1267 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1268 .enable = GPIO_HIGH,
1275 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1277 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1278 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1285 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1286 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1296 static struct platform_device device_rfkill_rk = {
1297 .name = "rfkill_rk",
1300 .platform_data = &rfkill_rk_platdata,
1305 #if defined(CONFIG_GPS_RK)
1306 int rk_gps_io_init(void)
1308 printk("%s \n", __FUNCTION__);
1310 gpio_request(RK30_PIN1_PB5, NULL);
1311 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1313 iomux_set(GPS_RFCLK);//GPS_CLK
1314 iomux_set(GPS_MAG);//GPS_MAG
1315 iomux_set(GPS_SIG);//GPS_SIGN
1317 gpio_request(RK30_PIN1_PA6, NULL);
1318 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1320 gpio_request(RK30_PIN1_PA5, NULL);
1321 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1323 gpio_request(RK30_PIN1_PA7, NULL);
1324 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1327 int rk_gps_power_up(void)
1329 printk("%s \n", __FUNCTION__);
1334 int rk_gps_power_down(void)
1336 printk("%s \n", __FUNCTION__);
1341 int rk_gps_reset_set(int level)
1345 int rk_enable_hclk_gps(void)
1347 struct clk *gps_aclk = NULL;
1348 gps_aclk = clk_get(NULL, "aclk_gps");
1350 clk_enable(gps_aclk);
1352 printk("%s \n", __FUNCTION__);
1355 printk("get gps aclk fail\n");
1358 int rk_disable_hclk_gps(void)
1360 struct clk *gps_aclk = NULL;
1361 gps_aclk = clk_get(NULL, "aclk_gps");
1363 //TO wait long enough until GPS ISR is finished.
1365 clk_disable(gps_aclk);
1367 printk("%s \n", __FUNCTION__);
1370 printk("get gps aclk fail\n");
1373 struct rk_gps_data rk_gps_info = {
1374 .io_init = rk_gps_io_init,
1375 .power_up = rk_gps_power_up,
1376 .power_down = rk_gps_power_down,
1377 .reset = rk_gps_reset_set,
1378 .enable_hclk_gps = rk_enable_hclk_gps,
1379 .disable_hclk_gps = rk_disable_hclk_gps,
1380 .GpsSign = RK30_PIN1_PB3,
1381 .GpsMag = RK30_PIN1_PB2, //GPIO index
1382 .GpsClk = RK30_PIN1_PB4, //GPIO index
1383 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1384 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1385 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1386 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1390 .u32GpsPhyAddr = RK30_GPS_PHYS,
1391 .u32GpsPhySize = RK30_GPS_SIZE,
1394 struct platform_device rk_device_gps = {
1395 .name = "gps_hv5820b",
1398 .platform_data = &rk_gps_info,
1403 #if defined(CONFIG_MT5931_MT6622)
1404 static struct mt6622_platform_data mt6622_platdata = {
1405 .power_gpio = { // BT_REG_ON
1406 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1407 .enable = GPIO_HIGH,
1413 .reset_gpio = { // BT_RST
1414 .io = RK30_PIN0_PD7,
1415 .enable = GPIO_HIGH,
1422 .io = RK30_PIN3_PD2,
1423 .enable = GPIO_HIGH,
1430 static struct platform_device device_mt6622 = {
1434 .platform_data = &mt6622_platdata,
1439 static struct platform_device *devices[] __initdata = {
1443 #ifdef CONFIG_ANDROID_TIMED_GPIO
1444 &rk29_device_vibrator,
1446 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1447 &rk29_device_gpio_leds,
1449 #ifdef CONFIG_RK_IRDA
1452 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1453 &rk29sdk_wifi_device,
1456 #if defined(CONFIG_MT6620)
1460 #ifdef CONFIG_RK29_SUPPORT_MODEM
1463 #if defined(CONFIG_MU509)
1466 #if defined(CONFIG_MW100)
1469 #if defined(CONFIG_MT6229)
1470 &rk29_device_mt6229,
1472 #ifdef CONFIG_BATTERY_RK30_ADC
1473 &rk30_device_adc_battery,
1475 #ifdef CONFIG_RFKILL_RK
1478 #ifdef CONFIG_GPS_RK
1481 #if defined(CONFIG_ARCH_RK3188)
1484 #ifdef CONFIG_MT5931_MT6622
1489 static int rk_platform_add_display_devices(void)
1491 struct platform_device *fb = NULL; //fb
1492 struct platform_device *lcdc0 = NULL; //lcdc0
1493 struct platform_device *lcdc1 = NULL; //lcdc1
1494 struct platform_device *bl = NULL; //backlight
1495 #ifdef CONFIG_FB_ROCKCHIP
1499 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1500 lcdc0 = &device_lcdc0,
1503 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1504 lcdc1 = &device_lcdc1,
1507 #ifdef CONFIG_BACKLIGHT_RK29_BL
1508 bl = &rk29_device_backlight,
1510 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1517 #ifdef CONFIG_I2C0_RK30
1518 static struct i2c_board_info __initdata i2c0_info[] = {
1519 #if defined (CONFIG_GS_MMA8452)
1521 .type = "gs_mma8452",
1524 .irq = MMA8452_INT_PIN,
1525 .platform_data = &mma8452_info,
1528 #if defined (CONFIG_GS_LIS3DH)
1530 .type = "gs_lis3dh",
1531 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1533 .irq = LIS3DH_INT_PIN,
1534 .platform_data = &lis3dh_info,
1537 #if defined (CONFIG_COMPASS_AK8975)
1542 .irq = RK30_PIN3_PD7,
1543 .platform_data = &akm8975_info,
1546 #if defined (CONFIG_GYRO_L3G4200D)
1548 .type = "l3g4200d_gryo",
1551 .irq = L3G4200D_INT_PIN,
1552 .platform_data = &l3g4200d_info,
1555 #if defined (CONFIG_SND_SOC_RK1000)
1557 .type = "rk1000_i2c_codec",
1562 .type = "rk1000_control",
1567 #if defined (CONFIG_SND_SOC_RT5631)
1575 #if defined (CONFIG_SND_SOC_RT5640)
1583 #ifdef CONFIG_MFD_RK610
1585 .type = "rk610_ctl",
1588 .platform_data = &rk610_ctl_pdata,
1590 #ifdef CONFIG_RK610_TVOUT
1592 .type = "rk610_tvout",
1597 #ifdef CONFIG_HDMI_RK610
1599 .type = "rk610_hdmi",
1602 .irq = INVALID_GPIO,
1605 #ifdef CONFIG_SND_SOC_RK610
1606 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1607 .type = "rk610_i2c_codec",
1610 .platform_data = &rk610_codec_pdata,
1618 int __sramdata g_pmic_type = 0;
1619 #ifdef CONFIG_I2C1_RK30
1620 #ifdef CONFIG_MFD_WM831X_I2C
1621 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1623 static struct pmu_info wm8326_dcdc_info[] = {
1625 .name = "vdd_core", //logic
1628 .suspend_vol = 950000,
1631 .name = "vdd_cpu", //arm
1634 .suspend_vol = 950000,
1637 .name = "dcdc3", //ddr
1640 .suspend_vol = 1150000,
1642 #ifdef CONFIG_MACH_RK3066_SDK
1644 .name = "dcdc4", //vcc_io
1647 .suspend_vol = 3000000,
1651 .name = "dcdc4", //vcc_io
1654 .suspend_vol = 2800000,
1659 static struct pmu_info wm8326_ldo_info[] = {
1661 .name = "ldo1", //vcc18_cif
1664 .suspend_vol = 1800000,
1667 .name = "ldo2", //vccio_wl
1670 .suspend_vol = 1800000,
1676 .suspend_vol = 1100000,
1679 .name = "ldo4", //vdd11
1682 .suspend_vol = 1000000,
1685 .name = "ldo5", //vcc25
1688 .suspend_vol = 1800000,
1691 .name = "ldo6", //vcc33
1694 .suspend_vol = 3300000,
1697 .name = "ldo7", //vcc28_cif
1700 .suspend_vol = 2800000,
1703 .name = "ldo8", //vcca33
1706 .suspend_vol = 3300000,
1709 .name = "ldo9", //vcc_tp
1712 .suspend_vol = 3300000,
1715 .name = "ldo10", //flash_io
1718 .suspend_vol = 1800000,
1722 #include "board-pmu-wm8326.c"
1725 #ifdef CONFIG_MFD_TPS65910
1726 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1728 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1730 static struct pmu_info tps65910_dcdc_info[] = {
1732 .name = "vdd_core", //logic
1737 .name = "vdd2", //ddr
1742 .name = "vio", //vcc_io
1748 static struct pmu_info tps65910_ldo_info[] = {
1750 .name = "vpll", //vdd10
1755 .name = "vdig1", //vcc18_cif
1760 .name = "vdig2", //vdd_jetta
1765 .name = "vaux1", //vcc28_cif
1770 .name = "vaux2", //vcca33
1775 .name = "vaux33", //vcc_tp
1780 .name = "vmmc", //vcc30
1785 .name = "vdac", //vcc18
1791 #include "board-pmu-tps65910.c"
1794 #ifdef CONFIG_REGULATOR_ACT8846
1795 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1796 #define PMU_VSEL RK30_PIN3_PD3
1797 static struct pmu_info act8846_dcdc_info[] = {
1799 .name = "act_dcdc1", //ddr
1802 .suspend_vol = 1200000,
1805 .name = "vdd_core", //logic
1808 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1809 .suspend_vol = 1200000,
1811 .suspend_vol = 900000,
1816 .name = "vdd_cpu", //arm
1819 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1820 .suspend_vol = 1200000,
1822 .suspend_vol = 900000,
1827 .name = "act_dcdc4", //vccio
1830 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1831 .suspend_vol = 3000000,
1833 .suspend_vol = 2800000,
1839 static struct pmu_info act8846_ldo_info[] = {
1841 .name = "act_ldo1", //vdd11
1846 .name = "act_ldo2", //vdd12
1851 .name = "act_ldo3", //vcc18_cif
1856 .name = "act_ldo4", //vcca33
1861 .name = "act_ldo5", //vcctp
1866 .name = "act_ldo6", //vcc33
1871 .name = "act_ldo7", //vccio_wl
1876 .name = "act_ldo8", //vcc28_cif
1882 #include "board-pmu-act8846.c"
1885 #ifdef CONFIG_MFD_RK808
1886 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1887 #define RK808_HOST_IRQ RK30_PIN0_PB3
1889 static struct pmu_info rk808_dcdc_info[] = {
1891 .name = "vdd_cpu", //arm
1894 .suspend_vol = 900000,
1897 .name = "vdd_core", //logic
1900 .suspend_vol = 900000,
1903 .name = "rk_dcdc3", //ddr
1906 .suspend_vol = 1200000,
1909 .name = "rk_dcdc4", //vccio
1912 .suspend_vol = 3000000,
1916 static struct pmu_info rk808_ldo_info[] = {
1918 .name = "rk_ldo1", //vcc33
1921 .suspend_vol = 3300000,
1924 .name = "rk_ldo2", //vcctp
1927 .suspend_vol = 3300000,
1931 .name = "rk_ldo3", //vdd10
1934 .suspend_vol = 1000000,
1937 .name = "rk_ldo4", //vcc18
1940 .suspend_vol = 1800000,
1943 .name = "rk_ldo5", //vcc28_cif
1946 .suspend_vol = 2800000,
1949 .name = "rk_ldo6", //vdd12
1952 .suspend_vol = 1200000,
1955 .name = "rk_ldo7", //vcc18_cif
1958 .suspend_vol = 1800000,
1961 .name = "rk_ldo8", //vcca_33
1964 .suspend_vol = 3300000,
1968 #include "board-pmu-rk808.c"
1970 #ifdef CONFIG_MFD_RICOH619
1971 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1972 #define RICOH619_HOST_IRQ RK30_PIN0_PB3
1974 static struct pmu_info ricoh619_dcdc_info[] = {
1976 .name = "vdd_cpu", //arm
1979 .suspend_vol = 900000,
1982 .name = "vdd_core", //logic
1985 .suspend_vol = 900000,
1989 .name = "ricoh_dc3", //vcc18
1992 .suspend_vol = 1800000,
1996 .name = "ricoh_dc4", //vccio
1999 .suspend_vol = 3300000,
2003 .name = "ricoh_dc5", //ddr
2006 .suspend_vol = 1200000,
2010 static struct pmu_info ricoh619_ldo_info[] = {
2012 .name = "ricoh_ldo1", //vcc30
2017 .name = "ricoh_ldo2", //vcca33
2022 .name = "ricoh_ldo3", //vcctp
2027 .name = "ricoh_ldo4", //vccsd
2032 .name = "ricoh_ldo5", //vcc18_cif
2037 .name = "ricoh_ldo6", //vdd12
2042 .name = "ricoh_ldo7", //vcc28_cif
2047 .name = "ricoh_ldo8", //vcc25
2052 .name = "ricoh_ldo9", //vdd10
2057 .name = "ricoh_ldo10", //vcca18
2064 #include "board-pmu-ricoh619.c"
2069 static struct i2c_board_info __initdata i2c1_info[] = {
2070 #if defined (CONFIG_MFD_WM831X_I2C)
2075 .irq = RK30_PIN0_PB3,
2076 .platform_data = &wm831x_platdata,
2079 #if defined (CONFIG_MFD_TPS65910)
2082 .addr = TPS65910_I2C_ID0,
2084 .irq = TPS65910_HOST_IRQ,
2085 .platform_data = &tps65910_data,
2089 #if defined (CONFIG_REGULATOR_ACT8846)
2094 // .irq = ACT8846_HOST_IRQ,
2095 .platform_data=&act8846_data,
2098 #if defined (CONFIG_MFD_RK808)
2103 // .irq = ACT8846_HOST_IRQ,
2104 .platform_data=&rk808_data,
2108 #if defined (CONFIG_MFD_RICOH619)
2113 .irq = RICOH619_HOST_IRQ,
2114 .platform_data=&ricoh619_data,
2118 #if defined (CONFIG_RTC_HYM8563)
2120 .type = "rtc_hym8563",
2123 .irq = RK30_PIN1_PA4,
2125 #if defined (CONFIG_CW2015_BATTERY)
2130 .platform_data = &cw_bat_platdata,
2138 void __sramfunc board_pmu_suspend(void)
2140 #if defined (CONFIG_MFD_WM831X_I2C)
2141 if(pmic_is_wm8326())
2142 board_pmu_wm8326_suspend();
2144 #if defined (CONFIG_MFD_TPS65910)
2145 if(pmic_is_tps65910())
2146 board_pmu_tps65910_suspend();
2148 #if defined (CONFIG_REGULATOR_ACT8846)
2149 if(pmic_is_act8846())
2150 board_pmu_act8846_suspend();
2152 #if defined (CONFIG_MFD_RK808)
2154 board_pmu_rk808_suspend();
2156 #if defined (CONFIG_MFD_RICOH619)
2157 if(pmic_is_ricoh619())
2158 board_pmu_ricoh619_suspend();
2163 void __sramfunc board_pmu_resume(void)
2165 #if defined (CONFIG_MFD_WM831X_I2C)
2166 if(pmic_is_wm8326())
2167 board_pmu_wm8326_resume();
2169 #if defined (CONFIG_MFD_TPS65910)
2170 if(pmic_is_tps65910())
2171 board_pmu_tps65910_resume();
2173 #if defined (CONFIG_REGULATOR_ACT8846)
2174 if(pmic_is_act8846())
2175 board_pmu_act8846_resume();
2177 #if defined (CONFIG_MFD_RK808)
2179 board_pmu_rk808_resume();
2181 #if defined (CONFIG_MFD_RICOH619)
2182 if(pmic_is_ricoh619())
2183 board_pmu_ricoh619_resume();
2188 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
2190 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
2191 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
2193 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
2195 #ifdef CONFIG_RK30_PWM_REGULATOR
2197 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
2199 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
2200 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
2201 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
2202 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
2204 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
2205 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
2206 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
2207 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
2210 void __sramfunc rk30_pwm_logic_resume_voltage(void)
2212 #ifdef CONFIG_RK30_PWM_REGULATOR
2213 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
2214 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
2215 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
2216 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
2222 extern void pwm_suspend_voltage(void);
2223 extern void pwm_resume_voltage(void);
2224 void rk30_pwm_suspend_voltage_set(void)
2226 #ifdef CONFIG_RK30_PWM_REGULATOR
2227 pwm_suspend_voltage();
2230 void rk30_pwm_resume_voltage_set(void)
2232 #ifdef CONFIG_RK30_PWM_REGULATOR
2233 pwm_resume_voltage();
2238 #ifdef CONFIG_I2C2_RK30
2239 static struct i2c_board_info __initdata i2c2_info[] = {
2240 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
2242 .type = "Goodix-TS",
2245 .irq = RK30_PIN1_PB7,
2246 .platform_data = &goodix_info,
2249 #if defined (CONFIG_LS_CM3217)
2251 .type = "lightsensor",
2254 .platform_data = &cm3217_info,
2260 #ifdef CONFIG_I2C3_RK30
2261 static struct i2c_board_info __initdata i2c3_info[] = {
2265 #ifdef CONFIG_I2C4_RK30
2266 static struct i2c_board_info __initdata i2c4_info[] = {
2267 #if defined (CONFIG_MFD_RK616)
2272 .platform_data = &rk616_pdata,
2279 #ifdef CONFIG_I2C_GPIO_RK30
2280 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2281 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2282 static int rk30_i2c_io_init(void)
2284 //set iomux (gpio) here
2285 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2286 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2290 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2291 .sda_pin = I2C_SDA_PIN,
2292 .scl_pin = I2C_SCL_PIN,
2293 .udelay = 5, // clk = 500/udelay = 100Khz
2294 .timeout = 100,//msecs_to_jiffies(100),
2296 .io_init = rk30_i2c_io_init,
2298 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2302 static void __init rk30_i2c_register_board_info(void)
2304 #ifdef CONFIG_I2C0_RK30
2305 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2307 #ifdef CONFIG_I2C1_RK30
2308 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2310 #ifdef CONFIG_I2C2_RK30
2311 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2313 #ifdef CONFIG_I2C3_RK30
2314 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2316 #ifdef CONFIG_I2C4_RK30
2317 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2319 #ifdef CONFIG_I2C_GPIO_RK30
2320 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2325 // ========== Begin of rk3168 top board keypad defination ============
2327 #include <plat/key.h>
2329 static struct rk29_keys_button key_button[] = {
2332 .code = KEY_VOLUMEDOWN,
2334 .gpio = INVALID_GPIO,
2335 .active_low = PRESS_LEV_LOW,
2340 .gpio = RK30_PIN0_PA4,
2341 .active_low = PRESS_LEV_LOW,
2346 .code = KEY_VOLUMEUP,
2348 .gpio = INVALID_GPIO,
2349 .active_low = PRESS_LEV_LOW,
2355 .gpio = INVALID_GPIO,
2356 .active_low = PRESS_LEV_LOW,
2362 .gpio = INVALID_GPIO,
2363 .active_low = PRESS_LEV_LOW,
2369 .gpio = INVALID_GPIO,
2370 .active_low = PRESS_LEV_LOW,
2376 .gpio = INVALID_GPIO,
2377 .active_low = PRESS_LEV_LOW,
2380 struct rk29_keys_platform_data rk29_keys_pdata = {
2381 .buttons = key_button,
2382 .nbuttons = ARRAY_SIZE(key_button),
2383 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
2386 // =========== End of rk3168 top board keypad defination =============
2389 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2390 static void rk30_pm_power_off(void)
2392 printk(KERN_ERR "rk30_pm_power_off start...\n");
2393 #if defined(CONFIG_MFD_WM831X)
2394 if(pmic_is_wm8326()){
2395 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2396 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2400 #if defined(CONFIG_REGULATOR_ACT8846)
2401 if(pmic_is_act8846())
2403 act8846_device_shutdown();
2407 #if defined(CONFIG_MFD_TPS65910)
2408 if(pmic_is_tps65910())
2410 tps65910_device_shutdown();//tps65910 shutdown
2414 #if defined(CONFIG_MFD_RK808)
2417 rk808_device_shutdown();//rk808 shutdown
2420 #if defined(CONFIG_MFD_RICOH619)
2421 if(pmic_is_ricoh619()){
2422 ricoh619_power_off(); //ricoh619 shutdown
2426 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2430 static void __init machine_rk30_board_init(void)
2433 gpio_request(POWER_ON_PIN, "poweronpin");
2434 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2436 pm_power_off = rk30_pm_power_off;
2438 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2441 rk30_i2c_register_board_info();
2442 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2443 platform_add_devices(devices, ARRAY_SIZE(devices));
2444 rk_platform_add_display_devices();
2445 board_usb_detect_init(RK30_PIN0_PA7);
2447 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2448 rk29sdk_wifi_bt_gpio_control_init();
2449 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2450 rk29sdk_wifi_combo_module_gpio_init();
2453 #if defined(CONFIG_MT6620)
2454 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2457 #if defined(CONFIG_MT5931_MT6622)
2458 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2461 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2462 static void __init rk30_reserve(void)
2464 #if defined(CONFIG_ARCH_RK3188)
2465 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2466 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2468 int ump_mem_phy_size=512UL*1024UL*1024UL;
2469 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2470 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2474 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2476 #ifdef CONFIG_FB_ROCKCHIP
2477 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2478 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2480 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2481 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2484 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2485 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2486 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2490 #ifdef CONFIG_VIDEO_RK29
2491 rk30_camera_request_reserve_mem();
2494 #ifdef CONFIG_GPS_RK
2495 //it must be more than 8MB
2496 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2498 board_mem_reserved();
2500 /******************************** arm dvfs frequency volt table **********************************/
2502 * dvfs_cpu_logic_table: table for arm and logic dvfs
2503 * @frequency : arm frequency
2504 * @cpu_volt : arm voltage depend on frequency
2507 #if defined(CONFIG_ARCH_RK3188)
2509 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2510 {.frequency = 312 * 1000, .index = 850 * 1000},
2511 {.frequency = 504 * 1000, .index = 900 * 1000},
2512 {.frequency = 816 * 1000, .index = 950 * 1000},
2513 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2514 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2515 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2516 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2517 {.frequency = CPUFREQ_TABLE_END},
2520 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2521 {.frequency = 312 * 1000, .index = 875 * 1000},
2522 {.frequency = 504 * 1000, .index = 925 * 1000},
2523 {.frequency = 816 * 1000, .index = 975 * 1000},
2524 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2525 {.frequency = 1200 * 1000, .index = 1150 * 1000},
2526 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2527 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2528 {.frequency = CPUFREQ_TABLE_END},
2531 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2532 {.frequency = 312 * 1000, .index = 900 * 1000},
2533 {.frequency = 504 * 1000, .index = 925 * 1000},
2534 {.frequency = 816 * 1000, .index = 1000 * 1000},
2535 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2536 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2537 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2538 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2539 {.frequency = CPUFREQ_TABLE_END},
2542 /******************************** gpu dvfs frequency volt table **********************************/
2544 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {
2545 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2546 {.frequency = 200 * 1000, .index = 975 * 1000},
2547 {.frequency = 266 * 1000, .index = 1000 * 1000},
2548 {.frequency = 300 * 1000, .index = 1050 * 1000},
2549 {.frequency = 400 * 1000, .index = 1100 * 1000},
2550 {.frequency = 600 * 1000, .index = 1200 * 1000},
2551 {.frequency = CPUFREQ_TABLE_END},
2554 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {
2555 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2556 {.frequency = 200 * 1000, .index = 1000 * 1000},
2557 {.frequency = 266 * 1000, .index = 1025 * 1000},
2558 {.frequency = 300 * 1000, .index = 1050 * 1000},
2559 {.frequency = 400 * 1000, .index = 1100 * 1000},
2560 {.frequency = 600 * 1000, .index = 1250 * 1000},
2561 {.frequency = CPUFREQ_TABLE_END},
2564 /******************************** ddr dvfs frequency volt table **********************************/
2565 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2566 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2567 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2568 {.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2569 {.frequency = 460 * 1000 + DDR_FREQ_DUALVIEW, .index = 1150 * 1000},
2570 //{.frequency = 528 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2571 {.frequency = CPUFREQ_TABLE_END},
2574 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2575 #define dvfs_arm_table dvfs_arm_table_volt_level1
2576 #define dvfs_gpu_table dvfs_gpu_table_volt_level1
2577 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2580 //for RK3168 && RK3066B
2581 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2582 {.frequency = 312 * 1000, .index = 950 * 1000},
2583 {.frequency = 504 * 1000, .index = 1000 * 1000},
2584 {.frequency = 816 * 1000, .index = 1050 * 1000},
2585 {.frequency = 1008 * 1000, .index = 1125 * 1000},
2586 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2587 //{.frequency = 1416 * 1000, .index = 1250 * 1000},
2588 //{.frequency = 1608 * 1000, .index = 1300 * 1000},
2589 {.frequency = CPUFREQ_TABLE_END},
2592 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2593 {.frequency = 100 * 1000, .index = 1000 * 1000},
2594 {.frequency = 200 * 1000, .index = 1000 * 1000},
2595 {.frequency = 266 * 1000, .index = 1050 * 1000},
2596 //{.frequency = 300 * 1000, .index = 1050 * 1000},
2597 {.frequency = 400 * 1000, .index = 1125 * 1000},
2598 {.frequency = CPUFREQ_TABLE_END},
2601 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2602 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1000 * 1000},
2603 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2604 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2605 {.frequency = 450 * 1000, .index = 1150 * 1000},
2606 {.frequency = CPUFREQ_TABLE_END},
2609 /******************************** arm dvfs frequency volt table end **********************************/
2610 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2611 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2612 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2613 int get_max_freq(struct cpufreq_frequency_table *table)
2617 for(i=0;table[i].frequency!= CPUFREQ_TABLE_END;i++)
2619 if(temp<table[i].frequency)
2620 temp=table[i].frequency;
2622 printk("get_max_freq=%d\n",temp);
2626 void __init board_clock_init(void)
2628 u32 flags=RK30_CLOCKS_DEFAULT_FLAGS;
2629 #if !defined(CONFIG_ARCH_RK3188)
2630 if(get_max_freq(dvfs_gpu_table)<=(400*1000))
2632 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_GPLL;
2635 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_CPLL;
2637 rk30_clock_data_init(periph_pll_default, codec_pll_default, flags);
2638 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2639 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2640 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2641 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2644 MACHINE_START(RK30, "RK30board")
2645 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2646 .fixup = rk30_fixup,
2647 .reserve = &rk30_reserve,
2648 .map_io = rk30_map_io,
2649 .init_irq = rk30_init_irq,
2650 .timer = &rk30_timer,
2651 .init_machine = machine_rk30_board_init,