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>
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/rk29-pwm-regulator.h>
49 #if defined(CONFIG_HDMI_RK30)
50 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
53 #if defined(CONFIG_SPIM_RK29)
54 #include "../../../drivers/spi/rk29_spim.h"
56 #if defined(CONFIG_MU509)
57 #include <linux/mu509.h>
59 #if defined(CONFIG_MW100)
60 #include <linux/mw100.h>
62 #if defined(CONFIG_MT6229)
63 #include <linux/mt6229.h>
65 #if defined(CONFIG_ANDROID_TIMED_GPIO)
66 #include "../../../drivers/staging/android/timed_gpio.h"
69 #ifdef CONFIG_THREE_FB_BUFFER
70 #define RK30_FB0_MEM_SIZE 12*SZ_1M
72 #define RK30_FB0_MEM_SIZE 8*SZ_1M
75 #include "board-rk3066b-sdk-camera.c"
76 #include "board-rk3066b-sdk-key.c"
78 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
79 #define TOUCH_RESET_PIN RK30_PIN2_PC0
80 #define TOUCH_PWR_PIN RK30_PIN2_PB4
81 static int goodix_init_platform_hw(void)
85 rk30_mux_api_set(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME, GPIO2C_GPIO2C0);
86 rk30_mux_api_set(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME, GPIO2B_GPIO2B4);
87 printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME),rk30_mux_api_get(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME));
89 if (TOUCH_PWR_PIN != INVALID_GPIO) {
90 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
92 gpio_free(TOUCH_PWR_PIN);
93 printk("goodix power error\n");
96 gpio_direction_output(TOUCH_PWR_PIN, 0);
97 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
101 if (TOUCH_RESET_PIN != INVALID_GPIO) {
102 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
104 gpio_free(TOUCH_RESET_PIN);
105 printk("goodix gpio_request error\n");
108 gpio_direction_output(TOUCH_RESET_PIN, 1);
110 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
112 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
118 struct goodix_platform_data goodix_info = {
120 .irq_pin = RK30_PIN0_PD4,
121 .rest_pin = TOUCH_RESET_PIN,
122 .init_platform_hw = goodix_init_platform_hw,
126 static struct spi_board_info board_spi_devices[] = {
129 /***********************************************************
131 ************************************************************/
132 #ifdef CONFIG_BACKLIGHT_RK29_BL
134 #define PWM_MUX_NAME GPIO3D5_PWM2_JTAGTCK_OTGDRVVBUS_NAME
135 #define PWM_MUX_MODE GPIO3D_PWM2
136 #define PWM_MUX_MODE_GPIO GPIO3D_GPIO3D5
137 #define PWM_GPIO RK30_PIN3_PD5
138 #define PWM_EFFECT_VALUE 1
140 #define LCD_DISP_ON_PIN
142 #ifdef LCD_DISP_ON_PIN
143 #define BL_EN_PIN RK30_PIN0_PA2
144 #define BL_EN_VALUE GPIO_HIGH
146 static int rk29_backlight_io_init(void)
149 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
150 #ifdef LCD_DISP_ON_PIN
151 // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
153 ret = gpio_request(BL_EN_PIN, NULL);
155 gpio_free(BL_EN_PIN);
158 gpio_direction_output(BL_EN_PIN, 0);
159 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
164 static int rk29_backlight_io_deinit(void)
167 #ifdef LCD_DISP_ON_PIN
168 gpio_free(BL_EN_PIN);
170 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
171 gpio_request(PWM_GPIO, NULL);
172 gpio_direction_output(PWM_GPIO, GPIO_LOW);
176 static int rk29_backlight_pwm_suspend(void)
179 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
180 if (gpio_request(PWM_GPIO, NULL)) {
181 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
184 gpio_direction_output(PWM_GPIO, GPIO_LOW);
185 #ifdef LCD_DISP_ON_PIN
186 gpio_direction_output(BL_EN_PIN, 0);
187 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
192 static int rk29_backlight_pwm_resume(void)
195 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_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 = {
206 .bl_ref = PWM_EFFECT_VALUE,
207 .io_init = rk29_backlight_io_init,
208 .io_deinit = rk29_backlight_io_deinit,
209 .pwm_suspend = rk29_backlight_pwm_suspend,
210 .pwm_resume = rk29_backlight_pwm_resume,
213 static struct platform_device rk29_device_backlight = {
214 .name = "rk29_backlight",
217 .platform_data = &rk29_bl_info,
223 #ifdef CONFIG_RK29_SUPPORT_MODEM
225 #define RK30_MODEM_POWER RK30_PIN2_PB0
226 #define RK30_MODEM_POWER_IOMUX rk29_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0)
228 static int rk30_modem_io_init(void)
230 printk("%s\n", __FUNCTION__);
231 RK30_MODEM_POWER_IOMUX;
236 static struct rk29_io_t rk30_modem_io = {
237 .io_addr = RK30_MODEM_POWER,
240 .io_init = rk30_modem_io_init,
243 static struct platform_device rk30_device_modem = {
244 .name = "rk30_modem",
247 .platform_data = &rk30_modem_io,
251 #if defined(CONFIG_MU509)
252 static int mu509_io_init(void)
255 rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
256 rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
257 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
258 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
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_PB0,
272 .bp_power = RK30_PIN2_PB0,
273 .bp_reset = RK30_PIN2_PD1,
274 .ap_wakeup_bp = RK30_PIN2_PB7,
275 .bp_wakeup_ap = RK30_PIN6_PA0,
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)
288 rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
289 rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
290 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
291 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
295 static int mw100_io_deinit(void)
301 struct rk29_mw100_data rk29_mw100_info = {
302 .io_init = mw100_io_init,
303 .io_deinit = mw100_io_deinit,
304 .modem_power_en = RK30_PIN6_PB0,
305 .bp_power = RK30_PIN2_PB0,
306 .bp_reset = RK30_PIN2_PD1,
307 .ap_wakeup_bp = RK30_PIN2_PB7,
308 .bp_wakeup_ap = RK30_PIN6_PA0,
310 struct platform_device rk29_device_mw100 = {
314 .platform_data = &rk29_mw100_info,
318 #if defined(CONFIG_MT6229)
319 static int mt6229_io_init(void)
321 rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
322 rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
323 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
324 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
328 static int mt6229_io_deinit(void)
334 struct rk29_mt6229_data rk29_mt6229_info = {
335 .io_init = mt6229_io_init,
336 .io_deinit = mt6229_io_deinit,
337 .modem_power_en = RK30_PIN2_PB0,
338 .bp_power = RK30_PIN2_PB0,//RK30_PIN2_PB6,
339 .bp_reset = RK30_PIN2_PD1,
340 .ap_wakeup_bp = RK30_PIN2_PC0,
341 .bp_wakeup_ap = RK30_PIN6_PA0,
343 struct platform_device rk29_device_mt6229 = {
347 .platform_data = &rk29_mt6229_info,
353 #if defined (CONFIG_GS_MMA8452)
354 #define MMA8452_INT_PIN RK30_PIN3_PD7
356 static int mma8452_init_platform_hw(void)
361 static struct sensor_platform_data mma8452_info = {
362 .type = SENSOR_TYPE_ACCEL,
365 .init_platform_hw = mma8452_init_platform_hw,
366 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
369 #if defined (CONFIG_GS_LIS3DH)
370 #define LIS3DH_INT_PIN RK30_PIN3_PD7
372 static int lis3dh_init_platform_hw(void)
378 static struct sensor_platform_data lis3dh_info = {
379 .type = SENSOR_TYPE_ACCEL,
382 .init_platform_hw = lis3dh_init_platform_hw,
383 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
386 #if defined (CONFIG_COMPASS_AK8975)
387 static struct sensor_platform_data akm8975_info =
389 .type = SENSOR_TYPE_COMPASS,
422 #if defined(CONFIG_GYRO_L3G4200D)
424 #include <linux/l3g4200d.h>
425 #define L3G4200D_INT_PIN RK30_PIN0_PB4
427 static int l3g4200d_init_platform_hw(void)
432 static struct sensor_platform_data l3g4200d_info = {
433 .type = SENSOR_TYPE_GYROSCOPE,
436 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
437 .init_platform_hw = l3g4200d_init_platform_hw,
438 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
445 #ifdef CONFIG_LS_CM3217
446 static struct sensor_platform_data cm3217_info = {
447 .type = SENSOR_TYPE_LIGHT,
449 .poll_delay_ms = 500,
454 #ifdef CONFIG_FB_ROCKCHIP
456 #define LCD_CS_PIN INVALID_GPIO
457 #define LCD_CS_VALUE GPIO_HIGH
459 #define LCD_EN_PIN RK30_PIN0_PB0
460 #define LCD_EN_VALUE GPIO_HIGH
462 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
466 if(LCD_CS_PIN !=INVALID_GPIO)
468 ret = gpio_request(LCD_CS_PIN, NULL);
471 gpio_free(LCD_CS_PIN);
472 printk(KERN_ERR "request lcd cs pin fail!\n");
477 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
481 if(LCD_EN_PIN !=INVALID_GPIO)
483 ret = gpio_request(LCD_EN_PIN, NULL);
486 gpio_free(LCD_EN_PIN);
487 printk(KERN_ERR "request lcd en pin fail!\n");
492 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
497 static int rk_fb_io_disable(void)
499 if(LCD_CS_PIN !=INVALID_GPIO)
501 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
503 if(LCD_EN_PIN !=INVALID_GPIO)
505 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
509 static int rk_fb_io_enable(void)
511 if(LCD_CS_PIN !=INVALID_GPIO)
513 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
515 if(LCD_EN_PIN !=INVALID_GPIO)
517 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
522 #if defined(CONFIG_LCDC0_RK3066B)
523 struct rk29fb_info lcdc0_screen_info = {
524 .prop = PRMRY, //primary display device
525 .io_init = rk_fb_io_init,
526 .io_disable = rk_fb_io_disable,
527 .io_enable = rk_fb_io_enable,
528 .set_screen_info = set_lcd_info,
532 #if defined(CONFIG_LCDC1_RK3066B)
533 struct rk29fb_info lcdc1_screen_info = {
534 #if defined(CONFIG_HDMI_RK30)
535 .prop = EXTEND, //extend display device
537 .set_screen_info = hdmi_init_lcdc,
542 static struct resource resource_fb[] = {
546 .end = 0,//RK30_FB0_MEM_SIZE - 1,
547 .flags = IORESOURCE_MEM,
550 .name = "ipp buf", //for rotate
552 .end = 0,//RK30_FB0_MEM_SIZE - 1,
553 .flags = IORESOURCE_MEM,
558 .end = 0,//RK30_FB0_MEM_SIZE - 1,
559 .flags = IORESOURCE_MEM,
563 static struct platform_device device_fb = {
566 .num_resources = ARRAY_SIZE(resource_fb),
567 .resource = resource_fb,
571 #if defined(CONFIG_LCDC0_RK3066B)
572 static struct resource resource_lcdc0[] = {
575 .start = RK30_LCDC0_PHYS,
576 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
577 .flags = IORESOURCE_MEM,
584 .flags = IORESOURCE_IRQ,
588 static struct platform_device device_lcdc0 = {
591 .num_resources = ARRAY_SIZE(resource_lcdc0),
592 .resource = resource_lcdc0,
594 .platform_data = &lcdc0_screen_info,
598 #if defined(CONFIG_LCDC1_RK3066B)
599 static struct resource resource_lcdc1[] = {
602 .start = RK30_LCDC1_PHYS,
603 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
604 .flags = IORESOURCE_MEM,
610 .flags = IORESOURCE_IRQ,
614 static struct platform_device device_lcdc1 = {
617 .num_resources = ARRAY_SIZE(resource_lcdc1),
618 .resource = resource_lcdc1,
620 .platform_data = &lcdc1_screen_info,
625 #ifdef CONFIG_ANDROID_TIMED_GPIO
626 static struct timed_gpio timed_gpios[] = {
629 .gpio = RK30_PIN3_PD3,
632 .adjust_time =20, //adjust for diff product
636 static struct timed_gpio_platform_data rk29_vibrator_info = {
638 .gpios = timed_gpios,
641 static struct platform_device rk29_device_vibrator = {
642 .name = "timed-gpio",
645 .platform_data = &rk29_vibrator_info,
651 #ifdef CONFIG_LEDS_GPIO_PLATFORM
652 static struct gpio_led rk29_leds[] = {
654 .name = "button-backlight",
655 .gpio = RK30_PIN2_PB3,
656 .default_trigger = "timer",
658 .retain_state_suspended = 0,
659 .default_state = LEDS_GPIO_DEFSTATE_OFF,
663 static struct gpio_led_platform_data rk29_leds_pdata = {
665 .num_leds = ARRAY_SIZE(rk29_leds),
668 static struct platform_device rk29_device_gpio_leds = {
672 .platform_data = &rk29_leds_pdata,
677 #ifdef CONFIG_RK_IRDA
678 #define IRDA_IRQ_PIN RK30_PIN0_PA3
680 static int irda_iomux_init(void)
685 ret = gpio_request(IRDA_IRQ_PIN, NULL);
687 gpio_free(IRDA_IRQ_PIN);
688 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
690 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
691 gpio_direction_input(IRDA_IRQ_PIN);
696 static int irda_iomux_deinit(void)
698 gpio_free(IRDA_IRQ_PIN);
702 static struct irda_info rk29_irda_info = {
703 .intr_pin = IRDA_IRQ_PIN,
704 .iomux_init = irda_iomux_init,
705 .iomux_deinit = irda_iomux_deinit,
706 //.irda_pwr_ctl = bu92747guw_power_ctl,
709 static struct platform_device irda_device = {
710 #ifdef CONFIG_RK_IRDA_NET
713 .name = "bu92747_irda",
717 .platform_data = &rk29_irda_info,
723 #define ION_RESERVE_SIZE (80 * SZ_1M)
724 static struct ion_platform_data rk30_ion_pdata = {
728 .type = ION_HEAP_TYPE_CARVEOUT,
729 .id = ION_NOR_HEAP_ID,
731 .size = ION_RESERVE_SIZE,
736 static struct platform_device device_ion = {
737 .name = "ion-rockchip",
740 .platform_data = &rk30_ion_pdata,
745 /**************************************************************************************************
746 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
747 **************************************************************************************************/
748 #ifdef CONFIG_SDMMC_RK29
749 #include "board-rk3066b-sdk-sdmmc.c"
751 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
752 #define SDMMC0_WRITE_PROTECT_PIN RK30_PIN3_PB7 //According to your own project to set the value of write-protect-pin.
755 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
756 #define SDMMC1_WRITE_PROTECT_PIN RK30_PIN3_PC7 //According to your own project to set the value of write-protect-pin.
759 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK30_PIN6_PB2
761 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
763 #ifdef CONFIG_SDMMC0_RK29
764 static int rk29_sdmmc0_cfg_gpio(void)
766 #ifdef CONFIG_SDMMC_RK29_OLD
767 rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
768 rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
769 rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
770 rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
771 rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
772 rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
774 rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
776 rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
777 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
778 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
781 rk29_sdmmc_set_iomux(0, 0xFFFF);
783 rk30_mux_api_set(GPIO3B0_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0DETECTN);
785 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
786 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
787 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
795 #define CONFIG_SDMMC0_USE_DMA
796 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
798 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
799 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
800 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
802 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
803 .io_init = rk29_sdmmc0_cfg_gpio,
805 #if !defined(CONFIG_SDMMC_RK29_OLD)
806 .set_iomux = rk29_sdmmc_set_iomux,
809 .dma_name = "sd_mmc",
810 #ifdef CONFIG_SDMMC0_USE_DMA
815 .detect_irq = RK30_PIN3_PB6, // INVALID_GPIO
816 .enable_sd_wakeup = 0,
818 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
819 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
821 .write_prt = INVALID_GPIO,
824 #endif // CONFIG_SDMMC0_RK29
826 #ifdef CONFIG_SDMMC1_RK29
827 #define CONFIG_SDMMC1_USE_DMA
828 static int rk29_sdmmc1_cfg_gpio(void)
830 #if defined(CONFIG_SDMMC_RK29_OLD)
831 rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
832 rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
833 rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
834 rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
835 rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
836 rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
837 //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
841 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
842 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
843 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
851 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
853 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
854 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
857 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
858 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
859 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
862 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
865 .io_init = rk29_sdmmc1_cfg_gpio,
867 #if !defined(CONFIG_SDMMC_RK29_OLD)
868 .set_iomux = rk29_sdmmc_set_iomux,
872 #ifdef CONFIG_SDMMC1_USE_DMA
878 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
879 #ifdef CONFIG_WIFI_CONTROL_FUNC
880 .status = rk29sdk_wifi_status,
881 .register_status_notify = rk29sdk_wifi_status_register,
884 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
887 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
888 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
890 .write_prt = INVALID_GPIO,
894 .detect_irq = INVALID_GPIO,
895 .enable_sd_wakeup = 0,
899 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
901 /**************************************************************************************************
902 * the end of setting for SDMMC devices
903 **************************************************************************************************/
905 #ifdef CONFIG_BATTERY_RK30_ADC
906 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
907 .dc_det_pin = RK30_PIN0_PB2,
908 .batt_low_pin = RK30_PIN0_PB1,
909 .charge_set_pin = INVALID_GPIO,
910 .charge_ok_pin = RK30_PIN0_PA6,
911 .dc_det_level = GPIO_LOW,
912 .charge_ok_level = GPIO_HIGH,
915 static struct platform_device rk30_device_adc_battery = {
916 .name = "rk30-battery",
919 .platform_data = &rk30_adc_battery_platdata,
923 #ifdef CONFIG_RK30_PWM_REGULATOR
924 const static int pwm_voltage_map[] = {
925 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
928 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
930 .supply = "vdd_core",
934 struct regulator_init_data pwm_regulator_init_dcdc[1] =
940 .max_uV = 1800000, //0.6-1.8V
942 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
944 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
945 .consumer_supplies = pwm_dcdc1_consumers,
949 static struct pwm_platform_data pwm_regulator_info[1] = {
952 .pwm_gpio = RK30_PIN3_PD6,
953 .pwm_iomux_name = GPIO3D6_PWM3_JTAGTMS_HOSTDRVVBUS_NAME,
954 .pwm_iomux_pwm = GPIO3D_PWM3,
955 .pwm_iomux_gpio = GPIO3D_GPIO3D6,
956 .pwm_voltage = 1100000,
957 .suspend_voltage = 1050000,
960 .coefficient = 455, //45.5%
961 .pwm_voltage_map = pwm_voltage_map,
962 .init_data = &pwm_regulator_init_dcdc[0],
966 struct platform_device pwm_regulator_device[1] = {
968 .name = "pwm-voltage-regulator",
971 .platform_data = &pwm_regulator_info[0],
977 #ifdef CONFIG_RK29_VMAC
978 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
979 #include "board-rk30-sdk-vmac.c"
982 #ifdef CONFIG_RFKILL_RK
983 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
984 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
985 .type = RFKILL_TYPE_BLUETOOTH,
987 .poweron_gpio = { // BT_REG_ON
988 .io = INVALID_GPIO, //RK30_PIN3_PC7,
991 .name = GPIO3C7_SDMMC1WRITEPRT_RMIICRS_NAME,
992 .fgpio = GPIO3C_GPIO3C7,
996 .reset_gpio = { // BT_RST
997 .io = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1000 .name = GPIO3D1_SDMMC1BACKENDPWR_MIIMDCLK_NAME,
1001 .fgpio = GPIO3D_GPIO3D1,
1005 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1006 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1007 .enable = GPIO_HIGH,
1009 .name = GPIO3C6_SDMMC1DETECTN_RMIIRXERR_NAME,
1010 .fgpio = GPIO3C_GPIO3C6,
1014 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1016 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1017 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1024 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1025 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1028 .name = GPIO1A3_UART0RTSN_NAME,
1029 .fgpio = GPIO1A_GPIO1A3,
1030 .fmux = GPIO1A_UART0RTSN,
1035 static struct platform_device device_rfkill_rk = {
1036 .name = "rfkill_rk",
1039 .platform_data = &rfkill_rk_platdata,
1044 static struct platform_device *devices[] __initdata = {
1045 #ifdef CONFIG_FB_ROCKCHIP
1048 #if defined(CONFIG_LCDC0_RK3066B)
1051 #if defined(CONFIG_LCDC1_RK3066B)
1055 #ifdef CONFIG_BACKLIGHT_RK29_BL
1056 &rk29_device_backlight,
1062 #ifdef CONFIG_ANDROID_TIMED_GPIO
1063 &rk29_device_vibrator,
1065 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1066 &rk29_device_gpio_leds,
1068 #ifdef CONFIG_RK_IRDA
1071 #ifdef CONFIG_WIFI_CONTROL_FUNC
1072 &rk29sdk_wifi_device,
1074 #ifdef CONFIG_RK29_SUPPORT_MODEM
1077 #if defined(CONFIG_MU509)
1080 #if defined(CONFIG_MW100)
1083 #if defined(CONFIG_MT6229)
1084 &rk29_device_mt6229,
1086 #ifdef CONFIG_BATTERY_RK30_ADC
1087 &rk30_device_adc_battery,
1089 #ifdef CONFIG_RFKILL_RK
1095 #ifdef CONFIG_I2C0_RK30
1096 static struct i2c_board_info __initdata i2c0_info[] = {
1097 #if defined (CONFIG_GS_MMA8452)
1099 .type = "gs_mma8452",
1102 .irq = MMA8452_INT_PIN,
1103 .platform_data = &mma8452_info,
1106 #if defined (CONFIG_GS_LIS3DH)
1108 .type = "gs_lis3dh",
1109 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1111 .irq = LIS3DH_INT_PIN,
1112 .platform_data = &lis3dh_info,
1115 #if defined (CONFIG_COMPASS_AK8975)
1120 .irq = RK30_PIN0_PD5,
1121 .platform_data = &akm8975_info,
1124 #if defined (CONFIG_GYRO_L3G4200D)
1126 .type = "l3g4200d_gryo",
1129 .irq = L3G4200D_INT_PIN,
1130 .platform_data = &l3g4200d_info,
1133 #if defined (CONFIG_SND_SOC_RK1000)
1135 .type = "rk1000_i2c_codec",
1140 .type = "rk1000_control",
1145 #if defined (CONFIG_SND_SOC_RT5631)
1153 #ifdef CONFIG_MFD_RK610
1155 .type = "rk610_ctl",
1159 #ifdef CONFIG_RK610_TVOUT
1161 .type = "rk610_tvout",
1166 #ifdef CONFIG_HDMI_RK610
1168 .type = "rk610_hdmi",
1171 .irq = INVALID_GPIO,
1174 #ifdef CONFIG_SND_SOC_RK610
1175 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1176 .type = "rk610_i2c_codec",
1186 #define PMIC_TYPE_WM8326 1
1187 #define PMIC_TYPE_TPS65910 2
1188 int __sramdata g_pmic_type = 0;
1189 #ifdef CONFIG_I2C1_RK30
1190 #ifdef CONFIG_MFD_WM831X_I2C
1191 #include "board-rk3066b-sdk-wm8326.c"
1193 #ifdef CONFIG_MFD_TPS65910
1194 #ifdef CONFIG_ARCH_RK3066B
1195 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1197 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1199 #include "board-rk3066b-sdk-tps65910.c"
1202 static struct i2c_board_info __initdata i2c1_info[] = {
1203 #if defined (CONFIG_MFD_WM831X_I2C)
1208 .irq = RK30_PIN0_PB3,
1209 .platform_data = &wm831x_platdata,
1212 #if defined (CONFIG_MFD_TPS65910)
1215 .addr = TPS65910_I2C_ID0,
1217 .irq = TPS65910_HOST_IRQ,
1218 .platform_data = &tps65910_data,
1224 void __sramfunc board_pmu_suspend(void)
1226 #if defined (CONFIG_MFD_WM831X_I2C)
1227 if(g_pmic_type == PMIC_TYPE_WM8326)
1228 board_pmu_wm8326_suspend();
1230 #if defined (CONFIG_MFD_TPS65910)
1231 if(g_pmic_type == PMIC_TYPE_TPS65910)
1232 board_pmu_tps65910_suspend();
1236 void __sramfunc board_pmu_resume(void)
1238 #if defined (CONFIG_MFD_WM831X_I2C)
1239 if(g_pmic_type == PMIC_TYPE_WM8326)
1240 board_pmu_wm8326_resume();
1242 #if defined (CONFIG_MFD_TPS65910)
1243 if(g_pmic_type == PMIC_TYPE_TPS65910)
1244 board_pmu_tps65910_resume();
1248 int __sramdata gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1250 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1252 #ifdef CONFIG_RK30_PWM_REGULATOR
1254 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1256 gpio0d7_iomux = readl_relaxed(GRF_GPIO0D_IOMUX);
1257 gpio0d7_do = grf_readl(GRF_GPIO0H_DO);
1258 gpio0d7_dir = grf_readl(GRF_GPIO0H_DIR);
1259 gpio0d7_en = grf_readl(GRF_GPIO0H_EN);
1261 writel_relaxed((1<<30), GRF_GPIO0D_IOMUX);
1262 grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DIR);
1263 grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DO);
1264 grf_writel((1<<31)|(1<<15), GRF_GPIO0H_EN);
1267 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1269 #ifdef CONFIG_RK30_PWM_REGULATOR
1270 writel_relaxed((1<<30)|gpio0d7_iomux, GRF_GPIO0D_IOMUX);
1271 grf_writel((1<<31)|gpio0d7_en, GRF_GPIO0H_EN);
1272 grf_writel((1<<31)|gpio0d7_dir, GRF_GPIO0H_DIR);
1273 grf_writel((1<<31)|gpio0d7_do, GRF_GPIO0H_DO);
1279 extern void pwm_suspend_voltage(void);
1280 extern void pwm_resume_voltage(void);
1281 void rk30_pwm_suspend_voltage_set(void)
1283 #ifdef CONFIG_RK30_PWM_REGULATOR
1284 pwm_suspend_voltage();
1287 void rk30_pwm_resume_voltage_set(void)
1289 #ifdef CONFIG_RK30_PWM_REGULATOR
1290 pwm_resume_voltage();
1295 #ifdef CONFIG_I2C2_RK30
1296 static struct i2c_board_info __initdata i2c2_info[] = {
1297 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1299 .type = "Goodix-TS",
1302 .irq = RK30_PIN0_PD4,
1303 .platform_data = &goodix_info,
1306 #if defined (CONFIG_LS_CM3217)
1308 .type = "lightsensor",
1311 .platform_data = &cm3217_info,
1317 #ifdef CONFIG_I2C3_RK30
1318 static struct i2c_board_info __initdata i2c3_info[] = {
1322 #ifdef CONFIG_I2C4_RK30
1323 static struct i2c_board_info __initdata i2c4_info[] = {
1327 #ifdef CONFIG_I2C_GPIO_RK30
1328 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1329 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1330 static int rk30_i2c_io_init(void)
1332 //set iomux (gpio) here
1333 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1334 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1338 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1339 .sda_pin = I2C_SDA_PIN,
1340 .scl_pin = I2C_SCL_PIN,
1341 .udelay = 5, // clk = 500/udelay = 100Khz
1342 .timeout = 100,//msecs_to_jiffies(100),
1344 .io_init = rk30_i2c_io_init,
1346 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1350 static void __init rk30_i2c_register_board_info(void)
1352 #ifdef CONFIG_I2C0_RK30
1353 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1355 #ifdef CONFIG_I2C1_RK30
1356 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1358 #ifdef CONFIG_I2C2_RK30
1359 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1361 #ifdef CONFIG_I2C3_RK30
1362 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1364 #ifdef CONFIG_I2C4_RK30
1365 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1367 #ifdef CONFIG_I2C_GPIO_RK30
1368 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1373 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
1374 static void rk30_pm_power_off(void)
1376 printk(KERN_ERR "rk30_pm_power_off start...\n");
1377 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1378 #if defined(CONFIG_MFD_WM831X)
1379 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
1380 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1385 static void __init machine_rk30_board_init(void)
1388 gpio_request(POWER_ON_PIN, "poweronpin");
1389 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1391 pm_power_off = rk30_pm_power_off;
1393 rk30_i2c_register_board_info();
1394 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1395 platform_add_devices(devices, ARRAY_SIZE(devices));
1396 board_usb_detect_init(RK30_PIN0_PA7);
1398 #ifdef CONFIG_WIFI_CONTROL_FUNC
1399 rk29sdk_wifi_bt_gpio_control_init();
1403 static void __init rk30_reserve(void)
1406 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1408 #ifdef CONFIG_FB_ROCKCHIP
1409 resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1410 resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1412 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1413 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1414 resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1415 resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1418 #ifdef CONFIG_VIDEO_RK29
1419 rk30_camera_request_reserve_mem();
1421 board_mem_reserved();
1425 * dvfs_cpu_logic_table: table for arm and logic dvfs
1426 * @frequency : arm frequency
1427 * @cpu_volt : arm voltage depend on frequency
1428 * @logic_volt : logic voltage arm requests depend on frequency
1429 * comments : min arm/logic voltage
1431 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1432 {.frequency = 252 * 1000, .cpu_volt = 1000 * 1000, .logic_volt = 1000 * 1000},//0.975V/1.000V
1433 {.frequency = 504 * 1000, .cpu_volt = 1000 * 1000, .logic_volt = 1000 * 1000},//0.975V/1.000V
1434 {.frequency = 816 * 1000, .cpu_volt = 1000 * 1000, .logic_volt = 1000 * 1000},//1.000V/1.025V
1435 {.frequency = 1008 * 1000, .cpu_volt = 1000 * 1000, .logic_volt = 1000 * 1000},//1.025V/1.050V
1436 {.frequency = 1200 * 1000, .cpu_volt = 1000 * 1000, .logic_volt = 1000 * 1000},//1.100V/1.050V
1438 {.frequency = 1272 * 1000, .cpu_volt = 1225 * 1000, .logic_volt = 1200 * 1000},//1.150V/1.100V
1439 {.frequency = 1416 * 1000, .cpu_volt = 1300 * 1000, .logic_volt = 1200 * 1000},//1.225V/1.100V
1440 {.frequency = 1512 * 1000, .cpu_volt = 1350 * 1000, .logic_volt = 1250 * 1000},//1.300V/1.150V
1441 {.frequency = 1608 * 1000, .cpu_volt = 1425 * 1000, .logic_volt = 1300 * 1000},//1.325V/1.175V
1443 {.frequency = CPUFREQ_TABLE_END},
1446 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1447 {.frequency = 266 * 1000, .index = 1000 * 1000},
1448 {.frequency = 400 * 1000, .index = 1000 * 1000},
1449 {.frequency = CPUFREQ_TABLE_END},
1452 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1453 {.frequency = 300 * 1000, .index = 1000 * 1000},
1454 {.frequency = 400 * 1000, .index = 1000 * 1000},
1455 {.frequency = CPUFREQ_TABLE_END},
1458 #define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
1459 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1460 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1462 void __init board_clock_init(void)
1464 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1465 dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1466 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1467 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1470 MACHINE_START(RK30, "RK30board")
1471 .boot_params = PLAT_PHYS_OFFSET + 0x800,
1472 .fixup = rk30_fixup,
1473 .reserve = &rk30_reserve,
1474 .map_io = rk30_map_io,
1475 .init_irq = rk30_init_irq,
1476 .timer = &rk30_timer,
1477 .init_machine = machine_rk30_board_init,