3 * Copyright (C) 2012 ROCKCHIP, Inc.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
21 #include <linux/delay.h>
22 #include <linux/i2c.h>
23 #include <linux/skbuff.h>
24 #include <linux/spi/spi.h>
25 #include <linux/mmc/host.h>
26 #include <linux/ion.h>
27 #include <linux/cpufreq.h>
28 #include <linux/clk.h>
29 #include <mach/dvfs.h>
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
38 #include <mach/board.h>
39 #include <mach/hardware.h>
41 #include <mach/gpio.h>
42 #include <mach/iomux.h>
43 #include <linux/rk_fb.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/rfkill-rk.h>
46 #include <linux/sensor-dev.h>
47 #include <linux/mfd/tps65910.h>
48 #include <linux/regulator/act8846.h>
49 #include <linux/regulator/rk29-pwm-regulator.h>
51 #ifdef CONFIG_CW2015_BATTERY
52 #include <linux/power/cw2015_battery.h>
55 #if defined(CONFIG_MFD_RK610)
56 #include <linux/mfd/rk610_core.h>
59 #if defined(CONFIG_RK_HDMI)
60 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
63 #if defined(CONFIG_SPIM_RK29)
64 #include "../../../drivers/spi/rk29_spim.h"
66 #if defined(CONFIG_GPS_RK)
67 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
69 #if defined(CONFIG_MU509)
70 #include <linux/mu509.h>
72 #if defined(CONFIG_MW100)
73 #include <linux/mw100.h>
75 #if defined(CONFIG_MT6229)
76 #include <linux/mt6229.h>
78 #if defined(CONFIG_ANDROID_TIMED_GPIO)
79 #include "../../../drivers/staging/android/timed_gpio.h"
82 #if defined(CONFIG_MT6620)
83 #include <linux/gps.h>
85 #include "board-rk3188-u30gt2-camera.c"
87 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
88 #define TOUCH_RESET_PIN RK30_PIN0_PB6
89 #define TOUCH_PWR_PIN RK30_PIN0_PC5 // need to fly line by hardware engineer
91 /* Android Parameter */
92 static int ap_mdm = 0;
93 module_param(ap_mdm, int, 0644);
94 static int ap_has_alsa = 0;
95 module_param(ap_has_alsa, int, 0644);
96 static int ap_data_only = 2;
97 module_param(ap_data_only, int, 0644);
98 static int ap_has_earphone = 0;
99 module_param(ap_has_earphone, int, 0644);
102 static int goodix_init_platform_hw(void)
106 if (TOUCH_PWR_PIN != INVALID_GPIO) {
107 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
109 gpio_free(TOUCH_PWR_PIN);
110 printk("goodix power error\n");
113 gpio_direction_output(TOUCH_PWR_PIN, 0);
114 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
118 if (TOUCH_RESET_PIN != INVALID_GPIO) {
119 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
121 gpio_free(TOUCH_RESET_PIN);
122 printk("goodix gpio_request error\n");
125 gpio_direction_output(TOUCH_RESET_PIN, 1);
127 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
129 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
135 struct goodix_platform_data goodix_info = {
137 .irq_pin = RK30_PIN1_PB7,
138 .rest_pin = TOUCH_RESET_PIN,
139 .init_platform_hw = goodix_init_platform_hw,
144 #if defined (CONFIG_TOUCHSCREEN_FT5X0X)
146 #define TOUCH_RESET_PIN RK30_PIN0_PB6
147 #define TOUCH_EN_PIN NULL
148 #define TOUCH_INT_PIN RK30_PIN1_PB7
150 static struct ts_hw_data ts_hw_info = {
151 .reset_gpio = TOUCH_RESET_PIN,
152 //.touch_en_gpio = TOUCH_POWER_PIN,
156 static struct spi_board_info board_spi_devices[] = {
159 /***********************************************************
161 ************************************************************/
162 #ifdef CONFIG_BACKLIGHT_RK29_BL
164 #define PWM_MODE PWM3
165 #define PWM_EFFECT_VALUE 0
167 #define LCD_DISP_ON_PIN
169 #ifdef LCD_DISP_ON_PIN
170 #define BL_EN_PIN RK30_PIN0_PA2
171 #define BL_EN_VALUE GPIO_HIGH
174 struct delayed_work backlight_enable_work;
175 void backlight_enable(struct work_struct *work)
177 printk("xhc function: %s\n", __func__);
178 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
181 static int rk29_backlight_io_init(void)
186 #ifdef LCD_DISP_ON_PIN
187 ret = gpio_request(BL_EN_PIN, "bl_en");
190 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
193 printk("xhc call %s()\n", __func__);
195 INIT_DELAYED_WORK(&backlight_enable_work, backlight_enable);
196 schedule_delayed_work(&backlight_enable_work, msecs_to_jiffies(300));
202 static int rk29_backlight_io_deinit(void)
204 int ret = 0, pwm_gpio;
205 #ifdef LCD_DISP_ON_PIN
206 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
207 gpio_free(BL_EN_PIN);
209 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
210 gpio_request(pwm_gpio, "bl_pwm");
211 gpio_direction_output(pwm_gpio, GPIO_LOW);
215 static int rk29_backlight_pwm_suspend(void)
217 int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
219 ret = gpio_request(pwm_gpio, "bl_pwm");
221 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
224 gpio_direction_output(pwm_gpio, GPIO_LOW);
225 #ifdef LCD_DISP_ON_PIN
226 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
231 static int rk29_backlight_pwm_resume(void)
233 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
237 #ifdef LCD_DISP_ON_PIN
240 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
246 static struct rk29_bl_info rk29_bl_info = {
250 .brightness_mode =BRIGHTNESS_MODE_CONIC,
251 .pre_div = 10 * 1000, // pwm output clk: 40k;
252 .bl_ref = PWM_EFFECT_VALUE,
253 .io_init = rk29_backlight_io_init,
254 .io_deinit = rk29_backlight_io_deinit,
255 .pwm_suspend = rk29_backlight_pwm_suspend,
256 .pwm_resume = rk29_backlight_pwm_resume,
257 .min_brightness = 50,
260 static struct platform_device rk29_device_backlight = {
261 .name = "rk29_backlight",
264 .platform_data = &rk29_bl_info,
270 #ifdef CONFIG_RK29_SUPPORT_MODEM
272 #define RK30_MODEM_POWER RK30_PIN0_PC6
273 #define RK30_MODEM_POWER_IOMUX iomux_set(GPIO0_C6)
275 static int rk30_modem_io_init(void)
277 printk("%s\n", __FUNCTION__);
278 RK30_MODEM_POWER_IOMUX;
283 static struct rk29_io_t rk30_modem_io = {
284 .io_addr = RK30_MODEM_POWER,
287 .io_init = rk30_modem_io_init,
290 static struct platform_device rk30_device_modem = {
291 .name = "rk30_modem",
294 .platform_data = &rk30_modem_io,
298 #if defined(CONFIG_MU509)
299 static int mu509_io_init(void)
310 static int mu509_io_deinit(void)
316 struct rk29_mu509_data rk29_mu509_info = {
317 .io_init = mu509_io_init,
318 .io_deinit = mu509_io_deinit,
319 .modem_power_en = RK30_PIN2_PD5,
320 .bp_power = RK30_PIN0_PC6,
321 .bp_reset = RK30_PIN2_PD4,
322 .ap_wakeup_bp = RK30_PIN0_PC4,
323 .bp_wakeup_ap = RK30_PIN0_PC5,
325 struct platform_device rk29_device_mu509 = {
329 .platform_data = &rk29_mu509_info,
333 #if defined(CONFIG_MW100)
334 static int mw100_io_init(void)
344 static int mw100_io_deinit(void)
350 struct rk29_mw100_data rk29_mw100_info = {
351 .io_init = mw100_io_init,
352 .io_deinit = mw100_io_deinit,
353 .modem_power_en = RK30_PIN2_PD5,
354 .bp_power = RK30_PIN0_PC6,
355 .bp_reset = RK30_PIN2_PD4,
356 .ap_wakeup_bp = RK30_PIN0_PC4,
357 .bp_wakeup_ap = RK30_PIN0_PC5,
359 struct platform_device rk29_device_mw100 = {
363 .platform_data = &rk29_mw100_info,
367 #if defined(CONFIG_MT6229)
368 static int mt6229_io_init(void)
378 static int mt6229_io_deinit(void)
384 struct rk29_mt6229_data rk29_mt6229_info = {
385 .io_init = mt6229_io_init,
386 .io_deinit = mt6229_io_deinit,
387 .modem_power_en = RK30_PIN2_PD5,
388 .bp_power = RK30_PIN0_PC6,
389 .bp_reset = RK30_PIN2_PD4,
390 .ap_wakeup_bp = RK30_PIN0_PC4,
391 .bp_wakeup_ap = RK30_PIN0_PC5,
393 struct platform_device rk29_device_mt6229 = {
397 .platform_data = &rk29_mt6229_info,
403 #if defined (CONFIG_GS_MMA8452)
404 #define MMA8452_INT_PIN RK30_PIN0_PB7
406 static int mma8452_init_platform_hw(void)
411 static struct sensor_platform_data mma8452_info = {
412 .type = SENSOR_TYPE_ACCEL,
415 .init_platform_hw = mma8452_init_platform_hw,
416 //.orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
417 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
420 #if defined (CONFIG_GS_LIS3DH)
421 #define LIS3DH_INT_PIN RK30_PIN0_PB7
423 static int lis3dh_init_platform_hw(void)
429 static struct sensor_platform_data lis3dh_info = {
430 .type = SENSOR_TYPE_ACCEL,
433 .init_platform_hw = lis3dh_init_platform_hw,
434 // .orientation = {0, -1, 0, 0, 0, -1, -1, 0, 0},
435 .orientation = {0, -1, 0, -1, 0, 0, 0, 0, -1},
439 #if defined(CONFIG_CHARGER_CW2015)
440 struct cw2015_platform_data cw2015_info = {
441 .dc_det_pin = RK30_PIN0_PB2,
442 .batt_low_pin = RK30_PIN0_PB1,
443 .dc_det_level = GPIO_LOW,
444 .batt_low_level = GPIO_LOW,
448 #if defined (CONFIG_COMPASS_AK8975)
449 static struct sensor_platform_data akm8975_info =
451 .type = SENSOR_TYPE_COMPASS,
484 #if defined(CONFIG_GYRO_L3G20D)
486 #include <linux/l3g4200d.h>
487 #define L3G20D_INT_PIN RK30_PIN0_PB4
489 static int l3g20d_init_platform_hw(void)
494 static struct sensor_platform_data l3g20d_info = {
495 .type = SENSOR_TYPE_GYROSCOPE,
497 .poll_delay_ms = 0, //30,
498 .orientation = {1, 0, 0, 0, -1, 0, 0, 0, -1},
499 .init_platform_hw = l3g20d_init_platform_hw,
500 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
507 #ifdef CONFIG_LS_CM3217
508 static struct sensor_platform_data cm3217_info = {
509 .type = SENSOR_TYPE_LIGHT,
511 .poll_delay_ms = 500,
516 #ifdef CONFIG_FB_ROCKCHIP
518 #define LCD_CS_PIN RK30_PIN1_PB6
519 #define LCD_CS_VALUE GPIO_HIGH
521 #define LCD_EN_PIN RK30_PIN0_PB0
522 #define LCD_EN_VALUE GPIO_LOW
524 #define LCD_PWR_PIN RK30_PIN1_PB5
525 #define LCD_PWR_VALUE GPIO_HIGH
528 #define LCD_CS_PIN_1 RK30_PIN3_PD4
529 #define LCD_CS_VALUE_1 GPIO_HIGH
531 #define LCD_PWR_PIN_1 RK30_PIN0_PA7
532 #define LCD_PWR_VALUE_1 GPIO_HIGH
536 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
540 if(LCD_CS_PIN !=INVALID_GPIO)
542 ret = gpio_request(LCD_CS_PIN, NULL);
545 gpio_free(LCD_CS_PIN);
546 printk(KERN_ERR "request lcd cs pin fail!\n");
551 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
554 if(LCD_CS_PIN_1 !=INVALID_GPIO)
556 ret = gpio_request(LCD_CS_PIN_1, NULL);
559 gpio_free(LCD_CS_PIN_1);
560 printk(KERN_ERR "request lcd cs pin fail!\n");
565 gpio_direction_output(LCD_CS_PIN_1, LCD_CS_VALUE_1);
571 if(LCD_EN_PIN !=INVALID_GPIO)
573 ret = gpio_request(LCD_EN_PIN, NULL);
576 gpio_free(LCD_EN_PIN);
577 printk(KERN_ERR "request lcd en pin fail!\n");
582 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
585 if(LCD_PWR_PIN !=INVALID_GPIO)
587 ret = gpio_request(LCD_PWR_PIN, NULL);
590 gpio_free(LCD_PWR_PIN);
591 printk(KERN_ERR "request lcd en pin fail!\n");
596 gpio_direction_output(LCD_PWR_PIN, LCD_PWR_VALUE);
599 if(LCD_PWR_PIN_1 !=INVALID_GPIO)
601 ret = gpio_request(LCD_PWR_PIN_1, NULL);
604 gpio_free(LCD_PWR_PIN_1);
605 printk(KERN_ERR "request lcd en pin fail!\n");
610 gpio_direction_output(LCD_PWR_PIN_1, LCD_PWR_VALUE_1);
619 static int rk_fb_io_disable(void)
621 if(LCD_CS_PIN !=INVALID_GPIO)
623 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
625 if(LCD_CS_PIN_1 !=INVALID_GPIO)
627 gpio_set_value(LCD_CS_PIN_1, !LCD_CS_VALUE_1);
630 if(LCD_EN_PIN !=INVALID_GPIO)
632 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
634 if(LCD_PWR_PIN !=INVALID_GPIO)
636 gpio_direction_output(LCD_PWR_PIN, !LCD_PWR_VALUE);
638 if(LCD_PWR_PIN_1 !=INVALID_GPIO)
640 gpio_direction_output(LCD_PWR_PIN_1, !LCD_PWR_VALUE_1);
647 static int rk_fb_io_enable(void)
649 if(LCD_CS_PIN !=INVALID_GPIO)
651 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
653 if(LCD_CS_PIN_1 !=INVALID_GPIO)
655 gpio_set_value(LCD_CS_PIN_1, LCD_CS_VALUE_1);
658 if(LCD_EN_PIN !=INVALID_GPIO)
660 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
662 if(LCD_PWR_PIN !=INVALID_GPIO)
664 gpio_direction_output(LCD_PWR_PIN, LCD_PWR_VALUE);
666 if(LCD_PWR_PIN_1 !=INVALID_GPIO)
668 gpio_direction_output(LCD_PWR_PIN_1, LCD_PWR_VALUE_1);
676 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
677 struct rk29fb_info lcdc0_screen_info = {
678 .prop = PRMRY, //primary display device
679 .io_init = rk_fb_io_init,
680 .io_disable = rk_fb_io_disable,
681 .io_enable = rk_fb_io_enable,
682 .set_screen_info = set_lcd_info,
686 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
687 struct rk29fb_info lcdc1_screen_info = {
688 #if defined(CONFIG_RK_HDMI)
689 .prop = EXTEND, //extend display device
691 .set_screen_info = hdmi_init_lcdc,
696 static struct resource resource_fb[] = {
700 .end = 0,//RK30_FB0_MEM_SIZE - 1,
701 .flags = IORESOURCE_MEM,
704 .name = "ipp buf", //for rotate
706 .end = 0,//RK30_FB0_MEM_SIZE - 1,
707 .flags = IORESOURCE_MEM,
712 .end = 0,//RK30_FB0_MEM_SIZE - 1,
713 .flags = IORESOURCE_MEM,
717 static struct platform_device device_fb = {
720 .num_resources = ARRAY_SIZE(resource_fb),
721 .resource = resource_fb,
724 #if defined(CONFIG_ARCH_RK3188)
725 static struct resource resource_mali[] = {
730 .flags = IORESOURCE_MEM,
735 static struct platform_device device_mali= {
736 .name = "mali400_ump",
738 .num_resources = ARRAY_SIZE(resource_mali),
739 .resource = resource_mali,
743 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
744 static struct resource resource_lcdc0[] = {
747 .start = RK30_LCDC0_PHYS,
748 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
749 .flags = IORESOURCE_MEM,
756 .flags = IORESOURCE_IRQ,
760 static struct platform_device device_lcdc0 = {
763 .num_resources = ARRAY_SIZE(resource_lcdc0),
764 .resource = resource_lcdc0,
766 .platform_data = &lcdc0_screen_info,
770 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
771 static struct resource resource_lcdc1[] = {
774 .start = RK30_LCDC1_PHYS,
775 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
776 .flags = IORESOURCE_MEM,
782 .flags = IORESOURCE_IRQ,
786 static struct platform_device device_lcdc1 = {
789 .num_resources = ARRAY_SIZE(resource_lcdc1),
790 .resource = resource_lcdc1,
792 .platform_data = &lcdc1_screen_info,
797 #if defined(CONFIG_MFD_RK610)
798 #define RK610_RST_PIN RK30_PIN2_PC5
799 static int rk610_power_on_init(void)
802 if(RK610_RST_PIN != INVALID_GPIO)
804 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
807 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
811 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
813 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
815 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
824 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
825 .rk610_power_on_init = rk610_power_on_init,
829 #ifdef CONFIG_SND_SOC_RK610
830 static int rk610_codec_io_init(void)
833 //Must not gpio_request
837 static struct rk610_codec_platform_data rk610_codec_pdata = {
838 .spk_ctl_io = RK30_PIN4_PC6,
839 .io_init = rk610_codec_io_init,
843 #ifdef CONFIG_ANDROID_TIMED_GPIO
844 static struct timed_gpio timed_gpios[] = {
847 .gpio = INVALID_GPIO,
850 .adjust_time =20, //adjust for diff product
854 static struct timed_gpio_platform_data rk29_vibrator_info = {
856 .gpios = timed_gpios,
859 static struct platform_device rk29_device_vibrator = {
860 .name = "timed-gpio",
863 .platform_data = &rk29_vibrator_info,
869 #ifdef CONFIG_LEDS_GPIO_PLATFORM
870 static struct gpio_led rk29_leds[] = {
872 .name = "button-backlight",
873 .gpio = INVALID_GPIO,
874 .default_trigger = "timer",
876 .retain_state_suspended = 0,
877 .default_state = LEDS_GPIO_DEFSTATE_OFF,
881 static struct gpio_led_platform_data rk29_leds_pdata = {
883 .num_leds = ARRAY_SIZE(rk29_leds),
886 static struct platform_device rk29_device_gpio_leds = {
890 .platform_data = &rk29_leds_pdata,
895 #ifdef CONFIG_RK_IRDA
896 #define IRDA_IRQ_PIN INVALID_GPIO //RK30_PIN0_PA3
898 static int irda_iomux_init(void)
903 ret = gpio_request(IRDA_IRQ_PIN, NULL);
905 gpio_free(IRDA_IRQ_PIN);
906 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
908 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
909 gpio_direction_input(IRDA_IRQ_PIN);
914 static int irda_iomux_deinit(void)
916 gpio_free(IRDA_IRQ_PIN);
920 static struct irda_info rk29_irda_info = {
921 .intr_pin = IRDA_IRQ_PIN,
922 .iomux_init = irda_iomux_init,
923 .iomux_deinit = irda_iomux_deinit,
924 //.irda_pwr_ctl = bu92747guw_power_ctl,
927 static struct platform_device irda_device = {
928 #ifdef CONFIG_RK_IRDA_NET
931 .name = "bu92747_irda",
935 .platform_data = &rk29_irda_info,
940 #ifdef CONFIG_RK_HDMI
941 #define RK_HDMI_RST_PIN RK30_PIN3_PB2
942 static int rk_hdmi_power_init(void)
944 if(RK_HDMI_RST_PIN != INVALID_GPIO)
946 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
947 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
950 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
951 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
953 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
958 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
959 .io_init = rk_hdmi_power_init,
963 #define ION_RESERVE_SIZE (120 * SZ_1M)
964 static struct ion_platform_data rk30_ion_pdata = {
968 .type = ION_HEAP_TYPE_CARVEOUT,
969 .id = ION_NOR_HEAP_ID,
971 .size = ION_RESERVE_SIZE,
976 static struct platform_device device_ion = {
977 .name = "ion-rockchip",
980 .platform_data = &rk30_ion_pdata,
985 /**************************************************************************************************
986 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
987 **************************************************************************************************/
988 #ifdef CONFIG_SDMMC_RK29
989 #include "board-rk3188-u30gt2-sdmmc-config.c"
990 #include "../plat-rk/rk-sdmmc-ops.c"
991 #include "../plat-rk/rk-sdmmc-wifi.c"
992 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
994 #ifdef CONFIG_SDMMC0_RK29
995 static int rk29_sdmmc0_cfg_gpio(void)
997 #ifdef CONFIG_SDMMC_RK29_OLD
999 iomux_set(MMC0_CLKOUT);
1005 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
1007 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1008 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1011 rk29_sdmmc_set_iomux(0, 0xFFFF);
1013 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
1014 #if SDMMC_USE_NEW_IOMUX_API
1015 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
1017 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
1020 #if SDMMC_USE_NEW_IOMUX_API
1021 iomux_set(MMC0_DETN);
1023 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
1027 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1028 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1029 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1037 #define CONFIG_SDMMC0_USE_DMA
1038 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1040 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1041 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1042 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1044 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1045 .io_init = rk29_sdmmc0_cfg_gpio,
1047 #if !defined(CONFIG_SDMMC_RK29_OLD)
1048 .set_iomux = rk29_sdmmc_set_iomux,
1051 .dma_name = "sd_mmc",
1052 #ifdef CONFIG_SDMMC0_USE_DMA
1058 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1059 .status = rk29sdk_wifi_mmc0_status,
1060 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1063 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1064 .power_en = RK29SDK_SD_CARD_PWR_EN,
1065 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1067 .power_en = INVALID_GPIO,
1068 .power_en_level = GPIO_LOW,
1070 .enable_sd_wakeup = 0,
1072 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1073 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1074 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1076 .write_prt = INVALID_GPIO,
1080 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1081 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1082 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1083 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1085 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1086 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1087 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1089 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1090 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1101 #endif // CONFIG_SDMMC0_RK29
1103 #ifdef CONFIG_SDMMC1_RK29
1104 #define CONFIG_SDMMC1_USE_DMA
1105 static int rk29_sdmmc1_cfg_gpio(void)
1107 #if defined(CONFIG_SDMMC_RK29_OLD)
1108 iomux_set(MMC1_CMD);
1109 iomux_set(MMC1_CLKOUT);
1116 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1117 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1118 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1126 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1128 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1129 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1132 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1133 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1134 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1137 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1140 .io_init = rk29_sdmmc1_cfg_gpio,
1142 #if !defined(CONFIG_SDMMC_RK29_OLD)
1143 .set_iomux = rk29_sdmmc_set_iomux,
1147 #ifdef CONFIG_SDMMC1_USE_DMA
1153 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1154 .status = rk29sdk_wifi_status,
1155 .register_status_notify = rk29sdk_wifi_status_register,
1158 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1159 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1160 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1162 .write_prt = INVALID_GPIO,
1165 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1166 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1170 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1171 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1172 .io = RK29SDK_SD_CARD_DETECT_N,
1177 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1178 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1180 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1181 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1182 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1184 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1185 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1195 .enable_sd_wakeup = 0,
1197 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1199 /**************************************************************************************************
1200 * the end of setting for SDMMC devices
1201 **************************************************************************************************/
1203 #ifdef CONFIG_BATTERY_RK30_ADC
1204 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1205 .dc_det_pin = RK30_PIN0_PB2,
1206 .batt_low_pin = RK30_PIN0_PB1,
1207 .charge_set_pin = INVALID_GPIO,
1208 .charge_ok_pin = RK30_PIN0_PA6,
1209 .dc_det_level = GPIO_LOW,
1210 .charge_ok_level = GPIO_HIGH,
1213 static struct platform_device rk30_device_adc_battery = {
1214 .name = "rk30-battery",
1217 .platform_data = &rk30_adc_battery_platdata,
1222 #ifdef CONFIG_CW2015_BATTERY
1224 static u8 config_info[SIZE_BATINFO] = {
1225 0x15, 0x42, 0x60, 0x59, 0x52,
\r
1226 0x58, 0x4D, 0x48, 0x48, 0x44,
\r
1227 0x44, 0x46, 0x49, 0x48, 0x32,
\r
1228 0x24, 0x20, 0x17, 0x13, 0x0F,
\r
1229 0x19, 0x3E, 0x51, 0x45, 0x08,
\r
1230 0x76, 0x0B, 0x85, 0x0E, 0x1C,
\r
1231 0x2E, 0x3E, 0x4D, 0x52, 0x52,
\r
1232 0x57, 0x3D, 0x1B, 0x6A, 0x2D,
\r
1233 0x25, 0x43, 0x52, 0x87, 0x8F,
\r
1234 0x91, 0x94, 0x52, 0x82, 0x8C,
\r
1235 0x92, 0x96, 0xFF, 0x7B, 0xBB,
\r
1236 0xCB, 0x2F, 0x7D, 0x72, 0xA5,
\r
1237 0xB5, 0xC1, 0x46, 0xAE
1240 static struct cw_bat_platform_data cw_bat_platdata = {
1241 .dc_det_pin = RK30_PIN0_PB2,
1242 .bat_low_pin = RK30_PIN0_PB1,
1243 .chg_ok_pin = RK30_PIN0_PA6,
1244 .dc_det_level = GPIO_LOW,
1245 .bat_low_level = GPIO_LOW,
1246 .chg_ok_level = GPIO_HIGH,
1248 .cw_bat_config_info = config_info,
1255 #ifdef CONFIG_RK30_PWM_REGULATOR
1256 static int pwm_voltage_map[] = {
1257 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1259 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1261 .supply = "vdd_cpu",
1265 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1269 .name = "PWM_DCDC1",
1271 .max_uV = 1800000, //0.6-1.8V
1273 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1275 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1276 .consumer_supplies = pwm_dcdc1_consumers,
1280 static struct pwm_platform_data pwm_regulator_info[1] = {
1283 .pwm_gpio = RK30_PIN3_PD4,
1284 .pwm_iomux_pwm = PWM1,
1285 .pwm_iomux_gpio = GPIO3_D4,
1286 .pwm_voltage = 1100000,
1287 .suspend_voltage = 1000000,
1290 .coefficient = 575, //57.5%
1291 .pwm_voltage_map = pwm_voltage_map,
1292 .init_data = &pwm_regulator_init_dcdc[0],
1296 struct platform_device pwm_regulator_device[1] = {
1298 .name = "pwm-voltage-regulator",
1301 .platform_data = &pwm_regulator_info[0],
1307 #ifdef CONFIG_RK29_VMAC
1308 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1309 #include "board-rk30-sdk-vmac.c"
1312 #ifdef CONFIG_RFKILL_RK
1313 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1314 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1315 .type = RFKILL_TYPE_BLUETOOTH,
1317 .poweron_gpio = { // BT_REG_ON
1318 .io = RK30_PIN3_PC7,
1319 .enable = GPIO_HIGH,
1321 .name = "bt_poweron",
1326 .reset_gpio = { // BT_RST
1327 .io = RK30_PIN3_PD1,//RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1335 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1336 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1337 .enable = GPIO_HIGH,
1344 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1346 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1347 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1354 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1355 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1365 static struct platform_device device_rfkill_rk = {
1366 .name = "rfkill_rk",
1369 .platform_data = &rfkill_rk_platdata,
1374 #if defined(CONFIG_GPS_RK)
1375 int rk_gps_io_init(void)
1377 printk("%s \n", __FUNCTION__);
1379 gpio_request(RK30_PIN1_PB5, NULL);
1380 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1382 iomux_set(GPS_RFCLK);//GPS_CLK
1383 iomux_set(GPS_MAG);//GPS_MAG
1384 iomux_set(GPS_SIG);//GPS_SIGN
1386 gpio_request(RK30_PIN1_PA6, NULL);
1387 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1389 gpio_request(RK30_PIN1_PA5, NULL);
1390 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1392 gpio_request(RK30_PIN1_PA7, NULL);
1393 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1396 int rk_gps_power_up(void)
1398 printk("%s \n", __FUNCTION__);
1403 int rk_gps_power_down(void)
1405 printk("%s \n", __FUNCTION__);
1410 int rk_gps_reset_set(int level)
1414 int rk_enable_hclk_gps(void)
1416 struct clk *gps_aclk = NULL;
1417 gps_aclk = clk_get(NULL, "aclk_gps");
1419 clk_enable(gps_aclk);
1421 printk("%s \n", __FUNCTION__);
1424 printk("get gps aclk fail\n");
1427 int rk_disable_hclk_gps(void)
1429 struct clk *gps_aclk = NULL;
1430 gps_aclk = clk_get(NULL, "aclk_gps");
1432 //TO wait long enough until GPS ISR is finished.
1434 clk_disable(gps_aclk);
1436 printk("%s \n", __FUNCTION__);
1439 printk("get gps aclk fail\n");
1442 struct rk_gps_data rk_gps_info = {
1443 .io_init = rk_gps_io_init,
1444 .power_up = rk_gps_power_up,
1445 .power_down = rk_gps_power_down,
1446 .reset = rk_gps_reset_set,
1447 .enable_hclk_gps = rk_enable_hclk_gps,
1448 .disable_hclk_gps = rk_disable_hclk_gps,
1449 .GpsSign = RK30_PIN1_PB3,
1450 .GpsMag = RK30_PIN1_PB2, //GPIO index
1451 .GpsClk = RK30_PIN1_PB4, //GPIO index
1452 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1453 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1454 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1455 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1459 .u32GpsPhyAddr = RK30_GPS_PHYS,
1460 .u32GpsPhySize = RK30_GPS_SIZE,
1463 struct platform_device rk_device_gps = {
1464 .name = "gps_hv5820b",
1467 .platform_data = &rk_gps_info,
1473 static struct platform_device *devices[] __initdata = {
1477 #ifdef CONFIG_ANDROID_TIMED_GPIO
1478 &rk29_device_vibrator,
1480 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1481 &rk29_device_gpio_leds,
1483 #ifdef CONFIG_RK_IRDA
1486 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1487 &rk29sdk_wifi_device,
1490 #if defined(CONFIG_MT6620)
1494 #ifdef CONFIG_RK29_SUPPORT_MODEM
1497 #if defined(CONFIG_MU509)
1500 #if defined(CONFIG_MW100)
1503 #if defined(CONFIG_MT6229)
1504 &rk29_device_mt6229,
1506 #ifdef CONFIG_BATTERY_RK30_ADC
1507 &rk30_device_adc_battery,
1509 #ifdef CONFIG_RFKILL_RK
1512 #ifdef CONFIG_GPS_RK
1515 #if defined(CONFIG_ARCH_RK3188)
1520 static int rk_platform_add_display_devices(void)
1522 struct platform_device *fb = NULL; //fb
1523 struct platform_device *lcdc0 = NULL; //lcdc0
1524 struct platform_device *lcdc1 = NULL; //lcdc1
1525 struct platform_device *bl = NULL; //backlight
1526 #ifdef CONFIG_FB_ROCKCHIP
1530 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1531 lcdc0 = &device_lcdc0,
1534 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1535 lcdc1 = &device_lcdc1,
1538 #ifdef CONFIG_BACKLIGHT_RK29_BL
1539 bl = &rk29_device_backlight,
1541 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1548 #ifdef CONFIG_I2C0_RK30
1549 static struct i2c_board_info __initdata i2c0_info[] = {
1550 #if defined (CONFIG_GS_LSM303D)
1553 .addr = 0x1d, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1557 #if defined (CONFIG_GS_MMA8452)
1559 .type = "gs_mma8452",
1562 .irq = MMA8452_INT_PIN,
1563 .platform_data = &mma8452_info,
1566 #if defined (CONFIG_GS_LIS3DH)
1568 .type = "gs_lis3dh",
1569 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1571 .irq = LIS3DH_INT_PIN,
1572 .platform_data = &lis3dh_info,
1575 #if defined (CONFIG_COMPASS_AK8975)
1580 .irq = RK30_PIN3_PD7,
1581 .platform_data = &akm8975_info,
1584 #if defined (CONFIG_GYRO_L3G20D)
1586 .type = "l3g20d_gryo",
1589 .irq = L3G20D_INT_PIN,
1590 .platform_data = &l3g20d_info,
1593 #if defined (CONFIG_SND_SOC_RK1000)
1595 .type = "rk1000_i2c_codec",
1600 .type = "rk1000_control",
1605 #if defined (CONFIG_SND_SOC_RT5631)
1612 #if defined (CONFIG_SND_RK29_SOC_ES8323)
1614 .type = "es8323",//"es8323",
1620 #ifdef CONFIG_MFD_RK610
1622 .type = "rk610_ctl",
1625 .platform_data = &rk610_ctl_pdata,
1627 #ifdef CONFIG_RK610_TVOUT
1629 .type = "rk610_tvout",
1634 #ifdef CONFIG_HDMI_RK610
1636 .type = "rk610_hdmi",
1639 .irq = INVALID_GPIO,
1642 #ifdef CONFIG_SND_SOC_RK610
1643 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1644 .type = "rk610_i2c_codec",
1647 .platform_data = &rk610_codec_pdata,
1655 int __sramdata g_pmic_type = 0;
1656 #ifdef CONFIG_I2C1_RK30
1657 #ifdef CONFIG_MFD_WM831X_I2C
1658 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1660 static struct pmu_info wm8326_dcdc_info[] = {
1662 .name = "vdd_core", //logic
1665 .suspend_vol = 950000,
1668 .name = "vdd_cpu", //arm
1671 .suspend_vol = 950000,
1674 .name = "dcdc3", //ddr
1677 .suspend_vol = 1150000,
1679 #ifdef CONFIG_MACH_RK3066_SDK
1681 .name = "dcdc4", //vcc_io
1684 .suspend_vol = 3000000,
1688 .name = "dcdc4", //vcc_io
1691 .suspend_vol = 2800000,
1696 static struct pmu_info wm8326_ldo_info[] = {
1698 .name = "ldo1", //vcc18_cif
1701 .suspend_vol = 1800000,
1704 .name = "ldo2", //vccio_wl
1707 .suspend_vol = 1800000,
1713 .suspend_vol = 1100000,
1716 .name = "ldo4", //vdd11
1719 .suspend_vol = 1000000,
1722 .name = "ldo5", //vcc25
1725 .suspend_vol = 1800000,
1728 .name = "ldo6", //vcc33
1731 .suspend_vol = 3300000,
1734 .name = "ldo7", //vcc28_cif
1737 .suspend_vol = 2800000,
1740 .name = "ldo8", //vcca33
1743 .suspend_vol = 3300000,
1746 .name = "ldo9", //vcc_tp
1749 .suspend_vol = 3300000,
1752 .name = "ldo10", //flash_io
1755 .suspend_vol = 1800000,
1759 #include "board-pmu-wm8326.c"
1762 #ifdef CONFIG_MFD_TPS65910
1763 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1765 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1767 static struct pmu_info tps65910_dcdc_info[] = {
1769 .name = "vdd_core", //logic
1774 .name = "vdd2", //ddr
1779 .name = "vio", //vcc_io
1785 static struct pmu_info tps65910_ldo_info[] = {
1787 .name = "vpll", //vdd10
1792 .name = "vdig1", //vcc18_cif
1797 .name = "vdig2", //vdd_jetta
1802 .name = "vaux1", //vcc28_cif
1807 .name = "vaux2", //vcca33
1812 .name = "vaux33", //vcc_tp
1817 .name = "vmmc", //vcc30
1822 .name = "vdac", //vcc18
1828 #include "board-pmu-tps65910.c"
1831 #ifdef CONFIG_REGULATOR_ACT8846
1832 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1833 #define PMU_VSEL RK30_PIN3_PD3
1834 static struct pmu_info act8846_dcdc_info[] = {
1836 .name = "act_dcdc1", //ddr
1839 .suspend_vol = 1200000,
1842 .name = "vdd_core", //logic
1845 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1846 .suspend_vol = 1200000,
1848 .suspend_vol = 900000,
1853 .name = "vdd_cpu", //arm
1856 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1857 .suspend_vol = 1200000,
1859 .suspend_vol = 900000,
1864 .name = "act_dcdc4", //vccio
1867 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1868 .suspend_vol = 3000000,
1870 .suspend_vol = 2800000,
1876 static struct pmu_info act8846_ldo_info[] = {
1878 .name = "act_ldo1", //vdd11
1883 .name = "act_ldo2", //vdd12
1888 .name = "act_ldo3", //vcc18_cif
1893 .name = "act_ldo4", //vcca33
1898 .name = "act_ldo5", //vcctp
1903 .name = "act_ldo6", //vcc33
1908 .name = "act_ldo7", //vccio_wl
1913 .name = "act_ldo8", //vcc28_cif
1919 #include "../mach-rk30/board-pmu-act8846.c"
1923 static struct i2c_board_info __initdata i2c1_info[] = {
1924 #if defined (CONFIG_MFD_WM831X_I2C)
1929 .irq = RK30_PIN0_PB3,
1930 .platform_data = &wm831x_platdata,
1933 #if defined (CONFIG_MFD_TPS65910)
1936 .addr = TPS65910_I2C_ID0,
1938 .irq = TPS65910_HOST_IRQ,
1939 .platform_data = &tps65910_data,
1943 #if defined (CONFIG_REGULATOR_ACT8846)
1948 // .irq = ACT8846_HOST_IRQ,
1949 .platform_data=&act8846_data,
1952 #if defined (CONFIG_RTC_HYM8563)
1954 .type = "rtc_hym8563",
1957 .irq = RK30_PIN1_PA4,
1960 #if defined (CONFIG_CHARGER_CW2015)
1965 .platform_data = &cw2015_info,
1969 #if defined (CONFIG_CW2015_BATTERY)
1974 .platform_data = &cw_bat_platdata,
1981 void __sramfunc board_pmu_suspend(void)
1983 #if defined (CONFIG_MFD_WM831X_I2C)
1984 if(pmic_is_wm8326())
1985 board_pmu_wm8326_suspend();
1987 #if defined (CONFIG_MFD_TPS65910)
1988 if(pmic_is_tps65910())
1989 board_pmu_tps65910_suspend();
1991 #if defined (CONFIG_REGULATOR_ACT8846)
1992 if(pmic_is_act8846())
1993 board_pmu_act8846_suspend();
1998 void __sramfunc board_pmu_resume(void)
2000 #if defined (CONFIG_MFD_WM831X_I2C)
2001 if(pmic_is_wm8326())
2002 board_pmu_wm8326_resume();
2004 #if defined (CONFIG_MFD_TPS65910)
2005 if(pmic_is_tps65910())
2006 board_pmu_tps65910_resume();
2008 #if defined (CONFIG_REGULATOR_ACT8846)
2009 if(pmic_is_act8846())
2010 board_pmu_act8846_resume();
2014 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
2016 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
2017 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
2019 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
2021 #ifdef CONFIG_RK30_PWM_REGULATOR
2023 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
2025 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
2026 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
2027 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
2028 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
2030 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
2031 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
2032 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
2033 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
2036 void __sramfunc rk30_pwm_logic_resume_voltage(void)
2038 #ifdef CONFIG_RK30_PWM_REGULATOR
2039 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
2040 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
2041 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
2042 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
2048 extern void pwm_suspend_voltage(void);
2049 extern void pwm_resume_voltage(void);
2050 void rk30_pwm_suspend_voltage_set(void)
2052 #ifdef CONFIG_RK30_PWM_REGULATOR
2053 pwm_suspend_voltage();
2056 void rk30_pwm_resume_voltage_set(void)
2058 #ifdef CONFIG_RK30_PWM_REGULATOR
2059 pwm_resume_voltage();
2063 #if defined (CONFIG_TOUCHSCREEN_FT5406)
2064 #define TOUCH_RESET_PIN RK30_PIN0_PB6
2065 #define TOUCH_INT_PIN RK30_PIN1_PB7
2066 int ft5406_init_platform_hw(void)
2068 printk("ft5406_init_platform_hw\n");
2069 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
2070 gpio_free(TOUCH_RESET_PIN);
2071 printk("ft5406_init_platform_hw gpio_request error\n");
2075 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
2076 gpio_free(TOUCH_INT_PIN);
2077 printk("ift5406_init_platform_hw gpio_request error\n");
2081 gpio_direction_output(TOUCH_RESET_PIN, 0);
2082 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
2084 gpio_direction_input(TOUCH_INT_PIN);
2086 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
2091 void ft5406_exit_platform_hw(void)
2093 printk("ft5406_exit_platform_hw\n");
2094 gpio_free(TOUCH_RESET_PIN);
2095 gpio_free(TOUCH_INT_PIN);
2098 int ft5406_platform_sleep(void)
2100 printk("ft5406_platform_sleep\n");
2101 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
2105 int ft5406_platform_wakeup(void)
2107 printk("ft5406_platform_wakeup\n");
2108 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
2113 struct ft5406_platform_data ft5406_info = {
2115 .init_platform_hw= ft5406_init_platform_hw,
2116 .exit_platform_hw= ft5406_exit_platform_hw,
2117 .platform_sleep = ft5406_platform_sleep,
2118 .platform_wakeup = ft5406_platform_wakeup,
2122 #ifdef CONFIG_I2C2_RK30
2123 static struct i2c_board_info __initdata i2c2_info[] = {
2124 #if defined (CONFIG_TOUCHSCREEN_FT5406)
2127 .addr = 0x38, //0x70,
2129 .irq =RK30_PIN1_PB7, // support goodix tp detect, 20110706
2130 .platform_data = &ft5406_info,
2133 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
2135 .type = "Goodix-TS",
2138 .irq = RK30_PIN1_PB7,
2139 .platform_data = &goodix_info,
2143 #if defined (CONFIG_TOUCHSCREEN_FT5X0X)
2145 .type = "ft5x0x_ts",
2148 .irq = RK30_PIN1_PB7,
2149 //.platform_data = &ft5x0x_info,
2150 .platform_data = &ts_hw_info,
2154 #if defined (CONFIG_LS_CM3217)
2156 .type = "lightsensor",
2159 .platform_data = &cm3217_info,
2162 #if defined (CONFIG_LS_US5151)
2169 //#ifdef CONFIG_U30GT_V3
2170 #if defined(CONFIG_HDMI_CAT66121)
2172 .type = "cat66121_hdmi",
2175 .irq = RK30_PIN2_PD6,
2176 .platform_data = &rk_hdmi_pdata,
2183 #ifdef CONFIG_I2C3_RK30
2184 static struct i2c_board_info __initdata i2c3_info[] = {
2188 #ifdef CONFIG_I2C4_RK30
2189 static struct i2c_board_info __initdata i2c4_info[] = {
2190 #if defined(CONFIG_HDMI_CAT6611)
2192 .type = "cat6611_hdmi",
2195 .irq = RK30_PIN1_PB7,
2198 //#ifdef CONFIG_U30GT_V3
2199 #if defined (CONFIG_SND_RK29_SOC_ES8323)
2201 .type = "es8323",//"es8323",
2210 #ifdef CONFIG_I2C_GPIO_RK30
2211 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2212 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2213 static int rk30_i2c_io_init(void)
2215 //set iomux (gpio) here
2216 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2217 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2221 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2222 .sda_pin = I2C_SDA_PIN,
2223 .scl_pin = I2C_SCL_PIN,
2224 .udelay = 5, // clk = 500/udelay = 100Khz
2225 .timeout = 100,//msecs_to_jiffies(100),
2227 .io_init = rk30_i2c_io_init,
2229 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2233 static void __init rk30_i2c_register_board_info(void)
2235 #ifdef CONFIG_I2C0_RK30
2236 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2238 #ifdef CONFIG_I2C1_RK30
2239 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2241 #ifdef CONFIG_I2C2_RK30
2242 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2244 #ifdef CONFIG_I2C3_RK30
2245 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2247 #ifdef CONFIG_I2C4_RK30
2248 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2250 #ifdef CONFIG_I2C_GPIO_RK30
2251 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2256 // ========== Begin of rk3168 top board keypad defination ============
2258 #include <plat/key.h>
2260 static struct rk29_keys_button key_button[] = {
2263 .code = KEY_VOLUMEDOWN,
2265 .gpio = INVALID_GPIO,
2266 .active_low = PRESS_LEV_LOW,
2271 .gpio = RK30_PIN0_PA4,
2272 .active_low = PRESS_LEV_LOW,
2277 .code = KEY_VOLUMEUP,
2279 .gpio = INVALID_GPIO,
2280 .active_low = PRESS_LEV_LOW,
2287 .gpio = INVALID_GPIO,
2288 .active_low = PRESS_LEV_LOW,
2294 .gpio = INVALID_GPIO,
2295 .active_low = PRESS_LEV_LOW,
2301 .gpio = INVALID_GPIO,
2302 .active_low = PRESS_LEV_LOW,
2308 .gpio = INVALID_GPIO,
2309 .active_low = PRESS_LEV_LOW,
2313 struct rk29_keys_platform_data rk29_keys_pdata = {
2314 .buttons = key_button,
2315 .nbuttons = ARRAY_SIZE(key_button),
2316 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
2319 // =========== End of rk3168 top board keypad defination =============
2322 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2323 static void rk30_pm_power_off(void)
2325 printk(KERN_ERR "rk30_pm_power_off start...\n");
2326 #if defined(CONFIG_MFD_WM831X)
2327 if(pmic_is_wm8326()){
2328 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2329 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2333 #if defined(CONFIG_REGULATOR_ACT8846)
2334 if(pmic_is_act8846())
2336 act8846_device_shutdown();
2340 #if defined(CONFIG_MFD_TPS65910)
2341 if(pmic_is_tps65910())
2343 tps65910_device_shutdown();//tps65910 shutdown
2347 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2351 static void __init machine_rk30_board_init(void)
2354 writel_relaxed(0x03000300, RK30_GRF_BASE + 0xf8);
2355 gpio_request(POWER_ON_PIN, "poweronpin");
2356 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2358 // gpio_direction_output(RK30_PIN1_PB4, GPIO_LOW);
2359 //gpio_direction_output(RK30_PIN3_PD5, GPIO_HIGH);
2361 pm_power_off = rk30_pm_power_off;
2363 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2366 rk30_i2c_register_board_info();
2367 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2368 platform_add_devices(devices, ARRAY_SIZE(devices));
2369 rk_platform_add_display_devices();
2370 // board_usb_detect_init(RK30_PIN0_PA7);
2372 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2373 rk29sdk_wifi_bt_gpio_control_init();
2374 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2375 rk29sdk_wifi_combo_module_gpio_init();
2378 #if defined(CONFIG_MT6620)
2379 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2382 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2383 static void __init rk30_reserve(void)
2385 #if defined(CONFIG_ARCH_RK3188)
2386 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2387 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2389 int ump_mem_phy_size=512UL*1024UL*1024UL;
2390 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2391 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2395 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2397 #ifdef CONFIG_FB_ROCKCHIP
2398 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2399 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2401 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2402 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2405 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2406 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2407 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2411 #ifdef CONFIG_VIDEO_RK29
2412 rk30_camera_request_reserve_mem();
2415 #ifdef CONFIG_GPS_RK
2416 //it must be more than 8MB
2417 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2419 board_mem_reserved();
2421 /******************************** arm dvfs frequency volt table **********************************/
2423 * dvfs_cpu_logic_table: table for arm and logic dvfs
2424 * @frequency : arm frequency
2425 * @cpu_volt : arm voltage depend on frequency
2430 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2431 {.frequency = 312 * 1000, .index = 850 * 1000},
2432 {.frequency = 504 * 1000, .index = 900 * 1000},
2433 {.frequency = 816 * 1000, .index = 950 * 1000},
2434 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2435 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2436 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2437 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2438 {.frequency = CPUFREQ_TABLE_END},
2441 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2442 {.frequency = 312 * 1000, .index = 875 * 1000},
2443 {.frequency = 504 * 1000, .index = 925 * 1000},
2444 {.frequency = 816 * 1000, .index = 975 * 1000},
2445 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2446 {.frequency = 1200 * 1000, .index = 1150 * 1000},
2447 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2448 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2449 {.frequency = CPUFREQ_TABLE_END},
2453 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2454 {.frequency = 312 * 1000, .index = 900 * 1000},
2455 {.frequency = 504 * 1000, .index = 925 * 1000},
2456 {.frequency = 816 * 1000, .index = 1000 * 1000},
2457 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2458 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2459 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2460 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2461 {.frequency = CPUFREQ_TABLE_END},
2463 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2464 #define dvfs_arm_table dvfs_arm_table_volt_level2
2466 /******************************** gpu dvfs frequency volt table **********************************/
2468 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {
2469 #if defined(CONFIG_ARCH_RK3188)
2470 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2471 #elif defined(CONFIG_ARCH_RK3066B)
2472 {.frequency = 100 * 1000, .index = 950 * 1000},//the minimum rate is no limit for rk3168 rk3066B
2475 {.frequency = 200 * 1000, .index = 1025 * 1000},
2476 {.frequency = 266 * 1000, .index = 1025 * 1000},
2477 {.frequency = 300 * 1000, .index = 1050 * 1000},
2478 {.frequency = 400 * 1000, .index = 1100 * 1000},
2479 {.frequency = 600 * 1000, .index = 1250 * 1000},
2480 {.frequency = CPUFREQ_TABLE_END},
2484 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {
2485 #if defined(CONFIG_ARCH_RK3188)
2486 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2487 #elif defined(CONFIG_ARCH_RK3066B)
2488 {.frequency = 100 * 1000, .index = 950 * 1000},//the minimum rate is no limit for rk3168 rk3066B
2491 {.frequency = 200 * 1000, .index = 1000 * 1000},
2492 {.frequency = 266 * 1000, .index = 1025 * 1000},
2493 {.frequency = 300 * 1000, .index = 1050 * 1000},
2494 {.frequency = 400 * 1000, .index = 1100 * 1000},
2495 {.frequency = 600 * 1000, .index = 1250 * 1000},
2496 {.frequency = CPUFREQ_TABLE_END},
2500 #define dvfs_gpu_table dvfs_gpu_table_volt_level0
2502 /******************************** ddr dvfs frequency volt table **********************************/
2503 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2504 #if defined(CONFIG_ARCH_RK3188)
2505 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2506 // {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2508 {.frequency = 528* 1000 + DDR_FREQ_NORMAL, .index = 1250 * 1000},
2509 // {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2510 {.frequency = CPUFREQ_TABLE_END},
2513 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2515 /******************************** arm dvfs frequency volt table end **********************************/
2519 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2520 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2521 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2523 void __init board_clock_init(void)
2525 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2526 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2527 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2528 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2529 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2532 MACHINE_START(RK30, "RK30board")
2533 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2534 .fixup = rk30_fixup,
2535 .reserve = &rk30_reserve,
2536 .map_io = rk30_map_io,
2537 .init_irq = rk30_init_irq,
2538 .timer = &rk30_timer,
2539 .init_machine = machine_rk30_board_init,