arm: tegra: cardhu: add support for PM315
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-sensors.c
index b4fd1a2..d90802d 100644 (file)
 #include <linux/i2c/pca954x.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/nct1008.h>
+#include <linux/gpio.h>
+
+#include <mach/gpio-tegra.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 <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"
+#include "devices.h"
 
 static struct regulator *cardhu_1v8_cam1 = NULL;
 static struct regulator *cardhu_1v8_cam2 = NULL;
@@ -86,7 +88,8 @@ 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)) {
+               (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",
@@ -130,15 +133,17 @@ static int cardhu_camera_init(void)
        return 0;
 }
 
-static int cardhu_left_ov5650_power_on(void)
+static int cardhu_left_ov5650_power_on(struct device *dev)
 {
        /* 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");
+                       cardhu_vdd_2v8_cam1 =
+                               regulator_get(dev, "vdd_2v8_cam1");
                        if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam1))) {
                                pr_err("%s: couldn't get regulator vdd_2v8_cam1: %ld\n",
                                        __func__, PTR_ERR(cardhu_vdd_2v8_cam1));
@@ -151,7 +156,7 @@ static int cardhu_left_ov5650_power_on(void)
 
        /* Enable VDD_1V8_Cam1 */
        if (cardhu_1v8_cam1 == NULL) {
-               cardhu_1v8_cam1 = regulator_get(NULL, "vdd_1v8_cam1");
+               cardhu_1v8_cam1 = regulator_get(dev, "vdd_1v8_cam1");
                if (WARN_ON(IS_ERR(cardhu_1v8_cam1))) {
                        pr_err("%s: couldn't get regulator vdd_1v8_cam1: %ld\n",
                                __func__, PTR_ERR(cardhu_1v8_cam1));
@@ -162,7 +167,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);
@@ -192,12 +198,13 @@ reg_alloc_fail:
 
 }
 
-static int cardhu_left_ov5650_power_off(void)
+static int cardhu_left_ov5650_power_off(struct device *dev)
 {
        /* 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);
@@ -271,7 +278,7 @@ static struct i2c_board_info cardhu_i2c_board_info_e1214[] = {
 };
 #endif
 
-static int cardhu_right_ov5650_power_on(void)
+static int cardhu_right_ov5650_power_on(struct device *dev)
 {
        /* CSI-B and front sensor are muxed on cardhu */
        gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
@@ -279,14 +286,16 @@ static int cardhu_right_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)) {
 
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
                mdelay(10);
 
                if (cardhu_vdd_2v8_cam2 == NULL) {
-                       cardhu_vdd_2v8_cam2 = regulator_get(NULL, "vdd_2v8_cam2");
+                       cardhu_vdd_2v8_cam2 =
+                               regulator_get(dev, "vdd_2v8_cam2");
                        if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam2))) {
                                pr_err("%s: couldn't get regulator vdd_2v8_cam2: %ld\n",
                                        __func__, PTR_ERR(cardhu_vdd_2v8_cam2));
@@ -299,7 +308,7 @@ static int cardhu_right_ov5650_power_on(void)
 
        /* Enable VDD_1V8_Cam2 */
        if (cardhu_1v8_cam2 == NULL) {
-               cardhu_1v8_cam2 = regulator_get(NULL, "vdd_1v8_cam2");
+               cardhu_1v8_cam2 = regulator_get(dev, "vdd_1v8_cam2");
                if (WARN_ON(IS_ERR(cardhu_1v8_cam2))) {
                        pr_err("%s: couldn't get regulator vdd_1v8_cam2: %ld\n",
                                __func__, PTR_ERR(cardhu_1v8_cam2));
@@ -332,15 +341,16 @@ reg_alloc_fail:
 
 }
 
-static int cardhu_right_ov5650_power_off(void)
+static int cardhu_right_ov5650_power_off(struct device *dev)
 {
        /* 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);
@@ -361,8 +371,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);
@@ -380,23 +390,29 @@ struct ov5650_platform_data cardhu_right_ov5650_data = {
        .synchronize_sensors = cardhu_ov5650_synchronize_sensors,
 };
 
-static int cardhu_ov2710_power_on(void)
+static int cardhu_ov2710_power_on(struct device *dev)
 {
        /* 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(dev, "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)) {
-
-               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);
-
+               (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");
+                       cardhu_vdd_cam3 = regulator_get(dev, "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));
@@ -404,19 +420,17 @@ static int cardhu_ov2710_power_on(void)
                        }
                }
                regulator_enable(cardhu_vdd_cam3);
-       }
 
-       /* 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;
-               }
+               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);
+
        }
-       regulator_enable(cardhu_1v8_cam3);
-       mdelay(5);
+
+       mdelay(20);
 
        return 0;
 
@@ -433,7 +447,7 @@ reg_alloc_fail:
        return -ENODEV;
 }
 
-static int cardhu_ov2710_power_off(void)
+static int cardhu_ov2710_power_off(struct device *dev)
 {
        /* CSI-B and front sensor are muxed on cardhu */
        gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
@@ -441,16 +455,17 @@ static int cardhu_ov2710_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);
+               if (cardhu_vdd_cam3)
+                       regulator_disable(cardhu_vdd_cam3);
        }
 
        if (cardhu_1v8_cam3)
                regulator_disable(cardhu_1v8_cam3);
-       if (cardhu_vdd_cam3)
-               regulator_disable(cardhu_vdd_cam3);
 
        return 0;
 }
@@ -460,7 +475,7 @@ struct ov2710_platform_data cardhu_ov2710_data = {
        .power_off = cardhu_ov2710_power_off,
 };
 
-static int cardhu_ov5640_power_on(void)
+static int cardhu_ov5640_power_on(struct device *dev)
 {
        /* CSI-B and front sensor are muxed on cardhu */
        gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
@@ -468,7 +483,8 @@ static int cardhu_ov5640_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)) {
 
                gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
                gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
@@ -476,7 +492,7 @@ static int cardhu_ov5640_power_on(void)
                mdelay(10);
 
                if (cardhu_vdd_cam3 == NULL) {
-                       cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
+                       cardhu_vdd_cam3 = regulator_get(dev, "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));
@@ -488,7 +504,7 @@ static int cardhu_ov5640_power_on(void)
 
        /* Enable VDD_1V8_Cam3 */
        if (cardhu_1v8_cam3 == NULL) {
-               cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
+               cardhu_1v8_cam3 = regulator_get(dev, "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));
@@ -513,7 +529,7 @@ reg_alloc_fail:
        return -ENODEV;
 }
 
-static int cardhu_ov5640_power_off(void)
+static int cardhu_ov5640_power_off(struct device *dev)
 {
        /* CSI-B and front sensor are muxed on cardhu */
        gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
@@ -521,7 +537,8 @@ static int cardhu_ov5640_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);
@@ -596,6 +613,54 @@ static struct sh532u_platform_data pm269_sh532u_right_pdata = {
        .gpio           = pm269_sh532u_right_gpio_pdata,
 };
 
+static struct nvc_gpio_pdata ad5816_gpio_pdata[] = {
+       { AD5816_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
+};
+
+static struct ad5816_platform_data ad5816_left_pdata = {
+       .cfg            = 0,
+       .num            = 1,
+       .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*/
@@ -623,6 +688,10 @@ static struct i2c_board_info cardhu_i2c6_board_info[] = {
                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[] = {
@@ -634,6 +703,10 @@ static struct i2c_board_info cardhu_i2c7_board_info[] = {
                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[] = {
@@ -645,6 +718,10 @@ static struct i2c_board_info pm269_i2c6_board_info[] = {
                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[] = {
@@ -656,6 +733,10 @@ static struct i2c_board_info pm269_i2c7_board_info[] = {
                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[] = {
@@ -669,71 +750,40 @@ static struct i2c_board_info cardhu_i2c8_board_info[] = {
        },
 };
 
-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);
-}
-
-static void nct1008_probe_callback(struct nct1008_data *data)
-{
-       struct tegra_thermal_device *thermal_device;
-
-       thermal_device = kzalloc(sizeof(struct tegra_thermal_device),
-                                       GFP_KERNEL);
-       if (!thermal_device) {
-               pr_err("unable to allocate thermal device\n");
-               return;
-       }
-
-       thermal_device->name = "nct1008";
-       thermal_device->data = data;
-       thermal_device->offset = TDIODE_OFFSET;
-       thermal_device->get_temp = nct_get_temp;
-       thermal_device->get_temp_low = nct_get_temp_low;
-       thermal_device->set_limits = nct_set_limits;
-       thermal_device->set_alert = nct_set_alert;
-       thermal_device->set_shutdown_temp = nct_set_shutdown_temp;
-
-       tegra_thermal_set_device(thermal_device);
-}
+static struct balanced_throttle tj_throttle = {
+       .throt_tab_size = 10,
+       .throt_tab = {
+               {      0, 1000 },
+               { 640000, 1000 },
+               { 640000, 1000 },
+               { 640000, 1000 },
+               { 640000, 1000 },
+               { 640000, 1000 },
+               { 760000, 1000 },
+               { 760000, 1050 },
+               {1000000, 1050 },
+               {1000000, 1100 },
+       },
+};
 
 static struct nct1008_platform_data cardhu_nct1008_pdata = {
        .supported_hwrev = true,
        .ext_range = true,
        .conv_rate = 0x08,
        .offset = 8, /* 4 * 2C. Bug 844025 - 1C for device accuracies */
-       .probe_callback = nct1008_probe_callback,
+       .shutdown_ext_limit = 90, /* C */
+       .shutdown_local_limit = 100, /* C */
+
+       /* Thermal Throttling */
+       .passive = {
+               .create_cdev = (struct thermal_cooling_device *(*)(void *))
+                               balanced_throttle_register,
+               .cdev_data = &tj_throttle,
+               .trip_temp = 85000,
+               .tc1 = 0,
+               .tc2 = 1,
+               .passive_delay = 2000,
+       }
 };
 
 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
@@ -760,7 +810,8 @@ static int cardhu_nct1008_init(void)
                (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) ||
@@ -770,8 +821,31 @@ static int cardhu_nct1008_init(void)
        }
 
        if (nct1008_port >= 0) {
+#ifdef CONFIG_TEGRA_EDP_LIMITS
+               const struct tegra_edp_limits *cpu_edp_limits;
+               int cpu_edp_limits_size;
+               int i;
+
+               /* edp capping */
+               tegra_get_cpu_edp_limits(&cpu_edp_limits, &cpu_edp_limits_size);
+
+               if (cpu_edp_limits_size > MAX_THROT_TABLE_SIZE)
+                       BUG();
+
+               for (i = 0; i < cpu_edp_limits_size-1; i++) {
+                       cardhu_nct1008_pdata.active[i].create_cdev =
+                               (struct thermal_cooling_device *(*)(void *))
+                                       edp_cooling_device_create;
+                       cardhu_nct1008_pdata.active[i].cdev_data = (void *)i;
+                       cardhu_nct1008_pdata.active[i].trip_temp =
+                               cpu_edp_limits[i].temperature * 1000;
+                       cardhu_nct1008_pdata.active[i].hysteresis = 1000;
+               }
+               cardhu_nct1008_pdata.active[i].create_cdev = NULL;
+#endif
+
                /* FIXME: enable irq when throttling is supported */
-               cardhu_i2c4_nct1008_board_info[0].irq = TEGRA_GPIO_TO_IRQ(nct1008_port);
+               cardhu_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
 
                ret = gpio_request(nct1008_port, "temp_alert");
                if (ret < 0)
@@ -782,9 +856,91 @@ static int cardhu_nct1008_init(void)
                        gpio_free(nct1008_port);
        }
 
+       i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
+               ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
+
        return ret;
 }
 
+#ifdef CONFIG_TEGRA_SKIN_THROTTLE
+static int tegra_skin_match(struct thermal_zone_device *thz, void *data)
+{
+       return strcmp((char *)data, thz->type) == 0;
+}
+
+static int tegra_skin_get_temp(void *data, long *temp)
+{
+       struct thermal_zone_device *thz;
+
+       thz = thermal_zone_device_find(data, tegra_skin_match);
+
+       if (!thz || thz->ops->get_temp(thz, temp))
+               *temp = 25000;
+
+       return 0;
+}
+
+static struct therm_est_data skin_data = {
+       .toffset = 9793,
+       .polling_period = 1100,
+       .ndevs = 2,
+       .devs = {
+                       {
+                               .dev_data = "nct_ext",
+                               .get_temp = tegra_skin_get_temp,
+                               .coeffs = {
+                                       2, 1, 1, 1,
+                                       1, 1, 1, 1,
+                                       1, 1, 1, 0,
+                                       1, 1, 0, 0,
+                                       0, 0, -1, -7
+                               },
+                       },
+                       {
+                               .dev_data = "nct_int",
+                               .get_temp = tegra_skin_get_temp,
+                               .coeffs = {
+                                       -11, -7, -5, -3,
+                                       -3, -2, -1, 0,
+                                       0, 0, 1, 1,
+                                       1, 2, 2, 3,
+                                       4, 6, 11, 18
+                               },
+                       },
+       },
+       .trip_temp = 43000,
+       .tc1 = 1,
+       .tc2 = 15,
+       .passive_delay = 15000,
+};
+
+static struct balanced_throttle skin_throttle = {
+       .throt_tab_size = 6,
+       .throt_tab = {
+               { 640000, 1200 },
+               { 640000, 1200 },
+               { 760000, 1200 },
+               { 760000, 1200 },
+               {1000000, 1200 },
+               {1000000, 1200 },
+       },
+};
+
+static int __init cardhu_skin_init(void)
+{
+       struct thermal_cooling_device *skin_cdev;
+
+       skin_cdev = balanced_throttle_register(&skin_throttle);
+
+       skin_data.cdev = skin_cdev;
+       tegra_skin_therm_est_device.dev.platform_data = &skin_data;
+       platform_device_register(&tegra_skin_therm_est_device);
+
+       return 0;
+}
+late_initcall(cardhu_skin_init);
+#endif
+
 #if defined(CONFIG_GPIO_PCA953X)
 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
        .gpio_base      = PMU_TCA6416_GPIO_BASE,
@@ -846,56 +1002,34 @@ static int __init cam_tca6416_init(void)
 #endif
 
 /* 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    */
+       .sec_slave_type = SECONDARY_SLAVE_TYPE_ACCEL,
+       .sec_slave_id   = ACCEL_ID_KXTF9,
+       .secondary_i2c_addr     = MPU_ACCEL_ADDR,
+       .secondary_read_reg     = 0x06,
+       .secondary_orientation  = MPU_ACCEL_ORIENTATION,
+       .key            = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
+                          0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
 };
 
-#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 mpu_platform_data mpu_compass_data = {
+       .orientation    = MPU_COMPASS_ORIENTATION,
+       .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
 };
 
 static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
        {
                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,
        },
 };
@@ -903,10 +1037,10 @@ static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
 static void mpuirq_init(void)
 {
        int ret = 0;
+       int i = 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);
@@ -922,7 +1056,6 @@ static void mpuirq_init(void)
                return;
        }
 #endif
-#endif
 
        /* MPU-IRQ assignment */
        ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
@@ -939,6 +1072,14 @@ static void mpuirq_init(void)
        }
        pr_info("*** MPU END *** mpuirq_init...\n");
 
+       inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
+#if MPU_ACCEL_IRQ_GPIO
+       inv_mpu_i2c2_board_info[i].irq = gpio_to_irq(MPU_ACCEL_IRQ_GPIO);
+#endif
+       i++;
+#if MPU_COMPASS_IRQ_GPIO
+       inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_COMPAS_IRQ_GPIO);
+#endif
        i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
                ARRAY_SIZE(inv_mpu_i2c2_board_info));
 }
@@ -1011,7 +1152,7 @@ int __init cardhu_sensors_init(void)
        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
+       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));
 
@@ -1067,19 +1208,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);