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 cc6056a68bc7546fa3ce272c3b5d46575b145488..0af0074b720d96f1b16f9c5cb66e5d4824691fbd 100755 (executable)
@@ -61,7 +61,7 @@
 #include <linux/mtk23d.h>
 #endif
 
-#include "../../../drivers/headset_observe/rk2818_headset.h"
+#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"
@@ -72,6 +72,7 @@
 #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
@@ -269,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*/
@@ -534,12 +548,12 @@ struct rk29_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);        
@@ -555,7 +569,6 @@ int wm831x_post_init(struct wm831x *parm)
        struct regulator *dcdc;
        struct regulator *ldo;
        
-
        dcdc = regulator_get(NULL, "dcdc3");            // 1th IO
        regulator_set_voltage(dcdc,3000000,3000000);
        regulator_enable(dcdc);                 
@@ -729,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[] = {
@@ -1228,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",
@@ -1382,14 +1399,26 @@ struct wm8994_pdata wm8994_platdata = {
        .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_HEADSET_DET
+#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 -- Ï½µÑØ
+       .irq_type       = IRQF_TRIGGER_RISING,//IRQF_TRIGGER_RISING -- ??????   IRQF_TRIGGER_FALLING -- ?½???
        .headset_in_type= HEADSET_IN_HIGH,
 };
 
@@ -1402,6 +1431,38 @@ struct platform_device rk28_device_headset = {
 };
 #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
@@ -1447,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,
 };
 
@@ -1465,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,
 };
 
@@ -1565,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
 
@@ -2151,9 +2221,25 @@ static struct platform_device rk29_device_pwm_regulator = {
 
 
 #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;
@@ -2181,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);
@@ -2203,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
@@ -2485,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,
@@ -2590,9 +2681,12 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_VIDEO_RK29XX_VOUT
        &rk29_v4l2_output_devce,
 #endif
-#ifdef CONFIG_HEADSET_DET
+#ifdef CONFIG_RK_HEADSET_DET
     &rk28_device_headset,
 #endif
+#ifdef CONFIG_RK29_GPS
+       &rk29_device_gps,
+#endif
 };
 
 #ifdef CONFIG_RK29_VMAC
@@ -2751,7 +2845,7 @@ struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
  * author: hhb@rock-chips.com
  *****************************************************************************************/
 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
-#define XPT2046_GPIO_INT           RK29_PIN4_PD5 //中断è\84?#define DEBOUNCE_REPTIME  3
+#define XPT2046_GPIO_INT           RK29_PIN4_PD5 //中断???#define DEBOUNCE_REPTIME  3
 
 static struct xpt2046_platform_data xpt2046_info = {
        .model                  = 2046,
@@ -2839,6 +2933,16 @@ static struct xpt2046_platform_data xpt2046_info = {
 };
 #endif
 
+#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_SPI)
        {
@@ -2861,7 +2965,15 @@ static struct spi_board_info board_spi_devices[] = {
                .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
 };
 
 
@@ -2896,6 +3008,8 @@ static struct kobj_attribute rk29xx_virtual_keys_attr = {
         .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
 
 
@@ -2946,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);
 }
 
@@ -2958,11 +3075,6 @@ static void __init machine_rk29_board_init(void)
        gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
        pm_power_off = rk29_pm_power_off;
 
-// codec                
-       gpio_request(RK29_PIN5_PA1, NULL);                       
-       gpio_direction_output(RK29_PIN5_PA1,GPIO_HIGH);                 
-       gpio_free(RK29_PIN5_PA1);
-
        platform_add_devices(devices, ARRAY_SIZE(devices));
 #ifdef CONFIG_I2C0_RK29
        i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,