Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
Hi Eduardo, On Wed, Jan 21, 2015 at 09:10:15AM +0100, Lukasz Majewski wrote: Hi Eduardo, On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote: Hi Eduardo, On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote: 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. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- 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 --- drivers/thermal/samsung/Makefile | 2 - drivers/thermal/samsung/exynos_tmu.c | 345 +++ drivers/thermal/samsung/exynos_tmu.h | 53 +- 3 files changed, 226 insertions(+), 174 deletions(-) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,5 +3,3 @@ # obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o exynos_thermal-y:= exynos_tmu.o -exynos_thermal-y += exynos_tmu_data.o Can this makefile change be part of the patch that removes exynos_tmu_data.c? -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o Can this makefile change be part of the patch that removes exynos_thermal_common.c? Unfortunately, this code cannot be moved to the next patch, in which I remove the files, since this causes build break of the series. The code structure as is, provides working, bisectable thermal solution - thermal and cpu_cooling functionality is preserved across all commits in the series. My concern here is simply that this specific commit is leaving unused files in the tree. One option would be to remove the files altogether in this specific commit. Is is really necessary? This patch itself changes around 400 LOC. Those changes __are__ important and in my opinion deserve their own commit. When I squash following patches, which remove old exynos files, we would have around 1.2K LOC in a single commit. I think that current approach is far more readable. I agree that separating is far more readable. However, the commit leaves zombie files. For a sake of simplicity, lets leave those files as zombie for one (or at most two) commit. Eduardo, is there a chance for this series (the newest version is v5 - which include Ablibash comments) to be included to yours -next tree before v3.19 is out? Yes, we can target this. I have sent couple of minor comments on v5. Despite them, there are also some parts of this series that are supposed to be merged via other trees. The cpufreq part seams to be too little and Viresh has already flagged that I can merge it as long it is in a separated patch. Indeed, this was already agreed with Viresh. However, most part of this series touches arch/arm directory and those should go via your platform tree. Is there a change you could either as your Exynos maintainer to queue the patches touching arch/arm or ask him if he is fine if I merge them via my tree? I've asked Kukjin to ACK those patches, so it would be possible for you to grab them all and push them to your tree. Such approach allows us to keep this rework in one piece (and hence assure no regression). Cheers, diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 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 b.zolnier...@samsung.com + * Lukasz Majewski l.majew...@samsung.com + * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim dg77@samsung.com * Amit Daniel Kachhap amit.kach...@linaro.org @@ -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
Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
On Wed, Jan 21, 2015 at 09:10:15AM +0100, Lukasz Majewski wrote: Hi Eduardo, On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote: Hi Eduardo, On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote: 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. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- 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 --- drivers/thermal/samsung/Makefile | 2 - drivers/thermal/samsung/exynos_tmu.c | 345 +++ drivers/thermal/samsung/exynos_tmu.h | 53 +- 3 files changed, 226 insertions(+), 174 deletions(-) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,5 +3,3 @@ # obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o exynos_thermal-y := exynos_tmu.o -exynos_thermal-y += exynos_tmu_data.o Can this makefile change be part of the patch that removes exynos_tmu_data.c? -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o Can this makefile change be part of the patch that removes exynos_thermal_common.c? Unfortunately, this code cannot be moved to the next patch, in which I remove the files, since this causes build break of the series. The code structure as is, provides working, bisectable thermal solution - thermal and cpu_cooling functionality is preserved across all commits in the series. My concern here is simply that this specific commit is leaving unused files in the tree. One option would be to remove the files altogether in this specific commit. Is is really necessary? This patch itself changes around 400 LOC. Those changes __are__ important and in my opinion deserve their own commit. When I squash following patches, which remove old exynos files, we would have around 1.2K LOC in a single commit. I think that current approach is far more readable. I agree that separating is far more readable. However, the commit leaves zombie files. Eduardo, is there a chance for this series (the newest version is v5 - which include Ablibash comments) to be included to yours -next tree before v3.19 is out? Yes, we can target this. I have sent couple of minor comments on v5. Despite them, there are also some parts of this series that are supposed to be merged via other trees. The cpufreq part seams to be too little and Viresh has already flagged that I can merge it as long it is in a separated patch. However, most part of this series touches arch/arm directory and those should go via your platform tree. Is there a change you could either as your Exynos maintainer to queue the patches touching arch/arm or ask him if he is fine if I merge them via my tree? Cheers, diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 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 b.zolnier...@samsung.com + * Lukasz Majewski l.majew...@samsung.com + * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim dg77@samsung.com * Amit Daniel Kachhap amit.kach...@linaro.org @@ -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_SHIFT24 #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
Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
Hi Eduardo, On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote: Hi Eduardo, On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote: 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. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- 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 --- drivers/thermal/samsung/Makefile | 2 - drivers/thermal/samsung/exynos_tmu.c | 345 +++ drivers/thermal/samsung/exynos_tmu.h | 53 +- 3 files changed, 226 insertions(+), 174 deletions(-) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,5 +3,3 @@ # obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o exynos_thermal-y:= exynos_tmu.o -exynos_thermal-y += exynos_tmu_data.o Can this makefile change be part of the patch that removes exynos_tmu_data.c? -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o Can this makefile change be part of the patch that removes exynos_thermal_common.c? Unfortunately, this code cannot be moved to the next patch, in which I remove the files, since this causes build break of the series. The code structure as is, provides working, bisectable thermal solution - thermal and cpu_cooling functionality is preserved across all commits in the series. My concern here is simply that this specific commit is leaving unused files in the tree. One option would be to remove the files altogether in this specific commit. Is is really necessary? This patch itself changes around 400 LOC. Those changes __are__ important and in my opinion deserve their own commit. When I squash following patches, which remove old exynos files, we would have around 1.2K LOC in a single commit. I think that current approach is far more readable. Eduardo, is there a chance for this series (the newest version is v5 - which include Ablibash comments) to be included to yours -next tree before v3.19 is out? diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 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 b.zolnier...@samsung.com + * Lukasz Majewski l.majew...@samsung.com + * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim dg77@samsung.com * Amit Daniel Kachhap amit.kach...@linaro.org @@ -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_TRIMINFO0x0 @@ -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);
Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote: Hi Eduardo, On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote: 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. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- 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 --- drivers/thermal/samsung/Makefile | 2 - drivers/thermal/samsung/exynos_tmu.c | 345 +++ drivers/thermal/samsung/exynos_tmu.h | 53 +- 3 files changed, 226 insertions(+), 174 deletions(-) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,5 +3,3 @@ # obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o exynos_thermal-y := exynos_tmu.o -exynos_thermal-y+= exynos_tmu_data.o Can this makefile change be part of the patch that removes exynos_tmu_data.c? -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o Can this makefile change be part of the patch that removes exynos_thermal_common.c? Unfortunately, this code cannot be moved to the next patch, in which I remove the files, since this causes build break of the series. The code structure as is, provides working, bisectable thermal solution - thermal and cpu_cooling functionality is preserved across all commits in the series. My concern here is simply that this specific commit is leaving unused files in the tree. One option would be to remove the files altogether in this specific commit. diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 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 b.zolnier...@samsung.com + * Lukasz Majewski l.majew...@samsung.com + * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim dg77@samsung.com * Amit Daniel Kachhap amit.kach...@linaro.org @@ -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_SHIFT24 #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,
Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
Hi Eduardo, On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote: 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. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- 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 --- drivers/thermal/samsung/Makefile | 2 - drivers/thermal/samsung/exynos_tmu.c | 345 +++ drivers/thermal/samsung/exynos_tmu.h | 53 +- 3 files changed, 226 insertions(+), 174 deletions(-) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,5 +3,3 @@ # obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o exynos_thermal-y := exynos_tmu.o -exynos_thermal-y += exynos_tmu_data.o Can this makefile change be part of the patch that removes exynos_tmu_data.c? -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o Can this makefile change be part of the patch that removes exynos_thermal_common.c? Unfortunately, this code cannot be moved to the next patch, in which I remove the files, since this causes build break of the series. The code structure as is, provides working, bisectable thermal solution - thermal and cpu_cooling functionality is preserved across all commits in the series. diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 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 b.zolnier...@samsung.com + * Lukasz Majewski l.majew...@samsung.com + * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim dg77@samsung.com * Amit Daniel Kachhap amit.kach...@linaro.org @@ -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_TRIMINFO0x0 @@ -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
Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote: 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. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- 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 --- drivers/thermal/samsung/Makefile | 2 - drivers/thermal/samsung/exynos_tmu.c | 345 +++ drivers/thermal/samsung/exynos_tmu.h | 53 +- 3 files changed, 226 insertions(+), 174 deletions(-) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,5 +3,3 @@ # obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o exynos_thermal-y := exynos_tmu.o -exynos_thermal-y += exynos_tmu_data.o Can this makefile change be part of the patch that removes exynos_tmu_data.c? -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o Can this makefile change be part of the patch that removes exynos_thermal_common.c? diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 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 b.zolnier...@samsung.com + * Lukasz Majewski l.majew...@samsung.com + * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim dg77@samsung.com * Amit Daniel Kachhap amit.kach...@linaro.org @@ -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_SHIFT24 #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) +
[PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
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. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- 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 --- drivers/thermal/samsung/Makefile | 2 - drivers/thermal/samsung/exynos_tmu.c | 345 +++ drivers/thermal/samsung/exynos_tmu.h | 53 +- 3 files changed, 226 insertions(+), 174 deletions(-) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -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..633a9e2 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 b.zolnier...@samsung.com + * Lukasz Majewski l.majew...@samsung.com + * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim dg77@samsung.com * Amit Daniel Kachhap amit.kach...@linaro.org @@ -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_TRIMINFO0x0 @@ -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