public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 6/7] omap4: thermal: add basic CPU thermal zone
@ 2012-06-27 18:05 Konstantin Baydarov
  2012-06-28  5:12 ` Eduardo Valentin
  0 siblings, 1 reply; 4+ messages in thread
From: Konstantin Baydarov @ 2012-06-27 18:05 UTC (permalink / raw)
  To: b-cousson, kishon, santosh.shilimkar, tony, paul
  Cc: balbi, amit.kucheria, linux-pm, linux-arm-kernel, linux-omap,
	amit.kachhap, Eduardo Valentin

    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

    Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 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

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index f9989e8..7d44b5c 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -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.
+
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 5ff1af1..6397678 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -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
diff --git a/drivers/thermal/omap-bandgap.c b/drivers/thermal/omap-bandgap.c
index c68fa1a..c80d879 100644
--- a/drivers/thermal/omap-bandgap.c
+++ b/drivers/thermal/omap-bandgap.c
@@ -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 = {
 		{
diff --git a/drivers/thermal/omap-bandgap.h b/drivers/thermal/omap-bandgap.h
index 41f25ff..3f4c192 100644
--- a/drivers/thermal/omap-bandgap.h
+++ b/drivers/thermal/omap-bandgap.h
@@ -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
diff --git a/drivers/thermal/omap4-thermal.c b/drivers/thermal/omap4-thermal.c
new file mode 100644
index 0000000..fb11753
--- /dev/null
+++ b/drivers/thermal/omap4-thermal.c
@@ -0,0 +1,72 @@
+/*
+ * SPEAr thermal driver.
+ *
+ * Copyright (C) 2011-2012 Texas Instruments Inc.
+ * Contact:
+ *	Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * 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;
+}
-- 
1.7.7.6



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

* Re: [PATCH v3 6/7] omap4: thermal: add basic CPU thermal zone
  2012-06-27 18:05 [PATCH v3 6/7] omap4: thermal: add basic CPU thermal zone Konstantin Baydarov
@ 2012-06-28  5:12 ` Eduardo Valentin
  2012-06-28  5:16   ` R, Durgadoss
  0 siblings, 1 reply; 4+ messages in thread
From: Eduardo Valentin @ 2012-06-28  5:12 UTC (permalink / raw)
  To: Konstantin Baydarov
  Cc: balbi, kishon, amit.kucheria, linux-pm, linux-omap,
	linux-arm-kernel

On Wed, Jun 27, 2012 at 10:05:11PM +0400, Konstantin Baydarov wrote:
>     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
> 
>     Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
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.

> ---
>  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
> 
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index f9989e8..7d44b5c 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -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.
> +
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 5ff1af1..6397678 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -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
> diff --git a/drivers/thermal/omap-bandgap.c b/drivers/thermal/omap-bandgap.c
> index c68fa1a..c80d879 100644
> --- a/drivers/thermal/omap-bandgap.c
> +++ b/drivers/thermal/omap-bandgap.c
> @@ -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 = {
>  		{
> diff --git a/drivers/thermal/omap-bandgap.h b/drivers/thermal/omap-bandgap.h
> index 41f25ff..3f4c192 100644
> --- a/drivers/thermal/omap-bandgap.h
> +++ b/drivers/thermal/omap-bandgap.h
> @@ -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
> diff --git a/drivers/thermal/omap4-thermal.c b/drivers/thermal/omap4-thermal.c
> new file mode 100644
> index 0000000..fb11753
> --- /dev/null
> +++ b/drivers/thermal/omap4-thermal.c
> @@ -0,0 +1,72 @@
> +/*
> + * SPEAr thermal driver.
> + *
> + * Copyright (C) 2011-2012 Texas Instruments Inc.
> + * Contact:
> + *	Eduardo Valentin <eduardo.valentin@ti.com>
> + *
> + * 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;
> +}
> -- 
> 1.7.7.6
> 
> 

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

* Re: [PATCH v3 6/7] omap4: thermal: add basic CPU thermal zone
  2012-06-28  5:12 ` Eduardo Valentin
@ 2012-06-28  5:16   ` R, Durgadoss
  2012-06-28  5:24     ` Eduardo Valentin
  0 siblings, 1 reply; 4+ messages in thread
From: R, Durgadoss @ 2012-06-28  5:16 UTC (permalink / raw)
  To: eduardo.valentin@ti.com, Konstantin Baydarov
  Cc: amit.kucheria@linaro.org, kishon@ti.com, balbi@ti.com,
	linux-pm@lists.linux-foundation.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

Hi,

> > +
> > +	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

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

* Re: [PATCH v3 6/7] omap4: thermal: add basic CPU thermal zone
  2012-06-28  5:16   ` R, Durgadoss
@ 2012-06-28  5:24     ` Eduardo Valentin
  0 siblings, 0 replies; 4+ messages in thread
From: Eduardo Valentin @ 2012-06-28  5:24 UTC (permalink / raw)
  To: R, Durgadoss
  Cc: Konstantin Baydarov, amit.kucheria@linaro.org, kishon@ti.com,
	balbi@ti.com, linux-pm@lists.linux-foundation.org,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org

Hello Durga,

On Thu, Jun 28, 2012 at 05:16:43AM +0000, R, Durgadoss wrote:
> Hi,
> 
> > > +
> > > +	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.

Ok. Thanks for the heads up. I will have a look on linux-next.

> 
> Thanks,
> Durga

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

end of thread, other threads:[~2012-06-28  5:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-27 18:05 [PATCH v3 6/7] omap4: thermal: add basic CPU thermal zone Konstantin Baydarov
2012-06-28  5:12 ` Eduardo Valentin
2012-06-28  5:16   ` R, Durgadoss
2012-06-28  5:24     ` Eduardo Valentin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox