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 #if defined(CONFIG_MFD_RK610)
52 #include <linux/mfd/rk610_core.h>
55 #if defined(CONFIG_DP_ANX6345)
56 #include<linux/anx6345.h>
59 #if defined(CONFIG_CT36X_TS)
60 #include <linux/ct36x.h>
63 #if defined(CONFIG_RK_HDMI)
64 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
67 #if defined(CONFIG_SPIM_RK29)
68 #include "../../../drivers/spi/rk29_spim.h"
70 #if defined(CONFIG_GPS_RK)
71 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
74 #if defined(CONFIG_MU509)
75 #include <linux/mu509.h>
77 #if defined(CONFIG_MW100)
78 #include <linux/mw100.h>
80 #if defined(CONFIG_MT6229)
81 #include <linux/mt6229.h>
83 #if defined(CONFIG_ANDROID_TIMED_GPIO)
84 #include "../../../drivers/staging/android/timed_gpio.h"
88 #include "board-rk3168-LR097-camera.c"
90 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
91 #define TOUCH_RESET_PIN RK30_PIN0_PB6
92 #define TOUCH_PWR_PIN RK30_PIN0_PC5 // need to fly line by hardware engineer
93 static int goodix_init_platform_hw(void)
97 if (TOUCH_PWR_PIN != INVALID_GPIO) {
98 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
100 gpio_free(TOUCH_PWR_PIN);
101 printk("goodix power error\n");
104 gpio_direction_output(TOUCH_PWR_PIN, 0);
105 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
109 if (TOUCH_RESET_PIN != INVALID_GPIO) {
110 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
112 gpio_free(TOUCH_RESET_PIN);
113 printk("goodix gpio_request error\n");
116 gpio_direction_output(TOUCH_RESET_PIN, 1);
118 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
120 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
126 struct goodix_platform_data goodix_info = {
128 .irq_pin = RK30_PIN1_PB7,
129 .rest_pin = TOUCH_RESET_PIN,
130 .init_platform_hw = goodix_init_platform_hw,
135 #if defined(CONFIG_CT36X_TS)
137 #define TOUCH_MODEL 363
138 #define TOUCH_MAX_X 1280
139 #define TOUCH_MAX_y 800
140 #define TOUCH_RESET_PIN RK30_PIN0_PB6
141 #define TOUCH_INT_PIN RK30_PIN1_PB7
143 static struct ct36x_platform_data ct36x_info = {
144 .model = TOUCH_MODEL,
145 .x_max = TOUCH_MAX_X,
146 .y_max = TOUCH_MAX_y,
149 .gpio = TOUCH_RESET_PIN,
153 .gpio = TOUCH_INT_PIN,
156 .orientation = {1, 0, 0, 1},
160 static struct spi_board_info board_spi_devices[] = {
163 /***********************************************************
165 ************************************************************/
166 #ifdef CONFIG_BACKLIGHT_RK29_BL
168 #define PWM_MODE PWM3
169 #define PWM_EFFECT_VALUE 0
171 #define LCD_DISP_ON_PIN
173 #ifdef LCD_DISP_ON_PIN
174 #define BL_EN_PIN RK30_PIN0_PA2
175 #define BL_EN_VALUE GPIO_HIGH
177 static int rk29_backlight_io_init(void)
182 #ifdef LCD_DISP_ON_PIN
183 ret = gpio_request(BL_EN_PIN, "bl_en");
185 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
191 static int rk29_backlight_io_deinit(void)
193 int ret = 0, pwm_gpio;
194 #ifdef LCD_DISP_ON_PIN
195 gpio_free(BL_EN_PIN);
197 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
198 gpio_request(pwm_gpio, "bl_pwm");
199 gpio_direction_output(pwm_gpio, GPIO_LOW);
203 static int rk29_backlight_pwm_suspend(void)
205 int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
207 ret = gpio_request(pwm_gpio, "bl_pwm");
209 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
212 gpio_direction_output(pwm_gpio, GPIO_LOW);
213 #ifdef LCD_DISP_ON_PIN
214 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
219 static int rk29_backlight_pwm_resume(void)
221 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
225 #ifdef LCD_DISP_ON_PIN
227 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
232 static struct rk29_bl_info rk29_bl_info = {
234 .min_brightness = 50,
236 .brightness_mode =BRIGHTNESS_MODE_CONIC,
237 .pre_div = 30 * 1000,
238 .bl_ref = PWM_EFFECT_VALUE,
239 .io_init = rk29_backlight_io_init,
240 .io_deinit = rk29_backlight_io_deinit,
241 .pwm_suspend = rk29_backlight_pwm_suspend,
242 .pwm_resume = rk29_backlight_pwm_resume,
245 static struct platform_device rk29_device_backlight = {
246 .name = "rk29_backlight",
249 .platform_data = &rk29_bl_info,
255 #ifdef CONFIG_RK29_SUPPORT_MODEM
257 #define RK30_MODEM_POWER RK30_PIN0_PC6
258 #define RK30_MODEM_POWER_IOMUX iomux_set(GPIO0_C6)
260 static int rk30_modem_io_init(void)
262 printk("%s\n", __FUNCTION__);
263 RK30_MODEM_POWER_IOMUX;
268 static struct rk29_io_t rk30_modem_io = {
269 .io_addr = RK30_MODEM_POWER,
272 .io_init = rk30_modem_io_init,
275 static struct platform_device rk30_device_modem = {
276 .name = "rk30_modem",
279 .platform_data = &rk30_modem_io,
283 #if defined(CONFIG_MU509)
284 static int mu509_io_init(void)
295 static int mu509_io_deinit(void)
301 struct rk29_mu509_data rk29_mu509_info = {
302 .io_init = mu509_io_init,
303 .io_deinit = mu509_io_deinit,
304 .modem_power_en = RK30_PIN2_PD5,
305 .bp_power = RK30_PIN0_PC6,
306 .bp_reset = RK30_PIN2_PD4,
307 .ap_wakeup_bp = RK30_PIN0_PC4,
308 .bp_wakeup_ap = RK30_PIN0_PC5,
310 struct platform_device rk29_device_mu509 = {
314 .platform_data = &rk29_mu509_info,
318 #if defined(CONFIG_MW100)
319 static int mw100_io_init(void)
329 static int mw100_io_deinit(void)
335 struct rk29_mw100_data rk29_mw100_info = {
336 .io_init = mw100_io_init,
337 .io_deinit = mw100_io_deinit,
338 .modem_power_en = RK30_PIN2_PD5,
339 .bp_power = RK30_PIN0_PC6,
340 .bp_reset = RK30_PIN2_PD4,
341 .ap_wakeup_bp = RK30_PIN0_PC4,
342 .bp_wakeup_ap = RK30_PIN0_PC5,
344 struct platform_device rk29_device_mw100 = {
348 .platform_data = &rk29_mw100_info,
352 #if defined(CONFIG_MT6229)
353 static int mt6229_io_init(void)
363 static int mt6229_io_deinit(void)
369 struct rk29_mt6229_data rk29_mt6229_info = {
370 .io_init = mt6229_io_init,
371 .io_deinit = mt6229_io_deinit,
372 .modem_power_en = RK30_PIN2_PD5,
373 .bp_power = RK30_PIN0_PC6,
374 .bp_reset = RK30_PIN2_PD4,
375 .ap_wakeup_bp = RK30_PIN0_PC4,
376 .bp_wakeup_ap = RK30_PIN0_PC5,
378 struct platform_device rk29_device_mt6229 = {
382 .platform_data = &rk29_mt6229_info,
388 #if defined (CONFIG_GS_MMA8452)
389 #define MMA8452_INT_PIN RK30_PIN0_PB7
391 static int mma8452_init_platform_hw(void)
396 static struct sensor_platform_data mma8452_info = {
397 .type = SENSOR_TYPE_ACCEL,
400 .init_platform_hw = mma8452_init_platform_hw,
401 .orientation = {1, 0, 0, 0, -1, 0, 0, 0, -1},
404 #if defined (CONFIG_GS_LIS3DH)
405 #define LIS3DH_INT_PIN RK30_PIN0_PB7
407 static int lis3dh_init_platform_hw(void)
413 static struct sensor_platform_data lis3dh_info = {
414 .type = SENSOR_TYPE_ACCEL,
417 .init_platform_hw = lis3dh_init_platform_hw,
418 .orientation = {1, 0, 0, 0, -1, 0, 0, 0, -1},
421 #if defined(CONFIG_CHARGER_CW2015)
422 struct cw2015_platform_data cw2015_info = {
423 .dc_det_pin = RK30_PIN0_PB2,
424 .batt_low_pin = RK30_PIN0_PB1,
425 //.charge_ok_pin = RK30_PIN0_PA6,
426 .dc_det_level = GPIO_LOW,
427 .batt_low_level = GPIO_LOW,
428 //.charge_ok_level = GPIO_HIGH,
431 #if defined (CONFIG_COMPASS_AK8975)
432 static struct sensor_platform_data akm8975_info =
434 .type = SENSOR_TYPE_COMPASS,
467 #if defined(CONFIG_GYRO_L3G4200D)
469 #include <linux/l3g4200d.h>
470 #define L3G4200D_INT_PIN RK30_PIN0_PB4
472 static int l3g4200d_init_platform_hw(void)
477 static struct sensor_platform_data l3g4200d_info = {
478 .type = SENSOR_TYPE_GYROSCOPE,
481 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
482 .init_platform_hw = l3g4200d_init_platform_hw,
483 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
490 #ifdef CONFIG_LS_CM3217
491 static struct sensor_platform_data cm3217_info = {
492 .type = SENSOR_TYPE_LIGHT,
494 .poll_delay_ms = 500,
499 #ifdef CONFIG_FB_ROCKCHIP
501 #define LCD_CS_PIN INVALID_GPIO
502 #define LCD_CS_VALUE GPIO_HIGH
504 #define LCD_EN_PIN INVALID_GPIO
505 #define LCD_EN_VALUE GPIO_HIGH
507 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
511 if(LCD_CS_PIN !=INVALID_GPIO)
513 ret = gpio_request(LCD_CS_PIN, NULL);
516 gpio_free(LCD_CS_PIN);
517 printk(KERN_ERR "request lcd cs pin fail!\n");
522 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
526 if(LCD_EN_PIN !=INVALID_GPIO)
528 ret = gpio_request(LCD_EN_PIN, NULL);
531 gpio_free(LCD_EN_PIN);
532 printk(KERN_ERR "request lcd en pin fail!\n");
537 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
542 static int rk_fb_io_disable(void)
544 if(LCD_CS_PIN !=INVALID_GPIO)
546 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
548 if(LCD_EN_PIN !=INVALID_GPIO)
550 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
554 static int rk_fb_io_enable(void)
556 if(LCD_CS_PIN !=INVALID_GPIO)
558 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
560 if(LCD_EN_PIN !=INVALID_GPIO)
562 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
567 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
568 struct rk29fb_info lcdc0_screen_info = {
569 .prop = PRMRY, //primary display device
570 .io_init = rk_fb_io_init,
571 .io_disable = rk_fb_io_disable,
572 .io_enable = rk_fb_io_enable,
573 .set_screen_info = set_lcd_info,
577 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
578 struct rk29fb_info lcdc1_screen_info = {
579 #if defined(CONFIG_RK_HDMI)
580 .prop = EXTEND, //extend display device
582 .set_screen_info = hdmi_init_lcdc,
587 static struct resource resource_fb[] = {
591 .end = 0,//RK30_FB0_MEM_SIZE - 1,
592 .flags = IORESOURCE_MEM,
595 .name = "ipp buf", //for rotate
597 .end = 0,//RK30_FB0_MEM_SIZE - 1,
598 .flags = IORESOURCE_MEM,
603 .end = 0,//RK30_FB0_MEM_SIZE - 1,
604 .flags = IORESOURCE_MEM,
608 static struct platform_device device_fb = {
611 .num_resources = ARRAY_SIZE(resource_fb),
612 .resource = resource_fb,
616 #if defined(CONFIG_ARCH_RK3188)
617 static struct resource resource_mali[] = {
622 .flags = IORESOURCE_MEM,
627 static struct platform_device device_mali= {
628 .name = "mali400_ump",
630 .num_resources = ARRAY_SIZE(resource_mali),
631 .resource = resource_mali,
635 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
636 static struct resource resource_lcdc0[] = {
639 .start = RK30_LCDC0_PHYS,
640 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
641 .flags = IORESOURCE_MEM,
648 .flags = IORESOURCE_IRQ,
652 static struct platform_device device_lcdc0 = {
655 .num_resources = ARRAY_SIZE(resource_lcdc0),
656 .resource = resource_lcdc0,
658 .platform_data = &lcdc0_screen_info,
662 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
663 static struct resource resource_lcdc1[] = {
666 .start = RK30_LCDC1_PHYS,
667 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
668 .flags = IORESOURCE_MEM,
674 .flags = IORESOURCE_IRQ,
678 static struct platform_device device_lcdc1 = {
681 .num_resources = ARRAY_SIZE(resource_lcdc1),
682 .resource = resource_lcdc1,
684 .platform_data = &lcdc1_screen_info,
689 #if defined(CONFIG_MFD_RK610)
690 #define RK610_RST_PIN RK30_PIN2_PC5
691 static int rk610_power_on_init(void)
694 if(RK610_RST_PIN != INVALID_GPIO)
696 // rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
697 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
700 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
704 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
706 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
708 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
710 printk("%s........rst ok\n",__func__);
718 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
719 .rk610_power_on_init = rk610_power_on_init,
723 #ifdef CONFIG_SND_SOC_RK610
724 static int rk610_codec_io_init(void)
727 //Must not gpio_request
731 static struct rk610_codec_platform_data rk610_codec_pdata = {
732 .spk_ctl_io = RK30_PIN2_PD7,
733 .io_init = rk610_codec_io_init,
737 #ifdef CONFIG_RK_HDMI
738 #define RK_HDMI_RST_PIN RK30_PIN3_PB2
739 static int rk_hdmi_power_init(void)
743 if(RK_HDMI_RST_PIN != INVALID_GPIO)
745 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
746 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
749 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
750 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
752 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
757 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
758 .io_init = rk_hdmi_power_init,
762 #ifdef CONFIG_ANDROID_TIMED_GPIO
763 static struct timed_gpio timed_gpios[] = {
766 .gpio = INVALID_GPIO,
769 .adjust_time =20, //adjust for diff product
773 static struct timed_gpio_platform_data rk29_vibrator_info = {
775 .gpios = timed_gpios,
778 static struct platform_device rk29_device_vibrator = {
779 .name = "timed-gpio",
782 .platform_data = &rk29_vibrator_info,
788 #ifdef CONFIG_DP_ANX6345
790 #define DVDD33_EN_PIN RK30_PIN0_PB0
791 #define DVDD33_EN_VALUE GPIO_LOW
793 #define DVDD18_EN_PIN RK30_PIN3_PD4//RK30_PIN3_PD4//RK30_PIN1_PB6//RK30_PIN4_PC7
794 #define DVDD18_EN_VALUE GPIO_HIGH
796 #define EDP_RST_PIN RK30_PIN0_PB4
797 static int rk_edp_power_ctl(void)
800 ret = gpio_request(DVDD33_EN_PIN, "dvdd33_en_pin");
803 gpio_free(DVDD33_EN_PIN);
804 printk(KERN_ERR "request dvdd33 en pin fail!\n");
809 gpio_direction_output(DVDD33_EN_PIN, DVDD33_EN_VALUE);
813 ret = gpio_request(DVDD18_EN_PIN, "dvdd18_en_pin");
816 gpio_free(DVDD18_EN_PIN);
817 printk(KERN_ERR "request dvdd18 en pin fail!\n");
822 gpio_direction_output(DVDD18_EN_PIN, DVDD18_EN_VALUE);
825 ret = gpio_request(EDP_RST_PIN, "edp_rst_pin");
828 gpio_free(EDP_RST_PIN);
829 printk(KERN_ERR "request rst pin fail!\n");
834 gpio_direction_output(EDP_RST_PIN, GPIO_LOW);
836 gpio_direction_output(EDP_RST_PIN, GPIO_HIGH);
841 static struct anx6345_platform_data anx6345_platform_data = {
842 .power_ctl = rk_edp_power_ctl,
843 .dvdd33_en_pin = DVDD33_EN_PIN,
844 .dvdd33_en_val = DVDD33_EN_VALUE,
845 .dvdd18_en_pin = DVDD18_EN_PIN,
846 .dvdd18_en_val = DVDD18_EN_VALUE,
847 .edp_rst_pin = EDP_RST_PIN,
851 #ifdef CONFIG_LEDS_GPIO_PLATFORM
852 static struct gpio_led rk29_leds[] = {
854 .name = "button-backlight",
855 .gpio = RK30_PIN2_PB3,
856 .default_trigger = "timer",
858 .retain_state_suspended = 0,
859 .default_state = LEDS_GPIO_DEFSTATE_OFF,
863 static struct gpio_led_platform_data rk29_leds_pdata = {
865 .num_leds = ARRAY_SIZE(rk29_leds),
868 static struct platform_device rk29_device_gpio_leds = {
872 .platform_data = &rk29_leds_pdata,
877 #ifdef CONFIG_RK_IRDA
878 #define IRDA_IRQ_PIN RK30_PIN0_PA3
880 static int irda_iomux_init(void)
885 ret = gpio_request(IRDA_IRQ_PIN, NULL);
887 gpio_free(IRDA_IRQ_PIN);
888 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
890 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
891 gpio_direction_input(IRDA_IRQ_PIN);
896 static int irda_iomux_deinit(void)
898 gpio_free(IRDA_IRQ_PIN);
902 static struct irda_info rk29_irda_info = {
903 .intr_pin = IRDA_IRQ_PIN,
904 .iomux_init = irda_iomux_init,
905 .iomux_deinit = irda_iomux_deinit,
906 //.irda_pwr_ctl = bu92747guw_power_ctl,
909 static struct platform_device irda_device = {
910 #ifdef CONFIG_RK_IRDA_NET
913 .name = "bu92747_irda",
917 .platform_data = &rk29_irda_info,
923 #define ION_RESERVE_SIZE (80 * SZ_1M)
924 static struct ion_platform_data rk30_ion_pdata = {
928 .type = ION_HEAP_TYPE_CARVEOUT,
929 .id = ION_NOR_HEAP_ID,
931 .size = ION_RESERVE_SIZE,
936 static struct platform_device device_ion = {
937 .name = "ion-rockchip",
940 .platform_data = &rk30_ion_pdata,
945 /**************************************************************************************************
946 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
947 **************************************************************************************************/
948 #ifdef CONFIG_SDMMC_RK29
949 #include "board-LR097-sdmmc-config.c"
950 #include "../plat-rk/rk-sdmmc-ops.c"
951 #include "../plat-rk/rk-sdmmc-wifi.c"
952 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
954 #ifdef CONFIG_SDMMC0_RK29
955 static int rk29_sdmmc0_cfg_gpio(void)
957 #ifdef CONFIG_SDMMC_RK29_OLD
959 iomux_set(MMC0_CLKOUT);
965 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
967 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
968 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
971 rk29_sdmmc_set_iomux(0, 0xFFFF);
973 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
974 #if SDMMC_USE_NEW_IOMUX_API
975 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
977 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
980 #if SDMMC_USE_NEW_IOMUX_API
981 iomux_set(MMC0_DETN);
983 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
987 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
988 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
989 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
997 #define CONFIG_SDMMC0_USE_DMA
998 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1000 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1001 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1002 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1004 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1005 .io_init = rk29_sdmmc0_cfg_gpio,
1007 #if !defined(CONFIG_SDMMC_RK29_OLD)
1008 .set_iomux = rk29_sdmmc_set_iomux,
1011 .dma_name = "sd_mmc",
1012 #ifdef CONFIG_SDMMC0_USE_DMA
1018 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1019 .status = rk29sdk_wifi_mmc0_status,
1020 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1023 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1024 .power_en = RK29SDK_SD_CARD_PWR_EN,
1025 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1027 .power_en = INVALID_GPIO,
1028 .power_en_level = GPIO_LOW,
1030 .enable_sd_wakeup = 0,
1032 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1033 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1034 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1036 .write_prt = INVALID_GPIO,
1040 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1041 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1042 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1043 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1045 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1046 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1047 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1049 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1050 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1061 #endif // CONFIG_SDMMC0_RK29
1063 #ifdef CONFIG_SDMMC1_RK29
1064 #define CONFIG_SDMMC1_USE_DMA
1065 static int rk29_sdmmc1_cfg_gpio(void)
1067 #if defined(CONFIG_SDMMC_RK29_OLD)
1068 iomux_set(MMC1_CMD);
1069 iomux_set(MMC1_CLKOUT);
1076 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1077 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1078 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1086 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1088 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1089 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1092 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1093 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1094 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1097 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1100 .io_init = rk29_sdmmc1_cfg_gpio,
1102 #if !defined(CONFIG_SDMMC_RK29_OLD)
1103 .set_iomux = rk29_sdmmc_set_iomux,
1107 #ifdef CONFIG_SDMMC1_USE_DMA
1113 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1114 .status = rk29sdk_wifi_status,
1115 .register_status_notify = rk29sdk_wifi_status_register,
1118 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1119 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1120 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1122 .write_prt = INVALID_GPIO,
1125 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1126 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1130 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1131 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1132 .io = RK29SDK_SD_CARD_DETECT_N,
1137 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1138 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1140 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1141 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1142 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1144 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1145 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1155 .enable_sd_wakeup = 0,
1157 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1159 /**************************************************************************************************
1160 * the end of setting for SDMMC devices
1161 **************************************************************************************************/
1163 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1165 static int batt_table[2*11+6] =
1167 0x4B434F52,0x7461625F,0x79726574,1,470,100,
1168 6800, 7242, 7332, 7404, 7470, 7520, 7610, 7744, 7848, 8016, 8284,//discharge
1169 7630, 7754, 7852, 7908, 7956, 8024, 8112, 8220, 8306, 8318, 8458//charge
1172 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1173 .dc_det_pin = RK30_PIN0_PB2,
1174 .batt_low_pin = INVALID_GPIO,
1175 .charge_set_pin = INVALID_GPIO,
1176 .charge_ok_pin = RK30_PIN0_PA6,
1177 .dc_det_level = GPIO_LOW,
1178 .charge_ok_level = GPIO_HIGH,
1180 .reference_voltage = 1800,
1181 .pull_up_res = 470, //divider resistance , pull-up resistor
1182 .pull_down_res = 100, //divider resistance , pull-down resistor
1183 .is_reboot_charging = 1,
1184 .save_capacity = 1 ,
1185 .use_board_table = 1,
1186 .board_batt_table = batt_table,
1189 static struct platform_device rk30_device_adc_battery = {
1190 .name = "rk30-battery",
1193 .platform_data = &rk30_adc_battery_platdata,
1197 #ifdef CONFIG_RK30_PWM_REGULATOR
1198 static int pwm_voltage_map[] = {
1199 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1201 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1203 .supply = "vdd_cpu",
1207 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1211 .name = "PWM_DCDC1",
1213 .max_uV = 1800000, //0.6-1.8V
1215 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1217 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1218 .consumer_supplies = pwm_dcdc1_consumers,
1222 static struct pwm_platform_data pwm_regulator_info[1] = {
1225 .pwm_gpio = RK30_PIN3_PD4,
1226 .pwm_iomux_pwm = PWM1,
1227 .pwm_iomux_gpio = GPIO3_D4,
1228 .pwm_voltage = 1100000,
1229 .suspend_voltage = 1000000,
1232 .coefficient = 575, //57.5%
1233 .pwm_voltage_map = pwm_voltage_map,
1234 .init_data = &pwm_regulator_init_dcdc[0],
1238 struct platform_device pwm_regulator_device[1] = {
1240 .name = "pwm-voltage-regulator",
1243 .platform_data = &pwm_regulator_info[0],
1249 #ifdef CONFIG_RK29_VMAC
1250 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1251 #include "board-rk30-sdk-vmac.c"
1254 #ifdef CONFIG_RFKILL_RK
1255 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1256 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1257 .type = RFKILL_TYPE_BLUETOOTH,
1259 .poweron_gpio = { // BT_REG_ON
1260 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1261 .enable = GPIO_HIGH,
1263 .name = "bt_poweron",
1268 .reset_gpio = { // BT_RST
1269 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1277 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1278 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1279 .enable = GPIO_HIGH,
1286 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1288 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1289 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1296 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1297 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1307 static struct platform_device device_rfkill_rk = {
1308 .name = "rfkill_rk",
1311 .platform_data = &rfkill_rk_platdata,
1316 #if defined(CONFIG_GPS_RK)
1317 int rk_gps_io_init(void)
1319 printk("%s \n", __FUNCTION__);
1321 gpio_request(RK30_PIN1_PB5, NULL);
1322 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1324 iomux_set(GPS_RFCLK);//GPS_CLK
1325 iomux_set(GPS_MAG);//GPS_MAG
1326 iomux_set(GPS_SIG);//GPS_SIGN
1328 gpio_request(RK30_PIN1_PA6, NULL);
1329 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1331 gpio_request(RK30_PIN1_PA5, NULL);
1332 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1334 gpio_request(RK30_PIN1_PA7, NULL);
1335 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1338 int rk_gps_power_up(void)
1340 printk("%s \n", __FUNCTION__);
1345 int rk_gps_power_down(void)
1347 printk("%s \n", __FUNCTION__);
1352 int rk_gps_reset_set(int level)
1356 int rk_enable_hclk_gps(void)
1358 printk("%s \n", __FUNCTION__);
1359 clk_enable(clk_get(NULL, "hclk_gps"));
1362 int rk_disable_hclk_gps(void)
1364 printk("%s \n", __FUNCTION__);
1365 clk_disable(clk_get(NULL, "hclk_gps"));
1368 struct rk_gps_data rk_gps_info = {
1369 .io_init = rk_gps_io_init,
1370 .power_up = rk_gps_power_up,
1371 .power_down = rk_gps_power_down,
1372 .reset = rk_gps_reset_set,
1373 .enable_hclk_gps = rk_enable_hclk_gps,
1374 .disable_hclk_gps = rk_disable_hclk_gps,
1375 .GpsSign = RK30_PIN1_PB3,
1376 .GpsMag = RK30_PIN1_PB2, //GPIO index
1377 .GpsClk = RK30_PIN1_PB4, //GPIO index
1378 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1379 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1380 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1381 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1385 .u32GpsPhyAddr = RK30_GPS_PHYS,
1386 .u32GpsPhySize = RK30_GPS_SIZE,
1389 struct platform_device rk_device_gps = {
1390 .name = "gps_hv5820b",
1393 .platform_data = &rk_gps_info,
1398 #if defined(CONFIG_MT5931_MT6622)
1399 static struct mt6622_platform_data mt6622_platdata = {
1400 .power_gpio = { // BT_REG_ON
1401 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1402 .enable = GPIO_HIGH,
1404 .name = "mt6622_power",
1409 .reset_gpio = { // BT_RST
1410 .io = RK30_PIN3_PD1,
1411 .enable = GPIO_HIGH,
1418 .io = RK30_PIN0_PA5,
1426 static struct platform_device device_mt6622 = {
1430 .platform_data = &mt6622_platdata,
1436 static struct platform_device *devices[] __initdata = {
1440 #ifdef CONFIG_ANDROID_TIMED_GPIO
1441 &rk29_device_vibrator,
1443 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1444 &rk29_device_gpio_leds,
1446 #ifdef CONFIG_RK_IRDA
1449 #ifdef CONFIG_WIFI_CONTROL_FUNC
1450 &rk29sdk_wifi_device,
1452 #ifdef CONFIG_RK29_SUPPORT_MODEM
1455 #if defined(CONFIG_MU509)
1458 #if defined(CONFIG_MW100)
1461 #if defined(CONFIG_MT6229)
1462 &rk29_device_mt6229,
1464 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1465 &rk30_device_adc_battery,
1467 #ifdef CONFIG_RFKILL_RK
1470 #ifdef CONFIG_GPS_RK
1473 #ifdef CONFIG_MT5931_MT6622
1476 #if defined(CONFIG_ARCH_RK3188)
1481 static int rk_platform_add_display_devices(void)
1483 struct platform_device *fb = NULL; //fb
1484 struct platform_device *lcdc0 = NULL; //lcdc0
1485 struct platform_device *lcdc1 = NULL; //lcdc1
1486 struct platform_device *bl = NULL; //backlight
1487 #ifdef CONFIG_FB_ROCKCHIP
1491 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1492 lcdc0 = &device_lcdc0,
1495 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1496 lcdc1 = &device_lcdc1,
1499 #ifdef CONFIG_BACKLIGHT_RK29_BL
1500 bl = &rk29_device_backlight,
1502 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1508 #ifdef CONFIG_I2C0_RK30
1509 static struct i2c_board_info __initdata i2c0_info[] = {
1510 #if defined (CONFIG_GS_MMA8452)
1512 .type = "gs_mma8452",
1515 .irq = MMA8452_INT_PIN,
1516 .platform_data = &mma8452_info,
1519 #if defined (CONFIG_GS_LIS3DH)
1521 .type = "gs_lis3dh",
1522 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1524 .irq = LIS3DH_INT_PIN,
1525 .platform_data = &lis3dh_info,
1528 #if defined (CONFIG_COMPASS_AK8975)
1533 .irq = RK30_PIN3_PD7,
1534 .platform_data = &akm8975_info,
1537 #if defined (CONFIG_GYRO_L3G4200D)
1539 .type = "l3g4200d_gryo",
1542 .irq = L3G4200D_INT_PIN,
1543 .platform_data = &l3g4200d_info,
1546 #if defined (CONFIG_SND_SOC_RK1000)
1548 .type = "rk1000_i2c_codec",
1553 .type = "rk1000_control",
1558 #if defined (CONFIG_CHARGER_CW2015)
1563 .platform_data = &cw2015_info,
1569 int __sramdata g_pmic_type = 0;
1570 #ifdef CONFIG_I2C1_RK30
1572 #ifdef CONFIG_MFD_WM831X_I2C
1573 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1575 static struct pmu_info wm8326_dcdc_info[] = {
1577 .name = "vdd_core", //logic
1580 .suspend_vol = 950000,
1583 .name = "vdd_cpu", //arm
1586 .suspend_vol = 950000,
1589 .name = "dcdc3", //ddr
1592 .suspend_vol = 1150000,
1594 #ifdef CONFIG_MACH_RK3066_SDK
1596 .name = "dcdc4", //vcc_io
1599 .suspend_vol = 3000000,
1603 .name = "dcdc4", //vcc_io
1606 .suspend_vol = 2800000,
1611 static struct pmu_info wm8326_ldo_info[] = {
1613 .name = "ldo1", //vcc18_cif
1616 .suspend_vol = 1800000,
1619 .name = "ldo2", //vccio_wl
1622 .suspend_vol = 1800000,
1628 .suspend_vol = 1100000,
1631 .name = "ldo4", //vdd11
1634 .suspend_vol = 1000000,
1637 .name = "ldo5", //vcc25
1640 .suspend_vol = 1800000,
1643 .name = "ldo6", //vcc33
1646 .suspend_vol = 3300000,
1649 .name = "ldo7", //vcc28_cif
1652 .suspend_vol = 2800000,
1655 .name = "ldo8", //vcca33
1658 .suspend_vol = 3300000,
1661 .name = "ldo9", //vcc_tp
1664 .suspend_vol = 3300000,
1667 .name = "ldo10", //flash_io
1670 .suspend_vol = 1800000,
1674 #include "board-pmu-wm8326.c"
1677 #ifdef CONFIG_MFD_TPS65910
1679 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1681 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1683 static struct pmu_info tps65910_dcdc_info[] = {
1685 .name = "vdd_core", //logic
1690 .name = "vdd2", //ddr
1695 .name = "vio", //vcc_io
1701 static struct pmu_info tps65910_ldo_info[] = {
1703 .name = "vpll", //vdd10
1708 .name = "vdig1", //vcc18_cif
1713 .name = "vdig2", //vdd_jetta
1718 .name = "vaux1", //vcc28_cif
1723 .name = "vaux2", //vcca33
1728 .name = "vaux33", //vcc_tp
1733 .name = "vmmc", //vcc30
1738 .name = "vdac", //vcc18
1744 #include "board-pmu-tps65910.c"
1747 #ifdef CONFIG_REGULATOR_ACT8846
1748 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1749 #define ACT8846_HOST_IRQ RK30_PIN0_PB3
1750 #define PMU_VSEL RK30_PIN3_PD3
1752 static struct pmu_info act8846_dcdc_info[] = {
1754 .name = "act_dcdc1", //ddr
1757 .suspend_vol = 1200000,
1760 .name = "vdd_core", //logic
1763 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1764 .suspend_vol = 1200000,
1766 .suspend_vol = 900000,
1770 .name = "vdd_cpu", //arm
1773 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1774 .suspend_vol = 1200000,
1776 .suspend_vol = 900000,
1780 .name = "act_dcdc4", //vccio
1783 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1784 .suspend_vol = 3000000,
1786 .suspend_vol = 2800000,
1791 static struct pmu_info act8846_ldo_info[] = {
1793 .name = "act_ldo1", //vdd11
1798 .name = "act_ldo2", //vdd12
1803 .name = "act_ldo3", //vcc18_cif
1808 .name = "act_ldo4", //vcca33
1813 .name = "act_ldo5", //vcctp
1818 .name = "act_ldo6", //vcc33
1823 .name = "act_ldo7", //vccio_wl
1828 .name = "act_ldo8", //vcc28_cif
1834 #include "board-pmu-act8846.c"
1837 static struct i2c_board_info __initdata i2c1_info[] = {
1838 #if defined (CONFIG_MFD_WM831X_I2C)
1843 .irq = RK30_PIN0_PB3,
1844 .platform_data = &wm831x_platdata,
1847 #if defined (CONFIG_MFD_TPS65910)
1850 .addr = TPS65910_I2C_ID0,
1852 .irq = TPS65910_HOST_IRQ,
1853 .platform_data = &tps65910_data,
1856 #if defined (CONFIG_REGULATOR_ACT8846)
1861 // .irq = ACT8846_HOST_IRQ,
1862 .platform_data=&act8846_data,
1865 #if defined (CONFIG_RTC_HYM8563)
1867 .type = "rtc_hym8563",
1870 .irq = RK30_PIN0_PB5,
1876 void __sramfunc board_pmu_suspend(void)
1878 #if defined (CONFIG_MFD_WM831X_I2C)
1879 if(pmic_is_wm8326())
1880 board_pmu_wm8326_suspend();
1882 #if defined (CONFIG_MFD_TPS65910)
1883 if(pmic_is_tps65910())
1884 board_pmu_tps65910_suspend();
1886 #if defined (CONFIG_REGULATOR_ACT8846)
1887 if(pmic_is_act8846())
1888 board_pmu_act8846_suspend();
1892 void __sramfunc board_pmu_resume(void)
1894 #if defined (CONFIG_MFD_WM831X_I2C)
1895 if(pmic_is_wm8326())
1896 board_pmu_wm8326_resume();
1898 #if defined (CONFIG_MFD_TPS65910)
1899 if(pmic_is_tps65910())
1900 board_pmu_tps65910_resume();
1902 #if defined (CONFIG_REGULATOR_ACT8846)
1903 if(pmic_is_act8846())
1904 board_pmu_act8846_resume();
1909 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1911 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1912 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1914 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1916 #ifdef CONFIG_RK30_PWM_REGULATOR
1918 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1920 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1921 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1922 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1923 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1925 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1926 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1927 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1928 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1931 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1933 #ifdef CONFIG_RK30_PWM_REGULATOR
1934 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1935 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1936 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1937 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1943 extern void pwm_suspend_voltage(void);
1944 extern void pwm_resume_voltage(void);
1945 void rk30_pwm_suspend_voltage_set(void)
1947 #ifdef CONFIG_RK30_PWM_REGULATOR
1948 pwm_suspend_voltage();
1951 void rk30_pwm_resume_voltage_set(void)
1953 #ifdef CONFIG_RK30_PWM_REGULATOR
1954 pwm_resume_voltage();
1959 #ifdef CONFIG_I2C2_RK30
1960 static struct i2c_board_info __initdata i2c2_info[] = {
1961 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1963 .type = "Goodix-TS",
1966 .irq = RK30_PIN1_PB7,
1967 .platform_data = &goodix_info,
1970 #if defined (CONFIG_LS_CM3217)
1972 .type = "lightsensor",
1975 .platform_data = &cm3217_info,
1979 #if defined (CONFIG_DP_ANX6345)
1984 .platform_data = &anx6345_platform_data,
1989 #if defined (CONFIG_CT36X_TS)
1994 .platform_data = &ct36x_info,
1997 #if defined(CONFIG_HDMI_CAT66121)
1999 .type = "cat66121_hdmi",
2002 .irq = RK30_PIN2_PD6,
2003 .platform_data = &rk_hdmi_pdata,
2010 #ifdef CONFIG_I2C3_RK30
2011 static struct i2c_board_info __initdata i2c3_info[] = {
2015 #ifdef CONFIG_I2C4_RK30
2016 static struct i2c_board_info __initdata i2c4_info[] = {
2017 #ifdef CONFIG_MFD_RK610
2019 .type = "rk610_ctl",
2022 .platform_data = &rk610_ctl_pdata,
2024 #ifdef CONFIG_RK610_TVOUT
2026 .type = "rk610_tvout",
2031 #ifdef CONFIG_HDMI_RK610
2033 .type = "rk610_hdmi",
2036 .irq = INVALID_GPIO,
2039 #ifdef CONFIG_SND_SOC_RK610
2040 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
2041 .type = "rk610_i2c_codec",
2044 .platform_data = &rk610_codec_pdata,
2048 #ifdef CONFIG_SND_SOC_RT5631
2059 #ifdef CONFIG_I2C_GPIO_RK30
2060 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2061 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2062 static int rk30_i2c_io_init(void)
2064 //set iomux (gpio) here
2065 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2066 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2070 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2071 .sda_pin = I2C_SDA_PIN,
2072 .scl_pin = I2C_SCL_PIN,
2073 .udelay = 5, // clk = 500/udelay = 100Khz
2074 .timeout = 100,//msecs_to_jiffies(100),
2076 .io_init = rk30_i2c_io_init,
2078 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2082 static void __init rk30_i2c_register_board_info(void)
2084 #ifdef CONFIG_I2C0_RK30
2085 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2087 #ifdef CONFIG_I2C1_RK30
2088 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2090 #ifdef CONFIG_I2C2_RK30
2091 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2093 #ifdef CONFIG_I2C3_RK30
2094 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2096 #ifdef CONFIG_I2C4_RK30
2097 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2099 #ifdef CONFIG_I2C_GPIO_RK30
2100 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2105 // ========== Begin of rk3168 top board keypad defination ============
2107 #include <plat/key.h>
2109 static struct rk29_keys_button key_button[] = {
2112 .code = KEY_VOLUMEDOWN,
2114 .gpio = INVALID_GPIO,
2115 .active_low = PRESS_LEV_LOW,
2120 .gpio = RK30_PIN0_PA4,
2121 .active_low = PRESS_LEV_LOW,
2126 .code = KEY_VOLUMEUP,
2128 .gpio = INVALID_GPIO,
2129 .active_low = PRESS_LEV_LOW,
2136 .gpio = INVALID_GPIO,
2137 .active_low = PRESS_LEV_LOW,
2144 .gpio = INVALID_GPIO,
2145 .active_low = PRESS_LEV_LOW,
2152 .gpio = INVALID_GPIO,
2153 .active_low = PRESS_LEV_LOW,
2160 .gpio = INVALID_GPIO,
2161 .active_low = PRESS_LEV_LOW,
2165 struct rk29_keys_platform_data rk29_keys_pdata = {
2166 .buttons = key_button,
2167 .nbuttons = ARRAY_SIZE(key_button),
2168 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
2171 // =========== End of rk3168 top board keypad defination =============
2174 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2175 static void rk30_pm_power_off(void)
2177 printk(KERN_ERR "rk30_pm_power_off start...\n");
2178 #if defined(CONFIG_MFD_WM831X)
2179 if(pmic_is_wm8326()){
2180 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2181 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2185 #if defined(CONFIG_REGULATOR_ACT8846)
2186 if(pmic_is_act8846())
2188 printk("enter dcdet:");
2189 if(gpio_get_value (RK30_PIN0_PB2) == GPIO_LOW)
2191 printk("with dc:enter restart system\n");
2192 arm_pm_restart(0, NULL);
2196 printk("without dc,shutdown system\n");
2197 act8846_device_shutdown();
2203 #if defined(CONFIG_MFD_TPS65910)
2204 if(pmic_is_tps65910())
2206 tps65910_device_shutdown();//tps65910 shutdown
2210 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2214 static void __init machine_rk30_board_init(void)
2217 gpio_request(POWER_ON_PIN, "poweronpin");
2218 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2220 pm_power_off = rk30_pm_power_off;
2222 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2225 rk30_i2c_register_board_info();
2226 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2227 platform_add_devices(devices, ARRAY_SIZE(devices));
2228 rk_platform_add_display_devices();
2229 board_usb_detect_init(RK30_PIN0_PA7);
2231 #ifdef CONFIG_WIFI_CONTROL_FUNC
2232 rk29sdk_wifi_bt_gpio_control_init();
2234 #if defined(CONFIG_MT5931_MT6622)
2235 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2239 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2240 static void __init rk30_reserve(void)
2242 #if defined(CONFIG_ARCH_RK3188)
2243 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2244 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2246 int ump_mem_phy_size=256UL*1024UL*1024UL;
2247 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2248 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2252 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2254 #ifdef CONFIG_FB_ROCKCHIP
2255 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2256 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2258 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2259 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2262 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2263 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2264 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2268 #ifdef CONFIG_VIDEO_RK29
2269 rk30_camera_request_reserve_mem();
2272 #ifdef CONFIG_GPS_RK
2273 //it must be more than 8MB
2274 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2276 board_mem_reserved();
2280 * dvfs_cpu_logic_table: table for arm and logic dvfs
2281 * @frequency : arm frequency
2282 * @cpu_volt : arm voltage depend on frequency
2283 * @logic_volt : logic voltage arm requests depend on frequency
2284 * comments : min arm/logic voltage
2286 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2287 {.frequency = 312 * 1000, .index = 850 * 1000},
2288 {.frequency = 504 * 1000, .index = 900 * 1000},
2289 {.frequency = 816 * 1000, .index = 950 * 1000},
2290 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2291 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2292 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2293 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2294 {.frequency = CPUFREQ_TABLE_END},
2297 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2298 #if defined(CONFIG_ARCH_RK3188)
2299 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2300 #elif defined(CONFIG_ARCH_RK3066B)
2301 {.frequency = 100 * 1000, .index = 950 * 1000},//the minimum rate is no limit for rk3168 rk3066B
2304 {.frequency = 200 * 1000, .index = 975 * 1000},
2305 {.frequency = 266 * 1000, .index = 1000 * 1000},
2306 {.frequency = 300 * 1000, .index = 1050 * 1000},
2307 {.frequency = 400 * 1000, .index = 1100 * 1000},
2308 {.frequency = 600 * 1000, .index = 1200 * 1000},
2309 {.frequency = CPUFREQ_TABLE_END},
2312 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2313 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2314 //{.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2315 {.frequency = 528 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2316 {.frequency = CPUFREQ_TABLE_END},
2319 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2320 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2321 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2323 void __init board_clock_init(void)
2325 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2326 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2327 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2328 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2329 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2332 MACHINE_START(RK30, "RK30board")
2333 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2334 .fixup = rk30_fixup,
2335 .reserve = &rk30_reserve,
2336 .map_io = rk30_map_io,
2337 .init_irq = rk30_init_irq,
2338 .timer = &rk30_timer,
2339 .init_machine = machine_rk30_board_init,