linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer
@ 2012-11-26 13:47 Amit Daniel Kachhap
  2012-11-26 13:47 ` [PATCH V2 1/3] Thermal: exynos: Add support for temperature falling interrupt Amit Daniel Kachhap
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Amit Daniel Kachhap @ 2012-11-26 13:47 UTC (permalink / raw)
  To: linux-pm, Zhang Rui
  Cc: linux-samsung-soc, linux-kernel, amit.kachhap, jonghwa3.lee

Changes since V1: Used the new thermal trend type macro

The patch submitted by Jonghwa Lee (https://patchwork.kernel.org/patch/1683441/)
adds support for interrupt based notification to thermal layer. This is a good
feature but the current code need more fixes to support that feature so using 2 new thermal
trend type to implement this feature and some falling interrupt fixes.

All these patches are based on thermal maintainer thermal branch.
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git thermal

Amit Daniel Kachhap (2):
  thermal: exynos: Miscellaneous fixes to support falling threshold
    interrupt
  thermal: exynos: Use the new thermal trend type for quick cooling
    action.

Jonghwa Lee (1):
  Thermal: exynos: Add support for temperature falling interrupt.

 drivers/thermal/exynos_thermal.c             |  108 +++++++++++++++-----------
 include/linux/platform_data/exynos_thermal.h |    3 +
 2 files changed, 67 insertions(+), 44 deletions(-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH V2 1/3] Thermal: exynos: Add support for temperature falling interrupt.
  2012-11-26 13:47 [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer Amit Daniel Kachhap
@ 2012-11-26 13:47 ` Amit Daniel Kachhap
  2012-11-26 13:47 ` [PATCH V2 2/3] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt Amit Daniel Kachhap
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Amit Daniel Kachhap @ 2012-11-26 13:47 UTC (permalink / raw)
  To: linux-pm, Zhang Rui
  Cc: linux-samsung-soc, linux-kernel, amit.kachhap, jonghwa3.lee

From: Jonghwa Lee <jonghwa3.lee@samsung.com>

This patch introduces using temperature falling interrupt in exynos
thermal driver. Former patch, it only use polling way to check
whether if system themperature is fallen. However, exynos SOC also
provides temperature falling interrupt way to do same things by hw.
This feature is not supported in exynos4210.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
---
 drivers/thermal/exynos_thermal.c             |   81 +++++++++++++++-----------
 include/linux/platform_data/exynos_thermal.h |    3 +
 2 files changed, 49 insertions(+), 35 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index e2ef8a3..3b6c387 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -94,6 +94,7 @@
 #define SENSOR_NAME_LEN	16
 #define MAX_TRIP_COUNT	8
 #define MAX_COOLING_DEVICE 4
+#define MAX_THRESHOLD_LEVS 4
 
 #define ACTIVE_INTERVAL 500
 #define IDLE_INTERVAL 10000
@@ -133,6 +134,7 @@ struct exynos_tmu_data {
 struct	thermal_trip_point_conf {
 	int trip_val[MAX_TRIP_COUNT];
 	int trip_count;
+	u8 trigger_falling;
 };
 
 struct	thermal_cooling_conf {
@@ -182,7 +184,8 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 
 	mutex_lock(&th_zone->therm_dev->lock);
 
-	if (mode == THERMAL_DEVICE_ENABLED)
+	if (mode == THERMAL_DEVICE_ENABLED &&
+		!th_zone->sensor_conf->trip_data.trigger_falling)
 		th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
 	else
 		th_zone->therm_dev->polling_delay = 0;
@@ -421,7 +424,8 @@ static void exynos_report_trigger(void)
 			break;
 	}
 
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED) {
+	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
+		!th_zone->sensor_conf->trip_data.trigger_falling) {
 		if (i > 0)
 			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
 		else
@@ -460,7 +464,8 @@ static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name,
 			EXYNOS_ZONE_COUNT, 0, NULL, &exynos_dev_ops, NULL, 0,
-			IDLE_INTERVAL);
+			sensor_conf->trip_data.trigger_falling ?
+			0 : IDLE_INTERVAL);
 
 	if (IS_ERR(th_zone->therm_dev)) {
 		pr_err("Failed to register thermal zone device\n");
@@ -567,8 +572,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
 	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status, trim_info, rising_threshold;
-	int ret = 0, threshold_code;
+	unsigned int status, trim_info;
+	unsigned int rising_threshold = 0, falling_threshold = 0;
+	int ret = 0, threshold_code, i, trigger_levs = 0;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
@@ -593,6 +599,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			(data->temp_error2 != 0))
 		data->temp_error1 = pdata->efuse_value;
 
+	/* Count trigger levels to be enabled */
+	for (i = 0; i < MAX_THRESHOLD_LEVS; i++)
+		if (pdata->trigger_levels[i])
+			trigger_levs++;
+
 	if (data->soc == SOC_ARCH_EXYNOS4210) {
 		/* Write temperature code for threshold */
 		threshold_code = temp_to_code(data, pdata->threshold);
@@ -602,44 +613,38 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 		}
 		writeb(threshold_code,
 			data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
-
-		writeb(pdata->trigger_levels[0],
-			data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0);
-		writeb(pdata->trigger_levels[1],
-			data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL1);
-		writeb(pdata->trigger_levels[2],
-			data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL2);
-		writeb(pdata->trigger_levels[3],
-			data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL3);
+		for (i = 0; i < trigger_levs; i++)
+			writeb(pdata->trigger_levels[i],
+			data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
 
 		writel(EXYNOS4210_TMU_INTCLEAR_VAL,
 			data->base + EXYNOS_TMU_REG_INTCLEAR);
 	} else if (data->soc == SOC_ARCH_EXYNOS) {
-		/* Write temperature code for threshold */
-		threshold_code = temp_to_code(data, pdata->trigger_levels[0]);
-		if (threshold_code < 0) {
-			ret = threshold_code;
-			goto out;
-		}
-		rising_threshold = threshold_code;
-		threshold_code = temp_to_code(data, pdata->trigger_levels[1]);
-		if (threshold_code < 0) {
-			ret = threshold_code;
-			goto out;
-		}
-		rising_threshold |= (threshold_code << 8);
-		threshold_code = temp_to_code(data, pdata->trigger_levels[2]);
-		if (threshold_code < 0) {
-			ret = threshold_code;
-			goto out;
+		/* Write temperature code for rising and falling threshold */
+		for (i = 0; i < trigger_levs; i++) {
+			threshold_code = temp_to_code(data,
+						pdata->trigger_levels[i]);
+			if (threshold_code < 0) {
+				ret = threshold_code;
+				goto out;
+			}
+			rising_threshold |= threshold_code << 8 * i;
+			if (pdata->threshold_falling) {
+				threshold_code = temp_to_code(data,
+						pdata->trigger_levels[i] -
+						pdata->threshold_falling);
+				if (threshold_code > 0)
+					falling_threshold |=
+						threshold_code << 8 * i;
+			}
 		}
-		rising_threshold |= (threshold_code << 16);
 
 		writel(rising_threshold,
 				data->base + EXYNOS_THD_TEMP_RISE);
-		writel(0, data->base + EXYNOS_THD_TEMP_FALL);
+		writel(falling_threshold,
+				data->base + EXYNOS_THD_TEMP_FALL);
 
-		writel(EXYNOS_TMU_CLEAR_RISE_INT|EXYNOS_TMU_CLEAR_FALL_INT,
+		writel(EXYNOS_TMU_CLEAR_RISE_INT | EXYNOS_TMU_CLEAR_FALL_INT,
 				data->base + EXYNOS_TMU_REG_INTCLEAR);
 	}
 out:
@@ -672,6 +677,8 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 			pdata->trigger_level2_en << 8 |
 			pdata->trigger_level1_en << 4 |
 			pdata->trigger_level0_en;
+		if (pdata->threshold_falling)
+			interrupt_en |= interrupt_en << 16;
 	} else {
 		con |= EXYNOS_TMU_CORE_OFF;
 		interrupt_en = 0; /* Disable all interrupts */
@@ -710,7 +717,8 @@ static void exynos_tmu_work(struct work_struct *work)
 
 
 	if (data->soc == SOC_ARCH_EXYNOS)
-		writel(EXYNOS_TMU_CLEAR_RISE_INT,
+		writel(EXYNOS_TMU_CLEAR_RISE_INT |
+				EXYNOS_TMU_CLEAR_FALL_INT,
 				data->base + EXYNOS_TMU_REG_INTCLEAR);
 	else
 		writel(EXYNOS4210_TMU_INTCLEAR_VAL,
@@ -767,6 +775,7 @@ static struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412)
 static struct exynos_tmu_platform_data const exynos_default_tmu_data = {
+	.threshold_falling = 10,
 	.trigger_levels[0] = 85,
 	.trigger_levels[1] = 103,
 	.trigger_levels[2] = 110,
@@ -1012,6 +1021,8 @@ static int __devinit exynos_tmu_probe(struct platform_device *pdev)
 		exynos_sensor_conf.trip_data.trip_val[i] =
 			pdata->threshold + pdata->trigger_levels[i];
 
+	exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling;
+
 	exynos_sensor_conf.cooling_data.freq_clip_count =
 						pdata->freq_tab_count;
 	for (i = 0; i < pdata->freq_tab_count; i++) {
diff --git a/include/linux/platform_data/exynos_thermal.h b/include/linux/platform_data/exynos_thermal.h
index a7bdb2f..da7e627 100644
--- a/include/linux/platform_data/exynos_thermal.h
+++ b/include/linux/platform_data/exynos_thermal.h
@@ -53,6 +53,8 @@ struct freq_clip_table {
  * struct exynos_tmu_platform_data
  * @threshold: basic temperature for generating interrupt
  *	       25 <= threshold <= 125 [unit: degree Celsius]
+ * @threshold_falling: differntial value for setting threshold
+ *		       of temperature falling interrupt.
  * @trigger_levels: array for each interrupt levels
  *	[unit: degree Celsius]
  *	0: temperature for trigger_level0 interrupt
@@ -97,6 +99,7 @@ struct freq_clip_table {
  */
 struct exynos_tmu_platform_data {
 	u8 threshold;
+	u8 threshold_falling;
 	u8 trigger_levels[4];
 	bool trigger_level0_en;
 	bool trigger_level1_en;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH V2 2/3] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt
  2012-11-26 13:47 [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer Amit Daniel Kachhap
  2012-11-26 13:47 ` [PATCH V2 1/3] Thermal: exynos: Add support for temperature falling interrupt Amit Daniel Kachhap
@ 2012-11-26 13:47 ` Amit Daniel Kachhap
  2013-01-06 23:50   ` [PATCH 2/5 RESEND] " Amit Daniel Kachhap
  2012-11-26 13:47 ` [PATCH V2 3/3] thermal: exynos: Use the new thermal trend type for quick cooling action Amit Daniel Kachhap
  2013-01-06 23:57 ` [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer amit daniel kachhap
  3 siblings, 1 reply; 12+ messages in thread
From: Amit Daniel Kachhap @ 2012-11-26 13:47 UTC (permalink / raw)
  To: linux-pm, Zhang Rui
  Cc: linux-samsung-soc, linux-kernel, amit.kachhap, jonghwa3.lee

Below fixes are done to support falling threshold interrupt,
* Falling interrupt status macro corrected according to exynos5 data sheet.
* The get trend function modified to calculate trip temperature correctly.
* The clearing of interrupt status in the isr is now done after handling
  the event that caused the interrupt.

Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
 drivers/thermal/exynos_thermal.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index 3b6c387..54b3fea 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -82,7 +82,7 @@
 
 #define EXYNOS_TRIMINFO_RELOAD		0x1
 #define EXYNOS_TMU_CLEAR_RISE_INT	0x111
-#define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 16)
+#define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 12)
 #define EXYNOS_MUX_ADDR_VALUE		6
 #define EXYNOS_MUX_ADDR_SHIFT		20
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
@@ -373,12 +373,19 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
 static int exynos_get_trend(struct thermal_zone_device *thermal,
 			int trip, enum thermal_trend *trend)
 {
-	if (thermal->temperature >= trip)
+	int ret = 0;
+	unsigned long trip_temp;
+
+	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
+	if (ret < 0)
+		return ret;
+
+	if (thermal->temperature >= trip_temp)
 		*trend = THERMAL_TREND_RAISING;
 	else
 		*trend = THERMAL_TREND_DROPPING;
 
-	return 0;
+	return ret;
 }
 /* Operation callback functions for thermal zone */
 static struct thermal_zone_device_ops const exynos_dev_ops = {
@@ -716,6 +723,11 @@ static void exynos_tmu_work(struct work_struct *work)
 	clk_enable(data->clk);
 
 
+
+	clk_disable(data->clk);
+	mutex_unlock(&data->lock);
+	exynos_report_trigger();
+	clk_enable(data->clk);
 	if (data->soc == SOC_ARCH_EXYNOS)
 		writel(EXYNOS_TMU_CLEAR_RISE_INT |
 				EXYNOS_TMU_CLEAR_FALL_INT,
@@ -723,10 +735,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	else
 		writel(EXYNOS4210_TMU_INTCLEAR_VAL,
 				data->base + EXYNOS_TMU_REG_INTCLEAR);
-
 	clk_disable(data->clk);
-	mutex_unlock(&data->lock);
-	exynos_report_trigger();
 	enable_irq(data->irq);
 }
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH V2 3/3] thermal: exynos: Use the new thermal trend type for quick cooling action.
  2012-11-26 13:47 [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer Amit Daniel Kachhap
  2012-11-26 13:47 ` [PATCH V2 1/3] Thermal: exynos: Add support for temperature falling interrupt Amit Daniel Kachhap
  2012-11-26 13:47 ` [PATCH V2 2/3] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt Amit Daniel Kachhap
@ 2012-11-26 13:47 ` Amit Daniel Kachhap
  2013-01-06 23:57 ` [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer amit daniel kachhap
  3 siblings, 0 replies; 12+ messages in thread
From: Amit Daniel Kachhap @ 2012-11-26 13:47 UTC (permalink / raw)
  To: linux-pm, Zhang Rui
  Cc: linux-samsung-soc, linux-kernel, amit.kachhap, jonghwa3.lee

This patch uses the quick thermal cooling trend type macros. This is needed
as exynos5 and other thermal sensors now supports only interrupt method for
thresold temperature check.

Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
 drivers/thermal/exynos_thermal.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index 54b3fea..2490901 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -295,7 +295,7 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 		case MONITOR_ZONE:
 		case WARN_ZONE:
 			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, level)) {
+								level, 0)) {
 				pr_err("error binding cdev inst %d\n", i);
 				ret = -EINVAL;
 			}
@@ -381,9 +381,9 @@ static int exynos_get_trend(struct thermal_zone_device *thermal,
 		return ret;
 
 	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISING;
+		*trend = THERMAL_TREND_RAISE_FULL;
 	else
-		*trend = THERMAL_TREND_DROPPING;
+		*trend = THERMAL_TREND_DROP_FULL;
 
 	return ret;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/5 RESEND] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt
  2012-11-26 13:47 ` [PATCH V2 2/3] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt Amit Daniel Kachhap
@ 2013-01-06 23:50   ` Amit Daniel Kachhap
  2013-01-06 23:55     ` Joe Perches
  0 siblings, 1 reply; 12+ messages in thread
From: Amit Daniel Kachhap @ 2013-01-06 23:50 UTC (permalink / raw)
  To: linux-pm, linux-pm, Zhang Rui; +Cc: linux-samsung-soc, linux-kernel

Below fixes are done to support falling threshold interrupt,
* Falling interrupt status macro corrected according to exynos5 data sheet.
* The get trend function modified to calculate trip temperature correctly.
* The clearing of interrupt status in the isr is now done after handling
  the event that caused the interrupt.

Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
---
 drivers/thermal/exynos_thermal.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index dcd13f7..0d17d41 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -82,7 +82,7 @@
 
 #define EXYNOS_TRIMINFO_RELOAD		0x1
 #define EXYNOS_TMU_CLEAR_RISE_INT	0x111
-#define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 16)
+#define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 12)
 #define EXYNOS_MUX_ADDR_VALUE		6
 #define EXYNOS_MUX_ADDR_SHIFT		20
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
@@ -373,12 +373,19 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
 static int exynos_get_trend(struct thermal_zone_device *thermal,
 			int trip, enum thermal_trend *trend)
 {
-	if (thermal->temperature >= trip)
+	int ret = 0;
+	unsigned long trip_temp;
+
+	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
+	if (ret < 0)
+		return ret;
+
+	if (thermal->temperature >= trip_temp)
 		*trend = THERMAL_TREND_RAISING;
 	else
 		*trend = THERMAL_TREND_DROPPING;
 
-	return 0;
+	return ret;
 }
 /* Operation callback functions for thermal zone */
 static struct thermal_zone_device_ops const exynos_dev_ops = {
@@ -712,10 +719,9 @@ static void exynos_tmu_work(struct work_struct *work)
 	struct exynos_tmu_data *data = container_of(work,
 			struct exynos_tmu_data, irq_work);
 
+	exynos_report_trigger();
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-
-
 	if (data->soc == SOC_ARCH_EXYNOS)
 		writel(EXYNOS_TMU_CLEAR_RISE_INT |
 				EXYNOS_TMU_CLEAR_FALL_INT,
@@ -723,10 +729,9 @@ static void exynos_tmu_work(struct work_struct *work)
 	else
 		writel(EXYNOS4210_TMU_INTCLEAR_VAL,
 				data->base + EXYNOS_TMU_REG_INTCLEAR);
-
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
-	exynos_report_trigger();
+
 	enable_irq(data->irq);
 }
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5 RESEND] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt
  2013-01-06 23:50   ` [PATCH 2/5 RESEND] " Amit Daniel Kachhap
@ 2013-01-06 23:55     ` Joe Perches
  2013-01-09  4:30       ` amit kachhap
  0 siblings, 1 reply; 12+ messages in thread
From: Joe Perches @ 2013-01-06 23:55 UTC (permalink / raw)
  To: Amit Daniel Kachhap
  Cc: linux-pm, linux-pm, Zhang Rui, linux-samsung-soc, linux-kernel

On Sun, 2013-01-06 at 15:50 -0800, Amit Daniel Kachhap wrote:
> Below fixes are done to support falling threshold interrupt,
> * Falling interrupt status macro corrected according to exynos5 data sheet.
> * The get trend function modified to calculate trip temperature correctly.
> * The clearing of interrupt status in the isr is now done after handling
>   the event that caused the interrupt.
[]
> diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
[]
> @@ -373,12 +373,19 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
>  static int exynos_get_trend(struct thermal_zone_device *thermal,
>  			int trip, enum thermal_trend *trend)
>  {
> -	if (thermal->temperature >= trip)
> +	int ret = 0;

Unnecessary initialization

> +	unsigned long trip_temp;
> +
> +	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
> +	if (ret < 0)
> +		return ret;
> +
> +	if (thermal->temperature >= trip_temp)
>  		*trend = THERMAL_TREND_RAISING;
>  	else
>  		*trend = THERMAL_TREND_DROPPING;

THERMAL_TREND_STABLE ?

>  
> -	return 0;
> +	return ret;

return 0 is clearer.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer
  2012-11-26 13:47 [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer Amit Daniel Kachhap
                   ` (2 preceding siblings ...)
  2012-11-26 13:47 ` [PATCH V2 3/3] thermal: exynos: Use the new thermal trend type for quick cooling action Amit Daniel Kachhap
@ 2013-01-06 23:57 ` amit daniel kachhap
  2013-01-17 17:47   ` amit daniel kachhap
  3 siblings, 1 reply; 12+ messages in thread
From: amit daniel kachhap @ 2013-01-06 23:57 UTC (permalink / raw)
  To: Zhang Rui
  Cc: linux-pm, linux-samsung-soc, linux-kernel, amit.kachhap, jonghwa3.lee

Hi Rui,

Any comment on these patches? These are based on new quick cooling
macros introduced.
Also my linaro ID is not valid so using samsung ID.

Thanks,
Amit Daniel

On Mon, Nov 26, 2012 at 5:47 AM, Amit Daniel Kachhap
<amit.kachhap@linaro.org> wrote:
> Changes since V1: Used the new thermal trend type macro
>
> The patch submitted by Jonghwa Lee (https://patchwork.kernel.org/patch/1683441/)
> adds support for interrupt based notification to thermal layer. This is a good
> feature but the current code need more fixes to support that feature so using 2 new thermal
> trend type to implement this feature and some falling interrupt fixes.
>
> All these patches are based on thermal maintainer thermal branch.
> git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git thermal
>
> Amit Daniel Kachhap (2):
>   thermal: exynos: Miscellaneous fixes to support falling threshold
>     interrupt
>   thermal: exynos: Use the new thermal trend type for quick cooling
>     action.
>
> Jonghwa Lee (1):
>   Thermal: exynos: Add support for temperature falling interrupt.
>
>  drivers/thermal/exynos_thermal.c             |  108 +++++++++++++++-----------
>  include/linux/platform_data/exynos_thermal.h |    3 +
>  2 files changed, 67 insertions(+), 44 deletions(-)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5 RESEND] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt
  2013-01-06 23:55     ` Joe Perches
@ 2013-01-09  4:30       ` amit kachhap
  2013-01-17  1:42         ` [PATCH V3 2/3] " Amit Daniel Kachhap
  0 siblings, 1 reply; 12+ messages in thread
From: amit kachhap @ 2013-01-09  4:30 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-pm, linux-pm, Zhang Rui, linux-samsung-soc, linux-kernel

Hi Joe,

Thanks for the review. Will re-post with your suggestion,

On Sun, Jan 6, 2013 at 3:55 PM, Joe Perches <joe@perches.com> wrote:
> On Sun, 2013-01-06 at 15:50 -0800, Amit Daniel Kachhap wrote:
>> Below fixes are done to support falling threshold interrupt,
>> * Falling interrupt status macro corrected according to exynos5 data sheet.
>> * The get trend function modified to calculate trip temperature correctly.
>> * The clearing of interrupt status in the isr is now done after handling
>>   the event that caused the interrupt.
> []
>> diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
> []
>> @@ -373,12 +373,19 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
>>  static int exynos_get_trend(struct thermal_zone_device *thermal,
>>                       int trip, enum thermal_trend *trend)
>>  {
>> -     if (thermal->temperature >= trip)
>> +     int ret = 0;
Yes agreed. Will modify it.
>
> Unnecessary initialization
>
>> +     unsigned long trip_temp;
>> +
>> +     ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
>> +     if (ret < 0)
>> +             return ret;
>> +
>> +     if (thermal->temperature >= trip_temp)
>>               *trend = THERMAL_TREND_RAISING;
>>       else
>>               *trend = THERMAL_TREND_DROPPING;
>
> THERMAL_TREND_STABLE ?
Only 2 trend is sufficient. It is stable for some time as the falling
threshold interrupt is some units below the trip temp.
>
>>
>> -     return 0;
>> +     return ret;
Ok agreed
>
> return 0 is clearer.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH V3 2/3] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt
  2013-01-09  4:30       ` amit kachhap
@ 2013-01-17  1:42         ` Amit Daniel Kachhap
  2013-01-20 12:53           ` Shubhrajyoti Datta
  0 siblings, 1 reply; 12+ messages in thread
From: Amit Daniel Kachhap @ 2013-01-17  1:42 UTC (permalink / raw)
  To: linux-pm, Zhang Rui
  Cc: jonghwa3.lee, linux-samsung-soc, linux-kernel, durgadoss.r, joe

Below fixes are done to support falling threshold interrupt,
* Falling interrupt status macro corrected according to exynos5 data sheet.
* The get trend function modified to calculate trip temperature correctly.
* The clearing of interrupt status in the isr is now done after handling
  the event that caused the interrupt.

Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
---
Changes since V2,
Incorporated Joe Perches <joe@perches.com> review comments about coding
guidelines.

This path is based on thermal maintainer next tree.

 drivers/thermal/exynos_thermal.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index dcd13f7..f4dd68a 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -82,7 +82,7 @@
 
 #define EXYNOS_TRIMINFO_RELOAD		0x1
 #define EXYNOS_TMU_CLEAR_RISE_INT	0x111
-#define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 16)
+#define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 12)
 #define EXYNOS_MUX_ADDR_VALUE		6
 #define EXYNOS_MUX_ADDR_SHIFT		20
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
@@ -373,7 +373,14 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
 static int exynos_get_trend(struct thermal_zone_device *thermal,
 			int trip, enum thermal_trend *trend)
 {
-	if (thermal->temperature >= trip)
+	int ret;
+	unsigned long trip_temp;
+
+	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
+	if (ret < 0)
+		return ret;
+
+	if (thermal->temperature >= trip_temp)
 		*trend = THERMAL_TREND_RAISING;
 	else
 		*trend = THERMAL_TREND_DROPPING;
@@ -712,10 +719,9 @@ static void exynos_tmu_work(struct work_struct *work)
 	struct exynos_tmu_data *data = container_of(work,
 			struct exynos_tmu_data, irq_work);
 
+	exynos_report_trigger();
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-
-
 	if (data->soc == SOC_ARCH_EXYNOS)
 		writel(EXYNOS_TMU_CLEAR_RISE_INT |
 				EXYNOS_TMU_CLEAR_FALL_INT,
@@ -723,10 +729,9 @@ static void exynos_tmu_work(struct work_struct *work)
 	else
 		writel(EXYNOS4210_TMU_INTCLEAR_VAL,
 				data->base + EXYNOS_TMU_REG_INTCLEAR);
-
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
-	exynos_report_trigger();
+
 	enable_irq(data->irq);
 }
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer
  2013-01-06 23:57 ` [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer amit daniel kachhap
@ 2013-01-17 17:47   ` amit daniel kachhap
  2013-01-22  1:32     ` Kukjin Kim
  0 siblings, 1 reply; 12+ messages in thread
From: amit daniel kachhap @ 2013-01-17 17:47 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-samsung-soc, linux-kernel, jonghwa3.lee

Hi Rui,

Any update?
Please merge these patch series as they have many critical fixes.

Thanks,
Amit Daniel



On Sun, Jan 6, 2013 at 3:57 PM, amit daniel kachhap
<amit.daniel@samsung.com> wrote:
> Hi Rui,
>
> Any comment on these patches? These are based on new quick cooling
> macros introduced.
> Also my linaro ID is not valid so using samsung ID.
>
> Thanks,
> Amit Daniel
>
> On Mon, Nov 26, 2012 at 5:47 AM, Amit Daniel Kachhap
> <amit.kachhap@linaro.org> wrote:
>> Changes since V1: Used the new thermal trend type macro
>>
>> The patch submitted by Jonghwa Lee (https://patchwork.kernel.org/patch/1683441/)
>> adds support for interrupt based notification to thermal layer. This is a good
>> feature but the current code need more fixes to support that feature so using 2 new thermal
>> trend type to implement this feature and some falling interrupt fixes.
>>
>> All these patches are based on thermal maintainer thermal branch.
>> git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git thermal
>>
>> Amit Daniel Kachhap (2):
>>   thermal: exynos: Miscellaneous fixes to support falling threshold
>>     interrupt
>>   thermal: exynos: Use the new thermal trend type for quick cooling
>>     action.
>>
>> Jonghwa Lee (1):
>>   Thermal: exynos: Add support for temperature falling interrupt.
>>
>>  drivers/thermal/exynos_thermal.c             |  108 +++++++++++++++-----------
>>  include/linux/platform_data/exynos_thermal.h |    3 +
>>  2 files changed, 67 insertions(+), 44 deletions(-)
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH V3 2/3] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt
  2013-01-17  1:42         ` [PATCH V3 2/3] " Amit Daniel Kachhap
@ 2013-01-20 12:53           ` Shubhrajyoti Datta
  0 siblings, 0 replies; 12+ messages in thread
From: Shubhrajyoti Datta @ 2013-01-20 12:53 UTC (permalink / raw)
  To: Amit Daniel Kachhap
  Cc: linux-pm, Zhang Rui, jonghwa3.lee, linux-samsung-soc,
	linux-kernel, durgadoss.r, joe

On 1/17/13, Amit Daniel Kachhap <amit.daniel@samsung.com> wrote:
> Below fixes are done to support falling threshold interrupt,
> * Falling interrupt status macro corrected according to exynos5 data sheet.
> * The get trend function modified to calculate trip temperature correctly.
> * The clearing of interrupt status in the isr is now done after handling
>   the event that caused the interrupt.
One fix per patch would have been better.

However not particular.

Also are they applicable to older kernels?

>
> Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
> ---

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer
  2013-01-17 17:47   ` amit daniel kachhap
@ 2013-01-22  1:32     ` Kukjin Kim
  0 siblings, 0 replies; 12+ messages in thread
From: Kukjin Kim @ 2013-01-22  1:32 UTC (permalink / raw)
  To: 'amit daniel kachhap', 'Zhang Rui'
  Cc: linux-pm, linux-samsung-soc, linux-kernel, jonghwa3.lee

Amit Daniel Kachhap wrote:

> > On Mon, Nov 26, 2012 at 5:47 AM, Amit Daniel Kachhap
> > <amit.kachhap@linaro.org> wrote:
> >> Changes since V1: Used the new thermal trend type macro
> >>
> >> The patch submitted by Jonghwa Lee
> (https://patchwork.kernel.org/patch/1683441/)
> >> adds support for interrupt based notification to thermal layer. This is
a
> good
> >> feature but the current code need more fixes to support that feature so
> using 2 new thermal
> >> trend type to implement this feature and some falling interrupt fixes.
> >>
> >> All these patches are based on thermal maintainer thermal branch.
> >> git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git thermal
> >>
> >> Amit Daniel Kachhap (2):
> >>   thermal: exynos: Miscellaneous fixes to support falling threshold
> >>     interrupt
> >>   thermal: exynos: Use the new thermal trend type for quick cooling
> >>     action.
> >>
> >> Jonghwa Lee (1):
> >>   Thermal: exynos: Add support for temperature falling interrupt.
> >>
> >>  drivers/thermal/exynos_thermal.c             |  108
+++++++++++++++--------
> ---
> >>  include/linux/platform_data/exynos_thermal.h |    3 +
> >>  2 files changed, 67 insertions(+), 44 deletions(-)

This whole series looks good to me. And if you want to add my ack as a
maintainer of EXYNOS SoCs, feel free.

Acked-by: Kukjin Kim <kgene.kim@samsung.com>

Thanks.

- Kukjin


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-01-22  1:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-26 13:47 [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer Amit Daniel Kachhap
2012-11-26 13:47 ` [PATCH V2 1/3] Thermal: exynos: Add support for temperature falling interrupt Amit Daniel Kachhap
2012-11-26 13:47 ` [PATCH V2 2/3] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt Amit Daniel Kachhap
2013-01-06 23:50   ` [PATCH 2/5 RESEND] " Amit Daniel Kachhap
2013-01-06 23:55     ` Joe Perches
2013-01-09  4:30       ` amit kachhap
2013-01-17  1:42         ` [PATCH V3 2/3] " Amit Daniel Kachhap
2013-01-20 12:53           ` Shubhrajyoti Datta
2012-11-26 13:47 ` [PATCH V2 3/3] thermal: exynos: Use the new thermal trend type for quick cooling action Amit Daniel Kachhap
2013-01-06 23:57 ` [PATCH V2 0/3] thermal: Add support for interrupt based notification to thermal layer amit daniel kachhap
2013-01-17 17:47   ` amit daniel kachhap
2013-01-22  1:32     ` Kukjin Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).