ARM: tegra: dalmore: Add sensor board support
Yuvraj Pasi [Sat, 8 Sep 2012 11:43:36 +0000 (16:43 +0530)]
Add sensor board support on dalmore for front
sensor ov9772.

Bug 1011174

Reviewed-on: http://git-master/r/132968

Change-Id: Iefe6c6376381906eeffcf02d3ff37e4afed97cc4
Signed-off-by: Yuvraj Pasi <ypasi@nvidia.com>
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/143043
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

arch/arm/mach-tegra/board-dalmore-sensors.c
arch/arm/mach-tegra/board-dalmore.h
include/linux/mpu.h

index 133f32a..645fb66 100644 (file)
@@ -98,7 +98,7 @@ static int dalmore_imx091_power_on(void)
 
 reg_alloc_fail:
 
-       for (i = ARRAY_SIZE(dalmore_cam_reg_name) - 1; i >= 0; i--) {
+       for (i = 0; i < ARRAY_SIZE(dalmore_cam_reg_name); i++) {
                if (dalmore_cam_reg[i]) {
                        regulator_put(dalmore_cam_reg[i]);
                        dalmore_cam_reg[i] = NULL;
@@ -113,11 +113,10 @@ static int dalmore_imx091_power_off(void)
        int i;
        gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
 
-       for (i = ARRAY_SIZE(dalmore_cam_reg_name) - 1; i >= 0; i--) {
+       for (i = 0; i < ARRAY_SIZE(dalmore_cam_reg_name); i++) {
                if (dalmore_cam_reg[i]) {
                        regulator_disable(dalmore_cam_reg[i]);
                        regulator_put(dalmore_cam_reg[i]);
-                       dalmore_cam_reg[i] = NULL;
                }
        }
 
@@ -153,7 +152,7 @@ static int dalmore_ov9772_power_on(void)
 
 reg_alloc_fail:
 
-       for (i = ARRAY_SIZE(dalmore_cam_reg_name) - 1; i >= 0; i--) {
+       for (i = 0; i < ARRAY_SIZE(dalmore_cam_reg_name); i++) {
                if (dalmore_cam_reg[i]) {
                        regulator_put(dalmore_cam_reg[i]);
                        dalmore_cam_reg[i] = NULL;
@@ -168,11 +167,10 @@ static int dalmore_ov9772_power_off(void)
        int i;
        gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
 
-       for (i = ARRAY_SIZE(dalmore_cam_reg_name) - 1; i >= 0; i--) {
+       for (i = 0; i < ARRAY_SIZE(dalmore_cam_reg_name); i++) {
                if (dalmore_cam_reg[i]) {
                        regulator_disable(dalmore_cam_reg[i]);
                        regulator_put(dalmore_cam_reg[i]);
-                       dalmore_cam_reg[i] = NULL;
                }
        }
 
@@ -255,11 +253,69 @@ fail_free_gpio:
 }
 
 
+/* MPU board file definition   */
+static struct mpu_platform_data mpu9150_gyro_data = {
+       .int_config     = 0x10,
+       .level_shifter  = 0,
+       .orientation    = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h    */
+       .sec_slave_type = SECONDARY_SLAVE_TYPE_COMPASS,
+       .sec_slave_id   = COMPASS_ID_AK8975,
+       .secondary_i2c_addr     = MPU_COMPASS_ADDR,
+       .secondary_read_reg     = 0x06,
+       .secondary_orientation  = MPU_COMPASS_ORIENTATION,
+       .key            = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
+                          0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
+};
+
+#define TEGRA_CAMERA_GPIO(_gpio, _label, _value)               \
+       {                                                       \
+               .gpio = _gpio,                                  \
+               .label = _label,                                \
+               .value = _value,                                \
+       }
+
+static struct i2c_board_info __initdata inv_mpu9150_i2c2_board_info[] = {
+        {
+                I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
+                .platform_data = &mpu9150_gyro_data,
+        },
+};
+
+static void mpuirq_init(void)
+{
+        int ret = 0;
+        unsigned gyro_irq_gpio = MPU_GYRO_IRQ_GPIO;
+        unsigned gyro_bus_num = MPU_GYRO_BUS_NUM;
+        char *gyro_name = MPU_GYRO_NAME;
+
+        pr_info("*** MPU START *** mpuirq_init...\n");
+
+        ret = gpio_request(gyro_irq_gpio, gyro_name);
+
+        if (ret < 0) {
+                pr_err("%s: gpio_request failed %d\n", __func__, ret);
+                return;
+        }
+
+        ret = gpio_direction_input(gyro_irq_gpio);
+        if (ret < 0) {
+                pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
+                gpio_free(gyro_irq_gpio);
+                return;
+        }
+        pr_info("*** MPU END *** mpuirq_init...\n");
+
+        inv_mpu9150_i2c2_board_info[0].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
+        i2c_register_board_info(gyro_bus_num, inv_mpu9150_i2c2_board_info,
+                ARRAY_SIZE(inv_mpu9150_i2c2_board_info));
+}
+
 int __init dalmore_sensors_init(void)
 {
        tegra_get_board_info(&board_info);
 
        dalmore_camera_init();
+       mpuirq_init();
 
        return 0;
 }
index b9cf39c..cdd5b86 100644 (file)
 #define CAM_GPIO1                      TEGRA_GPIO_PCC1
 #define CAM_GPIO2                      TEGRA_GPIO_PCC2
 
+/* Touchscreen definitions */
+#define TOUCH_GPIO_IRQ_RAYDIUM_SPI      TEGRA_GPIO_PK2
+#define TOUCH_GPIO_RST_RAYDIUM_SPI      TEGRA_GPIO_PK4
+
+/* Invensense MPU Definitions */
+#define MPU_GYRO_NAME           "mpu9150"
+#define MPU_GYRO_IRQ_GPIO       TEGRA_GPIO_PR3
+#define MPU_GYRO_ADDR           0x69
+#define MPU_GYRO_BUS_NUM        0
+#define MPU_GYRO_ORIENTATION    { -1, 0, 0, 0, -1, 0, 0, 0, 1 }
+#define MPU_ACCEL_NAME          "kxtf9"
+#define MPU_ACCEL_IRQ_GPIO      0 /* DISABLE ACCELIRQ:  TEGRA_GPIO_PJ2 */
+#define MPU_ACCEL_ADDR          0x0F
+#define MPU_ACCEL_BUS_NUM       0
+#define MPU_ACCEL_ORIENTATION   { 0, 1, 0, -1, 0, 0, 0, 0, 1 }
+#define MPU_COMPASS_NAME        "ak8975"
+#define MPU_COMPASS_IRQ_GPIO    0
+#define MPU_COMPASS_ADDR        0x0D
+#define MPU_COMPASS_BUS_NUM     0
+#define MPU_COMPASS_ORIENTATION { 0, 1, 0, -1, 0, 0, 0, 0, 1 }
+
+
 int dalmore_regulator_init(void);
 int dalmore_suspend_init(void);
 int dalmore_sdhci_init(void);
index 1977b38..e399a27 100644 (file)
@@ -140,6 +140,14 @@ enum ext_slave_type {
 
        EXT_SLAVE_NUM_TYPES
 };
+enum secondary_slave_type {
+        SECONDARY_SLAVE_TYPE_NONE,
+        SECONDARY_SLAVE_TYPE_ACCEL,
+        SECONDARY_SLAVE_TYPE_COMPASS,
+        SECONDARY_SLAVE_TYPE_PRESSURE,
+
+        SECONDARY_SLAVE_TYPE_TYPES
+};
 
 enum ext_slave_id {
        ID_INVALID = 0,
@@ -310,6 +318,12 @@ struct mpu_platform_data {
        __u8 int_config;
        __u8 level_shifter;
        __s8 orientation[GYRO_NUM_AXES * GYRO_NUM_AXES];
+       enum secondary_slave_type sec_slave_type;
+        enum ext_slave_id sec_slave_id;
+        __u16 secondary_i2c_addr;
+        __u8 secondary_read_reg;
+        __s8 secondary_orientation[9];
+        __u8 key[16];
 };
 
 #define MPU_IOCTL (0x81) /* Magic number for MPU Iocts */