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 "board-rk3168-tb-camera.c"
84 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
85 #define TOUCH_RESET_PIN 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_PIN1_PB7,
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 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_PA2
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, 0, 1, 0, -1, 0},
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_PB0
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_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-rk3168m-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,
1010 #ifdef USE_SDIO_INT_LEVEL
1011 .sdio_INT_level = RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE,
1016 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1017 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
1018 .io = RK29SDK_SD_CARD_DETECT_N,
1023 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
1024 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1026 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1027 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1028 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1030 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1031 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1041 .enable_sd_wakeup = 0,
1043 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1045 /**************************************************************************************************
1046 * the end of setting for SDMMC devices
1047 **************************************************************************************************/
1049 #ifdef CONFIG_BATTERY_RK30_ADC
1050 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1051 .dc_det_pin = RK30_PIN0_PB2,
1052 .batt_low_pin = RK30_PIN0_PB1,
1053 .charge_set_pin = INVALID_GPIO,
1054 .charge_ok_pin = RK30_PIN0_PA6,
1055 .dc_det_level = GPIO_LOW,
1056 .charge_ok_level = GPIO_HIGH,
1059 static struct platform_device rk30_device_adc_battery = {
1060 .name = "rk30-battery",
1063 .platform_data = &rk30_adc_battery_platdata,
1067 #ifdef CONFIG_RK30_PWM_REGULATOR
1068 static int pwm_voltage_map[] = {
1069 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1071 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1073 .supply = "vdd_cpu",
1077 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1081 .name = "PWM_DCDC1",
1083 .max_uV = 1800000, //0.6-1.8V
1085 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1087 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1088 .consumer_supplies = pwm_dcdc1_consumers,
1092 static struct pwm_platform_data pwm_regulator_info[1] = {
1095 .pwm_gpio = RK30_PIN3_PD4,
1096 .pwm_iomux_pwm = PWM1,
1097 .pwm_iomux_gpio = GPIO3_D4,
1098 .pwm_voltage = 1100000,
1099 .suspend_voltage = 1000000,
1102 .coefficient = 575, //57.5%
1103 .pwm_voltage_map = pwm_voltage_map,
1104 .init_data = &pwm_regulator_init_dcdc[0],
1108 struct platform_device pwm_regulator_device[1] = {
1110 .name = "pwm-voltage-regulator",
1113 .platform_data = &pwm_regulator_info[0],
1119 #ifdef CONFIG_RK29_VMAC
1120 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1121 #include "board-rk30-sdk-vmac.c"
1124 #ifdef CONFIG_RFKILL_RK
1125 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1126 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1127 .type = RFKILL_TYPE_BLUETOOTH,
1129 .poweron_gpio = { // BT_REG_ON
1130 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1131 .enable = GPIO_HIGH,
1133 .name = "bt_poweron",
1138 .reset_gpio = { // BT_RST
1139 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1147 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1148 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1149 .enable = GPIO_HIGH,
1156 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1158 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1159 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1166 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1167 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1177 static struct platform_device device_rfkill_rk = {
1178 .name = "rfkill_rk",
1181 .platform_data = &rfkill_rk_platdata,
1186 #if defined(CONFIG_GPS_RK)
1187 int rk_gps_io_init(void)
1189 printk("%s \n", __FUNCTION__);
1191 gpio_request(RK30_PIN1_PB5, NULL);
1192 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1194 iomux_set(GPS_RFCLK);//GPS_CLK
1195 iomux_set(GPS_MAG);//GPS_MAG
1196 iomux_set(GPS_SIG);//GPS_SIGN
1198 gpio_request(RK30_PIN1_PA6, NULL);
1199 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1201 gpio_request(RK30_PIN1_PA5, NULL);
1202 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1204 gpio_request(RK30_PIN1_PA7, NULL);
1205 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1208 int rk_gps_power_up(void)
1210 printk("%s \n", __FUNCTION__);
1215 int rk_gps_power_down(void)
1217 printk("%s \n", __FUNCTION__);
1222 int rk_gps_reset_set(int level)
1226 int rk_enable_hclk_gps(void)
1228 struct clk *gps_aclk = NULL;
1229 gps_aclk = clk_get(NULL, "aclk_gps");
1231 clk_enable(gps_aclk);
1233 printk("%s \n", __FUNCTION__);
1236 printk("get gps aclk fail\n");
1239 int rk_disable_hclk_gps(void)
1241 struct clk *gps_aclk = NULL;
1242 gps_aclk = clk_get(NULL, "aclk_gps");
1244 //TO wait long enough until GPS ISR is finished.
1246 clk_disable(gps_aclk);
1248 printk("%s \n", __FUNCTION__);
1251 printk("get gps aclk fail\n");
1254 struct rk_gps_data rk_gps_info = {
1255 .io_init = rk_gps_io_init,
1256 .power_up = rk_gps_power_up,
1257 .power_down = rk_gps_power_down,
1258 .reset = rk_gps_reset_set,
1259 .enable_hclk_gps = rk_enable_hclk_gps,
1260 .disable_hclk_gps = rk_disable_hclk_gps,
1261 .GpsSign = RK30_PIN1_PB3,
1262 .GpsMag = RK30_PIN1_PB2, //GPIO index
1263 .GpsClk = RK30_PIN1_PB4, //GPIO index
1264 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1265 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1266 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1267 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1271 .u32GpsPhyAddr = RK30_GPS_PHYS,
1272 .u32GpsPhySize = RK30_GPS_SIZE,
1275 struct platform_device rk_device_gps = {
1276 .name = "gps_hv5820b",
1279 .platform_data = &rk_gps_info,
1284 #if defined(CONFIG_MT5931_MT6622)
1285 static struct mt6622_platform_data mt6622_platdata = {
1286 .power_gpio = { // BT_REG_ON
1287 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1288 .enable = GPIO_HIGH,
1294 .reset_gpio = { // BT_RST
1295 .io = RK30_PIN0_PD7,
1296 .enable = GPIO_HIGH,
1303 .io = RK30_PIN3_PD2,
1304 .enable = GPIO_HIGH,
1311 static struct platform_device device_mt6622 = {
1315 .platform_data = &mt6622_platdata,
1320 static struct platform_device *devices[] __initdata = {
1324 #ifdef CONFIG_ANDROID_TIMED_GPIO
1325 &rk29_device_vibrator,
1327 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1328 &rk29_device_gpio_leds,
1330 #ifdef CONFIG_RK_IRDA
1333 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1334 &rk29sdk_wifi_device,
1337 #if defined(CONFIG_MT6620)
1341 #ifdef CONFIG_RK29_SUPPORT_MODEM
1344 #if defined(CONFIG_MU509)
1347 #if defined(CONFIG_MW100)
1350 #if defined(CONFIG_MT6229)
1351 &rk29_device_mt6229,
1353 #ifdef CONFIG_BATTERY_RK30_ADC
1354 &rk30_device_adc_battery,
1356 #ifdef CONFIG_RFKILL_RK
1359 #ifdef CONFIG_GPS_RK
1363 #ifdef CONFIG_MT5931_MT6622
1368 static int rk_platform_add_display_devices(void)
1370 struct platform_device *fb = NULL; //fb
1371 struct platform_device *lcdc0 = NULL; //lcdc0
1372 struct platform_device *lcdc1 = NULL; //lcdc1
1373 struct platform_device *bl = NULL; //backlight
1374 #ifdef CONFIG_FB_ROCKCHIP
1378 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1379 lcdc0 = &device_lcdc0,
1382 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1383 lcdc1 = &device_lcdc1,
1386 #ifdef CONFIG_BACKLIGHT_RK29_BL
1387 bl = &rk29_device_backlight,
1389 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1396 #ifdef CONFIG_I2C0_RK30
1397 static struct i2c_board_info __initdata i2c0_info[] = {
1398 #if defined (CONFIG_GS_MMA8452)
1400 .type = "gs_mma8452",
1403 .irq = MMA8452_INT_PIN,
1404 .platform_data = &mma8452_info,
1407 #if defined (CONFIG_GS_LIS3DH)
1409 .type = "gs_lis3dh",
1410 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1412 .irq = LIS3DH_INT_PIN,
1413 .platform_data = &lis3dh_info,
1416 #if defined (CONFIG_COMPASS_AK8975)
1421 .irq = RK30_PIN3_PD7,
1422 .platform_data = &akm8975_info,
1425 #if defined (CONFIG_GYRO_L3G4200D)
1427 .type = "l3g4200d_gryo",
1430 .irq = L3G4200D_INT_PIN,
1431 .platform_data = &l3g4200d_info,
1434 #if defined (CONFIG_SND_SOC_RK1000)
1436 .type = "rk1000_i2c_codec",
1441 .type = "rk1000_control",
1446 #if defined (CONFIG_SND_SOC_RT5631)
1458 int __sramdata g_pmic_type = 0;
1459 #ifdef CONFIG_I2C1_RK30
1460 #ifdef CONFIG_MFD_WM831X_I2C
1461 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1463 static struct pmu_info wm8326_dcdc_info[] = {
1465 .name = "vdd_core", //logic
1468 .suspend_vol = 950000,
1471 .name = "vdd_cpu", //arm
1474 .suspend_vol = 950000,
1477 .name = "dcdc3", //ddr
1480 .suspend_vol = 1150000,
1482 #ifdef CONFIG_MACH_RK3066_SDK
1484 .name = "dcdc4", //vcc_io
1487 .suspend_vol = 3000000,
1491 .name = "dcdc4", //vcc_io
1494 .suspend_vol = 2800000,
1499 static struct pmu_info wm8326_ldo_info[] = {
1501 .name = "ldo1", //vcc18_cif
1504 .suspend_vol = 1800000,
1507 .name = "ldo2", //vccio_wl
1510 .suspend_vol = 1800000,
1516 .suspend_vol = 1100000,
1519 .name = "ldo4", //vdd11
1522 .suspend_vol = 1000000,
1525 .name = "ldo5", //vcc25
1528 .suspend_vol = 1800000,
1531 .name = "ldo6", //vcc33
1534 .suspend_vol = 3300000,
1537 .name = "ldo7", //vcc28_cif
1540 .suspend_vol = 2800000,
1543 .name = "ldo8", //vcca33
1546 .suspend_vol = 3300000,
1549 .name = "ldo9", //vcc_tp
1552 .suspend_vol = 3300000,
1555 .name = "ldo10", //flash_io
1558 .suspend_vol = 1800000,
1562 #include "board-pmu-wm8326.c"
1565 #ifdef CONFIG_MFD_TPS65910
1566 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1568 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1570 static struct pmu_info tps65910_dcdc_info[] = {
1572 .name = "vdd_core", //logic
1577 .name = "vdd2", //ddr
1582 .name = "vio", //vcc_io
1588 static struct pmu_info tps65910_ldo_info[] = {
1590 .name = "vpll", //vdd10
1595 .name = "vdig1", //vcc18_cif
1600 .name = "vdig2", //vdd_jetta
1605 .name = "vaux1", //vcc28_cif
1610 .name = "vaux2", //vcca33
1615 .name = "vaux33", //vcc_tp
1620 .name = "vmmc", //vcc30
1625 .name = "vdac", //vcc18
1631 #include "board-pmu-tps65910.c"
1634 #ifdef CONFIG_REGULATOR_ACT8846
1635 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1636 #define PMU_VSEL RK30_PIN3_PD3
1637 static struct pmu_info act8846_dcdc_info[] = {
1639 .name = "act_dcdc1", //ddr
1642 .suspend_vol = 1200000,
1645 .name = "vdd_core", //logic
1648 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1649 .suspend_vol = 1200000,
1651 .suspend_vol = 900000,
1656 .name = "vdd_cpu", //arm
1659 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1660 .suspend_vol = 1200000,
1662 .suspend_vol = 900000,
1667 .name = "act_dcdc4", //vccio
1670 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1671 .suspend_vol = 3000000,
1673 .suspend_vol = 2800000,
1679 static struct pmu_info act8846_ldo_info[] = {
1681 .name = "act_ldo1", //vdd11
1686 .name = "act_ldo2", //vdd12
1691 .name = "act_ldo3", //vcc18_cif
1696 .name = "act_ldo4", //vcca33
1701 .name = "act_ldo5", //vcctp
1706 .name = "act_ldo6", //vcc33
1711 .name = "act_ldo7", //vccio_wl
1716 .name = "act_ldo8", //vcc28_cif
1722 #include "board-pmu-act8846.c"
1726 static struct i2c_board_info __initdata i2c1_info[] = {
1727 #if defined (CONFIG_MFD_WM831X_I2C)
1732 .irq = RK30_PIN0_PB3,
1733 .platform_data = &wm831x_platdata,
1736 #if defined (CONFIG_MFD_TPS65910)
1739 .addr = TPS65910_I2C_ID0,
1741 .irq = TPS65910_HOST_IRQ,
1742 .platform_data = &tps65910_data,
1746 #if defined (CONFIG_REGULATOR_ACT8846)
1751 // .irq = ACT8846_HOST_IRQ,
1752 .platform_data=&act8846_data,
1755 #if defined (CONFIG_RTC_HYM8563)
1757 .type = "rtc_hym8563",
1760 .irq = RK30_PIN1_PA4,
1767 void __sramfunc board_pmu_suspend(void)
1769 #if defined (CONFIG_MFD_WM831X_I2C)
1770 if(pmic_is_wm8326())
1771 board_pmu_wm8326_suspend();
1773 #if defined (CONFIG_MFD_TPS65910)
1774 if(pmic_is_tps65910())
1775 board_pmu_tps65910_suspend();
1777 #if defined (CONFIG_REGULATOR_ACT8846)
1778 if(pmic_is_act8846())
1779 board_pmu_act8846_suspend();
1784 void __sramfunc board_pmu_resume(void)
1786 #if defined (CONFIG_MFD_WM831X_I2C)
1787 if(pmic_is_wm8326())
1788 board_pmu_wm8326_resume();
1790 #if defined (CONFIG_MFD_TPS65910)
1791 if(pmic_is_tps65910())
1792 board_pmu_tps65910_resume();
1794 #if defined (CONFIG_REGULATOR_ACT8846)
1795 if(pmic_is_act8846())
1796 board_pmu_act8846_resume();
1800 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1802 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1803 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1805 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1807 #ifdef CONFIG_RK30_PWM_REGULATOR
1809 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1811 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1812 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1813 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1814 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1816 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1817 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1818 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1819 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1822 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1824 #ifdef CONFIG_RK30_PWM_REGULATOR
1825 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1826 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1827 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1828 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1834 extern void pwm_suspend_voltage(void);
1835 extern void pwm_resume_voltage(void);
1836 void rk30_pwm_suspend_voltage_set(void)
1838 #ifdef CONFIG_RK30_PWM_REGULATOR
1839 pwm_suspend_voltage();
1842 void rk30_pwm_resume_voltage_set(void)
1844 #ifdef CONFIG_RK30_PWM_REGULATOR
1845 pwm_resume_voltage();
1850 #ifdef CONFIG_I2C2_RK30
1851 static struct i2c_board_info __initdata i2c2_info[] = {
1852 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1854 .type = "Goodix-TS",
1857 .irq = RK30_PIN1_PB7,
1858 .platform_data = &goodix_info,
1861 #if defined (CONFIG_LS_CM3217)
1863 .type = "lightsensor",
1866 .platform_data = &cm3217_info,
1872 #ifdef CONFIG_I2C3_RK30
1873 static struct i2c_board_info __initdata i2c3_info[] = {
1877 #ifdef CONFIG_I2C4_RK30
1878 static struct i2c_board_info __initdata i2c4_info[] = {
1879 #ifdef CONFIG_MFD_RK610
1881 .type = "rk610_ctl",
1884 .platform_data = &rk610_ctl_pdata,
1886 #ifdef CONFIG_RK610_TVOUT
1888 .type = "rk610_tvout",
1893 #ifdef CONFIG_HDMI_RK610
1895 .type = "rk610_hdmi",
1898 .irq = INVALID_GPIO,
1901 #ifdef CONFIG_SND_SOC_RK610
1902 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1903 .type = "rk610_i2c_codec",
1906 .platform_data = &rk610_codec_pdata,
1914 #ifdef CONFIG_I2C_GPIO_RK30
1915 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1916 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1917 static int rk30_i2c_io_init(void)
1919 //set iomux (gpio) here
1920 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1921 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1925 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1926 .sda_pin = I2C_SDA_PIN,
1927 .scl_pin = I2C_SCL_PIN,
1928 .udelay = 5, // clk = 500/udelay = 100Khz
1929 .timeout = 100,//msecs_to_jiffies(100),
1931 .io_init = rk30_i2c_io_init,
1933 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1937 static void __init rk30_i2c_register_board_info(void)
1939 #ifdef CONFIG_I2C0_RK30
1940 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1942 #ifdef CONFIG_I2C1_RK30
1943 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1945 #ifdef CONFIG_I2C2_RK30
1946 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1948 #ifdef CONFIG_I2C3_RK30
1949 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1951 #ifdef CONFIG_I2C4_RK30
1952 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1954 #ifdef CONFIG_I2C_GPIO_RK30
1955 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1960 // ========== Begin of rk3168 top board keypad defination ============
1962 #include <plat/key.h>
1964 static struct rk29_keys_button key_button[] = {
1967 .code = KEY_VOLUMEDOWN,
1969 .gpio = INVALID_GPIO,
1970 .active_low = PRESS_LEV_LOW,
1975 .gpio = RK30_PIN0_PA4,
1976 .active_low = PRESS_LEV_LOW,
1981 .code = KEY_VOLUMEUP,
1982 .adc_value = 559,//133
1983 .gpio = INVALID_GPIO,
1984 .active_low = PRESS_LEV_LOW,
1990 .gpio = INVALID_GPIO,
1991 .active_low = PRESS_LEV_LOW,
1996 .adc_value = 355,//550
1997 .gpio = INVALID_GPIO,
1998 .active_low = PRESS_LEV_LOW,
2003 .adc_value = 171,//333
2004 .gpio = INVALID_GPIO,
2005 .active_low = PRESS_LEV_LOW,
2011 .gpio = INVALID_GPIO,
2012 .active_low = PRESS_LEV_LOW,
2015 struct rk29_keys_platform_data rk29_keys_pdata = {
2016 .buttons = key_button,
2017 .nbuttons = ARRAY_SIZE(key_button),
2018 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
2021 // =========== End of rk3168 top board keypad defination =============
2024 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2025 static void rk30_pm_power_off(void)
2027 printk(KERN_ERR "rk30_pm_power_off start...\n");
2028 #if defined(CONFIG_MFD_WM831X)
2029 if(pmic_is_wm8326()){
2030 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2031 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2035 #if defined(CONFIG_REGULATOR_ACT8846)
2036 if(pmic_is_act8846())
2038 act8846_device_shutdown();
2042 #if defined(CONFIG_MFD_TPS65910)
2043 if(pmic_is_tps65910())
2045 tps65910_device_shutdown();//tps65910 shutdown
2049 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2053 static void __init machine_rk30_board_init(void)
2056 gpio_request(POWER_ON_PIN, "poweronpin");
2057 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2059 pm_power_off = rk30_pm_power_off;
2061 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2064 rk30_i2c_register_board_info();
2065 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2066 platform_add_devices(devices, ARRAY_SIZE(devices));
2067 rk_platform_add_display_devices();
2068 board_usb_detect_init(RK30_PIN0_PA7);
2070 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2071 rk29sdk_wifi_bt_gpio_control_init();
2072 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2073 rk29sdk_wifi_combo_module_gpio_init();
2076 #if defined(CONFIG_MT6620)
2077 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2080 #if defined(CONFIG_MT5931_MT6622)
2081 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2085 static void __init rk30_reserve(void)
2088 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2090 #ifdef CONFIG_FB_ROCKCHIP
2091 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2092 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2094 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2095 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2098 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2099 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2100 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2104 #ifdef CONFIG_VIDEO_RK29
2105 rk30_camera_request_reserve_mem();
2108 #ifdef CONFIG_GPS_RK
2109 //it must be more than 8MB
2110 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2112 board_mem_reserved();
2116 * dvfs_cpu_logic_table: table for arm and logic dvfs
2117 * @frequency : arm frequency
2118 * @cpu_volt : arm voltage depend on frequency
2120 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2121 {.frequency = 312 * 1000, .index = 850 * 1000},
2122 {.frequency = 504 * 1000, .index = 900 * 1000},
2123 {.frequency = 816 * 1000, .index = 950 * 1000},
2124 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2125 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2126 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2127 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2128 {.frequency = CPUFREQ_TABLE_END},
2131 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2132 #if defined(CONFIG_ARCH_RK3188)
2133 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2134 #elif defined(CONFIG_ARCH_RK3066B)
2135 {.frequency = 100 * 1000, .index = 950 * 1000},//the minimum rate is no limit for rk3168 rk3066B
2138 {.frequency = 200 * 1000, .index = 975 * 1000},
2139 {.frequency = 266 * 1000, .index = 1000 * 1000},
2140 {.frequency = 300 * 1000, .index = 1050 * 1000},
2141 {.frequency = 400 * 1000, .index = 1100 * 1000},
2142 {.frequency = 600 * 1000, .index = 1200 * 1000},
2143 {.frequency = CPUFREQ_TABLE_END},
2146 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2147 #if defined(CONFIG_ARCH_RK3188)
2148 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2149 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2151 {.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2152 {.frequency = CPUFREQ_TABLE_END},
2155 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2156 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2157 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2159 void __init board_clock_init(void)
2161 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2162 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2163 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2164 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2165 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2168 MACHINE_START(RK30, "RK30board")
2169 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2170 .fixup = rk30_fixup,
2171 .reserve = &rk30_reserve,
2172 .map_io = rk30_map_io,
2173 .init_irq = rk30_init_irq,
2174 .timer = &rk30_timer,
2175 .init_machine = machine_rk30_board_init,