From b6bcf393d1910426cd4c8f3aae77351c393a00b0 Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Tue, 11 Sep 2012 18:15:57 -0500
Subject: [PATCH] panda: more thermal bandgap fixes

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 patch.sh                                      |  13 +-
 .../0001-panda-fix-wl12xx-regulator.patch     |   6 +-
 ...02-ti-st-st-kim-fixing-firmware-path.patch |   2 +-
 ...ermal-Correct-checkpatch.pl-warnings.patch |  58 +++++++
 ...rmal-remove-checkpatch.pl-warnings-o.patch | 149 ++++++++++++++++++
 ...-thermal-fix-polling-period-settings.patch |  35 ++++
 ...rmal-improve-conf-data-handling-and-.patch | 132 ++++++++++++++++
 version.sh                                    |   2 +-
 8 files changed, 389 insertions(+), 8 deletions(-)
 create mode 100644 patches/panda/0003-staging-omap-thermal-Correct-checkpatch.pl-warnings.patch
 create mode 100644 patches/panda/0004-staging-omap-thermal-remove-checkpatch.pl-warnings-o.patch
 create mode 100644 patches/panda/0005-staging-omap-thermal-fix-polling-period-settings.patch
 create mode 100644 patches/panda/0006-staging-omap-thermal-improve-conf-data-handling-and-.patch

diff --git a/patch.sh b/patch.sh
index bc663c3dc..4df282e3c 100644
--- a/patch.sh
+++ b/patch.sh
@@ -22,8 +22,8 @@
 
 # Split out, so build_kernel.sh and build_deb.sh can share..
 
-git="git am"
-#git="git am --whitespace=fix"
+#git="git am"
+git="git am --whitespace=fix"
 
 if [ -f ${DIR}/system.sh ] ; then
 	source ${DIR}/system.sh
@@ -41,7 +41,7 @@ git_add () {
 }
 
 cleanup () {
-	git format-patch -4 -o ${DIR}/patches/
+	git format-patch -6 -o ${DIR}/patches/
 	exit
 }
 
@@ -96,6 +96,13 @@ panda () {
 	${git} "${DIR}/patches/panda/0001-panda-fix-wl12xx-regulator.patch"
 	#Status: unknown: cherry picked from linaro
 	${git} "${DIR}/patches/panda/0002-ti-st-st-kim-fixing-firmware-path.patch"
+
+	#Status: https://lkml.org/lkml/2012/9/11/303
+	${git} "${DIR}/patches/panda/0003-staging-omap-thermal-Correct-checkpatch.pl-warnings.patch"
+	${git} "${DIR}/patches/panda/0004-staging-omap-thermal-remove-checkpatch.pl-warnings-o.patch"
+	${git} "${DIR}/patches/panda/0005-staging-omap-thermal-fix-polling-period-settings.patch"
+	${git} "${DIR}/patches/panda/0006-staging-omap-thermal-improve-conf-data-handling-and-.patch"
+	cleanup
 }
 
 omap_fixes () {
diff --git a/patches/panda/0001-panda-fix-wl12xx-regulator.patch b/patches/panda/0001-panda-fix-wl12xx-regulator.patch
index eea8516eb..782056943 100644
--- a/patches/panda/0001-panda-fix-wl12xx-regulator.patch
+++ b/patches/panda/0001-panda-fix-wl12xx-regulator.patch
@@ -1,7 +1,7 @@
 From c008a1eb2ab9db6684f07355c2c6695a3c45a748 Mon Sep 17 00:00:00 2001
 From: Robert Nelson <robertcnelson@gmail.com>
 Date: Tue, 2 Aug 2011 21:55:34 -0500
-Subject: [PATCH 1/5] panda: fix wl12xx regulator
+Subject: [PATCH 1/6] panda: fix wl12xx regulator
 
 pulled from: http://elinux.org/Panda_How_to_kernel_3_0_rel
 
@@ -11,10 +11,10 @@ Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
  1 file changed, 1 insertion(+)
 
 diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
-index 43a9790..3e04aad 100644
+index db5ff66..50ab9ea 100644
 --- a/arch/arm/mach-omap2/twl-common.c
 +++ b/arch/arm/mach-omap2/twl-common.c
-@@ -376,6 +376,7 @@ static struct regulator_init_data omap4_vusb_idata = {
+@@ -375,6 +375,7 @@ static struct regulator_init_data omap4_vusb_idata = {
  static struct regulator_init_data omap4_clk32kg_idata = {
  	.constraints = {
  		.valid_ops_mask		= REGULATOR_CHANGE_STATUS,
diff --git a/patches/panda/0002-ti-st-st-kim-fixing-firmware-path.patch b/patches/panda/0002-ti-st-st-kim-fixing-firmware-path.patch
index e3d1aa36a..a61bbecbd 100644
--- a/patches/panda/0002-ti-st-st-kim-fixing-firmware-path.patch
+++ b/patches/panda/0002-ti-st-st-kim-fixing-firmware-path.patch
@@ -1,7 +1,7 @@
 From 0044b7229d0738c6ed61ba5f73ee3029d927fa34 Mon Sep 17 00:00:00 2001
 From: Ricardo Salveti de Araujo <ricardo.salveti@linaro.org>
 Date: Tue, 25 Oct 2011 10:06:39 +0200
-Subject: [PATCH 2/5] ti-st/st-kim: fixing firmware path
+Subject: [PATCH 2/6] ti-st/st-kim: fixing firmware path
 
 Signed-off-by: Ricardo Salveti de Araujo <ricardo.salveti@linaro.org>
 Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
diff --git a/patches/panda/0003-staging-omap-thermal-Correct-checkpatch.pl-warnings.patch b/patches/panda/0003-staging-omap-thermal-Correct-checkpatch.pl-warnings.patch
new file mode 100644
index 000000000..4bd90a0fa
--- /dev/null
+++ b/patches/panda/0003-staging-omap-thermal-Correct-checkpatch.pl-warnings.patch
@@ -0,0 +1,58 @@
+From 907cfffa6e6c01a8827b25083ffea5fa92144d44 Mon Sep 17 00:00:00 2001
+From: J Keerthy <j-keerthy@ti.com>
+Date: Tue, 11 Sep 2012 19:06:52 +0300
+Subject: [PATCH 3/6] staging: omap-thermal: Correct checkpatch.pl warnings
+
+Removes checkpatch warnings on omap-bandgap.c.
+
+Signed-off-by: J Keerthy <j-keerthy@ti.com>
+Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
+---
+ drivers/staging/omap-thermal/omap-bandgap.c |   15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
+index c556abb..9ef44ea 100644
+--- a/drivers/staging/omap-thermal/omap-bandgap.c
++++ b/drivers/staging/omap-thermal/omap-bandgap.c
+@@ -1037,20 +1037,20 @@ static int omap_bandgap_save_ctxt(struct omap_bandgap *bg_ptr)
+ 
+ 		if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
+ 			rval->bg_mode_ctrl = omap_bandgap_readl(bg_ptr,
+-								tsr->bgap_mode_ctrl);
++							tsr->bgap_mode_ctrl);
+ 		if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ 			rval->bg_counter = omap_bandgap_readl(bg_ptr,
+-							      tsr->bgap_counter);
++							tsr->bgap_counter);
+ 		if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+ 			rval->bg_threshold = omap_bandgap_readl(bg_ptr,
+-								tsr->bgap_threshold);
++							tsr->bgap_threshold);
+ 			rval->bg_ctrl = omap_bandgap_readl(bg_ptr,
+-							   tsr->bgap_mask_ctrl);
++						   tsr->bgap_mask_ctrl);
+ 		}
+ 
+ 		if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG))
+ 			rval->tshut_threshold = omap_bandgap_readl(bg_ptr,
+-								   tsr->tshut_threshold);
++						   tsr->tshut_threshold);
+ 	}
+ 
+ 	return 0;
+@@ -1074,8 +1074,9 @@ static int omap_bandgap_restore_ctxt(struct omap_bandgap *bg_ptr)
+ 
+ 		if (val == 0) {
+ 			if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG))
+-				omap_bandgap_writel(bg_ptr, rval->tshut_threshold,
+-							   tsr->tshut_threshold);
++				omap_bandgap_writel(bg_ptr,
++					rval->tshut_threshold,
++						   tsr->tshut_threshold);
+ 			/* Force immediate temperature measurement and update
+ 			 * of the DTEMP field
+ 			 */
+-- 
+1.7.10.4
+
diff --git a/patches/panda/0004-staging-omap-thermal-remove-checkpatch.pl-warnings-o.patch b/patches/panda/0004-staging-omap-thermal-remove-checkpatch.pl-warnings-o.patch
new file mode 100644
index 000000000..e74cc78cc
--- /dev/null
+++ b/patches/panda/0004-staging-omap-thermal-remove-checkpatch.pl-warnings-o.patch
@@ -0,0 +1,149 @@
+From b976f2ca85ccc9e516840d9d5c3a7ab940b31072 Mon Sep 17 00:00:00 2001
+From: Eduardo Valentin <eduardo.valentin@TI.COM>
+Date: Tue, 11 Sep 2012 19:06:53 +0300
+Subject: [PATCH 4/6] staging: omap-thermal: remove checkpatch.pl warnings on
+ data files
+
+Simple checkpatch.pl clean ups.
+
+Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
+---
+ drivers/staging/omap-thermal/omap4-thermal.c |   54 +++++++++++++-------------
+ drivers/staging/omap-thermal/omap5-thermal.c |   38 +++++++++---------
+ 2 files changed, 46 insertions(+), 46 deletions(-)
+
+diff --git a/drivers/staging/omap-thermal/omap4-thermal.c b/drivers/staging/omap-thermal/omap4-thermal.c
+index fa9dbcd..04c02b6 100644
+--- a/drivers/staging/omap-thermal/omap4-thermal.c
++++ b/drivers/staging/omap-thermal/omap4-thermal.c
+@@ -77,15 +77,15 @@ const struct omap_bandgap_data omap4430_data = {
+ 	.remove_sensor = omap_thermal_remove_sensor,
+ 	.sensors = {
+ 		{
+-			.registers = &omap4430_mpu_temp_sensor_registers,
+-			.ts_data = &omap4430_mpu_temp_sensor_data,
+-			.domain = "cpu",
+-			.slope = 0,
+-			.constant = 20000,
+-			.slope_pcb = 0,
+-			.constant_pcb = 20000,
+-			.register_cooling = omap_thermal_register_cpu_cooling,
+-			.unregister_cooling = omap_thermal_unregister_cpu_cooling,
++		.registers = &omap4430_mpu_temp_sensor_registers,
++		.ts_data = &omap4430_mpu_temp_sensor_data,
++		.domain = "cpu",
++		.slope = 0,
++		.constant = 20000,
++		.slope_pcb = 0,
++		.constant_pcb = 20000,
++		.register_cooling = omap_thermal_register_cpu_cooling,
++		.unregister_cooling = omap_thermal_unregister_cpu_cooling,
+ 		},
+ 	},
+ 	.sensor_count = 1,
+@@ -215,15 +215,15 @@ const struct omap_bandgap_data omap4460_data = {
+ 	.remove_sensor = omap_thermal_remove_sensor,
+ 	.sensors = {
+ 		{
+-			.registers = &omap4460_mpu_temp_sensor_registers,
+-			.ts_data = &omap4460_mpu_temp_sensor_data,
+-			.domain = "cpu",
+-			.slope = OMAP_GRADIENT_SLOPE_4460,
+-			.constant = OMAP_GRADIENT_CONST_4460,
+-			.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4460,
+-			.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4460,
+-			.register_cooling = omap_thermal_register_cpu_cooling,
+-			.unregister_cooling = omap_thermal_unregister_cpu_cooling,
++		.registers = &omap4460_mpu_temp_sensor_registers,
++		.ts_data = &omap4460_mpu_temp_sensor_data,
++		.domain = "cpu",
++		.slope = OMAP_GRADIENT_SLOPE_4460,
++		.constant = OMAP_GRADIENT_CONST_4460,
++		.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4460,
++		.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4460,
++		.register_cooling = omap_thermal_register_cpu_cooling,
++		.unregister_cooling = omap_thermal_unregister_cpu_cooling,
+ 		},
+ 	},
+ 	.sensor_count = 1,
+@@ -244,15 +244,15 @@ const struct omap_bandgap_data omap4470_data = {
+ 	.remove_sensor = omap_thermal_remove_sensor,
+ 	.sensors = {
+ 		{
+-			.registers = &omap4460_mpu_temp_sensor_registers,
+-			.ts_data = &omap4460_mpu_temp_sensor_data,
+-			.domain = "cpu",
+-			.slope = OMAP_GRADIENT_SLOPE_4470,
+-			.constant = OMAP_GRADIENT_CONST_4470,
+-			.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4470,
+-			.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4470,
+-			.register_cooling = omap_thermal_register_cpu_cooling,
+-			.unregister_cooling = omap_thermal_unregister_cpu_cooling,
++		.registers = &omap4460_mpu_temp_sensor_registers,
++		.ts_data = &omap4460_mpu_temp_sensor_data,
++		.domain = "cpu",
++		.slope = OMAP_GRADIENT_SLOPE_4470,
++		.constant = OMAP_GRADIENT_CONST_4470,
++		.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4470,
++		.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4470,
++		.register_cooling = omap_thermal_register_cpu_cooling,
++		.unregister_cooling = omap_thermal_unregister_cpu_cooling,
+ 		},
+ 	},
+ 	.sensor_count = 1,
+diff --git a/drivers/staging/omap-thermal/omap5-thermal.c b/drivers/staging/omap-thermal/omap5-thermal.c
+index 0658af2..2f3a498 100644
+--- a/drivers/staging/omap-thermal/omap5-thermal.c
++++ b/drivers/staging/omap-thermal/omap5-thermal.c
+@@ -268,29 +268,29 @@ const struct omap_bandgap_data omap5430_data = {
+ 	.remove_sensor = omap_thermal_remove_sensor,
+ 	.sensors = {
+ 		{
+-			.registers = &omap5430_mpu_temp_sensor_registers,
+-			.ts_data = &omap5430_mpu_temp_sensor_data,
+-			.domain = "cpu",
+-			.register_cooling = omap_thermal_register_cpu_cooling,
+-			.unregister_cooling = omap_thermal_unregister_cpu_cooling,
+-			.slope = OMAP_GRADIENT_SLOPE_5430_CPU,
+-			.constant = OMAP_GRADIENT_CONST_5430_CPU,
+-			.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_CPU,
+-			.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_CPU,
++		.registers = &omap5430_mpu_temp_sensor_registers,
++		.ts_data = &omap5430_mpu_temp_sensor_data,
++		.domain = "cpu",
++		.register_cooling = omap_thermal_register_cpu_cooling,
++		.unregister_cooling = omap_thermal_unregister_cpu_cooling,
++		.slope = OMAP_GRADIENT_SLOPE_5430_CPU,
++		.constant = OMAP_GRADIENT_CONST_5430_CPU,
++		.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_CPU,
++		.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_CPU,
+ 		},
+ 		{
+-			.registers = &omap5430_gpu_temp_sensor_registers,
+-			.ts_data = &omap5430_gpu_temp_sensor_data,
+-			.domain = "gpu",
+-			.slope = OMAP_GRADIENT_SLOPE_5430_GPU,
+-			.constant = OMAP_GRADIENT_CONST_5430_GPU,
+-			.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU,
+-			.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_GPU,
++		.registers = &omap5430_gpu_temp_sensor_registers,
++		.ts_data = &omap5430_gpu_temp_sensor_data,
++		.domain = "gpu",
++		.slope = OMAP_GRADIENT_SLOPE_5430_GPU,
++		.constant = OMAP_GRADIENT_CONST_5430_GPU,
++		.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU,
++		.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_GPU,
+ 		},
+ 		{
+-			.registers = &omap5430_core_temp_sensor_registers,
+-			.ts_data = &omap5430_core_temp_sensor_data,
+-			.domain = "core",
++		.registers = &omap5430_core_temp_sensor_registers,
++		.ts_data = &omap5430_core_temp_sensor_data,
++		.domain = "core",
+ 		},
+ 	},
+ 	.sensor_count = 3,
+-- 
+1.7.10.4
+
diff --git a/patches/panda/0005-staging-omap-thermal-fix-polling-period-settings.patch b/patches/panda/0005-staging-omap-thermal-fix-polling-period-settings.patch
new file mode 100644
index 000000000..bea42a709
--- /dev/null
+++ b/patches/panda/0005-staging-omap-thermal-fix-polling-period-settings.patch
@@ -0,0 +1,35 @@
+From 34113008eca849e7778b24823fa200bfced4febc Mon Sep 17 00:00:00 2001
+From: Eduardo Valentin <eduardo.valentin@ti.com>
+Date: Tue, 11 Sep 2012 19:06:54 +0300
+Subject: [PATCH 5/6] staging: omap-thermal: fix polling period settings
+
+While registering the omap thermal zones we need to
+properly specify TC1 and TC2, as long as the proper
+passive polling period and monitor period.
+
+This patch fixes the parameters passed while registering
+the thermal zone.
+
+Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
+---
+ drivers/staging/omap-thermal/omap-thermal-common.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c b/drivers/staging/omap-thermal/omap-thermal-common.c
+index 0675a5e..d156424 100644
+--- a/drivers/staging/omap-thermal/omap-thermal-common.c
++++ b/drivers/staging/omap-thermal/omap-thermal-common.c
+@@ -246,7 +246,9 @@ int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
+ 	/* Create thermal zone */
+ 	data->omap_thermal = thermal_zone_device_register(domain,
+ 				OMAP_TRIP_NUMBER, 0, data, &omap_thermal_ops,
+-				0, FAST_TEMP_MONITORING_RATE, 0, 0);
++				1, 2, /*TODO: remove this when FW allows */
++				FAST_TEMP_MONITORING_RATE,
++				FAST_TEMP_MONITORING_RATE);
+ 	if (IS_ERR_OR_NULL(data->omap_thermal)) {
+ 		dev_err(bg_ptr->dev, "thermal zone device is NULL\n");
+ 		return PTR_ERR(data->omap_thermal);
+-- 
+1.7.10.4
+
diff --git a/patches/panda/0006-staging-omap-thermal-improve-conf-data-handling-and-.patch b/patches/panda/0006-staging-omap-thermal-improve-conf-data-handling-and-.patch
new file mode 100644
index 000000000..7d00fda78
--- /dev/null
+++ b/patches/panda/0006-staging-omap-thermal-improve-conf-data-handling-and-.patch
@@ -0,0 +1,132 @@
+From b167919d1aa9ca4ad516e83a46cb078f1b0c4f35 Mon Sep 17 00:00:00 2001
+From: Eduardo Valentin <eduardo.valentin@ti.com>
+Date: Tue, 11 Sep 2012 19:06:55 +0300
+Subject: [PATCH 6/6] staging: omap-thermal: improve conf data handling and
+ initialization
+
+While registering the thermal zone, it is required to have the cooling
+devices already setup, so that the .bind callback can succeed.
+
+Due to that, the driver code needs to be reorganized so that we first
+setup the cooling devices then the zones. This way we cope with the
+right thermal framework initialization sequence.
+
+This patch changes the order of the thermal zone initialization,
+so that we create it only when the cooling devices are available.
+It also adds some defensive checks for the config data, so that
+the callbacks are ready for calls when the data is still not
+initialized.
+
+Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
+---
+ drivers/staging/omap-thermal/omap-bandgap.c        |    6 ++--
+ drivers/staging/omap-thermal/omap-thermal-common.c |   38 +++++++++++++++++---
+ 2 files changed, 36 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
+index 9ef44ea..ff93c15 100644
+--- a/drivers/staging/omap-thermal/omap-bandgap.c
++++ b/drivers/staging/omap-thermal/omap-bandgap.c
+@@ -953,12 +953,12 @@ int __devinit omap_bandgap_probe(struct platform_device *pdev)
+ 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ 		char *domain;
+ 
++		if (bg_ptr->conf->sensors[i].register_cooling)
++			bg_ptr->conf->sensors[i].register_cooling(bg_ptr, i);
++
+ 		domain = bg_ptr->conf->sensors[i].domain;
+ 		if (bg_ptr->conf->expose_sensor)
+ 			bg_ptr->conf->expose_sensor(bg_ptr, i, domain);
+-
+-		if (bg_ptr->conf->sensors[i].register_cooling)
+-			bg_ptr->conf->sensors[i].register_cooling(bg_ptr, i);
+ 	}
+ 
+ 	/*
+diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c b/drivers/staging/omap-thermal/omap-thermal-common.c
+index d156424..46ee0a9 100644
+--- a/drivers/staging/omap-thermal/omap-thermal-common.c
++++ b/drivers/staging/omap-thermal/omap-thermal-common.c
+@@ -77,10 +77,16 @@ static inline int omap_thermal_get_temp(struct thermal_zone_device *thermal,
+ 					 unsigned long *temp)
+ {
+ 	struct omap_thermal_data *data = thermal->devdata;
+-	struct omap_bandgap *bg_ptr = data->bg_ptr;
+-	struct omap_temp_sensor *s = &bg_ptr->conf->sensors[data->sensor_id];
++	struct omap_bandgap *bg_ptr;
++	struct omap_temp_sensor *s;
+ 	int ret, tmp, pcb_temp, slope, constant;
+ 
++	if (!data)
++		return 0;
++
++	bg_ptr = data->bg_ptr;
++	s = &bg_ptr->conf->sensors[data->sensor_id];
++
+ 	ret = omap_bandgap_read_temperature(bg_ptr, data->sensor_id, &tmp);
+ 	if (ret)
+ 		return ret;
+@@ -227,21 +233,37 @@ static struct thermal_zone_device_ops omap_thermal_ops = {
+ 	.get_crit_temp = omap_thermal_get_crit_temp,
+ };
+ 
+-int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
+-			       char *domain)
++static struct omap_thermal_data
++*omap_thermal_build_data(struct omap_bandgap *bg_ptr, int id)
+ {
+ 	struct omap_thermal_data *data;
+ 
+ 	data = devm_kzalloc(bg_ptr->dev, sizeof(*data), GFP_KERNEL);
+ 	if (!data) {
+ 		dev_err(bg_ptr->dev, "kzalloc fail\n");
+-		return -ENOMEM;
++		return NULL;
+ 	}
+ 	data->sensor_id = id;
+ 	data->bg_ptr = bg_ptr;
+ 	data->mode = THERMAL_DEVICE_ENABLED;
+ 	INIT_WORK(&data->thermal_wq, omap_thermal_work);
+ 
++	return data;
++}
++
++int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
++			       char *domain)
++{
++	struct omap_thermal_pdata pdata;
++
++	data = omap_bandgap_get_sensor_data(bg_ptr, id);
++
++	if (!data)
++		data = omap_thermal_build_pdata(bg_ptr, id);
++
++	if (!data)
++		return -EINVAL;
++
+ 	/* TODO: remove TC1 TC2 */
+ 	/* Create thermal zone */
+ 	data->omap_thermal = thermal_zone_device_register(domain,
+@@ -335,6 +357,11 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
+ 	int tab_size, ret;
+ 
+ 	data = omap_bandgap_get_sensor_data(bg_ptr, id);
++	if (!data)
++		data = omap_thermal_build_pdata(bg_ptr, id);
++
++	if (!data)
++		return -EINVAL;
+ 
+ 	ret = omap_thermal_build_cpufreq_clip(bg_ptr, &tab_ptr, &tab_size);
+ 	if (ret < 0) {
+@@ -351,6 +378,7 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
+ 		return PTR_ERR(data->cool_dev);
+ 	}
+ 	bg_ptr->conf->sensors[id].cooling_data.freq_clip_count = tab_size;
++	omap_bandgap_set_sensor_data(bg_ptr, id, data);
+ 
+ 	return 0;
+ }
+-- 
+1.7.10.4
+
diff --git a/version.sh b/version.sh
index be39fc1f8..4bfb8f47d 100644
--- a/version.sh
+++ b/version.sh
@@ -23,7 +23,7 @@ config="omap2plus_defconfig"
 #Kernel/Build
 KERNEL_REL=3.6
 KERNEL_TAG=${KERNEL_REL}-rc5
-BUILD=d2
+BUILD=d2.1
 
 #git branch
 #BRANCH=
-- 
GitLab