rk29: rename RK29_GPU_PHYS_SIZE to RK29_GPU_SIZE
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk29 / board-rk29-fih.c
index 313d224ba9c482400517f78ee5543e78d6ffbb8e..6fd3e1e83fd5e442db3507c2d3c613b1cadef41a 100755 (executable)
@@ -26,7 +26,7 @@
 #include <linux/usb/android_composite.h>
 #include <linux/i2c/tps65910.h>
 #include <linux/mpu.h>
-
+#include <linux/mpu3050.h>
 #include <mach/hardware.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -62,7 +62,7 @@
 #else
 #define SDRAM_SIZE          SZ_512M
 #endif
-#define PMEM_GPU_SIZE       SZ_64M
+#define PMEM_GPU_SIZE      ( SZ_64M *3)
 #define PMEM_UI_SIZE        SZ_32M
 #define PMEM_VPU_SIZE       SZ_64M
 #define PMEM_CAM_SIZE       0x01300000
@@ -403,34 +403,49 @@ static struct mma8452_platform_data mma8452_info = {
 
 };
 #endif
-#if 1
+#if defined (CONFIG_SENSORS_MPU3050)
 /*mpu3050*/
 static struct mpu3050_platform_data mpu3050_data = {
                .int_config = 0x10,
-               .orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
+               .orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
+               //{ 0, -1, 0 ,-1 , 0, 0, 0, 0, 1 },
+//{ 0, -1, 0 ,-1 , 0, 0, 0, 0, 1 },
+//{ 1, 0, 0,0, -1, 0,0, 0, 1 },//{ 0, 1, 0,1, 0, 0,0, 0, -1 },
                .level_shifter = 0,
-#if 0
+#if defined (CONFIG_SENSORS_KXTF9)
                .accel = {
-                               .get_slave_descr = bma150_get_slave_descr,
+                               .get_slave_descr = kxtf9_get_slave_descr ,
                                .adapt_num = 0, // The i2c bus to which the mpu device is
                                // connected
+                               .irq = RK29_PIN0_PA3,
                                .bus = EXT_SLAVE_BUS_SECONDARY,  //The secondary I2C of MPU
-                               .address = 0x38,
-                               .orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
+                               .address = 0x0f,
+                               .orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
+                               //{ 0, -1, 0 ,1 , 0, 0, 0, 0, 1 },
+//{ 0, -1, 0 ,1 , 0, 0, 0, 0, 1 },
+//{ 1, 0, 0,0, 1, 0,0, 0, 1 },//{ 0, 1, 0,1, 0, 0,0, 0, -1 },
                },
 #endif
+#if defined (CONFIG_SENSORS_AK8975)
                .compass = {
                                .get_slave_descr = ak8975_get_slave_descr,/*ak5883_get_slave_descr,*/
                                .adapt_num = 0, // The i2c bus to which the compass device is. 
                                // It can be difference with mpu
                                // connected
+                               .irq = RK29_PIN0_PA4,
                                .bus = EXT_SLAVE_BUS_PRIMARY,
-                               .address = 0x1E,
-                               .orientation = { 0, 1, 0,-1, 0, 0,0, 0, 1 },
+                               .address = 0x0d,
+                               .orientation = /*{ 0, 1, 0,
+                                                               -1, 0, 0,
+                                                                0, 0, 1 },*/
+                               { -1, 0, 0,0, -1, 0,0, 0, 1 },
+                               //{ 0, 1, 0 , -1 , 0, 0, 0, 0, 1 },
+//{ -1, 0, 0 ,0 , -1, 0, 0, 0, 1 },
+//{ -1, 0, 0,0, -1, 0,0, 0, 1 },//{ 0, 1, 0,-1, 0, 0,0, 0, 1 },
                },
 };
 #endif
-
+#endif
 #if defined (CONFIG_BATTERY_BQ27510)
  
 #define DC_CHECK_PIN RK29_PIN4_PA1
@@ -724,7 +739,7 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
                printk(KERN_ERR "Unable to write TPS65910_REG_VDD1 reg\n");
                return -EIO;
        }
-       
+
        /* VDD2 */
        err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD2);
        if (err) {
@@ -738,7 +753,7 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
                printk(KERN_ERR "Unable to write TPS65910_REG_VDD2 reg\n");
                return -EIO;
        }
-       
+
        /* VIO */
        err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VIO);
        if (err) {
@@ -752,7 +767,7 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
                printk(KERN_ERR "Unable to write TPS65910_REG_VIO reg\n");
                return -EIO;
        }
-       
+
        /* Mask ALL interrupts */
        err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, 0xFF,
                        TPS65910_REG_INT_MSK);
@@ -777,27 +792,6 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
                return -EIO;
        }
 
-#if 0
-       printk(KERN_INFO "TPS65910 Set default voltage.\n");
-       /* VDD1 Set the default voltage: 1150 mV(47)*/
-       val = 47;       
-       err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD1_OP);
-       if (err) {
-               printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
-                               \n", TPS65910_REG_VDD1_OP);
-               return -EIO;
-       }
-
-       /* VDD2 Set the default voltage: 1087 * 1.25mV(41)*/
-       val = 42;       
-       err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD2_OP);
-       if (err) {
-               printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
-                               \n", TPS65910_REG_VDD2_OP);
-               return -EIO;
-       }
-#endif
-
        /* initilize all ISR work as NULL, specific driver will
         * assign function(s) later.
         */
@@ -957,7 +951,7 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .irq                    = RK29_PIN0_PA4,
        },
 #endif
-#if defined (CONFIG_SENSORS_AK8975)
+#if 0//defined (CONFIG_SENSORS_AK8975)
        {
                .type                   = "ak8975",
                .addr           = 0x0d,
@@ -965,8 +959,8 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .irq                    = RK29_PIN0_PA4,
        },
 #endif
-#if 1
 /*mpu3050*/
+#if defined (CONFIG_SENSORS_MPU3050) 
        {
                .type                   = "mpu3050",
                .addr                   = 0x68,
@@ -1817,7 +1811,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] = {
@@ -2094,8 +2088,7 @@ static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
     {
                .name = "spi0 cs0",
                .cs_gpio = RK29_PIN2_PC1,
-               .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
-               .cs_iomux_mode = GPIO2H_SPI0_CSN0,
+               .cs_iomux_name = NULL,
        },
        {
                .name = "spi0 cs1",
@@ -2109,8 +2102,7 @@ static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
     {
                .name = "spi1 cs0",
                .cs_gpio = RK29_PIN2_PC5,
-               .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
-               .cs_iomux_mode = GPIO2H_SPI1_CSN0,
+               .cs_iomux_name = NULL,
        },
        {
                .name = "spi1 cs1",
@@ -2123,20 +2115,40 @@ 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;
+       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;
+                       }
+                       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;
 }
 
@@ -2289,9 +2301,11 @@ 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));
@@ -2310,11 +2324,8 @@ static void __init machine_rk29_board_init(void)
 #endif
 
        spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
-
-#ifdef CONFIG_WIFI_CONTROL_FUNC
-    rk29sdk_wifi_bt_gpio_control_init();
-       rk29sdk_init_wifi_mem();
-#endif        
+        
+    rk29sdk_init_wifi_mem();
 }
 
 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,