omap4: thermal: add basic CPU thermal zone
PATCH v3 6/7 omap4: thermal: add basic CPU thermal zone
omap4: thermal: add basic CPU thermal zone
This patch exposes OMAP4 thermal sensor as a thermal zone named "cpu". Only thermal creation is done here.
TODO:
- Add cooling bindings
- Add extrapolation rules
--- drivers/thermal/Kconfig | 12 ++++++ drivers/thermal/Makefile | 1 + drivers/thermal/omap-bandgap.c | 1 + drivers/thermal/omap-bandgap.h | 12 ++++++ drivers/thermal/omap4-thermal.c | 72 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 0 deletions(-) create mode 100644 drivers/thermal/omap4-thermal.c
drivers/thermal/Kconfig +12 -0
@@ -38,3 +38,15 @@ config OMAP_BANDGAP This includes alert interrupts generation and also the TSHUT support. +config OMAP4_THERMAL + bool "Texas Instruments OMAP4 thermal support" + depends on OMAP_BANDGAP + depends on ARCH_OMAP4 + help + If you say yes here you get thermal support for the Texas Instruments + OMAP4 SoC family. The current chip supported are: + - OMAP4460 + + This includes alert interrupts generation and also the TSHUT + support. +
drivers/thermal/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_THERMAL) += thermal_sys.o obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o obj-$(CONFIG_OMAP_BANDGAP) += omap-thermal.o omap-thermal-y := omap-bandgap.o +omap-thermal-$(CONFIG_OMAP4_THERMAL) += omap4-thermal.o
drivers/thermal/omap-bandgap.c +1 -0
@@ -1328,6 +1328,7 @@ static const struct omap_bandgap_data omap4460_data = { .fclock_name = "bandgap_ts_fclk", .div_ck_name = "div_ts_ck", .conv_table = omap4460_adc_to_temp, + .expose_sensor = omap4_thermal_expose_sensor, .irq = 126, .sensors = { {
drivers/thermal/omap-bandgap.h +12 -0
@@ -61,4 +61,16 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr, int id,int omap_bandgap_read_temperature (struct omap_bandgap *bg_ptr,int id,int *temperature); +#ifdef CONFIG_OMAP4_THERMAL +int omap4_thermal_expose_sensor (struct omap_bandgap *bg_ptr,int id, +char *domain); +#else +static inline int omap4_thermal_expose_sensor (struct omap_bandgap *bg_ptr, +int id,char *domain) +{ +return 0 ; +} + +#endif +#endif
drivers/thermal/omap4-thermal.c new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
1.7.7.6
PATCH v3 6/7 omap4: thermal: add basic CPU thermal zone
Quoted 11 lines · Konstantin Baydarov
omap4: thermal: add basic CPU thermal zone
This patch exposes OMAP4 thermal sensor as a thermal zone named "cpu". Only thermal creation is done here.
TODO:
- Add cooling bindings
- Add extrapolation rulesSigned-off-by Eduardo Valentin <[email protected]>
You change the authorship and don't sign?
Anyway, this one has a lot to evolve still. I will send to you an improved version of the BG driver.
Quoted 153 lines
--- drivers/thermal/Kconfig | 12 ++++++ drivers/thermal/Makefile | 1 + drivers/thermal/omap-bandgap.c | 1 + drivers/thermal/omap-bandgap.h | 12 ++++++ drivers/thermal/omap4-thermal.c | 72 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 0 deletions(-) create mode 100644 drivers/thermal/omap4-thermal.cdrivers/thermal/Kconfig +12
-0@@ -38,3 +38,15 @@ config OMAP_BANDGAP This includes alert interrupts generation and also the TSHUT support. +config OMAP4_THERMAL + bool "Texas Instruments OMAP4 thermal support" + depends on OMAP_BANDGAP + depends on ARCH_OMAP4 + help + If you say yes here you get thermal support for the Texas Instruments + OMAP4 SoC family. The current chip supported are: + - OMAP4460 + + This includes alert interrupts generation and also the TSHUT + support. +drivers/thermal/Makefile +1
-0@@ -6,3 +6,4 @@ obj-$(CONFIG_THERMAL) += thermal_sys.o obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o obj-$(CONFIG_OMAP_BANDGAP) += omap-thermal.o omap-thermal-y := omap-bandgap.o +omap-thermal-$(CONFIG_OMAP4_THERMAL) += omap4-thermal.odrivers/thermal/omap-bandgap.c +1
-0@@ -1328,6 +1328,7 @@ static const struct omap_bandgap_data omap4460_data = { .fclock_name = "bandgap_ts_fclk", .div_ck_name = "div_ts_ck", .conv_table = omap4460_adc_to_temp, + .expose_sensor = omap4_thermal_expose_sensor, .irq = 126, .sensors = { {drivers/thermal/omap-bandgap.h +12
-0@@ -61,4 +61,16 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr, int id,int omap_bandgap_read_temperature (struct omap_bandgap *bg_ptr,int id,int *temperature); +#ifdef CONFIG_OMAP4_THERMAL +int omap4_thermal_expose_sensor (struct omap_bandgap *bg_ptr,int id, +char *domain); +#else +static inline int omap4_thermal_expose_sensor (struct omap_bandgap *bg_ptr, +int id,char *domain) +{ +return 0 ; +} + +#endif +#endif drivers/thermal/omap4-thermal.c new file +72
-0@@ -0,0 +1,72 @@ +/* +* SPEAr thermal driver. +* +* Copyright (C) 2011-2012 Texas Instruments Inc. +* Contact: +* Eduardo Valentin <[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/device.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/thermal.h> + +#include "omap-bandgap.h" + +struct omap4_thermal_data { +struct thermal_zone_device *omap4_thermal; +struct omap_bandgap *bg_ptr; +int sensor_id; +}; + +static inline int omap4_thermal_get_temp (struct thermal_zone_device *thermal, +unsigned long *temp) +{ +struct omap4_thermal_data *data = thermal->devdata; +int ret, tmp; + + ret =omap_bandgap_read_temperature (data->bg_ptr, data->sensor_id, + &tmp); +if (!ret) + *temp = tmp; + +return ret; +} + +static struct thermal_zone_device_ops omap4_thermal_ops = { + .get_temp = omap4_thermal_get_temp, +}; + +int omap4_thermal_expose_sensor (struct omap_bandgap *bg_ptr,int id, +char *domain) +{ +struct omap4_thermal_data *data; + + data =devm_kzalloc (bg_ptr->dev,sizeof (*data),GFP_KERNEL ); +if (!data) { +dev_err (bg_ptr->dev,"kzalloc fail\n" ); +return -ENOMEM ; + } + data->sensor_id = id; + data->bg_ptr = bg_ptr; + data->omap4_thermal =thermal_zone_device_register (domain,0 , + data, &omap4_thermal_ops,0 ,0 ,0 ,0 ); +if (IS_ERR (data->omap4_thermal)) { +dev_err (bg_ptr->dev,"thermal zone device is NULL\n" ); +return PTR_ERR (data->omap4_thermal); + } + +return 0 ; +}Signature · 1 line
1.7.7.6
PATCH v3 6/7 omap4: thermal: add basic CPU thermal zone
Hi,
Quoted 10 lines
drivers/thermal/omap4-thermal.c line 65
Quoted 10 lines
drivers/thermal/omap4-thermal.c new file +10
-0+ + data =devm_kzalloc (bg_ptr->dev,sizeof (*data),GFP_KERNEL ); +if (!data) { +dev_err (bg_ptr->dev,"kzalloc fail\n" ); +return -ENOMEM ; + } + data->sensor_id = id; + data->bg_ptr = bg_ptr; + data->omap4_thermal =thermal_zone_device_register (domain,0 , + data, &omap4_thermal_ops,0 ,0 ,0 ,0 );
Please watch out for changes on this API.
The third argument is the flag for writeable trip points. This patch is in linux-next. So, kindly have a look at this API implementation in thermal_sys.c in linux-next, when you submit this patch next time.
Thanks,
Durga
PATCH v3 6/7 omap4: thermal: add basic CPU thermal zone
Hello Durga,
Quoted 18 lines · Durgadoss
Hi,
Quoted 10 lines
drivers/thermal/omap4-thermal.c line 65
Quoted 10 lines
drivers/thermal/omap4-thermal.c new file +10
-0+ + data =devm_kzalloc (bg_ptr->dev,sizeof (*data),GFP_KERNEL ); +if (!data) { +dev_err (bg_ptr->dev,"kzalloc fail\n" ); +return -ENOMEM ; + } + data->sensor_id = id; + data->bg_ptr = bg_ptr; + data->omap4_thermal =thermal_zone_device_register (domain,0 , + data, &omap4_thermal_ops,0 ,0 ,0 ,0 );Please watch out for changes on this API.
The third argument is the flag for writeable trip points. This patch is in linux-next. So, kindly have a look at this API implementation inthermal_sys.cin linux-next, when you submit this patch next time.
Ok. Thanks for the heads up. I will have a look on linux-next.
Quoted 3 lines
Thanks,
Durga