Skip to contentSkip to conversation

thermal: exynos: Thermal code rework to use device tree

PATCH Superseded Lukasz Majewski 12 participants 244 messages Oct 9, 2014 – Feb 26, 2015 Page 3 of 3

Subsystems (5)
lore
Share & tools
lore
#193 lore raw

Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration

In reply to Eduardo Valentin

Hi Eduardo,

Quoted 27 lines · Lukasz Majewski
Quoted 6 lines

This patch brings support for providing configuration via device tree. Previously this data has been hardcoded in the exynos_tmu_data.c file. Such approach was not scalable and very often required copying the whole data.

Quoted 14 lines

---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added Changes for v4:
- None
Changes for v5:
- Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan <[email protected]>

several checkpatch.pl items to be reviewed in this patch:
CHECK: No space is necessary after a cast
#509: FILE: drivers/thermal/samsung/exynos_tmu.c:821:
+ pdata->gain = (u8) value;

Quoted 7 lines

CHECK: No space is necessary after a cast #511: FILE: drivers/thermal/samsung/exynos_tmu.c:823:
+ pdata->reference_voltage = (u8) value;

Can you please make sure all of your patches pass:
checkpatch.pl --strict

` ^^^^^^^^^ Is now checkpatch.pl required to run with
--strict rule?

I've tested those patches only with checkpatch with no errors.

Has kernel policy changed recently? Are all developers now obliged to use the --strict rule?

Quoted 772 lines

?

Quoted 768 lines
---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 339

++++++++++++++++++++++-------------
drivers/thermal/samsung/exynos_tmu.h | 53 +----- 3 files changed, 220 insertions(+), 174 deletions(-)

(quoted diff) +0 -0

b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644

drivers/thermal/samsung/Makefile +0 -0
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+=

exynos_thermal.o exynos_thermal-y :=
exynos_tmu.o -exynos_thermal-y +=
exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) +=
exynos_thermal_common.o diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..9d2d685 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1,6 +1,10 @@ /*
* exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit) *

+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <[email protected]>
+ *  Lukasz Majewski <[email protected]>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <[email protected]>
  *  Amit Daniel Kachhap <[email protected]>
drivers/thermal/samsung/Makefile +2 -1
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data

of the TMU driver

drivers/thermal/samsung/Makefile +29 -1
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the

calibration type. @@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
bool falling) {

drivers/thermal/samsung/Makefile +6 -3
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from

of-thermal.c!\n",

drivers/thermal/samsung/Makefile +9 -1
+		       __func__);
+		return 0;
+	}
 
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
+
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct

platform_device *pdev, bool on) static int exynos4210_tmu_initialize(struct platform_device *pdev) {

drivers/thermal/samsung/Makefile +8 -2
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from

of-thermal.c!\n",

drivers/thermal/samsung/Makefile +4 -0
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct

platform_device *pdev) sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));

drivers/thermal/samsung/Makefile +6 -1
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base +

EXYNOS4210_TMU_REG_THRESHOLD_TEMP);

drivers/thermal/samsung/Makefile +25 -13
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl,
 rising_threshold; int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
 platform_device *pdev) data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
 HW_TRIP) {
-		threshold_code = temp_to_code(data,
 pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base +
 EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
+	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at
 of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
 	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base +

EXYNOS_THD_TEMP_RISE);

drivers/thermal/samsung/Makefile +6 -2
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_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 trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between

TMU0 and @@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev) data->tmu_clear_irqs(data);

drivers/thermal/samsung/Makefile +0 -2
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==

HW_TRIP) {

drivers/thermal/samsung/Makefile +0 -1
-		threshold_code = temp_to_code(data,

pdata->trigger_levels[i]);

drivers/thermal/samsung/Makefile +1 -0
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))

{

drivers/thermal/samsung/Makefile +1 -0
+		threshold_code = temp_to_code(data, crit_temp /

MCELSIUS); /* 5th level to be assigned in th2 reg */

drivers/thermal/samsung/Makefile +0 -0
 		rising_threshold =
 			threshold_code <<

EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev) static void exynos4210_tmu_control(struct platform_device *pdev, bool on) {

drivers/thermal/samsung/Makefile +1 -1
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base +

EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);

drivers/thermal/samsung/Makefile +0 -1
 		interrupt_en =
-			pdata->trigger_enable[3] <<

EXYNOS_TMU_INTEN_RISE3_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[2] <<

EXYNOS_TMU_INTEN_RISE2_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] <<

EXYNOS_TMU_INTEN_RISE1_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[0] <<

EXYNOS_TMU_INTEN_RISE0_SHIFT;

drivers/thermal/samsung/Makefile +9 -0
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en <<

EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) static void exynos5440_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev);

drivers/thermal/samsung/Makefile +1 -1
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base +

EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);

drivers/thermal/samsung/Makefile +0 -1
 		interrupt_en =
-			pdata->trigger_enable[3] <<

EXYNOS5440_TMU_INTEN_RISE3_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[2] <<

EXYNOS5440_TMU_INTEN_RISE2_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] <<

EXYNOS5440_TMU_INTEN_RISE1_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[0] <<

EXYNOS5440_TMU_INTEN_RISE0_SHIFT;

drivers/thermal/samsung/Makefile +0 -1
-		interrupt_en |= interrupt_en <<

EXYNOS5440_TMU_INTEN_FALL0_SHIFT;

drivers/thermal/samsung/Makefile +10 -0
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en <<

EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {

drivers/thermal/samsung/Makefile +0 -0
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct

platform_device *pdev, bool on) writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL); }

drivers/thermal/samsung/Makefile +7 -5
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) *

MCELSIUS; +

drivers/thermal/samsung/Makefile +25 -23
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
 *work) if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
 void *id) static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible =
 "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data
 *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np,
 "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np,
 "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+
 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data

*pdata) +{

drivers/thermal/samsung/Makefile +8 -0
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",

&value);

drivers/thermal/samsung/Makefile +10 -0
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np,

"samsung,tmu_default_temp_offset", &value);

drivers/thermal/samsung/Makefile +3 -0
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type",

&pdata->cal_type);

drivers/thermal/samsung/Makefile +1 -0
+	of_property_read_u32(np, "samsung,tmu_cal_mode",

&pdata->cal_mode); +

drivers/thermal/samsung/Makefile +9 -6
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
 platform_device *pdev) return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data
 supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct
 exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
drivers/thermal/samsung/Makefile +14 -4
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
 platform_device *pdev) return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct
 exynos_tmu_data), GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
 data,
+
 &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
drivers/thermal/samsung/Makefile +5 -3
 	pdata = data->pdata;
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
 "tmu_apbif"); if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev,
 "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get
 triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get
 clock\n");
-			return ret;
+			goto err_sensor;
 		}
drivers/thermal/samsung/Makefile +0 -3
 	}
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core

thermal */

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct

thermal_sensor_conf), GFP_KERNEL);

drivers/thermal/samsung/Makefile +0 -6
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void

*))exynos_tmu_read;

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned

long))exynos_tmu_set_emulation;

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count =

pdata->trigger_enable[0] +

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] +

pdata->trigger_enable[2]+

drivers/thermal/samsung/Makefile +0 -5
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold +

pdata->trigger_levels[i];

drivers/thermal/samsung/Makefile +0 -5
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling =

pdata->threshold_falling; -

drivers/thermal/samsung/Makefile +0 -7
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal

interface: %d\n",

drivers/thermal/samsung/Makefile +0 -5
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq,

exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data); if (ret) {

drivers/thermal/samsung/Makefile +6 -2
@@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) goto err_clk;
 	}
 
+	exynos_tmu_control(pdev, true);
 	return 0;
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
(quoted diff) +0 -0

b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644

drivers/thermal/samsung/exynos_tmu.h +1 -12
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * 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
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold +

trigger_levels[0]
- * 1: temperature for trigger_level1 interrupt
- * condition for trigger_level1 interrupt:
- * current temperature > threshold +
trigger_levels[1]
- * 2: temperature for trigger_level2 interrupt
- * condition for trigger_level2 interrupt:
- * current temperature > threshold +
trigger_levels[2]
- * 3: temperature for trigger_level3 interrupt
- * condition for trigger_level3 interrupt:
- * current temperature > threshold +
trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- * THROTTLE_ACTIVE trigger type
- * THROTTLE_PASSIVE trigger type
- * SW_TRIP trigger type
- * HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- * 1 = enable trigger_level[] interrupt,
- * 0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
* @gain: gain of amplifier in the positive-TC generator block
* 0 < gain <= 15
* @reference_voltage: reference voltage of amplifier

drivers/thermal/samsung/exynos_tmu.h +0 -2
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no

trimming
* @cal_type: calibration type for temperature
*
* This structure is required for configuration of exynos_tmu
driver. */
struct exynos_tmu_platform_data {

drivers/thermal/samsung/exynos_tmu.h +0 -12
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance

exynos tmu
- * driver.
- */

drivers/thermal/samsung/exynos_tmu.h +0 -5
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const

exynos3250_default_tmu_data; extern struct exynos_tmu_init_data const exynos4210_default_tmu_data; extern struct exynos_tmu_init_data const exynos4412_default_tmu_data; -- 2.0.0.rc2

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#194 lore raw

Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration

Quoted 37 lines · Lukasz Majewski

Hi Eduardo,

Quoted 27 lines · Lukasz Majewski
Quoted 6 lines

This patch brings support for providing configuration via device tree. Previously this data has been hardcoded in the exynos_tmu_data.c file. Such approach was not scalable and very often required copying the whole data.

Quoted 14 lines

---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added Changes for v4:
- None
Changes for v5:
- Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan <[email protected]>

several checkpatch.pl items to be reviewed in this patch:
CHECK: No space is necessary after a cast
#509: FILE: drivers/thermal/samsung/exynos_tmu.c:821:
+ pdata->gain = (u8) value;

Quoted 7 lines

CHECK: No space is necessary after a cast #511: FILE: drivers/thermal/samsung/exynos_tmu.c:823:
+ pdata->reference_voltage = (u8) value;

Can you please make sure all of your patches pass:
checkpatch.pl --strict

Quoted 7 lines

` ^^^^^^^^^ Is now checkpatch.pl required to run with
--strict rule?

I've tested those patches only with checkpatch with no errors.

Has kernel policy changed recently? Are all developers now obliged to use the --strict rule?

no change in policy. the --strict is just appreciated. it depends on maintainer to maintainer. --strict catches more checks and warnings though. that is probably why I see people asking for it.

Quoted 783 lines
Quoted 774 lines

?

Quoted 768 lines
---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 339

++++++++++++++++++++++-------------
drivers/thermal/samsung/exynos_tmu.h | 53 +----- 3 files changed, 220 insertions(+), 174 deletions(-)

(quoted diff) +0 -0

b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644

drivers/thermal/samsung/Makefile +0 -0
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+=

exynos_thermal.o exynos_thermal-y :=
exynos_tmu.o -exynos_thermal-y +=
exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) +=
exynos_thermal_common.o diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..9d2d685 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1,6 +1,10 @@ /*
* exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit) *

+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <[email protected]>
+ *  Lukasz Majewski <[email protected]>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <[email protected]>
  *  Amit Daniel Kachhap <[email protected]>
drivers/thermal/samsung/Makefile +2 -1
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data

of the TMU driver

drivers/thermal/samsung/Makefile +29 -1
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the

calibration type. @@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
bool falling) {

drivers/thermal/samsung/Makefile +6 -3
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from

of-thermal.c!\n",

drivers/thermal/samsung/Makefile +9 -1
+		       __func__);
+		return 0;
+	}
 
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
+
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct

platform_device *pdev, bool on) static int exynos4210_tmu_initialize(struct platform_device *pdev) {

drivers/thermal/samsung/Makefile +8 -2
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from

of-thermal.c!\n",

drivers/thermal/samsung/Makefile +4 -0
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct

platform_device *pdev) sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));

drivers/thermal/samsung/Makefile +6 -1
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base +

EXYNOS4210_TMU_REG_THRESHOLD_TEMP);

drivers/thermal/samsung/Makefile +25 -13
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl,
 rising_threshold; int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
 platform_device *pdev) data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
 HW_TRIP) {
-		threshold_code = temp_to_code(data,
 pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base +
 EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
+	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at
 of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
 	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base +

EXYNOS_THD_TEMP_RISE);

drivers/thermal/samsung/Makefile +6 -2
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_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 trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between

TMU0 and @@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev) data->tmu_clear_irqs(data);

drivers/thermal/samsung/Makefile +0 -2
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==

HW_TRIP) {

drivers/thermal/samsung/Makefile +0 -1
-		threshold_code = temp_to_code(data,

pdata->trigger_levels[i]);

drivers/thermal/samsung/Makefile +1 -0
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))

{

drivers/thermal/samsung/Makefile +1 -0
+		threshold_code = temp_to_code(data, crit_temp /

MCELSIUS); /* 5th level to be assigned in th2 reg */

drivers/thermal/samsung/Makefile +0 -0
 		rising_threshold =
 			threshold_code <<

EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev) static void exynos4210_tmu_control(struct platform_device *pdev, bool on) {

drivers/thermal/samsung/Makefile +1 -1
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base +

EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);

drivers/thermal/samsung/Makefile +0 -1
 		interrupt_en =
-			pdata->trigger_enable[3] <<

EXYNOS_TMU_INTEN_RISE3_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[2] <<

EXYNOS_TMU_INTEN_RISE2_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] <<

EXYNOS_TMU_INTEN_RISE1_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[0] <<

EXYNOS_TMU_INTEN_RISE0_SHIFT;

drivers/thermal/samsung/Makefile +9 -0
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en <<

EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) static void exynos5440_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev);

drivers/thermal/samsung/Makefile +1 -1
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base +

EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);

drivers/thermal/samsung/Makefile +0 -1
 		interrupt_en =
-			pdata->trigger_enable[3] <<

EXYNOS5440_TMU_INTEN_RISE3_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[2] <<

EXYNOS5440_TMU_INTEN_RISE2_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] <<

EXYNOS5440_TMU_INTEN_RISE1_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[0] <<

EXYNOS5440_TMU_INTEN_RISE0_SHIFT;

drivers/thermal/samsung/Makefile +0 -1
-		interrupt_en |= interrupt_en <<

EXYNOS5440_TMU_INTEN_FALL0_SHIFT;

drivers/thermal/samsung/Makefile +10 -0
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en <<

EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {

drivers/thermal/samsung/Makefile +0 -0
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct

platform_device *pdev, bool on) writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL); }

drivers/thermal/samsung/Makefile +7 -5
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) *

MCELSIUS; +

drivers/thermal/samsung/Makefile +25 -23
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
 *work) if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
 void *id) static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible =
 "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data
 *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np,
 "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np,
 "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+
 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data

*pdata) +{

drivers/thermal/samsung/Makefile +8 -0
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",

&value);

drivers/thermal/samsung/Makefile +10 -0
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np,

"samsung,tmu_default_temp_offset", &value);

drivers/thermal/samsung/Makefile +3 -0
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type",

&pdata->cal_type);

drivers/thermal/samsung/Makefile +1 -0
+	of_property_read_u32(np, "samsung,tmu_cal_mode",

&pdata->cal_mode); +

drivers/thermal/samsung/Makefile +9 -6
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
 platform_device *pdev) return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data
 supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct
 exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
drivers/thermal/samsung/Makefile +14 -4
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
 platform_device *pdev) return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct
 exynos_tmu_data), GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
 data,
+
 &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
drivers/thermal/samsung/Makefile +5 -3
 	pdata = data->pdata;
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
 "tmu_apbif"); if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev,
 "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get
 triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get
 clock\n");
-			return ret;
+			goto err_sensor;
 		}
drivers/thermal/samsung/Makefile +0 -3
 	}
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core

thermal */

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct

thermal_sensor_conf), GFP_KERNEL);

drivers/thermal/samsung/Makefile +0 -6
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void

*))exynos_tmu_read;

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned

long))exynos_tmu_set_emulation;

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count =

pdata->trigger_enable[0] +

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] +

pdata->trigger_enable[2]+

drivers/thermal/samsung/Makefile +0 -5
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold +

pdata->trigger_levels[i];

drivers/thermal/samsung/Makefile +0 -5
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling =

pdata->threshold_falling; -

drivers/thermal/samsung/Makefile +0 -7
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal

interface: %d\n",

drivers/thermal/samsung/Makefile +0 -5
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq,

exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data); if (ret) {

drivers/thermal/samsung/Makefile +6 -2
@@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) goto err_clk;
 	}
 
+	exynos_tmu_control(pdev, true);
 	return 0;
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
(quoted diff) +0 -0

b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644

drivers/thermal/samsung/exynos_tmu.h +1 -12
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * 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
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold +

trigger_levels[0]
- * 1: temperature for trigger_level1 interrupt
- * condition for trigger_level1 interrupt:
- * current temperature > threshold +
trigger_levels[1]
- * 2: temperature for trigger_level2 interrupt
- * condition for trigger_level2 interrupt:
- * current temperature > threshold +
trigger_levels[2]
- * 3: temperature for trigger_level3 interrupt
- * condition for trigger_level3 interrupt:
- * current temperature > threshold +
trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- * THROTTLE_ACTIVE trigger type
- * THROTTLE_PASSIVE trigger type
- * SW_TRIP trigger type
- * HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- * 1 = enable trigger_level[] interrupt,
- * 0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
* @gain: gain of amplifier in the positive-TC generator block
* 0 < gain <= 15
* @reference_voltage: reference voltage of amplifier

drivers/thermal/samsung/exynos_tmu.h +0 -2
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no

trimming
* @cal_type: calibration type for temperature
*
* This structure is required for configuration of exynos_tmu
driver. */
struct exynos_tmu_platform_data {

drivers/thermal/samsung/exynos_tmu.h +0 -12
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance

exynos tmu
- * driver.
- */

drivers/thermal/samsung/exynos_tmu.h +0 -5
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const

exynos3250_default_tmu_data; extern struct exynos_tmu_init_data const exynos4210_default_tmu_data; extern struct exynos_tmu_init_data const exynos4412_default_tmu_data; -- 2.0.0.rc2

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#195 lore raw

Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration

In reply to Lukasz Majewski
Quoted 326 lines · Lukasz Majewski

This patch brings support for providing configuration via device tree. Previously this data has been hardcoded in the exynos_tmu_data.c file. Such approach was not scalable and very often required copying the whole data.

---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table
Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added Changes for v4:
- None
Changes for v5:
- Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan <[email protected]>

---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 339 ++++++++++++++++++++++-------------
 drivers/thermal/samsung/exynos_tmu.h |  53 +-----
 3 files changed, 220 insertions(+), 174 deletions(-)
drivers/thermal/samsung/Makefile +0 -2
index c09d830..1e47d0d 100644
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
drivers/thermal/samsung/exynos_tmu.c +122 -38
index ae30f6a..9d2d685 100644
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <[email protected]>
+ *  Lukasz Majewski <[email protected]>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <[email protected]>
  *  Amit Daniel Kachhap <[email protected]>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		return 0;
+	}
 
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
+
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
 
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_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;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
+	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
 	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_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 trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
-		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */

drivers/thermal/samsung/exynos_tmu.c static void exynos5440_tmu_control(struct platform_device *pdev, bool on) · line 576

Quoted 5 lines
drivers/thermal/samsung/exynos_tmu.c +1 -1
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)

exynos_get_temp must be static.

Quoted 399 lines
drivers/thermal/samsung/exynos_tmu.c +96 -81
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+					 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
+{
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal interface: %d\n",
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	exynos_tmu_control(pdev, true);
 	return 0;
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
drivers/thermal/samsung/exynos_tmu.h +1 -52
index 627dec9..d876d4c 100644
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * 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
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
Signature · 1 line
2.0.0.rc2
#196 lore raw

Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration

Hi Eduardo,

Quoted 351 lines · Lukasz Majewski
Quoted 350 lines

This patch brings support for providing configuration via device tree. Previously this data has been hardcoded in the exynos_tmu_data.c file. Such approach was not scalable and very often required copying the whole data.

---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added Changes for v4:
- None
Changes for v5:
- Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan <[email protected]>

---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 339

++++++++++++++++++++++-------------
drivers/thermal/samsung/exynos_tmu.h | 53 +----- 3 files changed, 220 insertions(+), 174 deletions(-)

(quoted diff) +0 -0

b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644

drivers/thermal/samsung/Makefile +0 -0
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+=

exynos_thermal.o exynos_thermal-y :=
exynos_tmu.o -exynos_thermal-y +=
exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) +=
exynos_thermal_common.o diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..9d2d685 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1,6 +1,10 @@ /*
* exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit) *

+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <[email protected]>
+ *  Lukasz Majewski <[email protected]>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <[email protected]>
  *  Amit Daniel Kachhap <[email protected]>
drivers/thermal/samsung/Makefile +2 -1
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data

of the TMU driver

drivers/thermal/samsung/Makefile +29 -1
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the

calibration type. @@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
bool falling) {

drivers/thermal/samsung/Makefile +6 -3
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from

of-thermal.c!\n",

drivers/thermal/samsung/Makefile +9 -1
+		       __func__);
+		return 0;
+	}
 
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
+
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct

platform_device *pdev, bool on) static int exynos4210_tmu_initialize(struct platform_device *pdev) {

drivers/thermal/samsung/Makefile +8 -2
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from

of-thermal.c!\n",

drivers/thermal/samsung/Makefile +4 -0
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct

platform_device *pdev) sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));

drivers/thermal/samsung/Makefile +6 -1
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base +

EXYNOS4210_TMU_REG_THRESHOLD_TEMP);

drivers/thermal/samsung/Makefile +25 -13
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl,
 rising_threshold; int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
 platform_device *pdev) data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
 HW_TRIP) {
-		threshold_code = temp_to_code(data,
 pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base +
 EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
+	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at
 of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
 	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base +

EXYNOS_THD_TEMP_RISE);

drivers/thermal/samsung/Makefile +6 -2
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_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 trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between

TMU0 and @@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev) data->tmu_clear_irqs(data);

drivers/thermal/samsung/Makefile +0 -2
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==

HW_TRIP) {

drivers/thermal/samsung/Makefile +0 -1
-		threshold_code = temp_to_code(data,

pdata->trigger_levels[i]);

drivers/thermal/samsung/Makefile +1 -0
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))

{

drivers/thermal/samsung/Makefile +1 -0
+		threshold_code = temp_to_code(data, crit_temp /

MCELSIUS); /* 5th level to be assigned in th2 reg */

drivers/thermal/samsung/Makefile +0 -0
 		rising_threshold =
 			threshold_code <<

EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev) static void exynos4210_tmu_control(struct platform_device *pdev, bool on) {

drivers/thermal/samsung/Makefile +1 -1
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base +

EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);

drivers/thermal/samsung/Makefile +0 -1
 		interrupt_en =
-			pdata->trigger_enable[3] <<

EXYNOS_TMU_INTEN_RISE3_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[2] <<

EXYNOS_TMU_INTEN_RISE2_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] <<

EXYNOS_TMU_INTEN_RISE1_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[0] <<

EXYNOS_TMU_INTEN_RISE0_SHIFT;

drivers/thermal/samsung/Makefile +9 -0
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en <<

EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) static void exynos5440_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev);

drivers/thermal/samsung/Makefile +1 -1
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base +

EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);

drivers/thermal/samsung/Makefile +0 -1
 		interrupt_en =
-			pdata->trigger_enable[3] <<

EXYNOS5440_TMU_INTEN_RISE3_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[2] <<

EXYNOS5440_TMU_INTEN_RISE2_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] <<

EXYNOS5440_TMU_INTEN_RISE1_SHIFT |

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[0] <<

EXYNOS5440_TMU_INTEN_RISE0_SHIFT;

drivers/thermal/samsung/Makefile +0 -1
-		interrupt_en |= interrupt_en <<

EXYNOS5440_TMU_INTEN_FALL0_SHIFT;

drivers/thermal/samsung/Makefile +10 -0
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en <<

EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {

drivers/thermal/samsung/Makefile +0 -0
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct

platform_device *pdev, bool on) writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL); }

Quoted 4 lines

drivers/thermal/samsung/Makefile

Quoted 2 lines
drivers/thermal/samsung/Makefile +1 -1
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)

exynos_get_temp must be static.

Yes, this should be static.
Thanks.

Quoted 437 lines
Quoted 437 lines

{

drivers/thermal/samsung/Makefile +6 -4
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) *

MCELSIUS; +

drivers/thermal/samsung/Makefile +25 -23
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
 *work) if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
 void *id) static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible =
 "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data
 *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np,
 "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np,
 "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+
 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np,
 "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data

*pdata) +{

drivers/thermal/samsung/Makefile +8 -0
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",

&value);

drivers/thermal/samsung/Makefile +10 -0
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim",

&value);

drivers/thermal/samsung/Makefile +2 -0
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np,

"samsung,tmu_default_temp_offset", &value);

drivers/thermal/samsung/Makefile +3 -0
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type",

&pdata->cal_type);

drivers/thermal/samsung/Makefile +1 -0
+	of_property_read_u32(np, "samsung,tmu_cal_mode",

&pdata->cal_mode); +

drivers/thermal/samsung/Makefile +9 -6
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
 platform_device *pdev) return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data
 supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct
 exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
drivers/thermal/samsung/Makefile +14 -4
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
 platform_device *pdev) return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct
 exynos_tmu_data), GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
 data,
+
 &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
drivers/thermal/samsung/Makefile +5 -3
 	pdata = data->pdata;
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
 "tmu_apbif"); if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev,
 "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get
 triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get
 clock\n");
-			return ret;
+			goto err_sensor;
 		}
drivers/thermal/samsung/Makefile +0 -3
 	}
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core

thermal */

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct

thermal_sensor_conf), GFP_KERNEL);

drivers/thermal/samsung/Makefile +0 -6
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void

*))exynos_tmu_read;

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned

long))exynos_tmu_set_emulation;

drivers/thermal/samsung/Makefile +0 -2
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count =

pdata->trigger_enable[0] +

drivers/thermal/samsung/Makefile +0 -1
-			pdata->trigger_enable[1] +

pdata->trigger_enable[2]+

drivers/thermal/samsung/Makefile +0 -5
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold +

pdata->trigger_levels[i];

drivers/thermal/samsung/Makefile +0 -5
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling =

pdata->threshold_falling; -

drivers/thermal/samsung/Makefile +0 -7
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal

interface: %d\n",

drivers/thermal/samsung/Makefile +0 -5
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq,

exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data); if (ret) {

drivers/thermal/samsung/Makefile +6 -2
@@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) goto err_clk;
 	}
 
+	exynos_tmu_control(pdev, true);
 	return 0;
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
(quoted diff) +0 -0

b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644

drivers/thermal/samsung/exynos_tmu.h +1 -12
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * 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
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold +

trigger_levels[0]
- * 1: temperature for trigger_level1 interrupt
- * condition for trigger_level1 interrupt:
- * current temperature > threshold +
trigger_levels[1]
- * 2: temperature for trigger_level2 interrupt
- * condition for trigger_level2 interrupt:
- * current temperature > threshold +
trigger_levels[2]
- * 3: temperature for trigger_level3 interrupt
- * condition for trigger_level3 interrupt:
- * current temperature > threshold +
trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- * THROTTLE_ACTIVE trigger type
- * THROTTLE_PASSIVE trigger type
- * SW_TRIP trigger type
- * HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- * 1 = enable trigger_level[] interrupt,
- * 0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
* @gain: gain of amplifier in the positive-TC generator block
* 0 < gain <= 15
* @reference_voltage: reference voltage of amplifier

drivers/thermal/samsung/exynos_tmu.h +0 -2
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no

trimming
* @cal_type: calibration type for temperature
*
* This structure is required for configuration of exynos_tmu
driver. */
struct exynos_tmu_platform_data {

drivers/thermal/samsung/exynos_tmu.h +0 -12
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance

exynos tmu
- * driver.
- */

drivers/thermal/samsung/exynos_tmu.h +0 -5
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const

exynos3250_default_tmu_data; extern struct exynos_tmu_init_data const exynos4210_default_tmu_data; extern struct exynos_tmu_init_data const exynos4412_default_tmu_data; -- 2.0.0.rc2

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#197 lore raw

PATCH v5 16/18 thermal: exynos: Remove exynos_thermal_common.[c|h] files

In reply to Lukasz Majewski

After defining all necessary Exynos data in the device tree and heavy reusage of the of-thermal.c those files can be removed.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None

---
 drivers/thermal/samsung/exynos_thermal_common.c | 445 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 551 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
drivers/thermal/samsung/exynos_thermal_common.c deleted +0 -445
deleted file mode 100644
index 00aa688..0000000
@@ -1,445 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	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_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	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
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-				cpufreq_cooling_register(cpu_present_mask);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
-			if (ret != -EPROBE_DEFER)
-				dev_err(sensor_conf->dev,
-					"Failed to register cpufreq cooling device: %d\n",
-					ret);
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; ++i)
-		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
drivers/thermal/samsung/exynos_thermal_common.h deleted +0 -106

106 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#198 lore raw

PATCH v5 17/18 thermal: exynos: Remove exynos_tmu_data.c file

In reply to Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the appropriate device tree files.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None

---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
drivers/thermal/samsung/exynos_tmu_data.c deleted +0 -228
deleted file mode 100644
index a993f3d..0000000
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
Signature · 1 line
2.0.0.rc2
#199 lore raw

PATCH v5 18/18 thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h

In reply to Lukasz Majewski

After switching to device tree based configuration those declarations are not needed anymore.

---
Changes for v5:
- New patch

---
 drivers/thermal/samsung/exynos_tmu.h | 8 --------
 1 file changed, 8 deletions(-)
drivers/thermal/samsung/exynos_tmu.h +0 -8
index d876d4c..9f9b1b8 100644
@@ -71,12 +71,4 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5260_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5420_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;
-
 #endif /* _EXYNOS_TMU_H */
Signature · 1 line
2.0.0.rc2
#200 lore raw

Re: [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h

Quoted 17 lines · Lukasz Majewski

After switching to device tree based configuration those declarations are not needed anymore.

---
Changes for v5:
- New patch

---
 drivers/thermal/samsung/exynos_tmu.h | 8 --------
 1 file changed, 8 deletions(-)
drivers/thermal/samsung/exynos_tmu.h +0 -0
index d876d4c..9f9b1b8 100644

drivers/thermal/samsung/exynos_tmu.h struct exynos_tmu_platform_data { · line 80

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.h +0 -7
@@ -71,12 +71,4 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5260_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5420_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;

Please merge this patch to the one that removes these symbols from kernel.

Quoted 5 lines
drivers/thermal/samsung/exynos_tmu.h +0 -1
-
 #endif /* _EXYNOS_TMU_H */
Signature · 1 line
2.0.0.rc2
#201 lore raw

Re: [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h

Hi Eduardo,

Quoted 21 lines · Lukasz Majewski
Quoted 20 lines

After switching to device tree based configuration those declarations are not needed anymore.

---
Changes for v5:
- New patch
---
| 8 --------

 1 file changed, 8 deletions(-)
(quoted diff) +0 -0

b/drivers/thermal/samsung/exynos_tmu.h index d876d4c..9f9b1b8 100644

drivers/thermal/samsung/exynos_tmu.h +0 -0
@@ -71,12 +71,4 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
Quoted 12 lines
Quoted 9 lines
drivers/thermal/samsung/exynos_tmu.h +0 -1
-extern struct exynos_tmu_init_data const

exynos3250_default_tmu_data; -extern struct exynos_tmu_init_data const exynos4210_default_tmu_data; -extern struct exynos_tmu_init_data const exynos4412_default_tmu_data; -extern struct exynos_tmu_init_data const exynos5250_default_tmu_data; -extern struct exynos_tmu_init_data const exynos5260_default_tmu_data; -extern struct exynos_tmu_init_data const exynos5420_default_tmu_data; -extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;

Please merge this patch to the one that removes these symbols from kernel.

Will be done for v6 version.

Quoted 6 lines
Quoted 6 lines

-
#endif /* _EXYNOS_TMU_H */

Signature · 1 line
2.0.0.rc2
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#202 lore raw
In reply to Lukasz Majewski

Hello Arnd,

Quoted 46 lines · Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

Quoted 6 lines

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

This series contains changes under drivers/thermal that I can pick up, but it also contains changes under arch/arm/boot/dts that depend on a header file provided by the driver. The header is introduced in this series.

How do you prefer to preceed in such sitation? Are you OK if I pick the complete series, changes under drivers/thermal and the DTS changes?

Cheers,

Eduardo

Quoted 67 lines

Lukasz Majewski (18):
thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be included in
device tree files
arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
arm: dts: Adding CPU cooling binding for Exynos SoCs
thermal: exynos: Modify exynos thermal code to use device tree for cpu
cooling configuration
thermal: exynos: dts: Add default definition of the TMU sensor
parameter
dts: Documentation: Extending documentation entry for exynos-thermal
thermal: dts: Default trip points definition for Exynos5420 SoCs
thermal: exynos: dts: Define default thermal-zones for Exynos4
thermal: dts: exynos: Trip points and sensor configuration data for

    Exynos5440

dts: Documentation: Update exynos-thermal.txt example for Exynos5440
thermal: exynos: dts: Provide device tree bindings identical to the
one in exynos_tmu_data.c
thermal: samsung: core: Exynos TMU rework to use device tree for
configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file
thermal: exynos: Remove not needed exynos_tmu_init_data declarations
from exynos_tmu.h

 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  76 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 632 insertions(+), 1009 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
Signature · 1 line
2.0.0.rc2
#203 lore raw

v6 cover thermal: exynos: Thermal code rework to use device tree

In reply to Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):
thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be included in
device tree files
arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
arm: dts: Adding CPU cooling binding for Exynos SoCs
thermal: exynos: Modify exynos thermal code to use device tree for cpu
cooling configuration
cpufreq: exynos: Use device tree to determine if cpufreq cooling
should be registered
thermal: exynos: dts: Add default definition of the TMU sensor
parameter
dts: Documentation: Extending documentation entry for exynos-thermal
thermal: dts: Default trip points definition for Exynos5420 SoCs
thermal: exynos: dts: Define default thermal-zones for Exynos4
thermal: dts: exynos: Trip points and sensor configuration data for

    Exynos5440

dts: Documentation: Update exynos-thermal.txt example for Exynos5440
thermal: exynos: dts: Provide device tree bindings identical to the
one in exynos_tmu_data.c
thermal: samsung: core: Exynos TMU rework to use device tree for
configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  76 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 636 insertions(+), 1008 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
Signature · 1 line
2.0.0.rc2
#204 lore raw

PATCH v6 1/18 thermal: exynos: cosmetic: Correct comment format

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/samsung/exynos_tmu.c +1 -1
index d2f1e62..5000727 100644
@@ -576,7 +576,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
Signature · 1 line
2.0.0.rc2
#205 lore raw

PATCH v6 2/18 thermal: exynos: Provide thermal_exynos.h file to be included in device tree files

In reply to Lukasz Majewski

This patch is a preparatory patch to be able to read Exynos thermal configuration from the device tree.

It turned out that DTC is not able to interpret enums properly and hence it is necessary to #define those values explicitly.

For this reason the ./include/dt-bindings/thermal/thermal_exynos.h file has been introduced.

---
Changes for v2:
- None
Changes for v3:
- Restore 'enum soc_type type' since TMU sensor type will be extracted from device tree compatible
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 drivers/thermal/samsung/exynos_tmu.h         | 12 +++---------
 include/dt-bindings/thermal/thermal_exynos.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 9 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
drivers/thermal/samsung/exynos_tmu.h +3 -9
index da3009b..7f880d2 100644
@@ -26,14 +26,6 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
 	SOC_ARCH_EXYNOS4210,
@@ -44,6 +36,7 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +108,9 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
 	enum soc_type type;
+	u32 cal_type;
+	u32 cal_mode;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
include/dt-bindings/thermal/thermal_exynos.h new file +28 -0
new file mode 100644
index 0000000..0646500
@@ -0,0 +1,28 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
Signature · 1 line
2.0.0.rc2
#206 lore raw

PATCH v6 3/18 arm: dts: trats: Enable TMU on the Exynos4210 trats device

In reply to Lukasz Majewski

The thermal IP block (Thermal Management Unit) called TMU has been enabled in this device.

---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: arm to arm: dts: trats Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/exynos4210-trats.dts +4 -0
index 7208362..61009f4 100644
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu@100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
Signature · 1 line
2.0.0.rc2
#207 lore raw

PATCH v6 4/18 arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid

In reply to Lukasz Majewski

---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: exynos to arm: dts: Odroid Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/boot/dts/exynos4412-odroid-common.dtsi +7 -0
index 3fbf588..0adb57c 100644
@@ -231,6 +231,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
Signature · 1 line
2.0.0.rc2
#208 lore raw

PATCH v6 5/18 arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device

In reply to Lukasz Majewski

This commit enables TMU IP block on the Exynos4412 Odroid U3 device.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- Rename patch title from "thermal: dts:" to "arm: dts: odroid" Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/exynos4412-odroid-common.dtsi +5 -0
index 0adb57c..c7517fc 100644
@@ -396,6 +396,11 @@
 	ehci: ehci@12580000 {
 		status = "okay";
 	};
+
+	tmu@100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
Signature · 1 line
2.0.0.rc2
#209 lore raw

Aw: [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device

Hello,

just a small nit concerning the patch subject. Shouldn't it be "Enable TMU on Exynos4412 based Odroid devices" (since it's not just for the U3)?

With best wishes,
Tobias

Gesendet: Freitag, 23. Januar 2015 um 13:09 Uhr
Von: "Lukasz Majewski" <[email protected]>
An: "Eduardo Valentin" <[email protected]>, "Zhang Rui" <[email protected]>, "Kukjin Kim" <[email protected]>, "Kukjin Kim" <[email protected]>
Cc: "Linux PM list" <[email protected]>, "[email protected]" <[email protected]>, "Bartlomiej Zolnierkiewicz" <[email protected]>, "Lukasz Majewski" <[email protected]>, "Amit Daniel Kachhap" <[email protected]>, "Abhilash Kesavan" <[email protected]>, "Abhilash Kesavan" <[email protected]>, "Chanwoo Choi" <[email protected]>, "Viresh Kumar" <[email protected]>, "Lukasz Majewski" <[email protected]> Betreff: [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
This commit enables TMU IP block on the Exynos4412 Odroid U3
device.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- Rename patch title from "thermal: dts:" to "arm: dts: odroid" Changes for v5:
- None
Changes for v6:
- None
---
arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++

1 file changed, 5 insertions(+)
arch/arm/boot/dts/exynos4412-odroid-common.dtsi +0 -0
index 0adb57c..c7517fc 100644
@@ -396,6 +396,11 @@

ehci: ehci@12580000 {
status = "okay";
};
+
+ tmu@100C0000 {
+ vtmu-supply = <&ldo10_reg>;
+ status = "okay";
+ };
};

&pinctrl_1 {
--
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#210 lore raw

PATCH v6 6/18 arm: dts: Adding CPU cooling binding for Exynos SoCs

In reply to Lukasz Majewski

Presented patch aims to move data necessary for correct CPU cooling device configuration from exynos_tmu_data.c to device tree.

---
Changes for v2:
- None
Changes for v3:
- Adjust CPU's DT nodes to work with newest ti-soc-thermal/next branch
- Patch title has been changed from "thermal: cpu_cooling: dts: ..." Changes for v4:
- Spaces and tabs cleanup
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412-trats2.dts         | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
 7 files changed, 76 insertions(+), 4 deletions(-)
arch/arm/boot/dts/exynos4210-trats.dts +15 -0
index 61009f4..e3879c0 100644
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
arch/arm/boot/dts/exynos4210.dtsi +4 -1
index bcc9e63..2e66df8 100644
@@ -35,10 +35,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@900 {
+		cpu0: cpu@900 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@901 {
arch/arm/boot/dts/exynos4212.dtsi +4 -1
index dd0a43e..5be03288 100644
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
arch/arm/boot/dts/exynos4412-odroid-common.dtsi +15 -0
index c7517fc..25b4f7d 100644
@@ -401,6 +401,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
arch/arm/boot/dts/exynos4412-trats2.dts +15 -0
index 29231b4..52a7771 100644
@@ -863,6 +863,21 @@
 		pulldown-ohm = <100000>; /* 100K */
 		io-channels = <&adc 2>;  /* Battery temperature */
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_0 {
arch/arm/boot/dts/exynos4412.dtsi +4 -1
index 0f6ec93..68ad43b 100644
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
arch/arm/boot/dts/exynos5250.dtsi +19 -1
index 0a229fc..4641d3c 100644
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu@1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial@12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
Signature · 1 line
2.0.0.rc2
#211 lore raw

PATCH v6 7/18 thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration

In reply to Lukasz Majewski

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration data. Now the Exynos thermal core code uses device tree to get this data. For this purpose generic thermal code for configuring CPU cooling was used.

---
Changes for v2:
- None
Changes for v3:
- Rewrite code responsible for registering CPU cooling device to not depend on explicit "/cpus/cpu@0" path since now Exynos SoCs use new cpu node names (e.g. cpu@A00). New approach iterates over "cpus" node children.
- Patch title changed to thermal: exynos
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- Remove exynos cpufreq related code (exynos-cpufreq.c) from this commit

---
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 4 files changed, 73 insertions(+), 103 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +70 -52
index 6dc3815..00aa688 100644
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
drivers/thermal/samsung/exynos_tmu.c +0 -7
index 5000727..ae30f6a 100644
@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
drivers/thermal/samsung/exynos_tmu.h +0 -5
index 7f880d2..627dec9 100644
@@ -83,9 +83,6 @@ enum soc_type {
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
 	enum soc_type type;
 	u32 cal_type;
 	u32 cal_mode;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.c +3 -39

66 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#212 lore raw

PATCH v6 9/18 thermal: exynos: dts: Add default definition of the TMU sensor parameter

In reply to Lukasz Majewski

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the on chip temperature. For this reason it is possible to group TMU configuration parameters in one dts file.

---
Changes for v2:
- None
Changes for v3:
- "samsung,tmu_" prefix for TMU specific properties has been added Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi new file +24 -0
new file mode 100644
index 0000000..e3f7934
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <8>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <55>;
+samsung,tmu_min_efuse_value = <40>;
+samsung,tmu_max_efuse_value = <100>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <85>;
+samsung,tmu_default_temp_offset = <50>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
Signature · 1 line
2.0.0.rc2
#213 lore raw

PATCH v6 10/18 dts: Documentation: Extending documentation entry for exynos-thermal

In reply to Lukasz Majewski

Properties necessary for providing Exynos thermal configuration via device tree.

---
Changes for v3:
- New patch
Changes for v4:
- Remove entry regarding Exynos5440
Changes for v5:
- None
Changes for v6:
- None

---
 .../devicetree/bindings/thermal/exynos-thermal.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +16 -0
index ae738f5..8497794 100644
@@ -39,6 +39,18 @@
 - vtmu-supply: This entry is optional and provides the regulator node supplying
 		voltage to TMU. If needed this entry can be placed inside
 		board/platform specific dts file.
+Following properties are mandatory (depending on SoC):
+- samsung,tmu_gain: Gain value for internal TMU operation.
+- samsung,tmu_reference_voltage: Value of TMU IP block's reference voltage
+- samsung,tmu_noise_cancel_mode: Mode for noise cancellation
+- samsung,tmu_efuse_value: Default level of temperature - it is needed when
+			   in factory fusing produced wrong value
+- samsung,tmu_min_efuse_value: Minimum temperature fused value
+- samsung,tmu_max_efuse_value: Maximum temperature fused value
+- samsung,tmu_first_point_trim: First point trimming value
+- samsung,tmu_second_point_trim: Second point trimming value
+- samsung,tmu_default_temp_offset: Default temperature offset
+- samsung,tmu_cal_type: Callibration type
 
 Example 1):
 
@@ -51,6 +63,7 @@ Example 1):
 		clock-names = "tmu_apbif";
 		status = "disabled";
 		vtmu-supply = <&tmu_regulator_node>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Example 2):
@@ -70,6 +83,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 184 0>;
 		clocks = <&clock 318>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -78,6 +92,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 185 0>;
 		clocks = <&clock 318>, <&clock 319>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -86,6 +101,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 215 0>;
 		clocks = <&clock 319>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Note: For multi-instance tmu each instance should have an alias correctly
Signature · 1 line
2.0.0.rc2
#214 lore raw

PATCH v6 11/18 thermal: dts: Default trip points definition for Exynos5420 SoCs

In reply to Lukasz Majewski

This code groups in one place default settings of trip points. It is used in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
arch/arm/boot/dts/exynos5420-trip-points.dtsi new file +35 -0
new file mode 100644
index 0000000..09d6c56
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
Signature · 1 line
2.0.0.rc2
#215 lore raw

PATCH v6 12/18 thermal: exynos: dts: Define default thermal-zones for Exynos4

In reply to Lukasz Majewski

Trip points corresponding to the one defined in the exynos_tmu_data.c for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412 and Exynos5250.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
arch/arm/boot/dts/exynos4-cpu-thermal.dtsi new file +52 -0
new file mode 100644
index 0000000..506600a
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
Signature · 1 line
2.0.0.rc2
#216 lore raw

PATCH v6 13/18 thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440

In reply to Lukasz Majewski

This commit provides information about Exynos5440 device configuration. Previously this information was available in exynos_tmu_data.c file. Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

---
Changes for v2:
- None
Changes for v3:
- "type" property removed
- "samsung,tmu_" prefix for TMU specific properties has been added Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 24 ++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi new file +24 -0
new file mode 100644
index 0000000..7b2fba0
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <5>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <0x5d2d>;
+samsung,tmu_min_efuse_value = <16>;
+samsung,tmu_max_efuse_value = <76>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <70>;
+samsung,tmu_default_temp_offset = <25>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
arch/arm/boot/dts/exynos5440-trip-points.dtsi new file +25 -0
new file mode 100644
index 0000000..48adfa8
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
Signature · 1 line
2.0.0.rc2
#217 lore raw

PATCH v6 14/18 dts: Documentation: Update exynos-thermal.txt example for Exynos5440

In reply to Lukasz Majewski

Updating exynos-thermal.txt documentation entry for Exynos5440

---
Changes for v4:
- New patch
Changes for v5:
- None
Changes for v6:
- None

---
 Documentation/devicetree/bindings/thermal/exynos-thermal.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +1 -0
index 8497794..0f44932 100644
@@ -74,6 +74,7 @@ Example 2):
 		interrupts = <0 58 0>;
 		clocks = <&clock 21>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
Signature · 1 line
2.0.0.rc2
#218 lore raw

PATCH v6 15/18 thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c

In reply to Lukasz Majewski

Presented device tree bindings provide data already hardcoded in the exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core framework in Exynos SoCs.

---
Changes for v2:
- Add proper TMU entries for exynos3250.dtsi
Changes for v3:
- Remove "type" DT properties, which will be extracted from compatible
- "samsung,tmu_" prefix for TMU specific properties has been added Changes for v4:
- Providing mandatory properties for thermal-zones (Exynos4210 and Exynos5250) Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos3250.dtsi |  2 ++
 arch/arm/boot/dts/exynos4.dtsi    |  4 ++++
 arch/arm/boot/dts/exynos4210.dtsi | 25 ++++++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  1 +
 arch/arm/boot/dts/exynos5250.dtsi |  9 +++++++--
 arch/arm/boot/dts/exynos5420.dtsi | 28 ++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 7 files changed, 84 insertions(+), 3 deletions(-)
arch/arm/boot/dts/exynos3250.dtsi +2 -0
index 2246549..8cc078c 100644
@@ -18,6 +18,7 @@
  */
 
 #include "skeleton.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos3250.h>
 
 / {
@@ -188,6 +189,7 @@
 			interrupts = <0 216 0>;
 			clocks = <&cmu CLK_TMU_APBIF>;
 			clock-names = "tmu_apbif";
+			#include "exynos4412-tmu-sensor-conf.dtsi"
 			status = "disabled";
 		};
 
arch/arm/boot/dts/exynos4.dtsi +4 -0
index b8168f1..f18d746 100644
@@ -645,4 +645,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu@100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
arch/arm/boot/dts/exynos4210.dtsi +24 -1
index 2e66df8..78a43b0 100644
@@ -21,6 +21,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +147,38 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu@100C0000 {
+	tmu: tmu@100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		samsung,tmu_gain = <15>;
+		samsung,tmu_reference_voltage = <7>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d@12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
arch/arm/boot/dts/exynos4x12.dtsi +1 -0
index 93b7040..3ee2031 100644
@@ -19,6 +19,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	aliases {
arch/arm/boot/dts/exynos5250.dtsi +7 -2
index 4641d3c..90211c0 100644
@@ -20,7 +20,7 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
 
 / {
@@ -236,16 +236,21 @@
 		status = "disabled";
 	};
 
-	tmu@10060000 {
+	tmu: tmu@10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
 		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
 			cooling-maps {
 				map0 {
 				     /* Corresponds to 800MHz at freq_table */
arch/arm/boot/dts/exynos5420.dtsi +28 -0
index 517e50f..f5771e5 100644
@@ -761,6 +761,7 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu1: tmu@10064000 {
@@ -769,6 +770,7 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu2: tmu@10068000 {
@@ -777,6 +779,7 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -785,6 +788,7 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -793,6 +797,30 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog@101D0000 {
arch/arm/boot/dts/exynos5440.dtsi +18 -0
index 8f3373c..59d9416 100644
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl@16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl@160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata@210000 {
Signature · 1 line
2.0.0.rc2
#219 lore raw

PATCH v6 16/18 thermal: samsung: core: Exynos TMU rework to use device tree for configuration

In reply to Lukasz Majewski

This patch brings support for providing configuration via device tree. Previously this data has been hardcoded in the exynos_tmu_data.c file. Such approach was not scalable and very often required copying the whole data.

---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table
Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None
Changes for v5:
- Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan <[email protected]>
Changes for v6:
- change exynos_get_temp() definition to be static
- squash with v5's patch:
"thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h"
- Remove space after cast to squash checkpatch.pl --strict

---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 339 ++++++++++++++++++++++-------------
 drivers/thermal/samsung/exynos_tmu.h |  61 +------
 3 files changed, 220 insertions(+), 182 deletions(-)
drivers/thermal/samsung/Makefile +0 -2
index c09d830..1e47d0d 100644
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
drivers/thermal/samsung/exynos_tmu.c +219 -120

568 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu.h +1 -60

92 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#220 lore raw

PATCH v6 17/18 thermal: exynos: Remove exynos_thermal_common.[c|h] files

In reply to Lukasz Majewski

After defining all necessary Exynos data in the device tree and heavy reusage of the of-thermal.c those files can be removed.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 drivers/thermal/samsung/exynos_thermal_common.c | 445 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 551 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
drivers/thermal/samsung/exynos_thermal_common.c deleted +0 -445
deleted file mode 100644
index 00aa688..0000000
@@ -1,445 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	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_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	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
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-				cpufreq_cooling_register(cpu_present_mask);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
-			if (ret != -EPROBE_DEFER)
-				dev_err(sensor_conf->dev,
-					"Failed to register cpufreq cooling device: %d\n",
-					ret);
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; ++i)
-		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
drivers/thermal/samsung/exynos_thermal_common.h deleted +0 -106

106 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#221 lore raw

PATCH v6 18/18 thermal: exynos: Remove exynos_tmu_data.c file

In reply to Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the appropriate device tree files.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
drivers/thermal/samsung/exynos_tmu_data.c deleted +0 -228
deleted file mode 100644
index a993f3d..0000000
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
Signature · 1 line
2.0.0.rc2
#222 lore raw
In reply to Lukasz Majewski
Quoted 46 lines · Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

Quoted 7 lines

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc cycle)

Quoted 5 lines

thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be included in
device tree files
thermal: exynos: Modify exynos thermal code to use device tree for cpu
cooling configuration

Quoted 8 lines

cpufreq: exynos: Use device tree to determine if cpufreq cooling
should be registered
dts: Documentation: Extending documentation entry for exynos-thermal
dts: Documentation: Update exynos-thermal.txt example for Exynos5440
thermal: samsung: core: Exynos TMU rework to use device tree for
configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

The patches below should go via platform tree:

Quoted 9 lines

arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
arm: dts: Adding CPU cooling binding for Exynos SoCs
thermal: exynos: dts: Add default definition of the TMU sensor
parameter
thermal: dts: Default trip points definition for Exynos5420 SoCs
thermal: exynos: dts: Define default thermal-zones for Exynos4
thermal: dts: exynos: Trip points and sensor configuration data for

Quoted 3 lines
    Exynos5440

thermal: exynos: dts: Provide device tree bindings identical to the
one in exynos_tmu_data.c

Thanks a lot.

Quoted 41 lines
 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  76 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 636 insertions(+), 1008 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
Signature · 1 line
2.0.0.rc2
#223 lore raw

Hi Eduardo,

Quoted 50 lines · Lukasz Majewski
Quoted 49 lines

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

5. This work apply on the following tree:

Quoted 22 lines
Quoted 5 lines

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc cycle)

Quoted 13 lines

thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be included in
device tree files
thermal: exynos: Modify exynos thermal code to use device tree
for cpu cooling configuration
cpufreq: exynos: Use device tree to determine if cpufreq cooling
should be registered
dts: Documentation: Extending documentation entry for
exynos-thermal dts: Documentation: Update exynos-thermal.txt example for Exynos5440 thermal: samsung: core: Exynos TMU rework to use device tree for configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

By some mishap the last patch "thermal: exynos: Remove exynos_tmu_data.c file" was not applied to neither linux-soc-thermal/next nor linux-soc-thermal/fixes.

Eduardo, could you apply it?

Quoted 62 lines

The patches below should go via platform tree:

Quoted 4 lines

arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU on
Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device arm: dts: Adding CPU cooling binding for Exynos SoCs

Quoted 8 lines

thermal: exynos: dts: Add default definition of the TMU sensor
parameter
thermal: dts: Default trip points definition for Exynos5420 SoCs
thermal: exynos: dts: Define default thermal-zones for Exynos4
thermal: dts: exynos: Trip points and sensor configuration data
for Exynos5440
thermal: exynos: dts: Provide device tree bindings identical to
the one in exynos_tmu_data.c

Thanks a lot.

Quoted 43 lines
 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427

---------------------
drivers/thermal/samsung/exynos_thermal_common.h | 106 -----
drivers/thermal/samsung/exynos_tmu.c | 348
+++++++++++------
drivers/thermal/samsung/exynos_tmu.h | 76 +---
drivers/thermal/samsung/exynos_tmu_data.c | 264
------------- include/dt-bindings/thermal/thermal_exynos.h |
28 ++ 26 files changed, 636 insertions(+), 1008 deletions(-) create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

Signature · 1 line
2.0.0.rc2
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#224 lore raw
In reply to Eduardo Valentin
Quoted 72 lines · Eduardo Valentin
Quoted 46 lines · Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

Quoted 7 lines

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc cycle)

Quoted 5 lines

thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be included in
device tree files
thermal: exynos: Modify exynos thermal code to use device tree for cpu
cooling configuration

Quoted 8 lines

cpufreq: exynos: Use device tree to determine if cpufreq cooling
should be registered
dts: Documentation: Extending documentation entry for exynos-thermal
dts: Documentation: Update exynos-thermal.txt example for Exynos5440
thermal: samsung: core: Exynos TMU rework to use device tree for
configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

Quoted 15 lines

The patches below should go via platform tree:

Quoted 12 lines

arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
arm: dts: Adding CPU cooling binding for Exynos SoCs
thermal: exynos: dts: Add default definition of the TMU sensor
parameter
thermal: dts: Default trip points definition for Exynos5420 SoCs
thermal: exynos: dts: Define default thermal-zones for Exynos4
thermal: dts: exynos: Trip points and sensor configuration data for

    Exynos5440

thermal: exynos: dts: Provide device tree bindings identical to the
one in exynos_tmu_data.c

I've applied above patches with small subject changes.

BTW unfortunately, since missing the "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't merge it into for-next yet.

Can you please provide a topic branch for it? If not, this cannot be handled in arm-soc tree in this time, I think.

- Kukjin

Quoted 40 lines

Thanks a lot.

Quoted 37 lines
 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
 drivers/thermal/sam`sung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  76 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 636 insertions(+), 1008 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
#225 lore raw

Hi Kukjin, Eduardo

Quoted 91 lines · Eduardo Valentin
Quoted 74 lines · Lukasz Majewski
Quoted 48 lines

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

Quoted 7 lines

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc cycle)

Quoted 5 lines

thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be included in
device tree files
thermal: exynos: Modify exynos thermal code to use device tree
for cpu cooling configuration

Quoted 8 lines

cpufreq: exynos: Use device tree to determine if cpufreq cooling
should be registered
dts: Documentation: Extending documentation entry for
exynos-thermal dts: Documentation: Update exynos-thermal.txt example for Exynos5440 thermal: samsung: core: Exynos TMU rework to use device tree for configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

Quoted 15 lines

The patches below should go via platform tree:

Quoted 12 lines

arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU on
Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device arm: dts: Adding CPU cooling binding for Exynos SoCs
thermal: exynos: dts: Add default definition of the TMU sensor
parameter
thermal: dts: Default trip points definition for Exynos5420 SoCs
thermal: exynos: dts: Define default thermal-zones for Exynos4
thermal: dts: exynos: Trip points and sensor configuration data
for Exynos5440
thermal: exynos: dts: Provide device tree bindings identical to
the one in exynos_tmu_data.c

Quoted 5 lines

I've applied above patches with small subject changes.

BTW unfortunately, since missing the "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't merge it into for-next yet.

As of this writing: (Kernel 4.0-rc1) the "include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel tree.

Kukjin, could you add missing DTS files and send this to upstream.

Thanks in advance.

Quoted 49 lines

Can you please provide a topic branch for it? If not, this cannot be handled in arm-soc tree in this time, I think.

- Kukjin

Quoted 43 lines

Thanks a lot.

Quoted 40 lines
 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
 drivers/thermal/sam`sung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427

---------------------
drivers/thermal/samsung/exynos_thermal_common.h | 106 -----
drivers/thermal/samsung/exynos_tmu.c | 348
+++++++++++------
drivers/thermal/samsung/exynos_tmu.h | 76 +---
drivers/thermal/samsung/exynos_tmu_data.c | 264
------------- include/dt-bindings/thermal/thermal_exynos.h | 28 ++ 26 files changed, 636 insertions(+), 1008 deletions(-) create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#226 lore raw
Quoted 3 lines · Lukasz Majewski

Hi Kukjin, Eduardo

Hi,

Quoted 93 lines
Quoted 93 lines · Eduardo Valentin
Quoted 74 lines · Lukasz Majewski
Quoted 48 lines

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

Quoted 7 lines

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc cycle)

Quoted 5 lines

thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be included in
device tree files
thermal: exynos: Modify exynos thermal code to use device tree
for cpu cooling configuration

Quoted 8 lines

cpufreq: exynos: Use device tree to determine if cpufreq cooling
should be registered
dts: Documentation: Extending documentation entry for
exynos-thermal dts: Documentation: Update exynos-thermal.txt example for Exynos5440 thermal: samsung: core: Exynos TMU rework to use device tree for configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

Quoted 15 lines

The patches below should go via platform tree:

Quoted 12 lines

arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU on
Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device arm: dts: Adding CPU cooling binding for Exynos SoCs
thermal: exynos: dts: Add default definition of the TMU sensor
parameter
thermal: dts: Default trip points definition for Exynos5420 SoCs
thermal: exynos: dts: Define default thermal-zones for Exynos4
thermal: dts: exynos: Trip points and sensor configuration data
for Exynos5440
thermal: exynos: dts: Provide device tree bindings identical to
the one in exynos_tmu_data.c

I've applied above patches with small subject changes.

Quoted 8 lines
Quoted 3 lines

BTW unfortunately, since missing the "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't merge it into for-next yet.

As of this writing: (Kernel 4.0-rc1) the "include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel tree.

I know.

Quoted 2 lines

Kukjin, could you add missing DTS files and send this to upstream.

Unfortunately, I couldn't take the DT changes in Samsung tree at that time because of missing header file and it causes build error. Now I can pick them into Samsung tree but I'm not sure it can be sent to upstream during this -rc...

Eduardo, Lukasz,
Do you guys think the DT changes are really fixes for 4.0?

Quoted 7 lines

Thanks in advance.

Quoted 5 lines

Can you please provide a topic branch for it? If not, this cannot be handled in arm-soc tree in this time, I think.

- Kukjin

#227 lore raw

Hi Kukjin,

Quoted 107 lines
Quoted 3 lines · Lukasz Majewski

Hi Kukjin, Eduardo

Hi,

Quoted 93 lines
Quoted 93 lines · Eduardo Valentin
Quoted 74 lines · Lukasz Majewski
Quoted 48 lines

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

Quoted 7 lines

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc cycle)

Quoted 5 lines

thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be
included in device tree files
thermal: exynos: Modify exynos thermal code to use device
tree for cpu cooling configuration

Quoted 8 lines

cpufreq: exynos: Use device tree to determine if cpufreq
cooling should be registered
dts: Documentation: Extending documentation entry for
exynos-thermal dts: Documentation: Update exynos-thermal.txt example for Exynos5440 thermal: samsung: core: Exynos TMU rework to use device tree for configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

Quoted 15 lines

The patches below should go via platform tree:

Quoted 12 lines

arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU
on Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device arm: dts: Adding CPU cooling binding for Exynos SoCs thermal: exynos: dts: Add default definition of the TMU sensor parameter
thermal: dts: Default trip points definition for Exynos5420
SoCs thermal: exynos: dts: Define default thermal-zones for Exynos4 thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
thermal: exynos: dts: Provide device tree bindings identical
to the one in exynos_tmu_data.c

I've applied above patches with small subject changes.

Quoted 8 lines
Quoted 3 lines

BTW unfortunately, since missing the "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't merge it into for-next yet.

As of this writing: (Kernel 4.0-rc1) the "include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel tree.

Quoted 6 lines

I know.

Quoted 2 lines

Kukjin, could you add missing DTS files and send this to upstream.

Unfortunately, I couldn't take the DT changes in Samsung tree at that time because of missing header file and it causes build error.

The header problem was due to splitting this patch set to -samsung and -thermal trees.
The intention was to merge it all at once, but unfortunately it was split.

Quoted 6 lines

Now I
can pick them into Samsung tree but I'm not sure it can be sent to upstream during this -rc...

Eduardo, Lukasz,
Do you guys think the DT changes are really fixes for 4.0?

The thermal Samsung rework has been merged, so without this DTS files we have regression, since boards like Trats2, Odroid will not have thermal support in 4.0 final release.

Additionally we are now at -rc1 state, so some extra time is left to handle unexpected situation (although there shouldn't be any).

Quoted 9 lines
Quoted 8 lines

Thanks in advance.

Quoted 5 lines

Can you please provide a topic branch for it? If not, this cannot be handled in arm-soc tree in this time, I think.

- Kukjin

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#228 lore raw
In reply to Kukjin Kim

Hi Kukjin,

Quoted 111 lines
Quoted 3 lines · Lukasz Majewski

Hi Kukjin, Eduardo

Hi,

Quoted 93 lines
Quoted 93 lines · Eduardo Valentin
Quoted 74 lines · Lukasz Majewski
Quoted 48 lines

1. Introduction

Following patches aim to clean up the current implementation of the thermal framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling devices by reducing operating frequency. Definition of trip points and cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to the Exynos thermal subsystem was performed. Now device tree is used for configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality has been preserved in the code, but not tested on the hardware. I would be grateful for help in testing.

Quoted 7 lines

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc cycle)

Quoted 5 lines

thermal: exynos: cosmetic: Correct comment format
thermal: exynos: Provide thermal_exynos.h file to be
included in device tree files
thermal: exynos: Modify exynos thermal code to use device
tree for cpu cooling configuration

Quoted 8 lines

cpufreq: exynos: Use device tree to determine if cpufreq
cooling should be registered
dts: Documentation: Extending documentation entry for
exynos-thermal dts: Documentation: Update exynos-thermal.txt example for Exynos5440 thermal: samsung: core: Exynos TMU rework to use device tree for configuration
thermal: exynos: Remove exynos_thermal_common.[c|h] files
thermal: exynos: Remove exynos_tmu_data.c file

Quoted 15 lines

The patches below should go via platform tree:

Quoted 12 lines

arm: dts: trats: Enable TMU on the Exynos4210 trats device
arm: dts: odroid: Add LDO10 regulator node necessary for TMU
on Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device arm: dts: Adding CPU cooling binding for Exynos SoCs thermal: exynos: dts: Add default definition of the TMU sensor parameter
thermal: dts: Default trip points definition for Exynos5420
SoCs thermal: exynos: dts: Define default thermal-zones for Exynos4 thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
thermal: exynos: dts: Provide device tree bindings identical
to the one in exynos_tmu_data.c

I've applied above patches with small subject changes.

Quoted 8 lines
Quoted 3 lines

BTW unfortunately, since missing the "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't merge it into for-next yet.

As of this writing: (Kernel 4.0-rc1) the "include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel tree.

I know.

Quoted 2 lines

Kukjin, could you add missing DTS files and send this to upstream.

Quoted 7 lines

Unfortunately, I couldn't take the DT changes in Samsung tree at that time because of missing header file and it causes build error. Now I can pick them into Samsung tree but I'm not sure it can be sent to upstream during this -rc...

Eduardo, Lukasz,
Do you guys think the DT changes are really fixes for 4.0?

I've created following repository with DTS files:

https://github.com/lmajewski/linux-samsung-thermal.git

Branch: devel.

On top of the v4.0-rc1 tag you will find all necessary patches for fixing thermal regression at Samsung Exynos boards.

I hope, that organizing all patches in a separate repository will facilitate and speed up the inclusion process.

Quoted 9 lines
Quoted 8 lines

Thanks in advance.

Quoted 5 lines

Can you please provide a topic branch for it? If not, this cannot be handled in arm-soc tree in this time, I think.

- Kukjin

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#229 lore raw
Quoted 7 lines · Lukasz Majewski

Hi Kukjin,

Quoted 5 lines
Quoted 3 lines · Lukasz Majewski

Hi Kukjin, Eduardo

Hi,

[...]

Quoted 14 lines
Quoted 9 lines
Quoted 2 lines

Kukjin, could you add missing DTS files and send this to upstream.

Unfortunately, I couldn't take the DT changes in Samsung tree at that time because of missing header file and it causes build error. Now I can pick them into Samsung tree but I'm not sure it can be sent to upstream during this -rc...

Eduardo, Lukasz,
Do you guys think the DT changes are really fixes for 4.0?

I've created following repository with DTS files:

https://github.com/lmajewski/linux-samsung-thermal.git

Quoted 7 lines

Branch: devel.

On top of the v4.0-rc1 tag you will find all necessary patches for fixing thermal regression at Samsung Exynos boards.

I hope, that organizing all patches in a separate repository will facilitate and speed up the inclusion process.

I already did :-) If any problems on the branch (v4.0-samsung-dt-tmu-hdmi) in my tree, please kindly let me know.

Thanks,
Kukjin

#230 lore raw

PATCH v6 8/18 cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered

In reply to Lukasz Majewski

With thermal subsystem rework it is necessary to tune current cpufreq code to use cpu frequency change as a potential cooling device.

Now the cpu cooling device is registered only when proper nodes and properties are available in device tree. Lack of them, however, will not prevent cpufreq for normal operation.

---
Changes for v6:
- New patch

---
 drivers/cpufreq/exynos-cpufreq.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
drivers/cpufreq/exynos-cpufreq.c +32 -1
index f99a0b0..5e98c6b 100644
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *cpus, *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,36 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
+	ret = cpufreq_register_driver(&exynos_driver);
+	if (ret)
+		goto err_cpufreq_reg;
+
+	cpus = of_find_node_by_path("/cpus");
+	if (!cpus) {
+		pr_err("failed to find cpus node\n");
+		return 0;
+	}
+
+	np = of_get_next_child(cpus, NULL);
+	if (!np) {
+		pr_err("failed to find cpus child node\n");
+		of_node_put(cpus);
 		return 0;
+	}
+
+	if (of_find_property(np, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(np,
+						   cpu_present_mask);
+		if (IS_ERR(cdev))
+			pr_err("running cpufreq without cooling device: %ld\n",
+			       PTR_ERR(cdev));
+	}
+	of_node_put(np);
+	of_node_put(cpus);
+
+	return 0;
 
+err_cpufreq_reg:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
Signature · 1 line
2.0.0.rc2
maintainer
#231 lore raw

Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered

drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_probe(struct platform_device *pdev) · line 220

Quoted 12 lines · Lukasz Majewski
drivers/cpufreq/exynos-cpufreq.c +11 -0
+       cpus = of_find_node_by_path("/cpus");
+       if (!cpus) {
+               pr_err("failed to find cpus node\n");
+               return 0;
+       }
+
+       np = of_get_next_child(cpus, NULL);
+       if (!np) {
+               pr_err("failed to find cpus child node\n");
+               of_node_put(cpus);
                return 0;
+       }

Why making it complex? Just get device node for cpu 0 and do cpu_dev->np.

#232 lore raw

Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered

Hi Viresh,

Quoted 15 lines

drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_probe(struct platform_device *pdev) · line 220

Quoted 12 lines · Lukasz Majewski
drivers/cpufreq/exynos-cpufreq.c +11 -0
+       cpus = of_find_node_by_path("/cpus");
+       if (!cpus) {
+               pr_err("failed to find cpus node\n");
+               return 0;
+       }
+
+       np = of_get_next_child(cpus, NULL);
+       if (!np) {
+               pr_err("failed to find cpus child node\n");
+               of_node_put(cpus);
                return 0;
+       }
Quoted 2 lines

Why making it complex? Just get device node for cpu 0 and do cpu_dev->np.

Please pay a note about following problem:

Previously we got: cpu0: cpu@0 for all Exynos devices.

Now, however, cpu numbering has changed (due to GIC rework). For example:

Exynos4412:

	cpus {
		cpu0: cpu@A00 {
			...
			#cooling-cells = <2>; /* min followed by max */
		};

		cpu@A01 {
		};

		cpu@A02 {
		};

		cpu@A03 {
		};
	}

Exynos 4210:

	cpus {
		cpu0: cpu@900 {
			#cooling-cells = <2>; /* min followed by max */
		};

		cpu@901 {
		};
	};

Exynos 5250:

	cpus {
		cpu0: cpu@0 {
			#cooling-cells = <2>; /* min followed by max */
		};

		cpu@1 {
		};
	};

As you can see different cpu@XXY nodes we have and simply calling cpu@0 won't work.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
maintainer
#233 lore raw

Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered

Quoted 45 lines · Lukasz Majewski

Please pay a note about following problem:

Previously we got: cpu0: cpu@0 for all Exynos devices.

Now, however, cpu numbering has changed (due to GIC rework). For example:

Exynos4412:

        cpus {
                cpu0: cpu@A00 {
                        ...
                        #cooling-cells = <2>; /* min followed by max */
                };

                cpu@A01 {
                };

                cpu@A02 {
                };

                cpu@A03 {
                };
        }

Exynos 4210:

        cpus {
                cpu0: cpu@900 {
                        #cooling-cells = <2>; /* min followed by max */
                };

                cpu@901 {
                };
        };

Exynos 5250:

        cpus {
                cpu0: cpu@0 {
                        #cooling-cells = <2>; /* min followed by max */
                };

                cpu@1 {
                };
        };
Quoted 2 lines

As you can see different cpu@XXY nodes we have and simply calling cpu@0 won't work.

I wasn't asked you to get the cpu0 node from dt but this:

cpu_dev = get_cpu_dev(0);
np = of_node_get(cpu_dev->of_node);

Wouldn't this work? You only need to guarantee that the cooling-cells is added onto the boot CPUs node.

#234 lore raw

Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered

Quoted 47 lines · On Sun, 25 Jan 2015 19:31:14 +0530 Viresh Kumar <[email protected]> wrote:
Quoted 45 lines · Lukasz Majewski

Please pay a note about following problem:

Previously we got: cpu0: cpu@0 for all Exynos devices.

Now, however, cpu numbering has changed (due to GIC rework). For example:

Exynos4412:

        cpus {
                cpu0: cpu@A00 {
                        ...
                        #cooling-cells = <2>; /* min followed by

max */ };

                cpu@A01 {
                };

                cpu@A02 {
                };

                cpu@A03 {
                };
        }

Exynos 4210:

        cpus {
                cpu0: cpu@900 {
                        #cooling-cells = <2>; /* min followed by

max */ };

                cpu@901 {
                };
        };

Exynos 5250:

        cpus {
                cpu0: cpu@0 {
                        #cooling-cells = <2>; /* min followed by

max */ };

                cpu@1 {
                };
        };
Quoted 7 lines
Quoted 2 lines

As you can see different cpu@XXY nodes we have and simply calling cpu@0 won't work.

I wasn't asked you to get the cpu0 node from dt but this:

cpu_dev = get_cpu_dev(0);
np = of_node_get(cpu_dev->of_node);

Ingenious simplicity :-)

Quoted 3 lines

Wouldn't this work? You only need to guarantee that the cooling-cells is added onto the boot CPUs node.

I will test it tomorrow and share results.

Viresh, thanks for tip.

Best regards,
Lukasz Majewski

#235 lore raw

Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered

In reply to Viresh Kumar
Quoted 49 lines · Viresh Kumar
Quoted 45 lines · Lukasz Majewski

Please pay a note about following problem:

Previously we got: cpu0: cpu@0 for all Exynos devices.

Now, however, cpu numbering has changed (due to GIC rework). For example:

Exynos4412:

        cpus {
                cpu0: cpu@A00 {
                        ...
                        #cooling-cells = <2>; /* min followed by max */
                };

                cpu@A01 {
                };

                cpu@A02 {
                };

                cpu@A03 {
                };
        }

Exynos 4210:

        cpus {
                cpu0: cpu@900 {
                        #cooling-cells = <2>; /* min followed by max */
                };

                cpu@901 {
                };
        };

Exynos 5250:

        cpus {
                cpu0: cpu@0 {
                        #cooling-cells = <2>; /* min followed by max */
                };

                cpu@1 {
                };
        };
Quoted 2 lines

As you can see different cpu@XXY nodes we have and simply calling cpu@0 won't work.

Quoted 7 lines

I wasn't asked you to get the cpu0 node from dt but this:

cpu_dev = get_cpu_dev(0);
np = of_node_get(cpu_dev->of_node);

Wouldn't this work? You only need to guarantee that the cooling-cells is added onto the boot CPUs node.

Lukasz,

I agree with Viresh here, you can simplify your code.

I, somehow, missed this conversation and already applied v6 of this patch in my -fixes branch. Can you please fix this by sending a differential patch on top of this one applying Viresh's commit?

Viresh, my bad, I missed your comments.

Thanks

Eduardo

#236 lore raw

Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered

Quoted 59 lines · On Sun, 25 Jan 2015 12:46:21 -0400 Eduardo Valentin <[email protected]> wrote:
Quoted 50 lines · Viresh Kumar
Quoted 40 lines · Lukasz Majewski

Please pay a note about following problem:

Previously we got: cpu0: cpu@0 for all Exynos devices.

Now, however, cpu numbering has changed (due to GIC rework). For example:

Exynos4412:

        cpus {
                cpu0: cpu@A00 {
                        ...
                        #cooling-cells = <2>; /* min followed by

max */ };

                cpu@A01 {
                };

                cpu@A02 {
                };

                cpu@A03 {
                };
        }

Exynos 4210:

        cpus {
                cpu0: cpu@900 {
                        #cooling-cells = <2>; /* min followed by

max */ };

                cpu@901 {
                };
        };

Exynos 5250:

        cpus {
                cpu0: cpu@0 {
                        #cooling-cells = <2>; /* min followed by

max */ };

Quoted 7 lines
                cpu@1 {
                };
        };

As you can see different cpu@XXY nodes we have and simply calling cpu@0 won't work.

Quoted 7 lines

I wasn't asked you to get the cpu0 node from dt but this:

cpu_dev = get_cpu_dev(0);
np = of_node_get(cpu_dev->of_node);

Wouldn't this work? You only need to guarantee that the cooling-cells is added onto the boot CPUs node.

Quoted 7 lines

Lukasz,

I agree with Viresh here, you can simplify your code.

I, somehow, missed this conversation and already applied v6 of this patch in my -fixes branch. Can you please fix this by sending a differential patch on top of this one applying Viresh's commit?

No problem, I will check this in my office tomorrow.

Thanks.

Quoted 7 lines

Viresh, my bad, I missed your comments.

Thanks

Eduardo

#237 lore raw

PATCH 1/1 cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

In reply to Lukasz Majewski

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to use device tree to asses if cpu can be used as cooling device. Since the code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/cpufreq/exynos-cpufreq.c +6 -15
index 5e98c6b..b640da0 100644
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0, *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling device: %ld\n",
 			       PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;
 
Signature · 1 line
2.0.0.rc2
maintainer Acked-by on v1 1/1
#238 lore raw

Re: [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

Quoted 48 lines · Lukasz Majewski

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to use device tree to asses if cpu can be used as cooling device. Since the code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/cpufreq/exynos-cpufreq.c +5 -13
index 5e98c6b..b640da0 100644
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-       struct device_node *cpus, *np;
+       struct device_node *cpu0, *np;
        int ret = -EINVAL;
 
        exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
        if (ret)
                goto err_cpufreq_reg;
 
-       cpus = of_find_node_by_path("/cpus");
-       if (!cpus) {
-               pr_err("failed to find cpus node\n");
+       cpu0 = of_get_cpu_node(0, NULL);
+       if (!cpu0) {
+               pr_err("failed to find cpu0 node\n");
                return 0;
        }
 
-       np = of_get_next_child(cpus, NULL);
-       if (!np) {
-               pr_err("failed to find cpus child node\n");
-               of_node_put(cpus);
-               return 0;
-       }
-
-       if (of_find_property(np, "#cooling-cells", NULL)) {
-               cdev = of_cpufreq_cooling_register(np,
+       if (of_find_property(cpu0, "#cooling-cells", NULL)) {

drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_probe(struct platform_device *pdev) · line 223

Quoted 10 lines
drivers/cpufreq/exynos-cpufreq.c +1 -2
+               cdev = of_cpufreq_cooling_register(cpu0,
                                                   cpu_present_mask);
                if (IS_ERR(cdev))
                        pr_err("running cpufreq without cooling device: %ld\n",
                               PTR_ERR(cdev));
        }
-       of_node_put(np);
-       of_node_put(cpus);
 
        return 0;
#239 lore raw

Re: [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

Hi Eduardo,

Quoted 60 lines
Quoted 58 lines · Lukasz Majewski

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to use device tree to asses if cpu can be used as cooling device. Since the code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
(quoted diff) +0 -0

b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..b640da0 100644

drivers/cpufreq/exynos-cpufreq.c +6 -15
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-       struct device_node *cpus, *np;
+       struct device_node *cpu0, *np;
        int ret = -EINVAL;
 
        exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
 platform_device *pdev) if (ret)
                goto err_cpufreq_reg;
 
-       cpus = of_find_node_by_path("/cpus");
-       if (!cpus) {
-               pr_err("failed to find cpus node\n");
+       cpu0 = of_get_cpu_node(0, NULL);
+       if (!cpu0) {
+               pr_err("failed to find cpu0 node\n");
                return 0;
        }
 
-       np = of_get_next_child(cpus, NULL);
-       if (!np) {
-               pr_err("failed to find cpus child node\n");
-               of_node_put(cpus);
-               return 0;
-       }
-
-       if (of_find_property(np, "#cooling-cells", NULL)) {
-               cdev = of_cpufreq_cooling_register(np,
+       if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+               cdev = of_cpufreq_cooling_register(cpu0,
                                                   cpu_present_mask);
                if (IS_ERR(cdev))
                        pr_err("running cpufreq without cooling
 device: %ld\n", PTR_ERR(cdev));
        }
-       of_node_put(np);
-       of_node_put(cpus);
 
Quoted 3 lines

drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_probe(struct · line 223

Quoted 1 line
drivers/cpufreq/exynos-cpufreq.c +0 -0
        return 0;

Could you apply this patch to yours linux-soc-thermal tree?

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#240 lore raw

PATCH v2 1/1 cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to use device tree to asses if cpu can be used as cooling device. Since the code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

---
Changes for v2:
- Remove superfluous *np pointer

---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/cpufreq/exynos-cpufreq.c +6 -15
index 5e98c6b..82d2fbb 100644
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling device: %ld\n",
 			       PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;
 
Signature · 1 line
2.0.0.rc2
#241 lore raw

Re: [PATCH v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

Hi Eduardo,

Quoted 10 lines

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to use device tree to asses if cpu can be used as cooling device. Since the code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

This patch is also missing from linux-thermal-soc tree.

I will add it to samsung thermal tree, since Viresh has ACK'ed it.

Quoted 54 lines

---
Changes for v2:
- Remove superfluous *np pointer

---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
(quoted diff) +0 -0

b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644

drivers/cpufreq/exynos-cpufreq.c +6 -15
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
 platform_device *pdev) if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling
 device: %ld\n", PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;
 
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#242 lore raw

Re: [PATCH v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

Quoted 9 lines · Lukasz Majewski

Hi Eduardo,

Quoted 7 lines

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to use device tree to asses if cpu can be used as cooling device. Since the code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

Quoted 7 lines
Quoted 3 lines

This patch is also missing from linux-thermal-soc tree.

I will add it to samsung thermal tree, since Viresh has ACK'ed it.

Do we have any dependency with something which is only in the thermal tree(s)? If not, I suggest the cpufreq changes go via cpufreq tree(s).

BR,

Eduardo Valentin

Quoted 64 lines
Quoted 55 lines

---
Changes for v2:
- Remove superfluous *np pointer

---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
(quoted diff) +0 -0

b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644

drivers/cpufreq/exynos-cpufreq.c +6 -15
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
 platform_device *pdev) if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling
 device: %ld\n", PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;
 
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#243 lore raw

Re: [PATCH v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

Hi Eduardo,

Quoted 14 lines · Lukasz Majewski
Quoted 13 lines

Hi Eduardo,

Quoted 10 lines

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to use device tree to asses if cpu can be used as cooling device. Since the code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

Quoted 6 lines
Quoted 3 lines

This patch is also missing from linux-thermal-soc tree.

I will add it to samsung thermal tree, since Viresh has ACK'ed it.

Do we have any dependency with something which is only in the thermal tree(s)? If not, I suggest the cpufreq changes go via cpufreq tree(s).

As fair as I remember, Viresh didn't mind if this patch would go via thermal tree, since it is an integral part of the thermal solution for Exynos.

Frankly, I'm for keeping all "related" patches in one tree (especially when somebody already ACKed the patch) and not split them into several trees.

Look how bad things look now with thermal DTS patches .... If we would have taken them all at once, we hadn't had current problems.

Best regards,
Lukasz Majewski

Quoted 70 lines

BR,

Eduardo Valentin

Quoted 64 lines
Quoted 55 lines

---
Changes for v2:
- Remove superfluous *np pointer

---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
(quoted diff) +0 -0

b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644

drivers/cpufreq/exynos-cpufreq.c +6 -15
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
 platform_device *pdev) if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling
 device: %ld\n", PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;
 
Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group