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>
50 #if defined(CONFIG_CT36X_TS)
51 #include <linux/ct36x.h>
53 #if defined(CONFIG_MFD_RK610)
54 #include <linux/mfd/rk610_core.h>
57 #if defined(CONFIG_RK_HDMI)
58 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
61 #if defined(CONFIG_SPIM_RK29)
62 #include "../../../drivers/spi/rk29_spim.h"
64 #if defined(CONFIG_MT6229)
65 #include <linux/mt6229.h>
67 #if defined(CONFIG_GPS_RK)
68 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
71 #if defined(CONFIG_MT6620)
72 #include <linux/gps.h>
75 #include "../mach-rk30/board-rk3168-ds1006h-camera.c"
78 static struct rk29_keys_button key_button[] = {
82 .gpio = RK30_PIN0_PA4,
83 .active_low = PRESS_LEV_LOW,
91 .active_low = PRESS_LEV_LOW,
94 struct rk29_keys_platform_data rk29_keys_pdata = {
95 .buttons = key_button,
96 .nbuttons = ARRAY_SIZE(key_button),
97 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
100 #if defined(CONFIG_CT36X_TS)
102 #define TOUCH_MODEL 363
103 #define TOUCH_MAX_X 1280
104 #define TOUCH_MAX_y 800
105 #define TOUCH_RESET_PIN RK30_PIN0_PB6
106 #define TOUCH_INT_PIN RK30_PIN1_PB7
108 static struct ct36x_platform_data ct36x_info = {
109 .model = TOUCH_MODEL,
110 .x_max = TOUCH_MAX_X,
111 .y_max = TOUCH_MAX_y,
114 .gpio = TOUCH_RESET_PIN,
118 .gpio = TOUCH_INT_PIN,
121 .orientation = {1, 0, 1, 0},
124 static struct spi_board_info board_spi_devices[] = {
127 /***********************************************************
129 ************************************************************/
130 #ifdef CONFIG_BACKLIGHT_RK29_BL
132 #define PWM_MODE PWM3
133 #define PWM_EFFECT_VALUE 1
135 #define LCD_DISP_ON_PIN
137 #ifdef LCD_DISP_ON_PIN
138 #define BL_EN_PIN RK30_PIN0_PA2
139 #define BL_EN_VALUE GPIO_HIGH
141 static int rk29_backlight_io_init(void)
146 #ifdef LCD_DISP_ON_PIN
147 ret = gpio_request(BL_EN_PIN, NULL);
149 gpio_free(BL_EN_PIN);
152 gpio_direction_output(BL_EN_PIN, 0);
153 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
159 static int rk29_backlight_io_deinit(void)
161 int ret = 0, pwm_gpio;
163 #ifdef LCD_DISP_ON_PIN
164 gpio_free(BL_EN_PIN);
167 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
168 gpio_request(pwm_gpio, NULL);
169 gpio_direction_output(pwm_gpio, GPIO_LOW);
173 static int rk29_backlight_pwm_suspend(void)
175 int ret = 0, pwm_gpio;
177 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
178 if (gpio_request(pwm_gpio, NULL)) {
179 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
182 gpio_direction_output(pwm_gpio, GPIO_LOW);
183 #ifdef LCD_DISP_ON_PIN
184 gpio_direction_output(BL_EN_PIN, 0);
185 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
190 static int rk29_backlight_pwm_resume(void)
192 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
196 #ifdef LCD_DISP_ON_PIN
198 gpio_direction_output(BL_EN_PIN, 1);
199 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
204 static struct rk29_bl_info rk29_bl_info = {
205 .min_brightness = 65,
206 .max_brightness = 150,
207 .brightness_mode =BRIGHTNESS_MODE_CONIC,
208 .pre_div = 40 * 1000, // pwm output clk: 40k;
210 .bl_ref = PWM_EFFECT_VALUE,
211 .io_init = rk29_backlight_io_init,
212 .io_deinit = rk29_backlight_io_deinit,
213 .pwm_suspend = rk29_backlight_pwm_suspend,
214 .pwm_resume = rk29_backlight_pwm_resume,
217 static struct platform_device rk29_device_backlight = {
218 .name = "rk29_backlight",
221 .platform_data = &rk29_bl_info,
228 #if defined (CONFIG_GS_MMA8452)
229 #define MMA8452_INT_PIN RK30_PIN0_PB7
231 static int mma8452_init_platform_hw(void)
236 static struct sensor_platform_data mma8452_info = {
237 .type = SENSOR_TYPE_ACCEL,
240 .init_platform_hw = mma8452_init_platform_hw,
241 .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
244 #if defined (CONFIG_GS_LIS3DH)
245 #define LIS3DH_INT_PIN RK30_PIN0_PB7
247 static int lis3dh_init_platform_hw(void)
253 static struct sensor_platform_data lis3dh_info = {
254 .type = SENSOR_TYPE_ACCEL,
257 .init_platform_hw = lis3dh_init_platform_hw,
258 .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
262 #if (defined(CONFIG_SENSORS_AK8963) || defined(CONFIG_SENSORS_AK8963_MODULE))
263 static struct akm8963_platform_data akm_platform_data_8963 = {
264 .gpio_DRDY = RK30_PIN3_PD7,
271 #if defined(CONFIG_LS_PHOTORESISTOR)
272 static struct sensor_platform_data light_photoresistor_info = {
273 .type = SENSOR_TYPE_LIGHT,
276 .poll_delay_ms = 200,
280 #if defined (CONFIG_COMPASS_AK8975)
281 static struct sensor_platform_data akm8975_info =
283 .type = SENSOR_TYPE_COMPASS,
316 #if defined(CONFIG_MT6229)
317 static int mt6229_io_init(void)
320 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
321 k30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
322 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
323 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
324 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
325 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
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_PIN0_PC6,
340 .bp_power = RK30_PIN2_PD5,
341 .modem_usb_en = RK30_PIN0_PC7,
342 .modem_uart_en = RK30_PIN2_PD4,
343 .bp_wakeup_ap = RK30_PIN0_PC5,
344 .ap_ready = RK30_PIN0_PC4,
347 struct platform_device rk29_device_mt6229 = {
351 .platform_data = &rk29_mt6229_info,
356 #if defined(CONFIG_GYRO_L3G4200D)
358 #include <linux/l3g4200d.h>
359 #define L3G4200D_INT_PIN RK30_PIN0_PB4
361 static int l3g4200d_init_platform_hw(void)
366 static struct sensor_platform_data l3g4200d_info = {
367 .type = SENSOR_TYPE_GYROSCOPE,
370 .orientation = {1, 0, 0 , 0 , -1, 0, 0, 0, -1},
371 .init_platform_hw = l3g4200d_init_platform_hw,
372 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
379 #ifdef CONFIG_LS_CM3217
380 static struct sensor_platform_data cm3217_info = {
381 .type = SENSOR_TYPE_LIGHT,
383 .poll_delay_ms = 500,
388 #ifdef CONFIG_FB_ROCKCHIP
390 #define LCD_CS_PIN INVALID_GPIO
391 #define LCD_CS_VALUE GPIO_HIGH
393 #define LCD_EN_PIN RK30_PIN0_PB0
394 #define LCD_EN_VALUE GPIO_LOW
396 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
400 if(LCD_CS_PIN !=INVALID_GPIO)
402 ret = gpio_request(LCD_CS_PIN, NULL);
405 gpio_free(LCD_CS_PIN);
406 printk(KERN_ERR "request lcd cs pin fail!\n");
411 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
415 if(LCD_EN_PIN !=INVALID_GPIO)
417 ret = gpio_request(LCD_EN_PIN, NULL);
420 gpio_free(LCD_EN_PIN);
421 printk(KERN_ERR "request lcd en pin fail!\n");
426 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
431 static int rk_fb_io_disable(void)
433 if(LCD_CS_PIN !=INVALID_GPIO)
435 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
437 if(LCD_EN_PIN !=INVALID_GPIO)
439 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
443 static int rk_fb_io_enable(void)
445 if(LCD_CS_PIN !=INVALID_GPIO)
447 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
449 if(LCD_EN_PIN !=INVALID_GPIO)
451 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
456 #if defined(CONFIG_LCDC0_RK3188)
457 struct rk29fb_info lcdc0_screen_info = {
458 .prop = EXTEND, //extend display device
460 .set_screen_info = hdmi_init_lcdc,
465 #if defined(CONFIG_LCDC1_RK3188)
466 struct rk29fb_info lcdc1_screen_info = {
467 .prop = PRMRY, //primary display device
468 .io_init = rk_fb_io_init,
469 .io_disable = rk_fb_io_disable,
470 .io_enable = rk_fb_io_enable,
471 .set_screen_info = set_lcd_info,
476 static struct resource resource_fb[] = {
480 .end = 0,//RK30_FB0_MEM_SIZE - 1,
481 .flags = IORESOURCE_MEM,
484 .name = "ipp buf", //for rotate
486 .end = 0,//RK30_FB0_MEM_SIZE - 1,
487 .flags = IORESOURCE_MEM,
492 .end = 0,//RK30_FB0_MEM_SIZE - 1,
493 .flags = IORESOURCE_MEM,
497 static struct platform_device device_fb = {
500 .num_resources = ARRAY_SIZE(resource_fb),
501 .resource = resource_fb,
505 #if defined(CONFIG_LCDC0_RK3188)
506 static struct resource resource_lcdc0[] = {
509 .start = RK30_LCDC0_PHYS,
510 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
511 .flags = IORESOURCE_MEM,
518 .flags = IORESOURCE_IRQ,
522 static struct platform_device device_lcdc0 = {
525 .num_resources = ARRAY_SIZE(resource_lcdc0),
526 .resource = resource_lcdc0,
528 .platform_data = &lcdc0_screen_info,
532 #if defined(CONFIG_LCDC1_RK3188)
533 static struct resource resource_lcdc1[] = {
536 .start = RK30_LCDC1_PHYS,
537 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
538 .flags = IORESOURCE_MEM,
544 .flags = IORESOURCE_IRQ,
548 static struct platform_device device_lcdc1 = {
551 .num_resources = ARRAY_SIZE(resource_lcdc1),
552 .resource = resource_lcdc1,
554 .platform_data = &lcdc1_screen_info,
559 #if defined(CONFIG_MFD_RK610)
560 #define RK610_RST_PIN RK30_PIN3_PB2
561 static int rk610_power_on_init(void)
564 if(RK610_RST_PIN != INVALID_GPIO)
566 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
569 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
573 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
575 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
577 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
586 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
587 .rk610_power_on_init = rk610_power_on_init,
591 #ifdef CONFIG_SND_SOC_RK610
592 static int rk610_codec_io_init(void)
595 //Must not gpio_request
599 static struct rk610_codec_platform_data rk610_codec_pdata = {
600 .spk_ctl_io = RK30_PIN2_PD7,
601 .io_init = rk610_codec_io_init,
606 #ifdef CONFIG_RK_HDMI
607 #define RK_HDMI_RST_PIN RK30_PIN3_PB2
608 static int rk_hdmi_power_init(void)
612 if(RK_HDMI_RST_PIN != INVALID_GPIO)
614 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
615 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
618 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
619 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
621 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
626 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
627 //.io_init = rk_hdmi_power_init,
631 #define ION_RESERVE_SIZE (80 * SZ_1M)
632 static struct ion_platform_data rk30_ion_pdata = {
636 .type = ION_HEAP_TYPE_CARVEOUT,
637 .id = ION_NOR_HEAP_ID,
639 .size = ION_RESERVE_SIZE,
644 static struct platform_device device_ion = {
645 .name = "ion-rockchip",
648 .platform_data = &rk30_ion_pdata,
653 /**************************************************************************************************
654 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
655 **************************************************************************************************/
656 #ifdef CONFIG_SDMMC_RK29
657 #include "board-rk3188-ds1006h-sdmmc-config.c"
658 #include "../plat-rk/rk-sdmmc-ops.c"
659 #include "../plat-rk/rk-sdmmc-wifi.c"
660 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
662 #ifdef CONFIG_SDMMC0_RK29
663 static int rk29_sdmmc0_cfg_gpio(void)
665 #ifdef CONFIG_SDMMC_RK29_OLD
667 iomux_set(MMC0_CLKOUT);
673 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
675 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
676 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
679 rk29_sdmmc_set_iomux(0, 0xFFFF);
681 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
682 #if SDMMC_USE_NEW_IOMUX_API
683 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
685 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
688 #if SDMMC_USE_NEW_IOMUX_API
689 iomux_set(MMC0_DETN);
691 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
695 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
696 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
697 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
705 #define CONFIG_SDMMC0_USE_DMA
706 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
708 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
709 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
710 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
712 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
713 .io_init = rk29_sdmmc0_cfg_gpio,
715 #if !defined(CONFIG_SDMMC_RK29_OLD)
716 .set_iomux = rk29_sdmmc_set_iomux,
719 .dma_name = "sd_mmc",
720 #ifdef CONFIG_SDMMC0_USE_DMA
726 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
727 .status = rk29sdk_wifi_mmc0_status,
728 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
731 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
732 .power_en = RK29SDK_SD_CARD_PWR_EN,
733 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
735 .power_en = INVALID_GPIO,
736 .power_en_level = GPIO_LOW,
738 .enable_sd_wakeup = 0,
740 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
741 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
742 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
744 .write_prt = INVALID_GPIO,
748 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
749 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
750 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
751 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
753 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
754 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
755 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
757 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
758 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
769 #endif // CONFIG_SDMMC0_RK29
771 #ifdef CONFIG_SDMMC1_RK29
772 #define CONFIG_SDMMC1_USE_DMA
773 static int rk29_sdmmc1_cfg_gpio(void)
775 #if defined(CONFIG_SDMMC_RK29_OLD)
777 iomux_set(MMC1_CLKOUT);
784 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
785 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
786 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
794 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
796 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
797 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
800 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
801 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
802 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
805 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
808 .io_init = rk29_sdmmc1_cfg_gpio,
810 #if !defined(CONFIG_SDMMC_RK29_OLD)
811 .set_iomux = rk29_sdmmc_set_iomux,
815 #ifdef CONFIG_SDMMC1_USE_DMA
821 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
822 .status = rk29sdk_wifi_status,
823 .register_status_notify = rk29sdk_wifi_status_register,
826 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
827 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
828 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
830 .write_prt = INVALID_GPIO,
833 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
834 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
838 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
839 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
840 .io = RK29SDK_SD_CARD_DETECT_N,
845 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
846 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
848 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
849 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
850 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
852 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
853 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
863 .enable_sd_wakeup = 0,
865 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
867 /**************************************************************************************************
868 * the end of setting for SDMMC devices
869 **************************************************************************************************/
871 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
872 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
873 .dc_det_pin = RK30_PIN0_PB2,
874 .batt_low_pin = INVALID_GPIO,
875 .charge_set_pin = INVALID_GPIO,
876 .charge_ok_pin = RK30_PIN0_PA6,
877 .usb_det_pin = INVALID_GPIO,
878 .dc_det_level = GPIO_LOW,
879 .charge_ok_level = GPIO_HIGH,
881 .reference_voltage = 1800, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
882 .pull_up_res = 200, //divider resistance , pull-up resistor
883 .pull_down_res = 120, //divider resistance , pull-down resistor
885 .is_reboot_charging = 1,
887 .low_voltage_protection = 3600,
890 static struct platform_device rk30_device_adc_battery = {
891 .name = "rk30-battery",
894 .platform_data = &rk30_adc_battery_platdata,
898 #ifdef CONFIG_RK30_PWM_REGULATOR
899 static int pwm_voltage_map[] = {
900 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
903 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
909 struct regulator_init_data pwm_regulator_init_dcdc[1] =
915 .max_uV = 1800000, //0.6-1.8V
917 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
919 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
920 .consumer_supplies = pwm_dcdc1_consumers,
924 static struct pwm_platform_data pwm_regulator_info[1] = {
927 .pwm_gpio = RK30_PIN3_PD4,
928 .pwm_iomux_pwm = PWM1,
929 .pwm_iomux_gpio = GPIO3_D4,
930 .pwm_voltage = 1100000,
931 .suspend_voltage = 1000000,
934 .coefficient = 575, //57.5%
935 .pwm_voltage_map = pwm_voltage_map,
936 .init_data = &pwm_regulator_init_dcdc[0],
940 struct platform_device pwm_regulator_device[1] = {
942 .name = "pwm-voltage-regulator",
945 .platform_data = &pwm_regulator_info[0],
951 #ifdef CONFIG_RFKILL_RK
952 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
953 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
954 .type = RFKILL_TYPE_BLUETOOTH,
956 .poweron_gpio = { // BT_REG_ON
957 .io = INVALID_GPIO, //RK30_PIN3_PC7,
960 .name = "bt_poweron",
965 .reset_gpio = { // BT_RST
966 .io = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
974 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
975 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
983 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
985 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
986 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
993 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
994 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1004 static struct platform_device device_rfkill_rk = {
1005 .name = "rfkill_rk",
1008 .platform_data = &rfkill_rk_platdata,
1013 #if defined(CONFIG_GPS_RK)
1014 int rk_gps_io_init(void)
1016 printk("%s \n", __FUNCTION__);
1018 rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
1019 gpio_request(RK30_PIN1_PB5, NULL);
1020 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1022 rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
1023 rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
1024 rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
1026 rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
1027 gpio_request(RK30_PIN1_PA6, NULL);
1028 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1030 rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
1031 gpio_request(RK30_PIN1_PA5, NULL);
1032 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1034 rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
1035 gpio_request(RK30_PIN1_PA7, NULL);
1036 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1039 int rk_gps_power_up(void)
1041 printk("%s \n", __FUNCTION__);
1046 int rk_gps_power_down(void)
1048 printk("%s \n", __FUNCTION__);
1053 int rk_gps_reset_set(int level)
1057 int rk_enable_hclk_gps(void)
1059 printk("%s \n", __FUNCTION__);
1060 clk_enable(clk_get(NULL, "hclk_gps"));
1063 int rk_disable_hclk_gps(void)
1065 printk("%s \n", __FUNCTION__);
1066 clk_disable(clk_get(NULL, "hclk_gps"));
1069 struct rk_gps_data rk_gps_info = {
1070 .io_init = rk_gps_io_init,
1071 .power_up = rk_gps_power_up,
1072 .power_down = rk_gps_power_down,
1073 .reset = rk_gps_reset_set,
1074 .enable_hclk_gps = rk_enable_hclk_gps,
1075 .disable_hclk_gps = rk_disable_hclk_gps,
1076 .GpsSign = RK30_PIN1_PB3,
1077 .GpsMag = RK30_PIN1_PB2, //GPIO index
1078 .GpsClk = RK30_PIN1_PB4, //GPIO index
1079 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1080 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1081 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1082 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1086 .u32GpsPhyAddr = RK30_GPS_PHYS,
1087 .u32GpsPhySize = RK30_GPS_SIZE,
1090 struct platform_device rk_device_gps = {
1091 .name = "gps_hv5820b",
1094 .platform_data = &rk_gps_info,
1099 #if defined(CONFIG_MT5931_MT6622)
1100 static struct mt6622_platform_data mt6622_platdata = {
1101 .power_gpio = { // BT_REG_ON
1102 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1103 .enable = GPIO_HIGH,
1109 .reset_gpio = { // BT_RST
1110 .io = RK30_PIN0_PD7,
1111 .enable = GPIO_HIGH,
1118 .io = RK30_PIN3_PD2,
1119 .enable = GPIO_HIGH,
1126 static struct platform_device device_mt6622 = {
1130 .platform_data = &mt6622_platdata,
1135 static struct platform_device *devices[] __initdata = {
1140 #ifdef CONFIG_WIFI_CONTROL_FUNC
1141 &rk29sdk_wifi_device,
1144 #if defined(CONFIG_MT6620)
1148 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1149 &rk30_device_adc_battery,
1151 #ifdef CONFIG_RFKILL_RK
1154 #ifdef CONFIG_GPS_RK
1157 #ifdef CONFIG_MT5931_MT6622
1160 #if defined(CONFIG_MT6229)
1161 &rk29_device_mt6229,
1167 static int rk_platform_add_display_devices(void)
1169 struct platform_device *fb = NULL; //fb
1170 struct platform_device *lcdc0 = NULL; //lcdc0
1171 struct platform_device *lcdc1 = NULL; //lcdc1
1172 struct platform_device *bl = NULL; //backlight
1173 #ifdef CONFIG_FB_ROCKCHIP
1177 #if defined(CONFIG_LCDC0_RK3188)
1178 lcdc0 = &device_lcdc0,
1181 #if defined(CONFIG_LCDC1_RK3188)
1182 lcdc1 = &device_lcdc1,
1185 #ifdef CONFIG_BACKLIGHT_RK29_BL
1186 bl = &rk29_device_backlight,
1188 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1195 #ifdef CONFIG_I2C0_RK30
1196 static struct i2c_board_info __initdata i2c0_info[] = {
1197 #if defined (CONFIG_GS_MMA8452)
1199 .type = "gs_mma8452",
1202 .irq = MMA8452_INT_PIN,
1203 .platform_data = &mma8452_info,
1206 #if defined (CONFIG_LS_US5151)
1214 #if defined (CONFIG_GS_LIS3DH)
1216 .type = "gs_lis3dh",
1217 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1219 .irq = LIS3DH_INT_PIN,
1220 .platform_data = &lis3dh_info,
1223 #if defined (CONFIG_SENSORS_AK8963)
1227 .flags = I2C_CLIENT_WAKE,
1228 .irq = RK30_PIN3_PD7,
1229 .platform_data = &akm_platform_data_8963,
1232 #if defined (CONFIG_LS_PHOTORESISTOR)
1234 .type = "ls_photoresistor",
1237 .irq = INVALID_GPIO,
1238 .platform_data = &light_photoresistor_info,
1242 #if defined (CONFIG_COMPASS_AK8975)
1247 .irq = RK30_PIN3_PD7,
1248 .platform_data = &akm8975_info,
1249 .irq = RK30_PIN3_PD7,
1250 .platform_data = &akm8975_info,
1253 #if defined (CONFIG_GYRO_L3G4200D)
1255 .type = "l3g4200d_gryo",
1258 .irq = L3G4200D_INT_PIN,
1259 .platform_data = &l3g4200d_info,
1262 #if defined (CONFIG_SND_SOC_RK1000)
1264 .type = "rk1000_i2c_codec",
1269 .type = "rk1000_control",
1274 #if defined (CONFIG_SND_SOC_RT5631)
1284 int __sramdata g_pmic_type = 0;
1285 #ifdef CONFIG_I2C1_RK30
1286 #ifdef CONFIG_REGULATOR_ACT8846
1287 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1288 #define PMU_VSEL RK30_PIN3_PD3
1289 #define ACT8846_HOST_IRQ RK30_PIN0_PB3
1291 static struct pmu_info act8846_dcdc_info[] = {
1293 .name = "act_dcdc1", //ddr
1296 .suspend_vol = 1200000,
1299 .name = "vdd_core", //logic
1302 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1303 .suspend_vol = 1200000,
1305 .suspend_vol = 900000,
1309 .name = "vdd_cpu", //arm
1312 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1313 .suspend_vol = 1200000,
1315 .suspend_vol = 900000,
1319 .name = "act_dcdc4", //vccio
1322 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1323 .suspend_vol = 3000000,
1325 .suspend_vol = 2800000,
1330 static struct pmu_info act8846_ldo_info[] = {
1332 .name = "act_ldo1", //vdd10
1337 .name = "act_ldo2", //vdd12
1342 .name = "act_ldo3", //vcc18_cif
1347 .name = "act_ldo4", //vcca33
1352 .name = "act_ldo5", //vcctp
1357 .name = "act_ldo6", //vcc_jetta
1362 .name = "act_ldo7", //vcc18
1367 .name = "act_ldo8", //vcc28_cif
1373 #include "../mach-rk30/board-pmu-act8846.c"
1376 #ifdef CONFIG_MFD_WM831X_I2C
1377 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1379 static struct pmu_info wm8326_dcdc_info[] = {
1381 .name = "vdd_core", //logic
1384 .suspend_vol = 950000,
1387 .name = "vdd_cpu", //arm
1390 .suspend_vol = 950000,
1393 .name = "dcdc3", //ddr
1396 .suspend_vol = 1150000,
1398 #ifdef CONFIG_MACH_RK3066_SDK
1400 .name = "dcdc4", //vcc_io
1403 .suspend_vol = 3000000,
1407 .name = "dcdc4", //vcc_io
1410 .suspend_vol = 2800000,
1415 static struct pmu_info wm8326_ldo_info[] = {
1417 .name = "ldo1", //vcc18_cif
1420 .suspend_vol = 1800000,
1423 .name = "ldo2", //vccio_wl
1426 .suspend_vol = 1800000,
1432 .suspend_vol = 1100000,
1435 .name = "ldo4", //vdd11
1438 .suspend_vol = 1000000,
1441 .name = "ldo5", //vcc25
1444 .suspend_vol = 1800000,
1447 .name = "ldo6", //vcc33
1450 .suspend_vol = 3300000,
1453 .name = "ldo7", //vcc28_cif
1456 .suspend_vol = 2800000,
1459 .name = "ldo8", //vcca33
1462 .suspend_vol = 3300000,
1465 .name = "ldo9", //vcc_tp
1468 .suspend_vol = 3300000,
1471 .name = "ldo10", //flash_io
1474 .suspend_vol = 1800000,
1478 #include "../mach-rk30/board-pmu-wm8326.c"
1481 #ifdef CONFIG_MFD_TPS65910
1482 #ifdef CONFIG_ARCH_RK3188
1483 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1485 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1488 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1490 static struct pmu_info tps65910_dcdc_info[] = {
1492 .name = "vdd_core", //logic
1497 .name = "vdd2", //ddr
1502 .name = "vio", //vcc_io
1508 static struct pmu_info tps65910_ldo_info[] = {
1510 .name = "vpll", //vdd10
1515 .name = "vdig1", //vcc18_cif
1520 .name = "vdig2", //vdd_jetta
1525 .name = "vaux1", //vcc28_cif
1530 .name = "vaux2", //vcca33
1535 .name = "vaux33", //vcc_tp
1540 .name = "vmmc", //vcc30
1545 .name = "vdac", //vcc18
1551 #include "../mach-rk30/board-pmu-tps65910.c"
1554 static struct i2c_board_info __initdata i2c1_info[] = {
1555 #if defined (CONFIG_REGULATOR_ACT8846)
1560 .irq = ACT8846_HOST_IRQ,
1561 .platform_data=&act8846_data,
1564 #if defined (CONFIG_RTC_HYM8563)
1566 .type = "rtc_hym8563",
1569 .irq = RK30_PIN0_PB5,
1572 #if defined (CONFIG_MFD_WM831X_I2C)
1577 .irq = RK30_PIN0_PB3,
1578 .platform_data = &wm831x_platdata,
1581 #if defined (CONFIG_MFD_TPS65910)
1584 .addr = TPS65910_I2C_ID0,
1586 .irq = TPS65910_HOST_IRQ,
1587 .platform_data = &tps65910_data,
1593 void __sramfunc board_pmu_suspend(void)
1595 #if defined (CONFIG_REGULATOR_ACT8846)
1596 if(pmic_is_act8846())
1597 board_pmu_act8846_suspend();
1599 #if defined (CONFIG_MFD_WM831X_I2C)
1600 if(pmic_is_wm8326())
1601 board_pmu_wm8326_suspend();
1603 #if defined (CONFIG_MFD_TPS65910)
1604 if(pmic_is_tps65910())
1605 board_pmu_tps65910_suspend();
1609 void __sramfunc board_pmu_resume(void)
1611 #if defined (CONFIG_REGULATOR_ACT8846)
1612 if(pmic_is_act8846())
1613 board_pmu_act8846_resume();
1615 #if defined (CONFIG_MFD_WM831X_I2C)
1616 if(pmic_is_wm8326())
1617 board_pmu_wm8326_resume();
1619 #if defined (CONFIG_MFD_TPS65910)
1620 if(pmic_is_tps65910())
1621 board_pmu_tps65910_resume();
1625 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1627 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1628 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1630 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1632 #ifdef CONFIG_RK30_PWM_REGULATOR
1634 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1636 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1637 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1638 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1639 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1641 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1642 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1643 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1644 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1647 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1649 #ifdef CONFIG_RK30_PWM_REGULATOR
1650 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1651 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1652 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1653 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1659 extern void pwm_suspend_voltage(void);
1660 extern void pwm_resume_voltage(void);
1661 void rk30_pwm_suspend_voltage_set(void)
1663 #ifdef CONFIG_RK30_PWM_REGULATOR
1664 pwm_suspend_voltage();
1667 void rk30_pwm_resume_voltage_set(void)
1669 #ifdef CONFIG_RK30_PWM_REGULATOR
1670 pwm_resume_voltage();
1675 #ifdef CONFIG_I2C2_RK30
1676 static struct i2c_board_info __initdata i2c2_info[] = {
1677 #if defined (CONFIG_CT36X_TS)
1682 .platform_data = &ct36x_info,
1685 #if defined (CONFIG_LS_CM3217)
1687 .type = "lightsensor",
1690 .platform_data = &cm3217_info,
1693 #if defined(CONFIG_HDMI_CAT66121)
1695 .type = "cat66121_hdmi",
1698 .irq = RK30_PIN2_PD6,
1699 .platform_data = &rk_hdmi_pdata,
1705 #ifdef CONFIG_I2C3_RK30
1706 static struct i2c_board_info __initdata i2c3_info[] = {
1710 #ifdef CONFIG_I2C4_RK30
1711 static struct i2c_board_info __initdata i2c4_info[] = {
1712 #ifdef CONFIG_MFD_RK610
1714 .type = "rk610_ctl",
1717 .platform_data = &rk610_ctl_pdata,
1719 #ifdef CONFIG_RK610_TVOUT
1721 .type = "rk610_tvout",
1726 #ifdef CONFIG_HDMI_RK610
1728 .type = "rk610_hdmi",
1731 .irq = INVALID_GPIO,
1734 #ifdef CONFIG_SND_SOC_RK610
1735 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1736 .type = "rk610_i2c_codec",
1739 .platform_data = &rk610_codec_pdata,
1747 #ifdef CONFIG_I2C_GPIO_RK30
1748 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1749 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1750 static int rk30_i2c_io_init(void)
1752 //set iomux (gpio) here
1753 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1754 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1758 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1759 .sda_pin = I2C_SDA_PIN,
1760 .scl_pin = I2C_SCL_PIN,
1761 .udelay = 5, // clk = 500/udelay = 100Khz
1762 .timeout = 100,//msecs_to_jiffies(100),
1764 .io_init = rk30_i2c_io_init,
1766 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1770 static void __init rk30_i2c_register_board_info(void)
1772 #ifdef CONFIG_I2C0_RK30
1773 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1775 #ifdef CONFIG_I2C1_RK30
1776 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1778 #ifdef CONFIG_I2C2_RK30
1779 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1781 #ifdef CONFIG_I2C3_RK30
1782 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1784 #ifdef CONFIG_I2C4_RK30
1785 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1787 #ifdef CONFIG_I2C_GPIO_RK30
1788 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1793 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
1794 static void rk30_pm_power_off(void)
1796 printk(KERN_ERR "rk30_pm_power_off start...\n");
1797 #if defined(CONFIG_MFD_WM831X)
1798 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
1799 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1801 #if defined(CONFIG_REGULATOR_ACT8846)
1802 if (pmic_is_act8846()) {
1803 printk("enter dcdet===========\n");
1804 if(gpio_get_value (RK30_PIN0_PB2) == GPIO_LOW)
1806 printk("enter restart===========\n");
1807 arm_pm_restart(0, NULL);
1811 act8846_device_shutdown();
1815 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1819 static void __init machine_rk30_board_init(void)
1822 gpio_request(POWER_ON_PIN, "poweronpin");
1823 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1825 pm_power_off = rk30_pm_power_off;
1827 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1830 rk30_i2c_register_board_info();
1831 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1832 platform_add_devices(devices, ARRAY_SIZE(devices));
1833 rk_platform_add_display_devices();
1834 board_usb_detect_init(RK30_PIN0_PA7);
1836 #ifdef CONFIG_WIFI_CONTROL_FUNC
1837 rk29sdk_wifi_bt_gpio_control_init();
1840 #if defined(CONFIG_MT6620)
1841 clk_set_rate(clk_get_sys("rk_serial.1", "uart"), 48*1000000);
1844 #if defined(CONFIG_MT5931_MT6622)
1845 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
1849 static void __init rk30_reserve(void)
1852 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1855 #ifdef CONFIG_FB_ROCKCHIP
1856 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
1857 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
1859 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1860 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1863 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
1864 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
1865 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
1870 #ifdef CONFIG_VIDEO_RK29
1871 rk30_camera_request_reserve_mem();
1874 #ifdef CONFIG_GPS_RK
1875 //it must be more than 8MB
1876 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
1878 board_mem_reserved();
1882 * dvfs_cpu_logic_table: table for arm and logic dvfs
1883 * @frequency : arm frequency
1884 * @cpu_volt : arm voltage depend on frequency
1885 * @logic_volt : logic voltage arm requests depend on frequency
1886 * comments : min arm/logic voltage
1888 static struct cpufreq_frequency_table dvfs_arm_table[] = {
1890 {.frequency = 312 * 1000, .index = 850 * 1000},
1891 {.frequency = 504 * 1000, .index = 900 * 1000},
1892 {.frequency = 816 * 1000, .index = 950 * 1000},
1893 {.frequency = 1008 * 1000, .index = 1025 * 1000},
1894 {.frequency = 1200 * 1000, .index = 1100 * 1000},
1895 {.frequency = 1416 * 1000, .index = 1200 * 1000},
1896 //{.frequency = 1608 * 1000, .index = 1300 * 1000},
1898 {.frequency = 312 * 1000, .index = 800 * 1000},
1899 {.frequency = 504 * 1000, .index = 850 * 1000},
1900 {.frequency = 816 * 1000, .index = 950 * 1000},
1901 {.frequency = 1008 * 1000, .index = 1000 * 1000},
1902 {.frequency = 1200 * 1000, .index = 1075 * 1000},
1903 {.frequency = 1416 * 1000, .index = 1175 * 1000},
1904 {.frequency = 1608 * 1000, .index = 1275 * 1000},
1907 {.frequency = CPUFREQ_TABLE_END},
1910 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1911 {.frequency = 100 * 1000, .index = 950 * 1000},
1912 {.frequency = 150 * 1000, .index = 975 * 1000},
1913 {.frequency = 200 * 1000, .index = 975 * 1000},
1914 {.frequency = 240 * 1000, .index = 1000 * 1000},
1915 {.frequency = 300 * 1000, .index = 1050 * 1000},
1916 {.frequency = 400 * 1000, .index = 1100 * 1000},
1917 {.frequency = 600 * 1000, .index = 1200 * 1000},
1918 {.frequency = CPUFREQ_TABLE_END},
1921 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1922 //{.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
1923 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
1924 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
1925 {.frequency = CPUFREQ_TABLE_END},
1928 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
1929 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1930 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1932 void __init board_clock_init(void)
1934 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1935 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1936 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
1937 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1938 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1941 MACHINE_START(RK30, "RK30board")
1942 .boot_params = PLAT_PHYS_OFFSET + 0x800,
1943 .fixup = rk30_fixup,
1944 .reserve = &rk30_reserve,
1945 .map_io = rk30_map_io,
1946 .init_irq = rk30_init_irq,
1947 .timer = &rk30_timer,
1948 .init_machine = machine_rk30_board_init,