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>
50 #if defined(CONFIG_MFD_RK610)
51 #include <linux/mfd/rk610_core.h>
54 #if defined(CONFIG_HDMI_RK30)
55 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
58 #if defined(CONFIG_SPIM_RK29)
59 #include "../../../drivers/spi/rk29_spim.h"
61 #if defined(CONFIG_MU509)
62 #include <linux/mu509.h>
64 #if defined(CONFIG_MW100)
65 #include <linux/mw100.h>
67 #if defined(CONFIG_MT6229)
68 #include <linux/mt6229.h>
70 #if defined(CONFIG_SEW868)
71 #include <linux/sew868.h>
73 #if defined(CONFIG_ANDROID_TIMED_GPIO)
74 #include "../../../drivers/staging/android/timed_gpio.h"
77 #ifdef CONFIG_THREE_FB_BUFFER
78 #define RK30_FB0_MEM_SIZE 12*SZ_1M
80 #define RK30_FB0_MEM_SIZE 8*SZ_1M
83 #include "board-rk3066b-m701-camera.c"
84 #include "board-rk3066b-m701-key.c"
86 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
87 #define TOUCH_RESET_PIN RK30_PIN2_PC0
88 #define TOUCH_PWR_PIN RK30_PIN2_PB4
89 static int goodix_init_platform_hw(void)
93 rk30_mux_api_set(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME, GPIO2C_GPIO2C0);
94 rk30_mux_api_set(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME, GPIO2B_GPIO2B4);
95 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));
97 if (TOUCH_PWR_PIN != INVALID_GPIO) {
98 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
100 gpio_free(TOUCH_PWR_PIN);
101 printk("goodix power error\n");
104 gpio_direction_output(TOUCH_PWR_PIN, 0);
105 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
109 if (TOUCH_RESET_PIN != INVALID_GPIO) {
110 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
112 gpio_free(TOUCH_RESET_PIN);
113 printk("goodix gpio_request error\n");
116 gpio_direction_output(TOUCH_RESET_PIN, 1);
118 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
120 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
126 struct goodix_platform_data goodix_info = {
128 .irq_pin = RK30_PIN0_PD4,
129 .rest_pin = TOUCH_RESET_PIN,
130 .init_platform_hw = goodix_init_platform_hw,
134 #if defined (CONFIG_TOUCHSCREEN_FT5306_AV)
136 #define TOUCH_RESET_PIN RK30_PIN2_PC0
137 #define TOUCH_INT_PIN RK30_PIN0_PD4
138 #define TOUCH_PWR_PIN RK30_PIN2_PB4
140 static int ft5306_init_platform_hw(void)
143 rk30_mux_api_set(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME, GPIO2C_GPIO2C0);
144 rk30_mux_api_set(GPIO0D4_SPI1RXD_NAME, GPIO0D_GPIO0D4);
145 rk30_mux_api_set(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME, GPIO2B_GPIO2B4);
146 //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));
148 printk("ft5306_init_platform_hw \n");
149 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
150 gpio_free(TOUCH_RESET_PIN);
151 printk("ft5306_init_platform_hw gpio_request error\n");
155 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
156 gpio_free(TOUCH_INT_PIN);
157 printk("ift5306_init_platform_hw gpio_request error\n");
161 gpio_direction_output(TOUCH_RESET_PIN, 0);
162 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
164 gpio_direction_input(TOUCH_INT_PIN);
166 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
171 void ft5306_exit_platform_hw(void)
173 printk("ft5606_exit_platform_hw\n");
174 gpio_free(TOUCH_RESET_PIN);
175 gpio_free(TOUCH_INT_PIN);
178 int ft5306_platform_sleep(void)
180 printk("ft5606_platform_sleep\n");
181 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
185 int ft5306_platform_wakeup(void)
187 printk("ft5606_platform_wakeup\n");
188 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
193 struct ft5606_platform_data ft5306_info = {
195 .init_platform_hw= ft5306_init_platform_hw,
196 .exit_platform_hw= ft5306_exit_platform_hw,
197 .platform_sleep= ft5306_platform_sleep,
198 .platform_wakeup= ft5306_platform_wakeup,
203 static struct spi_board_info board_spi_devices[] = {
206 /***********************************************************
208 ************************************************************/
209 #ifdef CONFIG_BACKLIGHT_RK29_BL
211 #define PWM_MUX_NAME GPIO3D5_PWM2_JTAGTCK_OTGDRVVBUS_NAME
212 #define PWM_MUX_MODE GPIO3D_PWM2
213 #define PWM_MUX_MODE_GPIO GPIO3D_GPIO3D5
214 #define PWM_GPIO RK30_PIN3_PD5
215 #define PWM_EFFECT_VALUE 0
217 #define LCD_DISP_ON_PIN
219 #ifdef LCD_DISP_ON_PIN
220 #define BL_EN_PIN RK30_PIN0_PA2
221 #define BL_EN_VALUE GPIO_HIGH
223 static int rk29_backlight_io_init(void)
226 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
227 #ifdef LCD_DISP_ON_PIN
228 // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
230 ret = gpio_request(BL_EN_PIN, NULL);
232 gpio_free(BL_EN_PIN);
235 gpio_direction_output(BL_EN_PIN, 0);
236 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
241 static int rk29_backlight_io_deinit(void)
244 #ifdef LCD_DISP_ON_PIN
245 gpio_direction_output(BL_EN_PIN, 0);
246 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
247 gpio_free(BL_EN_PIN);
249 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
250 gpio_request(PWM_GPIO, NULL);
251 gpio_direction_output(PWM_GPIO, GPIO_LOW);
255 static int rk29_backlight_pwm_suspend(void)
258 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
259 if (gpio_request(PWM_GPIO, NULL)) {
260 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
263 gpio_direction_output(PWM_GPIO, GPIO_LOW);
264 #ifdef LCD_DISP_ON_PIN
265 gpio_direction_output(BL_EN_PIN, 0);
266 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
271 static int rk29_backlight_pwm_resume(void)
274 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
275 #ifdef LCD_DISP_ON_PIN
277 gpio_direction_output(BL_EN_PIN, 1);
278 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
283 static struct rk29_bl_info rk29_bl_info = {
285 .bl_ref = PWM_EFFECT_VALUE,
286 .io_init = rk29_backlight_io_init,
287 .io_deinit = rk29_backlight_io_deinit,
288 .min_brightness = 48,
290 .pwm_suspend = rk29_backlight_pwm_suspend,
291 .pwm_resume = rk29_backlight_pwm_resume,
294 static struct platform_device rk29_device_backlight = {
295 .name = "rk29_backlight",
298 .platform_data = &rk29_bl_info,
304 #ifdef CONFIG_RK29_SUPPORT_MODEM
306 #define RK30_MODEM_POWER RK30_PIN2_PB0
307 #define RK30_MODEM_POWER_IOMUX rk29_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0)
309 static int rk30_modem_io_init(void)
311 printk("%s\n", __FUNCTION__);
312 RK30_MODEM_POWER_IOMUX;
317 static struct rk29_io_t rk30_modem_io = {
318 .io_addr = RK30_MODEM_POWER,
321 .io_init = rk30_modem_io_init,
324 static struct platform_device rk30_device_modem = {
325 .name = "rk30_modem",
328 .platform_data = &rk30_modem_io,
332 #if defined(CONFIG_MU509)
333 static int mu509_io_init(void)
336 rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
337 rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
338 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
339 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
343 static int mu509_io_deinit(void)
349 struct rk29_mu509_data rk29_mu509_info = {
350 .io_init = mu509_io_init,
351 .io_deinit = mu509_io_deinit,
352 .modem_power_en = RK30_PIN2_PB0,
353 .bp_power = RK30_PIN2_PB0,
354 .bp_reset = RK30_PIN2_PD1,
355 .ap_wakeup_bp = RK30_PIN2_PB7,
356 .bp_wakeup_ap = RK30_PIN6_PA0,
358 struct platform_device rk29_device_mu509 = {
362 .platform_data = &rk29_mu509_info,
366 #if defined(CONFIG_MW100)
367 static int mw100_io_init(void)
369 rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
370 rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
371 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
372 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
376 static int mw100_io_deinit(void)
382 struct rk29_mw100_data rk29_mw100_info = {
383 .io_init = mw100_io_init,
384 .io_deinit = mw100_io_deinit,
385 .modem_power_en = RK30_PIN6_PB0,
386 .bp_power = RK30_PIN2_PB0,
387 .bp_reset = RK30_PIN2_PD1,
388 .ap_wakeup_bp = RK30_PIN2_PB7,
389 .bp_wakeup_ap = RK30_PIN6_PA0,
391 struct platform_device rk29_device_mw100 = {
395 .platform_data = &rk29_mw100_info,
399 #if defined(CONFIG_MT6229)
400 static int mt6229_io_init(void)
402 rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
403 rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
404 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
405 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
409 static int mt6229_io_deinit(void)
415 struct rk29_mt6229_data rk29_mt6229_info = {
416 .io_init = mt6229_io_init,
417 .io_deinit = mt6229_io_deinit,
418 .modem_power_en = RK30_PIN2_PB0,
419 .bp_power = RK30_PIN2_PB0,//RK30_PIN2_PB6,
420 .bp_reset = RK30_PIN2_PD1,
421 .ap_wakeup_bp = RK30_PIN2_PC0,
422 .bp_wakeup_ap = RK30_PIN6_PA0,
424 struct platform_device rk29_device_mt6229 = {
428 .platform_data = &rk29_mt6229_info,
432 #if defined(CONFIG_SEW868)
433 static int sew868_io_init(void)
435 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
436 rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
437 rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4);
440 static int sew868_io_deinit(void)
444 struct rk30_sew868_data rk30_sew868_info = {
445 .io_init = sew868_io_init,
446 .io_deinit = sew868_io_deinit,
447 .bp_power = RK30_PIN6_PB2,
448 .bp_power_active_low = 1,
449 .bp_sys = RK30_PIN2_PB6,
450 .bp_reset = RK30_PIN4_PD2,
451 .bp_reset_active_low = 1,
452 .bp_wakeup_ap = RK30_PIN4_PD4,
453 .ap_wakeup_bp = NULL,
456 struct platform_device rk30_device_sew868 = {
460 .platform_data = &rk30_sew868_info,
467 #if defined (CONFIG_GS_MMA7660)
468 #define MMA7660_INT_PIN RK30_PIN3_PD7
470 static int mma7660_init_platform_hw(void)
472 if(gpio_request(MMA7660_INT_PIN, NULL) != 0){
473 gpio_free(MMA7660_INT_PIN);
474 printk("gsensor gpio_request error\n");
477 //gpio_direction_input(MMA7660_INT_PIN);
481 static struct sensor_platform_data mma7660_info = {
482 .type = SENSOR_TYPE_ACCEL,
485 .init_platform_hw = mma7660_init_platform_hw,
486 .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
492 #if defined (CONFIG_GS_MMA8452)
493 #define MMA8452_INT_PIN RK30_PIN3_PD7
495 static int mma8452_init_platform_hw(void)
500 static struct sensor_platform_data mma8452_info = {
501 .type = SENSOR_TYPE_ACCEL,
504 .init_platform_hw = mma8452_init_platform_hw,
505 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
508 #if defined (CONFIG_GS_LIS3DH)
509 #define LIS3DH_INT_PIN RK30_PIN3_PD7
511 static int lis3dh_init_platform_hw(void)
517 static struct sensor_platform_data lis3dh_info = {
518 .type = SENSOR_TYPE_ACCEL,
521 .init_platform_hw = lis3dh_init_platform_hw,
522 .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
525 #if defined (CONFIG_COMPASS_AK8975)
526 static struct sensor_platform_data akm8975_info =
528 .type = SENSOR_TYPE_COMPASS,
561 #if defined(CONFIG_GYRO_L3G4200D)
563 #include <linux/l3g4200d.h>
564 #define L3G4200D_INT_PIN RK30_PIN0_PB4
566 static int l3g4200d_init_platform_hw(void)
571 static struct sensor_platform_data l3g4200d_info = {
572 .type = SENSOR_TYPE_GYROSCOPE,
575 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
576 .init_platform_hw = l3g4200d_init_platform_hw,
577 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
584 #ifdef CONFIG_LS_CM3217
585 static struct sensor_platform_data cm3217_info = {
586 .type = SENSOR_TYPE_LIGHT,
588 .poll_delay_ms = 500,
593 #ifdef CONFIG_FB_ROCKCHIP
595 #define LCD_CS_PIN RK30_PIN2_PB6
596 #define LCD_CS_VALUE GPIO_HIGH
598 #define LCD_EN_PIN RK30_PIN0_PB0
599 #define LCD_EN_VALUE GPIO_LOW
601 #define LCD_STB_PIN RK30_PIN2_PB3
602 #define LCD_STB_VALUE GPIO_HIGH
604 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
608 if(LCD_STB_PIN !=INVALID_GPIO)
610 ret = gpio_request(LCD_STB_PIN, NULL);
613 gpio_free(LCD_STB_PIN);
614 printk(KERN_ERR "request lcd en pin fail!\n");
619 gpio_direction_output(LCD_STB_PIN, LCD_STB_VALUE);
624 if(LCD_CS_PIN !=INVALID_GPIO)
626 ret = gpio_request(LCD_CS_PIN, NULL);
629 gpio_free(LCD_CS_PIN);
630 printk(KERN_ERR "request lcd cs pin fail!\n");
635 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
639 if(LCD_EN_PIN !=INVALID_GPIO)
641 ret = gpio_request(LCD_EN_PIN, NULL);
644 gpio_free(LCD_EN_PIN);
645 printk(KERN_ERR "request lcd en pin fail!\n");
650 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
657 static int rk_fb_io_disable(void)
659 if(LCD_STB_PIN !=INVALID_GPIO)
661 gpio_set_value(LCD_STB_PIN, !LCD_STB_VALUE);
664 if(LCD_CS_PIN !=INVALID_GPIO)
666 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
668 if(LCD_EN_PIN !=INVALID_GPIO)
670 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
675 static int rk_fb_io_enable(void)
677 if(LCD_STB_PIN !=INVALID_GPIO)
679 gpio_set_value(LCD_STB_PIN, LCD_STB_VALUE);
682 if(LCD_CS_PIN !=INVALID_GPIO)
684 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
686 if(LCD_EN_PIN !=INVALID_GPIO)
688 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
693 #if defined(CONFIG_LCDC0_RK3066B)
694 struct rk29fb_info lcdc0_screen_info = {
695 .prop = PRMRY, //primary display device
696 .io_init = rk_fb_io_init,
697 .io_disable = rk_fb_io_disable,
698 .io_enable = rk_fb_io_enable,
699 .set_screen_info = set_lcd_info,
703 #if defined(CONFIG_LCDC1_RK3066B)
704 struct rk29fb_info lcdc1_screen_info = {
705 #if defined(CONFIG_HDMI_RK30)
706 .prop = EXTEND, //extend display device
708 .set_screen_info = hdmi_init_lcdc,
713 static struct resource resource_fb[] = {
717 .end = 0,//RK30_FB0_MEM_SIZE - 1,
718 .flags = IORESOURCE_MEM,
721 .name = "ipp buf", //for rotate
723 .end = 0,//RK30_FB0_MEM_SIZE - 1,
724 .flags = IORESOURCE_MEM,
729 .end = 0,//RK30_FB0_MEM_SIZE - 1,
730 .flags = IORESOURCE_MEM,
734 static struct platform_device device_fb = {
737 .num_resources = ARRAY_SIZE(resource_fb),
738 .resource = resource_fb,
742 #if defined(CONFIG_LCDC0_RK3066B)
743 static struct resource resource_lcdc0[] = {
746 .start = RK30_LCDC0_PHYS,
747 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
748 .flags = IORESOURCE_MEM,
755 .flags = IORESOURCE_IRQ,
759 static struct platform_device device_lcdc0 = {
762 .num_resources = ARRAY_SIZE(resource_lcdc0),
763 .resource = resource_lcdc0,
765 .platform_data = &lcdc0_screen_info,
769 #if defined(CONFIG_LCDC1_RK3066B)
770 static struct resource resource_lcdc1[] = {
773 .start = RK30_LCDC1_PHYS,
774 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
775 .flags = IORESOURCE_MEM,
781 .flags = IORESOURCE_IRQ,
785 static struct platform_device device_lcdc1 = {
788 .num_resources = ARRAY_SIZE(resource_lcdc1),
789 .resource = resource_lcdc1,
791 .platform_data = &lcdc1_screen_info,
796 #if defined(CONFIG_MFD_RK610)
797 #define RK610_RST_PIN_MUX_NAME GPIO2C5_LCDC1DATA21_SMCADDR5_NAME
798 #define RK610_RST_PIN_MUX_MODE GPIO2C_GPIO2C5
799 #define RK610_RST_PIN RK30_PIN2_PC5
800 static int rk610_power_on_init(void)
803 if(RK610_RST_PIN != INVALID_GPIO)
805 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
806 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
809 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
813 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
815 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
817 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
826 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
827 .rk610_power_on_init = rk610_power_on_init,
831 #ifdef CONFIG_ANDROID_TIMED_GPIO
832 static struct timed_gpio timed_gpios[] = {
835 .gpio = RK30_PIN3_PD3,
838 .adjust_time =20, //adjust for diff product
842 static struct timed_gpio_platform_data rk29_vibrator_info = {
844 .gpios = timed_gpios,
847 static struct platform_device rk29_device_vibrator = {
848 .name = "timed-gpio",
851 .platform_data = &rk29_vibrator_info,
857 #ifdef CONFIG_LEDS_GPIO_PLATFORM
858 static struct gpio_led rk29_leds[] = {
860 .name = "button-backlight",
861 .gpio = RK30_PIN2_PB3,
862 .default_trigger = "timer",
864 .retain_state_suspended = 0,
865 .default_state = LEDS_GPIO_DEFSTATE_OFF,
869 static struct gpio_led_platform_data rk29_leds_pdata = {
871 .num_leds = ARRAY_SIZE(rk29_leds),
874 static struct platform_device rk29_device_gpio_leds = {
878 .platform_data = &rk29_leds_pdata,
883 #ifdef CONFIG_RK_IRDA
884 #define IRDA_IRQ_PIN RK30_PIN0_PA3
886 static int irda_iomux_init(void)
891 ret = gpio_request(IRDA_IRQ_PIN, NULL);
893 gpio_free(IRDA_IRQ_PIN);
894 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
896 gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
897 gpio_direction_input(IRDA_IRQ_PIN);
902 static int irda_iomux_deinit(void)
904 gpio_free(IRDA_IRQ_PIN);
908 static struct irda_info rk29_irda_info = {
909 .intr_pin = IRDA_IRQ_PIN,
910 .iomux_init = irda_iomux_init,
911 .iomux_deinit = irda_iomux_deinit,
912 //.irda_pwr_ctl = bu92747guw_power_ctl,
915 static struct platform_device irda_device = {
916 #ifdef CONFIG_RK_IRDA_NET
919 .name = "bu92747_irda",
923 .platform_data = &rk29_irda_info,
929 #define ION_RESERVE_SIZE (80 * SZ_1M)
930 static struct ion_platform_data rk30_ion_pdata = {
934 .type = ION_HEAP_TYPE_CARVEOUT,
935 .id = ION_NOR_HEAP_ID,
937 .size = ION_RESERVE_SIZE,
942 static struct platform_device device_ion = {
943 .name = "ion-rockchip",
946 .platform_data = &rk30_ion_pdata,
951 /**************************************************************************************************
952 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
953 **************************************************************************************************/
954 #ifdef CONFIG_SDMMC_RK29
955 #include "board-rk3066b-sdk-sdmmc.c"
957 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
958 #define SDMMC0_WRITE_PROTECT_PIN RK30_PIN3_PB7 //According to your own project to set the value of write-protect-pin.
961 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
962 #define SDMMC1_WRITE_PROTECT_PIN RK30_PIN3_PC7 //According to your own project to set the value of write-protect-pin.
965 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK30_PIN6_PB2
967 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
969 #ifdef CONFIG_SDMMC0_RK29
970 static int rk29_sdmmc0_cfg_gpio(void)
972 #ifdef CONFIG_SDMMC_RK29_OLD
973 rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
974 rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
975 rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
976 rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
977 rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
978 rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
980 rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
982 rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
983 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
984 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
987 rk29_sdmmc_set_iomux(0, 0xFFFF);
989 rk30_mux_api_set(GPIO3B0_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0DETECTN);
991 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
992 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
993 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1001 #define CONFIG_SDMMC0_USE_DMA
1002 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1004 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1005 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1006 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1008 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1009 .io_init = rk29_sdmmc0_cfg_gpio,
1011 #if !defined(CONFIG_SDMMC_RK29_OLD)
1012 .set_iomux = rk29_sdmmc_set_iomux,
1015 .dma_name = "sd_mmc",
1016 #ifdef CONFIG_SDMMC0_USE_DMA
1021 .detect_irq = RK30_PIN3_PB6, // INVALID_GPIO
1022 .enable_sd_wakeup = 0,
1024 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1025 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1027 .write_prt = INVALID_GPIO,
1030 #endif // CONFIG_SDMMC0_RK29
1032 #ifdef CONFIG_SDMMC1_RK29
1033 #define CONFIG_SDMMC1_USE_DMA
1034 static int rk29_sdmmc1_cfg_gpio(void)
1036 #if defined(CONFIG_SDMMC_RK29_OLD)
1037 rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1038 rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1039 rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1040 rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1041 rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1042 rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1043 //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
1047 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1048 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1049 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1057 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1059 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1060 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1063 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1064 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1065 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1068 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1071 .io_init = rk29_sdmmc1_cfg_gpio,
1073 #if !defined(CONFIG_SDMMC_RK29_OLD)
1074 .set_iomux = rk29_sdmmc_set_iomux,
1078 #ifdef CONFIG_SDMMC1_USE_DMA
1084 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1085 #ifdef CONFIG_WIFI_CONTROL_FUNC
1086 .status = rk29sdk_wifi_status,
1087 .register_status_notify = rk29sdk_wifi_status_register,
1090 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1093 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1094 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1096 .write_prt = INVALID_GPIO,
1100 .detect_irq = INVALID_GPIO,
1101 .enable_sd_wakeup = 0,
1105 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1107 /**************************************************************************************************
1108 * the end of setting for SDMMC devices
1109 **************************************************************************************************/
1111 #ifdef CONFIG_BATTERY_RK30_ADC
1112 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1113 .dc_det_pin = RK30_PIN0_PB2,
1114 .batt_low_pin = RK30_PIN0_PB1,
1115 .charge_set_pin = RK30_PIN2_PA7,
1116 .charge_ok_pin = RK30_PIN0_PA6,
1117 .dc_det_level = GPIO_LOW,
1118 .charge_ok_level = GPIO_HIGH,
1119 .charge_set_level = GPIO_HIGH,
1122 static struct platform_device rk30_device_adc_battery = {
1123 .name = "rk30-battery",
1126 .platform_data = &rk30_adc_battery_platdata,
1130 #ifdef CONFIG_RK30_PWM_REGULATOR
1131 const static int pwm_voltage_map[] = {
1132 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1135 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1137 .supply = "vdd_core",
1141 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1145 .name = "PWM_DCDC1",
1147 .max_uV = 1800000, //0.6-1.8V
1149 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1151 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1152 .consumer_supplies = pwm_dcdc1_consumers,
1156 static struct pwm_platform_data pwm_regulator_info[1] = {
1159 .pwm_gpio = RK30_PIN3_PD6,
1160 .pwm_iomux_name = GPIO3D6_PWM3_JTAGTMS_HOSTDRVVBUS_NAME,
1161 .pwm_iomux_pwm = GPIO3D_PWM3,
1162 .pwm_iomux_gpio = GPIO3D_GPIO3D6,
1163 .pwm_voltage = 1000000,
1164 .suspend_voltage = 1050000,
1167 .coefficient = 455, //45.5%
1168 .pwm_voltage_map = pwm_voltage_map,
1169 .init_data = &pwm_regulator_init_dcdc[0],
1173 struct platform_device pwm_regulator_device[1] = {
1175 .name = "pwm-voltage-regulator",
1178 .platform_data = &pwm_regulator_info[0],
1184 #ifdef CONFIG_RK29_VMAC
1185 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1186 #include "board-rk30-sdk-vmac.c"
1189 #ifdef CONFIG_RFKILL_RK
1190 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1191 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1192 .type = RFKILL_TYPE_BLUETOOTH,
1194 .poweron_gpio = { // BT_REG_ON
1195 .io = RK30_PIN3_PC7,
1196 .enable = GPIO_HIGH,
1198 .name = GPIO3C7_SDMMC1WRITEPRT_RMIICRS_NAME,
1199 .fgpio = GPIO3C_GPIO3C7,
1203 .reset_gpio = { // BT_RST
1204 .io = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1207 .name = GPIO3D1_SDMMC1BACKENDPWR_MIIMDCLK_NAME,
1208 .fgpio = GPIO3D_GPIO3D1,
1212 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1213 .io = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1214 .enable = GPIO_HIGH,
1216 .name = GPIO3C6_SDMMC1DETECTN_RMIIRXERR_NAME,
1217 .fgpio = GPIO3C_GPIO3C6,
1221 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1223 .io = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1224 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1231 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1232 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1235 .name = GPIO1A3_UART0RTSN_NAME,
1236 .fgpio = GPIO1A_GPIO1A3,
1237 .fmux = GPIO1A_UART0RTSN,
1242 static struct platform_device device_rfkill_rk = {
1243 .name = "rfkill_rk",
1246 .platform_data = &rfkill_rk_platdata,
1251 static struct platform_device *devices[] __initdata = {
1252 #ifdef CONFIG_FB_ROCKCHIP
1255 #if defined(CONFIG_LCDC0_RK3066B)
1258 #if defined(CONFIG_LCDC1_RK3066B)
1262 #ifdef CONFIG_BACKLIGHT_RK29_BL
1263 &rk29_device_backlight,
1269 #ifdef CONFIG_ANDROID_TIMED_GPIO
1270 &rk29_device_vibrator,
1272 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1273 &rk29_device_gpio_leds,
1275 #ifdef CONFIG_RK_IRDA
1278 #ifdef CONFIG_WIFI_CONTROL_FUNC
1279 &rk29sdk_wifi_device,
1281 #ifdef CONFIG_RK29_SUPPORT_MODEM
1284 #if defined(CONFIG_MU509)
1287 #if defined(CONFIG_MW100)
1290 #if defined(CONFIG_MT6229)
1291 &rk29_device_mt6229,
1293 #if defined(CONFIG_SEW868)
1294 &rk30_device_sew868,
1296 #ifdef CONFIG_BATTERY_RK30_ADC
1297 &rk30_device_adc_battery,
1299 #ifdef CONFIG_RFKILL_RK
1305 #ifdef CONFIG_I2C0_RK30
1306 static struct i2c_board_info __initdata i2c0_info[] = {
1307 #if defined (CONFIG_GS_MMA7660)
1309 .type = "gs_mma7660",
1312 .irq = MMA7660_INT_PIN,
1313 .platform_data = &mma7660_info,
1316 #if defined (CONFIG_GS_MMA8452)
1318 .type = "gs_mma8452",
1321 .irq = MMA8452_INT_PIN,
1322 .platform_data = &mma8452_info,
1325 #if defined (CONFIG_GS_LIS3DH)
1327 .type = "gs_lis3dh",
1328 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1330 .irq = LIS3DH_INT_PIN,
1331 .platform_data = &lis3dh_info,
1334 #if defined (CONFIG_COMPASS_AK8975)
1339 .irq = RK30_PIN0_PD5,
1340 .platform_data = &akm8975_info,
1343 #if defined (CONFIG_GYRO_L3G4200D)
1345 .type = "l3g4200d_gryo",
1348 .irq = L3G4200D_INT_PIN,
1349 .platform_data = &l3g4200d_info,
1352 #if defined (CONFIG_SND_SOC_RK1000)
1354 .type = "rk1000_i2c_codec",
1359 .type = "rk1000_control",
1364 #if defined (CONFIG_SND_SOC_RT5631)
1371 #if defined (CONFIG_SND_SOC_ES8323)
1378 #ifdef CONFIG_MFD_RK610
1380 .type = "rk610_ctl",
1383 .platform_data = &rk610_ctl_pdata,
1385 #ifdef CONFIG_RK610_TVOUT
1387 .type = "rk610_tvout",
1392 #ifdef CONFIG_HDMI_RK610
1394 .type = "rk610_hdmi",
1397 .irq = RK30_PIN0_PB6,
1400 #ifdef CONFIG_SND_SOC_RK610
1401 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1402 .type = "rk610_i2c_codec",
1412 #define PMIC_TYPE_WM8326 1
1413 #define PMIC_TYPE_TPS65910 2
1414 int __sramdata g_pmic_type = 0;
1415 #ifdef CONFIG_I2C1_RK30
1416 #ifdef CONFIG_MFD_WM831X_I2C
1417 #include "board-rk3066b-sdk-wm8326.c"
1419 #ifdef CONFIG_MFD_TPS65910
1420 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1421 #include "board-rk3066b-sdk-tps65910.c"
1424 static struct i2c_board_info __initdata i2c1_info[] = {
1425 #if defined (CONFIG_MFD_WM831X_I2C)
1430 .irq = RK30_PIN0_PB3,
1431 .platform_data = &wm831x_platdata,
1434 #if defined (CONFIG_MFD_TPS65910)
1437 .addr = TPS65910_I2C_ID0,
1439 .irq = TPS65910_HOST_IRQ,
1440 .platform_data = &tps65910_data,
1446 void __sramfunc board_pmu_suspend(void)
1448 #if defined (CONFIG_MFD_WM831X_I2C)
1449 if(g_pmic_type == PMIC_TYPE_WM8326)
1450 board_pmu_wm8326_suspend();
1452 #if defined (CONFIG_MFD_TPS65910)
1453 if(g_pmic_type == PMIC_TYPE_TPS65910)
1454 board_pmu_tps65910_suspend();
1458 void __sramfunc board_pmu_resume(void)
1460 #if defined (CONFIG_MFD_WM831X_I2C)
1461 if(g_pmic_type == PMIC_TYPE_WM8326)
1462 board_pmu_wm8326_resume();
1464 #if defined (CONFIG_MFD_TPS65910)
1465 if(g_pmic_type == PMIC_TYPE_TPS65910)
1466 board_pmu_tps65910_resume();
1470 int __sramdata gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1472 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1474 #ifdef CONFIG_RK30_PWM_REGULATOR
1476 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1478 gpio0d7_iomux = readl_relaxed(GRF_GPIO0D_IOMUX);
1479 gpio0d7_do = grf_readl(GRF_GPIO0H_DO);
1480 gpio0d7_dir = grf_readl(GRF_GPIO0H_DIR);
1481 gpio0d7_en = grf_readl(GRF_GPIO0H_EN);
1483 writel_relaxed((1<<30), GRF_GPIO0D_IOMUX);
1484 grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DIR);
1485 grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DO);
1486 grf_writel((1<<31)|(1<<15), GRF_GPIO0H_EN);
1489 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1491 #ifdef CONFIG_RK30_PWM_REGULATOR
1492 writel_relaxed((1<<30)|gpio0d7_iomux, GRF_GPIO0D_IOMUX);
1493 grf_writel((1<<31)|gpio0d7_en, GRF_GPIO0H_EN);
1494 grf_writel((1<<31)|gpio0d7_dir, GRF_GPIO0H_DIR);
1495 grf_writel((1<<31)|gpio0d7_do, GRF_GPIO0H_DO);
1501 extern void pwm_suspend_voltage(void);
1502 extern void pwm_resume_voltage(void);
1503 void rk30_pwm_suspend_voltage_set(void)
1505 #ifdef CONFIG_RK30_PWM_REGULATOR
1506 pwm_suspend_voltage();
1509 void rk30_pwm_resume_voltage_set(void)
1511 #ifdef CONFIG_RK30_PWM_REGULATOR
1512 pwm_resume_voltage();
1517 #ifdef CONFIG_I2C2_RK30
1518 static struct i2c_board_info __initdata i2c2_info[] = {
1519 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1521 .type = "Goodix-TS",
1524 .irq = RK30_PIN0_PD4,
1525 .platform_data = &goodix_info,
1528 #if defined (CONFIG_TOUCHSCREEN_FT5306_AV)
1530 .type = "ft5x0x_ts",
1533 .irq = RK30_PIN0_PD4,
1534 .platform_data = &ft5306_info,
1537 #if defined (CONFIG_LS_CM3217)
1539 .type = "lightsensor",
1542 .platform_data = &cm3217_info,
1548 #ifdef CONFIG_I2C3_RK30
1549 static struct i2c_board_info __initdata i2c3_info[] = {
1553 #ifdef CONFIG_I2C4_RK30
1554 static struct i2c_board_info __initdata i2c4_info[] = {
1558 #ifdef CONFIG_I2C_GPIO_RK30
1559 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1560 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1561 static int rk30_i2c_io_init(void)
1563 //set iomux (gpio) here
1564 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1565 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1569 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1570 .sda_pin = I2C_SDA_PIN,
1571 .scl_pin = I2C_SCL_PIN,
1572 .udelay = 5, // clk = 500/udelay = 100Khz
1573 .timeout = 100,//msecs_to_jiffies(100),
1575 .io_init = rk30_i2c_io_init,
1577 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1581 static void __init rk30_i2c_register_board_info(void)
1583 #ifdef CONFIG_I2C0_RK30
1584 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1586 #ifdef CONFIG_I2C1_RK30
1587 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1589 #ifdef CONFIG_I2C2_RK30
1590 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1592 #ifdef CONFIG_I2C3_RK30
1593 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1595 #ifdef CONFIG_I2C4_RK30
1596 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1598 #ifdef CONFIG_I2C_GPIO_RK30
1599 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1604 #define POWEROFF_CHARGING_ANIMATION (1)
1605 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
1606 static void rk30_pm_power_off(void)
1608 #if POWEROFF_CHARGING_ANIMATION
1610 struct rk30_adc_battery_platform_data *batt_plat_data = &rk30_adc_battery_platdata;
1611 if (gpio_get_value (batt_plat_data->dc_det_pin) ==
1612 batt_plat_data->dc_det_level) {
1613 printk("AC Charging, try to restart...\n");
1615 if (gpio_get_value (batt_plat_data->dc_det_pin) !=
1616 batt_plat_data->dc_det_level ) {
1625 printk("AC Charging, will restart system...\n");
1626 arm_pm_restart(0, NULL);
1631 printk("rk30_pm_power_off start...\n");
1632 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1633 #if defined(CONFIG_MFD_WM831X)
1634 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
1635 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1640 static void __init machine_rk30_board_init(void)
1643 gpio_request(POWER_ON_PIN, "poweronpin");
1644 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1646 pm_power_off = rk30_pm_power_off;
1648 rk30_i2c_register_board_info();
1649 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1650 platform_add_devices(devices, ARRAY_SIZE(devices));
1651 board_usb_detect_init(RK30_PIN0_PA7);
1653 #ifdef CONFIG_WIFI_CONTROL_FUNC
1654 rk29sdk_wifi_bt_gpio_control_init();
1657 // spk and ear switch
1658 gpio_request(RK30_PIN2_PB1, NULL);
1659 gpio_direction_output(RK30_PIN2_PB1, GPIO_HIGH);
1662 static void __init rk30_reserve(void)
1665 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1667 #ifdef CONFIG_FB_ROCKCHIP
1668 resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1669 resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1671 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1672 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1673 resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1674 resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1677 #ifdef CONFIG_VIDEO_RK29
1678 rk30_camera_request_reserve_mem();
1680 board_mem_reserved();
1684 * dvfs_cpu_logic_table: table for arm and logic dvfs
1685 * @frequency : arm frequency
1686 * @cpu_volt : arm voltage depend on frequency
1687 * @logic_volt : logic voltage arm requests depend on frequency
1688 * comments : min arm/logic voltage
1690 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1692 {.frequency = 252 * 1000, .cpu_volt = 1075 * 1000, .logic_volt = 1125 * 1000},
1694 {.frequency = 504 * 1000, .cpu_volt = 1100 * 1000, .logic_volt = 1100 * 1000},
1695 {.frequency = 816 * 1000, .cpu_volt = 1100 * 1000, .logic_volt = 1100 * 1000},
1696 {.frequency = 1200 * 1000, .cpu_volt = 1100 * 1000, .logic_volt = 1100 * 1000},
1698 {.frequency = 1008 * 1000, .cpu_volt = 1125 * 1000, .logic_volt = 1150 * 1000},
1699 {.frequency = 1272 * 1000, .cpu_volt = 1225 * 1000, .logic_volt = 1200 * 1000},
1700 {.frequency = 1416 * 1000, .cpu_volt = 1300 * 1000, .logic_volt = 1200 * 1000},
1701 {.frequency = 1512 * 1000, .cpu_volt = 1350 * 1000, .logic_volt = 1250 * 1000},
1702 {.frequency = 1608 * 1000, .cpu_volt = 1425 * 1000, .logic_volt = 1300 * 1000},
1704 {.frequency = CPUFREQ_TABLE_END},
1707 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1708 {.frequency = 266 * 1000, .index = 1000 * 1000},
1709 {.frequency = 400 * 1000, .index = 1000 * 1000},
1710 {.frequency = 600 * 1000, .index = 1200 * 1000},
1711 {.frequency = CPUFREQ_TABLE_END},
1714 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1715 {.frequency = 300 * 1000, .index = 1000 * 1000},
1716 {.frequency = 400 * 1000, .index = 1000 * 1000},
1717 {.frequency = CPUFREQ_TABLE_END},
1720 #define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
1721 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1722 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1724 void __init board_clock_init(void)
1726 rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1727 dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1728 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1729 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1732 MACHINE_START(RK30, "RK30board")
1733 .boot_params = PLAT_PHYS_OFFSET + 0x800,
1734 .fixup = rk30_fixup,
1735 .reserve = &rk30_reserve,
1736 .map_io = rk30_map_io,
1737 .init_irq = rk30_init_irq,
1738 .timer = &rk30_timer,
1739 .init_machine = machine_rk30_board_init,