ARM: tegra: cardhu: enable OV5650/OV5640 sensor
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-sensors.c
index 055cd88..af66e1f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/board-cardhu-sensors.c
  *
- * Copyright (c) 2010-2011, NVIDIA CORPORATION, All rights reserved.
+ * Copyright (c) 2010-2013, NVIDIA CORPORATION, All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
 #include <linux/i2c/pca954x.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/nct1008.h>
+#include <linux/module.h>
+
 #include <mach/fb.h>
 #include <mach/gpio.h>
 #include <media/ov5650.h>
+#include <media/ov5640.h>
 #include <media/ov14810.h>
 #include <media/ov2710.h>
 #include <media/tps61050.h>
+#include <media/soc_camera.h>
+#include <media/tegra_v4l2_camera.h>
 #include <generated/mach-types.h>
 #include "gpio-names.h"
 #include "board.h"
 #include <linux/mpu.h>
 #include <media/sh532u.h>
+#include <media/ad5816.h>
 #include <linux/bq27x00.h>
 #include <mach/gpio.h>
 #include <mach/edp.h>
+#include <mach/thermal.h>
+#include <linux/therm_est.h>
 
 #include "gpio-names.h"
 #include "board-cardhu.h"
 #include "cpu-tegra.h"
 
-static struct regulator *cardhu_1v8_cam1 = NULL;
-static struct regulator *cardhu_1v8_cam2 = NULL;
-static struct regulator *cardhu_1v8_cam3 = NULL;
-static struct regulator *cardhu_vdd_2v8_cam1 = NULL;
-static struct regulator *cardhu_vdd_2v8_cam2 = NULL;
-static struct regulator *cardhu_vdd_cam3 = NULL;
+#if defined(CONFIG_VIDEO_OV5650) || \
+       defined(CONFIG_VIDEO_OV5650_MODULE) || \
+       defined(CONFIG_SOC_CAMERA_OV5650) || \
+       defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
+static struct regulator *cardhu_1v8_cam1;
+static struct regulator *cardhu_vdd_2v8_cam1;
+#endif
+static struct regulator *cardhu_1v8_cam2;
+static struct regulator *cardhu_1v8_cam3;
+static struct regulator *cardhu_vdd_2v8_cam2;
+static struct regulator *cardhu_vdd_cam3;
 
 static struct board_info board_info;
 
@@ -77,6 +90,97 @@ static struct pca954x_platform_data cardhu_pca954x_data = {
        .num_modes      = ARRAY_SIZE(cardhu_pca954x_modes),
 };
 
+#if defined(CONFIG_SOC_CAMERA_OV5640) \
+       || defined(CONFIG_SOC_CAMERA_OV5640_MODULE)
+static int cardhu_ov5640_power_on(void);
+static int cardhu_ov5640_power_off(void);
+
+static int cardhu_ov5640_power(struct device *dev, int enable)
+{
+       if (enable)
+               return cardhu_ov5640_power_on();
+       else
+               cardhu_ov5640_power_off();
+
+       return 0;
+}
+
+static struct i2c_board_info cardhu_ov5640_camera_i2c_device = {
+       I2C_BOARD_INFO("ov5640", 0x3C),
+};
+
+static struct tegra_camera_platform_data cardhu_ov5640_camera_platform_data = {
+       .flip_v                 = 0,
+       .flip_h                 = 0,
+       .port                   = TEGRA_CAMERA_PORT_CSI_B,
+       .lanes                  = 2,
+       .continuous_clk         = 0,
+};
+
+static struct soc_camera_link ov5640_iclink = {
+       .bus_id         = -1, /* This must match the .id of tegra_vi01_device */
+       .board_info     = &cardhu_ov5640_camera_i2c_device,
+       .module_name    = "ov5640",
+       .i2c_adapter_id = PCA954x_I2C_BUS2,
+       .power          = cardhu_ov5640_power,
+       .priv           = &cardhu_ov5640_camera_platform_data,
+};
+
+static struct platform_device cardhu_ov5640_soc_camera_device = {
+       .name   = "soc-camera-pdrv",
+       .id     = 1,
+       .dev    = {
+               .platform_data = &ov5640_iclink,
+       },
+};
+#endif
+
+/* OV5650 V4L2 device */
+#if defined(CONFIG_SOC_CAMERA_OV5650) \
+       || defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
+static int cardhu_left_ov5650_power_on(void);
+static int cardhu_left_ov5650_power_off(void);
+
+static int cardhu_ov5650_power(struct device *dev, int enable)
+{
+       if (enable)
+               return cardhu_left_ov5650_power_on();
+       else
+               cardhu_left_ov5650_power_off();
+
+       return 0;
+}
+
+static struct i2c_board_info cardhu_ov5650_camera_i2c_device = {
+               I2C_BOARD_INFO("ov5650", 0x36),
+};
+
+static struct tegra_camera_platform_data cardhu_ov5650_camera_platform_data = {
+       .flip_v                 = 0,
+       .flip_h                 = 0,
+       .port                   = TEGRA_CAMERA_PORT_CSI_A,
+       .lanes                  = 2,
+       .continuous_clk         = 1,
+};
+
+static struct soc_camera_link ov5650_iclink = {
+       .bus_id         = -1, /* This must match the .id of tegra_vi01_device */
+       .board_info     = &cardhu_ov5650_camera_i2c_device,
+       .module_name    = "ov5650",
+       .i2c_adapter_id = PCA954x_I2C_BUS0,
+       .power          = cardhu_ov5650_power,
+       .priv           = &cardhu_ov5650_camera_platform_data,
+};
+
+static struct platform_device cardhu_ov5650_soc_camera_device = {
+       .name   = "soc-camera-pdrv",
+       .id     = 0,
+       .dev    = {
+               .platform_data = &ov5650_iclink,
+       },
+};
+#endif
+
 static int cardhu_camera_init(void)
 {
        int ret;
@@ -84,25 +188,22 @@ static int cardhu_camera_init(void)
        /* Boards E1198 and E1291 are of Cardhu personality
         * and donot have TCA6416 exp for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
-               tegra_gpio_enable(CAM1_POWER_DWN_GPIO);
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
                ret = gpio_request(CAM1_POWER_DWN_GPIO, "camera_power_en");
                if (ret < 0)
                        pr_err("%s: gpio_request failed for gpio %s\n",
                                __func__, "CAM1_POWER_DWN_GPIO");
-                               tegra_gpio_enable(CAM3_POWER_DWN_GPIO);
                ret = gpio_request(CAM3_POWER_DWN_GPIO, "cam3_power_en");
                if (ret < 0)
                        pr_err("%s: gpio_request failed for gpio %s\n",
                                __func__, "CAM3_POWER_DWN_GPIO");
 
-               tegra_gpio_enable(CAM2_POWER_DWN_GPIO);
                ret = gpio_request(CAM2_POWER_DWN_GPIO, "camera2_power_en");
                if (ret < 0)
                        pr_err("%s: gpio_request failed for gpio %s\n",
                                __func__, "CAM2_POWER_DWN_GPIO");
 
-               tegra_gpio_enable(OV5650_RESETN_GPIO);
                ret = gpio_request(OV5650_RESETN_GPIO, "camera_reset");
                if (ret < 0)
                        pr_err("%s: gpio_request failed for gpio %s\n",
@@ -122,7 +223,6 @@ static int cardhu_camera_init(void)
        }
 
        /* To select the CSIB MUX either for cam2 or cam3 */
-       tegra_gpio_enable(CAMERA_CSI_MUX_SEL_GPIO);
        ret = gpio_request(CAMERA_CSI_MUX_SEL_GPIO, "camera_csi_sel");
        if (ret < 0)
                pr_err("%s: gpio_request failed for gpio %s\n",
@@ -133,12 +233,17 @@ static int cardhu_camera_init(void)
        return 0;
 }
 
+#if defined(CONFIG_VIDEO_OV5650) || \
+       defined(CONFIG_VIDEO_OV5650_MODULE) || \
+       defined(CONFIG_SOC_CAMERA_OV5650) || \
+       defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
 static int cardhu_left_ov5650_power_on(void)
 {
        /* Boards E1198 and E1291 are of Cardhu personality
         * and donot have TCA6416 exp for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
 
                if (cardhu_vdd_2v8_cam1 == NULL) {
                        cardhu_vdd_2v8_cam1 = regulator_get(NULL, "vdd_2v8_cam1");
@@ -165,7 +270,8 @@ static int cardhu_left_ov5650_power_on(void)
 
        mdelay(5);
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
                mdelay(20);
                gpio_direction_output(OV5650_RESETN_GPIO, 0);
@@ -200,7 +306,8 @@ static int cardhu_left_ov5650_power_off(void)
        /* Boards E1198 and E1291 are of Cardhu personality
         * and donot have TCA6416 exp for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
@@ -212,11 +319,14 @@ static int cardhu_left_ov5650_power_off(void)
 
        return 0;
 }
+#endif
 
+#if defined(CONFIG_VIDEO_OV5650) || defined(CONFIG_VIDEO_OV5650_MODULE)
 struct ov5650_platform_data cardhu_left_ov5650_data = {
        .power_on = cardhu_left_ov5650_power_on,
        .power_off = cardhu_left_ov5650_power_off,
 };
+#endif
 
 #ifdef CONFIG_VIDEO_OV14810
 static int cardhu_ov14810_power_on(void)
@@ -276,10 +386,14 @@ static struct i2c_board_info cardhu_i2c_board_info_e1214[] = {
 
 static int cardhu_right_ov5650_power_on(void)
 {
+       /* CSI-B and front sensor are muxed on cardhu */
+       gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
+
        /* Boards E1198 and E1291 are of Cardhu personality
         * and donot have TCA6416 exp for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
 
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
@@ -334,10 +448,14 @@ reg_alloc_fail:
 
 static int cardhu_right_ov5650_power_off(void)
 {
+       /* CSI-B and front sensor are muxed on cardhu */
+       gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
+
        /* Boards E1198 and E1291 are of Cardhu personality
-        * and donot have TCA6416 exp for camera */
+        * and do not have TCA6416 for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
@@ -358,8 +476,8 @@ static void cardhu_ov5650_synchronize_sensors(void)
                mdelay(50);
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
                mdelay(50);
-       }
-       else if (board_info.board_id == BOARD_E1291) {
+       } else if ((board_info.board_id == BOARD_E1291) ||
+                       (board_info.board_id == BOARD_PM315)) {
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
                mdelay(50);
@@ -379,19 +497,104 @@ struct ov5650_platform_data cardhu_right_ov5650_data = {
 
 static int cardhu_ov2710_power_on(void)
 {
-       /* CSI-B and front sensor are muxed on verbier */
+       /* CSI-B and front sensor are muxed on cardhu */
        gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
 
+       /* Enable VDD_1V8_Cam3 */
+       if (cardhu_1v8_cam3 == NULL) {
+               cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
+               if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
+                       pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
+                               __func__, PTR_ERR(cardhu_1v8_cam3));
+                       goto reg_alloc_fail;
+               }
+       }
+       regulator_enable(cardhu_1v8_cam3);
+
        /* Boards E1198 and E1291 are of Cardhu personality
-        * and donot have TCA6416 exp for camera */
+        * and do not have TCA6416 for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
+               if (cardhu_vdd_cam3 == NULL) {
+                       cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
+                       if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
+                               pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
+                                       __func__, PTR_ERR(cardhu_vdd_cam3));
+                               goto reg_alloc_fail;
+                       }
+               }
+               regulator_enable(cardhu_vdd_cam3);
+
+               mdelay(5);
 
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
                gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
                mdelay(10);
 
+       }
+
+       mdelay(20);
+
+       return 0;
+
+reg_alloc_fail:
+       if (cardhu_1v8_cam3) {
+               regulator_put(cardhu_1v8_cam3);
+               cardhu_1v8_cam3 = NULL;
+       }
+       if (cardhu_vdd_cam3) {
+               regulator_put(cardhu_vdd_cam3);
+               cardhu_vdd_cam3 = NULL;
+       }
+
+       return -ENODEV;
+}
+
+static int cardhu_ov2710_power_off(void)
+{
+       /* CSI-B and front sensor are muxed on cardhu */
+       gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
+
+       /* Boards E1198 and E1291 are of Cardhu personality
+        * and donot have TCA6416 exp for camera */
+       if ((board_info.board_id == BOARD_E1198) ||
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
+               gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
+               gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
+               gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
+               if (cardhu_vdd_cam3)
+                       regulator_disable(cardhu_vdd_cam3);
+       }
+
+       if (cardhu_1v8_cam3)
+               regulator_disable(cardhu_1v8_cam3);
+
+       return 0;
+}
+
+struct ov2710_platform_data cardhu_ov2710_data = {
+       .power_on = cardhu_ov2710_power_on,
+       .power_off = cardhu_ov2710_power_off,
+};
+
+static int cardhu_ov5640_power_on(void)
+{
+       /* CSI-B and front sensor are muxed on cardhu */
+       gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
+
+       /* Boards E1198 and E1291 are of Cardhu personality
+        * and donot have TCA6416 exp for camera */
+       if ((board_info.board_id == BOARD_E1198) ||
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
+
+               gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
+               gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
+               mdelay(10);
+
                if (cardhu_vdd_cam3 == NULL) {
                        cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
                        if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
@@ -430,15 +633,16 @@ reg_alloc_fail:
        return -ENODEV;
 }
 
-static int cardhu_ov2710_power_off(void)
+static int cardhu_ov5640_power_off(void)
 {
+       /* CSI-B and front sensor are muxed on cardhu */
        gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
 
        /* Boards E1198 and E1291 are of Cardhu personality
         * and donot have TCA6416 exp for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291)) {
-               gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315)) {
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
                gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
        }
@@ -451,9 +655,9 @@ static int cardhu_ov2710_power_off(void)
        return 0;
 }
 
-struct ov2710_platform_data cardhu_ov2710_data = {
-       .power_on = cardhu_ov2710_power_on,
-       .power_off = cardhu_ov2710_power_off,
+struct ov5640_platform_data cardhu_ov5640_data = {
+       .power_on = cardhu_ov5640_power_on,
+       .power_off = cardhu_ov5640_power_off,
 };
 
 static const struct i2c_board_info cardhu_i2c3_board_info[] = {
@@ -463,103 +667,187 @@ static const struct i2c_board_info cardhu_i2c3_board_info[] = {
        },
 };
 
+
+static struct nvc_gpio_pdata sh532u_gpio_pdata[] = {
+       { SH532U_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
+};
+
 static struct sh532u_platform_data sh532u_left_pdata = {
+       .cfg            = NVC_CFG_NODEV,
        .num            = 1,
        .sync           = 2,
        .dev_name       = "focuser",
-       .gpio_reset     = TEGRA_GPIO_PBB0,
+       .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
+       .gpio           = sh532u_gpio_pdata,
 };
 
 static struct sh532u_platform_data sh532u_right_pdata = {
+       .cfg            = NVC_CFG_NODEV,
        .num            = 2,
        .sync           = 1,
        .dev_name       = "focuser",
-       .gpio_reset     = TEGRA_GPIO_PBB0,
+       .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
+       .gpio           = sh532u_gpio_pdata,
 };
 
-static bool cardhu_tps61050_pm_flag = 0;
+static struct nvc_gpio_pdata pm269_sh532u_left_gpio_pdata[] = {
+       { SH532U_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
+};
 
-static struct tps61050_pin_state cardhu_tps61050_pinstate = {
-       .mask           = 0x0008, /*VGP3*/
-       .values         = 0x0008,
+static struct sh532u_platform_data pm269_sh532u_left_pdata = {
+       .cfg            = 0,
+       .num            = 1,
+       .sync           = 2,
+       .dev_name       = "focuser",
+       .gpio_count     = ARRAY_SIZE(pm269_sh532u_left_gpio_pdata),
+       .gpio           = pm269_sh532u_left_gpio_pdata,
 };
 
-static int cardhu_tps61050_pm(int pwr)
-{
-       switch (pwr) {
-       case TPS61050_PWR_OFF:
-               if (cardhu_tps61050_pm_flag && cardhu_1v8_cam1) {
-                       regulator_disable(cardhu_1v8_cam1);
-                       cardhu_tps61050_pm_flag = 0;
-               }
-               return 0;
+static struct nvc_gpio_pdata pm269_sh532u_right_gpio_pdata[] = {
+       { SH532U_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
+};
 
-       case TPS61050_PWR_STDBY:
-       case TPS61050_PWR_COMM:
-       case TPS61050_PWR_ON:
-               if (!cardhu_tps61050_pm_flag) {
-                       if (cardhu_1v8_cam1 == NULL) {
-                               cardhu_1v8_cam1 =
-                                       regulator_get(NULL, "vdd_1v8_cam1");
-                               if (WARN_ON(IS_ERR(cardhu_1v8_cam1))) {
-                                       pr_err("%s: err: %ld\n",
-                                               __func__,
-                                               PTR_ERR(cardhu_1v8_cam1));
-                                       regulator_put(cardhu_1v8_cam1);
-                                       cardhu_1v8_cam1 = NULL;
-                               }
-                       }
-                       regulator_enable(cardhu_1v8_cam1);
-                       cardhu_tps61050_pm_flag = 1;
-                       mdelay(5);
-               }
-               return 0;
+static struct sh532u_platform_data pm269_sh532u_right_pdata = {
+       .cfg            = 0,
+       .num            = 2,
+       .sync           = 1,
+       .dev_name       = "focuser",
+       .gpio_count     = ARRAY_SIZE(pm269_sh532u_right_gpio_pdata),
+       .gpio           = pm269_sh532u_right_gpio_pdata,
+};
 
-       default:
-               return -1;
-       }
-}
+static struct nvc_gpio_pdata ad5816_gpio_pdata[] = {
+       { AD5816_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
+};
 
-static struct tps61050_platform_data cardhu_tps61050_data = {
+static struct ad5816_platform_data ad5816_left_pdata = {
        .cfg            = 0,
        .num            = 1,
-       .max_amp_torch  = CAMERA_FLASH_MAX_TORCH_AMP,
-       .max_amp_flash  = CAMERA_FLASH_MAX_FLASH_AMP,
+       .sync           = 2,
+       .dev_name       = "focuser",
+       .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
+       .gpio           = ad5816_gpio_pdata,
+};
+
+static struct ad5816_platform_data ad5816_right_pdata = {
+       .cfg            = 0,
+       .num            = 2,
+       .sync           = 1,
+       .dev_name       = "focuser",
+       .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
+       .gpio           = ad5816_gpio_pdata,
+};
+
+static struct nvc_gpio_pdata pm269_ad5816_left_gpio_pdata[] = {
+       { AD5816_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
+};
+
+static struct ad5816_platform_data pm269_ad5816_left_pdata = {
+       .cfg            = NVC_CFG_NODEV,
+       .num            = 1,
+       .sync           = 2,
+       .dev_name       = "focuser",
+       .gpio_count     = ARRAY_SIZE(pm269_ad5816_left_gpio_pdata),
+       .gpio           = pm269_ad5816_left_gpio_pdata,
+};
+
+static struct nvc_gpio_pdata pm269_ad5816_right_gpio_pdata[] = {
+       { AD5816_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
+};
+
+static struct ad5816_platform_data pm269_ad5816_right_pdata = {
+       .cfg            = NVC_CFG_NODEV,
+       .num            = 2,
+       .sync           = 1,
+       .dev_name       = "focuser",
+       .gpio_count     = ARRAY_SIZE(pm269_ad5816_right_gpio_pdata),
+       .gpio           = pm269_ad5816_right_gpio_pdata,
+};
+
+
+static struct nvc_torch_pin_state cardhu_tps61050_pinstate = {
+       .mask           = 0x0008, /*VGP3*/
+       .values         = 0x0008,
+};
+
+static struct tps61050_platform_data cardhu_tps61050_pdata = {
+       .dev_name       = "torch",
        .pinstate       = &cardhu_tps61050_pinstate,
-       .init           = NULL,
-       .exit           = NULL,
-       .pm             = cardhu_tps61050_pm,
-       .gpio_envm      = NULL,
-       .gpio_sync      = NULL,
 };
 
 static const struct i2c_board_info cardhu_i2c_board_info_tps61050[] = {
        {
                I2C_BOARD_INFO("tps61050", 0x33),
-               .platform_data = &cardhu_tps61050_data,
+               .platform_data = &cardhu_tps61050_pdata,
        },
 };
 
 static struct i2c_board_info cardhu_i2c6_board_info[] = {
+#if defined(CONFIG_VIDEO_OV5650) || defined(CONFIG_VIDEO_OV5650_MODULE)
        {
                I2C_BOARD_INFO("ov5650L", 0x36),
                .platform_data = &cardhu_left_ov5650_data,
        },
+#endif
        {
                I2C_BOARD_INFO("sh532u", 0x72),
                .platform_data = &sh532u_left_pdata,
        },
+       {
+               I2C_BOARD_INFO("ad5816", 0x0E),
+               .platform_data = &ad5816_left_pdata,
+       },
 };
 
 static struct i2c_board_info cardhu_i2c7_board_info[] = {
+#if defined(CONFIG_VIDEO_OV5650) || defined(CONFIG_VIDEO_OV5650_MODULE)
        {
                I2C_BOARD_INFO("ov5650R", 0x36),
                .platform_data = &cardhu_right_ov5650_data,
        },
+#endif
        {
                I2C_BOARD_INFO("sh532u", 0x72),
                .platform_data = &sh532u_right_pdata,
        },
+       {
+               I2C_BOARD_INFO("ad5816", 0x0E),
+               .platform_data = &ad5816_right_pdata,
+       },
+};
+
+static struct i2c_board_info pm269_i2c6_board_info[] = {
+#if defined(CONFIG_VIDEO_OV5650) || defined(CONFIG_VIDEO_OV5650_MODULE)
+       {
+               I2C_BOARD_INFO("ov5650L", 0x36),
+               .platform_data = &cardhu_left_ov5650_data,
+       },
+#endif
+       {
+               I2C_BOARD_INFO("sh532u", 0x72),
+               .platform_data = &pm269_sh532u_left_pdata,
+       },
+       {
+               I2C_BOARD_INFO("ad5816", 0x0E),
+               .platform_data = &pm269_ad5816_left_pdata,
+       },
+};
+
+static struct i2c_board_info pm269_i2c7_board_info[] = {
+#if defined(CONFIG_VIDEO_OV5650) || defined(CONFIG_VIDEO_OV5650_MODULE)
+       {
+               I2C_BOARD_INFO("ov5650R", 0x36),
+               .platform_data = &cardhu_right_ov5650_data,
+       },
+#endif
+       {
+               I2C_BOARD_INFO("sh532u", 0x72),
+               .platform_data = &pm269_sh532u_right_pdata,
+       },
+       {
+               I2C_BOARD_INFO("ad5816", 0x0E),
+               .platform_data = &pm269_ad5816_right_pdata,
+       },
 };
 
 static struct i2c_board_info cardhu_i2c8_board_info[] = {
@@ -567,18 +855,108 @@ static struct i2c_board_info cardhu_i2c8_board_info[] = {
                I2C_BOARD_INFO("ov2710", 0x36),
                .platform_data = &cardhu_ov2710_data,
        },
+#if defined(CONFIG_VIDEO_OV5640) || defined(CONFIG_VIDEO_OV5640_MODULE)
+       {
+               I2C_BOARD_INFO("ov5640", 0x3C),
+               .platform_data = &cardhu_ov5640_data,
+       },
+#endif
 };
 
+static int nct_get_temp(void *_data, long *temp)
+{
+       struct nct1008_data *data = _data;
+       return nct1008_thermal_get_temp(data, temp);
+}
+
+static int nct_get_temp_low(void *_data, long *temp)
+{
+       struct nct1008_data *data = _data;
+       return nct1008_thermal_get_temp_low(data, temp);
+}
+
+static int nct_set_limits(void *_data,
+                       long lo_limit_milli,
+                       long hi_limit_milli)
+{
+       struct nct1008_data *data = _data;
+       return nct1008_thermal_set_limits(data,
+                                       lo_limit_milli,
+                                       hi_limit_milli);
+}
+
+static int nct_set_alert(void *_data,
+                               void (*alert_func)(void *),
+                               void *alert_data)
+{
+       struct nct1008_data *data = _data;
+       return nct1008_thermal_set_alert(data, alert_func, alert_data);
+}
+
+static int nct_set_shutdown_temp(void *_data, long shutdown_temp)
+{
+       struct nct1008_data *data = _data;
+       return nct1008_thermal_set_shutdown_temp(data, shutdown_temp);
+}
+
+#ifdef CONFIG_TEGRA_SKIN_THROTTLE
+static int nct_get_itemp(void *dev_data, long *temp)
+{
+       struct nct1008_data *data = dev_data;
+       return nct1008_thermal_get_temps(data, NULL, temp);
+}
+#endif
+
+static void nct1008_probe_callback(struct nct1008_data *data)
+{
+       struct tegra_thermal_device *ext_nct;
+
+       ext_nct = kzalloc(sizeof(struct tegra_thermal_device),
+                                       GFP_KERNEL);
+       if (!ext_nct) {
+               pr_err("unable to allocate thermal device\n");
+               return;
+       }
+
+       ext_nct->name = "nct_ext";
+       ext_nct->id = THERMAL_DEVICE_ID_NCT_EXT;
+       ext_nct->data = data;
+       ext_nct->offset = TDIODE_OFFSET;
+       ext_nct->get_temp = nct_get_temp;
+       ext_nct->get_temp_low = nct_get_temp_low;
+       ext_nct->set_limits = nct_set_limits;
+       ext_nct->set_alert = nct_set_alert;
+       ext_nct->set_shutdown_temp = nct_set_shutdown_temp;
+
+       tegra_thermal_device_register(ext_nct);
+
+#ifdef CONFIG_TEGRA_SKIN_THROTTLE
+       {
+               struct tegra_thermal_device *int_nct;
+               int_nct = kzalloc(sizeof(struct tegra_thermal_device),
+                                               GFP_KERNEL);
+               if (!int_nct) {
+                       kfree(int_nct);
+                       pr_err("unable to allocate thermal device\n");
+                       return;
+               }
+
+               int_nct->name = "nct_int";
+               int_nct->id = THERMAL_DEVICE_ID_NCT_INT;
+               int_nct->data = data;
+               int_nct->get_temp = nct_get_itemp;
+
+               tegra_thermal_device_register(int_nct);
+       }
+#endif
+}
+
 static struct nct1008_platform_data cardhu_nct1008_pdata = {
        .supported_hwrev = true,
        .ext_range = true,
        .conv_rate = 0x08,
-       .hysteresis = 5,
        .offset = 8, /* 4 * 2C. Bug 844025 - 1C for device accuracies */
-       .shutdown_ext_limit = 90,
-       .shutdown_local_limit = 90,
-       .throttling_ext_limit = 85,
-       .alarm_fn = tegra_throttling_enable,
+       .probe_callback = nct1008_probe_callback,
 };
 
 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
@@ -595,24 +973,18 @@ static struct i2c_board_info cardhu_i2c4_nct1008_board_info[] = {
        }
 };
 
-
 static int cardhu_nct1008_init(void)
 {
        int nct1008_port = -1;
-       int ret;
-#ifdef CONFIG_TEGRA_EDP_LIMITS
-       const struct tegra_edp_limits *z;
-       int zones_sz;
-       int i;
-       bool throttle_ok = false;
-#endif
+       int ret = 0;
 
        if ((board_info.board_id == BOARD_E1198) ||
                (board_info.board_id == BOARD_E1291) ||
                (board_info.board_id == BOARD_E1257) ||
                (board_info.board_id == BOARD_PM269) ||
                (board_info.board_id == BOARD_PM305) ||
-               (board_info.board_id == BOARD_PM311)) {
+               (board_info.board_id == BOARD_PM311) ||
+               (board_info.board_id == BOARD_PM315)) {
                nct1008_port = TEGRA_GPIO_PCC2;
        } else if ((board_info.board_id == BOARD_E1186) ||
                (board_info.board_id == BOARD_E1187) ||
@@ -632,31 +1004,8 @@ static int cardhu_nct1008_init(void)
                ret = gpio_direction_input(nct1008_port);
                if (ret < 0)
                        gpio_free(nct1008_port);
-               else
-                       tegra_gpio_enable(nct1008_port);
-       }
-
-#ifdef CONFIG_TEGRA_EDP_LIMITS
-       tegra_get_cpu_edp_limits(&z, &zones_sz);
-       zones_sz = min(zones_sz, MAX_ZONES);
-       for (i = 0; i < zones_sz; i++) {
-               cardhu_nct1008_pdata.thermal_zones[i] = z[i].temperature;
-               if (cardhu_nct1008_pdata.thermal_zones[i] ==
-                   cardhu_nct1008_pdata.throttling_ext_limit) {
-                       throttle_ok = true;
-               }
        }
 
-       if (throttle_ok != true)
-               pr_warn("%s: WARNING! Throttling limit %dC would be inaccurate"
-                       " as it is NOT one of the EDP points\n",
-                       __func__, cardhu_nct1008_pdata.throttling_ext_limit);
-       else
-               pr_info("%s: Throttling limit %dC OK\n",
-                       __func__, cardhu_nct1008_pdata.throttling_ext_limit);
-
-       cardhu_nct1008_pdata.thermal_zones_sz = zones_sz;
-#endif
        return ret;
 }
 
@@ -686,7 +1035,8 @@ static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
 static int __init pmu_tca6416_init(void)
 {
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291))
+               (board_info.board_id == BOARD_E1291) ||
+                       (board_info.board_id == BOARD_PM315))
                        return 0;
 
        pr_info("Registering pmu pca6416\n");
@@ -700,7 +1050,8 @@ static int __init cam_tca6416_init(void)
        /* Boards E1198 and E1291 are of Cardhu personality
         * and donot have TCA6416 exp for camera */
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291))
+                       (board_info.board_id == BOARD_E1291) ||
+                       (board_info.board_id == BOARD_PM315))
                return 0;
 
        pr_info("Registering cam pca6416\n");
@@ -720,51 +1071,103 @@ static int __init cam_tca6416_init(void)
 }
 #endif
 
-#ifdef CONFIG_MPU_SENSORS_MPU3050
-#define SENSOR_MPU_NAME "mpu3050"
-static struct mpu3050_platform_data mpu3050_data = {
-       .int_config  = 0x10,
-       .orientation = { 0, -1, 0, -1, 0, 0, 0, 0, -1 },  /* Orientation matrix for MPU on cardhu */
-       .level_shifter = 0,
-
-       .accel = {
-       .get_slave_descr = get_accel_slave_descr,
-       .adapt_num   = 2,
-       .bus         = EXT_SLAVE_BUS_SECONDARY,
-       .address     = 0x0F,
-       .orientation = { 0, -1, 0, -1, 0, 0, 0, 0, -1 },  /* Orientation matrix for Kionix on cardhu */
-       },
+/* MPU board file definition   */
+#if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
+#define MPU_GYRO_NAME          "mpu3050"
+#endif
+#if (MPU_GYRO_TYPE == MPU_TYPE_MPU6050)
+#define MPU_GYRO_NAME          "mpu6050"
+#endif
+static struct mpu_platform_data mpu_gyro_data = {
+       .int_config     = 0x10,
+       .level_shifter  = 0,
+       .orientation    = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h    */
+};
 
-       .compass = {
-       .get_slave_descr = get_compass_slave_descr,
-       .adapt_num   = 2,
-       .bus         = EXT_SLAVE_BUS_PRIMARY,
-       .address     = 0x0C,
-       .orientation = { 1, 0, 0, 0, 1, 0, 0, 0, 1 },  /* Orientation matrix for AKM on cardhu */
-       },
+#if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
+static struct ext_slave_platform_data mpu_accel_data = {
+       .address        = MPU_ACCEL_ADDR,
+       .irq            = 0,
+       .adapt_num      = MPU_ACCEL_BUS_NUM,
+       .bus            = EXT_SLAVE_BUS_SECONDARY,
+       .orientation    = MPU_ACCEL_ORIENTATION,        /* Located in board_[platformname].h    */
+};
+#endif
+
+static struct ext_slave_platform_data mpu_compass_data = {
+       .address        = MPU_COMPASS_ADDR,
+       .irq            = 0,
+       .adapt_num      = MPU_COMPASS_BUS_NUM,
+       .bus            = EXT_SLAVE_BUS_PRIMARY,
+       .orientation    = MPU_COMPASS_ORIENTATION,      /* Located in board_[platformname].h    */
 };
 
-static struct i2c_board_info __initdata mpu3050_i2c0_boardinfo[] = {
+static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
        {
-               I2C_BOARD_INFO(SENSOR_MPU_NAME, 0x68),
-               .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PX1),
-               .platform_data = &mpu3050_data,
+               I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
+               .irq = TEGRA_GPIO_TO_IRQ(MPU_GYRO_IRQ_GPIO),
+               .platform_data = &mpu_gyro_data,
+       },
+#if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
+       {
+               I2C_BOARD_INFO(MPU_ACCEL_NAME, MPU_ACCEL_ADDR),
+#if    MPU_ACCEL_IRQ_GPIO
+               .irq = TEGRA_GPIO_TO_IRQ(MPU_ACCEL_IRQ_GPIO),
+#endif
+               .platform_data = &mpu_accel_data,
+       },
+#endif
+       {
+               I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
+#if    MPU_COMPASS_IRQ_GPIO
+               .irq = TEGRA_GPIO_TO_IRQ(MPU_COMPASS_IRQ_GPIO),
+#endif
+               .platform_data = &mpu_compass_data,
        },
 };
 
-static void cardhu_mpuirq_init(void)
+static void mpuirq_init(void)
 {
-       pr_info("*** MPU START *** cardhu_mpuirq_init...\n");
-       tegra_gpio_enable(TEGRA_GPIO_PX1);
-       gpio_request(TEGRA_GPIO_PX1, SENSOR_MPU_NAME);
-       gpio_direction_input(TEGRA_GPIO_PX1);
-       pr_info("*** MPU END *** cardhu_mpuirq_init...\n");
-
-       i2c_register_board_info(2, mpu3050_i2c0_boardinfo,
-               ARRAY_SIZE(mpu3050_i2c0_boardinfo));
-}
+       int ret = 0;
+
+       pr_info("*** MPU START *** mpuirq_init...\n");
+
+#if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
+#if    MPU_ACCEL_IRQ_GPIO
+       /* ACCEL-IRQ assignment */
+       ret = gpio_request(MPU_ACCEL_IRQ_GPIO, MPU_ACCEL_NAME);
+       if (ret < 0) {
+               pr_err("%s: gpio_request failed %d\n", __func__, ret);
+               return;
+       }
+
+       ret = gpio_direction_input(MPU_ACCEL_IRQ_GPIO);
+       if (ret < 0) {
+               pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
+               gpio_free(MPU_ACCEL_IRQ_GPIO);
+               return;
+       }
+#endif
 #endif
 
+       /* MPU-IRQ assignment */
+       ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
+       if (ret < 0) {
+               pr_err("%s: gpio_request failed %d\n", __func__, ret);
+               return;
+       }
+
+       ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
+       if (ret < 0) {
+               pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
+               gpio_free(MPU_GYRO_IRQ_GPIO);
+               return;
+       }
+       pr_info("*** MPU END *** mpuirq_init...\n");
+
+       i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
+               ARRAY_SIZE(inv_mpu_i2c2_board_info));
+}
 
 static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
        {
@@ -772,6 +1175,12 @@ static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
        }
 };
 
+static struct i2c_board_info cardhu_i2c2_ltr_board_info[] = {
+       {
+               I2C_BOARD_INFO("LTR_558ALS", 0x23),
+       }
+};
+
 int __init cardhu_sensors_init(void)
 {
        int err;
@@ -781,11 +1190,13 @@ int __init cardhu_sensors_init(void)
        cardhu_camera_init();
        cam_tca6416_init();
 
-       i2c_register_board_info(2, cardhu_i2c3_board_info,
-               ARRAY_SIZE(cardhu_i2c3_board_info));
+       if (board_info.board_id != BOARD_PM315) {
+               i2c_register_board_info(2, cardhu_i2c3_board_info,
+                       ARRAY_SIZE(cardhu_i2c3_board_info));
 
-       i2c_register_board_info(2, cardhu_i2c_board_info_tps61050,
-               ARRAY_SIZE(cardhu_i2c_board_info_tps61050));
+               i2c_register_board_info(2, cardhu_i2c_board_info_tps61050,
+                       ARRAY_SIZE(cardhu_i2c_board_info_tps61050));
+       }
 
 #ifdef CONFIG_VIDEO_OV14810
        /* This is disabled by default; To enable this change Kconfig;
@@ -798,12 +1209,23 @@ int __init cardhu_sensors_init(void)
 #else
        /* Left  camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
         * Front camera is on BUS2 */
-       i2c_register_board_info(PCA954x_I2C_BUS0, cardhu_i2c6_board_info,
-               ARRAY_SIZE(cardhu_i2c6_board_info));
-
-       i2c_register_board_info(PCA954x_I2C_BUS1, cardhu_i2c7_board_info,
-               ARRAY_SIZE(cardhu_i2c7_board_info));
-
+       if (board_info.board_id != BOARD_PM269) {
+               i2c_register_board_info(PCA954x_I2C_BUS0,
+                                       cardhu_i2c6_board_info,
+                                       ARRAY_SIZE(cardhu_i2c6_board_info));
+
+               i2c_register_board_info(PCA954x_I2C_BUS1,
+                                       cardhu_i2c7_board_info,
+                                       ARRAY_SIZE(cardhu_i2c7_board_info));
+       } else {
+               i2c_register_board_info(PCA954x_I2C_BUS0,
+                                       pm269_i2c6_board_info,
+                                       ARRAY_SIZE(pm269_i2c6_board_info));
+
+               i2c_register_board_info(PCA954x_I2C_BUS1,
+                                       pm269_i2c7_board_info,
+                                       ARRAY_SIZE(pm269_i2c7_board_info));
+       }
        i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
                ARRAY_SIZE(cardhu_i2c8_board_info));
 
@@ -814,8 +1236,12 @@ int __init cardhu_sensors_init(void)
                i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
                        ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
 
-       i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
-               ARRAY_SIZE(cardhu_i2c2_isl_board_info));
+       if (board_info.sku == BOARD_SKU_B11)
+               i2c_register_board_info(2, cardhu_i2c2_ltr_board_info,
+                       ARRAY_SIZE(cardhu_i2c2_ltr_board_info));
+       else if (board_info.board_id != BOARD_PM315)
+               i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
+                       ARRAY_SIZE(cardhu_i2c2_isl_board_info));
 
        err = cardhu_nct1008_init();
        if (err)
@@ -824,13 +1250,23 @@ int __init cardhu_sensors_init(void)
        i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
                ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
 
-#ifdef CONFIG_MPU_SENSORS_MPU3050
-       cardhu_mpuirq_init();
+       if (board_info.board_id != BOARD_PM315)
+               mpuirq_init();
+
+#if defined(CONFIG_SOC_CAMERA_OV5650) \
+       || defined(CONFIG_SOC_CAMERA_OV5650_MODULE)
+       platform_device_register(&cardhu_ov5650_soc_camera_device);
 #endif
+#if defined(CONFIG_SOC_CAMERA_OV5640) \
+       || defined(CONFIG_SOC_CAMERA_OV5640_MODULE)
+       platform_device_register(&cardhu_ov5640_soc_camera_device);
+#endif
+
        return 0;
 }
 
 #if defined(CONFIG_GPIO_PCA953X)
+#if defined(CONFIG_VIDEO_OV5650) || defined(CONFIG_VIDEO_OV5650_MODULE)
 struct ov5650_gpios {
        const char *name;
        int gpio;
@@ -871,19 +1307,20 @@ int __init cardhu_ov5650_late_init(void)
                return 0;
 
        if ((board_info.board_id == BOARD_E1198) ||
-               (board_info.board_id == BOARD_E1291))
+               (board_info.board_id == BOARD_E1291) ||
+               (board_info.board_id == BOARD_PM315))
                return 0;
 
-       printk("%s: \n", __func__);
+       printk(KERN_INFO "%s:\n", __func__);
        for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
                ret = gpio_request(ov5650_gpio_keys[i].gpio,
                        ov5650_gpio_keys[i].name);
                if (ret < 0) {
-                       printk("%s: gpio_request failed for gpio #%d\n",
+                       printk(KERN_INFO "%s: gpio_request failed for gpio #%d\n",
                                __func__, i);
                        goto fail;
                }
-               printk("%s: enable - %d\n", __func__, i);
+               printk(KERN_INFO "%s: enable - %d\n", __func__, i);
                gpio_direction_output(ov5650_gpio_keys[i].gpio,
                        ov5650_gpio_keys[i].enabled);
                gpio_export(ov5650_gpio_keys[i].gpio, false);
@@ -899,3 +1336,4 @@ fail:
 
 late_initcall(cardhu_ov5650_late_init);
 #endif
+#endif