[PATCH V3] regulator: add device tree support for s5m8767
This device tree support is added for PMIC block of S5m8767 multi function driver. The usage detail is added in the device tree documentation section. This change is tested on exynos5250 based arndale platform by regulator voltage set/get API's. Reviewed-by: Thomas Abraham Signed-off-by: Amit Daniel Kachhap --- Changes since V2: * Remove un-necessary inclusion of platform file as pointed by Rahul Sharma Changes since V1: * Added description of pmic-buck-ds-gpios and op_mode in the device tree documentation as suggested by Thomas Abraham. * Incorporated coding guidelines review comments. This patch is based on Mark Brown's tree for-next branch. git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git .../bindings/regulator/s5m8767-regulator.txt | 152 drivers/mfd/sec-core.c | 75 - drivers/regulator/s5m8767.c| 186 +++- include/linux/mfd/samsung/core.h | 11 +- 4 files changed, 417 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt diff --git a/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt new file mode 100644 index 000..a35ff99 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt @@ -0,0 +1,152 @@ +* Samsung S5M8767 Voltage and Current Regulator + +The Samsung S5M8767 is a multi-function device which includes volatage and +current regulators, rtc, charger controller and other sub-blocks. It is +interfaced to the host controller using a i2c interface. Each sub-block is +addressed by the host system using different i2c slave address. This document +describes the bindings for 'pmic' sub-block of s5m8767. + +Required properties: +- compatible: Should be "samsung,s5m8767-pmic". +- reg: Specifies the i2c slave address of the pmic block. It should be 0x66. + +- s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck2 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck3-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck3 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck4-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck4 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used + for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines. + +[1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional +property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage' +property should specify atleast one voltage level (which would be a +safe operating voltage). + +If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional +property is specified, then all the eight voltage values for the +'s5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. + +Optional properties: +- interrupt-parent: Specifies the phandle of the interrupt controller to which + the interrupts from s5m8767 are delivered to. +- interrupts: Interrupt specifiers for two interrupt sources. + - First interrupt specifier is for 'irq1' interrupt. + - Second interrupt specifier is for 'alert' interrupt. +- s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. +- s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs. +- s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs. + +Additional properties required if either of the optional properties are used: + +- s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected from + the possible 8 options selectable by the dvs gpios. The value of this + property should be between 0 and 7. If not specified or if out of range, the + default value of this property is set to 0. + +- s5m8767,pmic-buck-dvs-gpios: GPIO specifiers for three host gpio's used + for dvs. The format of the gpio specifier depends in the gpio controller. + +Regulators: The regulators of s5m8767 that have to be instantiated should be +included in a sub-node named 'regulators'. Regulator nodes included in this +sub-node should be of the format as listed below. + + regulator_name { + ldo1_reg: LDO1 { + regulator-name = "VDD_ALIVE_1.0V"; + regulator-min-microvolt = <110>; + regulator-max-microvolt = <110>; + regulator-always-on; + regulator-boot-on; + op_mo
[PATCH V3 1/2] thermal: sysfs: Add a new sysfs node emul_temp for thermal emulation
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone may report this temperature and not the actual temperature. The emulation implementation may be based on sensor capability through platform specific handler or pure software emulation if no platform handler defined. This is useful in debugging different temperature threshold and its associated cooling action. Critical threshold's cannot be emulated. Writing 0 on this node should disable emulation. Signed-off-by: Amit Daniel Kachhap Acked-by: Kukjin Kim --- Changes in V3: * Removed the un-necessary get_temp pointer check. * Added the read temp code in #ifdef EMULATION macros Changes in V2: * Added config option for enabling emulation support. * Added s/w emulation if no platform handler registered. * skip the critical trip point emulation This patchset is based on thermal maintainer next tree. git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next Documentation/thermal/sysfs-api.txt | 13 ++ drivers/thermal/Kconfig |8 drivers/thermal/thermal_sys.c | 79 ++- include/linux/thermal.h |2 + 4 files changed, 91 insertions(+), 11 deletions(-) diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt index 526d4b9..6859661 100644 --- a/Documentation/thermal/sysfs-api.txt +++ b/Documentation/thermal/sysfs-api.txt @@ -55,6 +55,8 @@ temperature) and throttle appropriate devices. .get_trip_type: get the type of certain trip point. .get_trip_temp: get the temperature above which the certain trip point will be fired. + .set_emul_temp: set the emulation temperature which helps in debugging + different threshold temperature points. 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz) @@ -153,6 +155,7 @@ Thermal zone device sys I/F, created once it's registered: |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point +|---emul_temp: Emulated temperature set node Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]: @@ -252,6 +255,16 @@ passive Valid values: 0 (disabled) or greater than 1000 RW, Optional +emul_temp + Interface to set the emulated temperature method in thermal zone + (sensor). After setting this temperature, the thermal zone may pass + this temperature to platform emulation function if registered or + cache it locally. This is useful in debugging different temperature + threshold and its associated cooling action. This is write only node + and writing 0 on this node should disable emulation. + Unit: millidegree Celsius + WO, Optional + * * Cooling device attributes * * diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index faf38c5..e4cf7fb 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -78,6 +78,14 @@ config CPU_THERMAL and not the ACPI interface. If you want this support, you should say Y here. +config THERMAL_EMULATION + bool "Thermal emulation mode support" + help + Enable this option to make a emul_temp sysfs node in thermal zone + directory to support temperature emulation. With emulation sysfs node, + user can manually input temperature and test the different trip + threshold behaviour for simulation purpose. + config SPEAR_THERMAL bool "SPEAr thermal sensor driver" depends on PLAT_SPEAR diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 0a1bf6b..0675687 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -378,24 +378,54 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) monitor_thermal_zone(tz); } +static int thermal_zone_get_temp(struct thermal_zone_device *tz, + unsigned long *temp) +{ + int ret = 0, count; + unsigned long crit_temp = -1UL; + enum thermal_trip_type type; + + mutex_lock(&tz->lock); + + ret = tz->ops->get_temp(tz, temp); +#ifdef CONFIG_THERMAL_EMULATION + if (!tz->emul_temperature) + goto skip_emul; + + for (count = 0; count < tz->trips; count++) { + ret = tz->ops->get_trip_type(tz, count, &type); + if (!ret && type == THERMAL_TRIP_CRITICAL) { + ret = tz->ops->get_trip_temp(tz, count, &crit_temp); + break; + } + } + + if (ret) +
Re: [PATCH] Thermal: fix iteration over CPU frequency list
On Thu, Jan 31, 2013 at 11:59 PM, Zhang Rui wrote: > On Thu, 2013-01-24 at 16:24 +0100, Gu1 wrote: >> In different places in the Thermal code, the CPU frequency list is iterated >> in an incorrect way, leading to endless loops when the frequency list >> contains >> a CPUFREQ_TABLE_INVALID entry, which is the case by default in the the Exynos >> 4x12 cpufreq driver, for example. >> >> The frequency list is iterated with a while loop, and when a >> CPUFREQ_TABLE_INVALID entry is encountered, the continue; statement is used >> to >> skip it, but the index is not incremented, causing an endless loop. >> >> A similar bug was fixed by hongbo.zhang in commit: >> Thermal: fix bug of counting cpu frequencies >> >> Signed-off-by: Gu1 >> --- >> drivers/thermal/cpu_cooling.c| 8 +++- >> drivers/thermal/exynos_thermal.c | 9 + >> 2 files changed, 8 insertions(+), 9 deletions(-) >> >> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c >> index 836828e..51acd26 100644 >> --- a/drivers/thermal/cpu_cooling.c >> +++ b/drivers/thermal/cpu_cooling.c >> @@ -123,7 +123,7 @@ static int is_cpufreq_valid(int cpu) >> */ >> static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) >> { >> - int ret = 0, i = 0; >> + int ret = 0, i; >> unsigned long level_index; >> bool descend = false; >> struct cpufreq_frequency_table *table = >> @@ -131,7 +131,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, >> unsigned long level) >> if (!table) >> return ret; >> >> - while (table[i].frequency != CPUFREQ_TABLE_END) { >> + for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { >> if (table[i].frequency == CPUFREQ_ENTRY_INVALID) >> continue; >> >> @@ -145,7 +145,6 @@ static unsigned int get_cpu_frequency(unsigned int cpu, >> unsigned long level) >> /*return if level matched and table in descending order*/ >> if (descend && i == level) >> return table[i].frequency; >> - i++; >> } >> i--; >> >> @@ -154,13 +153,12 @@ static unsigned int get_cpu_frequency(unsigned int >> cpu, unsigned long level) >> level_index = i - level; >> >> /*Scan the table in reverse order and match the level*/ >> - while (i >= 0) { >> + for (; i >= 0; i--) { >> if (table[i].frequency == CPUFREQ_ENTRY_INVALID) >> continue; >> /*return if level matched*/ >> if (i == level_index) >> return table[i].frequency; >> - i--; >> } >> return ret; >> } > > so the "level" parameter is the index in the frequency table, right? > >> diff --git a/drivers/thermal/exynos_thermal.c >> b/drivers/thermal/exynos_thermal.c >> index 224751e..fa9e1d7 100644 >> --- a/drivers/thermal/exynos_thermal.c >> +++ b/drivers/thermal/exynos_thermal.c >> @@ -233,7 +233,8 @@ static int exynos_get_crit_temp(struct >> thermal_zone_device *thermal, >> >> static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq) >> { >> - int i = 0, ret = -EINVAL; >> + int i, ret = -EINVAL; >> + unsigned int count = 0; >> struct cpufreq_frequency_table *table = NULL; >> #ifdef CONFIG_CPU_FREQ >> table = cpufreq_frequency_get_table(cpu); >> @@ -241,12 +242,12 @@ static int exynos_get_frequency_level(unsigned int >> cpu, unsigned int freq) >> if (!table) >> return ret; >> >> - while (table[i].frequency != CPUFREQ_TABLE_END) { >> + for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { >> if (table[i].frequency == CPUFREQ_ENTRY_INVALID) >> continue; >> if (table[i].frequency == freq) >> - return i; >> - i++; >> + return count; >> + count++; >> } >> return ret; >> } > > but we ignore the invalid entry here. > > take the following cpufreq table for example, with your patch, > entry frequency > 0 2.4G > 1 invalid > 2 2G > 3 invalid > 4 1.6G > 5 end > > in exynos_get_frequency_level(), freq 1.6G is translated to level 2, > because count is increased only twice, for entry 0 and entry 2, right? Hi Rui, Gui fixes looks fine for infinite loop issue. After Gui's fixes 1.6G in translated to level 4 which is fine. Thanks, Amit Daniel > > but then, in get_cpu_frequency(), level 2 is translated to 2G HZ, which > I do not think is what we want. > > I think we are doing something wrong here, and here is a cleanup patch I made > to fix this issue, please review. > > From a868d68fdcd94a29ac9d3998283119a453decb4b Mon Sep 17 00:00:00 2001 > From: Zhang Rui > Date: Fri, 1 Feb 2013 15:41:47 +0800 > Subject: [PATCH] Thermal cpu_cooling: fix inconsistent use of CPU frequency > table > > there are three kinds of entries in CPU frequency table. > 1
Re: [PATCH] Thermal: fix iteration over CPU frequency list
On Tue, Feb 5, 2013 at 1:59 AM, Zhang Rui wrote: > On Mon, 2013-02-04 at 11:49 -0800, amit daniel kachhap wrote: >> On Thu, Jan 31, 2013 at 11:59 PM, Zhang Rui wrote: >> > On Thu, 2013-01-24 at 16:24 +0100, Gu1 wrote: >> >> In different places in the Thermal code, the CPU frequency list is >> >> iterated >> >> in an incorrect way, leading to endless loops when the frequency list >> >> contains >> >> a CPUFREQ_TABLE_INVALID entry, which is the case by default in the the >> >> Exynos >> >> 4x12 cpufreq driver, for example. >> >> >> >> The frequency list is iterated with a while loop, and when a >> >> CPUFREQ_TABLE_INVALID entry is encountered, the continue; statement is >> >> used to >> >> skip it, but the index is not incremented, causing an endless loop. >> >> >> >> A similar bug was fixed by hongbo.zhang in commit: >> >> Thermal: fix bug of counting cpu frequencies >> >> >> >> Signed-off-by: Gu1 >> >> --- >> >> drivers/thermal/cpu_cooling.c| 8 +++- >> >> drivers/thermal/exynos_thermal.c | 9 + >> >> 2 files changed, 8 insertions(+), 9 deletions(-) >> >> >> >> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c >> >> index 836828e..51acd26 100644 >> >> --- a/drivers/thermal/cpu_cooling.c >> >> +++ b/drivers/thermal/cpu_cooling.c >> >> @@ -123,7 +123,7 @@ static int is_cpufreq_valid(int cpu) >> >> */ >> >> static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long >> >> level) >> >> { >> >> - int ret = 0, i = 0; >> >> + int ret = 0, i; >> >> unsigned long level_index; >> >> bool descend = false; >> >> struct cpufreq_frequency_table *table = >> >> @@ -131,7 +131,7 @@ static unsigned int get_cpu_frequency(unsigned int >> >> cpu, unsigned long level) >> >> if (!table) >> >> return ret; >> >> >> >> - while (table[i].frequency != CPUFREQ_TABLE_END) { >> >> + for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { >> >> if (table[i].frequency == CPUFREQ_ENTRY_INVALID) >> >> continue; >> >> >> >> @@ -145,7 +145,6 @@ static unsigned int get_cpu_frequency(unsigned int >> >> cpu, unsigned long level) >> >> /*return if level matched and table in descending order*/ >> >> if (descend && i == level) >> >> return table[i].frequency; >> >> - i++; >> >> } >> >> i--; >> >> >> >> @@ -154,13 +153,12 @@ static unsigned int get_cpu_frequency(unsigned int >> >> cpu, unsigned long level) >> >> level_index = i - level; >> >> >> >> /*Scan the table in reverse order and match the level*/ >> >> - while (i >= 0) { >> >> + for (; i >= 0; i--) { >> >> if (table[i].frequency == CPUFREQ_ENTRY_INVALID) >> >> continue; >> >> /*return if level matched*/ >> >> if (i == level_index) >> >> return table[i].frequency; >> >> - i--; >> >> } >> >> return ret; >> >> } >> > >> > so the "level" parameter is the index in the frequency table, right? >> > >> >> diff --git a/drivers/thermal/exynos_thermal.c >> >> b/drivers/thermal/exynos_thermal.c >> >> index 224751e..fa9e1d7 100644 >> >> --- a/drivers/thermal/exynos_thermal.c >> >> +++ b/drivers/thermal/exynos_thermal.c >> >> @@ -233,7 +233,8 @@ static int exynos_get_crit_temp(struct >> >> thermal_zone_device *thermal, >> >> >> >> static int exynos_get_frequency_level(unsigned int cpu, unsigned int >> >> freq) >> >> { >> >> - int i = 0, ret = -EINVAL; >> >> + int i, ret = -EINVAL; >> >> + unsigned int count = 0; >> >> struct cpufreq_frequency_table *table = NULL; >> >> #ifdef CONFIG_CPU_FREQ >> >> table = cpufreq_frequency_get_table(cpu); >> >> @@ -241,12 +242,12 @@ static int exynos_get_freque
[PATCH V3 1/2] Thermal: exynos: Add support for temperature falling interrupt.
From: Jonghwa Lee This patch introduces using temperature falling interrupt in exynos thermal driver. Former patch, it only use polling way to check whether if system themperature is fallen. However, exynos SOC also provides temperature falling interrupt way to do same things by hw. This feature is not supported in exynos4210. Acked-by: Kukjin Kim Signed-off-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- Hi, Submitting these patches again as they got lost somewhere and was not merged. Changes since V2: * Rebased against Rui Zhang next tree. * Added Kukjin Kim acked by. Changes since V1: Used the new thermal trend type macro All these patches are based on thermal maintainer next branch. git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git thermal drivers/thermal/exynos_thermal.c | 81 +++--- include/linux/platform_data/exynos_thermal.h |3 + 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 3a1b01e..65f69cf 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -94,6 +94,7 @@ #define SENSOR_NAME_LEN16 #define MAX_TRIP_COUNT 8 #define MAX_COOLING_DEVICE 4 +#define MAX_THRESHOLD_LEVS 4 #define ACTIVE_INTERVAL 500 #define IDLE_INTERVAL 1 @@ -133,6 +134,7 @@ struct exynos_tmu_data { struct thermal_trip_point_conf { int trip_val[MAX_TRIP_COUNT]; int trip_count; + u8 trigger_falling; }; struct thermal_cooling_conf { @@ -183,7 +185,8 @@ static int exynos_set_mode(struct thermal_zone_device *thermal, mutex_lock(&th_zone->therm_dev->lock); - if (mode == THERMAL_DEVICE_ENABLED) + if (mode == THERMAL_DEVICE_ENABLED && + !th_zone->sensor_conf->trip_data.trigger_falling) th_zone->therm_dev->polling_delay = IDLE_INTERVAL; else th_zone->therm_dev->polling_delay = 0; @@ -447,7 +450,8 @@ static void exynos_report_trigger(void) break; } - if (th_zone->mode == THERMAL_DEVICE_ENABLED) { + if (th_zone->mode == THERMAL_DEVICE_ENABLED && + !th_zone->sensor_conf->trip_data.trigger_falling) { if (i > 0) th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL; else @@ -486,7 +490,8 @@ static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, EXYNOS_ZONE_COUNT, 0, NULL, &exynos_dev_ops, NULL, 0, - IDLE_INTERVAL); + sensor_conf->trip_data.trigger_falling ? + 0 : IDLE_INTERVAL); if (IS_ERR(th_zone->therm_dev)) { pr_err("Failed to register thermal zone device\n"); @@ -593,8 +598,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_platform_data *pdata = data->pdata; - unsigned int status, trim_info, rising_threshold; - int ret = 0, threshold_code; + unsigned int status, trim_info; + unsigned int rising_threshold = 0, falling_threshold = 0; + int ret = 0, threshold_code, i, trigger_levs = 0; mutex_lock(&data->lock); clk_enable(data->clk); @@ -619,6 +625,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev) (data->temp_error2 != 0)) data->temp_error1 = pdata->efuse_value; + /* Count trigger levels to be enabled */ + for (i = 0; i < MAX_THRESHOLD_LEVS; i++) + if (pdata->trigger_levels[i]) + trigger_levs++; + if (data->soc == SOC_ARCH_EXYNOS4210) { /* Write temperature code for threshold */ threshold_code = temp_to_code(data, pdata->threshold); @@ -628,44 +639,38 @@ static int exynos_tmu_initialize(struct platform_device *pdev) } writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); - - writeb(pdata->trigger_levels[0], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0); - writeb(pdata->trigger_levels[1], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL1); - writeb(pdata->trigger_levels[2], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL2); - writeb(pdata->trigger_levels[3], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL3); + for (i = 0; i < trigger_levs; i++) + writeb(pdata->trigger_levels[i], +
[PATCH V3 2/2] thermal: exynos: Use the new thermal trend type for quick cooling action.
This patch uses the quick thermal cooling trend type macros. This is needed as exynos5 and other thermal sensors now supports only interrupt method for thresold temperature check. Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- Hi, Submitting these patches again as they got lost somewhere and was not merged. Changes since V2: * Rebased against Rui Zhang next tree. * Added Kukjin Kim acked by. All these patches are based on thermal maintainer next branch. git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git thermal drivers/thermal/exynos_thermal.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 65f69cf..030bba3 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -296,7 +296,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, case MONITOR_ZONE: case WARN_ZONE: if (thermal_zone_bind_cooling_device(thermal, i, cdev, - level, level)) { + level, 0)) { pr_err("error binding cdev inst %d\n", i); ret = -EINVAL; } @@ -399,9 +399,9 @@ static int exynos_get_trend(struct thermal_zone_device *thermal, return ret; if (thermal->temperature >= trip_temp) - *trend = THERMAL_TREND_RAISING; + *trend = THERMAL_TREND_RAISE_FULL; else - *trend = THERMAL_TREND_DROPPING; + *trend = THERMAL_TREND_DROP_FULL; return 0; } -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V3] thermal: exynos: Adapt to temperature emulation core thermal framework
This removes the driver specific sysfs support of the temperature emulation and uses the newly added core thermal framework for thermal emulation. An exynos platform specific handler is added to support this. In this patch, the exynos senor(tmu) related code and exynos framework related (thermal zone, cooling devices) code are intentionally kept separate. So an emulated function pointer is passed from sensor to framework. This is beneficial in adding more sensor support using the same framework code which is an ongoing work. The goal is to finally split them totally. Even the existing read_temperature also follows the same execution method. Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- Changes in V3: * Added an invalid return from function when CONFIG_THERMAL_EMULATION is not defined. * Added more details in the patch description. Changes in V2: * Added config option CONFIG_THERMAL_EMULATION instead of CONFIG_EXYNOS_THERMAL_EMUL This patchset is based on thermal maintainer next tree. git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next Documentation/thermal/exynos_thermal_emulation |8 +- drivers/thermal/Kconfig|9 -- drivers/thermal/exynos_thermal.c | 158 ++-- 3 files changed, 67 insertions(+), 108 deletions(-) diff --git a/Documentation/thermal/exynos_thermal_emulation b/Documentation/thermal/exynos_thermal_emulation index b73bbfb..36a3e79 100644 --- a/Documentation/thermal/exynos_thermal_emulation +++ b/Documentation/thermal/exynos_thermal_emulation @@ -13,11 +13,11 @@ Thermal emulation mode supports software debug for TMU's operation. User can set manually with software code and TMU will read current temperature from user value not from sensor's value. -Enabling CONFIG_EXYNOS_THERMAL_EMUL option will make this support in available. -When it's enabled, sysfs node will be created under -/sys/bus/platform/devices/'exynos device name'/ with name of 'emulation'. +Enabling CONFIG_THERMAL_EMULATION option will make this support available. +When it's enabled, sysfs node will be created as +/sys/devices/virtual/thermal/thermal_zone'zone id'/emul_temp. -The sysfs node, 'emulation', will contain value 0 for the initial state. When you input any +The sysfs node, 'emul_node', will contain value 0 for the initial state. When you input any temperature you want to update to sysfs node, it automatically enable emulation mode and current temperature will be changed into it. (Exynos also supports user changable delay time which would be used to delay of diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index a764f16..da4c19e 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -117,15 +117,6 @@ config EXYNOS_THERMAL If you say yes here you get support for TMU (Thermal Management Unit) on SAMSUNG EXYNOS series of SoC. -config EXYNOS_THERMAL_EMUL - bool "EXYNOS TMU emulation mode support" - depends on EXYNOS_THERMAL - help - Exynos 4412 and 4414 and 5 series has emulation mode on TMU. - Enable this option will be make sysfs node in exynos thermal platform - device directory to support emulation mode. With emulation mode sysfs - node, you can manually input temperature to TMU for simulation purpose. - config DOVE_THERMAL tristate "Temperature sensor on Marvell Dove SoCs" depends on ARCH_DOVE diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 64aa8b4..7ff62b0 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -100,13 +100,13 @@ #define IDLE_INTERVAL 1 #define MCELSIUS 1000 -#ifdef CONFIG_EXYNOS_THERMAL_EMUL +#ifdef CONFIG_THERMAL_EMULATION #define EXYNOS_EMUL_TIME 0x57F0 #define EXYNOS_EMUL_TIME_SHIFT 16 #define EXYNOS_EMUL_DATA_SHIFT 8 #define EXYNOS_EMUL_DATA_MASK 0xFF #define EXYNOS_EMUL_ENABLE 0x1 -#endif /* CONFIG_EXYNOS_THERMAL_EMUL */ +#endif /* CONFIG_THERMAL_EMULATION */ /* CPU Zone information */ #define PANIC_ZONE 4 @@ -145,6 +145,7 @@ struct thermal_cooling_conf { struct thermal_sensor_conf { char name[SENSOR_NAME_LEN]; int (*read_temperature)(void *data); + int (*write_emul_temp)(void *drv_data, unsigned long temp); struct thermal_trip_point_conf trip_data; struct thermal_cooling_conf cooling_data; void *private_data; @@ -369,6 +370,23 @@ static int exynos_get_temp(struct thermal_zone_device *thermal, 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; + + if (!th_zone->sensor_conf) { +
[PATCH V2] regulator: add device tree support for s5m8767
This device tree support is added for PMIC block of S5m8767 multi function driver. The usage detail is added in the device tree documentation section. This change is tested on exynos5250 based arndale platform by regulator voltage set/get API's. Reviewed-by: Thomas Abraham Signed-off-by: Amit Daniel Kachhap --- Change since V1: * Added description of pmic-buck-ds-gpios and op_mode in the device tree documentation as suggested by Thomas Abraham. * Incorporated coding guidelines review comments. This patch is based on Mark Brown's tree next branch. git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git .../bindings/regulator/s5m8767-regulator.txt | 152 drivers/mfd/sec-core.c | 75 - drivers/regulator/s5m8767.c| 188 +++- include/linux/mfd/samsung/core.h | 11 +- 4 files changed, 419 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt diff --git a/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt new file mode 100644 index 000..a35ff99 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt @@ -0,0 +1,152 @@ +* Samsung S5M8767 Voltage and Current Regulator + +The Samsung S5M8767 is a multi-function device which includes volatage and +current regulators, rtc, charger controller and other sub-blocks. It is +interfaced to the host controller using a i2c interface. Each sub-block is +addressed by the host system using different i2c slave address. This document +describes the bindings for 'pmic' sub-block of s5m8767. + +Required properties: +- compatible: Should be "samsung,s5m8767-pmic". +- reg: Specifies the i2c slave address of the pmic block. It should be 0x66. + +- s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck2 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck3-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck3 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck4-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck4 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used + for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines. + +[1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional +property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage' +property should specify atleast one voltage level (which would be a +safe operating voltage). + +If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional +property is specified, then all the eight voltage values for the +'s5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. + +Optional properties: +- interrupt-parent: Specifies the phandle of the interrupt controller to which + the interrupts from s5m8767 are delivered to. +- interrupts: Interrupt specifiers for two interrupt sources. + - First interrupt specifier is for 'irq1' interrupt. + - Second interrupt specifier is for 'alert' interrupt. +- s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. +- s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs. +- s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs. + +Additional properties required if either of the optional properties are used: + +- s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected from + the possible 8 options selectable by the dvs gpios. The value of this + property should be between 0 and 7. If not specified or if out of range, the + default value of this property is set to 0. + +- s5m8767,pmic-buck-dvs-gpios: GPIO specifiers for three host gpio's used + for dvs. The format of the gpio specifier depends in the gpio controller. + +Regulators: The regulators of s5m8767 that have to be instantiated should be +included in a sub-node named 'regulators'. Regulator nodes included in this +sub-node should be of the format as listed below. + + regulator_name { + ldo1_reg: LDO1 { + regulator-name = "VDD_ALIVE_1.0V"; + regulator-min-microvolt = <110>; + regulator-max-microvolt = <110>; + regulator-always-on; + regulator-boot-on; + op_mode = <1>; /* Normal Mode */ + }; + }; +The above regulator entries are defined
Re: [PATCH V2] regulator: add device tree support for s5m8767
On Thu, Jan 31, 2013 at 1:56 AM, Rahul Sharma wrote: > On Thu, Jan 31, 2013 at 3:10 AM, Amit Daniel Kachhap > wrote: >> This device tree support is added for PMIC block of S5m8767 multi >> function driver. The usage detail is added in the device tree >> documentation section. This change is tested on exynos5250 based >> arndale platform by regulator voltage set/get API's. >> >> Reviewed-by: Thomas Abraham >> Signed-off-by: Amit Daniel Kachhap >> --- >> Change since V1: >> * Added description of pmic-buck-ds-gpios and op_mode in the device tree >> documentation as suggested by Thomas Abraham. >> * Incorporated coding guidelines review comments. >> >> This patch is based on Mark Brown's tree next branch. >> git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git >> >> .../bindings/regulator/s5m8767-regulator.txt | 152 >> drivers/mfd/sec-core.c | 75 - >> drivers/regulator/s5m8767.c| 188 >> +++- >> include/linux/mfd/samsung/core.h | 11 +- >> 4 files changed, 419 insertions(+), 7 deletions(-) >> create mode 100644 >> Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt >> >> diff --git >> a/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt >> b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt >> new file mode 100644 >> index 000..a35ff99 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt >> @@ -0,0 +1,152 @@ >> +* Samsung S5M8767 Voltage and Current Regulator >> + >> +The Samsung S5M8767 is a multi-function device which includes volatage and >> +current regulators, rtc, charger controller and other sub-blocks. It is >> +interfaced to the host controller using a i2c interface. Each sub-block is >> +addressed by the host system using different i2c slave address. This >> document >> +describes the bindings for 'pmic' sub-block of s5m8767. >> + >> +Required properties: >> +- compatible: Should be "samsung,s5m8767-pmic". >> +- reg: Specifies the i2c slave address of the pmic block. It should be 0x66. >> + >> +- s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt >> (uV) >> + units for buck2 when changing voltage using gpio dvs. Refer to [1] below >> + for additional information. >> + >> +- s5m8767,pmic-buck3-dvs-voltage: A set of 8 voltage values in micro-volt >> (uV) >> + units for buck3 when changing voltage using gpio dvs. Refer to [1] below >> + for additional information. >> + >> +- s5m8767,pmic-buck4-dvs-voltage: A set of 8 voltage values in micro-volt >> (uV) >> + units for buck4 when changing voltage using gpio dvs. Refer to [1] below >> + for additional information. >> + >> +- s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used >> + for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines. >> + >> +[1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional >> +property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage' >> +property should specify atleast one voltage level (which would be a >> +safe operating voltage). >> + >> +If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional >> +property is specified, then all the eight voltage values for the >> +'s5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. >> + >> +Optional properties: >> +- interrupt-parent: Specifies the phandle of the interrupt controller to >> which >> + the interrupts from s5m8767 are delivered to. >> +- interrupts: Interrupt specifiers for two interrupt sources. >> + - First interrupt specifier is for 'irq1' interrupt. >> + - Second interrupt specifier is for 'alert' interrupt. >> +- s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. >> +- s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs. >> +- s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs. >> + >> +Additional properties required if either of the optional properties are >> used: >> + >> +- s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected >> from >> + the possible 8 options selectable by the dvs gpios. The value of this >> + property should be between 0
[PATCH V2 2/2] thermal: exynos: Use the framework for temperature emulation support
This removes the driver specific sysfs support of the temperature emulation and uses the newly added core thermal framework for thermal emulation. A platform specific handler is added to support this. Signed-off-by: Amit Daniel Kachhap Acked-by: Kukjin Kim --- Changes in V2: * Added config option CONFIG_THERMAL_EMULATION instead of CONFIG_EXYNOS_THERMAL_EMUL This patchset is based on thermal maintainer next tree. git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next Documentation/thermal/exynos_thermal_emulation |8 +- drivers/thermal/Kconfig|9 -- drivers/thermal/exynos_thermal.c | 158 ++-- 3 files changed, 67 insertions(+), 108 deletions(-) diff --git a/Documentation/thermal/exynos_thermal_emulation b/Documentation/thermal/exynos_thermal_emulation index b73bbfb..36a3e79 100644 --- a/Documentation/thermal/exynos_thermal_emulation +++ b/Documentation/thermal/exynos_thermal_emulation @@ -13,11 +13,11 @@ Thermal emulation mode supports software debug for TMU's operation. User can set manually with software code and TMU will read current temperature from user value not from sensor's value. -Enabling CONFIG_EXYNOS_THERMAL_EMUL option will make this support in available. -When it's enabled, sysfs node will be created under -/sys/bus/platform/devices/'exynos device name'/ with name of 'emulation'. +Enabling CONFIG_THERMAL_EMULATION option will make this support available. +When it's enabled, sysfs node will be created as +/sys/devices/virtual/thermal/thermal_zone'zone id'/emul_temp. -The sysfs node, 'emulation', will contain value 0 for the initial state. When you input any +The sysfs node, 'emul_node', will contain value 0 for the initial state. When you input any temperature you want to update to sysfs node, it automatically enable emulation mode and current temperature will be changed into it. (Exynos also supports user changable delay time which would be used to delay of diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index e4cf7fb..2a79510 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -109,15 +109,6 @@ config EXYNOS_THERMAL If you say yes here you get support for TMU (Thermal Management Unit) on SAMSUNG EXYNOS series of SoC. -config EXYNOS_THERMAL_EMUL - bool "EXYNOS TMU emulation mode support" - depends on EXYNOS_THERMAL - help - Exynos 4412 and 4414 and 5 series has emulation mode on TMU. - Enable this option will be make sysfs node in exynos thermal platform - device directory to support emulation mode. With emulation mode sysfs - node, you can manually input temperature to TMU for simulation purpose. - config DB8500_THERMAL bool "DB8500 thermal management" depends on ARCH_U8500 diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 327102a..afe9c2a 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -99,13 +99,13 @@ #define IDLE_INTERVAL 1 #define MCELSIUS 1000 -#ifdef CONFIG_EXYNOS_THERMAL_EMUL +#ifdef CONFIG_THERMAL_EMULATION #define EXYNOS_EMUL_TIME 0x57F0 #define EXYNOS_EMUL_TIME_SHIFT 16 #define EXYNOS_EMUL_DATA_SHIFT 8 #define EXYNOS_EMUL_DATA_MASK 0xFF #define EXYNOS_EMUL_ENABLE 0x1 -#endif /* CONFIG_EXYNOS_THERMAL_EMUL */ +#endif /* CONFIG_THERMAL_EMULATION */ /* CPU Zone information */ #define PANIC_ZONE 4 @@ -143,6 +143,7 @@ struct thermal_cooling_conf { struct thermal_sensor_conf { char name[SENSOR_NAME_LEN]; int (*read_temperature)(void *data); + int (*write_emul_temp)(void *data, unsigned long temp); struct thermal_trip_point_conf trip_data; struct thermal_cooling_conf cooling_data; void *private_data; @@ -366,6 +367,23 @@ static int exynos_get_temp(struct thermal_zone_device *thermal, 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; + + if (!th_zone->sensor_conf) { + pr_info("Temperature sensor not initialised\n"); + return -EINVAL; + } + data = th_zone->sensor_conf->private_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) @@ -382,6 +400,7 @@ static struct thermal_zone_device_ops const exynos_dev_ops = { .bind = exynos_bind, .unbin
[PATCH V2 1/2] thermal: sysfs: Add a new sysfs node emul_temp for thermal emulation
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone may report this temperature and not the actual temperature. The emulation implementation may be based on sensor capability through platform specific handler or pure software emulation if no platform handler defined. This is useful in debugging different temperature threshold and its associated cooling action. Critical threshold's cannot be emulated. Writing 0 on this node should disable emulation. Signed-off-by: Amit Daniel Kachhap Acked-by: Kukjin Kim --- Changes in V2: * Added config option for enabling emulation support. * Added s/w emulation if no platform handler registered. * skip the critical trip point emulation This patchset is based on thermal maintainer next tree. git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next Documentation/thermal/sysfs-api.txt | 13 ++ drivers/thermal/Kconfig |8 +++ drivers/thermal/thermal_sys.c | 82 ++- include/linux/thermal.h |2 + 4 files changed, 94 insertions(+), 11 deletions(-) diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt index 526d4b9..6859661 100644 --- a/Documentation/thermal/sysfs-api.txt +++ b/Documentation/thermal/sysfs-api.txt @@ -55,6 +55,8 @@ temperature) and throttle appropriate devices. .get_trip_type: get the type of certain trip point. .get_trip_temp: get the temperature above which the certain trip point will be fired. + .set_emul_temp: set the emulation temperature which helps in debugging + different threshold temperature points. 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz) @@ -153,6 +155,7 @@ Thermal zone device sys I/F, created once it's registered: |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point +|---emul_temp: Emulated temperature set node Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]: @@ -252,6 +255,16 @@ passive Valid values: 0 (disabled) or greater than 1000 RW, Optional +emul_temp + Interface to set the emulated temperature method in thermal zone + (sensor). After setting this temperature, the thermal zone may pass + this temperature to platform emulation function if registered or + cache it locally. This is useful in debugging different temperature + threshold and its associated cooling action. This is write only node + and writing 0 on this node should disable emulation. + Unit: millidegree Celsius + WO, Optional + * * Cooling device attributes * * diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index faf38c5..e4cf7fb 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -78,6 +78,14 @@ config CPU_THERMAL and not the ACPI interface. If you want this support, you should say Y here. +config THERMAL_EMULATION + bool "Thermal emulation mode support" + help + Enable this option to make a emul_temp sysfs node in thermal zone + directory to support temperature emulation. With emulation sysfs node, + user can manually input temperature and test the different trip + threshold behaviour for simulation purpose. + config SPEAR_THERMAL bool "SPEAr thermal sensor driver" depends on PLAT_SPEAR diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 0a1bf6b..59ba709 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -378,24 +378,57 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) monitor_thermal_zone(tz); } +static int thermal_zone_get_temp(struct thermal_zone_device *tz, + unsigned long *temp) +{ + int ret = 0, count; + unsigned long crit_temp = -1UL; + enum thermal_trip_type type; + + mutex_lock(&tz->lock); + + if (tz->ops->get_temp) + ret = tz->ops->get_temp(tz, temp); + else + ret = -EPERM; + + if (!tz->emul_temperature) + goto skip_emul; + + for (count = 0; count < tz->trips; count++) { + ret = tz->ops->get_trip_type(tz, count, &type); + if (!ret && type == THERMAL_TRIP_CRITICAL) { + ret = tz->ops->get_trip_temp(tz, count, &crit_temp); + break; + } + } + + if (ret) + goto skip_emul; + + if (*temp < crit_temp) + *
Re: [PATCH 1/3] thermal: samsung: correct the fall interrupt en, status bit fields
On Wed, Aug 28, 2013 at 11:15 AM, Naveen Krishna Chatradhi wrote: > The FALL interrupt related en, status bits are available at an offset of > 16 on INTEN, INTSTAT registers and at an offset of > 12 on INTCLEAR register. > > This patch corrects the same for exyns5250 and exynos5440 > > Signed-off-by: Naveen Krishna Chatradhi The changes looks fine. Acked-by: Amit Daniel Kachhap Thanks, Amit > --- > drivers/thermal/samsung/exynos_tmu.c |2 +- > drivers/thermal/samsung/exynos_tmu.h |2 ++ > drivers/thermal/samsung/exynos_tmu_data.c |2 ++ > drivers/thermal/samsung/exynos_tmu_data.h |3 ++- > 4 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index ec01dfe..d201ed8 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -265,7 +265,7 @@ skip_calib_data: > data->base + reg->threshold_th1); > > writel((reg->inten_rise_mask << reg->inten_rise_shift) | > - (reg->inten_fall_mask << reg->inten_fall_shift), > + (reg->inten_fall_mask << reg->intclr_fall_shift), > data->base + reg->tmu_intclear); > > /* if last threshold limit is also present */ > diff --git a/drivers/thermal/samsung/exynos_tmu.h > b/drivers/thermal/samsung/exynos_tmu.h > index b364c9e..7c6c34a 100644 > --- a/drivers/thermal/samsung/exynos_tmu.h > +++ b/drivers/thermal/samsung/exynos_tmu.h > @@ -134,6 +134,7 @@ enum soc_type { > * @inten_fall3_shift: shift bits of falling 3 interrupt bits. > * @tmu_intstat: Register containing the interrupt status values. > * @tmu_intclear: Register for clearing the raised interrupt status. > + * @intclr_fall_shift: shift bits for interrupt clear fall 0 > * @emul_con: TMU emulation controller register. > * @emul_temp_shift: shift bits of emulation temperature. > * @emul_time_shift: shift bits of emulation time. > @@ -204,6 +205,7 @@ struct exynos_tmu_registers { > u32 tmu_intstat; > > u32 tmu_intclear; > + u32 intclr_fall_shift; > > u32 emul_con; > u32 emul_temp_shift; > diff --git a/drivers/thermal/samsung/exynos_tmu_data.c > b/drivers/thermal/samsung/exynos_tmu_data.c > index 9002499..23fea23 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.c > +++ b/drivers/thermal/samsung/exynos_tmu_data.c > @@ -122,6 +122,7 @@ static const struct exynos_tmu_registers > exynos5250_tmu_registers = { > .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, > .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, > .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, > + .intclr_fall_shift = EXYNOS_TMU_CLEAR_FALL_INT_SHIFT, > .emul_con = EXYNOS_EMUL_CON, > .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, > .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, > @@ -210,6 +211,7 @@ static const struct exynos_tmu_registers > exynos5440_tmu_registers = { > .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT, > .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, > .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, > + .intclr_fall_shift = EXYNOS_TMU_CLEAR_FALL_INT_SHIFT, > .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS, > .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, > .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, > diff --git a/drivers/thermal/samsung/exynos_tmu_data.h > b/drivers/thermal/samsung/exynos_tmu_data.h > index dc7feb5..8788a87 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.h > +++ b/drivers/thermal/samsung/exynos_tmu_data.h > @@ -69,9 +69,10 @@ > #define EXYNOS_TMU_RISE_INT_MASK 0x111 > #define EXYNOS_TMU_RISE_INT_SHIFT 0 > #define EXYNOS_TMU_FALL_INT_MASK 0x111 > -#define EXYNOS_TMU_FALL_INT_SHIFT 12 > +#define EXYNOS_TMU_FALL_INT_SHIFT 16 > #define EXYNOS_TMU_CLEAR_RISE_INT 0x111 > #define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) > +#define EXYNOS_TMU_CLEAR_FALL_INT_SHIFT12 > #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 > #define EXYNOS_TMU_TRIP_MODE_MASK 0x7 > #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12 > -- > 1.7.9.5 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-pm" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html On Wed, Aug 28, 2013 at 11:15 AM, Naveen Krishna Chatradhi wrote: > The FALL interrupt related en, status bits are available at an offset of > 16 on INTEN, INTSTAT registers and at an o
Re: [PATCH 2/3] thermal: samsung: Add TMU support for Exynos5420 SoCs
On Wed, Aug 28, 2013 at 11:15 AM, Naveen Krishna Chatradhi wrote: > This patch adds the neccessary register changes and arch information > to support Exynos5420 SoCs > Exynos5420 has 5 TMU channels one for each CPU 0, 1, 2 and 3 and GPU > > Signed-off-by: Naveen Krishna Chatradhi Acked-by: Amit Daniel Kachhap Thanks, Amit > --- > drivers/thermal/samsung/exynos_tmu.c |4 ++ > drivers/thermal/samsung/exynos_tmu.h |1 + > drivers/thermal/samsung/exynos_tmu_data.c | 90 > + > drivers/thermal/samsung/exynos_tmu_data.h |7 +++ > 4 files changed, 102 insertions(+) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index d201ed8..bfdfbd6 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -499,6 +499,10 @@ static const struct of_device_id exynos_tmu_match[] = { > .compatible = "samsung,exynos5440-tmu", > .data = (void *)EXYNOS5440_TMU_DRV_DATA, > }, > + { > + .compatible = "samsung,exynos5420-tmu", > + .data = (void *)EXYNOS5420_TMU_DRV_DATA, > + }, > {}, > }; > MODULE_DEVICE_TABLE(of, exynos_tmu_match); > diff --git a/drivers/thermal/samsung/exynos_tmu.h > b/drivers/thermal/samsung/exynos_tmu.h > index 7c6c34a..d88a536 100644 > --- a/drivers/thermal/samsung/exynos_tmu.h > +++ b/drivers/thermal/samsung/exynos_tmu.h > @@ -43,6 +43,7 @@ enum soc_type { > SOC_ARCH_EXYNOS4210 = 1, > SOC_ARCH_EXYNOS, > SOC_ARCH_EXYNOS5440, > + SOC_ARCH_EXYNOS5420, > }; > > /** > diff --git a/drivers/thermal/samsung/exynos_tmu_data.c > b/drivers/thermal/samsung/exynos_tmu_data.c > index 23fea23..5adbb36 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.c > +++ b/drivers/thermal/samsung/exynos_tmu_data.c > @@ -177,6 +177,96 @@ struct exynos_tmu_init_data const > exynos5250_default_tmu_data = { > }; > #endif > > +#if defined(CONFIG_SOC_EXYNOS5420) > +static const struct exynos_tmu_registers exynos5420_tmu_registers = { > + .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, > + .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, > + .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, > + .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, > + .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT, > + .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK, > + .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, > + .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, > + .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, > + .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT, > + .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK, > + .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT, > + .tmu_status = EXYNOS_TMU_REG_STATUS, > + .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, > + .threshold_th0 = EXYNOS_THD_TEMP_RISE, > + .threshold_th1 = EXYNOS_THD_TEMP_FALL, > + .tmu_inten = EXYNOS_TMU_REG_INTEN, > + .inten_rise_mask = EXYNOS_TMU_RISE_INT_MASK, > + .inten_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT, > + .inten_fall_mask = EXYNOS_TMU_FALL_INT_MASK, > + .inten_fall_shift = EXYNOS_TMU_FALL_INT_SHIFT, > + .inten_rise0_shift = EXYNOS_TMU_INTEN_RISE0_SHIFT, > + .inten_rise1_shift = EXYNOS_TMU_INTEN_RISE1_SHIFT, > + .inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT, > + /* INTEN_RISE3 Not availble in exynos5420 */ > + .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT, > + .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, > + .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, > + .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, > + .intclr_fall_shift = EXYNOS_TMU_FALL_INT_SHIFT, > + .emul_con = EXYNOS_EMUL_CON, > + .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, > + .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, > + .emul_time_mask = EXYNOS_EMUL_TIME_MASK, > +}; > + > +#define EXYNOS5420_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, \ > + .gain = 8, \ > + .refer
Re: [PATCH 3/3] thermal: exynos: Handle the misplaced TRIMINFO register
Hi Naveen On Wed, Aug 28, 2013 at 11:15 AM, Naveen Krishna Chatradhi wrote: > This patch adds code to handle the misplaced TRIMINFO register > incase of Exynos5420. > > On Exynos5420 we have a TRIMINFO register being misplaced for > TMU channels 2, 3 and 4 > > TRIMINFO at 0x1006c000 contains data for TMU channel 3 > TRIMINFO at 0x100a contains data for TMU channel 4 > TRIMINFO at 0x10068000 contains data for TMU channel 2 > > The misplaced register address is passed through devicetree and > map it seperately during probe. > Also, adds the documentation under devicetree/bindings/thermal/ > > Signed-off-by: Naveen Krishna Chatradhi > --- > .../devicetree/bindings/thermal/exynos-thermal.txt | 21 + > drivers/thermal/samsung/exynos_tmu.c | 32 > +--- > 2 files changed, 49 insertions(+), 4 deletions(-) > > diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > index 284f530..e818473 100644 > --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > @@ -7,12 +7,21 @@ >"samsung,exynos4210-tmu" >"samsung,exynos5250-tmu" >"samsung,exynos5440-tmu" > + "samsung,exynos5420-tmu" > - interrupt-parent : The phandle for the interrupt controller > - reg : Address range of the thermal registers. For soc's which has multiple > instances of TMU and some registers are shared across all TMU's like > interrupt related then 2 set of register has to supplied. First set > belongs to each instance of TMU and second set belongs to common TMU > registers. > + > + ** NOTE FOR EXYNOS5420 ** > +TRIMINFO register is being misplaced for TMU channels 2, 3 and 4 > + > +TERMINFO for TMU channel 2 is present in address space of TMU channel 3 > +TERMINFO for TMU channel 3 is present in address space of TMU channel 4 > +TERMINFO for TMU channel 4 is present in address space of TMU channel 2 > + > - interrupts : Should contain interrupt for thermal system > - clocks : The main clock for TMU device > - clock-names : Thermal system clock name > @@ -43,6 +52,18 @@ Example 2): > clock-names = "tmu_apbif"; > }; > > +Example 3): In case of Exynos5420 TMU channel 3 > + > + /* tmu for CPU3 */ > + tmu@1006c000 { > + compatible = "samsung,exynos5420-tmu"; > + /* 2nd reg is for the misplaced TRIMINFO register */ > + reg = <0x1006c000 0x100>, <0x100a 0x4>; > + interrupts = <0 185 0>; > + clocks = <&clock 318>; > + clock-names = "tmu_apbif"; > + }; > + > Note: For multi-instance tmu each instance should have an alias correctly > numbered in "aliases" node. > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index bfdfbd6..f95844e 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -42,6 +42,7 @@ > * @pdata: pointer to the tmu platform/configuration data > * @base: base address of the single instance of the TMU controller. > * @base_common: base address of the common registers of the TMU controller. > + * @triminfo_base: misplaced register base for TRIMINFO on Exynos5420 only Instead of creating this new field you can re-use base_common for accessing the second set of register for misplaced triminfo address. Also you can rename this variable as base_second. > * @irq: irq number of the TMU controller. > * @soc: id of the SOC type. > * @irq_work: pointer to the irq work structure. > @@ -57,6 +58,7 @@ struct exynos_tmu_data { > struct exynos_tmu_platform_data *pdata; > void __iomem *base; > void __iomem *base_common; > + void __iomem *triminfo_base;/* Needed only Exynos5420 */ > int irq; > enum soc_type soc; > struct work_struct irq_work; > @@ -186,7 +188,12 @@ static int exynos_tmu_initialize(struct platform_device > *pdev) > EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); > } > } else { > - trim_info = readl(data->base + reg->triminfo_data); > + /* On exynos5420 TRIMINFO is misplaced for some channels */ > + if (data->triminfo_base) > + trim_info = readl(data->triminfo_base + > + reg->triminfo_data); > + else > + trim_info = readl(data->base + reg->triminfo_data); > } > data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK; > data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) & > @@ -586,8 +593,17 @@ static int exynos_map_dt_data(struct platform_device > *pdev) > * Check if the TMU shares some
Re: [PATCH 3/3] thermal: exynos: Handle the misplaced TRIMINFO register
Hi Naveen, On Wed, Aug 28, 2013 at 11:49 AM, Naveen Krishna Ch wrote: > On 28 August 2013 11:33, amit daniel kachhap wrote: >> Hi Naveen >> >> On Wed, Aug 28, 2013 at 11:15 AM, Naveen Krishna Chatradhi >> wrote: >>> This patch adds code to handle the misplaced TRIMINFO register >>> incase of Exynos5420. >>> >>> On Exynos5420 we have a TRIMINFO register being misplaced for >>> TMU channels 2, 3 and 4 >>> >>> TRIMINFO at 0x1006c000 contains data for TMU channel 3 >>> TRIMINFO at 0x100a contains data for TMU channel 4 >>> TRIMINFO at 0x10068000 contains data for TMU channel 2 >>> >>> The misplaced register address is passed through devicetree and >>> map it seperately during probe. >>> Also, adds the documentation under devicetree/bindings/thermal/ >>> >>> Signed-off-by: Naveen Krishna Chatradhi >>> --- >>> .../devicetree/bindings/thermal/exynos-thermal.txt | 21 + >>> drivers/thermal/samsung/exynos_tmu.c | 32 >>> +--- >>> 2 files changed, 49 insertions(+), 4 deletions(-) >>> >>> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>> index 284f530..e818473 100644 >>> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>> @@ -7,12 +7,21 @@ >>>"samsung,exynos4210-tmu" >>>"samsung,exynos5250-tmu" >>>"samsung,exynos5440-tmu" >>> + "samsung,exynos5420-tmu" >>> - interrupt-parent : The phandle for the interrupt controller >>> - reg : Address range of the thermal registers. For soc's which has >>> multiple >>> instances of TMU and some registers are shared across all TMU's like >>> interrupt related then 2 set of register has to supplied. First set >>> belongs to each instance of TMU and second set belongs to common TMU >>> registers. >>> + >>> + ** NOTE FOR EXYNOS5420 ** >>> +TRIMINFO register is being misplaced for TMU channels 2, 3 and 4 >>> + >>> +TERMINFO for TMU channel 2 is present in address space of TMU channel 3 >>> +TERMINFO for TMU channel 3 is present in address space of TMU channel 4 >>> +TERMINFO for TMU channel 4 is present in address space of TMU channel 2 >>> + >>> - interrupts : Should contain interrupt for thermal system >>> - clocks : The main clock for TMU device >>> - clock-names : Thermal system clock name >>> @@ -43,6 +52,18 @@ Example 2): >>> clock-names = "tmu_apbif"; >>> }; >>> >>> +Example 3): In case of Exynos5420 TMU channel 3 >>> + >>> + /* tmu for CPU3 */ >>> + tmu@1006c000 { >>> + compatible = "samsung,exynos5420-tmu"; >>> + /* 2nd reg is for the misplaced TRIMINFO register */ >>> + reg = <0x1006c000 0x100>, <0x100a 0x4>; >>> + interrupts = <0 185 0>; >>> + clocks = <&clock 318>; >>> + clock-names = "tmu_apbif"; >>> + }; >>> + >>> Note: For multi-instance tmu each instance should have an alias correctly >>> numbered in "aliases" node. >>> >>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>> b/drivers/thermal/samsung/exynos_tmu.c >>> index bfdfbd6..f95844e 100644 >>> --- a/drivers/thermal/samsung/exynos_tmu.c >>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>> @@ -42,6 +42,7 @@ >>> * @pdata: pointer to the tmu platform/configuration data >>> * @base: base address of the single instance of the TMU controller. >>> * @base_common: base address of the common registers of the TMU >>> controller. >>> + * @triminfo_base: misplaced register base for TRIMINFO on Exynos5420 only >> >> Instead of creating this new field you can re-use base_common for >> accessing the second set of register for misplaced triminfo address. >> Also you can rename this variable as base_second. > > The purpose and the meaning of the fields are entirely different. > The triminfo is a hardware bug present only in Exynos5420 My point is that for a bu
Re: [PATCH 3/3] thermal: exynos: Handle the misplaced TRIMINFO register
On Wed, Aug 28, 2013 at 2:27 PM, Naveen Krishna Ch wrote: > On 28 August 2013 14:13, amit daniel kachhap wrote: >> Hi Naveen, >> >> On Wed, Aug 28, 2013 at 11:49 AM, Naveen Krishna Ch >> wrote: >>> On 28 August 2013 11:33, amit daniel kachhap >>> wrote: >>>> Hi Naveen >>>> >>>> On Wed, Aug 28, 2013 at 11:15 AM, Naveen Krishna Chatradhi >>>> wrote: >>>>> This patch adds code to handle the misplaced TRIMINFO register >>>>> incase of Exynos5420. >>>>> >>>>> On Exynos5420 we have a TRIMINFO register being misplaced for >>>>> TMU channels 2, 3 and 4 >>>>> >>>>> TRIMINFO at 0x1006c000 contains data for TMU channel 3 >>>>> TRIMINFO at 0x100a contains data for TMU channel 4 >>>>> TRIMINFO at 0x10068000 contains data for TMU channel 2 >>>>> >>>>> The misplaced register address is passed through devicetree and >>>>> map it seperately during probe. >>>>> Also, adds the documentation under devicetree/bindings/thermal/ >>>>> >>>>> Signed-off-by: Naveen Krishna Chatradhi >>>>> --- >>>>> .../devicetree/bindings/thermal/exynos-thermal.txt | 21 + >>>>> drivers/thermal/samsung/exynos_tmu.c | 32 >>>>> +--- >>>>> 2 files changed, 49 insertions(+), 4 deletions(-) >>>>> >>>>> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>> index 284f530..e818473 100644 >>>>> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>> @@ -7,12 +7,21 @@ >>>>>"samsung,exynos4210-tmu" >>>>>"samsung,exynos5250-tmu" >>>>>"samsung,exynos5440-tmu" >>>>> + "samsung,exynos5420-tmu" >>>>> - interrupt-parent : The phandle for the interrupt controller >>>>> - reg : Address range of the thermal registers. For soc's which has >>>>> multiple >>>>> instances of TMU and some registers are shared across all TMU's >>>>> like >>>>> interrupt related then 2 set of register has to supplied. First >>>>> set >>>>> belongs to each instance of TMU and second set belongs to common >>>>> TMU >>>>> registers. >>>>> + >>>>> + ** NOTE FOR EXYNOS5420 ** >>>>> +TRIMINFO register is being misplaced for TMU channels 2, 3 and 4 >>>>> + >>>>> +TERMINFO for TMU channel 2 is present in address space of TMU >>>>> channel 3 >>>>> +TERMINFO for TMU channel 3 is present in address space of TMU >>>>> channel 4 >>>>> +TERMINFO for TMU channel 4 is present in address space of TMU >>>>> channel 2 >>>>> + >>>>> - interrupts : Should contain interrupt for thermal system >>>>> - clocks : The main clock for TMU device >>>>> - clock-names : Thermal system clock name >>>>> @@ -43,6 +52,18 @@ Example 2): >>>>> clock-names = "tmu_apbif"; >>>>> }; >>>>> >>>>> +Example 3): In case of Exynos5420 TMU channel 3 >>>>> + >>>>> + /* tmu for CPU3 */ >>>>> + tmu@1006c000 { >>>>> + compatible = "samsung,exynos5420-tmu"; >>>>> + /* 2nd reg is for the misplaced TRIMINFO register */ >>>>> + reg = <0x1006c000 0x100>, <0x100a 0x4>; >>>>> + interrupts = <0 185 0>; >>>>> + clocks = <&clock 318>; >>>>> + clock-names = "tmu_apbif"; >>>>> + }; >>>>> + >>>>> Note: For multi-instance tmu each instance should have an alias correctly >>>>> numbered in "aliases" node. >>>>> >>>>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>>>> b/drivers/thermal/samsung/exynos_tmu.c >>>>> index bfd
Re: [PATCH 2/3] thermal: samsung: Add TMU support for Exynos5420 SoCs
On Wed, Aug 28, 2013 at 11:15 AM, Naveen Krishna Chatradhi wrote: > This patch adds the neccessary register changes and arch information > to support Exynos5420 SoCs > Exynos5420 has 5 TMU channels one for each CPU 0, 1, 2 and 3 and GPU > > Signed-off-by: Naveen Krishna Chatradhi For all patch in this series, Acked-by: Amit Daniel Kachhap . A minor comment, please rename the flag SHARED_MEMORY to MULTIPLE_MEMORY as this is more consistent. Thanks, Amit Daniel > --- > drivers/thermal/samsung/exynos_tmu.c |4 ++ > drivers/thermal/samsung/exynos_tmu.h |1 + > drivers/thermal/samsung/exynos_tmu_data.c | 90 > + > drivers/thermal/samsung/exynos_tmu_data.h |7 +++ > 4 files changed, 102 insertions(+) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index d201ed8..bfdfbd6 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -499,6 +499,10 @@ static const struct of_device_id exynos_tmu_match[] = { > .compatible = "samsung,exynos5440-tmu", > .data = (void *)EXYNOS5440_TMU_DRV_DATA, > }, > + { > + .compatible = "samsung,exynos5420-tmu", > + .data = (void *)EXYNOS5420_TMU_DRV_DATA, > + }, > {}, > }; > MODULE_DEVICE_TABLE(of, exynos_tmu_match); > diff --git a/drivers/thermal/samsung/exynos_tmu.h > b/drivers/thermal/samsung/exynos_tmu.h > index 7c6c34a..d88a536 100644 > --- a/drivers/thermal/samsung/exynos_tmu.h > +++ b/drivers/thermal/samsung/exynos_tmu.h > @@ -43,6 +43,7 @@ enum soc_type { > SOC_ARCH_EXYNOS4210 = 1, > SOC_ARCH_EXYNOS, > SOC_ARCH_EXYNOS5440, > + SOC_ARCH_EXYNOS5420, > }; > > /** > diff --git a/drivers/thermal/samsung/exynos_tmu_data.c > b/drivers/thermal/samsung/exynos_tmu_data.c > index 23fea23..5adbb36 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.c > +++ b/drivers/thermal/samsung/exynos_tmu_data.c > @@ -177,6 +177,96 @@ struct exynos_tmu_init_data const > exynos5250_default_tmu_data = { > }; > #endif > > +#if defined(CONFIG_SOC_EXYNOS5420) > +static const struct exynos_tmu_registers exynos5420_tmu_registers = { > + .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, > + .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, > + .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, > + .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, > + .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT, > + .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK, > + .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, > + .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, > + .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, > + .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT, > + .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK, > + .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT, > + .tmu_status = EXYNOS_TMU_REG_STATUS, > + .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, > + .threshold_th0 = EXYNOS_THD_TEMP_RISE, > + .threshold_th1 = EXYNOS_THD_TEMP_FALL, > + .tmu_inten = EXYNOS_TMU_REG_INTEN, > + .inten_rise_mask = EXYNOS_TMU_RISE_INT_MASK, > + .inten_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT, > + .inten_fall_mask = EXYNOS_TMU_FALL_INT_MASK, > + .inten_fall_shift = EXYNOS_TMU_FALL_INT_SHIFT, > + .inten_rise0_shift = EXYNOS_TMU_INTEN_RISE0_SHIFT, > + .inten_rise1_shift = EXYNOS_TMU_INTEN_RISE1_SHIFT, > + .inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT, > + /* INTEN_RISE3 Not availble in exynos5420 */ > + .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT, > + .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, > + .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, > + .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, > + .intclr_fall_shift = EXYNOS_TMU_FALL_INT_SHIFT, > + .emul_con = EXYNOS_EMUL_CON, > + .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, > + .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, > + .emul_time_mask = EXYNOS_EMUL_TIME_MASK, > +}; > + > +#define EXYNOS5420_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] = S
Re: [PATCH 2/3] thermal: samsung: change base_common to more meaningful base_second
On Wed, Sep 4, 2013 at 9:53 AM, Naveen Krishna Chatradhi wrote: > On Exynos5440 and Exynos5420 there are registers common > across the TMU channels. > > To support that, we introduced a ADDRESS_MULTIPLE flag in the > driver and the 2nd set of register base and size are provided > in the "reg" property of the node. > > As per Amit's suggestion, this patch changes the base_common > to base_second and SHARED_MEMORY to ADDRESS_MULTIPLE. > > Signed-off-by: Naveen Krishna Chatradhi The changes look good. For all the 3 patches in the series, Acked-by: Amit Daniel Kachhap Reviewed-by: Amit Daniel Kachhap Thanks, Amit Daniel > --- > Changes since v2: > Changed the flag name from SHARED_MEMORY to ADDRESS_MULTIPLE. > https://lkml.org/lkml/2013/8/1/38 > > .../devicetree/bindings/thermal/exynos-thermal.txt |4 ++-- > drivers/thermal/samsung/exynos_tmu.c | 12 ++-- > drivers/thermal/samsung/exynos_tmu.h |4 ++-- > drivers/thermal/samsung/exynos_tmu_data.c |2 +- > 4 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > index 284f530..116cca0 100644 > --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > @@ -11,8 +11,8 @@ > - reg : Address range of the thermal registers. For soc's which has multiple > instances of TMU and some registers are shared across all TMU's like > interrupt related then 2 set of register has to supplied. First set > - belongs to each instance of TMU and second set belongs to common TMU > - registers. > + belongs to each instance of TMU and second set belongs to second set > + of common TMU registers. > - interrupts : Should contain interrupt for thermal system > - clocks : The main clock for TMU device > - clock-names : Thermal system clock name > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index d201ed8..3a55caf 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -41,7 +41,7 @@ > * @id: identifier of the one instance of the TMU controller. > * @pdata: pointer to the tmu platform/configuration data > * @base: base address of the single instance of the TMU controller. > - * @base_common: base address of the common registers of the TMU controller. > + * @base_second: base address of the common registers of the TMU controller. > * @irq: irq number of the TMU controller. > * @soc: id of the SOC type. > * @irq_work: pointer to the irq work structure. > @@ -56,7 +56,7 @@ struct exynos_tmu_data { > int id; > struct exynos_tmu_platform_data *pdata; > void __iomem *base; > - void __iomem *base_common; > + void __iomem *base_second; > int irq; > enum soc_type soc; > struct work_struct irq_work; > @@ -297,7 +297,7 @@ skip_calib_data: > } > /*Clear the PMIN in the common TMU register*/ > if (reg->tmu_pmin && !data->id) > - writel(0, data->base_common + reg->tmu_pmin); > + writel(0, data->base_second + reg->tmu_pmin); > out: > clk_disable(data->clk); > mutex_unlock(&data->lock); > @@ -451,7 +451,7 @@ static void exynos_tmu_work(struct work_struct *work) > > /* Find which sensor generated this interrupt */ > if (reg->tmu_irqstatus) { > - val_type = readl(data->base_common + reg->tmu_irqstatus); > + val_type = readl(data->base_second + reg->tmu_irqstatus); > if (!((val_type >> data->id) & 0x1)) > goto out; > } > @@ -582,7 +582,7 @@ static int exynos_map_dt_data(struct platform_device > *pdev) > * Check if the TMU shares some registers and then try to map the > * memory of common registers. > */ > - if (!TMU_SUPPORTS(pdata, SHARED_MEMORY)) > + if (!TMU_SUPPORTS(pdata, ADDRESS_MULTIPLE)) > return 0; > > if (of_address_to_resource(pdev->dev.of_node, 1, &res)) { > @@ -590,7 +590,7 @@ static int exynos_map_dt_data(struct platform_device > *pdev) > return -ENODEV; > } > > - data->base_common = devm_ioremap(&pdev->dev, res.start, > + data->base_second = devm_ioremap(&pdev->dev, res.start, > resource_size(&res))
Re: [PATCH 1/6] thermal: exynos: fix: Return from exynos_report_trigger() when therm_dev is NULL
On Tue, Sep 24, 2013 at 1:38 PM, Lukasz Majewski wrote: > The commit 4de0bdaa9677d11406c9becb70c60887c957e1f0 > ("thermal: exynos: Add support for instance based register/unregister") > broke check for presence of therm_dev at global thermal zone in > exynos_report_trigger(). > > The resulting wrong test prevents thermal_zone_device_update() call, which > calls handlers for situation when trip points are passed. > Such behavior prevents thermal driver from proper reaction (when TMU interrupt > is raised) in a situation when overheating is detected at TMU hardware. > This patch fixes it. > > Signed-off-by: Lukasz Majewski > Reviewed-by: Bartlomiej Zolnierkiewicz > Reviewed-by: Tomasz Figa > --- > drivers/thermal/samsung/exynos_thermal_common.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/thermal/samsung/exynos_thermal_common.c > b/drivers/thermal/samsung/exynos_thermal_common.c > index f10a6ad..55a912a 100644 > --- a/drivers/thermal/samsung/exynos_thermal_common.c > +++ b/drivers/thermal/samsung/exynos_thermal_common.c > @@ -310,7 +310,7 @@ void exynos_report_trigger(struct thermal_sensor_conf > *conf) > } > > th_zone = conf->pzone_data; > - if (th_zone->therm_dev) > + if (!th_zone->therm_dev) > return; Changes looks fine. Reviewed-by: Amit Daniel Kachhap Thanks, Amit Daniel > > if (th_zone->bind == false) { > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html On Tue, Sep 24, 2013 at 1:38 PM, Lukasz Majewski wrote: > The commit 4de0bdaa9677d11406c9becb70c60887c957e1f0 > ("thermal: exynos: Add support for instance based register/unregister") > broke check for presence of therm_dev at global thermal zone in > exynos_report_trigger(). > > The resulting wrong test prevents thermal_zone_device_update() call, which > calls handlers for situation when trip points are passed. > Such behavior prevents thermal driver from proper reaction (when TMU interrupt > is raised) in a situation when overheating is detected at TMU hardware. > This patch fixes it. > > Signed-off-by: Lukasz Majewski > Reviewed-by: Bartlomiej Zolnierkiewicz > Reviewed-by: Tomasz Figa > --- > drivers/thermal/samsung/exynos_thermal_common.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/thermal/samsung/exynos_thermal_common.c > b/drivers/thermal/samsung/exynos_thermal_common.c > index f10a6ad..55a912a 100644 > --- a/drivers/thermal/samsung/exynos_thermal_common.c > +++ b/drivers/thermal/samsung/exynos_thermal_common.c > @@ -310,7 +310,7 @@ void exynos_report_trigger(struct thermal_sensor_conf > *conf) > } > > th_zone = conf->pzone_data; > - if (th_zone->therm_dev) > + if (!th_zone->therm_dev) > return; > > if (th_zone->bind == false) { > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/6] thermal: exynos: Provide separate TMU data for Exynos4412
On Tue, Sep 24, 2013 at 1:38 PM, Lukasz Majewski wrote: > Up till now Exynos5250 and Exynos4412 had the same definitions for TMU > data. Following commit changes that, by introducing separate > exynos4412_default_tmu_data structure. > > Since Exynos4412 was chronologically first, the corresponding name for > TMU registers and default data was renamed. > > Additionally, new SOC_ARCH_EXYNOS4412 type has been defined. > > Signed-off-by: Lukasz Majewski > Reviewed-by: Bartlomiej Zolnierkiewicz > Reviewed-by: Tomasz Figa Reviewed-by: Amit Daniel Kachhap Thanks, Amit Daniel > --- > drivers/thermal/samsung/exynos_tmu.c |7 --- > drivers/thermal/samsung/exynos_tmu.h |1 + > drivers/thermal/samsung/exynos_tmu_data.c | 26 -- > drivers/thermal/samsung/exynos_tmu_data.h |9 - > 4 files changed, 33 insertions(+), 10 deletions(-) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index b43afda..a858cc4 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -488,7 +488,7 @@ static const struct of_device_id exynos_tmu_match[] = { > }, > { > .compatible = "samsung,exynos4412-tmu", > - .data = (void *)EXYNOS5250_TMU_DRV_DATA, > + .data = (void *)EXYNOS4412_TMU_DRV_DATA, > }, > { > .compatible = "samsung,exynos5250-tmu", > @@ -630,8 +630,9 @@ static int exynos_tmu_probe(struct platform_device *pdev) > return ret; > > if (pdata->type == SOC_ARCH_EXYNOS || > - pdata->type == SOC_ARCH_EXYNOS4210 || > - pdata->type == SOC_ARCH_EXYNOS5440) > + pdata->type == SOC_ARCH_EXYNOS4210 || > + pdata->type == SOC_ARCH_EXYNOS4412 || > + pdata->type == SOC_ARCH_EXYNOS5440) > data->soc = pdata->type; > else { > ret = -EINVAL; > diff --git a/drivers/thermal/samsung/exynos_tmu.h > b/drivers/thermal/samsung/exynos_tmu.h > index b364c9e..db37df0 100644 > --- a/drivers/thermal/samsung/exynos_tmu.h > +++ b/drivers/thermal/samsung/exynos_tmu.h > @@ -41,6 +41,7 @@ enum calibration_mode { > > enum soc_type { > SOC_ARCH_EXYNOS4210 = 1, > + SOC_ARCH_EXYNOS4412, > SOC_ARCH_EXYNOS, > SOC_ARCH_EXYNOS5440, > }; > diff --git a/drivers/thermal/samsung/exynos_tmu_data.c > b/drivers/thermal/samsung/exynos_tmu_data.c > index 9002499..bd08093 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.c > +++ b/drivers/thermal/samsung/exynos_tmu_data.c > @@ -90,8 +90,8 @@ struct exynos_tmu_init_data const > exynos4210_default_tmu_data = { > }; > #endif > > -#if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412) > -static const struct exynos_tmu_registers exynos5250_tmu_registers = { > +#if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250) > +static const struct exynos_tmu_registers exynos4412_tmu_registers = { > .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, > .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, > .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, > @@ -128,7 +128,7 @@ static const struct exynos_tmu_registers > exynos5250_tmu_registers = { > .emul_time_mask = EXYNOS_EMUL_TIME_MASK, > }; > > -#define EXYNOS5250_TMU_DATA \ > +#define EXYNOS4412_TMU_DATA \ > .threshold_falling = 10, \ > .trigger_levels[0] = 85, \ > .trigger_levels[1] = 103, \ > @@ -162,15 +162,29 @@ static const struct exynos_tmu_registers > exynos5250_tmu_registers = { > .temp_level = 103, \ > }, \ > .freq_tab_count = 2, \ > - .type = SOC_ARCH_EXYNOS, \ > - .registers = &exynos5250_tmu_registers, \ > + .registers = &exynos4412_tmu_registers, \ > .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ > TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | > \ > TMU_SUPPORT_EMUL_TIME) > +#endif > > +#if defined(CONFIG_SOC_EXYNOS4412) > +struct exynos_tmu_init_data const exynos4412_default_tmu_data = { > + .tmu_data = { > + { EXYNOS4412_TMU_DATA, > + .type = SOC_ARCH_EXYNOS4412, > + }, > + }, > + .tmu_count = 1, > +}; > +#endif > + > +#if defined(CONFIG_SOC_EXYNOS5250) > struct exynos_tmu_init_data const exynos5250_default_tmu_data = { > .tmu_data = { > - { EXYNOS5250_TMU_DATA }, > + { EXYNO
Re: [PATCH 3/6] thermal: exynos: Provide initial setting for TMU's test MUX address at Exynos4412
Hi, On Tue, Sep 24, 2013 at 1:38 PM, Lukasz Majewski wrote: > The commit d0a0ce3e77c795258d47f9163e92d5031d0c5221 ("thermal: exynos: Add > missing definations and code cleanup") has removed setting of test MUX address > value at TMU configuration setting. > > This field is not present on Exynos4210 and Exynos5 SoCs. However on > Exynos4412 > SoC it is required to set this field after reset because without it TMU shows > maximal available temperature, which causes immediate platform shutdown. Right In 5250 this field is not defined so didn't catch this. The changes looks fine but I have a minor comment that if this field is defined in 4412 in detail then you can add a field entry in exynos_tmu_registers with proper name and populate this field. The good thing is that in 5250 also this field is reserved and the default value is 0x6 so same TMU_DATA can be used for 5250 and 4412. The main idea of this suggestion is to reduce the soc checks in the driver. Thanks, Amit Daniel > > Signed-off-by: Lukasz Majewski > Reviewed-by: Bartlomiej Zolnierkiewicz > Reviewed-by: Tomasz Figa > --- > drivers/thermal/samsung/exynos_tmu.c |3 +++ > drivers/thermal/samsung/exynos_tmu_data.h |4 > 2 files changed, 7 insertions(+) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index a858cc4..21b89e4 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -317,6 +317,9 @@ static void exynos_tmu_control(struct platform_device > *pdev, bool on) > > con = readl(data->base + reg->tmu_ctrl); > > + if (pdata->type == SOC_ARCH_EXYNOS4412) > + con |= (EXYNOS4412_MUX_ADDR_VALUE << > EXYNOS4412_MUX_ADDR_SHIFT); > + > if (pdata->reference_voltage) { > con &= ~(reg->buf_vref_sel_mask << reg->buf_vref_sel_shift); > con |= pdata->reference_voltage << reg->buf_vref_sel_shift; > diff --git a/drivers/thermal/samsung/exynos_tmu_data.h > b/drivers/thermal/samsung/exynos_tmu_data.h > index b130b1e..a1ea19d 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.h > +++ b/drivers/thermal/samsung/exynos_tmu_data.h > @@ -95,6 +95,10 @@ > > #define EXYNOS_MAX_TRIGGER_PER_REG 4 > > +/* Exynos4412 specific */ > +#define EXYNOS4412_MUX_ADDR_VALUE 6 > +#define EXYNOS4412_MUX_ADDR_SHIFT 20 > + > /*exynos5440 specific registers*/ > #define EXYNOS5440_TMU_S0_7_TRIM 0x000 > #define EXYNOS5440_TMU_S0_7_CTRL 0x020 > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-pm" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html On Tue, Sep 24, 2013 at 1:38 PM, Lukasz Majewski wrote: > The commit d0a0ce3e77c795258d47f9163e92d5031d0c5221 ("thermal: exynos: Add > missing definations and code cleanup") has removed setting of test MUX address > value at TMU configuration setting. > > This field is not present on Exynos4210 and Exynos5 SoCs. However on > Exynos4412 > SoC it is required to set this field after reset because without it TMU shows > maximal available temperature, which causes immediate platform shutdown. > > Signed-off-by: Lukasz Majewski > Reviewed-by: Bartlomiej Zolnierkiewicz > Reviewed-by: Tomasz Figa > --- > drivers/thermal/samsung/exynos_tmu.c |3 +++ > drivers/thermal/samsung/exynos_tmu_data.h |4 > 2 files changed, 7 insertions(+) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index a858cc4..21b89e4 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -317,6 +317,9 @@ static void exynos_tmu_control(struct platform_device > *pdev, bool on) > > con = readl(data->base + reg->tmu_ctrl); > > + if (pdata->type == SOC_ARCH_EXYNOS4412) > + con |= (EXYNOS4412_MUX_ADDR_VALUE << > EXYNOS4412_MUX_ADDR_SHIFT); > + > if (pdata->reference_voltage) { > con &= ~(reg->buf_vref_sel_mask << reg->buf_vref_sel_shift); > con |= pdata->reference_voltage << reg->buf_vref_sel_shift; > diff --git a/drivers/thermal/samsung/exynos_tmu_data.h > b/drivers/thermal/samsung/exynos_tmu_data.h > index b130b1e..a1ea19d 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.h > +++ b/drivers/thermal/samsung/exynos_tmu_data.h > @@ -95,6 +95,10 @@ > > #define EXYNOS_MAX_TRIGGER_PER_REG 4 > > +/* Exynos4412 specific */ > +#define EXYNOS4412_MUX_ADDR_VALUE 6 > +#define EXYNOS4412_MUX_ADDR_SHIFT 20 > + > /*exynos5440 specific registers*/ > #define EXYNOS5440_TMU_S0_7_TRIM 0x000 > #define EXYNOS5440_TMU_S0_7_CTRL 0x020 > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-pm" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kern
Re: [PATCH 4/6] thermal: exynos: Replace SOC_ARCH_EXYNOS with SOC_ARCH_EXYNOS5250
On Tue, Sep 24, 2013 at 1:38 PM, Lukasz Majewski wrote: > The TMU data definition is now separated to Exynos4412 and Exynos5250. > > Now SOC_ARCH_EXYNOS only refers to Exynos5250. Hence the name > SOC_ARCH_EXYNOS has been changed to SOC_ARCH_EXYNOS5250. > > Signed-off-by: Lukasz Majewski Changes looks fine. Reviewed-by: Amit Daniel Kachhap Thanks, Amit > --- > drivers/thermal/samsung/exynos_tmu.c |4 ++-- > drivers/thermal/samsung/exynos_tmu.h |2 +- > drivers/thermal/samsung/exynos_tmu_data.c |2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index 21b89e4..037cd46 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -632,9 +632,9 @@ static int exynos_tmu_probe(struct platform_device *pdev) > if (ret) > return ret; > > - if (pdata->type == SOC_ARCH_EXYNOS || > - pdata->type == SOC_ARCH_EXYNOS4210 || > + if (pdata->type == SOC_ARCH_EXYNOS4210 || > pdata->type == SOC_ARCH_EXYNOS4412 || > + pdata->type == SOC_ARCH_EXYNOS5250 || > pdata->type == SOC_ARCH_EXYNOS5440) > data->soc = pdata->type; > else { > diff --git a/drivers/thermal/samsung/exynos_tmu.h > b/drivers/thermal/samsung/exynos_tmu.h > index db37df0..b42ece4 100644 > --- a/drivers/thermal/samsung/exynos_tmu.h > +++ b/drivers/thermal/samsung/exynos_tmu.h > @@ -42,7 +42,7 @@ enum calibration_mode { > enum soc_type { > SOC_ARCH_EXYNOS4210 = 1, > SOC_ARCH_EXYNOS4412, > - SOC_ARCH_EXYNOS, > + SOC_ARCH_EXYNOS5250, > SOC_ARCH_EXYNOS5440, > }; > > diff --git a/drivers/thermal/samsung/exynos_tmu_data.c > b/drivers/thermal/samsung/exynos_tmu_data.c > index bd08093..188223f 100644 > --- a/drivers/thermal/samsung/exynos_tmu_data.c > +++ b/drivers/thermal/samsung/exynos_tmu_data.c > @@ -183,7 +183,7 @@ struct exynos_tmu_init_data const > exynos4412_default_tmu_data = { > struct exynos_tmu_init_data const exynos5250_default_tmu_data = { > .tmu_data = { > { EXYNOS4412_TMU_DATA, > - .type = SOC_ARCH_EXYNOS, > + .type = SOC_ARCH_EXYNOS5250, > }, > }, > .tmu_count = 1, > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/4] regulator: s5m8767: Small fixes and device support
These patch series contains 3 small fixes and device tree support for pmic component of s5m8767 regulator driver. Amit Daniel Kachhap (4): regulator: s5m8767: Fix to work when platform registers less regulators regulator: s5m8767: Fix to read the first DVS register. regulator: s5m8767: Fix to work even if no DVS gpio present regulator: add device tree support for s5m8767 .../bindings/regulator/s5m8767-regulator.txt | 133 +++ drivers/mfd/sec-core.c | 75 ++- drivers/regulator/s5m8767.c| 230 ++-- include/linux/mfd/samsung/core.h |3 + 4 files changed, 424 insertions(+), 17 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/4] regulator: s5m8767: Fix to read the first DVS register.
This patch modifies the DVS register read function to select correct DVS1 register. This change is required because the GPIO select pin is 000 in unintialized state and hence selects the DVS1 register. Signed-off-by: Amit Daniel Kachhap --- drivers/regulator/s5m8767.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index df0b094..7ed7591 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -272,17 +272,17 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) reg = S5M8767_REG_BUCK1CTRL2; break; case S5M8767_BUCK2: - reg = S5M8767_REG_BUCK2DVS2; + reg = S5M8767_REG_BUCK2DVS1; if (s5m8767->buck2_gpiodvs) reg += s5m8767->buck_gpioindex; break; case S5M8767_BUCK3: - reg = S5M8767_REG_BUCK3DVS2; + reg = S5M8767_REG_BUCK3DVS1; if (s5m8767->buck3_gpiodvs) reg += s5m8767->buck_gpioindex; break; case S5M8767_BUCK4: - reg = S5M8767_REG_BUCK4DVS2; + reg = S5M8767_REG_BUCK4DVS1; if (s5m8767->buck4_gpiodvs) reg += s5m8767->buck_gpioindex; break; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/4] regulator: s5m8767: Fix to work even if no DVS gpio present
Signed-off-by: Amit Daniel Kachhap --- drivers/regulator/s5m8767.c | 17 ++--- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 7ed7591..9f991f2 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -626,9 +626,16 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) } } - if (gpio_is_valid(pdata->buck_gpios[0]) && - gpio_is_valid(pdata->buck_gpios[1]) && - gpio_is_valid(pdata->buck_gpios[2])) { + if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || + pdata->buck4_gpiodvs) { + + if (!gpio_is_valid(pdata->buck_gpios[0]) || + !gpio_is_valid(pdata->buck_gpios[1]) || + !gpio_is_valid(pdata->buck_gpios[2])) { + dev_err(&pdev->dev, "GPIO NOT VALID\n"); + return -EINVAL; + } + ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[0], "S5M8767 SET1"); if (ret) @@ -653,10 +660,6 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) /* SET3 GPIO */ gpio_direction_output(pdata->buck_gpios[2], (s5m8767->buck_gpioindex >> 0) & 0x1); - } else { - dev_err(&pdev->dev, "GPIO NOT VALID\n"); - ret = -EINVAL; - return ret; } ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2"); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/4] regulator: add device tree support for s5m8767
Add device tree based discovery support for pmic block of s5m8767 Signed-off-by: Amit Daniel Kachhap --- .../bindings/regulator/s5m8767-regulator.txt | 133 ++ drivers/mfd/sec-core.c | 75 - drivers/regulator/s5m8767.c| 190 +++- include/linux/mfd/samsung/core.h |3 + 4 files changed, 398 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt diff --git a/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt new file mode 100644 index 000..59c372b --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt @@ -0,0 +1,133 @@ +* Samsung S5M8767 Voltage and Current Regulator + +The Samsung S5M8767 is a multi-function device which includes volatage and +current regulators, rtc, charger controller and other sub-blocks. It is +interfaced to the host controller using a i2c interface. Each sub-block is +addressed by the host system using different i2c slave address. This document +describes the bindings for 'pmic' sub-block of s5m8767. + +Required properties: +- compatible: Should be "samsung,s5m8767-pmic". +- reg: Specifies the i2c slave address of the pmic block. It should be 0x66. + +- s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck2 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck3-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck3 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +- s5m8767,pmic-buck4-dvs-voltage: A set of 8 voltage values in micro-volt (uV) + units for buck4 when changing voltage using gpio dvs. Refer to [1] below + for additional information. + +[1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional +property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage' +property should specify atleast one voltage level (which would be a +safe operating voltage). + +If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional +property is specified, then all the eigth voltage values for the +'s5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. + +Optional properties: +- interrupt-parent: Specifies the phandle of the interrupt controller to which + the interrupts from s5m8767 are delivered to. +- interrupts: Interrupt specifiers for two interrupt sources. + - First interrupt specifier is for 'irq1' interrupt. + - Second interrupt specifier is for 'alert' interrupt. +- s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. +- s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs. +- s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs. + +Additional properties required if either of the optional properties are used: + +- s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected from + the possible 8 options selectable by the dvs gpios. The value of this + property should be between 0 and 7. If not specified or if out of range, the + default value of this property is set to 0. + +- s5m8767,pmic-buck-dvs-gpios: GPIO specifiers for three host gpio's used + for dvs. The format of the gpio specifier depends in the gpio controller. + +Regulators: The regulators of s5m8767 that have to be instantiated should be +included in a sub-node named 'regulators'. Regulator nodes included in this +sub-node should be of the format as listed below. + + regulator_name { + standard regulator bindings here + }; + +The following are the names of the regulators that the s5m8767 pmic block +supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number +as per the datasheet of s5m8767. + + - LDOn + - valid values for n are 1 to 28 + - Example: LDO0, LD01, LDO28 + - BUCKn + - valid values for n are 1 to 9. + - Example: BUCK1, BUCK2, BUCK9 + +The bindings inside the regulator nodes use the standard regulator bindings +which are documented elsewhere. + +Example: + + s5m8767_pmic@66 { + compatible = "samsung,s5m8767-pmic"; + reg = <0x66>; + + s5m8767,pmic-buck2-uses-gpio-dvs; + s5m8767,pmic-buck3-uses-gpio-dvs; + s5m8767,pmic-buck4-uses-gpio-dvs; + + s5m8767,pmic-buck-default-dvs-idx = <0>; + + s5m8767,pmic-buck-dvs-gpios = <&gpx0 0 1 0 0>, /* DVS1 */ +<&
[PATCH 1/4] regulator: s5m8767: Fix to work when platform registers less regulators
Signed-off-by: Amit Daniel Kachhap --- drivers/regulator/s5m8767.c | 17 + 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 2b822be..df0b094 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -168,7 +168,7 @@ static unsigned int s5m8767_opmode_reg[][4] = { static int s5m8767_get_register(struct regulator_dev *rdev, int *reg, int *enable_ctrl) { - int reg_id = rdev_get_id(rdev); + int i, reg_id = rdev_get_id(rdev); unsigned int mode; struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); @@ -195,8 +195,17 @@ static int s5m8767_get_register(struct regulator_dev *rdev, int *reg, return -EINVAL; } - mode = s5m8767->opmode[reg_id].mode; - *enable_ctrl = s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT; + for (i = 0; i < s5m8767->num_regulators; i++) { + if (s5m8767->opmode[i].id == reg_id) { + mode = s5m8767->opmode[i].mode; + break; + } + } + + if (i < s5m8767->num_regulators) + *enable_ctrl = + s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT; + return 0; } @@ -547,7 +556,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) rdev = s5m8767->rdev; s5m8767->dev = &pdev->dev; s5m8767->iodev = iodev; - s5m8767->num_regulators = S5M8767_REG_MAX - 2; + s5m8767->num_regulators = pdata->num_regulators; platform_set_drvdata(pdev, s5m8767); s5m8767->buck_gpioindex = pdata->buck_default_idx; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/4] thermal: Add support for interrupt based notification to thermal layer
The patch submitted by Jonghwa Lee (https://patchwork.kernel.org/patch/1683441/) adds support for interrupt based notification to thermal layer. This is a good feature but the current thermal framework needs polling/regular notification for invoking suitable cooling action. So adding 2 new thermal trend type to implement this feature. All these patches are based on thermal maintainer next tree. git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next Amit Daniel Kachhap (3): thermal: Add new thermal trend type to support quick cooling thermal: exynos: Miscellaneous fixes to support falling threshold interrupt thermal: exynos: Use the new thermal trend type for quick cooling action. Jonghwa Lee (1): Thermal: exynos: Add support for temperature falling interrupt. drivers/thermal/exynos_thermal.c | 105 +++--- drivers/thermal/step_wise.c | 19 - include/linux/platform_data/exynos_thermal.h |3 + include/linux/thermal.h |2 + 4 files changed, 80 insertions(+), 49 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/4] thermal: Add new thermal trend type to support quick cooling
This modification adds 2 new thermal trend type THERMAL_TREND_RAISE_FULL and THERMAL_TREND_DROP_FULL. This thermal trend can be used to quickly jump to the upper or lower cooling level instead of incremental increase or decrease. This is needed for temperature sensors which support rising/falling threshold interrupts and polling can be totally avoided. Signed-off-by: Amit Daniel Kachhap Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/step_wise.c | 19 +++ include/linux/thermal.h |2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index 1242cff..0d2d8d6 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c @@ -35,6 +35,10 @@ * state for this trip point *b. if the trend is THERMAL_TREND_DROPPING, use lower cooling * state for this trip point + *c. if the trend is THERMAL_TREND_RAISE_FULL, use highest cooling + * state for this trip point + *d. if the trend is THERMAL_TREND_DROP_FULL, use lowest cooling + * state for this trip point */ static unsigned long get_target_state(struct thermal_instance *instance, enum thermal_trend trend) @@ -50,7 +54,10 @@ static unsigned long get_target_state(struct thermal_instance *instance, } else if (trend == THERMAL_TREND_DROPPING) { cur_state = cur_state > instance->lower ? (cur_state - 1) : instance->lower; - } + } else if (trend == THERMAL_TREND_RAISE_FULL) + cur_state = instance->upper; + else if (trend == THERMAL_TREND_DROP_FULL) + cur_state = instance->lower; return cur_state; } @@ -87,7 +94,8 @@ static void update_instance_for_throttle(struct thermal_zone_device *tz, } static void update_instance_for_dethrottle(struct thermal_zone_device *tz, - int trip, enum thermal_trip_type trip_type) + int trip, enum thermal_trip_type trip_type, + enum thermal_trend trend) { struct thermal_instance *instance; struct thermal_cooling_device *cdev; @@ -101,7 +109,10 @@ static void update_instance_for_dethrottle(struct thermal_zone_device *tz, cdev = instance->cdev; cdev->ops->get_cur_state(cdev, &cur_state); - instance->target = cur_state > instance->lower ? + if (trend == THERMAL_TREND_DROP_FULL) + instance->target = instance->lower; + else + instance->target = cur_state > instance->lower ? (cur_state - 1) : THERMAL_NO_TARGET; /* Deactivate a passive thermal instance */ @@ -133,7 +144,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) if (tz->temperature >= trip_temp) update_instance_for_throttle(tz, trip, trip_type, trend); else - update_instance_for_dethrottle(tz, trip, trip_type); + update_instance_for_dethrottle(tz, trip, trip_type, trend); mutex_unlock(&tz->lock); } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 807f214..8bce3ec 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -68,6 +68,8 @@ enum thermal_trend { THERMAL_TREND_STABLE, /* temperature is stable */ THERMAL_TREND_RAISING, /* temperature is raising */ THERMAL_TREND_DROPPING, /* temperature is dropping */ + THERMAL_TREND_RAISE_FULL, /* Apply highest cooling action*/ + THERMAL_TREND_DROP_FULL, /* Apply lowest cooling action*/ }; /* Events supported by Thermal Netlink */ -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/4] Thermal: exynos: Add support for temperature falling interrupt.
From: Jonghwa Lee This patch introduces using temperature falling interrupt in exynos thermal driver. Former patch, it only use polling way to check whether if system themperature is fallen. However, exynos SOC also provides temperature falling interrupt way to do same things by hw. This feature is not supported in exynos4210. Signed-off-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/exynos_thermal.c | 81 +++--- include/linux/platform_data/exynos_thermal.h |3 + 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 7772d16..f6667e8 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -94,6 +94,7 @@ #define SENSOR_NAME_LEN16 #define MAX_TRIP_COUNT 8 #define MAX_COOLING_DEVICE 4 +#define MAX_THRESHOLD_LEVS 4 #define ACTIVE_INTERVAL 500 #define IDLE_INTERVAL 1 @@ -125,6 +126,7 @@ struct exynos_tmu_data { struct thermal_trip_point_conf { int trip_val[MAX_TRIP_COUNT]; int trip_count; + u8 trigger_falling; }; struct thermal_cooling_conf { @@ -174,7 +176,8 @@ static int exynos_set_mode(struct thermal_zone_device *thermal, mutex_lock(&th_zone->therm_dev->lock); - if (mode == THERMAL_DEVICE_ENABLED) + if (mode == THERMAL_DEVICE_ENABLED && + !th_zone->sensor_conf->trip_data.trigger_falling) th_zone->therm_dev->polling_delay = IDLE_INTERVAL; else th_zone->therm_dev->polling_delay = 0; @@ -413,7 +416,8 @@ static void exynos_report_trigger(void) break; } - if (th_zone->mode == THERMAL_DEVICE_ENABLED) { + if (th_zone->mode == THERMAL_DEVICE_ENABLED && + !th_zone->sensor_conf->trip_data.trigger_falling) { if (i > 0) th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL; else @@ -452,7 +456,8 @@ static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, EXYNOS_ZONE_COUNT, 0, NULL, &exynos_dev_ops, NULL, 0, - IDLE_INTERVAL); + sensor_conf->trip_data.trigger_falling ? + 0 : IDLE_INTERVAL); if (IS_ERR(th_zone->therm_dev)) { pr_err("Failed to register thermal zone device\n"); @@ -559,8 +564,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_platform_data *pdata = data->pdata; - unsigned int status, trim_info, rising_threshold; - int ret = 0, threshold_code; + unsigned int status, trim_info; + unsigned int rising_threshold = 0, falling_threshold = 0; + int ret = 0, threshold_code, i, trigger_levs = 0; mutex_lock(&data->lock); clk_enable(data->clk); @@ -585,6 +591,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev) (data->temp_error2 != 0)) data->temp_error1 = pdata->efuse_value; + /* Count trigger levels to be enabled */ + for (i = 0; i < MAX_THRESHOLD_LEVS; i++) + if (pdata->trigger_levels[i]) + trigger_levs++; + if (data->soc == SOC_ARCH_EXYNOS4210) { /* Write temperature code for threshold */ threshold_code = temp_to_code(data, pdata->threshold); @@ -594,44 +605,38 @@ static int exynos_tmu_initialize(struct platform_device *pdev) } writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); - - writeb(pdata->trigger_levels[0], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0); - writeb(pdata->trigger_levels[1], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL1); - writeb(pdata->trigger_levels[2], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL2); - writeb(pdata->trigger_levels[3], - data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL3); + for (i = 0; i < trigger_levs; i++) + writeb(pdata->trigger_levels[i], + data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4); writel(EXYNOS4210_TMU_INTCLEAR_VAL, data->base + EXYNOS_TMU_REG_INTCLEAR); } else if (data->soc == SOC_ARCH_EXYNOS) { - /* Write temperature code for threshold */ - threshold_code = temp_to_code(data, pdata->trigger_levels[0]); -
[PATCH 3/4] thermal: exynos: Miscellaneous fixes to support falling threshold interrupt
Below fixes are done to support falling threshold interrupt, * Falling interrupt status macro corrected according to exynos5 data sheet. * The get trend function modified to calculate trip temperature correctly. * The clearing of interrupt status in the isr is now done after handling the the event that caused the interrupt. Signed-off-by: Amit Daniel Kachhap Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/exynos_thermal.c | 18 +++--- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index f6667e8..bbaff56 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -82,7 +82,7 @@ #define EXYNOS_TRIMINFO_RELOAD 0x1 #define EXYNOS_TMU_CLEAR_RISE_INT 0x111 -#define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 16) +#define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) #define EXYNOS_MUX_ADDR_VALUE 6 #define EXYNOS_MUX_ADDR_SHIFT 20 #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 @@ -365,12 +365,19 @@ static int exynos_get_temp(struct thermal_zone_device *thermal, static int exynos_get_trend(struct thermal_zone_device *thermal, int trip, enum thermal_trend *trend) { - if (thermal->temperature >= trip) + int ret = 0; + unsigned long trip_temp; + + ret = exynos_get_trip_temp(thermal, trip, &trip_temp); + if (ret < 0) + return ret; + + if (thermal->temperature >= trip_temp) *trend = THERMAL_TREND_RAISING; else *trend = THERMAL_TREND_DROPPING; - return 0; + return ret; } /* Operation callback functions for thermal zone */ static struct thermal_zone_device_ops const exynos_dev_ops = { @@ -704,10 +711,9 @@ static void exynos_tmu_work(struct work_struct *work) struct exynos_tmu_data *data = container_of(work, struct exynos_tmu_data, irq_work); + exynos_report_trigger(); mutex_lock(&data->lock); clk_enable(data->clk); - - if (data->soc == SOC_ARCH_EXYNOS) writel(EXYNOS_TMU_CLEAR_RISE_INT | EXYNOS_TMU_CLEAR_FALL_INT, @@ -715,10 +721,8 @@ static void exynos_tmu_work(struct work_struct *work) else writel(EXYNOS4210_TMU_INTCLEAR_VAL, data->base + EXYNOS_TMU_REG_INTCLEAR); - clk_disable(data->clk); mutex_unlock(&data->lock); - exynos_report_trigger(); enable_irq(data->irq); } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/4] thermal: exynos: Use the new thermal trend type for quick cooling action.
This patch uses the quick thermal cooling trend type macros. This is needed as exynos5 and other thermal sensors now supports only interrupt method for thresold temperature check. Signed-off-by: Amit Daniel Kachhap Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/exynos_thermal.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index bbaff56..097c218 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -287,7 +287,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, case MONITOR_ZONE: case WARN_ZONE: if (thermal_zone_bind_cooling_device(thermal, i, cdev, - level, level)) { + level, 0)) { pr_err("error binding cdev inst %d\n", i); ret = -EINVAL; } @@ -373,9 +373,9 @@ static int exynos_get_trend(struct thermal_zone_device *thermal, return ret; if (thermal->temperature >= trip_temp) - *trend = THERMAL_TREND_RAISING; + *trend = THERMAL_TREND_RAISE_FULL; else - *trend = THERMAL_TREND_DROPPING; + *trend = THERMAL_TREND_DROP_FULL; return ret; } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] [RFC] cpufreq: can't raise max frequency with cpu_thermal
On Tue, Dec 18, 2012 at 9:45 PM, Doug Anderson wrote: > Amit, > > On Tue, Dec 18, 2012 at 8:17 PM, amit daniel kachhap > wrote: >> On Tue, Dec 18, 2012 at 12:29 AM, Sonny Rao wrote: >>> The cpu_thermal generic thermal management code has a bug where once >>> max cpu frequency has been lowered in sysfs (scaling_max_freq) it is >>> not possible to raise the max back up later. The bug is that the >>> notifer gets called by __cpufreq_set_policy() before the user policy >>> max is raised, and is incorrectly trying to enforce the max frequency >>> policy even when we are trying to change the policy. It is also not >>> clear why this driver is looking at the user policy since it is >>> primarily supposed to enforce thermal policy, not user set policy. >> >> Hi Sunny, >> >> I am not sure if this change is needed. > > Do you have a machine that's running with your code? Can you go into > sysfs (/sys/devices/system/cpu/cpu0/cpufreq/) and try lowering then > raising the max frequency by doing something like this (assumes that > you can scale down to 200MHz): > > cd /sys/devices/system/cpu/cpu0/cpufreq/ > OLD_VAL=$(cat scaling_max_freq) > cat scaling_min_freq > scaling_max_freq > echo ${OLD_VAL} > scaling_max_freq > > echo "$(cat scaling_max_freq) should be ${OLD_VAL}. Is it?" > > ...when I run the above without Sonny's patch on my system I see: > 20 should be 170. Is it? > > ...after Sonny's patch then the above works. Hi Doug, I tested the above steps on exynos origen board with all cpufreq cooling configs enabled in kernel version 3.8-rc1. In my tests I am able to vary scaling_max_freq to all values. Also I am in normal temperature threshold. So basically I am not able to reproduce the error reported, Thanks, Amit Daniel > >> There is a check in cpufreq_thermal_notifier function to return 0 if >> notify_device == NOTIFY_INVALID. So the user will be always able to >> change the max frequency in normal situation. Did you tested this for >> some corner cases? >> The reason behind putting this check is that I don't want to override >> the user constraints. >> >> Thanks, >> Amit Daniel >> >>> >>> Signed-off-by: Sonny Rao >>> --- >>> drivers/thermal/cpu_cooling.c |4 >>> 1 files changed, 0 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c >>> index 836828e..63bc708 100644 >>> --- a/drivers/thermal/cpu_cooling.c >>> +++ b/drivers/thermal/cpu_cooling.c >>> @@ -219,10 +219,6 @@ static int cpufreq_thermal_notifier(struct >>> notifier_block *nb, >>> if (cpumask_test_cpu(policy->cpu, ¬ify_device->allowed_cpus)) >>> max_freq = notify_device->cpufreq_val; >>> >>> - /* Never exceed user_policy.max*/ >>> - if (max_freq > policy->user_policy.max) >>> - max_freq = policy->user_policy.max; >>> - >>> if (policy->max != max_freq) >>> cpufreq_verify_within_limits(policy, 0, max_freq); >>> >>> -- >>> 1.7.7.3 >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >>> the body of a message to majord...@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>> Please read the FAQ at http://www.tux.org/lkml/ > > -Doug > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] cpufreq: exynos: Add the missing cpufreq_cpu_put function
This patch adds the missing cpufreq_cpu_put function needed for returning the cpufreq policy instance. Signed-off-by: Amit Daniel Kachhap --- drivers/cpufreq/exynos-cpufreq.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index 7012ea8..a2b7adc 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c @@ -208,6 +208,7 @@ static int exynos_cpufreq_pm_notifier(struct notifier_block *notifier, } out: mutex_unlock(&cpufreq_lock); + cpufreq_cpu_put(policy); return NOTIFY_OK; } -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] [RFC] cpufreq: can't raise max frequency with cpu_thermal
On Tue, Dec 18, 2012 at 12:29 AM, Sonny Rao wrote: > The cpu_thermal generic thermal management code has a bug where once > max cpu frequency has been lowered in sysfs (scaling_max_freq) it is > not possible to raise the max back up later. The bug is that the > notifer gets called by __cpufreq_set_policy() before the user policy > max is raised, and is incorrectly trying to enforce the max frequency > policy even when we are trying to change the policy. It is also not > clear why this driver is looking at the user policy since it is > primarily supposed to enforce thermal policy, not user set policy. Hi Sunny, I am not sure if this change is needed. There is a check in cpufreq_thermal_notifier function to return 0 if notify_device == NOTIFY_INVALID. So the user will be always able to change the max frequency in normal situation. Did you tested this for some corner cases? The reason behind putting this check is that I don't want to override the user constraints. Thanks, Amit Daniel > > Signed-off-by: Sonny Rao > --- > drivers/thermal/cpu_cooling.c |4 > 1 files changed, 0 insertions(+), 4 deletions(-) > > diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > index 836828e..63bc708 100644 > --- a/drivers/thermal/cpu_cooling.c > +++ b/drivers/thermal/cpu_cooling.c > @@ -219,10 +219,6 @@ static int cpufreq_thermal_notifier(struct > notifier_block *nb, > if (cpumask_test_cpu(policy->cpu, ¬ify_device->allowed_cpus)) > max_freq = notify_device->cpufreq_val; > > - /* Never exceed user_policy.max*/ > - if (max_freq > policy->user_policy.max) > - max_freq = policy->user_policy.max; > - > if (policy->max != max_freq) > cpufreq_verify_within_limits(policy, 0, max_freq); > > -- > 1.7.7.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/30] thermal: cpu_cooling: remove unused headers
Hi, On Wed, Apr 17, 2013 at 10:41 PM, Eduardo Valentin wrote: > As this code is not a module nor a platform device driver, > this patch removes some unused header files. > > Cc: Zhang Rui > Cc: linux...@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Eduardo Valentin Reviewed-by: Amit Daniel Kachhap Thanks, Amit Daniel > --- > drivers/thermal/cpu_cooling.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > index 5f5c780..778c43d 100644 > --- a/drivers/thermal/cpu_cooling.c > +++ b/drivers/thermal/cpu_cooling.c > @@ -20,10 +20,7 @@ > * > * ~~ > */ > -#include > -#include > #include > -#include > #include > #include > #include > -- > 1.8.2.1.342.gfa7285d > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 00/30] thermal: cpu_cooling: code improvements
Hi Eduardo, I looked at your whole series and they certainly looks useful, so for the entire series, Acked-by: Amit Daniel Kachhap Thanks, Amit Daniel Kachhap On Thu, Apr 18, 2013 at 2:02 AM, Eduardo Valentin wrote: > On 17-04-2013 13:11, Eduardo Valentin wrote: >> >> Rui, > > > > Looks like I forgot to add the lists on patch 00. Doing so.. >> >> >> This is a series of patches to improve the code for cpu_cooling. >> Majority of these changes are actually kernel-doc updates, as >> they required to be revised. A part from these, there are some >> changes regarding code style and readiness. >> >> Some may complain that these are a matter of taste, indeed. >> But I tried to just be unbiased and just keep the changes related >> to kernel-doc and checkpatch.pl. After this series, theses >> tools should be generating decent output ;-). >> >> The remaining changes are actually a couple of fixes for defensive >> coding. A part from updating the MAINTAINERS entry to cover cpu_cooling. >> >> This series has been tested on TI OMAP4430, together with the >> thermal driver under staging tree. >> >> All these patches are based on current linux-next/master. >> >> They are also available here: >> >> All best, >> >> Eduardo Valentin (30): >>thermal: cpu_cooling: remove unused headers >>thermal: cpu_cooling: remove trailing white spaces >>thermal: cpu_cooling: fix kernel_doc for cpufreq_cooling_device >>thermal: cpu_cooling: use EXPORT_SYMBOL_GPL >>thermal: cpu_cooling: remove compiler warning >>thermal: cpu_cooling: standardize end of function >>thermal: cpu_cooling: fix kernel doc for is_cpufreq_valid >>thermal: cpu_cooling: add documentation for get_property >>thermal: cpu_cooling: standardize comment style >>thermal: cpu_cooling: align on open parenthesis >>thermal: cpu_cooling: remove trailing blank line >>thermal: cpu_cooling: document cpufreq_get_cooling_level >>thermal: cpu_cooling: remove checkpatch.pl warning >>thermal: cpu_cooling: improve documentation for get_cpu_frequency >>thermal: cpu_cooling: update documentation for cpufreq_apply_cooling >>thermal: cpu_cooling: update documentation for >> cpufreq_thermal_notifier >>thermal: cpu_cooling: update Kconfig entry >>thermal: cpu_cooling: alignment improvements >>thermal: cpu_cooling: update documentation for cpufreq_get_max_state >>thermal: cpu_cooling: update documentation for cpufreq_get_cur_state >>thermal: cpu_cooling: update documentation for cpufreq_set_cur_state >>thermal: cpu_cooling: update kernel-doc for cpufreq_cooling_register >>thermal: cpu_cooling: update kernel-doc comment for >> cpufreq_cooling_unregister >>thermal: cpu_cooling: use snprintf instead of sprintf >>thermal: cpu_cooling: remove not needed curl brackets >>thermal: cpu_cooling: remove unused symbols >>thermal: cpu_cooling: add needed header for cpu_cooling.h >>MAINTAINERS: update thermal entry by adding file cpu_cooling.h >>thermal: cpu_cooling: remove unused symbols on cpu_cooling.h >>thermal: cpu_cooling: improve line breaking >> >> MAINTAINERS | 1 + >> drivers/thermal/Kconfig | 5 +- >> drivers/thermal/cpu_cooling.c | 156 >> ++ >> include/linux/cpu_cooling.h | 20 +++--- >> 4 files changed, 125 insertions(+), 57 deletions(-) >> > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V5 27/30] Documentation: thermal: Explain the exynos thermal driver model
Hi Rob, On Tue, Jun 11, 2013 at 10:52 PM, Rob Landley wrote: > On 06/11/2013 07:53:37 AM, Amit Daniel Kachhap wrote: >> >> This patch updates the documentation to explain the driver model >> and file layout. >> >> Acked-by: Kukjin Kim >> Signed-off-by: Amit Daniel Kachhap >> --- >> Documentation/thermal/exynos_thermal | 43 >> ++--- >> 1 files changed, 34 insertions(+), 9 deletions(-) > > ... > >> -TMU(Thermal Management Unit) in EXYNOS4 generates interrupt >> +TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt >> when temperature exceeds pre-defined levels. >> -The maximum number of configurable threshold is four. >> +The maximum number of configurable threshold is five. > > > Was that a driver change or was that a chipset change that only applies to > version 5? Basically in the new chipset several new features are added in controller so driver is modified accordingly. However in V5 some driver fixes are done as commented by jonghwa. > > Rob-- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V5 02/30] thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
Hi Eduardo, On Mon, Jun 17, 2013 at 8:35 AM, Eduardo Valentin wrote: > Hey Amit, > > On 11-06-2013 08:53, Amit Daniel Kachhap wrote: >> This patch adds config sybmol ARCH_HAS_TMU to enable the TMU driver. >> This will allow adding support for new soc easily as now it is the >> platform responsibility to enable this config symbol. >> >> Acked-by: Kukjin Kim >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/Kconfig |5 - >> 1 files changed, 4 insertions(+), 1 deletions(-) >> >> diff --git a/drivers/thermal/samsung/Kconfig >> b/drivers/thermal/samsung/Kconfig >> index 2d3d9dc..145a55d 100644 >> --- a/drivers/thermal/samsung/Kconfig >> +++ b/drivers/thermal/samsung/Kconfig >> @@ -1,6 +1,9 @@ >> +config ARCH_HAS_TMU >> + bool >> + >> config EXYNOS_THERMAL >> tristate "Temperature sensor on Samsung EXYNOS" >> - depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) >> + depends on ARCH_HAS_TMU > > I would rather use ARCH_HAS_BANDGAP as discussed and agreed during your > v4 review. I managed push this patch through RMK's system: > http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7758/1 Agreed I will post my TMU re-structured patches with this config flag. Thanks, Amit Daniel > >> depends on CPU_THERMAL >> help >> If you say yes here you get support for TMU (Thermal Management >> > > > -- > You have got to be excited about what you are doing. (L. Lamport) > > Eduardo Valentin > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 00/30] thermal: exynos: Re-structure driver and add support for exynos5440
Hi Rui/Eduardo, Submitting V6 version with all comments fixed. It is good if these patches gets merged in this merge window. If any comments please let me know. Thanks, Amit Daniel Changes in V6: * Uses ARCH_HAS_BANDGAP config flag which is merged now in arm tree. (http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7758/1). * In this version patches 1, 2, 3, 4 and 30 are modified. Others are same as V5. * Added acked by from Jonghwa Lee. * Rebased against Thermal Maintainer next tree. Changes in V5: * Most of the changes in this version is as per suggestion from Jonghwa Lee. I have retained one to one mapping of platform data with TMU instances as the TMU's are different devices. In exynos5440 soc there is some register sharing across multiple TMU's but in exynos5420 there is no register between multiple TMU's, so the current implementation is useful to support both of the above. This patch uses localized ARCH_HAS_TMU Kconfig option and is a temporary solution until a more generic macro ARCH_HAS_BANDGAP is introduced as per discussion in the link https://patchwork.kernel.org/patch/2659001/. * trip type is passed as platform data. * HW trip is allowed only for maximum level. * Platform data structure is now abstracted inside 1 more structure to support multiple sensor TMU data. Changes in V4: Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below, * Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed. * Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs. * Wrote all register description documentation. * Split 5440 TMU support patch into controller change, configuration data and feature addition patches. * Remove all *LINUX_* in the header files. * Still regulator enable is kept optional but a TODO: comment is added to fix it later. Changes in V3: * Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang. Changes in V2: * Separated SOC data from TMU driver. This is as per suggestion from Eduardo. * Merged the new file created for exynos5440 TMU controller with the existing TMU controller code. * Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file. * Even the register definations/bitfields are treated as data as there is some variation across SOC's. This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone. Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness. (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg17817.html) Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes. (https://patchwork.kernel.org/patch/1668371/) Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support. Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict. All these patches are based on thermal maintainers git tree, git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next. Amit Daniel Kachhap (29): thermal: exynos: Moving exynos thermal files into samsung directory thermal: exynos: Use ARCH_HAS_BANDGAP config to know the supported soc's thermal: exynos: Remove un-necessary CPU_THERMAL dependency thermal: exynos: Bifurcate exynos thermal common and tmu controller code thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c thermal: exynos: Move exynos_thermal.h from include/* to driver/* folder thermal: exynos: Bifurcate exynos tmu driver and configuration data thermal: exynos: Add missing definations and code cleanup thermal: exynos: Add extra entries in the tmu platform data thermal: exynos: Move register definitions from driver to data file thermal: exynos: Support thermal tripping thermal: exynos: Fix to clear only the generated interrupts thermal: exynos: Add support for instance based register/unregister thermal: exynos: Modify private_data to appropriate name driver_data thermal: exynos: Return success even if no cooling data supplied thermal: exynos: Make the zone handling use trip information thermal: exynos: Remove non DT based support thermal: exynos: Add support to handle many instances of TMU thermal: exynos:
[PATCH V6 08/30] thermal: exynos: Add missing definations and code cleanup
This patch adds some extra register bitfield definations and cleans up the code to prepare for moving register macros and definations inside the TMU data section. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 62 +- 1 files changed, 46 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 5df04a1..fa33a48 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -43,9 +43,12 @@ #define EXYNOS_TMU_TRIM_TEMP_MASK 0xff #define EXYNOS_TMU_GAIN_SHIFT 8 +#define EXYNOS_TMU_GAIN_MASK 0xf #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 -#define EXYNOS_TMU_CORE_ON 3 -#define EXYNOS_TMU_CORE_OFF2 +#define EXYNOS_TMU_REF_VOLTAGE_MASK0x1f +#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf +#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 +#define EXYNOS_TMU_CORE_EN_SHIFT 0 #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 /* Exynos4210 specific registers */ @@ -63,6 +66,7 @@ #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK0x10 #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK0x100 #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK0x1000 +#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x #define EXYNOS4210_TMU_INTCLEAR_VAL0x /* Exynos5250 and Exynos4412 specific registers */ @@ -72,17 +76,30 @@ #define EXYNOS_EMUL_CON0x80 #define EXYNOS_TRIMINFO_RELOAD 0x1 +#define EXYNOS_TRIMINFO_SHIFT 0x0 +#define EXYNOS_TMU_RISE_INT_MASK 0x111 +#define EXYNOS_TMU_RISE_INT_SHIFT 0 +#define EXYNOS_TMU_FALL_INT_MASK 0x111 +#define EXYNOS_TMU_FALL_INT_SHIFT 12 #define EXYNOS_TMU_CLEAR_RISE_INT 0x111 #define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) -#define EXYNOS_MUX_ADDR_VALUE 6 -#define EXYNOS_MUX_ADDR_SHIFT 20 #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 +#define EXYNOS_TMU_TRIP_MODE_MASK 0x7 + +#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 +#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 +#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 +#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 +#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 +#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 +#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 #define EFUSE_MIN_VALUE 40 #define EFUSE_MAX_VALUE 100 #ifdef CONFIG_THERMAL_EMULATION #define EXYNOS_EMUL_TIME 0x57F0 +#define EXYNOS_EMUL_TIME_MASK 0x #define EXYNOS_EMUL_TIME_SHIFT 16 #define EXYNOS_EMUL_DATA_SHIFT 8 #define EXYNOS_EMUL_DATA_MASK 0xFF @@ -261,24 +278,37 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) mutex_lock(&data->lock); clk_enable(data->clk); - con = pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT | - pdata->gain << EXYNOS_TMU_GAIN_SHIFT; + con = readl(data->base + EXYNOS_TMU_REG_CONTROL); - if (data->soc == SOC_ARCH_EXYNOS) { - con |= pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT; - con |= (EXYNOS_MUX_ADDR_VALUE << EXYNOS_MUX_ADDR_SHIFT); + if (pdata->reference_voltage) { + con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << + EXYNOS_TMU_REF_VOLTAGE_SHIFT); + con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT; + } + + if (pdata->gain) { + con &= ~(EXYNOS_TMU_GAIN_MASK << EXYNOS_TMU_GAIN_SHIFT); + con |= (pdata->gain << EXYNOS_TMU_GAIN_SHIFT); + } + + if (pdata->noise_cancel_mode) { + con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << + EXYNOS_TMU_TRIP_MODE_SHIFT); + con |= (pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT); } if (on) { - con |= EXYNOS_TMU_CORE_ON; - interrupt_en = pdata->trigger_level3_en << 12 | - pdata->trigger_level2_en << 8 | - pdata->trigger_level1_en << 4 | - pdata->trigger_level0_en; + con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); + interrupt_en = + pdata->trigger_level3_en << EXYNOS_TMU_INTEN_RISE3_SHIFT | + pdata->trigger_level2_en << EXYNOS_TMU_INTEN_RISE2_SHIFT | + pdata->trigger_level1_en << EXYNOS_TMU_INTEN_RISE1_SHIFT | + pdata->trigger_level0_en << EXYNOS_TMU_INTEN_RISE0_SHIFT; if (pdata->threshold_falling) - interrupt_en |= interrupt_en << 16; + interrupt_en |= + interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; } else { -
[PATCH V6 07/30] thermal: exynos: Bifurcate exynos tmu driver and configuration data
This code splits the exynos tmu driver code into SOC specific data parts. This will simplify adding new SOC specific data to the same TMU controller. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/Kconfig |3 +- drivers/thermal/samsung/Makefile |1 + drivers/thermal/samsung/exynos_tmu.c | 67 ++--- drivers/thermal/samsung/exynos_tmu_data.c | 78 + drivers/thermal/samsung/exynos_tmu_data.h | 40 +++ 5 files changed, 125 insertions(+), 64 deletions(-) create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index f8100b1..b653f15 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig @@ -5,7 +5,8 @@ config EXYNOS_THERMAL If you say yes here you get support for the TMU (Thermal Management Unit) driver for SAMSUNG EXYNOS series of soc. This driver initialises the TMU, reports temperature and handles cooling action if defined. - This driver uses the exynos core thermal API's. + This driver uses the exynos core thermal API's and TMU configuration + data from the supported soc's. config EXYNOS_THERMAL_CORE bool "Core thermal framework support for EXYNOS SOC's" diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index 22528d6..c09d830 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,4 +3,5 @@ # 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 6aa2fd2..5df04a1 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -30,6 +30,7 @@ #include "exynos_thermal_common.h" #include "exynos_tmu.h" +#include "exynos_tmu_data.h" /* Exynos generic registers */ #define EXYNOS_TMU_REG_TRIMINFO0x0 @@ -381,66 +382,6 @@ static struct thermal_sensor_conf exynos_sensor_conf = { .write_emul_temp= exynos_tmu_set_emulation, }; -#if defined(CONFIG_CPU_EXYNOS4210) -static struct exynos_tmu_platform_data const exynos4210_default_tmu_data = { - .threshold = 80, - .trigger_levels[0] = 5, - .trigger_levels[1] = 20, - .trigger_levels[2] = 30, - .trigger_level0_en = 1, - .trigger_level1_en = 1, - .trigger_level2_en = 1, - .trigger_level3_en = 0, - .gain = 15, - .reference_voltage = 7, - .cal_type = TYPE_ONE_POINT_TRIMMING, - .freq_tab[0] = { - .freq_clip_max = 800 * 1000, - .temp_level = 85, - }, - .freq_tab[1] = { - .freq_clip_max = 200 * 1000, - .temp_level = 100, - }, - .freq_tab_count = 2, - .type = SOC_ARCH_EXYNOS4210, -}; -#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data) -#else -#define EXYNOS4210_TMU_DRV_DATA (NULL) -#endif - -#if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412) -static struct exynos_tmu_platform_data const exynos_default_tmu_data = { - .threshold_falling = 10, - .trigger_levels[0] = 85, - .trigger_levels[1] = 103, - .trigger_levels[2] = 110, - .trigger_level0_en = 1, - .trigger_level1_en = 1, - .trigger_level2_en = 1, - .trigger_level3_en = 0, - .gain = 8, - .reference_voltage = 16, - .noise_cancel_mode = 4, - .cal_type = TYPE_ONE_POINT_TRIMMING, - .efuse_value = 55, - .freq_tab[0] = { - .freq_clip_max = 800 * 1000, - .temp_level = 85, - }, - .freq_tab[1] = { - .freq_clip_max = 200 * 1000, - .temp_level = 103, - }, - .freq_tab_count = 2, - .type = SOC_ARCH_EXYNOS, -}; -#define EXYNOS_TMU_DRV_DATA (&exynos_default_tmu_data) -#else -#define EXYNOS_TMU_DRV_DATA (NULL) -#endif - #ifdef CONFIG_OF static const struct of_device_id exynos_tmu_match[] = { { @@ -449,11 +390,11 @@ static const struct of_device_id exynos_tmu_match[] = { }, { .compatible = "samsung,exynos4412-tmu", - .data = (void *)EXYNOS_TMU_DRV_DATA, + .data = (void *)EXYNOS5250_TMU_DRV_DATA, }, { .compatible = "samsung,exynos5250-tmu", - .data = (void *)EXYNOS_TMU_DRV_DATA, + .data = (void *)EXYNOS5250_TMU_DRV_DATA, },
[PATCH V6 02/30] thermal: exynos: Use ARCH_HAS_BANDGAP config to know the supported soc's
This patch uses the recently added config sybmol ARCH_HAS_BANDGAP to enable the TMU driver. This will allow adding support for new soc easily as now it is the platform responsibility to enable this config symbol for a particular soc. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/Kconfig |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index 2d3d9dc..883a8a8 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig @@ -1,6 +1,6 @@ config EXYNOS_THERMAL tristate "Temperature sensor on Samsung EXYNOS" - depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) + depends on ARCH_HAS_BANDGAP depends on CPU_THERMAL help If you say yes here you get support for TMU (Thermal Management -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 05/30] thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
This patch renames exynos_thermal.c to exynos_tmu.c. This change is needed as this file now just contains exynos tmu driver related codes and thermal zone or cpufreq cooling registration related changes are not there anymore. Acked-by: Kukjin Kim Acked-by: Eduardo Valentin Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/Makefile |6 +++--- .../samsung/{exynos_thermal.c => exynos_tmu.c} |2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename drivers/thermal/samsung/{exynos_thermal.c => exynos_tmu.c} (99%) diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index 6227d4f..22528d6 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -1,6 +1,6 @@ # # Samsung thermal specific Makefile # -obj-$(CONFIG_EXYNOS_THERMAL) += exynos_soc_thermal.o -exynos_soc_thermal-y := exynos_thermal.o -exynos_soc_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o +obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o +exynos_thermal-y := exynos_tmu.o +exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o diff --git a/drivers/thermal/samsung/exynos_thermal.c b/drivers/thermal/samsung/exynos_tmu.c similarity index 99% rename from drivers/thermal/samsung/exynos_thermal.c rename to drivers/thermal/samsung/exynos_tmu.c index 5293849..22a8874 100644 --- a/drivers/thermal/samsung/exynos_thermal.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1,5 +1,5 @@ /* - * exynos_thermal.c - Samsung EXYNOS TMU (Thermal Management Unit) + * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit) * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 04/30] thermal: exynos: Bifurcate exynos thermal common and tmu controller code
This code bifurcates exynos thermal implementation into common and sensor specific parts. The common thermal code interacts with core thermal layer and core cpufreq cooling parts and is independent of SOC specific driver. This change is needed to cleanly add support for new TMU sensors. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/Kconfig | 19 +- drivers/thermal/samsung/Makefile|4 +- drivers/thermal/samsung/exynos_thermal.c| 419 +-- drivers/thermal/samsung/exynos_thermal_common.c | 384 + drivers/thermal/samsung/exynos_thermal_common.h | 83 + 5 files changed, 490 insertions(+), 419 deletions(-) create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index 2cf31ad..f8100b1 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig @@ -1,8 +1,17 @@ config EXYNOS_THERMAL - tristate "Temperature sensor on Samsung EXYNOS" + tristate "Exynos thermal management unit driver" depends on ARCH_HAS_BANDGAP help - If you say yes here you get support for TMU (Thermal Management - Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering - the exynos thermal driver with the core thermal layer and cpu - cooling API's. + If you say yes here you get support for the TMU (Thermal Management + Unit) driver for SAMSUNG EXYNOS series of soc. This driver initialises + the TMU, reports temperature and handles cooling action if defined. + This driver uses the exynos core thermal API's. + +config EXYNOS_THERMAL_CORE + bool "Core thermal framework support for EXYNOS SOC's" + depends on EXYNOS_THERMAL + help + If you say yes here you get support for EXYNOS TMU + (Thermal Management Unit) common registration/unregistration + functions to the core thermal layer and also to use the generic + cpu cooling API's. diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index 1fe6d93..6227d4f 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -1,4 +1,6 @@ # # Samsung thermal specific Makefile # -obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o +obj-$(CONFIG_EXYNOS_THERMAL) += exynos_soc_thermal.o +exynos_soc_thermal-y := exynos_thermal.o +exynos_soc_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o diff --git a/drivers/thermal/samsung/exynos_thermal.c b/drivers/thermal/samsung/exynos_thermal.c index 03e4bbc..5293849 100644 --- a/drivers/thermal/samsung/exynos_thermal.c +++ b/drivers/thermal/samsung/exynos_thermal.c @@ -21,23 +21,15 @@ * */ -#include -#include -#include -#include -#include -#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include +#include +#include #include +#include +#include + +#include "exynos_thermal_common.h" /* Exynos generic registers */ #define EXYNOS_TMU_REG_TRIMINFO0x0 @@ -88,16 +80,6 @@ #define EFUSE_MIN_VALUE 40 #define EFUSE_MAX_VALUE 100 -/* In-kernel thermal framework related macros & definations */ -#define SENSOR_NAME_LEN16 -#define MAX_TRIP_COUNT 8 -#define MAX_COOLING_DEVICE 4 -#define MAX_THRESHOLD_LEVS 4 - -#define ACTIVE_INTERVAL 500 -#define IDLE_INTERVAL 1 -#define MCELSIUS 1000 - #ifdef CONFIG_THERMAL_EMULATION #define EXYNOS_EMUL_TIME 0x57F0 #define EXYNOS_EMUL_TIME_SHIFT 16 @@ -106,17 +88,6 @@ #define EXYNOS_EMUL_ENABLE 0x1 #endif /* CONFIG_THERMAL_EMULATION */ -/* CPU Zone information */ -#define PANIC_ZONE 4 -#define WARN_ZONE 3 -#define MONITOR_ZONE2 -#define SAFE_ZONE 1 - -#define GET_ZONE(trip) (trip + 2) -#define GET_TRIP(zone) (zone - 2) - -#define EXYNOS_ZONE_COUNT 3 - struct exynos_tmu_data { struct exynos_tmu_platform_data *pdata; struct resource *mem; @@ -129,384 +100,6 @@ struct exynos_tmu_data { u8 temp_error1, temp_error2; }; -struct thermal_trip_point_conf { - int trip_val[MAX_TRIP_COUNT]; - int trip_count; - u8 trigger_falling; -}; - -struct thermal_cooling_conf { - struct freq_clip_table freq_data[MAX_TRIP_COUNT]; - int freq_clip_count; -}; - -struct thermal_sensor_conf { - char name[SENSOR_NAME_LEN]; - int (*read_temperature)(void *data); - int (*write_emul_temp)(void *drv_data, unsigned long temp); - struct thermal_trip_point_conf trip_data; - struct thermal_cooling_conf cooling_data; - void *private_data; -}; - -struct exynos_ther
[PATCH V6 03/30] thermal: exynos: Remove un-necessary CPU_THERMAL dependency
This patch removes the dependency on CPU_THERMAL for compiling TMU driver. This is useful for cases when only TMU controller needs to be initialised without cpu cooling action. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/Kconfig |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index 883a8a8..2cf31ad 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig @@ -1,7 +1,6 @@ config EXYNOS_THERMAL tristate "Temperature sensor on Samsung EXYNOS" depends on ARCH_HAS_BANDGAP - depends on CPU_THERMAL help If you say yes here you get support for TMU (Thermal Management Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 25/30] thermal: exynos: Fix to set the second point correction value
This patch sets the second point trimming value according to the platform data if the register value is 0. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 13 + 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index a4dbc84..af0e6ca 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -180,10 +180,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev) data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) & EXYNOS_TMU_TEMP_MASK); - if ((pdata->min_efuse_value > data->temp_error1) || - (data->temp_error1 > pdata->max_efuse_value) || - (data->temp_error2 != 0)) - data->temp_error1 = pdata->efuse_value; + if (!data->temp_error1 || + (pdata->min_efuse_value > data->temp_error1) || + (data->temp_error1 > pdata->max_efuse_value)) + data->temp_error1 = pdata->efuse_value & EXYNOS_TMU_TEMP_MASK; + + if (!data->temp_error2) + data->temp_error2 = + (pdata->efuse_value >> reg->triminfo_85_shift) & + EXYNOS_TMU_TEMP_MASK; if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) { dev_err(&pdev->dev, "Invalid max trigger level\n"); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 13/30] thermal: exynos: Add support for instance based register/unregister
This code modifies the thermal driver to have multiple thermal zone support by replacing the global thermal zone variable with device data member of thermal_zone_device. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c | 36 ++ drivers/thermal/samsung/exynos_thermal_common.h |9 +++-- drivers/thermal/samsung/exynos_tmu.c| 15 + 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index dd49c9f..2af1e3b 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -36,12 +36,11 @@ struct exynos_thermal_zone { bool bind; }; -static struct exynos_thermal_zone *th_zone; - /* 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; @@ -51,25 +50,26 @@ static int exynos_get_mode(struct thermal_zone_device *thermal, static int exynos_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { - if (!th_zone->therm_dev) { + struct exynos_thermal_zone *th_zone = thermal->devdata; + if (!th_zone) { pr_notice("thermal zone not registered\n"); return 0; } - mutex_lock(&th_zone->therm_dev->lock); + mutex_lock(&thermal->lock); if (mode == THERMAL_DEVICE_ENABLED && !th_zone->sensor_conf->trip_data.trigger_falling) - th_zone->therm_dev->polling_delay = IDLE_INTERVAL; + thermal->polling_delay = IDLE_INTERVAL; else - th_zone->therm_dev->polling_delay = 0; + thermal->polling_delay = 0; - mutex_unlock(&th_zone->therm_dev->lock); + mutex_unlock(&thermal->lock); th_zone->mode = mode; - thermal_zone_device_update(th_zone->therm_dev); + thermal_zone_device_update(thermal); pr_info("thermal polling set for duration=%d msec\n", - th_zone->therm_dev->polling_delay); + thermal->polling_delay); return 0; } @@ -96,6 +96,8 @@ static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal->devdata; + if (trip < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) return -EINVAL; @@ -122,6 +124,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, { 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; tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data; @@ -168,6 +171,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { int ret = 0, i, tab_size; + struct exynos_thermal_zone *th_zone = thermal->devdata; struct thermal_sensor_conf *data = th_zone->sensor_conf; if (th_zone->bind == false) @@ -210,6 +214,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, 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) { @@ -229,6 +234,7 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal, { void *data; int ret = -EINVAL; + struct exynos_thermal_zone *th_zone = thermal->devdata; if (!th_zone->sensor_conf) { pr_info("Temperature sensor not initialised\n"); @@ -276,11 +282,12 @@ static struct thermal_zone_device_ops const exynos_dev_ops = { * This function may be called from interrupt based temperature sensor * when threshold is changed. */ -void exynos_report_trigger(void) +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 = conf->pzone_data; if (!th_zone || !th_zone->therm_dev) return; @@ -321,6 +328,7 @@ int exynos_register_therma
[PATCH V6 23/30] thermal: exynos: Add driver support for exynos5440 TMU sensor
This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Jungseok Lee Signed-off-by: Amit Daniel Kachhap --- .../devicetree/bindings/thermal/exynos-thermal.txt | 24 - drivers/thermal/samsung/exynos_thermal_common.h|2 +- drivers/thermal/samsung/exynos_tmu.c | 54 +--- drivers/thermal/samsung/exynos_tmu.h |6 ++ drivers/thermal/samsung/exynos_tmu_data.h | 36 + 5 files changed, 112 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt index 0ea33f7..e6386ea 100644 --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt @@ -6,6 +6,7 @@ "samsung,exynos4412-tmu" "samsung,exynos4210-tmu" "samsung,exynos5250-tmu" + "samsung,exynos5440-tmu" - interrupt-parent : The phandle for the interrupt controller - reg : Address range of the thermal registers. For soc's which has multiple instances of TMU and some registers are shared across all TMU's like @@ -16,7 +17,7 @@ - clocks : The main clock for TMU device - clock-names : Thermal system clock name -Example: +Example 1): tmu@100C { compatible = "samsung,exynos4412-tmu"; @@ -27,3 +28,24 @@ Example: clock-names = "tmu_apbif"; status = "disabled"; }; + +Example 2): + + tmuctrl_0: tmuctrl@160118 { + compatible = "samsung,exynos5440-tmu"; + reg = <0x160118 0x230>, <0x160368 0x10>; + interrupts = <0 58 0>; + clocks = <&clock 21>; + clock-names = "tmu_apbif"; + }; + +Note: For multi-instance tmu each instance should have an alias correctly +numbered in "aliases" node. + +Example: + +aliases { + tmuctrl0 = &tmuctrl_0; + tmuctrl1 = &tmuctrl_1; + tmuctrl2 = &tmuctrl_2; +}; diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index 0c189d6..7d7c29a 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h @@ -27,7 +27,7 @@ #define SENSOR_NAME_LEN16 #define MAX_TRIP_COUNT 8 #define MAX_COOLING_DEVICE 4 -#define MAX_THRESHOLD_LEVS 4 +#define MAX_THRESHOLD_LEVS 5 #define ACTIVE_INTERVAL 500 #define IDLE_INTERVAL 1 diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 150a869..db4035d 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device *pdev) __raw_writel(1, data->base + reg->triminfo_ctrl); /* Save trimming info in order to perform calibration */ - trim_info = readl(data->base + reg->triminfo_data); + if (data->soc == SOC_ARCH_EXYNOS5440) { + /* +* For exynos5440 soc triminfo value is swapped between TMU0 and +* TMU2, so the below logic is needed. +*/ + switch (data->id) { + case 0: + trim_info = readl(data->base + + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); + break; + case 1: + trim_info = readl(data->base + reg->triminfo_data); + break; + case 2: + trim_info = readl(data->base - + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); + } + } else { + trim_info = readl(data->base + reg->triminfo_data); + } data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK; data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) & EXYNOS_TMU_TEMP_MASK); @@ -201,7 +220,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) reg->threshold_th0 + i * sizeof(reg->threshold_th0)); writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); - } else if (data->soc == SOC_ARCH_EXYNOS) { + } else if (data->soc == SOC_ARCH_EXYNOS || +
[PATCH V6 16/30] thermal: exynos: Make the zone handling use trip information
This code simplifies the zone handling to use the trip information passed by the TMU driver and not the hardcoded macros. This also helps in adding more zone support. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c | 61 +-- drivers/thermal/samsung/exynos_thermal_common.h |3 +- drivers/thermal/samsung/exynos_tmu.c|5 ++- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index 86d39aa..2873ca3 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -78,17 +78,22 @@ static int exynos_set_mode(struct thermal_zone_device *thermal, static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, enum thermal_trip_type *type) { - switch (GET_ZONE(trip)) { - case MONITOR_ZONE: - case WARN_ZONE: - *type = THERMAL_TRIP_ACTIVE; - break; - case PANIC_ZONE: - *type = THERMAL_TRIP_CRITICAL; - break; - default: + 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; + return 0; } @@ -97,8 +102,9 @@ 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 < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) + if (trip < 0 || trip >= max_trip) return -EINVAL; *temp = th_zone->sensor_conf->trip_data.trip_val[trip]; @@ -112,10 +118,10 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, static int exynos_get_crit_temp(struct thermal_zone_device *thermal, unsigned long *temp) { - int ret; - /* Panic zone */ - ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp); - return ret; + 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 */ @@ -340,19 +346,22 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) return -ENOMEM; th_zone->sensor_conf = sensor_conf; - cpumask_set_cpu(0, &mask_val); - th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); - if (IS_ERR(th_zone->cool_dev[0])) { - pr_err("Failed to register cpufreq cooling device\n"); - ret = -EINVAL; - goto err_unregister; + if (sensor_conf->cooling_data.freq_clip_count > 0) { + cpumask_set_cpu(0, &mask_val); + th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); + if (IS_ERR(th_zone->cool_dev[0])) { + pr_err("Failed to register cpufreq cooling device\n"); + ret = -EINVAL; + goto err_unregister; + } + th_zone->cool_dev_size++; } - th_zone->cool_dev_size++; - th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, - EXYNOS_ZONE_COUNT, 0, th_zone, &exynos_dev_ops, NULL, 0, - sensor_conf->trip_data.trigger_falling ? - 0 : IDLE_INTERVAL); + 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)) { pr_err("Failed to register thermal zone device\n"); diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index 1e9a326..dd0077e 100644 --- a/drivers/thermal/samsun
[PATCH V6 10/30] thermal: exynos: Move register definitions from driver to data file
This patch migrates the TMU register definition/bitfields to data file. This is needed to support SoC's which use the same TMU controller but register validity, offsets or bitfield may slightly vary across SOC's. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 172 +--- drivers/thermal/samsung/exynos_tmu.h | 133 ++ drivers/thermal/samsung/exynos_tmu_data.c | 59 ++ drivers/thermal/samsung/exynos_tmu_data.h | 68 +++ 4 files changed, 315 insertions(+), 117 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 401ec98..6fd776f 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -32,76 +32,6 @@ #include "exynos_tmu.h" #include "exynos_tmu_data.h" -/* Exynos generic registers */ -#define EXYNOS_TMU_REG_TRIMINFO0x0 -#define EXYNOS_TMU_REG_CONTROL 0x20 -#define EXYNOS_TMU_REG_STATUS 0x28 -#define EXYNOS_TMU_REG_CURRENT_TEMP0x40 -#define EXYNOS_TMU_REG_INTEN 0x70 -#define EXYNOS_TMU_REG_INTSTAT 0x74 -#define EXYNOS_TMU_REG_INTCLEAR0x78 - -#define EXYNOS_TMU_TRIM_TEMP_MASK 0xff -#define EXYNOS_TMU_GAIN_SHIFT 8 -#define EXYNOS_TMU_GAIN_MASK 0xf -#define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 -#define EXYNOS_TMU_REF_VOLTAGE_MASK0x1f -#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf -#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 -#define EXYNOS_TMU_CORE_EN_SHIFT 0 - -/* Exynos4210 specific registers */ -#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL1 0x54 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL2 0x58 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL3 0x5C -#define EXYNOS4210_TMU_REG_PAST_TEMP0 0x60 -#define EXYNOS4210_TMU_REG_PAST_TEMP1 0x64 -#define EXYNOS4210_TMU_REG_PAST_TEMP2 0x68 -#define EXYNOS4210_TMU_REG_PAST_TEMP3 0x6C - -#define EXYNOS4210_TMU_TRIG_LEVEL0_MASK0x1 -#define EXYNOS4210_TMU_TRIG_LEVEL1_MASK0x10 -#define EXYNOS4210_TMU_TRIG_LEVEL2_MASK0x100 -#define EXYNOS4210_TMU_TRIG_LEVEL3_MASK0x1000 -#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x -#define EXYNOS4210_TMU_INTCLEAR_VAL0x - -/* Exynos5250 and Exynos4412 specific registers */ -#define EXYNOS_TMU_TRIMINFO_CON0x14 -#define EXYNOS_THD_TEMP_RISE 0x50 -#define EXYNOS_THD_TEMP_FALL 0x54 -#define EXYNOS_EMUL_CON0x80 - -#define EXYNOS_TRIMINFO_RELOAD 0x1 -#define EXYNOS_TRIMINFO_SHIFT 0x0 -#define EXYNOS_TMU_RISE_INT_MASK 0x111 -#define EXYNOS_TMU_RISE_INT_SHIFT 0 -#define EXYNOS_TMU_FALL_INT_MASK 0x111 -#define EXYNOS_TMU_FALL_INT_SHIFT 12 -#define EXYNOS_TMU_CLEAR_RISE_INT 0x111 -#define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) -#define EXYNOS_TMU_TRIP_MODE_SHIFT 13 -#define EXYNOS_TMU_TRIP_MODE_MASK 0x7 - -#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 -#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 -#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 -#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 -#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 -#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 -#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 - -#ifdef CONFIG_THERMAL_EMULATION -#define EXYNOS_EMUL_TIME 0x57F0 -#define EXYNOS_EMUL_TIME_MASK 0x -#define EXYNOS_EMUL_TIME_SHIFT 16 -#define EXYNOS_EMUL_DATA_SHIFT 8 -#define EXYNOS_EMUL_DATA_MASK 0xFF -#define EXYNOS_EMUL_ENABLE 0x1 -#endif /* CONFIG_THERMAL_EMULATION */ - struct exynos_tmu_data { struct exynos_tmu_platform_data *pdata; struct resource *mem; @@ -186,6 +116,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_platform_data *pdata = data->pdata; + const struct exynos_tmu_registers *reg = pdata->registers; unsigned int status, trim_info; unsigned int rising_threshold = 0, falling_threshold = 0; int ret = 0, threshold_code, i, trigger_levs = 0; @@ -193,20 +124,20 @@ static int exynos_tmu_initialize(struct platform_device *pdev) mutex_lock(&data->lock); clk_enable(data->clk); - status = readb(data->base + EXYNOS_TMU_REG_STATUS); + status = readb(data->base + reg->tmu_status); if (!status) { ret = -EBUSY; goto out; } - if (data->soc == SOC_ARCH_EXYNOS) { - __raw_writel(EXYNOS_TRIMINFO_RELOAD, - data->base + EXYNOS_TMU_TRIMINFO_CON); - } + if (data->soc == SOC_ARCH_EXYNOS) + __raw_writel(1, data->base + reg->triminfo_ctrl); + /* Save trimming info in order to perform c
[PATCH V6 20/30] thermal: exynos: use device resource management infrastructure
This patch uses the device pointer stored in the configuration structure and converts to dev_* prints and devm API's. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c | 39 ++ 1 files changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index 2873ca3..59b47e3 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -52,7 +52,8 @@ static int exynos_set_mode(struct thermal_zone_device *thermal, { struct exynos_thermal_zone *th_zone = thermal->devdata; if (!th_zone) { - pr_notice("thermal zone not registered\n"); + dev_err(th_zone->sensor_conf->dev, + "thermal zone not registered\n"); return 0; } @@ -68,8 +69,9 @@ static int exynos_set_mode(struct thermal_zone_device *thermal, th_zone->mode = mode; thermal_zone_device_update(thermal); - pr_info("thermal polling set for duration=%d msec\n", - thermal->polling_delay); + dev_dbg(th_zone->sensor_conf->dev, + "thermal polling set for duration=%d msec\n", + thermal->polling_delay); return 0; } @@ -159,7 +161,8 @@ static int exynos_bind(struct thermal_zone_device *thermal, case WARN_ZONE: if (thermal_zone_bind_cooling_device(thermal, i, cdev, level, 0)) { - pr_err("error binding cdev inst %d\n", i); + dev_err(data->dev, + "error unbinding cdev inst=%d\n", i); ret = -EINVAL; } th_zone->bind = true; @@ -204,7 +207,8 @@ static int exynos_unbind(struct thermal_zone_device *thermal, case WARN_ZONE: if (thermal_zone_unbind_cooling_device(thermal, i, cdev)) { - pr_err("error unbinding cdev inst=%d\n", i); + dev_err(data->dev, + "error unbinding cdev inst=%d\n", i); ret = -EINVAL; } th_zone->bind = false; @@ -224,7 +228,8 @@ static int exynos_get_temp(struct thermal_zone_device *thermal, void *data; if (!th_zone->sensor_conf) { - pr_info("Temperature sensor not initialised\n"); + dev_err(th_zone->sensor_conf->dev, + "Temperature sensor not initialised\n"); return -EINVAL; } data = th_zone->sensor_conf->driver_data; @@ -243,7 +248,8 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal, struct exynos_thermal_zone *th_zone = thermal->devdata; if (!th_zone->sensor_conf) { - pr_info("Temperature sensor not initialised\n"); + dev_err(th_zone->sensor_conf->dev, + "Temperature sensor not initialised\n"); return -EINVAL; } data = th_zone->sensor_conf->driver_data; @@ -337,11 +343,13 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) struct exynos_thermal_zone *th_zone; if (!sensor_conf || !sensor_conf->read_temperature) { - pr_err("Temperature sensor not initialised\n"); + dev_err(sensor_conf->dev, + "Temperature sensor not initialised\n"); return -EINVAL; } - th_zone = kzalloc(sizeof(struct exynos_thermal_zone), GFP_KERNEL); + th_zone = devm_kzalloc(sensor_conf->dev, + sizeof(struct exynos_thermal_zone), GFP_KERNEL); if (!th_zone) return -ENOMEM; @@ -350,7 +358,8 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) cpumask_set_cpu(0, &mask_val); th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); if (IS_ERR(th_zone->cool_dev[0])) { - pr_err("Failed to register cpufreq cooling device\n"); + dev_err(sensor_conf->dev, + "Failed to register cpufreq cooling device\n"); ret = -EINVAL; goto err_unregister
[PATCH V6 11/30] thermal: exynos: Support thermal tripping
TMU urgently sends active-high signal (thermal trip) to PMU, and thermal tripping by hardware logic. Thermal tripping means that PMU cuts off the whole power of SoC by controlling external voltage regulator. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Jonghwan Choi Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 45 +--- drivers/thermal/samsung/exynos_tmu_data.c |2 + drivers/thermal/samsung/exynos_tmu_data.h |2 + 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 6fd776f..33f494e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -117,7 +117,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_platform_data *pdata = data->pdata; const struct exynos_tmu_registers *reg = pdata->registers; - unsigned int status, trim_info; + unsigned int status, trim_info = 0, con; unsigned int rising_threshold = 0, falling_threshold = 0; int ret = 0, threshold_code, i, trigger_levs = 0; @@ -144,10 +144,26 @@ static int exynos_tmu_initialize(struct platform_device *pdev) (data->temp_error2 != 0)) data->temp_error1 = pdata->efuse_value; - /* Count trigger levels to be enabled */ - for (i = 0; i < MAX_THRESHOLD_LEVS; i++) - if (pdata->trigger_levels[i]) + if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) { + dev_err(&pdev->dev, "Invalid max trigger level\n"); + goto out; + } + + for (i = 0; i < pdata->max_trigger_level; i++) { + if (!pdata->trigger_levels[i]) + continue; + + if ((pdata->trigger_type[i] == HW_TRIP) && + (!pdata->trigger_levels[pdata->max_trigger_level - 1])) { + dev_err(&pdev->dev, "Invalid hw trigger level\n"); + ret = -EINVAL; + goto out; + } + + /* Count trigger levels except the HW trip*/ + if (!(pdata->trigger_type[i] == HW_TRIP)) trigger_levs++; + } if (data->soc == SOC_ARCH_EXYNOS4210) { /* Write temperature code for threshold */ @@ -165,7 +181,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); } else if (data->soc == SOC_ARCH_EXYNOS) { /* Write temperature code for rising and falling threshold */ - for (i = 0; i < trigger_levs; i++) { + for (i = 0; + i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) { threshold_code = temp_to_code(data, pdata->trigger_levels[i]); if (threshold_code < 0) { @@ -191,6 +208,24 @@ static int exynos_tmu_initialize(struct platform_device *pdev) writel((reg->inten_rise_mask << reg->inten_rise_shift) | (reg->inten_fall_mask << reg->inten_fall_shift), data->base + reg->tmu_intclear); + + /* 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 (threshold_code < 0) { + ret = threshold_code; + goto out; + } + rising_threshold |= threshold_code << 8 * i; + writel(rising_threshold, + data->base + reg->threshold_th0); + con = readl(data->base + reg->tmu_ctrl); + con |= (1 << reg->therm_trip_en_shift); + writel(con, data->base + reg->tmu_ctrl); + } } out: clk_disable(data->clk); diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index 589a519..e7cb1cc 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c @@ -123,6 +123,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = { .trigger_levels[0] = 85, .trigger_levels[1] = 103
[PATCH V6 27/30] Documentation: thermal: Explain the exynos thermal driver model
This patch updates the documentation to explain the driver model and file layout. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- Documentation/thermal/exynos_thermal | 43 ++--- 1 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Documentation/thermal/exynos_thermal b/Documentation/thermal/exynos_thermal index 2b46f67..9010c44 100644 --- a/Documentation/thermal/exynos_thermal +++ b/Documentation/thermal/exynos_thermal @@ -1,17 +1,17 @@ -Kernel driver exynos4_tmu +Kernel driver exynos_tmu = Supported chips: -* ARM SAMSUNG EXYNOS4 series of SoC - Prefix: 'exynos4-tmu' +* ARM SAMSUNG EXYNOS4, EXYNOS5 series of SoC Datasheet: Not publicly available Authors: Donggeun Kim +Authors: Amit Daniel -Description +TMU controller Description: +--- -This driver allows to read temperature inside SAMSUNG EXYNOS4 series of SoC. +This driver allows to read temperature inside SAMSUNG EXYNOS4/5 series of SoC. The chip only exposes the measured 8-bit temperature code value through a register. @@ -34,9 +34,9 @@ The three equations are: TI2: Trimming info for 85 degree Celsius (stored at TRIMINFO register) Temperature code measured at 85 degree Celsius which is unchanged -TMU(Thermal Management Unit) in EXYNOS4 generates interrupt +TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt when temperature exceeds pre-defined levels. -The maximum number of configurable threshold is four. +The maximum number of configurable threshold is five. The threshold levels are defined as follows: Level_0: current temperature > trigger_level_0 + threshold Level_1: current temperature > trigger_level_1 + threshold @@ -47,6 +47,31 @@ The threshold levels are defined as follows: through the corresponding registers. When an interrupt occurs, this driver notify kernel thermal framework -with the function exynos4_report_trigger. +with the function exynos_report_trigger. Although an interrupt condition for level_0 can be set, it can be used to synchronize the cooling action. + +TMU driver description: +--- + +The exynos thermal driver is structured as, + + Kernel Core thermal framework + (thermal_core.c, step_wise.c, cpu_cooling.c) + ^ + | + | +TMU configuration data ---> TMU Driver <--> Exynos Core thermal wrapper +(exynos_tmu_data.c) (exynos_tmu.c) (exynos_thermal_common.c) +(exynos_tmu_data.h) (exynos_tmu.h) (exynos_thermal_common.h) + +a) TMU configuration data: This consist of TMU register offsets/bitfields + described through structure exynos_tmu_registers. Also several + other platform data (struct exynos_tmu_platform_data) members + are used to configure the TMU. +b) TMU driver: This component initialises the TMU controller and sets different + thresholds. It invokes core thermal implementation with the call + exynos_report_trigger. +c) Exynos Core thermal wrapper: This provides 3 wrapper function to use the + Kernel core thermal framework. They are exynos_unregister_thermal, + exynos_register_thermal and exynos_report_trigger. -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 28/30] thermal: exynos: Support for TMU regulator defined at device tree
TMU probe function now checks for a device tree defined regulator. For compatibility reasons it is allowed to probe driver even without this regulator defined. Acked-by: Jonghwa Lee Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Signed-off-by: Amit Daniel Kachhap --- .../devicetree/bindings/thermal/exynos-thermal.txt |4 +++ drivers/thermal/samsung/exynos_tmu.c | 23 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt index e6386ea..284f530 100644 --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt @@ -16,6 +16,9 @@ - interrupts : Should contain interrupt for thermal system - clocks : The main clock for TMU device - clock-names : Thermal system clock name +- 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. Example 1): @@ -27,6 +30,7 @@ Example 1): clocks = <&clock 383>; clock-names = "tmu_apbif"; status = "disabled"; + vtmu-supply = <&tmu_regulator_node>; }; Example 2): diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 7a259f4..441efd5 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "exynos_thermal_common.h" #include "exynos_tmu.h" @@ -48,6 +49,7 @@ * @clk: pointer to the clock structure. * @temp_error1: fused value of the first point trim. * @temp_error2: fused value of the second point trim. + * @regulator: pointer to the TMU regulator structure. * @reg_conf: pointer to structure to register with core thermal. */ struct exynos_tmu_data { @@ -61,6 +63,7 @@ struct exynos_tmu_data { struct mutex lock; struct clk *clk; u8 temp_error1, temp_error2; + struct regulator *regulator; struct thermal_sensor_conf *reg_conf; }; @@ -510,10 +513,27 @@ static int exynos_map_dt_data(struct platform_device *pdev) struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_platform_data *pdata; struct resource res; + int ret; if (!data) return -ENODEV; + /* +* Try enabling the regulator if found +* TODO: Add regulator as an SOC feature, so that regulator enable +* is a compulsory call. +*/ + data->regulator = devm_regulator_get(&pdev->dev, "vtmu"); + if (!IS_ERR(data->regulator)) { + ret = regulator_enable(data->regulator); + if (ret) { + dev_err(&pdev->dev, "failed to enable vtmu\n"); + return ret; + } + } else { + dev_info(&pdev->dev, "Regulator node (vtmu) not found\n"); + } + data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl"); if (data->id < 0) data->id = 0; @@ -680,6 +700,9 @@ static int exynos_tmu_remove(struct platform_device *pdev) clk_unprepare(data->clk); + if (!IS_ERR(data->regulator)) + regulator_disable(data->regulator); + return 0; } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 29/30] ARM: dts: Add device tree node for exynos5440 TMU controller
This patch adds device node for TMU controller. There are 3 instances of the controllers so 3 nodes are created. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- arch/arm/boot/dts/exynos5440.dtsi | 30 ++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi index f6b1c89..716e90c 100644 --- a/arch/arm/boot/dts/exynos5440.dtsi +++ b/arch/arm/boot/dts/exynos5440.dtsi @@ -16,6 +16,12 @@ interrupt-parent = <&gic>; + aliases { + tmuctrl0 = &tmuctrl_0; + tmuctrl1 = &tmuctrl_1; + tmuctrl2 = &tmuctrl_2; + }; + clock: clock-controller@0x16 { compatible = "samsung,exynos5440-clock"; reg = <0x16 0x1000>; @@ -216,4 +222,28 @@ clock-names = "rtc"; status = "disabled"; }; + + tmuctrl_0: tmuctrl@160118 { + compatible = "samsung,exynos5440-tmu"; + reg = <0x160118 0x230>, <0x160368 0x10>; + interrupts = <0 58 0>; + clocks = <&clock 21>; + clock-names = "tmu_apbif"; + }; + + tmuctrl_1: tmuctrl@16011C { + compatible = "samsung,exynos5440-tmu"; + reg = <0x16011C 0x230>, <0x160368 0x10>; + interrupts = <0 58 0>; + clocks = <&clock 21>; + clock-names = "tmu_apbif"; + }; + + tmuctrl_2: tmuctrl@160120 { + compatible = "samsung,exynos5440-tmu"; + reg = <0x160120 0x230>, <0x160368 0x10>; + interrupts = <0 58 0>; + clocks = <&clock 21>; + clock-names = "tmu_apbif"; + }; }; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 30/30] arm: exynos: enable ARCH_HAS_BANDGAP
This patch enables ARCH_HAS_BANDGAP config for exynos4210, 4212, 4412, 5250 and 5440 SOC. This config symbol is recently added to allow the platforms to enable bandgap based temperature sensor. Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- arch/arm/mach-exynos/Kconfig |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index d19edff..d3cb5c7 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -33,6 +33,7 @@ config CPU_EXYNOS4210 bool "SAMSUNG EXYNOS4210" default y depends on ARCH_EXYNOS4 + select ARCH_HAS_BANDGAP select ARM_CPU_SUSPEND if PM select PM_GENERIC_DOMAINS select S5P_PM if PM @@ -45,6 +46,7 @@ config SOC_EXYNOS4212 bool "SAMSUNG EXYNOS4212" default y depends on ARCH_EXYNOS4 + select ARCH_HAS_BANDGAP select S5P_PM if PM select S5P_SLEEP if PM select SAMSUNG_DMADEV @@ -55,6 +57,7 @@ config SOC_EXYNOS4412 bool "SAMSUNG EXYNOS4412" default y depends on ARCH_EXYNOS4 + select ARCH_HAS_BANDGAP select SAMSUNG_DMADEV help Enable EXYNOS4412 SoC support @@ -63,6 +66,7 @@ config SOC_EXYNOS5250 bool "SAMSUNG EXYNOS5250" default y depends on ARCH_EXYNOS5 + select ARCH_HAS_BANDGAP select PM_GENERIC_DOMAINS if PM select S5P_PM if PM select S5P_SLEEP if PM @@ -76,6 +80,7 @@ config SOC_EXYNOS5440 default y depends on ARCH_EXYNOS5 select ARCH_HAS_OPP + select ARCH_HAS_BANDGAP select ARM_ARCH_TIMER select AUTO_ZRELADDR select PINCTRL -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 22/30] thermal: exynos: Add support to access common register for multistance
This patch adds support to parse one more common set of TMU register. First set of register belongs to each instance of TMU and second set belongs to common TMU registers. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- .../devicetree/bindings/thermal/exynos-thermal.txt |6 +- drivers/thermal/samsung/exynos_tmu.c | 20 2 files changed, 25 insertions(+), 1 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt index 535fd0e..0ea33f7 100644 --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt @@ -7,7 +7,11 @@ "samsung,exynos4210-tmu" "samsung,exynos5250-tmu" - interrupt-parent : The phandle for the interrupt controller -- reg : Address range of the thermal registers +- reg : Address range of the thermal registers. For soc's which has multiple + instances of TMU and some registers are shared across all TMU's like + interrupt related then 2 set of register has to supplied. First set + belongs to each instance of TMU and second set belongs to common TMU + registers. - interrupts : Should contain interrupt for thermal system - clocks : The main clock for TMU device - clock-names : Thermal system clock name diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 877dab8..150a869 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -40,6 +40,7 @@ * @id: identifier of the one instance of the TMU controller. * @pdata: pointer to the tmu platform/configuration data * @base: base address of the single instance of the TMU controller. + * @base_common: base address of the common registers of the TMU controller. * @irq: irq number of the TMU controller. * @soc: id of the SOC type. * @irq_work: pointer to the irq work structure. @@ -53,6 +54,7 @@ struct exynos_tmu_data { int id; struct exynos_tmu_platform_data *pdata; void __iomem *base; + void __iomem *base_common; int irq; enum soc_type soc; struct work_struct irq_work; @@ -478,6 +480,24 @@ static int exynos_map_dt_data(struct platform_device *pdev) return -ENODEV; } data->pdata = pdata; + /* +* Check if the TMU shares some registers and then try to map the +* memory of common registers. +*/ + if (!TMU_SUPPORTS(pdata, SHARED_MEMORY)) + return 0; + + if (of_address_to_resource(pdev->dev.of_node, 1, &res)) { + dev_err(&pdev->dev, "failed to get Resource 1\n"); + return -ENODEV; + } + + data->base_common = devm_ioremap(&pdev->dev, res.start, + resource_size(&res)); + if (!data->base) { + dev_err(&pdev->dev, "Failed to ioremap memory\n"); + return -ENOMEM; + } return 0; } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 24/30] thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor
This patch adds configuration data for exynos5440 soc. Also register definations for the controller are added. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c |4 ++ drivers/thermal/samsung/exynos_tmu_data.c | 71 + drivers/thermal/samsung/exynos_tmu_data.h |7 +++ 3 files changed, 82 insertions(+), 0 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index db4035d..a4dbc84 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -455,6 +455,10 @@ static const struct of_device_id exynos_tmu_match[] = { .compatible = "samsung,exynos5250-tmu", .data = (void *)EXYNOS5250_TMU_DRV_DATA, }, + { + .compatible = "samsung,exynos5440-tmu", + .data = (void *)EXYNOS5440_TMU_DRV_DATA, + }, {}, }; MODULE_DEVICE_TABLE(of, exynos_tmu_match); diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index 694557e..b34e726 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c @@ -175,3 +175,74 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = { .tmu_count = 1, }; #endif + +#if defined(CONFIG_SOC_EXYNOS5440) +static const struct exynos_tmu_registers exynos5440_tmu_registers = { + .triminfo_data = EXYNOS5440_TMU_S0_7_TRIM, + .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, + .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, + .tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL, + .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT, + .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK, + .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, + .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, + .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, + .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT, + .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK, + .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT, + .tmu_status = EXYNOS5440_TMU_S0_7_STATUS, + .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP, + .threshold_th0 = EXYNOS5440_TMU_S0_7_TH0, + .threshold_th1 = EXYNOS5440_TMU_S0_7_TH1, + .threshold_th2 = EXYNOS5440_TMU_S0_7_TH2, + .threshold_th3_l0_shift = EXYNOS5440_TMU_TH_RISE4_SHIFT, + .tmu_inten = EXYNOS5440_TMU_S0_7_IRQEN, + .inten_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK, + .inten_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT, + .inten_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK, + .inten_fall_shift = EXYNOS5440_TMU_FALL_INT_SHIFT, + .inten_rise0_shift = EXYNOS5440_TMU_INTEN_RISE0_SHIFT, + .inten_rise1_shift = EXYNOS5440_TMU_INTEN_RISE1_SHIFT, + .inten_rise2_shift = EXYNOS5440_TMU_INTEN_RISE2_SHIFT, + .inten_rise3_shift = EXYNOS5440_TMU_INTEN_RISE3_SHIFT, + .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT, + .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, + .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, + .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS, + .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, + .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, + .tmu_pmin = EXYNOS5440_TMU_PMIN, +}; + +#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, \ + .gain = 5, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .cal_mode = 0, \ + .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, \ + .registers = &exynos5440_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \ + TMU_SUPPORT_MULTI_INST | TMU_SUPPORT_SHARED_MEMORY), + +struct exynos_tmu_init_data const exynos5440_default_tmu_data = { + .tmu_data = { + { EXYNOS5440_TMU_DATA } , + { EXYNOS5440_TMU_DATA } , + { EXYNOS5440_TMU_DATA } , + }, + .tmu_count = 3, +}; +#endif diff --git a/drivers/thermal/samsung/exynos_tmu_data.h b/drivers/thermal/samsung/exynos_tmu_data.h index ad263e9..43ce5fb 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.h +++ b/drivers/thermal/samsung/exynos_tmu_data.h @@ -143,4 +143,11 @@ extern struct exynos_tmu_init_data const exynos5250_default_tmu_data; #define EXYNOS5250_TMU_DRV_DATA (NULL) #endif +#if defined(CONFIG_SOC_EXYNOS5440) +extern struct exynos_tmu_init_data const exynos5440_de
[PATCH V6 26/30] thermal: exynos: Add hardware mode thermal calibration support
This patch adds support for h/w mode calibration in the TMU controller. soc's like 5440 support this features. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 15 +++ drivers/thermal/samsung/exynos_tmu.h |6 ++ drivers/thermal/samsung/exynos_tmu_data.c |2 ++ drivers/thermal/samsung/exynos_tmu_data.h |2 ++ 4 files changed, 25 insertions(+), 0 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index af0e6ca..7a259f4 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -73,6 +73,9 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp) struct exynos_tmu_platform_data *pdata = data->pdata; int temp_code; + if (pdata->cal_mode == HW_MODE) + return temp; + if (data->soc == SOC_ARCH_EXYNOS4210) /* temp should range between 25 and 125 */ if (temp < 25 || temp > 125) { @@ -107,6 +110,9 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code) struct exynos_tmu_platform_data *pdata = data->pdata; int temp; + if (pdata->cal_mode == HW_MODE) + return temp_code; + if (data->soc == SOC_ARCH_EXYNOS4210) /* temp_code should range between 75 and 175 */ if (temp_code < 75 || temp_code > 175) { @@ -155,6 +161,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev) if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) __raw_writel(1, data->base + reg->triminfo_ctrl); + if (pdata->cal_mode == HW_MODE) + goto skip_calib_data; + /* Save trimming info in order to perform calibration */ if (data->soc == SOC_ARCH_EXYNOS5440) { /* @@ -190,6 +199,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) (pdata->efuse_value >> reg->triminfo_85_shift) & EXYNOS_TMU_TEMP_MASK; +skip_calib_data: if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) { dev_err(&pdev->dev, "Invalid max trigger level\n"); goto out; @@ -319,6 +329,11 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift); } + if (pdata->cal_mode == HW_MODE) { + con &= ~(reg->calib_mode_mask << reg->calib_mode_shift); + con |= pdata->cal_type << reg->calib_mode_shift; + } + if (on) { con |= (1 << reg->core_en_shift); interrupt_en = diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h index 73aaed7..abfa1eb 100644 --- a/drivers/thermal/samsung/exynos_tmu.h +++ b/drivers/thermal/samsung/exynos_tmu.h @@ -88,6 +88,10 @@ enum soc_type { * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl register. * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register. + * @calib_mode_shift: shift bits of calibration mode value in tmu_ctrl + register. + * @calib_mode_mask: mask bits of calibration mode value in tmu_ctrl + register. * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in tmu_ctrl register. * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register. @@ -149,6 +153,8 @@ struct exynos_tmu_registers { u32 therm_trip_en_shift; u32 buf_slope_sel_shift; u32 buf_slope_sel_mask; + u32 calib_mode_shift; + u32 calib_mode_mask; u32 therm_trip_tq_en_shift; u32 core_en_shift; diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index b34e726..47c5d6b 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c @@ -189,6 +189,8 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = { .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT, .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK, + .calib_mode_shift = EXYNOS_TMU_CALIB_MODE_SHIFT, + .calib_mode_mask = EXYNOS_TMU_CALIB_MODE_MASK, .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT, .tmu_status = EXYNOS5440_TMU_S0_7_STATUS, .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP, diff --git a/drivers/thermal/samsung/exynos_tmu_data.h b/drivers/thermal/samsung/exynos_tmu_data.h index 43ce5fb..dc7feb5 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.h +++ b/drivers/thermal/samsung/exynos_tmu_data.h @@ -75,6 +75,8 @@
[PATCH V6 18/30] thermal: exynos: Add support to handle many instances of TMU
This patch adds support to handle multiple instances of the TMU controllers. This is done by removing the static structure to register with the core thermal and creating it dynamically for each instance of the TMU controller. The interrupt is made shared type to handle shared interrupts. Also the identifier of the TMU controller is extracted from device tree alias. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.h |1 + drivers/thermal/samsung/exynos_tmu.c| 147 --- drivers/thermal/samsung/exynos_tmu.h| 13 ++ drivers/thermal/samsung/exynos_tmu_data.c | 145 -- drivers/thermal/samsung/exynos_tmu_data.h |4 +- 5 files changed, 197 insertions(+), 113 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index dd0077e..0c189d6 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h @@ -84,6 +84,7 @@ struct thermal_sensor_conf { struct thermal_cooling_conf cooling_data; void *driver_data; void *pzone_data; + struct device *dev; }; /*Functions used exynos based thermal sensor driver*/ diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 4356118..1880c4e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -26,15 +26,32 @@ #include #include #include +#include +#include #include #include "exynos_thermal_common.h" #include "exynos_tmu.h" #include "exynos_tmu_data.h" +/** + * struct exynos_tmu_data : A structure to hold the private data of the TMU + driver + * @id: identifier of the one instance of the TMU controller. + * @pdata: pointer to the tmu platform/configuration data + * @base: base address of the single instance of the TMU controller. + * @irq: irq number of the TMU controller. + * @soc: id of the SOC type. + * @irq_work: pointer to the irq work structure. + * @lock: lock to implement synchronization. + * @clk: pointer to the clock structure. + * @temp_error1: fused value of the first point trim. + * @temp_error2: fused value of the second point trim. + * @reg_conf: pointer to structure to register with core thermal. + */ struct exynos_tmu_data { + int id; struct exynos_tmu_platform_data *pdata; - struct resource *mem; void __iomem *base; int irq; enum soc_type soc; @@ -42,6 +59,7 @@ struct exynos_tmu_data { struct mutex lock; struct clk *clk; u8 temp_error1, temp_error2; + struct thermal_sensor_conf *reg_conf; }; /* @@ -345,12 +363,6 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) { return -EINVAL; } #endif/*CONFIG_THERMAL_EMULATION*/ -static struct thermal_sensor_conf exynos_sensor_conf = { - .name = "exynos-therm", - .read_temperature = (int (*)(void *))exynos_tmu_read, - .write_emul_temp= exynos_tmu_set_emulation, -}; - static void exynos_tmu_work(struct work_struct *work) { struct exynos_tmu_data *data = container_of(work, @@ -359,7 +371,7 @@ static void exynos_tmu_work(struct work_struct *work) const struct exynos_tmu_registers *reg = pdata->registers; unsigned int val_irq; - exynos_report_trigger(&exynos_sensor_conf); + exynos_report_trigger(data->reg_conf); mutex_lock(&data->lock); clk_enable(data->clk); @@ -404,33 +416,73 @@ MODULE_DEVICE_TABLE(of, exynos_tmu_match); #endif static inline struct exynos_tmu_platform_data *exynos_get_driver_data( - struct platform_device *pdev) + struct platform_device *pdev, int id) { + struct exynos_tmu_init_data *data_table; + struct exynos_tmu_platform_data *tmu_data; #ifdef CONFIG_OF if (pdev->dev.of_node) { const struct of_device_id *match; match = of_match_node(exynos_tmu_match, pdev->dev.of_node); if (!match) return NULL; - return (struct exynos_tmu_platform_data *) match->data; + 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); } #endif return NULL; } -static int exynos_tmu_probe(struct platform_device *pdev) +static int exynos_map_dt_data(struct platform_device *pdev) { - struct exynos_tmu_data *data; - struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data;
[PATCH V6 19/30] thermal: exynos: Add TMU features to check instead of using SOC type
This patch adds several features supported by TMU as bitfields. This features varies across different SOC type and comparing the features present in the TMU is more logical than comparing the soc itself. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 26 +++- drivers/thermal/samsung/exynos_tmu.h | 31 + drivers/thermal/samsung/exynos_tmu_data.c |6 - 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 1880c4e..877dab8 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -142,13 +142,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev) mutex_lock(&data->lock); clk_enable(data->clk); - status = readb(data->base + reg->tmu_status); - if (!status) { - ret = -EBUSY; - goto out; + if (TMU_SUPPORTS(pdata, READY_STATUS)) { + status = readb(data->base + reg->tmu_status); + if (!status) { + ret = -EBUSY; + goto out; + } } - if (data->soc == SOC_ARCH_EXYNOS) + if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) __raw_writel(1, data->base + reg->triminfo_ctrl); /* Save trimming info in order to perform calibration */ @@ -287,7 +289,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) pdata->trigger_enable[2] << reg->inten_rise2_shift | pdata->trigger_enable[1] << reg->inten_rise1_shift | pdata->trigger_enable[0] << reg->inten_rise0_shift; - if (pdata->threshold_falling) + if (TMU_SUPPORTS(pdata, FALLING_TRIP)) interrupt_en |= interrupt_en << reg->inten_fall0_shift; } else { @@ -329,7 +331,7 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) unsigned int val; int ret = -EINVAL; - if (data->soc == SOC_ARCH_EXYNOS4210) + if (!TMU_SUPPORTS(pdata, EMULATION)) goto out; if (temp && temp < MCELSIUS) @@ -343,9 +345,13 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) if (temp) { temp /= MCELSIUS; - val = (EXYNOS_EMUL_TIME << reg->emul_time_shift) | - (temp_to_code(data, temp) -<< reg->emul_temp_shift) | EXYNOS_EMUL_ENABLE; + if (TMU_SUPPORTS(pdata, EMUL_TIME)) { + val &= ~(EXYNOS_EMUL_TIME_MASK << reg->emul_time_shift); + val |= (EXYNOS_EMUL_TIME << reg->emul_time_shift); + } + val &= ~(EXYNOS_EMUL_DATA_MASK << reg->emul_temp_shift); + val |= (temp_to_code(data, temp) << reg->emul_temp_shift) | + EXYNOS_EMUL_ENABLE; } else { val &= ~EXYNOS_EMUL_ENABLE; } diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h index b614407..6f55673 100644 --- a/drivers/thermal/samsung/exynos_tmu.h +++ b/drivers/thermal/samsung/exynos_tmu.h @@ -41,6 +41,34 @@ enum soc_type { }; /** + * EXYNOS TMU supported features. + * TMU_SUPPORT_EMULATION - This features is used to set user defined + * temperature to the TMU controller. + * TMU_SUPPORT_MULTI_INST - This features denotes that the soc + * has many instances of TMU. + * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can + * be reloaded. + * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can + * be registered for falling trips also. + * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current + * state(active/idle) can be checked. + * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation + * sample time. + * TMU_SUPPORT_SHARED_MEMORY - This feature tells that the different TMU + * sensors shares some common registers. + * TMU_SUPPORT - macro to compare the above features with the supplied. + */ +#define TMU_SUPPORT_EMULATION BIT(0) +#define TMU_SUPPORT_MULTI_INST BIT(1) +#define TMU_SUPPORT_TRIM_RELOADBIT(2) +#define TMU_SUPPORT_FALLING_TRIP BIT(3) +#define TMU_SUPPORT_READY_STATUS BIT(4) +#define TMU_SUPPORT_EMUL_TIME BIT(5) +#define TMU_SUPPORT_SHARED_MEMORY BIT(6) + +#define TMU_SUPPOR
[PATCH V6 21/30] ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal bindings
From: Lukasz Majewski Proper description for Exynos4 bindings added to Documentation/devicetree/ bindings Acked-by: Jonghwa Lee Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Signed-off-by: Amit Daniel Kachhap --- .../devicetree/bindings/thermal/exynos-thermal.txt | 25 1 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file mode 100644 index 000..535fd0e --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt @@ -0,0 +1,25 @@ +* Exynos Thermal Management Unit (TMU) + +** Required properties: + +- compatible : One of the following: + "samsung,exynos4412-tmu" + "samsung,exynos4210-tmu" + "samsung,exynos5250-tmu" +- interrupt-parent : The phandle for the interrupt controller +- reg : Address range of the thermal registers +- interrupts : Should contain interrupt for thermal system +- clocks : The main clock for TMU device +- clock-names : Thermal system clock name + +Example: + + tmu@100C { + compatible = "samsung,exynos4412-tmu"; + interrupt-parent = <&combiner>; + reg = <0x100C 0x100>; + interrupts = <2 4>; + clocks = <&clock 383>; + clock-names = "tmu_apbif"; + status = "disabled"; + }; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 17/30] thermal: exynos: Remove non DT based support
Recently non DT support from Exynos platform is removed and hence removing non DT support from the driver also. This will help in easy maintainence. Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 17 + 1 files changed, 1 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index acbd295..4356118 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -403,19 +403,6 @@ static const struct of_device_id exynos_tmu_match[] = { MODULE_DEVICE_TABLE(of, exynos_tmu_match); #endif -static struct platform_device_id exynos_tmu_driver_ids[] = { - { - .name = "exynos4210-tmu", - .driver_data= (kernel_ulong_t)EXYNOS4210_TMU_DRV_DATA, - }, - { - .name = "exynos5250-tmu", - .driver_data= (kernel_ulong_t)EXYNOS5250_TMU_DRV_DATA, - }, - { }, -}; -MODULE_DEVICE_TABLE(platform, exynos_tmu_driver_ids); - static inline struct exynos_tmu_platform_data *exynos_get_driver_data( struct platform_device *pdev) { @@ -428,8 +415,7 @@ static inline struct exynos_tmu_platform_data *exynos_get_driver_data( return (struct exynos_tmu_platform_data *) match->data; } #endif - return (struct exynos_tmu_platform_data *) - platform_get_device_id(pdev)->driver_data; + return NULL; } static int exynos_tmu_probe(struct platform_device *pdev) @@ -586,7 +572,6 @@ static struct platform_driver exynos_tmu_driver = { }, .probe = exynos_tmu_probe, .remove = exynos_tmu_remove, - .id_table = exynos_tmu_driver_ids, }; module_platform_driver(exynos_tmu_driver); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 15/30] thermal: exynos: Return success even if no cooling data supplied
This patch removes the error return in the bind/unbind routine as the platform may not register any cpufreq cooling data. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index 7064eb7..86d39aa 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -131,7 +131,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, tab_size = data->cooling_data.freq_clip_count; if (tab_ptr == NULL || tab_size == 0) - return -EINVAL; + return 0; /* find the cooling device registered*/ for (i = 0; i < th_zone->cool_dev_size; i++) @@ -180,7 +180,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, tab_size = data->cooling_data.freq_clip_count; if (tab_size == 0) - return -EINVAL; + return 0; /* find the cooling device registered*/ for (i = 0; i < th_zone->cool_dev_size; i++) -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 14/30] thermal: exynos: Modify private_data to appropriate name driver_data
This patch renames member private_data to driver_data of the thermal zone registration structure as this item stores the driver related data and uses it to call the driver related callbacks. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c |4 ++-- drivers/thermal/samsung/exynos_thermal_common.h |2 +- drivers/thermal/samsung/exynos_tmu.c|2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index 2af1e3b..7064eb7 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -221,7 +221,7 @@ static int exynos_get_temp(struct thermal_zone_device *thermal, pr_info("Temperature sensor not initialised\n"); return -EINVAL; } - data = th_zone->sensor_conf->private_data; + data = th_zone->sensor_conf->driver_data; *temp = th_zone->sensor_conf->read_temperature(data); /* convert the temperature into millicelsius */ *temp = *temp * MCELSIUS; @@ -240,7 +240,7 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal, pr_info("Temperature sensor not initialised\n"); return -EINVAL; } - data = th_zone->sensor_conf->private_data; + 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; diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index a845c2d..1e9a326 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h @@ -83,7 +83,7 @@ struct thermal_sensor_conf { int (*write_emul_temp)(void *drv_data, unsigned long temp); struct thermal_trip_point_conf trip_data; struct thermal_cooling_conf cooling_data; - void *private_data; + void *driver_data; void *pzone_data; }; diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index a7bba69..40e0cfd 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -504,7 +504,7 @@ static int exynos_tmu_probe(struct platform_device *pdev) exynos_tmu_control(pdev, true); /* Register the sensor with thermal management interface */ - (&exynos_sensor_conf)->private_data = data; + (&exynos_sensor_conf)->driver_data = data; exynos_sensor_conf.trip_data.trip_count = pdata->trigger_enable[0] + pdata->trigger_enable[1] + pdata->trigger_enable[2]+ pdata->trigger_enable[3]; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 09/30] thermal: exynos: Add extra entries in the tmu platform data
This patch adds entries min_efuse_value, max_efuse_value, default_temp_offset, trigger_type, cal_type, trim_first_point, trim_second_point, max_trigger_level trigger_enable in the TMU platform data structure. Also the driver is modified to use the data passed by these new platform memebers instead of the constant macros. All these changes helps in separating the SOC specific data part from the TMU driver. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.h |7 +++ drivers/thermal/samsung/exynos_tmu.c| 43 ++-- drivers/thermal/samsung/exynos_tmu.h| 49 ++ drivers/thermal/samsung/exynos_tmu_data.c | 35 4 files changed, 86 insertions(+), 48 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index 068f56c..fd789a5 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h @@ -44,6 +44,13 @@ #define EXYNOS_ZONE_COUNT 3 +enum trigger_type { + THROTTLE_ACTIVE = 1, + THROTTLE_PASSIVE, + SW_TRIP, + HW_TRIP, +}; + /** * struct freq_clip_table * @freq_clip_max: maximum frequency allowed for this cooling state. diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index fa33a48..401ec98 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -49,7 +49,6 @@ #define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf #define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 #define EXYNOS_TMU_CORE_EN_SHIFT 0 -#define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 /* Exynos4210 specific registers */ #define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 @@ -94,9 +93,6 @@ #define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 #define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 -#define EFUSE_MIN_VALUE 40 -#define EFUSE_MAX_VALUE 100 - #ifdef CONFIG_THERMAL_EMULATION #define EXYNOS_EMUL_TIME 0x57F0 #define EXYNOS_EMUL_TIME_MASK 0x @@ -136,15 +132,16 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp) switch (pdata->cal_type) { case TYPE_TWO_POINT_TRIMMING: - temp_code = (temp - 25) * - (data->temp_error2 - data->temp_error1) / - (85 - 25) + data->temp_error1; + temp_code = (temp - pdata->first_point_trim) * + (data->temp_error2 - data->temp_error1) / + (pdata->second_point_trim - pdata->first_point_trim) + + data->temp_error1; break; case TYPE_ONE_POINT_TRIMMING: - temp_code = temp + data->temp_error1 - 25; + temp_code = temp + data->temp_error1 - pdata->first_point_trim; break; default: - temp_code = temp + EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET; + temp_code = temp + pdata->default_temp_offset; break; } out: @@ -169,14 +166,16 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code) switch (pdata->cal_type) { case TYPE_TWO_POINT_TRIMMING: - temp = (temp_code - data->temp_error1) * (85 - 25) / - (data->temp_error2 - data->temp_error1) + 25; + temp = (temp_code - data->temp_error1) * + (pdata->second_point_trim - pdata->first_point_trim) / + (data->temp_error2 - data->temp_error1) + + pdata->first_point_trim; break; case TYPE_ONE_POINT_TRIMMING: - temp = temp_code - data->temp_error1 + 25; + temp = temp_code - data->temp_error1 + pdata->first_point_trim; break; default: - temp = temp_code - EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET; + temp = temp_code - pdata->default_temp_offset; break; } out: @@ -209,8 +208,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) data->temp_error1 = trim_info & EXYNOS_TMU_TRIM_TEMP_MASK; data->temp_error2 = ((trim_info >> 8) & EXYNOS_TMU_TRIM_TEMP_MASK); - if ((EFUSE_MIN_VALUE > data->temp_error1) || - (data->temp_error1 > EFUSE_MAX_VALUE) || + if ((pdata->min_efuse_value > data->temp_error1) || + (data->temp_error1 > pdata->max_efuse_value) || (data->temp_error2 != 0)) data->temp_error1 = pdata->efuse_value; @@ -300,10 +299,10 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT
[PATCH V6 12/30] thermal: exynos: Fix to clear only the generated interrupts
This patch uses the TMU status register to know the generated interrupts and only clear them in the interrupt handler. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 11 +-- drivers/thermal/samsung/exynos_tmu_data.c |2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 33f494e..f6f63ca 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -351,17 +351,16 @@ static void exynos_tmu_work(struct work_struct *work) struct exynos_tmu_data, irq_work); struct exynos_tmu_platform_data *pdata = data->pdata; const struct exynos_tmu_registers *reg = pdata->registers; + unsigned int val_irq; exynos_report_trigger(); mutex_lock(&data->lock); clk_enable(data->clk); - if (data->soc == SOC_ARCH_EXYNOS) - writel((reg->inten_rise_mask << reg->inten_rise_shift) | - (reg->inten_fall_mask << reg->inten_fall_shift), - data->base + reg->tmu_intclear); - else - writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); + /* TODO: take action based on particular interrupt */ + val_irq = readl(data->base + reg->tmu_intstat); + /* clear the interrupts */ + writel(val_irq, data->base + reg->tmu_intclear); clk_disable(data->clk); mutex_unlock(&data->lock); diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index e7cb1cc..7fcf183 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c @@ -45,6 +45,7 @@ static const struct exynos_tmu_registers exynos4210_tmu_registers = { .inten_rise1_shift = EXYNOS_TMU_INTEN_RISE1_SHIFT, .inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT, .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT, + .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, }; struct exynos_tmu_platform_data const exynos4210_default_tmu_data = { @@ -112,6 +113,7 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = { .inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT, .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT, .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, + .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, .emul_con = EXYNOS_EMUL_CON, .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 01/30] thermal: exynos: Moving exynos thermal files into samsung directory
This movement of files is done for easy maintenance and adding more new sensor's support for exynos platform easily . This will also help in bifurcating exynos common, sensor driver and sensor data related parts. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/Kconfig| 13 + drivers/thermal/Makefile |2 +- drivers/thermal/samsung/Kconfig|9 + drivers/thermal/samsung/Makefile |4 drivers/thermal/{ => samsung}/exynos_thermal.c |0 5 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 drivers/thermal/samsung/Kconfig create mode 100644 drivers/thermal/samsung/Makefile rename drivers/thermal/{ => samsung}/exynos_thermal.c (100%) diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index b13c2bc..ef10cf2 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -114,14 +114,6 @@ config KIRKWOOD_THERMAL Support for the Kirkwood thermal sensor driver into the Linux thermal framework. Only kirkwood 88F6282 and 88F6283 have this sensor. -config EXYNOS_THERMAL - tristate "Temperature sensor on Samsung EXYNOS" - depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) - depends on CPU_THERMAL - help - If you say yes here you get support for TMU (Thermal Management - Unit) on SAMSUNG EXYNOS series of SoC. - config DOVE_THERMAL tristate "Temperature sensor on Marvell Dove SoCs" depends on ARCH_DOVE @@ -185,4 +177,9 @@ menu "Texas Instruments thermal drivers" source "drivers/thermal/ti-soc-thermal/Kconfig" endmenu +menu "Samsung thermal drivers" +depends on PLAT_SAMSUNG +source "drivers/thermal/samsung/Kconfig" +endmenu + endif diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 67184a2..1f27ada 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -17,7 +17,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o obj-$(CONFIG_SPEAR_THERMAL)+= spear_thermal.o obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o obj-$(CONFIG_KIRKWOOD_THERMAL) += kirkwood_thermal.o -obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o +obj-y += samsung/ obj-$(CONFIG_DOVE_THERMAL) += dove_thermal.o obj-$(CONFIG_DB8500_THERMAL) += db8500_thermal.o obj-$(CONFIG_ARMADA_THERMAL) += armada_thermal.o diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig new file mode 100644 index 000..2d3d9dc --- /dev/null +++ b/drivers/thermal/samsung/Kconfig @@ -0,0 +1,9 @@ +config EXYNOS_THERMAL + tristate "Temperature sensor on Samsung EXYNOS" + depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) + depends on CPU_THERMAL + help + If you say yes here you get support for TMU (Thermal Management + Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering + the exynos thermal driver with the core thermal layer and cpu + cooling API's. diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile new file mode 100644 index 000..1fe6d93 --- /dev/null +++ b/drivers/thermal/samsung/Makefile @@ -0,0 +1,4 @@ +# +# Samsung thermal specific Makefile +# +obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/samsung/exynos_thermal.c similarity index 100% rename from drivers/thermal/exynos_thermal.c rename to drivers/thermal/samsung/exynos_thermal.c -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V6 06/30] thermal: exynos: Move exynos_thermal.h from include/* to driver/* folder
This patch renames and moves include/linux/platform_data/exynos_thermal.h to drivers/thermal/samsung/exynos_tmu.h. This file movement is needed as exynos SOC's are not supporting non-DT based platforms and this file now just contains exynos tmu driver related definations. Also struct freq_clip_table is now moved to exynos_thermal_common.c as it fixes the compilation issue occuring because now this new tmu header file is included in tmu driver c file and not in the common thermal header file. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c|1 - drivers/thermal/samsung/exynos_thermal_common.h| 15 drivers/thermal/samsung/exynos_tmu.c |2 +- .../thermal/samsung/exynos_tmu.h | 24 --- 4 files changed, 21 insertions(+), 21 deletions(-) rename include/linux/platform_data/exynos_thermal.h => drivers/thermal/samsung/exynos_tmu.h (84%) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index 92e50bc..dd49c9f 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -21,7 +21,6 @@ */ #include -#include #include #include diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index 8df1848..068f56c 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h @@ -44,6 +44,21 @@ #define EXYNOS_ZONE_COUNT 3 +/** + * struct freq_clip_table + * @freq_clip_max: maximum frequency allowed for this cooling state. + * @temp_level: Temperature level at which the temperature clipping will + * happen. + * @mask_val: cpumask of the allowed cpu's where the clipping will take place. + * + * This structure is required to be filled and passed to the + * cpufreq_cooling_unregister function. + */ +struct freq_clip_table { + unsigned int freq_clip_max; + unsigned int temp_level; + const struct cpumask *mask_val; +}; struct thermal_trip_point_conf { int trip_val[MAX_TRIP_COUNT]; int trip_count; diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 22a8874..6aa2fd2 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -27,9 +27,9 @@ #include #include #include -#include #include "exynos_thermal_common.h" +#include "exynos_tmu.h" /* Exynos generic registers */ #define EXYNOS_TMU_REG_TRIMINFO0x0 diff --git a/include/linux/platform_data/exynos_thermal.h b/drivers/thermal/samsung/exynos_tmu.h similarity index 84% rename from include/linux/platform_data/exynos_thermal.h rename to drivers/thermal/samsung/exynos_tmu.h index da7e627..9e0f887 100644 --- a/include/linux/platform_data/exynos_thermal.h +++ b/drivers/thermal/samsung/exynos_tmu.h @@ -1,8 +1,9 @@ /* - * exynos_thermal.h - Samsung EXYNOS TMU (Thermal Management Unit) + * exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit) * * Copyright (C) 2011 Samsung Electronics * Donggeun Kim + * Amit Daniel Kachhap * * 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 @@ -19,8 +20,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _LINUX_EXYNOS_THERMAL_H -#define _LINUX_EXYNOS_THERMAL_H +#ifndef _EXYNOS_TMU_H +#define _EXYNOS_TMU_H #include enum calibration_type { @@ -33,21 +34,6 @@ enum soc_type { SOC_ARCH_EXYNOS4210 = 1, SOC_ARCH_EXYNOS, }; -/** - * struct freq_clip_table - * @freq_clip_max: maximum frequency allowed for this cooling state. - * @temp_level: Temperature level at which the temperature clipping will - * happen. - * @mask_val: cpumask of the allowed cpu's where the clipping will take place. - * - * This structure is required to be filled and passed to the - * cpufreq_cooling_unregister function. - */ -struct freq_clip_table { - unsigned int freq_clip_max; - unsigned int temp_level; - const struct cpumask *mask_val; -}; /** * struct exynos_tmu_platform_data @@ -116,4 +102,4 @@ struct exynos_tmu_platform_data { struct freq_clip_table freq_tab[4]; unsigned int freq_tab_count; }; -#endif /* _LINUX_EXYNOS_THERMAL_H */ +#endif /* _EXYNOS_TMU_H */ -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.
Hi Jonghwa, Sorry for the late reply as I was on leave. On Sat, May 18, 2013 at 10:53 AM, wrote: > On 2013년 05월 14일 18:58, Amit Daniel Kachhap wrote: > >> This patch modifies TMU controller to add changes needed to work with >> exynos5440 platform. This sensor registers 3 instance of the tmu controller >> with the thermal zone and hence reports 3 temperature output. This controller >> supports upto five trip points. For critical threshold the driver uses the >> core driver thermal framework for shutdown. >> >> Acked-by: Kukjin Kim >> Signed-off-by: Amit Daniel Kachhap >> --- >> .../devicetree/bindings/thermal/exynos-thermal.txt | 28 - >> drivers/thermal/samsung/exynos_tmu.c | 43 >> +-- >> drivers/thermal/samsung/exynos_tmu.h |6 +++ >> drivers/thermal/samsung/exynos_tmu_data.h |2 + >> 4 files changed, 72 insertions(+), 7 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> index 535fd0e..970eeba 100644 >> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> @@ -6,13 +6,16 @@ >> "samsung,exynos4412-tmu" >> "samsung,exynos4210-tmu" >> "samsung,exynos5250-tmu" >> +"samsung,exynos5440-tmu" >> - interrupt-parent : The phandle for the interrupt controller >> -- reg : Address range of the thermal registers >> +- reg : Address range of the thermal registers. For exynos5440-tmu which >> has 3 >> + instances of TMU, 2 set of register has to supplied. First set belongs >> + to each instance of TMU and second set belongs to common TMU registers. >> - interrupts : Should contain interrupt for thermal system >> - clocks : The main clock for TMU device >> - clock-names : Thermal system clock name >> >> -Example: >> +Example 1): >> >> tmu@100C { >> compatible = "samsung,exynos4412-tmu"; >> @@ -23,3 +26,24 @@ Example: >> clock-names = "tmu_apbif"; >> status = "disabled"; >> }; >> + >> +Example 2): >> + >> + tmuctrl_0: tmuctrl@160118 { >> + compatible = "samsung,exynos5440-tmu"; >> + reg = <0x160118 0x230>, <0x160368 0x10>; >> + interrupts = <0 58 0>; >> + clocks = <&clock 21>; >> + clock-names = "tmu_apbif"; >> + }; >> + >> +Note: For multi-instance tmu each instance should have an alias correctly >> +numbered in "aliases" node. >> + >> +Example: >> + >> +aliases { >> + tmuctrl0 = &tmuctrl_0; >> + tmuctrl1 = &tmuctrl_1; >> + tmuctrl2 = &tmuctrl_2; >> +}; >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 7f7b1cf..7ca9c4d 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device >> *pdev) >> reg->threshold_th0 + i * sizeof(reg->threshold_th0)); >> >> writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); >> - } else if (data->soc == SOC_ARCH_EXYNOS) { >> + } else if (data->soc == SOC_ARCH_EXYNOS || >> + data->soc == SOC_ARCH_EXYNOS5440) { >> /* Write temperature code for rising and falling threshold */ >> - for (i = 0; i < trigger_levs; i++) { >> + for (i = 0; >> + i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) { >> threshold_code = temp_to_code(data, >> pdata->trigger_levels[i]); >> if (threshold_code < 0) { >> @@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device >> *pdev) >> writel((reg->inten_rise_mask << reg->inten_rise_shift) | >> (reg->inten_fall_mask << reg->inten_fall_shift), >> data->base + reg->tmu_intclear); >> + >> + /* if 5th threshold limit is also present, use TH2 register *
Re: [PATCH V4 10/30] thermal: exynos: Support thermal tripping
Hi . On Fri, May 17, 2013 at 5:26 PM, wrote: > Hi, Amit > On 2013년 05월 14일 18:58, Amit Daniel Kachhap wrote: > >> TMU urgently sends active-high signal (thermal trip) to PMU, and thermal >> tripping by hardware logic. Thermal tripping means that PMU cuts off the >> whole power of SoC by controlling external voltage regulator. >> >> Acked-by: Kukjin Kim >> Signed-off-by: Jonghwan Choi >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/exynos_tmu.c |8 +++- >> drivers/thermal/samsung/exynos_tmu_data.c |2 ++ >> 2 files changed, 9 insertions(+), 1 deletions(-) >> >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 5f8f189..479d61e 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -84,6 +84,7 @@ >> #define EXYNOS_TMU_CLEAR_FALL_INT(0x111 << 12) >> #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 >> #define EXYNOS_TMU_TRIP_MODE_MASK0x7 >> +#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12 >> >> #define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 >> #define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 >> @@ -186,7 +187,7 @@ static int exynos_tmu_initialize(struct platform_device >> *pdev) >> { >> struct exynos_tmu_data *data = platform_get_drvdata(pdev); >> struct exynos_tmu_platform_data *pdata = data->pdata; >> - unsigned int status, trim_info; >> + unsigned int status, trim_info, con; >> unsigned int rising_threshold = 0, falling_threshold = 0; >> int ret = 0, threshold_code, i, trigger_levs = 0; >> >> @@ -251,6 +252,11 @@ static int exynos_tmu_initialize(struct platform_device >> *pdev) >> falling_threshold |= >> threshold_code << 8 * i; >> } >> + if (pdata->trigger_type[i] != HW_TRIP) >> + continue; > > > As you know, HW trip can be used when only the most last level of threshold > temperature is set. (exynos4412 : 4th, exynos 5440 : 5th threshold level). So > it > wouldn't work properly, even if we enable HW trip according to pre-defined > trigger type not to HW trip threshold temperature. To enable HW trip, we just > need to check whether if HW trip threshold temperature level is defined. > > if (trigger_level[HW_TRIP_LEVEL]) > enable HW trip Yes you are right. I will include this change in the next version. Thanks, Amit Daniel > > Thanks, > Jonghwa > >> + con = readl(data->base + EXYNOS_TMU_REG_CONTROL); >> + con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT); >> + writel(con, data->base + EXYNOS_TMU_REG_CONTROL); >> } >> >> writel(rising_threshold, >> diff --git a/drivers/thermal/samsung/exynos_tmu_data.c >> b/drivers/thermal/samsung/exynos_tmu_data.c >> index ee6a3c9..6b937f5 100644 >> --- a/drivers/thermal/samsung/exynos_tmu_data.c >> +++ b/drivers/thermal/samsung/exynos_tmu_data.c >> @@ -64,6 +64,7 @@ struct exynos_tmu_platform_data const >> exynos5250_default_tmu_data = { >> .trigger_levels[0] = 85, >> .trigger_levels[1] = 103, >> .trigger_levels[2] = 110, >> + .trigger_levels[3] = 120, >> .trigger_enable[0] = 1, >> .trigger_enable[1] = 1, >> .trigger_enable[2] = 1, >> @@ -71,6 +72,7 @@ struct exynos_tmu_platform_data const >> exynos5250_default_tmu_data = { >> .trigger_type[0] = 0, >> .trigger_type[1] = 0, >> .trigger_type[2] = 1, >> + .trigger_type[3] = 2, >> .gain = 8, >> .reference_voltage = 16, >> .noise_cancel_mode = 4, > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V4 00/30] thermal: exynos: Add thermal driver for exynos5440
Hi Eduardo, On Wed, May 15, 2013 at 8:14 PM, Eduardo Valentin wrote: > On 14-05-2013 05:58, Amit Daniel Kachhap wrote: >> Changes in V4: >> Almost all the changes in this version is as per suggestion from Eduardo.The >> major ones are listed below, >> * Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. >> With >> this change existing symbol EXYNOS_TMU_DATA is not needed. > > I was more thinking if we could have a single flag that we could use in > thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not > merged yet. yes a single flag might be useful such as ARCH_HAS_THERMAL but this patch can work as an intermediate solution. Thanks, Amit Daniel > >> * Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is >> explained in the commit logs. >> * Wrote all register description documentation. >> * Split 5440 TMU support patch into controller change, configuration data and >> feature addition patches. >> * Remove all *LINUX_* in the header files. >> * Still regulator enable is kept optional but a TODO: comment is added to fix >> it later. >> >> Changes in V3: >> * Added proper dependency of different exynos thermal Kconfig symbols. >> Basically 3 >> Kconfig can be enabled now and corresponds to tmu driver. exynos common part >> and exynos configuration data. This issue was raised by Rui Zhang. >> >> Changes in V2: >> * Separated SOC data from TMU driver. This is as per suggestion from Eduardo. >> * Merged the new file created for exynos5440 TMU controller with the existing >> TMU controller code. >> * Removed the DT parsing code as now the SOC specific data are cleanly put >> inside the data specific file. >> * Even the register definations/bitfields are treated as data as there is >> some variation across SOC's. >> >> This patchset adds TMU(Thermal management Unit) driver support for >> exynos5440 platform. There are 3 instances of the TMU controllers so >> necessary cleanup/re-structure is done to handle multiple thermal zone. >> >> Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from >> Lukasz Majewski is already posted to mainline. Adding it here for >> completeness. >> (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg17817.html) >> >> Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is >> added here with some changes. >> (https://patchwork.kernel.org/patch/1668371/) >> >> Patch (thermal: exynos: Support for TMU regulator defined at device tree) >> is a repost of my earlier >> patch(https://patchwork-mail1.kernel.org/patch/2510771/) >> and adds regulator support. >> >> Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and >> patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos >> platform >> maintainer as this can cause merge conflict. >> >> All these patches are based on thermal maintainers git tree, >> git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next. >> >> Amit Daniel Kachhap (29): >> thermal: exynos: Moving exynos thermal files into samsung directory >> thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's >> thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver >> thermal: exynos: Bifurcate exynos thermal common and tmu controller >> code >> thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c >> thermal: exynos: Move exynos_thermal.h from include/* to driver/* >> folder >> thermal: exynos: Bifurcate exynos tmu driver and configuration data >> thermal: exynos: Add missing definations and code cleanup >> thermal: exynos: Add extra entries in the tmu platform data >> thermal: exynos: Support thermal tripping >> thermal: exynos: Move register definitions from driver file to data >> file >> thermal: exynos: Fix to clear only the generated interrupts >> thermal: exynos: Add support for instance based register/unregister >> thermal: exynos: Modify private_data to appropriate name driver_data >> thermal: exynos: Return success even if no cooling data supplied >> thermal: exynos: Make the zone handling dependent on trip count >> thermal: exynos: Add support to handle many instances of TMU >> thermal: exynos: Add TMU features to check instead of using SOC type >> thermal: exynos: use device resource management infrastructure >> thermal: exynos: Add support to access common register for >> multistance >> thermal: exynos
Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.
Hi Eduardo, On Tue, Jun 4, 2013 at 6:25 PM, Eduardo Valentin wrote: > On 04-06-2013 00:44, amit daniel kachhap wrote: >> Hi Jonghwa, >> >> Sorry for the late reply as I was on leave. >> >> On Sat, May 18, 2013 at 10:53 AM, wrote: >>> On 2013년 05월 14일 18:58, Amit Daniel Kachhap wrote: >>> >>>> This patch modifies TMU controller to add changes needed to work with >>>> exynos5440 platform. This sensor registers 3 instance of the tmu controller >>>> with the thermal zone and hence reports 3 temperature output. This >>>> controller >>>> supports upto five trip points. For critical threshold the driver uses the >>>> core driver thermal framework for shutdown. >>>> >>>> Acked-by: Kukjin Kim >>>> Signed-off-by: Amit Daniel Kachhap >>>> --- >>>> .../devicetree/bindings/thermal/exynos-thermal.txt | 28 - >>>> drivers/thermal/samsung/exynos_tmu.c | 43 >>>> +-- >>>> drivers/thermal/samsung/exynos_tmu.h |6 +++ >>>> drivers/thermal/samsung/exynos_tmu_data.h |2 + >>>> 4 files changed, 72 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>> index 535fd0e..970eeba 100644 >>>> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>> @@ -6,13 +6,16 @@ >>>> "samsung,exynos4412-tmu" >>>> "samsung,exynos4210-tmu" >>>> "samsung,exynos5250-tmu" >>>> +"samsung,exynos5440-tmu" >>>> - interrupt-parent : The phandle for the interrupt controller >>>> -- reg : Address range of the thermal registers >>>> +- reg : Address range of the thermal registers. For exynos5440-tmu which >>>> has 3 >>>> + instances of TMU, 2 set of register has to supplied. First set >>>> belongs >>>> + to each instance of TMU and second set belongs to common TMU >>>> registers. >>>> - interrupts : Should contain interrupt for thermal system >>>> - clocks : The main clock for TMU device >>>> - clock-names : Thermal system clock name >>>> >>>> -Example: >>>> +Example 1): >>>> >>>> tmu@100C { >>>> compatible = "samsung,exynos4412-tmu"; >>>> @@ -23,3 +26,24 @@ Example: >>>> clock-names = "tmu_apbif"; >>>> status = "disabled"; >>>> }; >>>> + >>>> +Example 2): >>>> + >>>> + tmuctrl_0: tmuctrl@160118 { >>>> + compatible = "samsung,exynos5440-tmu"; >>>> + reg = <0x160118 0x230>, <0x160368 0x10>; >>>> + interrupts = <0 58 0>; >>>> + clocks = <&clock 21>; >>>> + clock-names = "tmu_apbif"; >>>> + }; >>>> + >>>> +Note: For multi-instance tmu each instance should have an alias correctly >>>> +numbered in "aliases" node. >>>> + >>>> +Example: >>>> + >>>> +aliases { >>>> + tmuctrl0 = &tmuctrl_0; >>>> + tmuctrl1 = &tmuctrl_1; >>>> + tmuctrl2 = &tmuctrl_2; >>>> +}; >>>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>>> b/drivers/thermal/samsung/exynos_tmu.c >>>> index 7f7b1cf..7ca9c4d 100644 >>>> --- a/drivers/thermal/samsung/exynos_tmu.c >>>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>>> @@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct >>>> platform_device *pdev) >>>> reg->threshold_th0 + i * sizeof(reg->threshold_th0)); >>>> >>>> writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); >>>> - } else if (data->soc == SOC_ARCH_EXYNOS) { >>>> + } else if (data->soc == SOC_ARCH_EXYNOS || >>>> + data->soc == SOC_ARCH_EXYNOS5440) { >>>> /* Write tempera
Re: [PATCH V4 00/30] thermal: exynos: Add thermal driver for exynos5440
On Tue, Jun 4, 2013 at 6:31 PM, Eduardo Valentin wrote: > > Hi, > > On 04-06-2013 08:57, Eduardo Valentin wrote: >> On 04-06-2013 00:55, amit daniel kachhap wrote: >>> Hi Eduardo, >>> >>> On Wed, May 15, 2013 at 8:14 PM, Eduardo Valentin >>> wrote: >>>> On 14-05-2013 05:58, Amit Daniel Kachhap wrote: >>>>> Changes in V4: >>>>> Almost all the changes in this version is as per suggestion from >>>>> Eduardo.The >>>>> major ones are listed below, >>>>> * Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by >>>>> platform. With >>>>> this change existing symbol EXYNOS_TMU_DATA is not needed. >>>> >>>> I was more thinking if we could have a single flag that we could use in >>>> thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not >>>> merged yet. >>> >>> yes a single flag might be useful such as ARCH_HAS_THERMAL but this >>> patch can work as an intermediate solution. >> >> I think bandgap is a generic enough term IMO. >> >> [1] - http://en.wikipedia.org/wiki/Bandgap_voltage_reference >> [2] - http://en.wikipedia.org/wiki/Silicon_bandgap_temperature_sensor >> > > Hit the send button too early. So, I think bandgap is a generic enough > term. Using bandgap I believe it is better because its meaning has the > implication of having a device to control thermal. > > But if you feel more confident with the thermal term we can switch to > something like HAS_THERMAL_CONTROL. Even in my case TMU uses bandgap voltage reference circuit. so ARCH_HAS_BANDGAP should be fine. Thanks, Amit Daniel > >> >>> >>> Thanks, >>> Amit Daniel >>>> >>>>> * Movement of freq_clip_table from exynos_tmu.h to >>>>> exynos_thermal_common.h is >>>>> explained in the commit logs. >>>>> * Wrote all register description documentation. >>>>> * Split 5440 TMU support patch into controller change, configuration data >>>>> and >>>>> feature addition patches. >>>>> * Remove all *LINUX_* in the header files. >>>>> * Still regulator enable is kept optional but a TODO: comment is added to >>>>> fix >>>>> it later. >>>>> >>>>> Changes in V3: >>>>> * Added proper dependency of different exynos thermal Kconfig symbols. >>>>> Basically 3 >>>>> Kconfig can be enabled now and corresponds to tmu driver. exynos common >>>>> part >>>>> and exynos configuration data. This issue was raised by Rui Zhang. >>>>> >>>>> Changes in V2: >>>>> * Separated SOC data from TMU driver. This is as per suggestion from >>>>> Eduardo. >>>>> * Merged the new file created for exynos5440 TMU controller with the >>>>> existing >>>>> TMU controller code. >>>>> * Removed the DT parsing code as now the SOC specific data are cleanly put >>>>> inside the data specific file. >>>>> * Even the register definations/bitfields are treated as data as there is >>>>> some variation across SOC's. >>>>> >>>>> This patchset adds TMU(Thermal management Unit) driver support for >>>>> exynos5440 platform. There are 3 instances of the TMU controllers so >>>>> necessary cleanup/re-structure is done to handle multiple thermal zone. >>>>> >>>>> Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from >>>>> Lukasz Majewski is already posted to mainline. Adding it here for >>>>> completeness. >>>>> (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg17817.html) >>>>> >>>>> Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is >>>>> added here with some changes. >>>>> (https://patchwork.kernel.org/patch/1668371/) >>>>> >>>>> Patch (thermal: exynos: Support for TMU regulator defined at device tree) >>>>> is a repost of my earlier >>>>> patch(https://patchwork-mail1.kernel.org/patch/2510771/) >>>>> and adds regulator support. >>>>> >>>>> Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and >>>>> patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos >>>>> platform >>&g
Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.
Hi, On Wed, Jun 5, 2013 at 6:23 PM, Eduardo Valentin wrote: > On 04-06-2013 23:20, amit daniel kachhap wrote: >> Hi Eduardo, >> >> On Tue, Jun 4, 2013 at 6:25 PM, Eduardo Valentin >> wrote: >>> On 04-06-2013 00:44, amit daniel kachhap wrote: >>>> Hi Jonghwa, >>>> >>>> Sorry for the late reply as I was on leave. >>>> >>>> On Sat, May 18, 2013 at 10:53 AM, wrote: >>>>> On 2013년 05월 14일 18:58, Amit Daniel Kachhap wrote: >>>>> >>>>>> This patch modifies TMU controller to add changes needed to work with >>>>>> exynos5440 platform. This sensor registers 3 instance of the tmu >>>>>> controller >>>>>> with the thermal zone and hence reports 3 temperature output. This >>>>>> controller >>>>>> supports upto five trip points. For critical threshold the driver uses >>>>>> the >>>>>> core driver thermal framework for shutdown. >>>>>> >>>>>> Acked-by: Kukjin Kim >>>>>> Signed-off-by: Amit Daniel Kachhap >>>>>> --- >>>>>> .../devicetree/bindings/thermal/exynos-thermal.txt | 28 - >>>>>> drivers/thermal/samsung/exynos_tmu.c | 43 >>>>>> +-- >>>>>> drivers/thermal/samsung/exynos_tmu.h |6 +++ >>>>>> drivers/thermal/samsung/exynos_tmu_data.h |2 + >>>>>> 4 files changed, 72 insertions(+), 7 deletions(-) >>>>>> >>>>>> diff --git >>>>>> a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>>> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>>> index 535fd0e..970eeba 100644 >>>>>> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>>> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >>>>>> @@ -6,13 +6,16 @@ >>>>>> "samsung,exynos4412-tmu" >>>>>> "samsung,exynos4210-tmu" >>>>>> "samsung,exynos5250-tmu" >>>>>> +"samsung,exynos5440-tmu" >>>>>> - interrupt-parent : The phandle for the interrupt controller >>>>>> -- reg : Address range of the thermal registers >>>>>> +- reg : Address range of the thermal registers. For exynos5440-tmu >>>>>> which has 3 >>>>>> + instances of TMU, 2 set of register has to supplied. First set >>>>>> belongs >>>>>> + to each instance of TMU and second set belongs to common TMU >>>>>> registers. >>>>>> - interrupts : Should contain interrupt for thermal system >>>>>> - clocks : The main clock for TMU device >>>>>> - clock-names : Thermal system clock name >>>>>> >>>>>> -Example: >>>>>> +Example 1): >>>>>> >>>>>> tmu@100C { >>>>>> compatible = "samsung,exynos4412-tmu"; >>>>>> @@ -23,3 +26,24 @@ Example: >>>>>> clock-names = "tmu_apbif"; >>>>>> status = "disabled"; >>>>>> }; >>>>>> + >>>>>> +Example 2): >>>>>> + >>>>>> + tmuctrl_0: tmuctrl@160118 { >>>>>> + compatible = "samsung,exynos5440-tmu"; >>>>>> + reg = <0x160118 0x230>, <0x160368 0x10>; >>>>>> + interrupts = <0 58 0>; >>>>>> + clocks = <&clock 21>; >>>>>> + clock-names = "tmu_apbif"; >>>>>> + }; >>>>>> + >>>>>> +Note: For multi-instance tmu each instance should have an alias >>>>>> correctly >>>>>> +numbered in "aliases" node. >>>>>> + >>>>>> +Example: >>>>>> + >>>>>> +aliases { >>>>>> + tmuctrl0 = &tmuctrl_0; >>>>>> + tmuctrl1 = &tmuctrl_1; >>>>>> + tmuctrl2 = &tmuctrl_2; >>>>>> +}; >>>>>> diff --git
Re: [PATCH V6 04/30] thermal: exynos: Bifurcate exynos thermal common and tmu controller code
On Thu, Jun 20, 2013 at 12:15 AM, Eduardo Valentin wrote: > Amit, > > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This code bifurcates exynos thermal implementation into common and sensor >> specific parts. The common thermal code interacts with core thermal layer and >> core cpufreq cooling parts and is independent of SOC specific driver. This >> change is needed to cleanly add support for new TMU sensors. >> >> Acked-by: Kukjin Kim >> Acked-by: Jonghwa Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/Kconfig | 19 +- >> drivers/thermal/samsung/Makefile|4 +- >> drivers/thermal/samsung/exynos_thermal.c| 419 >> +-- >> drivers/thermal/samsung/exynos_thermal_common.c | 384 + >> drivers/thermal/samsung/exynos_thermal_common.h | 83 + >> 5 files changed, 490 insertions(+), 419 deletions(-) >> create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c >> create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h >> >> diff --git a/drivers/thermal/samsung/Kconfig >> b/drivers/thermal/samsung/Kconfig >> index 2cf31ad..f8100b1 100644 >> --- a/drivers/thermal/samsung/Kconfig >> +++ b/drivers/thermal/samsung/Kconfig >> @@ -1,8 +1,17 @@ >> config EXYNOS_THERMAL >> - tristate "Temperature sensor on Samsung EXYNOS" >> + tristate "Exynos thermal management unit driver" >> depends on ARCH_HAS_BANDGAP >> help >> - If you say yes here you get support for TMU (Thermal Management >> - Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering >> - the exynos thermal driver with the core thermal layer and cpu >> - cooling API's. >> + If you say yes here you get support for the TMU (Thermal Management >> + Unit) driver for SAMSUNG EXYNOS series of soc. This driver >> initialises >> + the TMU, reports temperature and handles cooling action if defined. >> + This driver uses the exynos core thermal API's. >> + >> +config EXYNOS_THERMAL_CORE >> + bool "Core thermal framework support for EXYNOS SOC's" >> + depends on EXYNOS_THERMAL >> + help >> + If you say yes here you get support for EXYNOS TMU >> + (Thermal Management Unit) common registration/unregistration >> + functions to the core thermal layer and also to use the generic >> + cpu cooling API's. > Should this one depend on CPU_THERMAL? Is it mandatory? Hi Eduardo, No it is not mandatory. If CPU_THERMAL is not present then cooling device is not created and only temp/trip_points etc sysfs are created. Thanks, Amit Daniel > >> diff --git a/drivers/thermal/samsung/Makefile >> b/drivers/thermal/samsung/Makefile >> index 1fe6d93..6227d4f 100644 >> --- a/drivers/thermal/samsung/Makefile >> +++ b/drivers/thermal/samsung/Makefile >> @@ -1,4 +1,6 @@ >> # >> # Samsung thermal specific Makefile >> # >> -obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o >> +obj-$(CONFIG_EXYNOS_THERMAL) += exynos_soc_thermal.o >> +exynos_soc_thermal-y := exynos_thermal.o >> +exynos_soc_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o >> diff --git a/drivers/thermal/samsung/exynos_thermal.c >> b/drivers/thermal/samsung/exynos_thermal.c >> index 03e4bbc..5293849 100644 >> --- a/drivers/thermal/samsung/exynos_thermal.c >> +++ b/drivers/thermal/samsung/exynos_thermal.c >> @@ -21,23 +21,15 @@ >> * >> */ >> >> -#include >> -#include >> -#include >> -#include >> -#include >> -#include >> #include >> -#include >> -#include >> -#include >> #include >> -#include >> -#include >> -#include >> -#include >> -#include >> +#include >> +#include >> #include >> +#include >> +#include >> + >> +#include "exynos_thermal_common.h" >> >> /* Exynos generic registers */ >> #define EXYNOS_TMU_REG_TRIMINFO 0x0 >> @@ -88,16 +80,6 @@ >> #define EFUSE_MIN_VALUE 40 >> #define EFUSE_MAX_VALUE 100 >> >> -/* In-kernel thermal framework related macros & definations */ >> -#define SENSOR_NAME_LEN 16 >> -#define MAX_TRIP_COUNT 8 >> -#define MAX_COOLING_DEVICE 4 >> -#define MAX_THRESHOLD_LEVS 4 >> - >> -#define ACTIVE_INTERVAL 500 >> -#define
Re: [PATCH V6 08/30] thermal: exynos: Add missing definations and code cleanup
Hi Eduardo, On Thu, Jun 20, 2013 at 1:25 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This patch adds some extra register bitfield definations and cleans >> up the code to prepare for moving register macros and definations inside >> the TMU data section. >> >> Acked-by: Kukjin Kim >> Acked-by: Jonghwa Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/exynos_tmu.c | 62 >> +- >> 1 files changed, 46 insertions(+), 16 deletions(-) >> >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 5df04a1..fa33a48 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -43,9 +43,12 @@ >> >> #define EXYNOS_TMU_TRIM_TEMP_MASK0xff >> #define EXYNOS_TMU_GAIN_SHIFT8 >> +#define EXYNOS_TMU_GAIN_MASK 0xf >> #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 >> -#define EXYNOS_TMU_CORE_ON 3 >> -#define EXYNOS_TMU_CORE_OFF 2 >> +#define EXYNOS_TMU_REF_VOLTAGE_MASK 0x1f >> +#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK0xf >> +#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 >> +#define EXYNOS_TMU_CORE_EN_SHIFT 0 >> #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 >> >> /* Exynos4210 specific registers */ >> @@ -63,6 +66,7 @@ >> #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10 >> #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100 >> #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000 >> +#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x >> #define EXYNOS4210_TMU_INTCLEAR_VAL 0x >> >> /* Exynos5250 and Exynos4412 specific registers */ >> @@ -72,17 +76,30 @@ >> #define EXYNOS_EMUL_CON 0x80 >> >> #define EXYNOS_TRIMINFO_RELOAD 0x1 >> +#define EXYNOS_TRIMINFO_SHIFT0x0 >> +#define EXYNOS_TMU_RISE_INT_MASK 0x111 >> +#define EXYNOS_TMU_RISE_INT_SHIFT0 >> +#define EXYNOS_TMU_FALL_INT_MASK 0x111 >> +#define EXYNOS_TMU_FALL_INT_SHIFT12 >> #define EXYNOS_TMU_CLEAR_RISE_INT0x111 >> #define EXYNOS_TMU_CLEAR_FALL_INT(0x111 << 12) >> -#define EXYNOS_MUX_ADDR_VALUE6 >> -#define EXYNOS_MUX_ADDR_SHIFT20 >> #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 >> +#define EXYNOS_TMU_TRIP_MODE_MASK0x7 >> + >> +#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 >> +#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 >> +#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 >> +#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 >> +#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 >> +#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 >> +#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 >> >> #define EFUSE_MIN_VALUE 40 >> #define EFUSE_MAX_VALUE 100 >> >> #ifdef CONFIG_THERMAL_EMULATION >> #define EXYNOS_EMUL_TIME 0x57F0 >> +#define EXYNOS_EMUL_TIME_MASK0x >> #define EXYNOS_EMUL_TIME_SHIFT 16 >> #define EXYNOS_EMUL_DATA_SHIFT 8 >> #define EXYNOS_EMUL_DATA_MASK0xFF >> @@ -261,24 +278,37 @@ static void exynos_tmu_control(struct platform_device >> *pdev, bool on) >> mutex_lock(&data->lock); >> clk_enable(data->clk); >> >> - con = pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT | >> - pdata->gain << EXYNOS_TMU_GAIN_SHIFT; >> + con = readl(data->base + EXYNOS_TMU_REG_CONTROL); >> >> - if (data->soc == SOC_ARCH_EXYNOS) { >> - con |= pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT; >> - con |= (EXYNOS_MUX_ADDR_VALUE << EXYNOS_MUX_ADDR_SHIFT); >> + if (pdata->reference_voltage) { >> + con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << >> + EXYNOS_TMU_REF_VOLTAGE_SHIFT); >> + con |= pdata->reference_voltage << >> EXYNOS_TMU_REF_VOLTAGE_SHIFT; >> + } >> + >> + if (pdata->gain) { >> + con &= ~(EXYNOS_TMU_GAIN_MASK << EXYNOS_TMU_GAIN_SHIFT); >> + con |= (pdata->gain << EXYNOS_TMU_GAIN_SHIFT); >> + } >> + >> + if (pdata->noise_cancel_mode) { >> + con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << >> + EXYNOS_TMU_TRIP_MODE_SHIFT); >> + con |= (pdata->noise_cancel_mode << >> EXYNOS_TMU_TRIP_MODE_SHIFT); >> } >>
Re: [PATCH V6 04/30] thermal: exynos: Bifurcate exynos thermal common and tmu controller code
On Thu, Jun 20, 2013 at 12:31 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This code bifurcates exynos thermal implementation into common and sensor >> specific parts. The common thermal code interacts with core thermal layer and >> core cpufreq cooling parts and is independent of SOC specific driver. This >> change is needed to cleanly add support for new TMU sensors. >> >> Acked-by: Kukjin Kim >> Acked-by: Jonghwa Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/Kconfig | 19 +- >> drivers/thermal/samsung/Makefile|4 +- >> drivers/thermal/samsung/exynos_thermal.c| 419 >> +-- >> drivers/thermal/samsung/exynos_thermal_common.c | 384 + >> drivers/thermal/samsung/exynos_thermal_common.h | 83 + >> 5 files changed, 490 insertions(+), 419 deletions(-) >> create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c >> create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h >> >> diff --git a/drivers/thermal/samsung/Kconfig >> b/drivers/thermal/samsung/Kconfig >> index 2cf31ad..f8100b1 100644 >> --- a/drivers/thermal/samsung/Kconfig >> +++ b/drivers/thermal/samsung/Kconfig >> @@ -1,8 +1,17 @@ >> config EXYNOS_THERMAL >> - tristate "Temperature sensor on Samsung EXYNOS" >> + tristate "Exynos thermal management unit driver" >> depends on ARCH_HAS_BANDGAP > > This is not really on this patch, but I think this one needs to depend > on CONFIG_OF too. In the driver CONFIG_OF is used for DT api's so this is not needed here. > >> help >> - If you say yes here you get support for TMU (Thermal Management >> - Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering >> - the exynos thermal driver with the core thermal layer and cpu >> - cooling API's. >> + If you say yes here you get support for the TMU (Thermal Management >> + Unit) driver for SAMSUNG EXYNOS series of soc. This driver >> initialises >> + the TMU, reports temperature and handles cooling action if defined. >> + This driver uses the exynos core thermal API's. >> + >> +config EXYNOS_THERMAL_CORE >> + bool "Core thermal framework support for EXYNOS SOC's" >> + depends on EXYNOS_THERMAL >> + help >> + If you say yes here you get support for EXYNOS TMU >> + (Thermal Management Unit) common registration/unregistration >> + functions to the core thermal layer and also to use the generic >> + cpu cooling API's. >> diff --git a/drivers/thermal/samsung/Makefile >> b/drivers/thermal/samsung/Makefile >> index 1fe6d93..6227d4f 100644 >> --- a/drivers/thermal/samsung/Makefile >> +++ b/drivers/thermal/samsung/Makefile >> @@ -1,4 +1,6 @@ >> # >> # Samsung thermal specific Makefile >> # >> -obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o >> +obj-$(CONFIG_EXYNOS_THERMAL) += exynos_soc_thermal.o >> +exynos_soc_thermal-y := exynos_thermal.o >> +exynos_soc_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o >> diff --git a/drivers/thermal/samsung/exynos_thermal.c >> b/drivers/thermal/samsung/exynos_thermal.c >> index 03e4bbc..5293849 100644 >> --- a/drivers/thermal/samsung/exynos_thermal.c >> +++ b/drivers/thermal/samsung/exynos_thermal.c >> @@ -21,23 +21,15 @@ >> * >> */ >> >> -#include >> -#include >> -#include >> -#include >> -#include >> -#include >> #include >> -#include >> -#include >> -#include >> #include >> -#include >> -#include >> -#include >> -#include >> -#include >> +#include >> +#include >> #include >> +#include >> +#include >> + >> +#include "exynos_thermal_common.h" >> >> /* Exynos generic registers */ >> #define EXYNOS_TMU_REG_TRIMINFO 0x0 >> @@ -88,16 +80,6 @@ >> #define EFUSE_MIN_VALUE 40 >> #define EFUSE_MAX_VALUE 100 >> >> -/* In-kernel thermal framework related macros & definations */ >> -#define SENSOR_NAME_LEN 16 >> -#define MAX_TRIP_COUNT 8 >> -#define MAX_COOLING_DEVICE 4 >> -#define MAX_THRESHOLD_LEVS 4 >> - >> -#define ACTIVE_INTERVAL 500 >> -#define IDLE_INTERVAL 1 >> -#define MCELSIUS 1000 >> - >&
Re: [PATCH V2] thermal: exynos: Support for TMU regulator defined at device tree
On Thu, Jun 20, 2013 at 1:33 AM, Eduardo Valentin wrote: > On 02-05-2013 06:18, Amit Daniel Kachhap wrote: >> TMU probe function now checks for a device tree defined regulator. >> For compatibility reasons it is allowed to probe driver even without >> this regulator defined. >> >> Signed-off-by: Luk asz Majewski >> Signed-off-by: Kyungmin Park >> Signed-off-by: Amit Daniel Kachhap > > I assume this one got superseeded by the same patch on your 30 patch > series, right? > https://patchwork.kernel.org/patch/2731031/ Yes right. In my re-structuring patch series this one is included. > > >> --- >> >> Changes in V2: >> * Added log message in regulator_get failure as suggested by Sylwester. >> * Used IS_ERR for checking regulator pointer as suggested by Sylwester. >> >> This patch is repost of the patch posted by Lukasz Majewski >> (https://patchwork.kernel.org/patch/2488211/). I have rebased this >> patch on top of my TMU re-structured patch series >> (http://lwn.net/Articles/548634/). Although I thought of handling >> regulator as one type of feature (newly added) but could not do >> so as regulator is a board/platform property and not SOC property so >> leaving the device tree to define and handle it. >> >> .../devicetree/bindings/thermal/exynos-thermal.txt |4 >> drivers/thermal/samsung/exynos_tmu.c | 19 >> +++ >> 2 files changed, 23 insertions(+), 0 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> index 970eeba..ff62f7a 100644 >> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> @@ -14,6 +14,9 @@ >> - interrupts : Should contain interrupt for thermal system >> - clocks : The main clock for TMU device >> - clock-names : Thermal system clock name >> +- 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. >> >> Example 1): >> >> @@ -25,6 +28,7 @@ Example 1): >> clocks = <&clock 383>; >> clock-names = "tmu_apbif"; >> status = "disabled"; >> + vtmu-supply = <&tmu_regulator_node>; >> }; >> >> Example 2): >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 72446c9..b7c609a 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -32,6 +32,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include "exynos_thermal_common.h" >> @@ -52,6 +53,7 @@ >> * @clk: pointer to the clock structure. >> * @temp_error1: fused value of the first point trim. >> * @temp_error2: fused value of the second point trim. >> + * @regulator: pointer to the TMU regulator structure. >> * @reg_conf: pointer to structure to register with core thermal. >> */ >> struct exynos_tmu_data { >> @@ -65,6 +67,7 @@ struct exynos_tmu_data { >> struct mutex lock; >> struct clk *clk; >> u8 temp_error1, temp_error2; >> + struct regulator *regulator; >> struct thermal_sensor_conf *reg_conf; >> }; >> >> @@ -501,10 +504,23 @@ static int exynos_map_dt_data(struct platform_device >> *pdev) >> struct exynos_tmu_data *data = platform_get_drvdata(pdev); >> struct exynos_tmu_platform_data *pdata = data->pdata; >> struct resource res; >> + int ret; >> >> if (!data) >> return -ENODEV; >> >> + /* Try enabling the regulator if found */ >> + data->regulator = devm_regulator_get(&pdev->dev, "vtmu"); >> + if (!IS_ERR(data->regulator)) { >> + ret = regulator_enable(data->regulator); >> + if (ret) { >> + dev_err(&pdev->dev, "failed to enable vtmu\n"); >> + return ret; >> + } >> + } else { >> + dev_info(&pdev->dev, "Regulator node (vtmu) not found\n"); >> + } >> + >> data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl"); >> if (data->id < 0) >> data->id = 0; >> @@ -669,6 +685,9 @@ static int exynos_tmu_remove(struct platform_device >> *pdev) >> >> clk_unprepare(data->clk); >> >> + if (!IS_ERR(data->regulator)) >> + regulator_disable(data->regulator); >> + >> platform_set_drvdata(pdev, NULL); >> >> return 0; >> > > > -- > You have got to be excited about what you are doing. (L. Lamport) > > Eduardo Valentin > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V6 06/30] thermal: exynos: Move exynos_thermal.h from include/* to driver/* folder
Hi On Thu, Jun 20, 2013 at 12:48 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This patch renames and moves include/linux/platform_data/exynos_thermal.h to >> drivers/thermal/samsung/exynos_tmu.h. This file movement is needed as exynos >> SOC's are not supporting non-DT based platforms and this file now just >> contains >> exynos tmu driver related definations. >> Also struct freq_clip_table is now moved to exynos_thermal_common.c as it >> fixes >> the compilation issue occuring because now this new tmu header file is >> included >> in tmu driver c file and not in the common thermal header file. >> >> Acked-by: Kukjin Kim >> Acked-by: Jonghwa Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/exynos_thermal_common.c|1 - >> drivers/thermal/samsung/exynos_thermal_common.h| 15 >> drivers/thermal/samsung/exynos_tmu.c |2 +- >> .../thermal/samsung/exynos_tmu.h | 24 >> --- >> 4 files changed, 21 insertions(+), 21 deletions(-) >> rename include/linux/platform_data/exynos_thermal.h => >> drivers/thermal/samsung/exynos_tmu.h (84%) >> >> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c >> b/drivers/thermal/samsung/exynos_thermal_common.c >> index 92e50bc..dd49c9f 100644 >> --- a/drivers/thermal/samsung/exynos_thermal_common.c >> +++ b/drivers/thermal/samsung/exynos_thermal_common.c >> @@ -21,7 +21,6 @@ >> */ >> >> #include >> -#include >> #include >> #include >> >> diff --git a/drivers/thermal/samsung/exynos_thermal_common.h >> b/drivers/thermal/samsung/exynos_thermal_common.h >> index 8df1848..068f56c 100644 >> --- a/drivers/thermal/samsung/exynos_thermal_common.h >> +++ b/drivers/thermal/samsung/exynos_thermal_common.h >> @@ -44,6 +44,21 @@ >> >> #define EXYNOS_ZONE_COUNT3 >> >> +/** >> + * struct freq_clip_table >> + * @freq_clip_max: maximum frequency allowed for this cooling state. >> + * @temp_level: Temperature level at which the temperature clipping will >> + * happen. >> + * @mask_val: cpumask of the allowed cpu's where the clipping will take >> place. >> + * >> + * This structure is required to be filled and passed to the >> + * cpufreq_cooling_unregister function. >> + */ >> +struct freq_clip_table { >> + unsigned int freq_clip_max; >> + unsigned int temp_level; >> + const struct cpumask *mask_val; >> +}; >> struct thermal_trip_point_conf { >> int trip_val[MAX_TRIP_COUNT]; >> int trip_count; >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 22a8874..6aa2fd2 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -27,9 +27,9 @@ >> #include >> #include >> #include >> -#include >> >> #include "exynos_thermal_common.h" >> +#include "exynos_tmu.h" >> >> /* Exynos generic registers */ >> #define EXYNOS_TMU_REG_TRIMINFO 0x0 >> diff --git a/include/linux/platform_data/exynos_thermal.h >> b/drivers/thermal/samsung/exynos_tmu.h >> similarity index 84% >> rename from include/linux/platform_data/exynos_thermal.h >> rename to drivers/thermal/samsung/exynos_tmu.h >> index da7e627..9e0f887 100644 >> --- a/include/linux/platform_data/exynos_thermal.h >> +++ b/drivers/thermal/samsung/exynos_tmu.h >> @@ -1,8 +1,9 @@ >> /* >> - * exynos_thermal.h - Samsung EXYNOS TMU (Thermal Management Unit) >> + * exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit) >> * >> * Copyright (C) 2011 Samsung Electronics >> * Donggeun Kim >> + * Amit Daniel Kachhap >> * >> * 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 >> @@ -19,8 +20,8 @@ >> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >> */ >> >> -#ifndef _LINUX_EXYNOS_THERMAL_H >> -#define _LINUX_EXYNOS_THERMAL_H >> +#ifndef _EXYNOS_TMU_H >> +#define _EXYNOS_TMU_H >> #include >> >> enum calibration_type { >> @@ -33,21 +34,6 @@ enum soc_type { >> SOC_ARCH_EXYNOS4210 = 1, >> SOC_ARCH_EXYNOS, >> }; >> -/** >> - * struct freq_clip_table >> - * @freq_c
Re: [PATCH V6 06/30] thermal: exynos: Move exynos_thermal.h from include/* to driver/* folder
On Thu, Jun 20, 2013 at 12:50 AM, Eduardo Valentin wrote: > On 19-06-2013 15:18, Eduardo Valentin wrote: >> On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >>> This patch renames and moves include/linux/platform_data/exynos_thermal.h to >>> drivers/thermal/samsung/exynos_tmu.h. This file movement is needed as exynos >>> SOC's are not supporting non-DT based platforms and this file now just >>> contains >>> exynos tmu driver related definations. >>> Also struct freq_clip_table is now moved to exynos_thermal_common.c as it >>> fixes >>> the compilation issue occuring because now this new tmu header file is >>> included >>> in tmu driver c file and not in the common thermal header file. >>> >>> Acked-by: Kukjin Kim >>> Acked-by: Jonghwa Lee >>> Signed-off-by: Amit Daniel Kachhap >>> --- >>> drivers/thermal/samsung/exynos_thermal_common.c|1 - >>> drivers/thermal/samsung/exynos_thermal_common.h| 15 >>> drivers/thermal/samsung/exynos_tmu.c |2 +- >>> .../thermal/samsung/exynos_tmu.h | 24 >>> --- >>> 4 files changed, 21 insertions(+), 21 deletions(-) >>> rename include/linux/platform_data/exynos_thermal.h => >>> drivers/thermal/samsung/exynos_tmu.h (84%) >>> >>> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c >>> b/drivers/thermal/samsung/exynos_thermal_common.c >>> index 92e50bc..dd49c9f 100644 >>> --- a/drivers/thermal/samsung/exynos_thermal_common.c >>> +++ b/drivers/thermal/samsung/exynos_thermal_common.c >>> @@ -21,7 +21,6 @@ >>> */ >>> >>> #include >>> -#include >>> #include >>> #include >>> >>> diff --git a/drivers/thermal/samsung/exynos_thermal_common.h >>> b/drivers/thermal/samsung/exynos_thermal_common.h >>> index 8df1848..068f56c 100644 >>> --- a/drivers/thermal/samsung/exynos_thermal_common.h >>> +++ b/drivers/thermal/samsung/exynos_thermal_common.h >>> @@ -44,6 +44,21 @@ >>> >>> #define EXYNOS_ZONE_COUNT 3 >>> >>> +/** >>> + * struct freq_clip_table >>> + * @freq_clip_max: maximum frequency allowed for this cooling state. >>> + * @temp_level: Temperature level at which the temperature clipping will >>> + * happen. >>> + * @mask_val: cpumask of the allowed cpu's where the clipping will take >>> place. >>> + * >>> + * This structure is required to be filled and passed to the >>> + * cpufreq_cooling_unregister function. >>> + */ >>> +struct freq_clip_table { >>> +unsigned int freq_clip_max; >>> +unsigned int temp_level; >>> +const struct cpumask *mask_val; >>> +}; > > Another minor: add an empty line here. Ok > >>> struct thermal_trip_point_conf { >>> int trip_val[MAX_TRIP_COUNT]; >>> int trip_count; >>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>> b/drivers/thermal/samsung/exynos_tmu.c >>> index 22a8874..6aa2fd2 100644 >>> --- a/drivers/thermal/samsung/exynos_tmu.c >>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>> @@ -27,9 +27,9 @@ >>> #include >>> #include >>> #include >>> -#include >>> >>> #include "exynos_thermal_common.h" >>> +#include "exynos_tmu.h" >>> >>> /* Exynos generic registers */ >>> #define EXYNOS_TMU_REG_TRIMINFO 0x0 >>> diff --git a/include/linux/platform_data/exynos_thermal.h >>> b/drivers/thermal/samsung/exynos_tmu.h >>> similarity index 84% >>> rename from include/linux/platform_data/exynos_thermal.h >>> rename to drivers/thermal/samsung/exynos_tmu.h >>> index da7e627..9e0f887 100644 >>> --- a/include/linux/platform_data/exynos_thermal.h >>> +++ b/drivers/thermal/samsung/exynos_tmu.h >>> @@ -1,8 +1,9 @@ >>> /* >>> - * exynos_thermal.h - Samsung EXYNOS TMU (Thermal Management Unit) >>> + * exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit) >>> * >>> * Copyright (C) 2011 Samsung Electronics >>> * Donggeun Kim >>> + * Amit Daniel Kachhap >>> * >>> * 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 >>> @@ -19,
Re: [PATCH V6 07/30] thermal: exynos: Bifurcate exynos tmu driver and configuration data
On Thu, Jun 20, 2013 at 1:13 AM, Eduardo Valentin wrote: > On 19-06-2013 15:35, Eduardo Valentin wrote: >> Rui, >> >> On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >>> This code splits the exynos tmu driver code into SOC specific data parts. >>> This will simplify adding new SOC specific data to the same TMU controller. >>> >>> Acked-by: Kukjin Kim >>> Acked-by: Jonghwa Lee >>> Signed-off-by: Amit Daniel Kachhap >> >> This patch looks good to me, you may want to add my: >> >> Acked-by: Eduardo Valentin > > Yet another minor before adding my ack, sorry this one almost fell into > the cracks (see below): > >> >>> --- >>> drivers/thermal/samsung/Kconfig |3 +- >>> drivers/thermal/samsung/Makefile |1 + >>> drivers/thermal/samsung/exynos_tmu.c | 67 ++--- >>> drivers/thermal/samsung/exynos_tmu_data.c | 78 >>> + >>> drivers/thermal/samsung/exynos_tmu_data.h | 40 +++ >>> 5 files changed, 125 insertions(+), 64 deletions(-) >>> create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c >>> create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h >>> >>> diff --git a/drivers/thermal/samsung/Kconfig >>> b/drivers/thermal/samsung/Kconfig >>> index f8100b1..b653f15 100644 >>> --- a/drivers/thermal/samsung/Kconfig >>> +++ b/drivers/thermal/samsung/Kconfig >>> @@ -5,7 +5,8 @@ config EXYNOS_THERMAL >>>If you say yes here you get support for the TMU (Thermal Management >>>Unit) driver for SAMSUNG EXYNOS series of soc. This driver >>> initialises >>>the TMU, reports temperature and handles cooling action if defined. >>> - This driver uses the exynos core thermal API's. >>> + This driver uses the exynos core thermal API's and TMU configuration >>> + data from the supported soc's. >>> >>> config EXYNOS_THERMAL_CORE >>> bool "Core thermal framework support for EXYNOS SOC's" >>> diff --git a/drivers/thermal/samsung/Makefile >>> b/drivers/thermal/samsung/Makefile >>> index 22528d6..c09d830 100644 >>> --- a/drivers/thermal/samsung/Makefile >>> +++ b/drivers/thermal/samsung/Makefile >>> @@ -3,4 +3,5 @@ >>> # >>> 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 6aa2fd2..5df04a1 100644 >>> --- a/drivers/thermal/samsung/exynos_tmu.c >>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>> @@ -30,6 +30,7 @@ >>> >>> #include "exynos_thermal_common.h" >>> #include "exynos_tmu.h" >>> +#include "exynos_tmu_data.h" >>> >>> /* Exynos generic registers */ >>> #define EXYNOS_TMU_REG_TRIMINFO 0x0 >>> @@ -381,66 +382,6 @@ static struct thermal_sensor_conf exynos_sensor_conf = >>> { >>> .write_emul_temp= exynos_tmu_set_emulation, >>> }; >>> >>> -#if defined(CONFIG_CPU_EXYNOS4210) >>> -static struct exynos_tmu_platform_data const exynos4210_default_tmu_data = >>> { >>> -.threshold = 80, >>> -.trigger_levels[0] = 5, >>> -.trigger_levels[1] = 20, >>> -.trigger_levels[2] = 30, >>> -.trigger_level0_en = 1, >>> -.trigger_level1_en = 1, >>> -.trigger_level2_en = 1, >>> -.trigger_level3_en = 0, >>> -.gain = 15, >>> -.reference_voltage = 7, >>> -.cal_type = TYPE_ONE_POINT_TRIMMING, >>> -.freq_tab[0] = { >>> -.freq_clip_max = 800 * 1000, >>> -.temp_level = 85, >>> -}, >>> -.freq_tab[1] = { >>> -.freq_clip_max = 200 * 1000, >>> -.temp_level = 100, >>> -}, >>> -.freq_tab_count = 2, >>> -.type = SOC_ARCH_EXYNOS4210, >>> -}; >>> -#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data) >>> -#else >>> -#define EXYNOS4210_TMU_DRV_DATA (NULL) >>> -#endif >
Re: [PATCH V6 09/30] thermal: exynos: Add extra entries in the tmu platform data
Hi Eduardo, On Thu, Jun 20, 2013 at 1:49 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This patch adds entries min_efuse_value, max_efuse_value, >> default_temp_offset, >> trigger_type, cal_type, trim_first_point, trim_second_point, >> max_trigger_level >> trigger_enable in the TMU platform data structure. Also the driver is >> modified >> to use the data passed by these new platform memebers instead of the constant >> macros. All these changes helps in separating the SOC specific data part from >> the TMU driver. >> >> Acked-by: Kukjin Kim >> Acked-by: Jonghwa Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/exynos_thermal_common.h |7 +++ >> drivers/thermal/samsung/exynos_tmu.c| 43 ++-- >> drivers/thermal/samsung/exynos_tmu.h| 49 >> ++ >> drivers/thermal/samsung/exynos_tmu_data.c | 35 >> 4 files changed, 86 insertions(+), 48 deletions(-) >> >> diff --git a/drivers/thermal/samsung/exynos_thermal_common.h >> b/drivers/thermal/samsung/exynos_thermal_common.h >> index 068f56c..fd789a5 100644 >> --- a/drivers/thermal/samsung/exynos_thermal_common.h >> +++ b/drivers/thermal/samsung/exynos_thermal_common.h >> @@ -44,6 +44,13 @@ >> >> #define EXYNOS_ZONE_COUNT3 >> >> +enum trigger_type { >> + THROTTLE_ACTIVE = 1, >> + THROTTLE_PASSIVE, >> + SW_TRIP, >> + HW_TRIP, >> +}; >> + >> /** >> * struct freq_clip_table >> * @freq_clip_max: maximum frequency allowed for this cooling state. >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index fa33a48..401ec98 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -49,7 +49,6 @@ >> #define EXYNOS_TMU_BUF_SLOPE_SEL_MASK0xf >> #define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 >> #define EXYNOS_TMU_CORE_EN_SHIFT 0 >> -#define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 >> >> /* Exynos4210 specific registers */ >> #define EXYNOS4210_TMU_REG_THRESHOLD_TEMP0x44 >> @@ -94,9 +93,6 @@ >> #define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 >> #define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 >> >> -#define EFUSE_MIN_VALUE 40 >> -#define EFUSE_MAX_VALUE 100 >> - >> #ifdef CONFIG_THERMAL_EMULATION >> #define EXYNOS_EMUL_TIME 0x57F0 >> #define EXYNOS_EMUL_TIME_MASK0x >> @@ -136,15 +132,16 @@ static int temp_to_code(struct exynos_tmu_data *data, >> u8 temp) >> >> switch (pdata->cal_type) { >> case TYPE_TWO_POINT_TRIMMING: >> - temp_code = (temp - 25) * >> - (data->temp_error2 - data->temp_error1) / >> - (85 - 25) + data->temp_error1; >> + temp_code = (temp - pdata->first_point_trim) * >> + (data->temp_error2 - data->temp_error1) / >> + (pdata->second_point_trim - pdata->first_point_trim) + >> + data->temp_error1; >> break; >> case TYPE_ONE_POINT_TRIMMING: >> - temp_code = temp + data->temp_error1 - 25; >> + temp_code = temp + data->temp_error1 - pdata->first_point_trim; >> break; >> default: >> - temp_code = temp + EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET; >> + temp_code = temp + pdata->default_temp_offset; >> break; >> } >> out: >> @@ -169,14 +166,16 @@ static int code_to_temp(struct exynos_tmu_data *data, >> u8 temp_code) >> >> switch (pdata->cal_type) { >> case TYPE_TWO_POINT_TRIMMING: >> - temp = (temp_code - data->temp_error1) * (85 - 25) / >> - (data->temp_error2 - data->temp_error1) + 25; >> + temp = (temp_code - data->temp_error1) * >> + (pdata->second_point_trim - pdata->first_point_trim) / >> + (data->temp_error2 - data->temp_error1) + >> + pdata->first_point_trim; >> break; >> case TYPE_ONE_POINT_TRIMMING: >> - temp = temp_code - data->temp_error1 + 25; >> + temp = temp_code - data->temp_error1 + pdata->first_point_trim; >> break; >> default: >> -
Re: [PATCH V6 09/30] thermal: exynos: Add extra entries in the tmu platform data
Hi, On Thu, Jun 20, 2013 at 2:22 AM, Eduardo Valentin wrote: > On 19-06-2013 16:19, Eduardo Valentin wrote: >> On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >>> This patch adds entries min_efuse_value, max_efuse_value, >>> default_temp_offset, >>> trigger_type, cal_type, trim_first_point, trim_second_point, >>> max_trigger_level >>> trigger_enable in the TMU platform data structure. Also the driver is >>> modified >>> to use the data passed by these new platform memebers instead of the >>> constant >>> macros. All these changes helps in separating the SOC specific data part >>> from >>> the TMU driver. >>> >>> Acked-by: Kukjin Kim >>> Acked-by: Jonghwa Lee >>> Signed-off-by: Amit Daniel Kachhap >>> --- >>> drivers/thermal/samsung/exynos_thermal_common.h |7 +++ >>> drivers/thermal/samsung/exynos_tmu.c| 43 ++-- >>> drivers/thermal/samsung/exynos_tmu.h| 49 >>> ++ >>> drivers/thermal/samsung/exynos_tmu_data.c | 35 >>> 4 files changed, 86 insertions(+), 48 deletions(-) >>> >>> diff --git a/drivers/thermal/samsung/exynos_thermal_common.h >>> b/drivers/thermal/samsung/exynos_thermal_common.h >>> index 068f56c..fd789a5 100644 >>> --- a/drivers/thermal/samsung/exynos_thermal_common.h >>> +++ b/drivers/thermal/samsung/exynos_thermal_common.h >>> @@ -44,6 +44,13 @@ >>> >>> #define EXYNOS_ZONE_COUNT 3 >>> >>> +enum trigger_type { >>> +THROTTLE_ACTIVE = 1, >>> +THROTTLE_PASSIVE, >>> +SW_TRIP, >>> +HW_TRIP, >>> +}; >>> + >>> /** >>> * struct freq_clip_table >>> * @freq_clip_max: maximum frequency allowed for this cooling state. >>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>> b/drivers/thermal/samsung/exynos_tmu.c >>> index fa33a48..401ec98 100644 >>> --- a/drivers/thermal/samsung/exynos_tmu.c >>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>> @@ -49,7 +49,6 @@ >>> #define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf >>> #define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 >>> #define EXYNOS_TMU_CORE_EN_SHIFT0 >>> -#define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 >>> >>> /* Exynos4210 specific registers */ >>> #define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 >>> @@ -94,9 +93,6 @@ >>> #define EXYNOS_TMU_INTEN_FALL1_SHIFT20 >>> #define EXYNOS_TMU_INTEN_FALL2_SHIFT24 >>> >>> -#define EFUSE_MIN_VALUE 40 >>> -#define EFUSE_MAX_VALUE 100 >>> - >>> #ifdef CONFIG_THERMAL_EMULATION >>> #define EXYNOS_EMUL_TIME0x57F0 >>> #define EXYNOS_EMUL_TIME_MASK 0x >>> @@ -136,15 +132,16 @@ static int temp_to_code(struct exynos_tmu_data *data, >>> u8 temp) >>> >>> switch (pdata->cal_type) { >>> case TYPE_TWO_POINT_TRIMMING: >>> -temp_code = (temp - 25) * >>> -(data->temp_error2 - data->temp_error1) / >>> -(85 - 25) + data->temp_error1; >>> +temp_code = (temp - pdata->first_point_trim) * >>> +(data->temp_error2 - data->temp_error1) / >>> +(pdata->second_point_trim - pdata->first_point_trim) + >>> +data->temp_error1; >>> break; >>> case TYPE_ONE_POINT_TRIMMING: >>> -temp_code = temp + data->temp_error1 - 25; >>> +temp_code = temp + data->temp_error1 - pdata->first_point_trim; >>> break; >>> default: >>> -temp_code = temp + EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET; >>> +temp_code = temp + pdata->default_temp_offset; >>> break; >>> } >>> out: >>> @@ -169,14 +166,16 @@ static int code_to_temp(struct exynos_tmu_data *data, >>> u8 temp_code) >>> >>> switch (pdata->cal_type) { >>> case TYPE_TWO_POINT_TRIMMING: >>> -temp = (temp_code - data->temp_error1) * (85 - 25) / >>> -(data->temp_error2 - data->temp_error1) + 25; >>> +temp = (temp_code - data->temp_error1) * >>> +(pdata->second_point_trim - pdata->first_point_trim) / >>> +
Re: [PATCH V6 16/30] thermal: exynos: Make the zone handling use trip information
Hi On Thu, Jun 20, 2013 at 4:33 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This code simplifies the zone handling to use the trip information passed >> by the TMU driver and not the hardcoded macros. This also helps in adding >> more zone support. >> >> Acked-by: Kukjin Kim >> Acked-by: Jonghwa Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/exynos_thermal_common.c | 61 >> +-- >> drivers/thermal/samsung/exynos_thermal_common.h |3 +- >> drivers/thermal/samsung/exynos_tmu.c|5 ++- >> 3 files changed, 40 insertions(+), 29 deletions(-) >> >> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c >> b/drivers/thermal/samsung/exynos_thermal_common.c >> index 86d39aa..2873ca3 100644 >> --- a/drivers/thermal/samsung/exynos_thermal_common.c >> +++ b/drivers/thermal/samsung/exynos_thermal_common.c >> @@ -78,17 +78,22 @@ static int exynos_set_mode(struct thermal_zone_device >> *thermal, >> static int exynos_get_trip_type(struct thermal_zone_device *thermal, int >> trip, >>enum thermal_trip_type *type) >> { >> - switch (GET_ZONE(trip)) { >> - case MONITOR_ZONE: >> - case WARN_ZONE: >> - *type = THERMAL_TRIP_ACTIVE; >> - break; >> - case PANIC_ZONE: >> - *type = THERMAL_TRIP_CRITICAL; >> - break; >> - default: >> + 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; >> + >> return 0; >> } >> >> @@ -97,8 +102,9 @@ 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 < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) >> + if (trip < 0 || trip >= max_trip) >> return -EINVAL; >> >> *temp = th_zone->sensor_conf->trip_data.trip_val[trip]; >> @@ -112,10 +118,10 @@ static int exynos_get_trip_temp(struct >> thermal_zone_device *thermal, int trip, >> static int exynos_get_crit_temp(struct thermal_zone_device *thermal, >> unsigned long *temp) >> { >> - int ret; >> - /* Panic zone */ >> - ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp); >> - return ret; >> + 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 */ >> @@ -340,19 +346,22 @@ int exynos_register_thermal(struct thermal_sensor_conf >> *sensor_conf) >> return -ENOMEM; >> >> th_zone->sensor_conf = sensor_conf; >> - cpumask_set_cpu(0, &mask_val); >> - th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); >> - if (IS_ERR(th_zone->cool_dev[0])) { >> - pr_err("Failed to register cpufreq cooling device\n"); >> - ret = -EINVAL; >> - goto err_unregister; >> + if (sensor_conf->cooling_data.freq_clip_count > 0) { >> + cpumask_set_cpu(0, &mask_val); >> + th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); > > Did you mean th_zone->cool_dev[th_zone->cool_dev_size] ? Yes. > > I think the logic behind the allocation of these cpufreq cooling devices > needs to be revisited. You always assigned to cool_dev[0], but you > always iterate the array until cool_dev_size. Remember that > cool_dev_size now is per th_zone, not global.
Re: [PATCH V6 18/30] thermal: exynos: Add support to handle many instances of TMU
Hi Eduardo, On Thu, Jun 20, 2013 at 4:57 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This patch adds support to handle multiple instances of the TMU controllers. >> This is done by removing the static structure to register with the core >> thermal >> and creating it dynamically for each instance of the TMU controller. The >> interrupt is made shared type to handle shared interrupts. Also >> the identifier of the TMU controller is extracted from device tree alias. >> >> Acked-by: Kukjin Kim >> Acked-by: Jonghwa Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/exynos_thermal_common.h |1 + >> drivers/thermal/samsung/exynos_tmu.c| 147 >> --- >> drivers/thermal/samsung/exynos_tmu.h| 13 ++ >> drivers/thermal/samsung/exynos_tmu_data.c | 145 >> -- >> drivers/thermal/samsung/exynos_tmu_data.h |4 +- >> 5 files changed, 197 insertions(+), 113 deletions(-) >> >> diff --git a/drivers/thermal/samsung/exynos_thermal_common.h >> b/drivers/thermal/samsung/exynos_thermal_common.h >> index dd0077e..0c189d6 100644 >> --- a/drivers/thermal/samsung/exynos_thermal_common.h >> +++ b/drivers/thermal/samsung/exynos_thermal_common.h >> @@ -84,6 +84,7 @@ struct thermal_sensor_conf { >> struct thermal_cooling_conf cooling_data; >> void *driver_data; >> void *pzone_data; >> + struct device *dev; >> }; >> >> /*Functions used exynos based thermal sensor driver*/ >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 4356118..1880c4e 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -26,15 +26,32 @@ >> #include >> #include >> #include >> +#include >> +#include >> #include >> >> #include "exynos_thermal_common.h" >> #include "exynos_tmu.h" >> #include "exynos_tmu_data.h" >> >> +/** >> + * struct exynos_tmu_data : A structure to hold the private data of the TMU >> + driver >> + * @id: identifier of the one instance of the TMU controller. >> + * @pdata: pointer to the tmu platform/configuration data >> + * @base: base address of the single instance of the TMU controller. >> + * @irq: irq number of the TMU controller. >> + * @soc: id of the SOC type. >> + * @irq_work: pointer to the irq work structure. >> + * @lock: lock to implement synchronization. >> + * @clk: pointer to the clock structure. >> + * @temp_error1: fused value of the first point trim. >> + * @temp_error2: fused value of the second point trim. >> + * @reg_conf: pointer to structure to register with core thermal. >> + */ >> struct exynos_tmu_data { >> + int id; >> struct exynos_tmu_platform_data *pdata; >> - struct resource *mem; >> void __iomem *base; >> int irq; >> enum soc_type soc; >> @@ -42,6 +59,7 @@ struct exynos_tmu_data { >> struct mutex lock; >> struct clk *clk; >> u8 temp_error1, temp_error2; >> + struct thermal_sensor_conf *reg_conf; >> }; >> >> /* >> @@ -345,12 +363,6 @@ static int exynos_tmu_set_emulation(void *drv_data, >> unsigned long temp) >> { return -EINVAL; } >> #endif/*CONFIG_THERMAL_EMULATION*/ >> >> -static struct thermal_sensor_conf exynos_sensor_conf = { >> - .name = "exynos-therm", >> - .read_temperature = (int (*)(void *))exynos_tmu_read, >> - .write_emul_temp= exynos_tmu_set_emulation, >> -}; >> - >> static void exynos_tmu_work(struct work_struct *work) >> { >> struct exynos_tmu_data *data = container_of(work, >> @@ -359,7 +371,7 @@ static void exynos_tmu_work(struct work_struct *work) >> const struct exynos_tmu_registers *reg = pdata->registers; >> unsigned int val_irq; >> >> - exynos_report_trigger(&exynos_sensor_conf); >> + exynos_report_trigger(data->reg_conf); >> mutex_lock(&data->lock); >> clk_enable(data->clk); >> >> @@ -404,33 +416,73 @@ MODULE_DEVICE_TABLE(of, exynos_tmu_match); >> #endif >> >> static inline struct exynos_tmu_platform_data *exynos_get_driver_data( >> - struct platform_device *pdev) >> + struct platf
Re: [PATCH V6 21/30] ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal bindings
On Thu, Jun 20, 2013 at 5:15 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> From: Lukasz Majewski >> >> Proper description for Exynos4 bindings added to Documentation/devicetree/ >> bindings >> >> Acked-by: Jonghwa Lee >> Signed-off-by: Lukasz Majewski >> Signed-off-by: Kyungmin Park >> Signed-off-by: Amit Daniel Kachhap >> --- >> .../devicetree/bindings/thermal/exynos-thermal.txt | 25 >> >> 1 files changed, 25 insertions(+), 0 deletions(-) >> create mode 100644 >> Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> >> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> new file mode 100644 >> index 000..535fd0e >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> @@ -0,0 +1,25 @@ >> +* Exynos Thermal Management Unit (TMU) >> + >> +** Required properties: >> + >> +- compatible : One of the following: >> +"samsung,exynos4412-tmu" >> +"samsung,exynos4210-tmu" >> +"samsung,exynos5250-tmu" >> +- interrupt-parent : The phandle for the interrupt controller >> +- reg : Address range of the thermal registers >> +- interrupts : Should contain interrupt for thermal system >> +- clocks : The main clock for TMU device >> +- clock-names : Thermal system clock name > > Should this include the documentation on the alias needed by patch 18? > tmuctrl? >Yes right it should be there. Actually It is there in the later patches. Will >re-submit this patch in proper order. > >> + >> +Example: >> + >> + tmu@100C { >> + compatible = "samsung,exynos4412-tmu"; >> + interrupt-parent = <&combiner>; >> + reg = <0x100C 0x100>; >> + interrupts = <2 4>; >> + clocks = <&clock 383>; >> + clock-names = "tmu_apbif"; >> + status = "disabled"; >> + }; >> > > > -- > You have got to be excited about what you are doing. (L. Lamport) > > Eduardo Valentin > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V6 23/30] thermal: exynos: Add driver support for exynos5440 TMU sensor
Hi Eduardo, On Thu, Jun 20, 2013 at 7:36 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This patch modifies TMU controller to add changes needed to work with >> exynos5440 platform. This sensor registers 3 instance of the tmu controller >> with the thermal zone and hence reports 3 temperature output. This controller >> supports upto five trip points. For critical threshold the driver uses the >> core driver thermal framework for shutdown. >> >> Acked-by: Jonghwa Lee >> Acked-by: Kukjin Kim >> Signed-off-by: Jungseok Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> .../devicetree/bindings/thermal/exynos-thermal.txt | 24 - >> drivers/thermal/samsung/exynos_thermal_common.h|2 +- >> drivers/thermal/samsung/exynos_tmu.c | 54 >> +--- >> drivers/thermal/samsung/exynos_tmu.h |6 ++ >> drivers/thermal/samsung/exynos_tmu_data.h | 36 + >> 5 files changed, 112 insertions(+), 10 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> index 0ea33f7..e6386ea 100644 >> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> @@ -6,6 +6,7 @@ >> "samsung,exynos4412-tmu" >> "samsung,exynos4210-tmu" >> "samsung,exynos5250-tmu" >> +"samsung,exynos5440-tmu" >> - interrupt-parent : The phandle for the interrupt controller >> - reg : Address range of the thermal registers. For soc's which has multiple >> instances of TMU and some registers are shared across all TMU's like >> @@ -16,7 +17,7 @@ >> - clocks : The main clock for TMU device >> - clock-names : Thermal system clock name >> >> -Example: >> +Example 1): >> >> tmu@100C { >> compatible = "samsung,exynos4412-tmu"; >> @@ -27,3 +28,24 @@ Example: >> clock-names = "tmu_apbif"; >> status = "disabled"; >> }; >> + >> +Example 2): >> + >> + tmuctrl_0: tmuctrl@160118 { >> + compatible = "samsung,exynos5440-tmu"; >> + reg = <0x160118 0x230>, <0x160368 0x10>; >> + interrupts = <0 58 0>; >> + clocks = <&clock 21>; >> + clock-names = "tmu_apbif"; >> + }; >> + >> +Note: For multi-instance tmu each instance should have an alias correctly >> +numbered in "aliases" node. >> + >> +Example: >> + >> +aliases { >> + tmuctrl0 = &tmuctrl_0; >> + tmuctrl1 = &tmuctrl_1; >> + tmuctrl2 = &tmuctrl_2; >> +}; >> diff --git a/drivers/thermal/samsung/exynos_thermal_common.h >> b/drivers/thermal/samsung/exynos_thermal_common.h >> index 0c189d6..7d7c29a 100644 >> --- a/drivers/thermal/samsung/exynos_thermal_common.h >> +++ b/drivers/thermal/samsung/exynos_thermal_common.h >> @@ -27,7 +27,7 @@ >> #define SENSOR_NAME_LEN 16 >> #define MAX_TRIP_COUNT 8 >> #define MAX_COOLING_DEVICE 4 >> -#define MAX_THRESHOLD_LEVS 4 >> +#define MAX_THRESHOLD_LEVS 5 >> >> #define ACTIVE_INTERVAL 500 >> #define IDLE_INTERVAL 1 >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 150a869..db4035d 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device >> *pdev) >> __raw_writel(1, data->base + reg->triminfo_ctrl); >> >> /* Save trimming info in order to perform calibration */ >> - trim_info = readl(data->base + reg->triminfo_data); >> + if (data->soc == SOC_ARCH_EXYNOS5440) { > > should this become some bit at your pdata->features? TMU_SUPPORTS(pdata, > TRIMINFO) for instance? Initially I also thought of getting rid of SOC checks completely but they have been retained in some rare cases. Here this a limitation in the h/w and very specific to exynos5440. So not sure if this can be added as a feature. > >> + /* >> + * For exynos5440 soc triminfo value is swapped between TMU0 >> and >> + * TMU2, so t
Re: [PATCH V6 24/30] thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor
Hi, On Thu, Jun 20, 2013 at 7:48 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This patch adds configuration data for exynos5440 soc. Also register >> definations for the controller are added. >> >> Acked-by: Jonghwa Lee >> Acked-by: Kukjin Kim >> Signed-off-by: Amit Daniel Kachhap >> --- >> drivers/thermal/samsung/exynos_tmu.c |4 ++ >> drivers/thermal/samsung/exynos_tmu_data.c | 71 >> + >> drivers/thermal/samsung/exynos_tmu_data.h |7 +++ >> 3 files changed, 82 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index db4035d..a4dbc84 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -455,6 +455,10 @@ static const struct of_device_id exynos_tmu_match[] = { >> .compatible = "samsung,exynos5250-tmu", >> .data = (void *)EXYNOS5250_TMU_DRV_DATA, >> }, >> + { >> + .compatible = "samsung,exynos5440-tmu", >> + .data = (void *)EXYNOS5440_TMU_DRV_DATA, >> + }, >> {}, >> }; >> MODULE_DEVICE_TABLE(of, exynos_tmu_match); >> diff --git a/drivers/thermal/samsung/exynos_tmu_data.c >> b/drivers/thermal/samsung/exynos_tmu_data.c >> index 694557e..b34e726 100644 >> --- a/drivers/thermal/samsung/exynos_tmu_data.c >> +++ b/drivers/thermal/samsung/exynos_tmu_data.c >> @@ -175,3 +175,74 @@ struct exynos_tmu_init_data const >> exynos5250_default_tmu_data = { >> .tmu_count = 1, >> }; >> #endif >> + >> +#if defined(CONFIG_SOC_EXYNOS5440) >> +static const struct exynos_tmu_registers exynos5440_tmu_registers = { >> + .triminfo_data = EXYNOS5440_TMU_S0_7_TRIM, >> + .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, >> + .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, >> + .tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL, >> + .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT, >> + .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK, >> + .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, >> + .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, >> + .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, >> + .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT, >> + .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK, >> + .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT, >> + .tmu_status = EXYNOS5440_TMU_S0_7_STATUS, >> + .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP, >> + .threshold_th0 = EXYNOS5440_TMU_S0_7_TH0, >> + .threshold_th1 = EXYNOS5440_TMU_S0_7_TH1, >> + .threshold_th2 = EXYNOS5440_TMU_S0_7_TH2, >> + .threshold_th3_l0_shift = EXYNOS5440_TMU_TH_RISE4_SHIFT, >> + .tmu_inten = EXYNOS5440_TMU_S0_7_IRQEN, >> + .inten_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK, >> + .inten_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT, >> + .inten_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK, >> + .inten_fall_shift = EXYNOS5440_TMU_FALL_INT_SHIFT, >> + .inten_rise0_shift = EXYNOS5440_TMU_INTEN_RISE0_SHIFT, >> + .inten_rise1_shift = EXYNOS5440_TMU_INTEN_RISE1_SHIFT, >> + .inten_rise2_shift = EXYNOS5440_TMU_INTEN_RISE2_SHIFT, >> + .inten_rise3_shift = EXYNOS5440_TMU_INTEN_RISE3_SHIFT, >> + .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT, >> + .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, >> + .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, >> + .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS, >> + .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, >> + .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, >> + .tmu_pmin = EXYNOS5440_TMU_PMIN, >> +}; >> + >> +#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, \ > > No active / passive cooling? > >> + .max_trigger_level = 5, \ >> + .gain = 5, \ >> + .reference_voltage = 16, \ >> + .noise_cancel_mode = 4, \ >> + .cal_type = TYPE_ONE_POINT_TRIMMING, \ >> + .cal_mode = 0, \ >> + .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, \ >> + .r
Re: [PATCH V6 24/30] thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor
On Fri, Jun 21, 2013 at 8:49 PM, amit daniel kachhap wrote: > Hi, > > On Thu, Jun 20, 2013 at 7:48 AM, Eduardo Valentin > wrote: >> On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >>> This patch adds configuration data for exynos5440 soc. Also register >>> definations for the controller are added. >>> >>> Acked-by: Jonghwa Lee >>> Acked-by: Kukjin Kim >>> Signed-off-by: Amit Daniel Kachhap >>> --- >>> drivers/thermal/samsung/exynos_tmu.c |4 ++ >>> drivers/thermal/samsung/exynos_tmu_data.c | 71 >>> + >>> drivers/thermal/samsung/exynos_tmu_data.h |7 +++ >>> 3 files changed, 82 insertions(+), 0 deletions(-) >>> >>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>> b/drivers/thermal/samsung/exynos_tmu.c >>> index db4035d..a4dbc84 100644 >>> --- a/drivers/thermal/samsung/exynos_tmu.c >>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>> @@ -455,6 +455,10 @@ static const struct of_device_id exynos_tmu_match[] = { >>> .compatible = "samsung,exynos5250-tmu", >>> .data = (void *)EXYNOS5250_TMU_DRV_DATA, >>> }, >>> + { >>> + .compatible = "samsung,exynos5440-tmu", >>> + .data = (void *)EXYNOS5440_TMU_DRV_DATA, >>> + }, >>> {}, >>> }; >>> MODULE_DEVICE_TABLE(of, exynos_tmu_match); >>> diff --git a/drivers/thermal/samsung/exynos_tmu_data.c >>> b/drivers/thermal/samsung/exynos_tmu_data.c >>> index 694557e..b34e726 100644 >>> --- a/drivers/thermal/samsung/exynos_tmu_data.c >>> +++ b/drivers/thermal/samsung/exynos_tmu_data.c >>> @@ -175,3 +175,74 @@ struct exynos_tmu_init_data const >>> exynos5250_default_tmu_data = { >>> .tmu_count = 1, >>> }; >>> #endif >>> + >>> +#if defined(CONFIG_SOC_EXYNOS5440) >>> +static const struct exynos_tmu_registers exynos5440_tmu_registers = { >>> + .triminfo_data = EXYNOS5440_TMU_S0_7_TRIM, >>> + .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, >>> + .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, >>> + .tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL, >>> + .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT, >>> + .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK, >>> + .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, >>> + .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, >>> + .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, >>> + .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT, >>> + .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK, >>> + .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT, >>> + .tmu_status = EXYNOS5440_TMU_S0_7_STATUS, >>> + .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP, >>> + .threshold_th0 = EXYNOS5440_TMU_S0_7_TH0, >>> + .threshold_th1 = EXYNOS5440_TMU_S0_7_TH1, >>> + .threshold_th2 = EXYNOS5440_TMU_S0_7_TH2, >>> + .threshold_th3_l0_shift = EXYNOS5440_TMU_TH_RISE4_SHIFT, >>> + .tmu_inten = EXYNOS5440_TMU_S0_7_IRQEN, >>> + .inten_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK, >>> + .inten_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT, >>> + .inten_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK, >>> + .inten_fall_shift = EXYNOS5440_TMU_FALL_INT_SHIFT, >>> + .inten_rise0_shift = EXYNOS5440_TMU_INTEN_RISE0_SHIFT, >>> + .inten_rise1_shift = EXYNOS5440_TMU_INTEN_RISE1_SHIFT, >>> + .inten_rise2_shift = EXYNOS5440_TMU_INTEN_RISE2_SHIFT, >>> + .inten_rise3_shift = EXYNOS5440_TMU_INTEN_RISE3_SHIFT, >>> + .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT, >>> + .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, >>> + .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, >>> + .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS, >>> + .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, >>> + .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, >>> + .tmu_pmin = EXYNOS5440_TMU_PMIN, >>> +}; >>> + >>> +#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, \ >> >> No active / passive cooling? >> >>> + .max_trigger_level = 5, \ >>> + .gain = 5, \ >>> + .reference_voltage = 16, \ >&
Re: [PATCH V6 08/30] thermal: exynos: Add missing definations and code cleanup
On Fri, Jun 21, 2013 at 8:01 PM, Eduardo Valentin wrote: > On 20-06-2013 22:01, amit daniel kachhap wrote: >> Hi Eduardo, >> >> On Thu, Jun 20, 2013 at 1:25 AM, Eduardo Valentin >> wrote: >>> On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >>>> This patch adds some extra register bitfield definations and cleans >>>> up the code to prepare for moving register macros and definations inside >>>> the TMU data section. >>>> >>>> Acked-by: Kukjin Kim >>>> Acked-by: Jonghwa Lee >>>> Signed-off-by: Amit Daniel Kachhap >>>> --- >>>> drivers/thermal/samsung/exynos_tmu.c | 62 >>>> +- >>>> 1 files changed, 46 insertions(+), 16 deletions(-) >>>> >>>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>>> b/drivers/thermal/samsung/exynos_tmu.c >>>> index 5df04a1..fa33a48 100644 >>>> --- a/drivers/thermal/samsung/exynos_tmu.c >>>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>>> @@ -43,9 +43,12 @@ >>>> >>>> #define EXYNOS_TMU_TRIM_TEMP_MASK0xff >>>> #define EXYNOS_TMU_GAIN_SHIFT8 >>>> +#define EXYNOS_TMU_GAIN_MASK 0xf >>>> #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 >>>> -#define EXYNOS_TMU_CORE_ON 3 >>>> -#define EXYNOS_TMU_CORE_OFF 2 >>>> +#define EXYNOS_TMU_REF_VOLTAGE_MASK 0x1f >>>> +#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK0xf >>>> +#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 >>>> +#define EXYNOS_TMU_CORE_EN_SHIFT 0 >>>> #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 >>>> >>>> /* Exynos4210 specific registers */ >>>> @@ -63,6 +66,7 @@ >>>> #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10 >>>> #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100 >>>> #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000 >>>> +#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x >>>> #define EXYNOS4210_TMU_INTCLEAR_VAL 0x >>>> >>>> /* Exynos5250 and Exynos4412 specific registers */ >>>> @@ -72,17 +76,30 @@ >>>> #define EXYNOS_EMUL_CON 0x80 >>>> >>>> #define EXYNOS_TRIMINFO_RELOAD 0x1 >>>> +#define EXYNOS_TRIMINFO_SHIFT0x0 >>>> +#define EXYNOS_TMU_RISE_INT_MASK 0x111 >>>> +#define EXYNOS_TMU_RISE_INT_SHIFT0 >>>> +#define EXYNOS_TMU_FALL_INT_MASK 0x111 >>>> +#define EXYNOS_TMU_FALL_INT_SHIFT12 >>>> #define EXYNOS_TMU_CLEAR_RISE_INT0x111 >>>> #define EXYNOS_TMU_CLEAR_FALL_INT(0x111 << 12) >>>> -#define EXYNOS_MUX_ADDR_VALUE6 >>>> -#define EXYNOS_MUX_ADDR_SHIFT20 >>>> #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 >>>> +#define EXYNOS_TMU_TRIP_MODE_MASK0x7 >>>> + >>>> +#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 >>>> +#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 >>>> +#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 >>>> +#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 >>>> +#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 >>>> +#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 >>>> +#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 >>>> >>>> #define EFUSE_MIN_VALUE 40 >>>> #define EFUSE_MAX_VALUE 100 >>>> >>>> #ifdef CONFIG_THERMAL_EMULATION >>>> #define EXYNOS_EMUL_TIME 0x57F0 >>>> +#define EXYNOS_EMUL_TIME_MASK0x >>>> #define EXYNOS_EMUL_TIME_SHIFT 16 >>>> #define EXYNOS_EMUL_DATA_SHIFT 8 >>>> #define EXYNOS_EMUL_DATA_MASK0xFF >>>> @@ -261,24 +278,37 @@ static void exynos_tmu_control(struct >>>> platform_device *pdev, bool on) >>>> mutex_lock(&data->lock); >>>> clk_enable(data->clk); >>>> >>>> - con = pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT | >>>> - pdata->gain << EXYNOS_TMU_GAIN_SHIFT; >>>> + con = readl(data->base + EXYNOS_TMU_REG_CONTROL); >>>> >>>> - if (data->soc == SOC_ARCH_EXYNOS) { >>>> - con |= pdata->noise_cancel_mode << >>>> EXYNOS_TMU_TRIP_MODE_SHIFT; >>>> - con |= (EXYNOS_MUX_ADDR_VALUE << EXYNOS_MUX_ADDR_SHIFT); >>>> + if (pdata
[PATCH V7 03/30] thermal: exynos: Remove un-necessary CPU_THERMAL dependency
This patch removes the dependency on CPU_THERMAL for compiling TMU driver. This is useful for cases when only TMU controller needs to be initialised without cpu cooling action. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Acked-by: Eduardo Valentin Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/Kconfig |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index 883a8a8..2cf31ad 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig @@ -1,7 +1,6 @@ config EXYNOS_THERMAL tristate "Temperature sensor on Samsung EXYNOS" depends on ARCH_HAS_BANDGAP - depends on CPU_THERMAL help If you say yes here you get support for TMU (Thermal Management Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V7 00/30] thermal: exynos: Re-structure driver and add support for exynos5440
Submitting V7 version with all comments fixed. Most of the patches are acked by Eduardo. All the un-acked patches are modified according to the review comments. If any comments please let me know. Thanks, Amit Daniel Changes in V7: * Fixed all the coding guidelines comments given by Eduardo. * Moved the request irq call below the core thermal registration as per discussion with Eduardo. * Appropriate logs/TODO's/comments added for some review comments which are still same as before, 1) calibration register setting still uses enums. 2) very few soc check's still left in the driver. 3) Cooling devices stored in an array in the exynos core thermal layer. Changes in V6: * Uses ARCH_HAS_BANDGAP config flag which is merged now in arm tree. (http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7758/1). * In this version patches 1, 2, 3, 4 and 30 are modified. Others are same as V5. * Added acked by from Jonghwa Lee. * Rebased against Thermal Maintainer next tree. Changes in V5: * Most of the changes in this version is as per suggestion from Jonghwa Lee. I have retained one to one mapping of platform data with TMU instances as the TMU's are different devices. In exynos5440 soc there is some register sharing across multiple TMU's but in exynos5420 there is no register between multiple TMU's, so the current implementation is useful to support both of the above. This patch uses localized ARCH_HAS_TMU Kconfig option and is a temporary solution until a more generic macro ARCH_HAS_BANDGAP is introduced as per discussion in the link https://patchwork.kernel.org/patch/2659001/. * trip type is passed as platform data. * HW trip is allowed only for maximum level. * Platform data structure is now abstracted inside 1 more structure to support multiple sensor TMU data. Changes in V4: Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below, * Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed. * Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs. * Wrote all register description documentation. * Split 5440 TMU support patch into controller change, configuration data and feature addition patches. * Remove all *LINUX_* in the header files. * Still regulator enable is kept optional but a TODO: comment is added to fix it later. Changes in V3: * Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang. Changes in V2: * Separated SOC data from TMU driver. This is as per suggestion from Eduardo. * Merged the new file created for exynos5440 TMU controller with the existing TMU controller code. * Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file. * Even the register definations/bitfields are treated as data as there is some variation across SOC's. This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone. Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Using it as it is needed. (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg17817.html) Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes. (https://patchwork.kernel.org/patch/1668371/) Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support. Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_BANDGAP) can be merged through exynos platform maintainer as this can cause merge conflict. All these patches are based on thermal maintainers git tree, git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next. Amit Daniel Kachhap (30): thermal: exynos: Moving exynos thermal files into samsung directory thermal: exynos: Use ARCH_HAS_BANDGAP config to know the supported soc's thermal: exynos: Remove un-necessary CPU_THERMAL dependency thermal: exynos: Bifurcate exynos thermal common and tmu controller code thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c thermal: exynos: Move exynos_thermal.h from include/* to driver/* folder thermal: exynos: Bifurcate exynos tmu driver and configuration data thermal: exynos: Add missing definations and code cleanup thermal: exynos: Add extra entries in the tmu platform data thermal: exynos: Move register definitions from driver to data file therma
[PATCH V7 28/30] Documentation: thermal: Explain the exynos thermal driver model
This patch updates the documentation to explain the driver model and file layout. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Acked-by: Eduardo Valentin Signed-off-by: Amit Daniel Kachhap --- Documentation/thermal/exynos_thermal | 43 ++--- 1 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Documentation/thermal/exynos_thermal b/Documentation/thermal/exynos_thermal index 2b46f67..9010c44 100644 --- a/Documentation/thermal/exynos_thermal +++ b/Documentation/thermal/exynos_thermal @@ -1,17 +1,17 @@ -Kernel driver exynos4_tmu +Kernel driver exynos_tmu = Supported chips: -* ARM SAMSUNG EXYNOS4 series of SoC - Prefix: 'exynos4-tmu' +* ARM SAMSUNG EXYNOS4, EXYNOS5 series of SoC Datasheet: Not publicly available Authors: Donggeun Kim +Authors: Amit Daniel -Description +TMU controller Description: +--- -This driver allows to read temperature inside SAMSUNG EXYNOS4 series of SoC. +This driver allows to read temperature inside SAMSUNG EXYNOS4/5 series of SoC. The chip only exposes the measured 8-bit temperature code value through a register. @@ -34,9 +34,9 @@ The three equations are: TI2: Trimming info for 85 degree Celsius (stored at TRIMINFO register) Temperature code measured at 85 degree Celsius which is unchanged -TMU(Thermal Management Unit) in EXYNOS4 generates interrupt +TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt when temperature exceeds pre-defined levels. -The maximum number of configurable threshold is four. +The maximum number of configurable threshold is five. The threshold levels are defined as follows: Level_0: current temperature > trigger_level_0 + threshold Level_1: current temperature > trigger_level_1 + threshold @@ -47,6 +47,31 @@ The threshold levels are defined as follows: through the corresponding registers. When an interrupt occurs, this driver notify kernel thermal framework -with the function exynos4_report_trigger. +with the function exynos_report_trigger. Although an interrupt condition for level_0 can be set, it can be used to synchronize the cooling action. + +TMU driver description: +--- + +The exynos thermal driver is structured as, + + Kernel Core thermal framework + (thermal_core.c, step_wise.c, cpu_cooling.c) + ^ + | + | +TMU configuration data ---> TMU Driver <--> Exynos Core thermal wrapper +(exynos_tmu_data.c) (exynos_tmu.c) (exynos_thermal_common.c) +(exynos_tmu_data.h) (exynos_tmu.h) (exynos_thermal_common.h) + +a) TMU configuration data: This consist of TMU register offsets/bitfields + described through structure exynos_tmu_registers. Also several + other platform data (struct exynos_tmu_platform_data) members + are used to configure the TMU. +b) TMU driver: This component initialises the TMU controller and sets different + thresholds. It invokes core thermal implementation with the call + exynos_report_trigger. +c) Exynos Core thermal wrapper: This provides 3 wrapper function to use the + Kernel core thermal framework. They are exynos_unregister_thermal, + exynos_register_thermal and exynos_report_trigger. -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V7 07/30] thermal: exynos: Bifurcate exynos tmu driver and configuration data
This code splits the exynos tmu driver code into SOC specific data parts. This will simplify adding new SOC specific data to the same TMU controller. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Acked-by: Eduardo Valentin Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/Kconfig |3 +- drivers/thermal/samsung/Makefile |1 + drivers/thermal/samsung/exynos_tmu.c | 67 ++--- drivers/thermal/samsung/exynos_tmu_data.c | 79 + drivers/thermal/samsung/exynos_tmu_data.h | 40 +++ 5 files changed, 126 insertions(+), 64 deletions(-) create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index f8100b1..b653f15 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig @@ -5,7 +5,8 @@ config EXYNOS_THERMAL If you say yes here you get support for the TMU (Thermal Management Unit) driver for SAMSUNG EXYNOS series of soc. This driver initialises the TMU, reports temperature and handles cooling action if defined. - This driver uses the exynos core thermal API's. + This driver uses the exynos core thermal API's and TMU configuration + data from the supported soc's. config EXYNOS_THERMAL_CORE bool "Core thermal framework support for EXYNOS SOC's" diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile index 22528d6..c09d830 100644 --- a/drivers/thermal/samsung/Makefile +++ b/drivers/thermal/samsung/Makefile @@ -3,4 +3,5 @@ # 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 6aa2fd2..5df04a1 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -30,6 +30,7 @@ #include "exynos_thermal_common.h" #include "exynos_tmu.h" +#include "exynos_tmu_data.h" /* Exynos generic registers */ #define EXYNOS_TMU_REG_TRIMINFO0x0 @@ -381,66 +382,6 @@ static struct thermal_sensor_conf exynos_sensor_conf = { .write_emul_temp= exynos_tmu_set_emulation, }; -#if defined(CONFIG_CPU_EXYNOS4210) -static struct exynos_tmu_platform_data const exynos4210_default_tmu_data = { - .threshold = 80, - .trigger_levels[0] = 5, - .trigger_levels[1] = 20, - .trigger_levels[2] = 30, - .trigger_level0_en = 1, - .trigger_level1_en = 1, - .trigger_level2_en = 1, - .trigger_level3_en = 0, - .gain = 15, - .reference_voltage = 7, - .cal_type = TYPE_ONE_POINT_TRIMMING, - .freq_tab[0] = { - .freq_clip_max = 800 * 1000, - .temp_level = 85, - }, - .freq_tab[1] = { - .freq_clip_max = 200 * 1000, - .temp_level = 100, - }, - .freq_tab_count = 2, - .type = SOC_ARCH_EXYNOS4210, -}; -#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data) -#else -#define EXYNOS4210_TMU_DRV_DATA (NULL) -#endif - -#if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412) -static struct exynos_tmu_platform_data const exynos_default_tmu_data = { - .threshold_falling = 10, - .trigger_levels[0] = 85, - .trigger_levels[1] = 103, - .trigger_levels[2] = 110, - .trigger_level0_en = 1, - .trigger_level1_en = 1, - .trigger_level2_en = 1, - .trigger_level3_en = 0, - .gain = 8, - .reference_voltage = 16, - .noise_cancel_mode = 4, - .cal_type = TYPE_ONE_POINT_TRIMMING, - .efuse_value = 55, - .freq_tab[0] = { - .freq_clip_max = 800 * 1000, - .temp_level = 85, - }, - .freq_tab[1] = { - .freq_clip_max = 200 * 1000, - .temp_level = 103, - }, - .freq_tab_count = 2, - .type = SOC_ARCH_EXYNOS, -}; -#define EXYNOS_TMU_DRV_DATA (&exynos_default_tmu_data) -#else -#define EXYNOS_TMU_DRV_DATA (NULL) -#endif - #ifdef CONFIG_OF static const struct of_device_id exynos_tmu_match[] = { { @@ -449,11 +390,11 @@ static const struct of_device_id exynos_tmu_match[] = { }, { .compatible = "samsung,exynos4412-tmu", - .data = (void *)EXYNOS_TMU_DRV_DATA, + .data = (void *)EXYNOS5250_TMU_DRV_DATA, }, { .compatible = "samsung,exynos5250-tmu", - .data = (void *)EXYNOS_TMU_DRV_DATA, + .data = (void
[PATCH V7 13/30] thermal: exynos: Add support for instance based register/unregister
This code modifies the thermal driver to have multiple thermal zone support by replacing the global thermal zone variable with device data member of thermal_zone_device. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Acked-by: Eduardo Valentin Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c | 51 --- drivers/thermal/samsung/exynos_thermal_common.h |9 ++-- drivers/thermal/samsung/exynos_tmu.c| 15 --- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index c9edc30..0b014e8 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -37,12 +37,11 @@ struct exynos_thermal_zone { bool bind; }; -static struct exynos_thermal_zone *th_zone; - /* 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; @@ -52,25 +51,26 @@ static int exynos_get_mode(struct thermal_zone_device *thermal, static int exynos_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { - if (!th_zone->therm_dev) { + struct exynos_thermal_zone *th_zone = thermal->devdata; + if (!th_zone) { pr_notice("thermal zone not registered\n"); return 0; } - mutex_lock(&th_zone->therm_dev->lock); + mutex_lock(&thermal->lock); if (mode == THERMAL_DEVICE_ENABLED && !th_zone->sensor_conf->trip_data.trigger_falling) - th_zone->therm_dev->polling_delay = IDLE_INTERVAL; + thermal->polling_delay = IDLE_INTERVAL; else - th_zone->therm_dev->polling_delay = 0; + thermal->polling_delay = 0; - mutex_unlock(&th_zone->therm_dev->lock); + mutex_unlock(&thermal->lock); th_zone->mode = mode; - thermal_zone_device_update(th_zone->therm_dev); + thermal_zone_device_update(thermal); pr_info("thermal polling set for duration=%d msec\n", - th_zone->therm_dev->polling_delay); + thermal->polling_delay); return 0; } @@ -97,6 +97,8 @@ static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal->devdata; + if (trip < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) return -EINVAL; @@ -123,6 +125,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, { 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; tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data; @@ -169,6 +172,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { int ret = 0, i, tab_size; + struct exynos_thermal_zone *th_zone = thermal->devdata; struct thermal_sensor_conf *data = th_zone->sensor_conf; if (th_zone->bind == false) @@ -211,6 +215,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, 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) { @@ -230,6 +235,7 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal, { void *data; int ret = -EINVAL; + struct exynos_thermal_zone *th_zone = thermal->devdata; if (!th_zone->sensor_conf) { pr_info("Temperature sensor not initialised\n"); @@ -277,14 +283,22 @@ static struct thermal_zone_device_ops const exynos_dev_ops = { * This function may be called from interrupt based temperature sensor * when threshold is changed. */ -void exynos_report_trigger(void) +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 (!th_zone || !th_zone->therm_dev) + if (!conf || !conf->pzone_data) { +
[PATCH V7 08/30] thermal: exynos: Add missing definations and code cleanup
This patch adds some extra register bitfield definations and cleans up the code to prepare for moving register macros and definations inside the TMU data section. In this code cleanup the TMU enable bit is correctly used as bit0 and bit1 is taken care which is reserve bit. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 62 +- 1 files changed, 46 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 5df04a1..fa33a48 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -43,9 +43,12 @@ #define EXYNOS_TMU_TRIM_TEMP_MASK 0xff #define EXYNOS_TMU_GAIN_SHIFT 8 +#define EXYNOS_TMU_GAIN_MASK 0xf #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 -#define EXYNOS_TMU_CORE_ON 3 -#define EXYNOS_TMU_CORE_OFF2 +#define EXYNOS_TMU_REF_VOLTAGE_MASK0x1f +#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf +#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 +#define EXYNOS_TMU_CORE_EN_SHIFT 0 #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 /* Exynos4210 specific registers */ @@ -63,6 +66,7 @@ #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK0x10 #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK0x100 #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK0x1000 +#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x #define EXYNOS4210_TMU_INTCLEAR_VAL0x /* Exynos5250 and Exynos4412 specific registers */ @@ -72,17 +76,30 @@ #define EXYNOS_EMUL_CON0x80 #define EXYNOS_TRIMINFO_RELOAD 0x1 +#define EXYNOS_TRIMINFO_SHIFT 0x0 +#define EXYNOS_TMU_RISE_INT_MASK 0x111 +#define EXYNOS_TMU_RISE_INT_SHIFT 0 +#define EXYNOS_TMU_FALL_INT_MASK 0x111 +#define EXYNOS_TMU_FALL_INT_SHIFT 12 #define EXYNOS_TMU_CLEAR_RISE_INT 0x111 #define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) -#define EXYNOS_MUX_ADDR_VALUE 6 -#define EXYNOS_MUX_ADDR_SHIFT 20 #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 +#define EXYNOS_TMU_TRIP_MODE_MASK 0x7 + +#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 +#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 +#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 +#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 +#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 +#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 +#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 #define EFUSE_MIN_VALUE 40 #define EFUSE_MAX_VALUE 100 #ifdef CONFIG_THERMAL_EMULATION #define EXYNOS_EMUL_TIME 0x57F0 +#define EXYNOS_EMUL_TIME_MASK 0x #define EXYNOS_EMUL_TIME_SHIFT 16 #define EXYNOS_EMUL_DATA_SHIFT 8 #define EXYNOS_EMUL_DATA_MASK 0xFF @@ -261,24 +278,37 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) mutex_lock(&data->lock); clk_enable(data->clk); - con = pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT | - pdata->gain << EXYNOS_TMU_GAIN_SHIFT; + con = readl(data->base + EXYNOS_TMU_REG_CONTROL); - if (data->soc == SOC_ARCH_EXYNOS) { - con |= pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT; - con |= (EXYNOS_MUX_ADDR_VALUE << EXYNOS_MUX_ADDR_SHIFT); + if (pdata->reference_voltage) { + con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << + EXYNOS_TMU_REF_VOLTAGE_SHIFT); + con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT; + } + + if (pdata->gain) { + con &= ~(EXYNOS_TMU_GAIN_MASK << EXYNOS_TMU_GAIN_SHIFT); + con |= (pdata->gain << EXYNOS_TMU_GAIN_SHIFT); + } + + if (pdata->noise_cancel_mode) { + con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << + EXYNOS_TMU_TRIP_MODE_SHIFT); + con |= (pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT); } if (on) { - con |= EXYNOS_TMU_CORE_ON; - interrupt_en = pdata->trigger_level3_en << 12 | - pdata->trigger_level2_en << 8 | - pdata->trigger_level1_en << 4 | - pdata->trigger_level0_en; + con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); + interrupt_en = + pdata->trigger_level3_en << EXYNOS_TMU_INTEN_RISE3_SHIFT | + pdata->trigger_level2_en << EXYNOS_TMU_INTEN_RISE2_SHIFT | + pdata->trigger_level1_en << EXYNOS_TMU_INTEN_RISE1_SHIFT | + pdata->trigger_level0_en << EXYNOS_TMU_INTEN_RISE0_SHIFT; if (pdata->threshold_falling) - interrupt_en |= interrupt_en << 16; + interru
[PATCH V7 30/30] arm: exynos: enable ARCH_HAS_BANDGAP
This patch enables ARCH_HAS_BANDGAP config for exynos4210, 4212, 4412, 5250 and 5440 SOC. This config symbol is recently added to allow the platforms to enable bandgap based temperature sensor. Acked-by: Jonghwa Lee Signed-off-by: Amit Daniel Kachhap --- arch/arm/mach-exynos/Kconfig |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index d19edff..d3cb5c7 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -33,6 +33,7 @@ config CPU_EXYNOS4210 bool "SAMSUNG EXYNOS4210" default y depends on ARCH_EXYNOS4 + select ARCH_HAS_BANDGAP select ARM_CPU_SUSPEND if PM select PM_GENERIC_DOMAINS select S5P_PM if PM @@ -45,6 +46,7 @@ config SOC_EXYNOS4212 bool "SAMSUNG EXYNOS4212" default y depends on ARCH_EXYNOS4 + select ARCH_HAS_BANDGAP select S5P_PM if PM select S5P_SLEEP if PM select SAMSUNG_DMADEV @@ -55,6 +57,7 @@ config SOC_EXYNOS4412 bool "SAMSUNG EXYNOS4412" default y depends on ARCH_EXYNOS4 + select ARCH_HAS_BANDGAP select SAMSUNG_DMADEV help Enable EXYNOS4412 SoC support @@ -63,6 +66,7 @@ config SOC_EXYNOS5250 bool "SAMSUNG EXYNOS5250" default y depends on ARCH_EXYNOS5 + select ARCH_HAS_BANDGAP select PM_GENERIC_DOMAINS if PM select S5P_PM if PM select S5P_SLEEP if PM @@ -76,6 +80,7 @@ config SOC_EXYNOS5440 default y depends on ARCH_EXYNOS5 select ARCH_HAS_OPP + select ARCH_HAS_BANDGAP select ARM_ARCH_TIMER select AUTO_ZRELADDR select PINCTRL -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V7 10/30] thermal: exynos: Move register definitions from driver to data file
This patch migrates the TMU register definition/bitfields to data file. This is needed to support SoC's which use the same TMU controller but register validity, offsets or bitfield may slightly vary across SOC's. Acked-by: Kukjin Kim Acked-by: Jonghwa Lee Acked-by: Eduardo Valentin Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 172 +--- drivers/thermal/samsung/exynos_tmu.h | 133 ++ drivers/thermal/samsung/exynos_tmu_data.c | 59 ++ drivers/thermal/samsung/exynos_tmu_data.h | 68 +++ 4 files changed, 315 insertions(+), 117 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 401ec98..6fd776f 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -32,76 +32,6 @@ #include "exynos_tmu.h" #include "exynos_tmu_data.h" -/* Exynos generic registers */ -#define EXYNOS_TMU_REG_TRIMINFO0x0 -#define EXYNOS_TMU_REG_CONTROL 0x20 -#define EXYNOS_TMU_REG_STATUS 0x28 -#define EXYNOS_TMU_REG_CURRENT_TEMP0x40 -#define EXYNOS_TMU_REG_INTEN 0x70 -#define EXYNOS_TMU_REG_INTSTAT 0x74 -#define EXYNOS_TMU_REG_INTCLEAR0x78 - -#define EXYNOS_TMU_TRIM_TEMP_MASK 0xff -#define EXYNOS_TMU_GAIN_SHIFT 8 -#define EXYNOS_TMU_GAIN_MASK 0xf -#define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 -#define EXYNOS_TMU_REF_VOLTAGE_MASK0x1f -#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf -#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 -#define EXYNOS_TMU_CORE_EN_SHIFT 0 - -/* Exynos4210 specific registers */ -#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL1 0x54 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL2 0x58 -#define EXYNOS4210_TMU_REG_TRIG_LEVEL3 0x5C -#define EXYNOS4210_TMU_REG_PAST_TEMP0 0x60 -#define EXYNOS4210_TMU_REG_PAST_TEMP1 0x64 -#define EXYNOS4210_TMU_REG_PAST_TEMP2 0x68 -#define EXYNOS4210_TMU_REG_PAST_TEMP3 0x6C - -#define EXYNOS4210_TMU_TRIG_LEVEL0_MASK0x1 -#define EXYNOS4210_TMU_TRIG_LEVEL1_MASK0x10 -#define EXYNOS4210_TMU_TRIG_LEVEL2_MASK0x100 -#define EXYNOS4210_TMU_TRIG_LEVEL3_MASK0x1000 -#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x -#define EXYNOS4210_TMU_INTCLEAR_VAL0x - -/* Exynos5250 and Exynos4412 specific registers */ -#define EXYNOS_TMU_TRIMINFO_CON0x14 -#define EXYNOS_THD_TEMP_RISE 0x50 -#define EXYNOS_THD_TEMP_FALL 0x54 -#define EXYNOS_EMUL_CON0x80 - -#define EXYNOS_TRIMINFO_RELOAD 0x1 -#define EXYNOS_TRIMINFO_SHIFT 0x0 -#define EXYNOS_TMU_RISE_INT_MASK 0x111 -#define EXYNOS_TMU_RISE_INT_SHIFT 0 -#define EXYNOS_TMU_FALL_INT_MASK 0x111 -#define EXYNOS_TMU_FALL_INT_SHIFT 12 -#define EXYNOS_TMU_CLEAR_RISE_INT 0x111 -#define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) -#define EXYNOS_TMU_TRIP_MODE_SHIFT 13 -#define EXYNOS_TMU_TRIP_MODE_MASK 0x7 - -#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 -#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 -#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 -#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 -#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 -#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 -#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 - -#ifdef CONFIG_THERMAL_EMULATION -#define EXYNOS_EMUL_TIME 0x57F0 -#define EXYNOS_EMUL_TIME_MASK 0x -#define EXYNOS_EMUL_TIME_SHIFT 16 -#define EXYNOS_EMUL_DATA_SHIFT 8 -#define EXYNOS_EMUL_DATA_MASK 0xFF -#define EXYNOS_EMUL_ENABLE 0x1 -#endif /* CONFIG_THERMAL_EMULATION */ - struct exynos_tmu_data { struct exynos_tmu_platform_data *pdata; struct resource *mem; @@ -186,6 +116,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_platform_data *pdata = data->pdata; + const struct exynos_tmu_registers *reg = pdata->registers; unsigned int status, trim_info; unsigned int rising_threshold = 0, falling_threshold = 0; int ret = 0, threshold_code, i, trigger_levs = 0; @@ -193,20 +124,20 @@ static int exynos_tmu_initialize(struct platform_device *pdev) mutex_lock(&data->lock); clk_enable(data->clk); - status = readb(data->base + EXYNOS_TMU_REG_STATUS); + status = readb(data->base + reg->tmu_status); if (!status) { ret = -EBUSY; goto out; } - if (data->soc == SOC_ARCH_EXYNOS) { - __raw_writel(EXYNOS_TRIMINFO_RELOAD, - data->base + EXYNOS_TMU_TRIMINFO_CON); - } + if (data->soc == SOC_ARCH_EXYNOS) + __raw_writel(1, data->base + reg->triminfo_ctrl); + /* Save trimming