board config: fix i2c1 and i2c3 transfer is not IRQ
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk29 / board-rk29-phonesdk.c
index 78f3d67b9c0541d54e52b8568f183656e2ea3cac..0af0074b720d96f1b16f9c5cb66e5d4824691fbd 100755 (executable)
@@ -1,4 +1,4 @@
-/* arch/arm/mach-rk29/board-rk29.c
+/* arch/arm/mach-rk29/board-rk29-phonesdk.c
  *
  * Copyright (C) 2010 ROCKCHIP, Inc.
  *
 #include <linux/mfd/wm831x/pdata.h>
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/gpio.h>
+#include <linux/mfd/wm8994/pdata.h>
+#include <linux/mfd/wm8994/registers.h>
 
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 
 #include "devices.h"
+
+#if defined(CONFIG_MTK23D)
+#include <linux/mtk23d.h>
+#endif
+
+#include "../../../drivers/headset_observe/rk_headset.h"
+/*set touchscreen different type header*/
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
+#include "../../../drivers/input/touchscreen/xpt2046_ts.h"
+#elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
+#include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
+#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
-#include "../../../drivers/misc/gps/rk29_gps.h"
+#endif
 
+#include "../../../drivers/misc/gps/rk29_gps.h"
+#include "../../../drivers/serial/sc8800.h"
 
 /* Set memory size of pmem */
 #ifdef CONFIG_RK29_MEM_SIZE_M
 #define MEM_CAMIPP_SIZE     0
 #endif
 #define MEM_FB_SIZE         (3*SZ_2M)
-
+#ifdef CONFIG_FB_WORK_IPP
+#define MEM_FBIPP_SIZE      SZ_8M   //1920 x 1080 x 2 x 2  //RGB565 = x2;RGB888 = x4
+#else
+#define MEM_FBIPP_SIZE      0
+#endif
 #define PMEM_GPU_BASE       ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
 #define PMEM_UI_BASE        (PMEM_GPU_BASE - PMEM_UI_SIZE)
 #define PMEM_VPU_BASE       (PMEM_UI_BASE - PMEM_VPU_SIZE)
 #define PMEM_CAM_BASE       (PMEM_VPU_BASE - PMEM_CAM_SIZE)
 #define MEM_CAMIPP_BASE     (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
 #define MEM_FB_BASE         (MEM_CAMIPP_BASE - MEM_FB_SIZE)
-#define LINUX_SIZE          (MEM_FB_BASE - RK29_SDRAM_PHYS)
+#define MEM_FBIPP_BASE      (MEM_FB_BASE - MEM_FBIPP_SIZE)
+#define LINUX_SIZE          (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
 
 #define PREALLOC_WLAN_SEC_NUM           4
 #define PREALLOC_WLAN_BUF_NUM           160
@@ -121,17 +142,18 @@ struct rk29_nand_platform_data rk29_nand_data = {
  * author: zyw@rock-chips.com
  *****************************************************************************************/
 //#ifdef  CONFIG_LCD_TD043MGEA1
-#define LCD_TXD_PIN          INVALID_GPIO
-#define LCD_CLK_PIN          INVALID_GPIO
-#define LCD_CS_PIN           INVALID_GPIO
+#define LCD_RXD_PIN          RK29_PIN2_PC7
+#define LCD_TXD_PIN          RK29_PIN2_PC6
+#define LCD_CLK_PIN          RK29_PIN2_PC4
+#define LCD_CS_PIN           RK29_PIN2_PC5
 /*****************************************************************************************
-* frame buffe  devices
+* frame buffer  devices
 * author: zyw@rock-chips.com
 *****************************************************************************************/
 #define FB_ID                       0
-#define FB_DISPLAY_ON_PIN           RK29_PIN6_PD0
-#define FB_LCD_STANDBY_PIN          RK29_PIN6_PD1
-#define FB_LCD_CABC_EN_PIN          RK29_PIN6_PD2
+#define FB_DISPLAY_ON_PIN           INVALID_GPIO//RK29_PIN6_PD0
+#define FB_LCD_STANDBY_PIN          INVALID_GPIO//RK29_PIN6_PD1
+#define FB_LCD_CABC_EN_PIN          INVALID_GPIO//RK29_PIN6_PD2
 #define FB_MCU_FMK_PIN              INVALID_GPIO
 
 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
@@ -141,12 +163,30 @@ struct rk29_nand_platform_data rk29_nand_data = {
 static int rk29_lcd_io_init(void)
 {
     int ret = 0;
+    //printk("rk29_lcd_io_init\n");
+    //ret = gpio_request(LCD_RXD_PIN, NULL);
+    ret = gpio_request(LCD_TXD_PIN, NULL);
+       ret = gpio_request(LCD_CLK_PIN, NULL);
+       ret = gpio_request(LCD_CS_PIN, NULL);
+       //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
+       rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
+       rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
+       rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
     return ret;
 }
 
 static int rk29_lcd_io_deinit(void)
 {
     int ret = 0;
+    //printk("rk29_lcd_io_deinit\n");
+    gpio_free(LCD_CS_PIN);
+       gpio_free(LCD_CLK_PIN);
+       gpio_free(LCD_TXD_PIN);
+       //gpio_free(LCD_RXD_PIN);
+       //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
+       rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
+       rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
+       rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_SPI1_CLK);
     return ret;
 }
 
@@ -235,9 +275,17 @@ static struct resource rk29_fb_resource[] = {
        [2] = {
            .name   = "win1 buf",
         .start  = MEM_FB_BASE,
-        .end    = MEM_FB_BASE + MEM_FB_SIZE,
+        .end    = MEM_FB_BASE + MEM_FB_SIZE - 1,
         .flags  = IORESOURCE_MEM,
     },
+    #ifdef CONFIG_FB_WORK_IPP
+    [3] = {
+           .name   = "win1 ipp buf",
+        .start  = MEM_FBIPP_BASE,
+        .end    = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
+        .flags  = IORESOURCE_MEM,
+    },
+    #endif
 };
 
 /*platform_device*/
@@ -312,7 +360,7 @@ static struct platform_device rk29_v4l2_output_devce = {
        .name           = "rk29_vout",
 };
 
-/*HANNSTAR_P1003 touch*/
+/* HANNSTAR_P1003 touch I2C */
 #if defined (CONFIG_HANNSTAR_P1003)
 #define TOUCH_RESET_PIN RK29_PIN6_PC3
 #define TOUCH_INT_PIN   RK29_PIN4_PD5
@@ -347,6 +395,29 @@ struct p1003_platform_data p1003_info = {
 
 };
 #endif
+
+#if defined(CONFIG_TOUCHSCREEN_GT801_IIC) 
+#include "../../../drivers/input/touchscreen/gt801_ts.h"
+#define GT801_GPIO_INT      RK29_PIN4_PD5
+#define GT801_GPIO_RESET    RK29_PIN6_PC3
+static struct gt801_platform_data gt801_info = {
+       .model                  = 801,
+       .swap_xy                = 0,
+       .x_min                  = 0,
+       .x_max                  = 480,
+       .y_min                  = 0,
+       .y_max                  = 800,
+       .gpio_reset     = GT801_GPIO_RESET,
+       .gpio_reset_active_low = 0,
+       .gpio_pendown           = GT801_GPIO_INT,
+    .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+    .resetpin_iomux_name = NULL,
+    .pendown_iomux_mode = GPIO4H_GPIO4D5,
+    .resetpin_iomux_mode = 0,
+};
+#endif
+
+/* EETI_EGALAX touch I2C */
 #if defined (CONFIG_EETI_EGALAX)
 #define TOUCH_RESET_PIN RK29_PIN6_PC3
 #define TOUCH_INT_PIN   RK29_PIN4_PD5
@@ -381,6 +452,7 @@ static struct eeti_egalax_platform_data eeti_egalax_info = {
 
 };
 #endif
+
 /*MMA8452 gsensor*/
 #if defined (CONFIG_GS_MMA8452)
 #define MMA8452_INT_PIN   RK29_PIN6_PC4
@@ -407,7 +479,7 @@ static struct mma8452_platform_data mma8452_info = {
 #endif
 
 #if defined(CONFIG_GPIO_WM831X)
-struct rk2818_gpio_expander_info  wm831x_gpio_settinginfo[] = {
+struct rk29_gpio_expander_info  wm831x_gpio_settinginfo[] = {
        {
                .gpio_num               =WM831X_P01,// tp3
                .pin_type           = GPIO_OUT,
@@ -476,12 +548,12 @@ struct rk2818_gpio_expander_info  wm831x_gpio_settinginfo[] = {
 
 
 #if defined(CONFIG_MFD_WM831X)
-
+static struct wm831x *gWm831x;
 int wm831x_pre_init(struct wm831x *parm)
 {
        int ret;
        printk("%s\n", __FUNCTION__);
-
+       gWm831x = parm;
        //ILIM = 900ma
        ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
        wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);        
@@ -497,92 +569,101 @@ int wm831x_post_init(struct wm831x *parm)
        struct regulator *dcdc;
        struct regulator *ldo;
        
-       //dcdc init
-       dcdc = regulator_get(NULL, "dcdc1");
-       regulator_set_voltage(dcdc,1800000,1800000);
-       regulator_enable(dcdc);
-       printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));   
+       dcdc = regulator_get(NULL, "dcdc3");            // 1th IO
+       regulator_set_voltage(dcdc,3000000,3000000);
+       regulator_enable(dcdc);                 
+       printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
        regulator_put(dcdc);
-
-       dcdc = regulator_get(NULL, "dcdc2");
+       udelay(100);
+       
+       ldo = regulator_get(NULL, "ldo10");     // 1th modem IO
+       regulator_set_voltage(ldo,3000000,3000000);
+       regulator_enable(ldo);                  
+       printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+       udelay(100);
+       
+       dcdc = regulator_get(NULL, "dcdc2");    // 2th CORE
        regulator_set_voltage(dcdc,1300000,1300000);
        regulator_enable(dcdc);                         
        printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
        regulator_put(dcdc);
-
-       dcdc = regulator_get(NULL, "dcdc3");
-       regulator_set_voltage(dcdc,3000000,3000000);
-       regulator_enable(dcdc);                 
-       printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
-       regulator_put(dcdc);
-
-       dcdc = regulator_get(NULL, "dcdc4");
-       regulator_set_voltage(dcdc,20000000,20000000);          
-       regulator_enable(dcdc); 
-       printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
+       udelay(100);
+       
+       dcdc = regulator_get(NULL, "dcdc1");    // 3th ddr
+       regulator_set_voltage(dcdc,1800000,1800000);
+       regulator_enable(dcdc);
+       printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));   
        regulator_put(dcdc);
+       udelay(100);
        
-       //ldo init
-       ldo = regulator_get(NULL, "ldo1");
+       ldo = regulator_get(NULL, "ldo1");              // 3th nand
        regulator_set_voltage(ldo,1800000,1800000);
        regulator_enable(ldo);                  
        printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));             
        regulator_put(ldo);
-
-       ldo = regulator_get(NULL, "ldo2");
-       regulator_set_voltage(ldo,1800000,1800000);
+       udelay(100);
+       
+       ldo = regulator_get(NULL, "ldo4");              // 4th usb
+       regulator_set_voltage(ldo,2500000,2500000);
+       regulator_enable(ldo);  
+       printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+       udelay(100);
+       
+       ldo = regulator_get(NULL, "ldo7");              // 5th usb
+       regulator_set_voltage(ldo,3300000,3300000);
+       regulator_enable(ldo);                  
+       printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+       udelay(100);
+       
+       dcdc = regulator_get(NULL, "dcdc4");    // backlight
+       regulator_set_voltage(dcdc,20000000,20000000);          
+       regulator_enable(dcdc); 
+       printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
+       regulator_put(dcdc);
+       udelay(100);
+#if 1
+       
+       ldo = regulator_get(NULL, "ldo2");              //lcd
+       regulator_set_voltage(ldo,3000000,3000000);
        regulator_enable(ldo);                  
        printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
        regulator_put(ldo);
 
-       ldo = regulator_get(NULL, "ldo3");
+       ldo = regulator_get(NULL, "ldo3");              //sram
        regulator_set_voltage(ldo,1800000,1800000);
        regulator_enable(ldo);                  
        printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-
-       ldo = regulator_get(NULL, "ldo4");
-       regulator_set_voltage(ldo,2800000,2800000);
-       //regulator_enable(ldo);        
-       //printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
+       regulator_put(ldo);     
 
-       ldo = regulator_get(NULL, "ldo5");
-       regulator_set_voltage(ldo,2800000,2800000);
+       ldo = regulator_get(NULL, "ldo5");              //tf
+       regulator_set_voltage(ldo,3000000,3000000);
        regulator_enable(ldo);                  
        printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
        regulator_put(ldo);
 
-       ldo = regulator_get(NULL, "ldo6");
-       regulator_set_voltage(ldo,3000000,3000000);
+       ldo = regulator_get(NULL, "ldo6");              //camera
+       regulator_set_voltage(ldo,1800000,1800000);
        regulator_enable(ldo);                  
        printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
        regulator_put(ldo);
 
-       ldo = regulator_get(NULL, "ldo7");
-       regulator_set_voltage(ldo,3300000,3300000);
-       regulator_enable(ldo);                  
-       printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-
-       ldo = regulator_get(NULL, "ldo8");
+       ldo = regulator_get(NULL, "ldo8");              //cmmb
        regulator_set_voltage(ldo,1200000,1200000);
-       //regulator_enable(ldo);                        
-       //printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-
-       ldo = regulator_get(NULL, "ldo9");
-       regulator_set_voltage(ldo,3000000,3000000);
        regulator_enable(ldo);                  
-       printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
        regulator_put(ldo);
 
-       ldo = regulator_get(NULL, "ldo10");
+       ldo = regulator_get(NULL, "ldo9");              //cmmb
        regulator_set_voltage(ldo,3000000,3000000);
        regulator_enable(ldo);                  
-       printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
        regulator_put(ldo);
-
+       
+#endif
+       
        ldo = regulator_get(NULL, "ldo11");
        //regulator_enable(ldo);                        
        printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));    
@@ -616,7 +697,7 @@ int wm831x_last_deinit(struct wm831x *parm)
 
 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
        .isink = 1,     /** ISINK to use, 1 or 2 */
-       .max_uA = 5000,    /** Maximum current to allow */
+       .max_uA = 19484,    /** Maximum current to allow */
 };
 
 struct wm831x_backup_pdata wm831x_backup_platdata = {
@@ -661,6 +742,9 @@ static struct regulator_consumer_supply dcdc1_consumers[] = {
 static struct regulator_consumer_supply dcdc2_consumers[] = {
        {
                .supply = "dcdc2",
+       },
+       {
+               .supply = "vcore",
        }
 };
 static struct regulator_consumer_supply dcdc3_consumers[] = {
@@ -981,9 +1065,9 @@ static int wm831x_checkrange(int start,int num,int val)
 
 static int wm831x_init_pin_type(struct wm831x *wm831x)
 {
-#if 0
+#if 1
        struct wm831x_pdata *pdata = wm831x->dev->platform_data;
-       struct rk2818_gpio_expander_info *wm831x_gpio_settinginfo;
+       struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
        uint16_t offset = 0;
        uint16_t wm831x_settingpin_num = 0;
        uint16_t ret = 0;
@@ -1160,41 +1244,42 @@ struct wm831x_pdata wm831x_platdata = {
 #define        RK29_GPS_POWER_PIN              RK29_PIN6_PB2
 #define        RK29_GPS_RESET_PIN              RK29_PIN6_PC1
 
-static int gps_open =0;
-
 int rk29_gps_power_up(void)
 {      
-       gps_open = 1;   
        printk("%s \n", __FUNCTION__);  
-       gpio_request(RK29_GPS_POWER_PIN, NULL);    
+
+    gpio_request(RK29_GPS_POWER_PIN, NULL);    
        gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);   
-       gpio_request(RK29_GPS_RESET_PIN, NULL);        
-       gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);      
-       rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
-       rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);      
-       mdelay(100);    
-       gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);           
+
        return 0;
 }
 
 int rk29_gps_power_down(void)
 {      
-       gps_open =0;    
        printk("%s \n", __FUNCTION__);  
+
        gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);            
-       mdelay(100);      
-       gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);    //uart1 
+
        return 0;
 }
 
+int rk29_gps_reset_set(int level)
+{
+       gpio_request(RK29_GPS_RESET_PIN, NULL);
+       if (level)
+               gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
+       else
+               gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
+
+       return 0;
+}
 
 struct rk29_gps_data rk29_gps_info = { 
        .power_up = rk29_gps_power_up,  
        .power_down = rk29_gps_power_down,      
+       .reset = rk29_gps_reset_set,
        .uart_id = 3,
-       .powerpin = RK29_GPS_POWER_PIN,
-       .powerflag = 1,
-       };
+};
 
 struct platform_device rk29_device_gps = {
        .name = "rk29_gps",
@@ -1205,6 +1290,179 @@ struct platform_device rk29_device_gps = {
        };
 #endif
 
+/*****************************************************************************************
+ * wm8994  codec
+ * author: qjb@rock-chips.com
+ *****************************************************************************************/
+//#if defined(CONFIG_MFD_WM8994)
+#if defined (CONFIG_REGULATOR_WM8994)
+static struct regulator_consumer_supply wm8994_ldo1_consumers[] = {
+       {
+               .supply = "DBVDD",
+       },
+       {
+               .supply = "AVDD1",
+       },
+       {
+               .supply = "CPVDD",
+       },
+       {
+               .supply = "SPKVDD1",
+       }               
+};
+static struct regulator_consumer_supply wm8994_ldo2_consumers[] = {
+       {
+               .supply = "DCVDD",
+       },
+       {
+               .supply = "AVDD2",
+       },
+       {
+               .supply = "SPKVDD2",
+       }                       
+};
+struct regulator_init_data regulator_init_data_ldo1 = {
+       .constraints = {
+               .name = "wm8994-ldo1",
+               .min_uA = 00000,
+               .max_uA = 18000,
+               .always_on = true,
+               .apply_uV = true,               
+               .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
+       },
+       .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo1_consumers),
+       .consumer_supplies = wm8994_ldo1_consumers,     
+};
+struct regulator_init_data regulator_init_data_ldo2 = {
+       .constraints = {
+               .name = "wm8994-ldo2",
+               .min_uA = 00000,
+               .max_uA = 18000,
+               .always_on = true,
+               .apply_uV = true,               
+               .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
+       },
+       .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo2_consumers),
+       .consumer_supplies = wm8994_ldo2_consumers,     
+};
+#endif 
+struct wm8994_drc_cfg wm8994_drc_cfg_pdata = {
+       .name = "wm8994_DRC",
+       .regs = {0,0,0,0,0},
+};
+
+struct wm8994_retune_mobile_cfg wm8994_retune_mobile_cfg_pdata = {
+       .name = "wm8994_EQ",
+       .rate = 0,
+       .regs = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
+}; 
+
+struct wm8994_pdata wm8994_platdata = {        
+#if defined (CONFIG_GPIO_WM8994)
+       .gpio_base = WM8994_GPIO_EXPANDER_BASE,
+       //Fill value to initialize the GPIO
+       .gpio_defaults ={},
+#endif 
+       //enable=0 disable ldo
+#if defined (CONFIG_REGULATOR_WM8994)  
+       .ldo = {
+               {
+                       .enable = 0,
+                       //RK29_PIN5_PA1
+                       .supply = NULL,
+                       .init_data = &regulator_init_data_ldo1,
+               },
+               {
+                       .enable = 0,
+                       .supply = NULL,         
+                       .init_data = &regulator_init_data_ldo2,
+               }
+       },
+#endif         
+       //DRC 0--use default
+       .num_drc_cfgs = 0,
+       .drc_cfgs = &wm8994_drc_cfg_pdata,
+       //EQ   0--use default 
+       .num_retune_mobile_cfgs = 0,
+       .retune_mobile_cfgs = &wm8994_retune_mobile_cfg_pdata,
+       
+       .lineout1_diff = 1,
+       .lineout2_diff = 1,
+       
+       .lineout1fb = 1,
+       .lineout2fb = 1,
+       
+       .micbias1_lvl = 1,
+       .micbias2_lvl = 1,
+       
+       .jd_scthr = 0,
+       .jd_thr = 0,
+
+       .PA_control =0,
+
+       .speaker_incall_vol = 0,
+       .speaker_incall_mic_vol = -9,
+       .speaker_normal_vol = 6,
+       .earpiece_incall_vol = 0,
+       .headset_incall_vol = 6,
+       .headset_incall_mic_vol = -6,
+       .headset_normal_vol = 6,
+       .BT_incall_vol = 0,
+       .BT_incall_mic_vol = 0,
+       .recorder_vol = 50,
+       
+};
+//#endif 
+
+#ifdef CONFIG_RK_HEADSET_DET
+#define HEADSET_GPIO RK29_PIN4_PD2
+struct rk2818_headset_data rk2818_headset_info = {
+       .gpio           = HEADSET_GPIO,
+       .irq_type       = IRQF_TRIGGER_RISING,//IRQF_TRIGGER_RISING -- ??????   IRQF_TRIGGER_FALLING -- ?½???
+       .headset_in_type= HEADSET_IN_HIGH,
+};
+
+struct platform_device rk28_device_headset = {
+               .name   = "rk2818_headsetdet",
+               .id     = 0,
+               .dev    = {
+                   .platform_data = &rk2818_headset_info,
+               }
+};
+#endif
+
+#if defined(CONFIG_GS_L3G4200D)
+
+#include <linux/l3g4200d.h>
+#define L3G4200D_INT_PIN  RK29_PIN5_PA3
+
+static int l3g4200d_init_platform_hw(void)
+{
+       if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
+               gpio_free(L3G4200D_INT_PIN);
+               printk("%s: request l3g4200d int pin error\n", __func__);
+               return -EIO;
+       }
+       gpio_pull_updown(L3G4200D_INT_PIN, 1);
+       return 0;
+}
+
+static struct l3g4200d_platform_data l3g4200d_info = {
+       .fs_range = 1,
+       
+       .axis_map_x = 0,
+       .axis_map_y = 1,
+       .axis_map_z = 2,
+
+       .negate_x = 1,
+       .negate_y = 1,
+       .negate_z = 0,
+
+       .init = l3g4200d_init_platform_hw,
+};
+
+#endif
+
 /*****************************************************************************************
  * i2c devices
  * author: kfx@rock-chips.com
@@ -1250,7 +1508,7 @@ struct rk29_i2c_platform_data default_i2c1_data = {
        .flags      = 0,
        .slave_addr = 0xff,
        .scl_rate  = 400*1000,
-       .mode           = I2C_MODE_POLL,
+       .mode           = I2C_MODE_IRQ,
        .io_init = rk29_i2c1_io_init,
 };
 
@@ -1268,7 +1526,7 @@ struct rk29_i2c_platform_data default_i2c3_data = {
        .flags      = 0,
        .slave_addr = 0xff,
        .scl_rate  = 400*1000,
-       .mode           = I2C_MODE_POLL,
+       .mode           = I2C_MODE_IRQ,
        .io_init = rk29_i2c3_io_init,
 };
 
@@ -1295,6 +1553,16 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .flags                  = 0,
        },
 #endif
+#if defined (CONFIG_SND_SOC_WM8994)
+       {
+               .type                   = "wm8994",
+               .addr           = 0x1a,
+               .flags                  = 0,
+//     #if defined(CONFIG_MFD_WM8994)  
+               .platform_data  = &wm8994_platdata,     
+//     #endif  
+       },
+#endif
 #if defined (CONFIG_BATTERY_STC3100)
        {
                .type                   = "stc3100",
@@ -1326,23 +1594,23 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
       .platform_data  = &mma8452_info,
     },
 #endif
-#if defined (CONFIG_SENSORS_AK8973)
+#if defined (CONFIG_COMPASS_AK8973)
        {
                .type                   = "ak8973",
                .addr           = 0x1d,
                .flags                  = 0,
-               .irq                    = RK29_PIN0_PA4,
+               .irq                    = RK29_PIN6_PC5,
        },
 #endif
-#if defined (CONFIG_SENSORS_AK8975)
+#if defined (CONFIG_COMPASS_AK8975)
        {
                .type                   = "ak8975",
                .addr           = 0x0d,
                .flags                  = 0,
-               .irq                    = RK29_PIN0_PA4,
+               .irq                    = RK29_PIN6_PC5,
        },
 #endif
-#if defined (CONFIG_INPUT_PSENSOR_ISL29028)
+#if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
        {
                .type           = "isl29028",
                .addr           = 0x44,
@@ -1358,6 +1626,15 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
         .irq            = RK29_PIN2_PA3,
     },
 #endif
+#if defined (CONFIG_GS_L3G4200D)
+       {
+               .type           = "gs_l3g4200d",
+               .addr           = 0x69,
+               .flags          = 0,
+               .irq            = L3G4200D_INT_PIN,
+               .platform_data  = &l3g4200d_info,
+       },
+#endif
 };
 #endif
 
@@ -1376,6 +1653,24 @@ static struct i2c_board_info __initdata board_i2c1_devices[] = {
 
 #ifdef CONFIG_I2C2_RK29
 static struct i2c_board_info __initdata board_i2c2_devices[] = {
+#if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
+{
+       .type           = "gt801_ts",
+       .addr           = 0x55,
+       .flags          = 0,
+       .irq            = RK29_PIN4_PD5,
+       .platform_data = &gt801_info,
+},     
+#endif
+#if defined (CONFIG_MFD_WM831X_I2C)
+{
+       .type           = "wm8310",
+       .addr           = 0x34,
+       .flags          = 0,
+       .irq            = RK29_PIN4_PD0,
+       .platform_data = &wm831x_platdata,
+},     
+#endif
 #if defined (CONFIG_HANNSTAR_P1003)
     {
       .type           = "p1003_touch",
@@ -1617,7 +1912,7 @@ static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,
                                        }
                                } else {
                                        ret = RK29_CAM_EIO_REQUESTFAIL;
-                                       printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
+                                       printk("\n%s..%s..PowerPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
                                }
                    } else {
                                ret = RK29_CAM_EIO_INVALID;
@@ -1670,13 +1965,35 @@ static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,
                {
                        if (camera_flash != INVALID_GPIO) {
                                if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
-                                       if (on) {
-                                       gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
-                                       //printk("\n%s..%s..FlashPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
-                                       } else {
-                                               gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
-                                       //printk("\n%s..%s..FlashPin= %d..PinLevel = %x   \n",__FUNCTION__,dev_name(dev), camera_flash, (((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
-                               }
+                    switch (on)
+                    {
+                        case Flash_Off:
+                        {
+                            gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+                                           //printk("\n%s..%s..FlashPin= %d..PinLevel = %x   \n",__FUNCTION__,dev_name(dev), camera_flash, (((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); 
+                                           break;
+                        }
+
+                        case Flash_On:
+                        {
+                            gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+                                           //printk("\n%s..%s..FlashPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+                                           break;
+                        }
+
+                        case Flash_Torch:
+                        {
+                            gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+                                           //printk("\n%s..%s..FlashPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+                                           break;
+                        }
+
+                        default:
+                        {
+                            printk("\n%s..%s..Flash command(%d) is invalidate \n",__FUNCTION__,dev_name(dev),on);
+                            break;
+                        }
+                    }
                                } else {
                                        ret = RK29_CAM_EIO_REQUESTFAIL;
                                        printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
@@ -1902,6 +2219,42 @@ static struct platform_device rk29_device_pwm_regulator = {
 
 #endif
 
+
+#if defined(CONFIG_MTK23D)
+static int mtk23d_io_init(void)
+{
+       
+       return 0;
+}
+
+static int mtk23d_io_deinit(void)
+{
+       
+       return 0;
+}
+struct rk2818_23d_data rk2818_23d_info = {
+       .io_init = mtk23d_io_init,
+  .io_deinit = mtk23d_io_deinit,
+       .bp_power = RK29_PIN0_PA0,
+       .bp_power_active_low = 0,
+       .bp_reset = RK29_PIN0_PA1,
+       .bp_reset_active_low = 1,
+       .bp_statue = RK29_PIN0_PA3,//input  high bp sleep;
+       .ap_statue = RK29_PIN0_PA2,//output high ap sleep;
+       .ap_bp_wakeup = RK29_PIN0_PA4, //output AP wake up BP used rising edge;
+       //.bp_ap_wakeup = RK2818_PIN_PE0,//input BP wake up AP
+};
+struct platform_device rk2818_device_mtk23d = {        
+        .name = "mtk23d",      
+       .id = -1,       
+       .dev            = {
+               .platform_data = &rk2818_23d_info,
+       }       
+    };
+#endif
+
+
 /*****************************************************************************************
  * SDMMC devices
 *****************************************************************************************/
@@ -1914,7 +2267,7 @@ static int rk29_sdmmc0_cfg_gpio(void)
        rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
        rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
        rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
-       rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
+       rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
        rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);   ///GPIO5H_SDMMC0_PWR_EN);  ///GPIO5H_GPIO5D5);
        gpio_request(RK29_PIN5_PD5,"sdmmc");
        gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
@@ -1936,6 +2289,8 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = {
 #else
        .use_dma = 0,
 #endif
+       .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
+       .enable_sd_wakeup = 0,
 };
 #endif
 #ifdef CONFIG_SDMMC1_RK29
@@ -2027,8 +2382,8 @@ static int rk29sdk_wifi_bt_gpio_control_init(void)
     }
 
     gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
-    gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N,    GPIO_LOW);
-    gpio_direction_output(RK29SDK_BT_GPIO_RESET_N,      GPIO_LOW);
+    gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N,    GPIO_HIGH);
+    gpio_direction_output(RK29SDK_BT_GPIO_RESET_N,      GPIO_HIGH);
 
     pr_info("%s: init finished\n",__func__);
 
@@ -2173,7 +2528,7 @@ static struct resource resources_gpu[] = {
     [1] = {
                .name = "gpu_base",
         .start  = RK29_GPU_PHYS,
-        .end    = RK29_GPU_PHYS + RK29_GPU_PHYS_SIZE,
+        .end    = RK29_GPU_PHYS + RK29_GPU_SIZE,
         .flags  = IORESOURCE_MEM,
     },
     [2] = {
@@ -2203,59 +2558,6 @@ static struct platform_device rk29_device_keys = {
 
 static void __init rk29_board_iomux_init(void)
 {
-       #ifdef CONFIG_UART0_RK29
-       rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
-       rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
-       #ifdef CONFIG_UART0_CTS_RTS_RK29
-       rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
-       rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
-       #endif
-       #endif
-       #ifdef CONFIG_UART1_RK29
-       rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
-       rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
-       #endif
-       #ifdef CONFIG_UART2_RK29
-       rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
-       rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
-       #ifdef CONFIG_UART2_CTS_RTS_RK29
-       rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
-       rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
-       #endif
-       #endif
-       #ifdef CONFIG_UART3_RK29
-       rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
-       rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
-       #ifdef CONFIG_UART3_CTS_RTS_RK29
-       rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
-       rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
-       #endif
-       #endif
-       #ifdef CONFIG_SPIM0_RK29
-    rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
-       rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
-       rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
-       rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
-    #endif
-    #ifdef CONFIG_SPIM1_RK29
-    rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
-       rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
-       rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
-       rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
-    #endif
-       #ifdef CONFIG_RK29_VMAC
-    rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
-    rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
-    rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
-    rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
-    rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
-    rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
-    rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
-    rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
-
-       rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
-       rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
-       #endif
        #ifdef CONFIG_RK29_PWM_REGULATOR
        rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
        #endif
@@ -2271,6 +2573,9 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_UART2_RK29
        &rk29_device_uart2,
 #endif
+#ifdef CONFIG_UART3_RK29
+       &rk29_device_uart3,
+#endif
 
 #ifdef CONFIG_RK29_PWM_REGULATOR
        &rk29_device_pwm_regulator,
@@ -2326,6 +2631,10 @@ static struct platform_device *devices[] __initdata = {
         &rk29sdk_rfkill,
 #endif
 
+#if defined(CONFIG_MTK23D)
+       &rk2818_device_mtk23d,
+#endif
+
 #ifdef CONFIG_MTD_NAND_RK29
        &rk29_device_nand,
 #endif
@@ -2372,6 +2681,12 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_VIDEO_RK29XX_VOUT
        &rk29_v4l2_output_devce,
 #endif
+#ifdef CONFIG_RK_HEADSET_DET
+    &rk28_device_headset,
+#endif
+#ifdef CONFIG_RK29_GPS
+       &rk29_device_gps,
+#endif
 };
 
 #ifdef CONFIG_RK29_VMAC
@@ -2447,7 +2762,8 @@ static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
     {
                .name = "spi0 cs0",
                .cs_gpio = RK29_PIN2_PC1,
-               .cs_iomux_name = NULL,
+               .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
+               .cs_iomux_mode = GPIO2H_SPI0_CSN0,
        },
        {
                .name = "spi0 cs1",
@@ -2461,7 +2777,8 @@ static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
     {
                .name = "spi1 cs0",
                .cs_gpio = RK29_PIN2_PC5,
-               .cs_iomux_name = NULL,
+               .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
+               .cs_iomux_mode = GPIO2H_SPI1_CSN0,
        },
        {
                .name = "spi1 cs1",
@@ -2474,40 +2791,18 @@ static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
 {
 #if 1
-       int i,j,ret;
-
-       //cs
-       if (cs_gpios) {
-               for (i=0; i<cs_num; i++) {
-                       rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
-                       ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
-                       if (ret) {
-                               for (j=0;j<i;j++) {
-                                       gpio_free(cs_gpios[j].cs_gpio);
-                                       //rk29_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
-                               }
-                               printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
-                               return -1;
+               int i;
+               if (cs_gpios) {
+                       for (i=0; i<cs_num; i++) {
+                               rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
                        }
-                       gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
                }
-       }
 #endif
        return 0;
 }
 
 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
 {
-#if 1
-       int i;
-
-       if (cs_gpios) {
-               for (i=0; i<cs_num; i++) {
-                       gpio_free(cs_gpios[i].cs_gpio);
-                       //rk29_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
-               }
-       }
-#endif
        return 0;
 }
 
@@ -2547,90 +2842,207 @@ struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
 
 /*****************************************************************************************
  * xpt2046 touch panel
- * author: cmc@rock-chips.com
+ * author: hhb@rock-chips.com
  *****************************************************************************************/
-#define XPT2046_GPIO_INT           RK29_PIN0_PA3
-#define DEBOUNCE_REPTIME  3
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
+#define XPT2046_GPIO_INT           RK29_PIN4_PD5 //中断???#define DEBOUNCE_REPTIME  3
 
-#if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
 static struct xpt2046_platform_data xpt2046_info = {
        .model                  = 2046,
        .keep_vref_on   = 1,
        .swap_xy                = 0,
-       .x_min                  = 0,
-       .x_max                  = 320,
-       .y_min                  = 0,
-       .y_max                  = 480,
        .debounce_max           = 7,
        .debounce_rep           = DEBOUNCE_REPTIME,
        .debounce_tol           = 20,
        .gpio_pendown           = XPT2046_GPIO_INT,
+       .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME, 
+       .pendown_iomux_mode = GPIO4H_GPIO4D5,   
+       .touch_virtualkey_length = 60,
        .penirq_recheck_delay_usecs = 1,
-};
-#elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
-static struct xpt2046_platform_data xpt2046_info = {
-       .model                  = 2046,
-       .keep_vref_on   = 1,
-       .swap_xy                = 0,
+#if defined(CONFIG_TOUCHSCREEN_480X800)
+       .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,
+       .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,
-       .debounce_max           = 7,
-       .debounce_rep           = DEBOUNCE_REPTIME,
-       .debounce_tol           = 20,
-       .gpio_pendown           = XPT2046_GPIO_INT,
-       .penirq_recheck_delay_usecs = 1,
+       .touch_ad_top = 3166,
+       .touch_ad_bottom = 256,
+       .touch_ad_left = 3658,
+       .touch_ad_right = 380,
+#endif 
 };
-#elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
+#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
 static struct xpt2046_platform_data xpt2046_info = {
        .model                  = 2046,
        .keep_vref_on   = 1,
-       .swap_xy                = 1,
-       .x_min                  = 0,
-       .x_max                  = 800,
-       .y_min                  = 0,
-       .y_max                  = 480,
+       .swap_xy                = 0,
        .debounce_max           = 7,
        .debounce_rep           = DEBOUNCE_REPTIME,
        .debounce_tol           = 20,
        .gpio_pendown           = XPT2046_GPIO_INT,
-
+       .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME, 
+       .pendown_iomux_mode = GPIO4H_GPIO4D5,   
+       .touch_virtualkey_length = 60,
        .penirq_recheck_delay_usecs = 1,
-};
-#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
-static struct xpt2046_platform_data xpt2046_info = {
-       .model                  = 2046,
-       .keep_vref_on   = 1,
-       .swap_xy                = 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 },
+#elif defined(CONFIG_TOUCHSCREEN_800X480)
        .x_min                  = 0,
        .x_max                  = 800,
        .y_min                  = 0,
        .y_max                  = 480,
-       .debounce_max           = 7,
-       .debounce_rep           = DEBOUNCE_REPTIME,
-       .debounce_tol           = 20,
-       .gpio_pendown           = XPT2046_GPIO_INT,
+       .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 
+};
+#endif
 
-       .penirq_recheck_delay_usecs = 1,
+#if defined(CONFIG_SERIAL_SC8800)
+static struct plat_sc8800 sc8800_plat_data = {
+       .slav_rts_pin = RK29_PIN4_PD4,
+       .slav_rdy_pin = RK29_PIN4_PD1,
+       .master_rts_pin = RK29_PIN4_PD2,
+       .master_rdy_pin = RK29_PIN4_PD3,
+       //.poll_time = 100,
 };
 #endif
 
 static struct spi_board_info board_spi_devices[] = {
-#if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
-    ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
        {
                .modalias       = "xpt2046_ts",
-               .chip_select    = 0,
+               .chip_select    = 0,// 2,
                .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
                .bus_num        = 0,
                .irq = XPT2046_GPIO_INT,
                .platform_data = &xpt2046_info,
        },
 #endif
+
+#if defined(CONFIG_MFD_WM831X_SPI)
+       {
+               .modalias       = "wm8310",
+               .chip_select    = 1,
+               .max_speed_hz   = 1*1000*1000,
+               .bus_num        = 1,
+               .irq            = RK29_PIN4_PD0,
+               .platform_data = &wm831x_platdata,
+       },
+#endif
+#if defined(CONFIG_SERIAL_SC8800)
+       {
+               .modalias  = "sc8800",
+               .bus_num = 0,
+               .platform_data = &sc8800_plat_data,
+               .max_speed_hz  = 12*1000*1000,
+               .chip_select   = 0,
+       },
+#endif
 };
 
 
+/**********************************************************************************************
+ *
+ * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
+ * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
+ *
+ ***********************************************************************************************/
+static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
+                       struct kobj_attribute *attr, char *buf)
+{
+#if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
+       || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)
+       /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
+    /* centerx;centery;width;height; */
+       return sprintf(buf,
+               __stringify(EV_KEY) ":" __stringify(KEY_BACK)       ":315:815:120:50"     //":50:830:98:50"  //":210:796:98:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU)   ":85:815:88:50"   // ":184:830:120:50"  // ":435:796:120:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME)   ":184:815:100:50"   //":315:830:100:50"  //":320:796:100:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":435:815:88:50"   //":50:815:98:50"    //   //":85:796:88:50"
+               "\n");
+#endif
+       return 0;
+}
+
+static struct kobj_attribute rk29xx_virtual_keys_attr = {
+       .attr = {
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
+               .name = "virtualkeys.xpt2046-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
+        .name = "virtualkeys.hx8520-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_GT801_IIC)
+               .name = "virtualkeys.gt801-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
+               .name = "virtualkeys.ili2102-touchscreen",
+#endif
+
+
+               .mode = S_IRUGO,
+       },
+       .show = &rk29xx_virtual_keys_show,
+};
+
+static struct attribute *rk29xx_properties_attrs[] = {
+       &rk29xx_virtual_keys_attr.attr,
+       NULL
+};
+
+static struct attribute_group rk29xx_properties_attr_group = {
+       .attrs = rk29xx_properties_attrs,
+};
+static int rk29xx_virtual_keys_init(void)
+{
+       int ret;
+       struct kobject *properties_kobj;
+       printk("rk29xx_virtual_keys_init \n");
+       properties_kobj = kobject_create_and_add("board_properties", NULL);
+       if (properties_kobj)
+               ret = sysfs_create_group(properties_kobj,
+                               &rk29xx_properties_attr_group);
+       if (!properties_kobj || ret)
+       {
+               pr_err("failed to create board_properties\n");
+       }
+       return ret;
+}
+
+
 static void __init rk29_gic_init_irq(void)
 {
        gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
@@ -2648,6 +3060,9 @@ static void rk29_pm_power_off(void)
 {
        printk(KERN_ERR "rk29_pm_power_off start...\n");
        gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
+#if defined(CONFIG_MFD_WM831X)
+       wm831x_device_shutdown(gWm831x);
+#endif
        while (1);
 }
 
@@ -2660,11 +3075,7 @@ static void __init machine_rk29_board_init(void)
        gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
        pm_power_off = rk29_pm_power_off;
 
-#ifdef CONFIG_WIFI_CONTROL_FUNC
-                rk29sdk_wifi_bt_gpio_control_init();
-#endif
-
-               platform_add_devices(devices, ARRAY_SIZE(devices));
+       platform_add_devices(devices, ARRAY_SIZE(devices));
 #ifdef CONFIG_I2C0_RK29
        i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
                        ARRAY_SIZE(board_i2c0_devices));
@@ -2684,7 +3095,12 @@ static void __init machine_rk29_board_init(void)
 
        spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
 
-        rk29sdk_init_wifi_mem();
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+       rk29sdk_wifi_bt_gpio_control_init();
+       rk29sdk_init_wifi_mem();
+#endif
+
+       rk29xx_virtual_keys_init();
 }
 
 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
@@ -2699,8 +3115,9 @@ static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tag
 static void __init machine_rk29_mapio(void)
 {
        rk29_map_common_io();
+       rk29_setup_early_printk();
        rk29_sram_init();
-       rk29_clock_init();
+       rk29_clock_init(periph_pll_288mhz);
        rk29_iomux_init();
 }