rk30:add touch gpio iomux operation
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / board-rk30-sdk.c
index c87edce5d5755a89f651d228a29e7324cca420e1..36731d2bb068f0b49ce4a5fe7d23bb65d90bf693 100755 (executable)
@@ -37,6 +37,7 @@
 #include <mach/io.h>
 #include <mach/gpio.h>
 #include <mach/iomux.h>
+
 /*set touchscreen different type header*/
 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
 #if defined(CONFIG_SPIM_RK29)
 #include "../../../drivers/spi/rk29_spim.h"
 #endif
+#if defined(CONFIG_ANDROID_TIMED_GPIO)
+#include "../../../drivers/staging/android/timed_gpio.h"
+#endif
 
 #define RK30_FB0_MEM_SIZE 8*SZ_1M
 
+#ifdef CONFIG_VIDEO_RK29
+/*---------------- Camera Sensor Macro Define Begin  ------------------------*/
+/*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
+#define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642                                         /* back camera sensor */
+#define CONFIG_SENSOR_IIC_ADDR_0               0x78
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_0   1
+#define CONFIG_SENSOR_CIF_INDEX_0                    0
+#define CONFIG_SENSOR_ORIENTATION_0      90
+#define CONFIG_SENSOR_POWER_PIN_0                INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_0                INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_0      INVALID_GPIO
+#define CONFIG_SENSOR_FALSH_PIN_0                INVALID_GPIO
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
+
+#define CONFIG_SENSOR_QCIF_FPS_FIXED_0         15000
+#define CONFIG_SENSOR_QVGA_FPS_FIXED_0         15000
+#define CONFIG_SENSOR_CIF_FPS_FIXED_0          15000
+#define CONFIG_SENSOR_VGA_FPS_FIXED_0          15000
+#define CONFIG_SENSOR_480P_FPS_FIXED_0         15000
+#define CONFIG_SENSOR_SVGA_FPS_FIXED_0         15000
+#define CONFIG_SENSOR_720P_FPS_FIXED_0         30000
+
+#define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659                                         /* front camera sensor */
+#define CONFIG_SENSOR_IIC_ADDR_1               0x60
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_1   1
+#define CONFIG_SENSOR_CIF_INDEX_1                                1
+#define CONFIG_SENSOR_ORIENTATION_1      270
+#define CONFIG_SENSOR_POWER_PIN_1                INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_1                INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_1      INVALID_GPIO
+#define CONFIG_SENSOR_FALSH_PIN_1                INVALID_GPIO
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
+
+#define CONFIG_SENSOR_QCIF_FPS_FIXED_1         15000
+#define CONFIG_SENSOR_QVGA_FPS_FIXED_1         15000
+#define CONFIG_SENSOR_CIF_FPS_FIXED_1          15000
+#define CONFIG_SENSOR_VGA_FPS_FIXED_1          15000
+#define CONFIG_SENSOR_480P_FPS_FIXED_1         15000
+#define CONFIG_SENSOR_SVGA_FPS_FIXED_1         15000
+#define CONFIG_SENSOR_720P_FPS_FIXED_1         30000
+
+#define CONFIG_USE_CIF_0       1
+#define CONFIG_USE_CIF_1      1
+#endif //#ifdef CONFIG_VIDEO_RK29
+/*---------------- Camera Sensor Configuration Macro End------------------------*/
+#include "../../../drivers/media/video/rk30_camera.c"
+/*---------------- Camera Sensor Macro Define End  ---------*/
+
+//RK30,use  ion to allocate mem , set it as 0
+#define PMEM_CAM_SIZE          0//PMEM_CAM_NECESSARY
+#ifdef CONFIG_VIDEO_RK29_WORK_IPP
+#define MEM_CAMIPP_SIZE_CIF_0  PMEM_CAMIPP_NECESSARY_CIF_0
+#define MEM_CAMIPP_SIZE_CIF_1  PMEM_CAMIPP_NECESSARY_CIF_0
+#else
+#define MEM_CAMIPP_SIZE_CIF_0  0
+#define MEM_CAMIPP_SIZE_CIF_1  0
+
+#endif
+/*****************************************************************************************
+ * camera  devices
+ * author: ddl@rock-chips.com
+ *****************************************************************************************/
+#ifdef CONFIG_VIDEO_RK29
+#define CONFIG_SENSOR_POWER_IOCTL_USR     0
+#define CONFIG_SENSOR_RESET_IOCTL_USR     0
+#define CONFIG_SENSOR_POWERDOWN_IOCTL_USR         0
+#define CONFIG_SENSOR_FLASH_IOCTL_USR     0
+
+#if CONFIG_SENSOR_POWER_IOCTL_USR
+static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+       #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
+}
+#endif
+
+#if CONFIG_SENSOR_RESET_IOCTL_USR
+static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+       #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
+}
+#endif
+
+#if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
+static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+       #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
+}
+#endif
+
+#if CONFIG_SENSOR_FLASH_IOCTL_USR
+static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+       #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
+}
+#endif
+
+static struct rk29camera_platform_ioctl_cb     sensor_ioctl_cb = {
+       #if CONFIG_SENSOR_POWER_IOCTL_USR
+       .sensor_power_cb = sensor_power_usr_cb,
+       #else
+       .sensor_power_cb = NULL,
+       #endif
+
+       #if CONFIG_SENSOR_RESET_IOCTL_USR
+       .sensor_reset_cb = sensor_reset_usr_cb,
+       #else
+       .sensor_reset_cb = NULL,
+       #endif
+
+       #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
+       .sensor_powerdown_cb = sensor_powerdown_usr_cb,
+       #else
+       .sensor_powerdown_cb = NULL,
+       #endif
+
+       #if CONFIG_SENSOR_FLASH_IOCTL_USR
+       .sensor_flash_cb = sensor_flash_usr_cb,
+       #else
+       .sensor_flash_cb = NULL,
+       #endif
+};
+static struct reginfo_t rk_init_data_sensor_reg_0[] =
+{
+               {0x0000, 0x00,0,0}
+       };
+static struct reginfo_t rk_init_data_sensor_winseqreg_0[] ={
+       {0x0000, 0x00,0,0}
+       };
+static rk_sensor_user_init_data_s rk_init_data_sensor_0 = 
+{      
+       .rk_sensor_init_width = INVALID_VALUE,
+       .rk_sensor_init_height = INVALID_VALUE,
+       .rk_sensor_init_bus_param = INVALID_VALUE,
+       .rk_sensor_init_pixelcode = INVALID_VALUE,
+       .rk_sensor_init_data = rk_init_data_sensor_reg_0,
+       .rk_sensor_init_winseq = NULL,//rk_init_data_sensor_winseqreg_0,
+       .rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_0) / sizeof(struct reginfo_t),
+       
+};
+static rk_sensor_user_init_data_s* rk_init_data_sensor_0_p = NULL;
+static rk_sensor_user_init_data_s* rk_init_data_sensor_1_p = NULL;
+#include "../../../drivers/media/video/rk30_camera.c"
+
+#endif /* CONFIG_VIDEO_RK29 */
+
+#if defined(CONFIG_TOUCHSCREEN_GT8XX)
+#define TOUCH_RESET_PIN  RK30_PIN4_PD0
+#define TOUCH_PWR_PIN    INVALID_GPIO
+int goodix_init_platform_hw(void)
+{
+       int ret;
+       
+       rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
+       rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
+       printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
+
+       if (TOUCH_PWR_PIN != INVALID_GPIO) {
+               ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
+               if (ret != 0) {
+                       gpio_free(TOUCH_PWR_PIN);
+                       printk("goodix power error\n");
+                       return -EIO;
+               }
+               gpio_direction_output(TOUCH_PWR_PIN, 0);
+               gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
+               msleep(100);
+       }
+
+       if (TOUCH_RESET_PIN != INVALID_GPIO) {
+               ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
+               if (ret != 0) {
+                       gpio_free(TOUCH_RESET_PIN);
+                       printk("goodix gpio_request error\n");
+                       return -EIO;
+               }
+               gpio_direction_output(TOUCH_RESET_PIN, 0);
+               gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
+               msleep(10);
+               gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
+               msleep(500);
+       }
+       return 0;
+}
+
+struct goodix_platform_data goodix_info = {
+       .model = 8105,
+       .irq_pin = RK30_PIN4_PC2,
+       .rest_pin = TOUCH_RESET_PIN,
+       .init_platform_hw = goodix_init_platform_hw,
+};
+#endif
 
 /*****************************************************************************************
  * xpt2046 touch panel
  * author: hhb@rock-chips.com
  *****************************************************************************************/
 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
-#define XPT2046_GPIO_INT       RK30_PIN4_PC2 
+#define XPT2046_GPIO_INT       RK30_PIN4_PC2
 #define DEBOUNCE_REPTIME       3
 
-
 static struct xpt2046_platform_data xpt2046_info = {
-       .model                  = 2046,
-       .keep_vref_on           = 1,
-       .swap_xy                = 0,
-       .debounce_max           = 7,
-       .debounce_rep           = DEBOUNCE_REPTIME,
-       .debounce_tol           = 20,
-       .gpio_pendown           = XPT2046_GPIO_INT,
-       .pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME, 
-       .pendown_iomux_mode = GPIO4C_GPIO4C2,   
+       .model = 2046,
+       .keep_vref_on = 1,
+       .swap_xy = 0,
+       .debounce_max = 7,
+       .debounce_rep = DEBOUNCE_REPTIME,
+       .debounce_tol = 20,
+       .gpio_pendown = XPT2046_GPIO_INT,
+       .pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME,
+       .pendown_iomux_mode = GPIO4C_GPIO4C2,
        .touch_virtualkey_length = 60,
        .penirq_recheck_delay_usecs = 1,
 #if defined(CONFIG_TOUCHSCREEN_480X800)
-       .x_min                  = 0,
-       .x_max                  = 480,
-       .y_min                  = 0,
-       .y_max                  = 800,
+       .x_min = 0,
+       .x_max = 480,
+       .y_min = 0,
+       .y_max = 800,
        .touch_ad_top = 3940,
        .touch_ad_bottom = 310,
        .touch_ad_left = 3772,
        .touch_ad_right = 340,
 #elif defined(CONFIG_TOUCHSCREEN_800X480)
-       .x_min                  = 0,
-       .x_max                  = 800,
-       .y_min                  = 0,
-       .y_max                  = 480,
+       .x_min = 0,
+       .x_max = 800,
+       .y_min = 0,
+       .y_max = 480,
        .touch_ad_top = 2447,
        .touch_ad_bottom = 207,
        .touch_ad_left = 5938,
        .touch_ad_right = 153,
 #elif defined(CONFIG_TOUCHSCREEN_320X480)
-       .x_min                  = 0,
-       .x_max                  = 320,
-       .y_min                  = 0,
-       .y_max                  = 480,
+       .x_min = 0,
+       .x_max = 320,
+       .y_min = 0,
+       .y_max = 480,
        .touch_ad_top = 3166,
        .touch_ad_bottom = 256,
        .touch_ad_left = 3658,
        .touch_ad_right = 380,
-#endif 
+#endif
 };
 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
 static struct xpt2046_platform_data xpt2046_info = {
-       .model                  = 2046,
-       .keep_vref_on   = 1,
-       .swap_xy                = 0,
-       .debounce_max           = 7,
-       .debounce_rep           = DEBOUNCE_REPTIME,
-       .debounce_tol           = 20,
-       .gpio_pendown           = XPT2046_GPIO_INT,
-       .pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME, 
-       .pendown_iomux_mode = GPIO4C_GPIO4C2,   
+       .model = 2046,
+       .keep_vref_on = 1,
+       .swap_xy = 0,
+       .debounce_max = 7,
+       .debounce_rep = DEBOUNCE_REPTIME,
+       .debounce_tol = 20,
+       .gpio_pendown = XPT2046_GPIO_INT,
+       .pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME,
+       .pendown_iomux_mode = GPIO4C_GPIO4C2,
        .touch_virtualkey_length = 60,
        .penirq_recheck_delay_usecs = 1,
-       
+
 #if defined(CONFIG_TOUCHSCREEN_480X800)
-       .x_min                  = 0,
-       .x_max                  = 480,
-       .y_min                  = 0,
-       .y_max                  = 800,
-       .screen_x = { 70,  410, 70, 410, 240},
-       .screen_y = { 50, 50,  740, 740, 400},
-       .uncali_x_default = {  3267,  831, 3139, 715, 1845 },
-       .uncali_y_default = { 3638,  3664, 564,  591, 2087 },
+       .x_min = 0,
+       .x_max = 480,
+       .y_min = 0,
+       .y_max = 800,
+       .screen_x = {70, 410, 70, 410, 240},
+       .screen_y = {50, 50, 740, 740, 400},
+       .uncali_x_default = {3267, 831, 3139, 715, 1845},
+       .uncali_y_default = {3638, 3664, 564, 591, 2087},
 #elif defined(CONFIG_TOUCHSCREEN_800X480)
-       .x_min                  = 0,
-       .x_max                  = 800,
-       .y_min                  = 0,
-       .y_max                  = 480,
-       .screen_x[5] = { 50, 750,  50, 750, 400};
-       .screen_y[5] = { 40,  40, 440, 440, 240};
-       .uncali_x_default[5] = { 438,  565, 3507,  3631, 2105 };
-       .uncali_y_default[5] = {  3756,  489, 3792, 534, 2159 };
+       .x_min = 0,
+       .x_max = 800,
+       .y_min = 0,
+       .y_max = 480,
+       .screen_x[5] = {50, 750, 50, 750, 400};
+       .screen_y[5] = {40, 40, 440, 440, 240};
+       .uncali_x_default[5] = {438, 565, 3507, 3631, 2105};
+       .uncali_y_default[5] = {3756, 489, 3792, 534, 2159};
 #elif defined(CONFIG_TOUCHSCREEN_320X480)
-       .x_min                  = 0,
-       .x_max                  = 320,
-       .y_min                  = 0,
-       .y_max                  = 480,
-       .screen_x[5] = { 50, 270,  50, 270, 160}; 
-       .screen_y[5] = { 40,  40, 440, 440, 240}; 
-       .uncali_x_default[5] = { 812,  3341, 851,  3371, 2183 };
-       .uncali_y_default[5] = {  442,  435, 3193, 3195, 2004 };
-#endif 
+       .x_min = 0,
+       .x_max = 320,
+       .y_min = 0,
+       .y_max = 480,
+       .screen_x[5] = {50, 270, 50, 270, 160};
+       .screen_y[5] = {40, 40, 440, 440, 240};
+       .uncali_x_default[5] = {812, 3341, 851, 3371, 2183};
+       .uncali_y_default[5] = {442, 435, 3193, 3195, 2004};
+#endif
 };
 #endif
 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
@@ -160,14 +360,13 @@ static struct spi_board_info board_spi_devices[] = {
                .max_speed_hz   = 1 * 1000 * 800,/* (max sample rate @ 3V) * (cmd + data + overhead) */
                .bus_num        = 0,
                .irq            = XPT2046_GPIO_INT,
-               .platform_data = &xpt2046_info,
+               .platform_data  = &xpt2046_info,
                .controller_data = &xpt2046_chip,
        },
 #endif
 
 };
 
-
 /***********************************************************
 *      rk30  backlight
 ************************************************************/
@@ -185,7 +384,7 @@ static struct spi_board_info board_spi_devices[] = {
 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
 
-#define BL_EN_PIN         INVALID_GPIO //?
+#define BL_EN_PIN         RK30_PIN6_PB3
 #define BL_EN_VALUE       GPIO_HIGH
 #endif
 static int rk29_backlight_io_init(void)
@@ -196,15 +395,14 @@ static int rk29_backlight_io_init(void)
        // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
 
        ret = gpio_request(BL_EN_PIN, NULL);
-       if(ret != 0)
-       {
+       if (ret != 0) {
                gpio_free(BL_EN_PIN);
        }
 
        gpio_direction_output(BL_EN_PIN, 0);
        gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
 #endif
-    return ret;
+       return ret;
 }
 
 static int rk29_backlight_io_deinit(void)
@@ -213,8 +411,8 @@ static int rk29_backlight_io_deinit(void)
 #ifdef  LCD_DISP_ON_PIN
        gpio_free(BL_EN_PIN);
 #endif
-       rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);   
-    return ret;
+       rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
+       return ret;
 }
 
 static int rk29_backlight_pwm_suspend(void)
@@ -246,21 +444,20 @@ static int rk29_backlight_pwm_resume(void)
 }
 
 static struct rk29_bl_info rk29_bl_info = {
-    .pwm_id   = PWM_ID,
-    .bl_ref   = PWM_EFFECT_VALUE,
-    .io_init   = rk29_backlight_io_init,
-    .io_deinit = rk29_backlight_io_deinit,
-    .pwm_suspend = rk29_backlight_pwm_suspend,
-    .pwm_resume = rk29_backlight_pwm_resume,
+       .pwm_id = PWM_ID,
+       .bl_ref = PWM_EFFECT_VALUE,
+       .io_init = rk29_backlight_io_init,
+       .io_deinit = rk29_backlight_io_deinit,
+       .pwm_suspend = rk29_backlight_pwm_suspend,
+       .pwm_resume = rk29_backlight_pwm_resume,
 };
 
-
 static struct platform_device rk29_device_backlight = {
        .name   = "rk29_backlight",
        .id     = -1,
-        .dev    = {
-           .platform_data  = &rk29_bl_info,
-        }
+       .dev    = {
+               .platform_data  = &rk29_bl_info,
+       }
 };
 
 #endif
@@ -273,7 +470,7 @@ static int mma8452_init_platform_hw(void)
 {
        rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
 
-       if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
+       if (gpio_request(MMA8452_INT_PIN, NULL) != 0) {
                gpio_free(MMA8452_INT_PIN);
                printk("mma8452_init_platform_hw gpio_request error\n");
                return -EIO;
@@ -282,13 +479,12 @@ static int mma8452_init_platform_hw(void)
        return 0;
 }
 
-
 static struct mma8452_platform_data mma8452_info = {
-       .model= 8452,
+       .model = 8452,
        .swap_xy = 0,
        .swap_xyz = 1,
-       .init_platform_hw= mma8452_init_platform_hw,
-       .orientation = { -1, 0, 0, 0, 0, 1, 0, -1, 0},
+       .init_platform_hw = mma8452_init_platform_hw,
+       .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
 };
 #endif
 #if defined (CONFIG_COMPASS_AK8975)
@@ -297,30 +493,29 @@ static struct akm8975_platform_data akm8975_info =
        .m_layout = 
        {
                {
-                       {1, 0, 0 },
-                       {0, -1, 0 },
-                       {0,     0, -1 },
+                       {1, 0, 0},
+                       {0, -1, 0},
+                       {0, 0, -1},
                },
 
                {
-                       {1, 0, 0 },
-                       {0, 1, 0 },
-                       {0,     0, 1 },
+                       {1, 0, 0},
+                       {0, 1, 0},
+                       {0, 0, 1},
                },
 
                {
-                       {1, 0, 0 },
-                       {0, 1, 0 },
-                       {0,     0, 1 },
+                       {1, 0, 0},
+                       {0, 1, 0},
+                       {0, 0, 1},
                },
 
                {
-                       {1, 0, 0 },
-                       {0, 1, 0 },
-                       {0,     0, 1 },
+                       {1, 0, 0},
+                       {0, 1, 0},
+                       {0, 0, 1},
                },
        }
-
 };
 
 #endif
@@ -357,8 +552,75 @@ static struct l3g4200d_platform_data l3g4200d_info = {
 
 #endif
 
+#ifdef CONFIG_LS_CM3217
+
+#define CM3217_POWER_PIN       INVALID_GPIO
+#define CM3217_IRQ_PIN         INVALID_GPIO
+static int cm3217_init_hw(void)
+{
+#if 0
+       if (gpio_request(CM3217_POWER_PIN, NULL) != 0) {
+               gpio_free(CM3217_POWER_PIN);
+               printk("%s: request cm3217 power pin error\n", __func__);
+               return -EIO;
+       }
+       gpio_pull_updown(CM3217_POWER_PIN, PullDisable);
+
+       if (gpio_request(CM3217_IRQ_PIN, NULL) != 0) {
+               gpio_free(CM3217_IRQ_PIN);
+               printk("%s: request cm3217 int pin error\n", __func__);
+               return -EIO;
+       }
+       gpio_pull_updown(CM3217_IRQ_PIN, PullDisable);
+#endif
+       return 0;
+}
+
+static void cm3217_exit_hw(void)
+{
+#if 0
+       gpio_free(CM3217_POWER_PIN);
+       gpio_free(CM3217_IRQ_PIN);
+#endif
+       return;
+}
+
+struct cm3217_platform_data cm3217_info = {
+       .irq_pin = CM3217_IRQ_PIN,
+       .power_pin = CM3217_POWER_PIN,
+       .init_platform_hw = cm3217_init_hw,
+       .exit_platform_hw = cm3217_exit_hw,
+};
+#endif
 
 #ifdef CONFIG_FB_ROCKCHIP
+
+#define LCD_EN_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
+#define LCD_EN_PIN         RK30_PIN4_PC7
+#define LCD_EN_VALUE       GPIO_HIGH
+
+static int rk_fb_io_init(void)
+{
+       int ret = 0;
+       rk30_mux_api_set(LCD_EN_MUX_NAME, GPIO4C_GPIO4C7);
+       ret = gpio_request(LCD_EN_PIN, NULL);
+       if (ret != 0)
+       {
+               gpio_free(LCD_EN_PIN);
+               printk(KERN_ERR "request lcd en pin fail!\n");
+               return -1;
+       }
+       else
+       {
+               gpio_direction_output(LCD_EN_PIN, 1);
+               gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
+       }
+       return 0;
+}
+static struct rk29lcd_info rk_fb_info = {
+       .io_init   = rk_fb_io_init,
+};
+
 static struct resource resource_fb[] = {
        [0] = {
                .name  = "fb0 buf",
@@ -381,75 +643,238 @@ static struct resource resource_fb[] = {
 };
 
 static struct platform_device device_fb = {
-       .name             = "rk-fb",
-       .id               = -1,
-       .num_resources    = ARRAY_SIZE(resource_fb),
-       .resource         = resource_fb,
+       .name           = "rk-fb",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(resource_fb),
+       .resource       = resource_fb,
+       .dev            = {
+               .platform_data  = &rk_fb_info,
+       }
+};
+#endif
+
+#ifdef CONFIG_ANDROID_TIMED_GPIO
+static struct timed_gpio timed_gpios[] = {
+       {
+               .name = "vibrator",
+               .gpio = RK30_PIN0_PA4,
+               .max_timeout = 1000,
+               .active_low = 0,
+               .adjust_time =20,      //adjust for diff product
+       },
+};
+
+struct timed_gpio_platform_data rk29_vibrator_info = {
+       .num_gpios = 1,
+       .gpios = timed_gpios,
+};
+
+struct platform_device rk29_device_vibrator = {
+       .name = "timed-gpio",
+       .id = -1,
+       .dev = {
+               .platform_data = &rk29_vibrator_info,
+       },
+
+};
+#endif
+
+#ifdef CONFIG_LEDS_GPIO_PLATFORM
+struct gpio_led rk29_leds[] = {
+       {
+               .name = "button-backlight",
+               .gpio = RK30_PIN4_PD7,
+               .default_trigger = "timer",
+               .active_low = 0,
+               .retain_state_suspended = 0,
+               .default_state = LEDS_GPIO_DEFSTATE_OFF,
+       },
+};
+
+struct gpio_led_platform_data rk29_leds_pdata = {
+       .leds = &rk29_leds,
+       .num_leds = ARRAY_SIZE(rk29_leds),
+};
+
+struct platform_device rk29_device_gpio_leds = {
+       .name   = "leds-gpio",
+       .id     = -1,
+       .dev    = {
+               .platform_data  = &rk29_leds_pdata,
+       },
+};
+#endif
+
+#ifdef CONFIG_RK_IRDA
+#define IRDA_IRQ_PIN           RK30_PIN6_PA1
+
+int irda_iomux_init(void)
+{
+       int ret = 0;
+
+       //irda irq pin
+       ret = gpio_request(IRDA_IRQ_PIN, NULL);
+       if (ret != 0) {
+               gpio_free(IRDA_IRQ_PIN);
+               printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
+       }
+       gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
+       gpio_direction_input(IRDA_IRQ_PIN);
+
+       return 0;
+}
+
+int irda_iomux_deinit(void)
+{
+       gpio_free(IRDA_IRQ_PIN);
+       return 0;
+}
+
+static struct irda_info rk29_irda_info = {
+       .intr_pin = IRDA_IRQ_PIN,
+       .iomux_init = irda_iomux_init,
+       .iomux_deinit = irda_iomux_deinit,
+       //.irda_pwr_ctl = bu92747guw_power_ctl,
+};
+
+static struct platform_device irda_device = {
+#ifdef CONFIG_RK_IRDA_NET
+       .name = "rk_irda",
+#else
+       .name = "bu92747_irda",
+#endif
+       .id = -1,
+       .dev = {
+               .platform_data = &rk29_irda_info,
+       }
+};
+#endif
+
+#ifdef CONFIG_ION
+#define ION_RESERVE_SIZE        (80 * SZ_1M)
+static struct ion_platform_data rk30_ion_pdata = {
+       .nr = 1,
+       .heaps = {
+               {
+                       .type = ION_HEAP_TYPE_CARVEOUT,
+                       .id = ION_NOR_HEAP_ID,
+                       .name = "norheap",
+                       .size = ION_RESERVE_SIZE,
+               }
+       },
+};
+
+static struct platform_device device_ion = {
+       .name = "ion-rockchip",
+       .id = 0,
+       .dev = {
+               .platform_data = &rk30_ion_pdata,
+       },
 };
 #endif
 
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_BACKLIGHT_RK29_BL
        &rk29_device_backlight,
-#endif 
+#endif
 #ifdef CONFIG_FB_ROCKCHIP
        &device_fb,
 #endif
+#ifdef CONFIG_ION
+       &device_ion,
+#endif
+#ifdef CONFIG_ANDROID_TIMED_GPIO
+       &rk29_device_vibrator,
+#endif
+#ifdef CONFIG_LEDS_GPIO_PLATFORM
+       &rk29_device_gpio_leds,
+#endif
+#ifdef CONFIG_RK_IRDA
+       &irda_device,
+#endif
 };
 
 // i2c
 #ifdef CONFIG_I2C0_RK30
 static struct i2c_board_info __initdata i2c0_info[] = {
 #if defined (CONFIG_GS_MMA8452)
-           {
-             .type           = "gs_mma8452",
-             .addr           = 0x1c,
-             .flags          = 0,
-             .irq            = MMA8452_INT_PIN,
-             .platform_data  = &mma8452_info,
-           },
+       {
+               .type           = "gs_mma8452",
+               .addr           = 0x1c,
+               .flags          = 0,
+               .irq            = MMA8452_INT_PIN,
+               .platform_data = &mma8452_info,
+       },
 #endif
 #if defined (CONFIG_COMPASS_AK8975)
        {
-               .type           = "ak8975",
-               .addr           = 0x0d,
-               .flags          = 0,
-               .irq            = RK30_PIN4_PC1,
-               .platform_data  = &akm8975_info,
+               .type          = "ak8975",
+               .addr          = 0x0d,
+               .flags         = 0,
+               .irq           = RK30_PIN4_PC1,
+               .platform_data = &akm8975_info,
        },
 #endif
 #if defined (CONFIG_GYRO_L3G4200D)
        {
-               .type           = "l3g4200d_gryo",
-               .addr           = 0x69,
-               .flags          = 0,
-               .irq            = L3G4200D_INT_PIN,
-               .platform_data  = &l3g4200d_info,
+               .type          = "l3g4200d_gryo",
+               .addr          = 0x69,
+               .flags         = 0,
+               .irq           = L3G4200D_INT_PIN,
+               .platform_data = &l3g4200d_info,
        },
 #endif
-
 #if defined (CONFIG_SND_SOC_RK1000)
        {
-               .type                   = "rk1000_i2c_codec",
-               .addr           = 0x60,
-               .flags                  = 0,
+               .type          = "rk1000_i2c_codec",
+               .addr          = 0x60,
+               .flags         = 0,
        },
        {
-               .type                   = "rk1000_control",
-               .addr                   = 0x40,
-               .flags                  = 0,
-       },      
+               .type          = "rk1000_control",
+               .addr          = 0x40,
+               .flags         = 0,
+       },
 #endif
 };
 #endif
 
 #ifdef CONFIG_I2C1_RK30
+#include "board-rk30-sdk-wm8326.c"
+
 static struct i2c_board_info __initdata i2c1_info[] = {
+#if defined (CONFIG_MFD_WM831X_I2C)
+       {
+               .type          = "wm8326",
+               .addr          = 0x36,    //0x34    ,is Decided by cs
+               .flags         = 0,
+               .irq           = RK30_PIN6_PA4,
+               .platform_data = &wm831x_platdata,
+       },
+#endif
 };
 #endif
 
 #ifdef CONFIG_I2C2_RK30
 static struct i2c_board_info __initdata i2c2_info[] = {
+#if defined (CONFIG_TOUCHSCREEN_GT8XX)
+       {
+               .type          = "Goodix-TS",
+               .addr          = 0x55,
+               .flags         = 0,
+               .irq           = RK30_PIN4_PC2,
+               .platform_data = &goodix_info,
+       },
+#endif
+#if defined (CONFIG_LS_CM3217)
+       {
+               .type          = "lightsensor",
+               .addr          = 0x20,
+               .flags         = 0,
+               .irq           = CM3217_IRQ_PIN,
+               .platform_data = &cm3217_info,
+       },
+#endif
 };
 #endif
 
@@ -483,26 +908,197 @@ static void __init rk30_i2c_register_board_info(void)
 }
 //end of i2c
 
+/**************************************************************************************************
+ * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
+**************************************************************************************************/
+#ifdef CONFIG_SDMMC_RK29
+#include "board-rk30-sdk-sdmmc.c"
+
+#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
+#define SDMMC0_WRITE_PROTECT_PIN       RK30_PIN3_PB7   //According to your own project to set the value of write-protect-pin.
+#endif
+
+#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
+#define SDMMC1_WRITE_PROTECT_PIN       RK30_PIN3_PC7   //According to your own project to set the value of write-protect-pin.
+#endif
+
+#define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
+
+#endif //endif ---#ifdef CONFIG_SDMMC_RK29
+
+#ifdef CONFIG_SDMMC0_RK29
+static int rk29_sdmmc0_cfg_gpio(void)
+{
+#ifdef CONFIG_SDMMC_RK29_OLD
+       rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
+       rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
+       rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
+       rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
+       rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
+       rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
+
+       rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
+
+       rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
+       gpio_request(RK30_PIN3_PA7, "sdmmc-power");
+       gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
+
+#else
+       rk29_sdmmc_set_iomux(0, 0xFFFF);
+
+       rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
+
+#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
+       gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
+       gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
+#endif
+
+#endif
+
+       return 0;
+}
+
+#define CONFIG_SDMMC0_USE_DMA
+struct rk29_sdmmc_platform_data default_sdmmc0_data = {
+       .host_ocr_avail =
+           (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
+            MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
+            MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
+       .host_caps =
+           (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
+       .io_init = rk29_sdmmc0_cfg_gpio,
+
+#if !defined(CONFIG_SDMMC_RK29_OLD)
+       .set_iomux = rk29_sdmmc_set_iomux,
+#endif
+
+       .dma_name = "sd_mmc",
+#ifdef CONFIG_SDMMC0_USE_DMA
+       .use_dma = 1,
+#else
+       .use_dma = 0,
+#endif
+       .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
+       .enable_sd_wakeup = 0,
+
+#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
+       .write_prt = SDMMC0_WRITE_PROTECT_PIN,
+#else
+       .write_prt = INVALID_GPIO,
+#endif
+};
+#endif // CONFIG_SDMMC0_RK29
+
+#ifdef CONFIG_SDMMC1_RK29
+#define CONFIG_SDMMC1_USE_DMA
+static int rk29_sdmmc1_cfg_gpio(void)
+{
+#if defined(CONFIG_SDMMC_RK29_OLD)
+       rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
+       rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
+       rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
+       rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
+       rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
+       rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
+       //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
+
+#else
+
+#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
+       gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
+       gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
+#endif
+
+#endif
+
+       return 0;
+}
+
+struct rk29_sdmmc_platform_data default_sdmmc1_data = {
+       .host_ocr_avail =
+           (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
+            MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
+            MMC_VDD_33_34),
+
+#if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
+       .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
+                     MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
+#else
+       .host_caps =
+           (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
+#endif
+
+       .io_init = rk29_sdmmc1_cfg_gpio,
+
+#if !defined(CONFIG_SDMMC_RK29_OLD)
+       .set_iomux = rk29_sdmmc_set_iomux,
+#endif
+
+       .dma_name = "sdio",
+#ifdef CONFIG_SDMMC1_USE_DMA
+       .use_dma = 1,
+#else
+       .use_dma = 0,
+#endif
+
+#if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+       .status = rk29sdk_wifi_status,
+       .register_status_notify = rk29sdk_wifi_status_register,
+#endif
+#if 0
+       .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
+#endif
+
+#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
+       .write_prt = SDMMC1_WRITE_PROTECT_PIN,
+#else
+       .write_prt = INVALID_GPIO,
+#endif
+
+#else
+       .detect_irq = INVALID_GPIO,
+       .enable_sd_wakeup = 0,
+#endif
+
+};
+#endif //endif--#ifdef CONFIG_SDMMC1_RK29
+/**************************************************************************************************
+ * the end of setting for SDMMC devices
+**************************************************************************************************/
+
 static void __init machine_rk30_board_init(void)
 {
        rk30_i2c_register_board_info();
        spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
        platform_add_devices(devices, ARRAY_SIZE(devices));
+       board_usb_detect_init(RK30_PIN6_PA3);
 }
 
 static void __init rk30_reserve(void)
 {
+#ifdef CONFIG_ION
+       rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
+#endif
 #ifdef CONFIG_FB_ROCKCHIP
-       resource_fb[0].start = board_mem_reserve_add("fb0",RK30_FB0_MEM_SIZE);
+       resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
        resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
-       resource_fb[1].start = board_mem_reserve_add("ipp buf",RK30_FB0_MEM_SIZE);
+       resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
        resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
-       resource_fb[2].start = board_mem_reserve_add("fb2",RK30_FB0_MEM_SIZE);
-       resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;      
+       resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
+       resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
+#endif
+#ifdef CONFIG_VIDEO_RK29
+       rk30_camera_request_reserve_mem();
 #endif
        board_mem_reserved();
 }
 
+void __init board_clock_init(void)
+{
+       rk30_clock_data_init(periph_pll_297mhz, codec_pll_360mhz, max_i2s_12288khz);
+}
+
 MACHINE_START(RK30, "RK30board")
        .boot_params    = PLAT_PHYS_OFFSET + 0x800,
        .fixup          = rk30_fixup,