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_RK_HDMI)
56 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
59 #if defined(CONFIG_SPIM_RK29)
60 #include "../../../drivers/spi/rk29_spim.h"
62 #if defined(CONFIG_GPS_RK)
63 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
66 #if defined(CONFIG_MU509)
67 #include <linux/mu509.h>
69 #if defined(CONFIG_MW100)
70 #include <linux/mw100.h>
72 #if defined(CONFIG_MT6229)
73 #include <linux/mt6229.h>
75 #if defined(CONFIG_ANDROID_TIMED_GPIO)
76 #include "../../../drivers/staging/android/timed_gpio.h"
79 #if defined(CONFIG_MT6620)
80 #include <linux/gps.h>
82 #include "../mach-rk30/board-rk3168-tb-camera.c"
84 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
85 #define TOUCH_RESET_PIN RK30_PIN0_PC1//RK30_PIN0_PB6
86 #define TOUCH_PWR_PIN INVALID_GPIO//RK30_PIN0_PC5 // need to fly line by hardware engineer
87 static int goodix_init_platform_hw(void)
91 if (TOUCH_PWR_PIN != INVALID_GPIO) {
92 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
94 gpio_free(TOUCH_PWR_PIN);
95 printk("goodix power error\n");
98 gpio_direction_output(TOUCH_PWR_PIN, 0);
99 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
103 if (TOUCH_RESET_PIN != INVALID_GPIO) {
104 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
106 gpio_free(TOUCH_RESET_PIN);
107 printk("goodix gpio_request error\n");
110 gpio_direction_output(TOUCH_RESET_PIN, 1);
112 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
114 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
120 struct goodix_platform_data goodix_info = {
122 .irq_pin = RK30_PIN0_PB4,
123 .rest_pin = TOUCH_RESET_PIN,
124 .init_platform_hw = goodix_init_platform_hw,
128 static struct spi_board_info board_spi_devices[] = {
131 /***********************************************************
133 ************************************************************/
134 #ifdef CONFIG_BACKLIGHT_RK29_BL
136 #define PWM_MODE PWM0// PWM3
137 #define PWM_EFFECT_VALUE 1
139 #define LCD_DISP_ON_PIN
141 #ifdef LCD_DISP_ON_PIN
142 #define BL_EN_PIN RK30_PIN0_PC0
143 #define BL_EN_VALUE GPIO_HIGH
145 static int rk29_backlight_io_init(void)
150 #ifdef LCD_DISP_ON_PIN
151 ret = gpio_request(BL_EN_PIN, "bl_en");
153 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
159 static int rk29_backlight_io_deinit(void)
161 int ret = 0, pwm_gpio;
162 #ifdef LCD_DISP_ON_PIN
163 gpio_free(BL_EN_PIN);
165 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
166 gpio_request(pwm_gpio, "bl_pwm");
167 gpio_direction_output(pwm_gpio, GPIO_LOW);
171 static int rk29_backlight_pwm_suspend(void)
173 int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
175 ret = gpio_request(pwm_gpio, "bl_pwm");
177 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
180 gpio_direction_output(pwm_gpio, GPIO_LOW);
181 #ifdef LCD_DISP_ON_PIN
182 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
187 static int rk29_backlight_pwm_resume(void)
189 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
193 #ifdef LCD_DISP_ON_PIN
195 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
200 static struct rk29_bl_info rk29_bl_info = {
204 .brightness_mode =BRIGHTNESS_MODE_CONIC,
205 .bl_ref = PWM_EFFECT_VALUE,
206 .io_init = rk29_backlight_io_init,
207 .io_deinit = rk29_backlight_io_deinit,
208 .pwm_suspend = rk29_backlight_pwm_suspend,
209 .pwm_resume = rk29_backlight_pwm_resume,
212 static struct platform_device rk29_device_backlight = {
213 .name = "rk29_backlight",
216 .platform_data = &rk29_bl_info,
222 #ifdef CONFIG_RK29_SUPPORT_MODEM
224 #define RK30_MODEM_POWER RK30_PIN0_PC6
225 #define RK30_MODEM_POWER_IOMUX iomux_set(GPIO0_C6)
227 static int rk30_modem_io_init(void)
229 printk("%s\n", __FUNCTION__);
230 RK30_MODEM_POWER_IOMUX;
235 static struct rk29_io_t rk30_modem_io = {
236 .io_addr = RK30_MODEM_POWER,
239 .io_init = rk30_modem_io_init,
242 static struct platform_device rk30_device_modem = {
243 .name = "rk30_modem",
246 .platform_data = &rk30_modem_io,
250 #if defined(CONFIG_MU509)
251 static int mu509_io_init(void)
262 static int mu509_io_deinit(void)
268 struct rk29_mu509_data rk29_mu509_info = {
269 .io_init = mu509_io_init,
270 .io_deinit = mu509_io_deinit,
271 .modem_power_en = RK30_PIN2_PD5,
272 .bp_power = RK30_PIN0_PC6,
273 .bp_reset = RK30_PIN2_PD4,
274 .ap_wakeup_bp = RK30_PIN0_PC4,
275 .bp_wakeup_ap = RK30_PIN0_PC5,
277 struct platform_device rk29_device_mu509 = {
281 .platform_data = &rk29_mu509_info,
285 #if defined(CONFIG_MW100)
286 static int mw100_io_init(void)
296 static int mw100_io_deinit(void)
302 struct rk29_mw100_data rk29_mw100_info = {
303 .io_init = mw100_io_init,
304 .io_deinit = mw100_io_deinit,
305 .modem_power_en = RK30_PIN2_PD5,
306 .bp_power = RK30_PIN0_PC6,
307 .bp_reset = RK30_PIN2_PD4,
308 .ap_wakeup_bp = RK30_PIN0_PC4,
309 .bp_wakeup_ap = RK30_PIN0_PC5,
311 struct platform_device rk29_device_mw100 = {
315 .platform_data = &rk29_mw100_info,
319 #if defined(CONFIG_MT6229)
320 static int mt6229_io_init(void)
330 static int mt6229_io_deinit(void)
336 struct rk29_mt6229_data rk29_mt6229_info = {
337 .io_init = mt6229_io_init,
338 .io_deinit = mt6229_io_deinit,
339 .modem_power_en = RK30_PIN2_PD5,
340 .bp_power = RK30_PIN0_PC6,
341 .bp_reset = RK30_PIN2_PD4,
342 .ap_wakeup_bp = RK30_PIN0_PC4,
343 .bp_wakeup_ap = RK30_PIN0_PC5,
345 struct platform_device rk29_device_mt6229 = {
349 .platform_data = &rk29_mt6229_info,
355 #if defined (CONFIG_GS_MMA8452)
356 #define MMA8452_INT_PIN RK30_PIN0_PB7
358 static int mma8452_init_platform_hw(void)
363 static struct sensor_platform_data mma8452_info = {
364 .type = SENSOR_TYPE_ACCEL,
367 .init_platform_hw = mma8452_init_platform_hw,
368 .orientation = {-1, 0, 0, 0, 1, 0, 0, 0, -1},
371 #if defined (CONFIG_GS_LIS3DH)
372 #define LIS3DH_INT_PIN RK30_PIN0_PB7
374 static int lis3dh_init_platform_hw(void)
380 static struct sensor_platform_data lis3dh_info = {
381 .type = SENSOR_TYPE_ACCEL,
384 .init_platform_hw = lis3dh_init_platform_hw,
385 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
388 #if defined (CONFIG_COMPASS_AK8975)
389 static struct sensor_platform_data akm8975_info =
391 .type = SENSOR_TYPE_COMPASS,
424 #if defined(CONFIG_GYRO_L3G4200D)
426 #include <linux/l3g4200d.h>
427 #define L3G4200D_INT_PIN RK30_PIN0_PB4
429 static int l3g4200d_init_platform_hw(void)
434 static struct sensor_platform_data l3g4200d_info = {
435 .type = SENSOR_TYPE_GYROSCOPE,
438 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
439 .init_platform_hw = l3g4200d_init_platform_hw,
440 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
447 #ifdef CONFIG_LS_CM3217
448 static struct sensor_platform_data cm3217_info = {
449 .type = SENSOR_TYPE_LIGHT,
451 .poll_delay_ms = 500,
456 #ifdef CONFIG_FB_ROCKCHIP
458 #define LCD_CS_PIN INVALID_GPIO
459 #define LCD_CS_VALUE GPIO_HIGH
461 #define LCD_EN_PIN RK30_PIN0_PB6
462 #define LCD_EN_VALUE GPIO_HIGH
464 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
468 if(LCD_CS_PIN !=INVALID_GPIO)
470 ret = gpio_request(LCD_CS_PIN, NULL);
473 gpio_free(LCD_CS_PIN);
474 printk(KERN_ERR "request lcd cs pin fail!\n");
479 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
483 if(LCD_EN_PIN !=INVALID_GPIO)
485 ret = gpio_request(LCD_EN_PIN, NULL);
488 gpio_free(LCD_EN_PIN);
489 printk(KERN_ERR "request lcd en pin fail!\n");
494 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
499 static int rk_fb_io_disable(void)
501 if(LCD_CS_PIN !=INVALID_GPIO)
503 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
505 if(LCD_EN_PIN !=INVALID_GPIO)
507 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
511 static int rk_fb_io_enable(void)
513 if(LCD_CS_PIN !=INVALID_GPIO)
515 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
517 if(LCD_EN_PIN !=INVALID_GPIO)
519 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
524 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
525 struct rk29fb_info lcdc0_screen_info = {
526 .prop = PRMRY, //primary display device
527 .io_init = rk_fb_io_init,
528 .io_disable = rk_fb_io_disable,
529 .io_enable = rk_fb_io_enable,
530 .set_screen_info = set_lcd_info,
534 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
535 struct rk29fb_info lcdc1_screen_info = {
536 .prop = PRMRY, //primary display device
537 .io_init = rk_fb_io_init,
538 .io_disable = rk_fb_io_disable,
539 .io_enable = rk_fb_io_enable,
540 .set_screen_info = set_lcd_info,
543 #if 0 // defined(CONFIG_RK_HDMI)
544 .prop = EXTEND, //extend display device
546 .set_screen_info = hdmi_init_lcdc,
551 static struct resource resource_fb[] = {
555 .end = 0,//RK30_FB0_MEM_SIZE - 1,
556 .flags = IORESOURCE_MEM,
559 .name = "ipp buf", //for rotate
561 .end = 0,//RK30_FB0_MEM_SIZE - 1,
562 .flags = IORESOURCE_MEM,
567 .end = 0,//RK30_FB0_MEM_SIZE - 1,
568 .flags = IORESOURCE_MEM,
572 static struct platform_device device_fb = {
575 .num_resources = ARRAY_SIZE(resource_fb),
576 .resource = resource_fb,
580 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
581 static struct resource resource_lcdc0[] = {
584 .start = RK30_LCDC0_PHYS,
585 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
586 .flags = IORESOURCE_MEM,
593 .flags = IORESOURCE_IRQ,
597 static struct platform_device device_lcdc0 = {
600 .num_resources = ARRAY_SIZE(resource_lcdc0),
601 .resource = resource_lcdc0,
603 .platform_data = &lcdc0_screen_info,
607 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
608 static struct resource resource_lcdc1[] = {
611 .start = RK30_LCDC1_PHYS,
612 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
613 .flags = IORESOURCE_MEM,
619 .flags = IORESOURCE_IRQ,
623 static struct platform_device device_lcdc1 = {
626 .num_resources = ARRAY_SIZE(resource_lcdc1),
627 .resource = resource_lcdc1,
629 .platform_data = &lcdc1_screen_info,
634 #if defined(CONFIG_MFD_RK610)
635 #define RK610_RST_PIN RK30_PIN2_PD5
636 #define RK610_TEST_PIN RK30_PIN2_PD6
637 #define RK610_ENABLE_PIN RK30_PIN0_PC5
638 static int rk610_power_on_init(void)
641 if(RK610_ENABLE_PIN != INVALID_GPIO)
643 ret = gpio_request(RK610_ENABLE_PIN, "rk610 reset");
646 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
650 gpio_direction_output(RK610_ENABLE_PIN, GPIO_HIGH);
654 if(RK610_TEST_PIN != INVALID_GPIO)
656 ret = gpio_request(RK610_TEST_PIN, "rk610 reset");
659 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
663 gpio_direction_output(RK610_TEST_PIN, GPIO_LOW);
667 if(RK610_RST_PIN != INVALID_GPIO)
669 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
672 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
676 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
678 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
680 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
689 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
690 .rk610_power_on_init = rk610_power_on_init,
694 #ifdef CONFIG_SND_SOC_RK610
695 static int rk610_codec_io_init(void)
698 //Must not gpio_request
702 static struct rk610_codec_platform_data rk610_codec_pdata = {
703 .spk_ctl_io = RK30_PIN3_PC7,//RK30_PIN2_PD7,
704 .io_init = rk610_codec_io_init,
708 #ifdef CONFIG_ANDROID_TIMED_GPIO
709 static struct timed_gpio timed_gpios[] = {
712 .gpio = INVALID_GPIO,
715 .adjust_time =20, //adjust for diff product
719 static struct timed_gpio_platform_data rk29_vibrator_info = {
721 .gpios = timed_gpios,
724 static struct platform_device rk29_device_vibrator = {
725 .name = "timed-gpio",
728 .platform_data = &rk29_vibrator_info,
734 #ifdef CONFIG_LEDS_GPIO_PLATFORM
735 static struct gpio_led rk29_leds[] = {
737 .name = "button-backlight",
738 .gpio = INVALID_GPIO,
739 .default_trigger = "timer",
741 .retain_state_suspended = 0,
742 .default_state = LEDS_GPIO_DEFSTATE_OFF,
746 static struct gpio_led_platform_data rk29_leds_pdata = {
748 .num_leds = ARRAY_SIZE(rk29_leds),
751 static struct platform_device rk29_device_gpio_leds = {
755 .platform_data = &rk29_leds_pdata,
760 #ifdef CONFIG_RK_IRDA
761 #define IRDA_IRQ_PIN INVALID_GPIO //RK30_PIN0_PA3
763 static int irda_iomux_init(void)
768 ret = gpio_request(IRDA_IRQ_PIN, NULL);
770 gpio_free(IRDA_IRQ_PIN);
771 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
773 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
774 gpio_direction_input(IRDA_IRQ_PIN);
779 static int irda_iomux_deinit(void)
781 gpio_free(IRDA_IRQ_PIN);
785 static struct irda_info rk29_irda_info = {
786 .intr_pin = IRDA_IRQ_PIN,
787 .iomux_init = irda_iomux_init,
788 .iomux_deinit = irda_iomux_deinit,
789 //.irda_pwr_ctl = bu92747guw_power_ctl,
792 static struct platform_device irda_device = {
793 #ifdef CONFIG_RK_IRDA_NET
796 .name = "bu92747_irda",
800 .platform_data = &rk29_irda_info,
806 #define ION_RESERVE_SIZE (80 * SZ_1M)
807 static struct ion_platform_data rk30_ion_pdata = {
811 .type = ION_HEAP_TYPE_CARVEOUT,
812 .id = ION_NOR_HEAP_ID,
814 .size = ION_RESERVE_SIZE,
819 static struct platform_device device_ion = {
820 .name = "ion-rockchip",
823 .platform_data = &rk30_ion_pdata,
828 /**************************************************************************************************
829 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
830 **************************************************************************************************/
831 #ifdef CONFIG_SDMMC_RK29
832 #include "board-rk3028-tb-sdmmc-conifg.c"
833 #include "../plat-rk/rk-sdmmc-ops.c"
834 #include "../plat-rk/rk-sdmmc-wifi.c"
835 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
837 #ifdef CONFIG_SDMMC0_RK29
838 static int rk29_sdmmc0_cfg_gpio(void)
840 #ifdef CONFIG_SDMMC_RK29_OLD
842 iomux_set(MMC0_CLKOUT);
848 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
850 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
851 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
854 rk29_sdmmc_set_iomux(0, 0xFFFF);
856 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
857 #if SDMMC_USE_NEW_IOMUX_API
858 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
860 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
863 #if SDMMC_USE_NEW_IOMUX_API
864 iomux_set(MMC0_DETN);
866 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
870 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
871 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
872 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
880 #define CONFIG_SDMMC0_USE_DMA
881 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
883 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
884 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
885 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
887 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
888 .io_init = rk29_sdmmc0_cfg_gpio,
890 #if !defined(CONFIG_SDMMC_RK29_OLD)
891 .set_iomux = rk29_sdmmc_set_iomux,
894 .dma_name = "sd_mmc",
895 #ifdef CONFIG_SDMMC0_USE_DMA
901 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
902 .status = rk29sdk_wifi_mmc0_status,
903 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
906 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
907 .power_en = RK29SDK_SD_CARD_PWR_EN,
908 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
910 .power_en = INVALID_GPIO,
911 .power_en_level = GPIO_LOW,
913 .enable_sd_wakeup = 0,
915 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
916 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
917 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
919 .write_prt = INVALID_GPIO,
923 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
924 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
925 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
926 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
928 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
929 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
930 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
932 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
933 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
944 #endif // CONFIG_SDMMC0_RK29
946 #ifdef CONFIG_SDMMC1_RK29
947 #define CONFIG_SDMMC1_USE_DMA
948 static int rk29_sdmmc1_cfg_gpio(void)
950 #if defined(CONFIG_SDMMC_RK29_OLD)
952 iomux_set(MMC1_CLKOUT);
959 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
960 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
961 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
969 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
971 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
972 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
975 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
976 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
977 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
980 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
983 .io_init = rk29_sdmmc1_cfg_gpio,
985 #if !defined(CONFIG_SDMMC_RK29_OLD)
986 .set_iomux = rk29_sdmmc_set_iomux,
990 #ifdef CONFIG_SDMMC1_USE_DMA
996 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
997 .status = rk29sdk_wifi_status,
998 .register_status_notify = rk29sdk_wifi_status_register,
1001 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1002 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1003 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1005 .write_prt = INVALID_GPIO,
1008 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1009 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1013 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1014 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1015 .io = RK29SDK_SD_CARD_DETECT_N,
1020 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1021 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1023 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1024 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1025 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1027 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1028 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1038 .enable_sd_wakeup = 0,
1040 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1042 /**************************************************************************************************
1043 * the end of setting for SDMMC devices
1044 **************************************************************************************************/
1046 #ifdef CONFIG_BATTERY_RK30_ADC
1047 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1048 .dc_det_pin = RK30_PIN0_PB2,
1049 .batt_low_pin = RK30_PIN0_PB1,
1050 .charge_set_pin = INVALID_GPIO,
1051 .charge_ok_pin = RK30_PIN0_PA6,
1052 .dc_det_level = GPIO_LOW,
1053 .charge_ok_level = GPIO_HIGH,
1056 static struct platform_device rk30_device_adc_battery = {
1057 .name = "rk30-battery",
1060 .platform_data = &rk30_adc_battery_platdata,
1064 #ifdef CONFIG_RK30_PWM_REGULATOR
1065 static int pwm_voltage_map[] = {
1067 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000*/
1068 950000,975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1070 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1072 .supply = "vdd_core",
1076 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1080 .name = "PWM_DCDC1",
1082 .max_uV = 1800000, //0.6-1.8V
1084 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1086 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1087 .consumer_supplies = pwm_dcdc1_consumers,
1091 static struct pwm_platform_data pwm_regulator_info[1] = {
1093 #if defined (CONFIG_MACH_RK3028_TB)
1095 .pwm_gpio = RK30_PIN3_PD5,
1096 .pwm_iomux_pwm = PWM2,
1097 .pwm_iomux_gpio = GPIO3_D5,
1100 .pwm_gpio = RK30_PIN3_PD4,
1101 .pwm_iomux_pwm = PWM1,
1102 .pwm_iomux_gpio = GPIO3_D4,
1105 .pwm_voltage = 1100000,
1106 .suspend_voltage = 1000000,
1109 .coefficient = 504, //57.5%
1110 .pwm_voltage_map = pwm_voltage_map,
1111 .init_data = &pwm_regulator_init_dcdc[0],
1115 struct platform_device pwm_regulator_device[1] = {
1117 .name = "pwm-voltage-regulator",
1120 .platform_data = &pwm_regulator_info[0],
1126 #ifdef CONFIG_RK29_VMAC
1127 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1128 #include "board-rk30-sdk-vmac.c"
1131 #ifdef CONFIG_RFKILL_RK
1132 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1133 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1134 .type = RFKILL_TYPE_BLUETOOTH,
1136 .poweron_gpio = { // BT_REG_ON
1137 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1138 .enable = GPIO_HIGH,
1140 .name = "bt_poweron",
1145 .reset_gpio = { // BT_RST
1146 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1154 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1155 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1156 .enable = GPIO_HIGH,
1163 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1165 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1166 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1173 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1174 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1184 static struct platform_device device_rfkill_rk = {
1185 .name = "rfkill_rk",
1188 .platform_data = &rfkill_rk_platdata,
1193 #if defined(CONFIG_GPS_RK)
1194 int rk_gps_io_init(void)
1196 printk("%s \n", __FUNCTION__);
1198 gpio_request(RK30_PIN1_PB5, NULL);
1199 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1201 iomux_set(GPS_RFCLK);//GPS_CLK
1202 iomux_set(GPS_MAG);//GPS_MAG
1203 iomux_set(GPS_SIG);//GPS_SIGN
1205 gpio_request(RK30_PIN1_PA6, NULL);
1206 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1208 gpio_request(RK30_PIN1_PA5, NULL);
1209 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1211 gpio_request(RK30_PIN1_PA7, NULL);
1212 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1215 int rk_gps_power_up(void)
1217 printk("%s \n", __FUNCTION__);
1222 int rk_gps_power_down(void)
1224 printk("%s \n", __FUNCTION__);
1229 int rk_gps_reset_set(int level)
1233 int rk_enable_hclk_gps(void)
1235 struct clk *gps_aclk = NULL;
1236 gps_aclk = clk_get(NULL, "aclk_gps");
1238 clk_enable(gps_aclk);
1240 printk("%s \n", __FUNCTION__);
1243 printk("get gps aclk fail\n");
1246 int rk_disable_hclk_gps(void)
1248 struct clk *gps_aclk = NULL;
1249 gps_aclk = clk_get(NULL, "aclk_gps");
1251 //TO wait long enough until GPS ISR is finished.
1253 clk_disable(gps_aclk);
1255 printk("%s \n", __FUNCTION__);
1258 printk("get gps aclk fail\n");
1261 struct rk_gps_data rk_gps_info = {
1262 .io_init = rk_gps_io_init,
1263 .power_up = rk_gps_power_up,
1264 .power_down = rk_gps_power_down,
1265 .reset = rk_gps_reset_set,
1266 .enable_hclk_gps = rk_enable_hclk_gps,
1267 .disable_hclk_gps = rk_disable_hclk_gps,
1268 .GpsSign = RK30_PIN1_PB3,
1269 .GpsMag = RK30_PIN1_PB2, //GPIO index
1270 .GpsClk = RK30_PIN1_PB4, //GPIO index
1271 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1272 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1273 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1274 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1278 .u32GpsPhyAddr = RK30_GPS_PHYS,
1279 .u32GpsPhySize = RK30_GPS_SIZE,
1282 struct platform_device rk_device_gps = {
1283 .name = "gps_hv5820b",
1286 .platform_data = &rk_gps_info,
1291 #if defined(CONFIG_MT5931_MT6622)
1292 static struct mt6622_platform_data mt6622_platdata = {
1293 .power_gpio = { // BT_REG_ON
1294 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1295 .enable = GPIO_HIGH,
1301 .reset_gpio = { // BT_RST
1302 .io = RK30_PIN0_PD7,
1303 .enable = GPIO_HIGH,
1310 .io = RK30_PIN3_PD2,
1311 .enable = GPIO_HIGH,
1318 static struct platform_device device_mt6622 = {
1322 .platform_data = &mt6622_platdata,
1327 static struct platform_device *devices[] __initdata = {
1331 #ifdef CONFIG_ANDROID_TIMED_GPIO
1332 &rk29_device_vibrator,
1334 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1335 &rk29_device_gpio_leds,
1337 #ifdef CONFIG_RK_IRDA
1340 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1341 &rk29sdk_wifi_device,
1344 #if defined(CONFIG_MT6620)
1348 #ifdef CONFIG_RK29_SUPPORT_MODEM
1351 #if defined(CONFIG_MU509)
1354 #if defined(CONFIG_MW100)
1357 #if defined(CONFIG_MT6229)
1358 &rk29_device_mt6229,
1360 #ifdef CONFIG_BATTERY_RK30_ADC
1361 &rk30_device_adc_battery,
1363 #ifdef CONFIG_RFKILL_RK
1366 #ifdef CONFIG_GPS_RK
1370 #ifdef CONFIG_MT5931_MT6622
1375 static int rk_platform_add_display_devices(void)
1377 struct platform_device *fb = NULL; //fb
1378 struct platform_device *lcdc0 = NULL; //lcdc0
1379 struct platform_device *lcdc1 = NULL; //lcdc1
1380 struct platform_device *bl = NULL; //backlight
1381 #ifdef CONFIG_FB_ROCKCHIP
1385 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1386 lcdc0 = &device_lcdc0,
1389 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1390 lcdc1 = &device_lcdc1,
1393 #ifdef CONFIG_BACKLIGHT_RK29_BL
1394 bl = &rk29_device_backlight,
1396 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1403 #ifdef CONFIG_I2C0_RK30
1404 static struct i2c_board_info __initdata i2c0_info[] = {
1405 #if defined (CONFIG_GS_MMA8452)
1407 .type = "gs_mma8452",
1410 .irq = MMA8452_INT_PIN,
1411 .platform_data = &mma8452_info,
1414 #if defined (CONFIG_GS_LIS3DH)
1416 .type = "gs_lis3dh",
1417 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1419 .irq = LIS3DH_INT_PIN,
1420 .platform_data = &lis3dh_info,
1423 #if defined (CONFIG_COMPASS_AK8975)
1428 .irq = RK30_PIN3_PD7,
1429 .platform_data = &akm8975_info,
1432 #if defined (CONFIG_GYRO_L3G4200D)
1434 .type = "l3g4200d_gryo",
1437 .irq = L3G4200D_INT_PIN,
1438 .platform_data = &l3g4200d_info,
1441 #if defined (CONFIG_SND_SOC_RK1000)
1443 .type = "rk1000_i2c_codec",
1448 .type = "rk1000_control",
1453 #if defined (CONFIG_SND_SOC_RT5631)
1465 int __sramdata g_pmic_type = 0;
1466 #ifdef CONFIG_I2C1_RK30
1467 #ifdef CONFIG_MFD_WM831X_I2C
1468 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1470 static struct pmu_info wm8326_dcdc_info[] = {
1472 .name = "vdd_core", //logic
1475 .suspend_vol = 950000,
1478 .name = "vdd_cpu", //arm
1481 .suspend_vol = 950000,
1484 .name = "dcdc3", //ddr
1487 .suspend_vol = 1150000,
1489 #ifdef CONFIG_MACH_RK3066_SDK
1491 .name = "dcdc4", //vcc_io
1494 .suspend_vol = 3000000,
1498 .name = "dcdc4", //vcc_io
1501 .suspend_vol = 2800000,
1506 static struct pmu_info wm8326_ldo_info[] = {
1508 .name = "ldo1", //vcc18_cif
1511 .suspend_vol = 1800000,
1514 .name = "ldo2", //vccio_wl
1517 .suspend_vol = 1800000,
1523 .suspend_vol = 1100000,
1526 .name = "ldo4", //vdd11
1529 .suspend_vol = 1000000,
1532 .name = "ldo5", //vcc25
1535 .suspend_vol = 1800000,
1538 .name = "ldo6", //vcc33
1541 .suspend_vol = 3300000,
1544 .name = "ldo7", //vcc28_cif
1547 .suspend_vol = 2800000,
1550 .name = "ldo8", //vcca33
1553 .suspend_vol = 3300000,
1556 .name = "ldo9", //vcc_tp
1559 .suspend_vol = 3300000,
1562 .name = "ldo10", //flash_io
1565 .suspend_vol = 1800000,
1569 #include "../mach-rk30/board-pmu-wm8326.c"
1572 #ifdef CONFIG_MFD_TPS65910
1573 #define TPS65910_HOST_IRQ RK30_PIN0_PB5//RK30_PIN0_PB3
1575 #define PMU_POWER_SLEEP RK30_PIN1_PB5
1577 static struct pmu_info tps65910_dcdc_info[] = {
1579 .name = "vdd_cpu", //arm
1584 .name = "vdd2", //ddr
1589 .name = "vio", //vcc_io
1595 static struct pmu_info tps65910_ldo_info[] = {
1597 .name = "vpll", //vdd10
1602 .name = "vdig1", //vcc18_cif
1607 .name = "vdig2", //vdd_jetta
1612 .name = "vaux1", //vcc28_cif
1617 .name = "vaux2", //vcca33
1622 .name = "vaux33", //vcc_tp
1627 .name = "vmmc", //vcc30
1632 .name = "vdac", //vcc18
1638 #include "../mach-rk30/board-pmu-tps65910.c"
1641 #ifdef CONFIG_REGULATOR_ACT8846
1642 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1643 #define PMU_VSEL RK30_PIN3_PD3
1644 static struct pmu_info act8846_dcdc_info[] = {
1646 .name = "act_dcdc1", //ddr
1649 .suspend_vol = 1200000,
1652 .name = "vdd_core", //logic
1655 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1656 .suspend_vol = 1200000,
1658 .suspend_vol = 900000,
1663 .name = "vdd_cpu", //arm
1666 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1667 .suspend_vol = 1200000,
1669 .suspend_vol = 900000,
1674 .name = "act_dcdc4", //vccio
1677 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1678 .suspend_vol = 3000000,
1680 .suspend_vol = 2800000,
1686 static struct pmu_info act8846_ldo_info[] = {
1688 .name = "act_ldo1", //vdd11
1693 .name = "act_ldo2", //vdd12
1698 .name = "act_ldo3", //vcc18_cif
1703 .name = "act_ldo4", //vcca33
1708 .name = "act_ldo5", //vcctp
1713 .name = "act_ldo6", //vcc33
1718 .name = "act_ldo7", //vccio_wl
1723 .name = "act_ldo8", //vcc28_cif
1729 #include "../mach-rk30/board-pmu-act8846.c"
1733 static struct i2c_board_info __initdata i2c1_info[] = {
1734 #if defined (CONFIG_MFD_WM831X_I2C)
1739 .irq = RK30_PIN0_PB3,
1740 .platform_data = &wm831x_platdata,
1743 #if defined (CONFIG_MFD_TPS65910)
1746 .addr = TPS65910_I2C_ID0,
1748 .irq = TPS65910_HOST_IRQ,
1749 .platform_data = &tps65910_data,
1753 #if defined (CONFIG_REGULATOR_ACT8846)
1758 // .irq = ACT8846_HOST_IRQ,
1759 .platform_data=&act8846_data,
1762 #if defined (CONFIG_RTC_HYM8563)
1764 .type = "rtc_hym8563",
1767 .irq = RK30_PIN1_PA4,
1774 void __sramfunc board_pmu_suspend(void)
1776 #if defined (CONFIG_MFD_WM831X_I2C)
1777 if(pmic_is_wm8326())
1778 board_pmu_wm8326_suspend();
1780 #if defined (CONFIG_MFD_TPS65910)
1781 if(pmic_is_tps65910())
1782 board_pmu_tps65910_suspend();
1784 #if defined (CONFIG_REGULATOR_ACT8846)
1785 if(pmic_is_act8846())
1786 board_pmu_act8846_suspend();
1791 void __sramfunc board_pmu_resume(void)
1793 #if defined (CONFIG_MFD_WM831X_I2C)
1794 if(pmic_is_wm8326())
1795 board_pmu_wm8326_resume();
1797 #if defined (CONFIG_MFD_TPS65910)
1798 if(pmic_is_tps65910())
1799 board_pmu_tps65910_resume();
1801 #if defined (CONFIG_REGULATOR_ACT8846)
1802 if(pmic_is_act8846())
1803 board_pmu_act8846_resume();
1807 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1809 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1810 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1812 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1814 #ifdef CONFIG_RK30_PWM_REGULATOR
1816 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1818 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1819 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1820 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1821 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1823 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1824 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1825 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1826 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1829 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1831 #ifdef CONFIG_RK30_PWM_REGULATOR
1832 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1833 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1834 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1835 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1841 extern void pwm_suspend_voltage(void);
1842 extern void pwm_resume_voltage(void);
1843 void rk30_pwm_suspend_voltage_set(void)
1845 #ifdef CONFIG_RK30_PWM_REGULATOR
1846 pwm_suspend_voltage();
1849 void rk30_pwm_resume_voltage_set(void)
1851 #ifdef CONFIG_RK30_PWM_REGULATOR
1852 pwm_resume_voltage();
1857 #ifdef CONFIG_I2C2_RK30
1858 static struct i2c_board_info __initdata i2c2_info[] = {
1859 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1861 .type = "Goodix-TS",
1864 .irq = RK30_PIN0_PB4,
1865 .platform_data = &goodix_info,
1868 #if defined (CONFIG_LS_CM3217)
1870 .type = "lightsensor",
1873 .platform_data = &cm3217_info,
1879 #ifdef CONFIG_I2C3_RK30
1880 static struct i2c_board_info __initdata i2c3_info[] = {
1884 #ifdef CONFIG_I2C4_RK30
1885 static struct i2c_board_info __initdata i2c4_info[] = {
1886 #ifdef CONFIG_MFD_RK610
1888 .type = "rk610_ctl",
1891 .platform_data = &rk610_ctl_pdata,
1893 #ifdef CONFIG_RK610_TVOUT
1895 .type = "rk610_tvout",
1900 #ifdef CONFIG_HDMI_RK610
1902 .type = "rk610_hdmi",
1905 .irq = INVALID_GPIO,
1908 #ifdef CONFIG_SND_SOC_RK610
1909 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1910 .type = "rk610_i2c_codec",
1913 .platform_data = &rk610_codec_pdata,
1921 #ifdef CONFIG_I2C_GPIO_RK30
1922 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1923 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1924 static int rk30_i2c_io_init(void)
1926 //set iomux (gpio) here
1927 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1928 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1932 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1933 .sda_pin = I2C_SDA_PIN,
1934 .scl_pin = I2C_SCL_PIN,
1935 .udelay = 5, // clk = 500/udelay = 100Khz
1936 .timeout = 100,//msecs_to_jiffies(100),
1938 .io_init = rk30_i2c_io_init,
1940 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1944 static void __init rk30_i2c_register_board_info(void)
1946 #ifdef CONFIG_I2C0_RK30
1947 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1949 #ifdef CONFIG_I2C1_RK30
1950 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1952 #ifdef CONFIG_I2C2_RK30
1953 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1955 #ifdef CONFIG_I2C3_RK30
1956 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1958 #ifdef CONFIG_I2C4_RK30
1959 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1961 #ifdef CONFIG_I2C_GPIO_RK30
1962 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1967 // ========== Begin of rk3168 top board keypad defination ============
1969 #include <plat/key.h>
1971 static struct rk29_keys_button key_button[] = {
1974 .code = KEY_VOLUMEDOWN,
1975 .gpio = RK30_PIN0_PD6,
1976 .active_low = PRESS_LEV_LOW,
1981 .gpio = RK30_PIN1_PB4,
1982 .active_low = PRESS_LEV_LOW,
1987 .code = KEY_VOLUMEUP,
1988 .adc_value = 1,//133
1989 .gpio = INVALID_GPIO,
1990 .active_low = PRESS_LEV_LOW,
1996 .gpio = INVALID_GPIO,
1997 .active_low = PRESS_LEV_LOW,
2002 .adc_value = 550,//550
2003 .gpio = INVALID_GPIO,
2004 .active_low = PRESS_LEV_LOW,
2009 .adc_value = 334,//333
2010 .gpio = INVALID_GPIO,
2011 .active_low = PRESS_LEV_LOW,
2017 .gpio = INVALID_GPIO,
2018 .active_low = PRESS_LEV_LOW,
2021 struct rk29_keys_platform_data rk29_keys_pdata = {
2022 .buttons = key_button,
2023 .nbuttons = ARRAY_SIZE(key_button),
2024 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
2027 // =========== End of rk3168 top board keypad defination =============
2030 #define POWER_ON_PIN RK30_PIN0_PD5 //power_hold
2031 static void rk30_pm_power_off(void)
2033 printk(KERN_ERR "rk30_pm_power_off start...\n");
2034 #if defined(CONFIG_MFD_WM831X)
2035 if(pmic_is_wm8326()){
2036 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2037 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2041 #if defined(CONFIG_REGULATOR_ACT8846)
2042 if(pmic_is_act8846())
2044 act8846_device_shutdown();
2048 #if defined(CONFIG_MFD_TPS65910)
2049 if(pmic_is_tps65910())
2051 tps65910_device_shutdown();//tps65910 shutdown
2055 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2059 static void __init machine_rk30_board_init(void)
2062 gpio_request(POWER_ON_PIN, "poweronpin");
2063 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2065 pm_power_off = rk30_pm_power_off;
2067 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2070 rk30_i2c_register_board_info();
2071 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2072 platform_add_devices(devices, ARRAY_SIZE(devices));
2073 rk_platform_add_display_devices();
2074 board_usb_detect_init(RK30_PIN0_PA7);
2076 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2077 rk29sdk_wifi_bt_gpio_control_init();
2078 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2079 rk29sdk_wifi_combo_module_gpio_init();
2082 #if defined(CONFIG_MT6620)
2083 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2086 #if defined(CONFIG_MT5931_MT6622)
2087 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2091 static void __init rk30_reserve(void)
2094 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2096 #ifdef CONFIG_FB_ROCKCHIP
2097 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2098 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2100 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2101 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2104 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2105 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2106 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2110 #ifdef CONFIG_VIDEO_RK29
2111 rk30_camera_request_reserve_mem();
2114 #ifdef CONFIG_GPS_RK
2115 //it must be more than 8MB
2116 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2118 board_mem_reserved();
2122 * dvfs_cpu_logic_table: table for arm and logic dvfs
2123 * @frequency : arm frequency
2124 * @cpu_volt : arm voltage depend on frequency
2126 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2127 {.frequency = 312 * 1000, .index = 900 * 1000},
2128 {.frequency = 504 * 1000, .index = 950 * 1000},
2129 {.frequency = 816 * 1000, .index = 1000 * 1000},
2130 {.frequency = 1008 * 1000, .index = 1100 * 1000},
2131 //{.frequency = 1200 * 1000, .index = 1100 * 1000},
2132 //{.frequency = 1416 * 1000, .index = 1200 * 1000},
2133 //{.frequency = 1608 * 1000, .index = 1300 * 1000},
2134 {.frequency = CPUFREQ_TABLE_END},
2137 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2138 #if defined(CONFIG_ARCH_RK3188)
2139 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2140 #elif defined(CONFIG_ARCH_RK3066B)
2141 {.frequency = 100 * 1000, .index = 950 * 1000},//the minimum rate is no limit for rk3168 rk3066B
2144 {.frequency = 200 * 1000, .index = 975 * 1000},
2145 {.frequency = 266 * 1000, .index = 1000 * 1000},
2146 {.frequency = 300 * 1000, .index = 1050 * 1000},
2147 {.frequency = 400 * 1000, .index = 1100 * 1000},
2148 //{.frequency = 600 * 1000, .index = 1200 * 1000},
2149 {.frequency = CPUFREQ_TABLE_END},
2152 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2153 #if defined(CONFIG_ARCH_RK3188)
2154 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2155 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2157 {.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2158 {.frequency = CPUFREQ_TABLE_END},
2161 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2162 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2163 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2165 void __init board_clock_init(void)
2167 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2168 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2169 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2170 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2171 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2174 MACHINE_START(RK30, "RK30board")
2175 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2176 .fixup = rk30_fixup,
2177 .reserve = &rk30_reserve,
2178 .map_io = rk30_map_io,
2179 .init_irq = rk30_init_irq,
2180 .timer = &rk30_timer,
2181 .init_machine = machine_rk30_board_init,