* [RFC PATCH 0/3] thermal: exynos: Add kernel thermal support for exynos platform
@ 2011-12-21 12:11 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 11:59 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linux-kernel, mjg59, linux-acpi, lenb, linaro-dev, lm-sensors,
amit.kachhap, patches
All the patchset based on Kernel version 3.2-rc6 and uses the cpufreq
cooling registration api's implemented in earlier patchset
http://www.spinics.net/lists/linux-pm/msg26500.html
The code added in this patchset adds a thermal interface layer for samsung
exynos platforms. This layer is registered from the hwmon based temperature
sensor and recieves/monitor the temperature from the sensor and informs the
generic thermal layer to take the necessary cooling action. Currently this
layer can be used to create only one thermal zone and hence only one
temperature sensor can register.
Some modifications are done in the temperature sensor driver to export the
information needed for the thermal interface to register with the core linux
thermal framework and with the cpu frequency based cooling devices.
A simple data/control flow diagrams to illustrate this,
Core Linux thermal <-------> Exynos thermal <-------- Temperature Sensor
| |
\|/ |
Cpufreq cooling device <-----
Amit Daniel Kachhap (3):
thermal: exynos: Add thermal interface support for linux thermal
layer
thermal: exynos4: Register the tmu sensor with the thermal interface
layer
ARM: exynos4: Add thermal sensor driver platform device support
arch/arm/mach-exynos/Kconfig | 12 ++
arch/arm/mach-exynos/Makefile | 1 +
arch/arm/mach-exynos/clock.c | 4 +
arch/arm/mach-exynos/dev-tmu.c | 64 +++++++
arch/arm/mach-exynos/include/mach/irqs.h | 2 +
arch/arm/mach-exynos/include/mach/map.h | 1 +
arch/arm/mach-exynos/mach-origen.c | 1 +
arch/arm/plat-samsung/include/plat/devs.h | 1 +
drivers/hwmon/exynos4_tmu.c | 34 ++++-
drivers/thermal/Kconfig | 8 +
drivers/thermal/Makefile | 1 +
drivers/thermal/exynos_thermal.c | 255 +++++++++++++++++++++++++++++
include/linux/exynos_thermal.h | 59 +++++++
include/linux/platform_data/exynos4_tmu.h | 7 +
14 files changed, 447 insertions(+), 3 deletions(-)
create mode 100644 arch/arm/mach-exynos/dev-tmu.c
create mode 100644 drivers/thermal/exynos_thermal.c
create mode 100644 include/linux/exynos_thermal.h
^ permalink raw reply [flat|nested] 25+ messages in thread
* [RFC PATCH 1/3] thermal: exynos: Add thermal interface support for linux thermal layer
2011-12-21 12:11 ` [lm-sensors] [RFC PATCH 0/3] thermal: exynos: Add kernel thermal Amit Daniel Kachhap
(?)
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
-1 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 11:59 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linaro-dev, patches, linux-kernel, lm-sensors, linux-acpi
This codes uses the generic linux thermal layer and creates a bridge
between temperature sensors, linux thermal framework and cooling devices
for samsung exynos platform. This layer recieves or monitor the
temperature from the sensor and informs the generic thermal layer to take
the necessary cooling action.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
drivers/thermal/Kconfig | 8 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/exynos_thermal.c | 255 ++++++++++++++++++++++++++++++++++++++
include/linux/exynos_thermal.h | 59 +++++++++
4 files changed, 323 insertions(+), 0 deletions(-)
create mode 100644 drivers/thermal/exynos_thermal.c
create mode 100644 include/linux/exynos_thermal.h
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 298c1cd..4e8df56 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -29,3 +29,11 @@ config CPU_THERMAL
This will be useful for platforms using the generic thermal interface
and not the ACPI interface.
If you want this support, you should say Y or M here.
+
+config SAMSUNG_THERMAL_INTERFACE
+ bool "Samsung Thermal interface support"
+ depends on THERMAL && CPU_THERMAL
+ help
+ This is a samsung thermal interface which will be used as
+ a link between sensors and cooling devices with linux thermal
+ framework.
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 655cbc4..c67b6b2 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -4,3 +4,4 @@
obj-$(CONFIG_THERMAL) += thermal_sys.o
obj-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
+obj-$(CONFIG_SAMSUNG_THERMAL_INTERFACE) += exynos_thermal.o
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
new file mode 100644
index 0000000..7c916db
--- /dev/null
+++ b/drivers/thermal/exynos_thermal.c
@@ -0,0 +1,255 @@
+/* linux/drivers/thermal/exynos_thermal.c
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/thermal.h>
+#include <linux/platform_device.h>
+#include <linux/cpufreq.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/cpu_cooling.h>
+#include <linux/platform_data/exynos4_tmu.h>
+#include <linux/exynos_thermal.h>
+
+struct exynos4_thermal_zone {
+ unsigned int idle_interval;
+ unsigned int active_interval;
+ struct thermal_zone_device *therm_dev;
+ struct thermal_cooling_device *cool_dev;
+ struct platform_device *exynos4_dev;
+ struct thermal_sensor_conf *sensor_conf;
+ struct exynos4_tmu_platform_data *sensor_data;
+};
+
+static struct exynos4_thermal_zone *th_zone;
+
+static int exynos4_get_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode *mode)
+{
+ if (th_zone->sensor_conf) {
+ pr_info("Temperature sensor not initialised\n");
+ *mode = THERMAL_DEVICE_DISABLED;
+ } else
+ *mode = THERMAL_DEVICE_ENABLED;
+ return 0;
+}
+
+static int exynos4_set_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode mode)
+{
+ if (!th_zone->therm_dev) {
+ pr_notice("thermal zone not registered\n");
+ return 0;
+ }
+ if (mode == THERMAL_DEVICE_ENABLED)
+ th_zone->therm_dev->polling_delay =
+ th_zone->active_interval*1000;
+ else
+ th_zone->therm_dev->polling_delay =
+ th_zone->idle_interval*1000;
+
+ thermal_zone_device_update(th_zone->therm_dev);
+ pr_info("thermal polling set for duration=%d sec\n",
+ th_zone->therm_dev->polling_delay/1000);
+ return 0;
+}
+
+/*This may be called from interrupt based temperature sensor*/
+void exynos4_report_trigger(void)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+ unsigned int monitor_temp = th_temp +
+ th_zone->sensor_data->trigger_levels[1];
+
+ thermal_zone_device_update(th_zone->therm_dev);
+
+ if (th_zone->therm_dev->last_temperature > monitor_temp)
+ th_zone->therm_dev->polling_delay =
+ th_zone->active_interval*1000;
+ else
+ th_zone->therm_dev->polling_delay =
+ th_zone->idle_interval*1000;
+}
+
+static int exynos4_get_trip_type(struct thermal_zone_device *thermal, int trip,
+ enum thermal_trip_type *type)
+{
+ if (trip == 0 || trip == 1)
+ *type = THERMAL_TRIP_STATE_ACTIVE;
+ else if (trip == 2)
+ *type = THERMAL_TRIP_CRITICAL;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
+static int exynos4_get_trip_temp(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+
+ /*Monitor zone*/
+ if (trip == 0)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[1];
+ /*Warn zone*/
+ else if (trip == 1)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[2];
+ /*Panic zone*/
+ else if (trip == 2)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[3];
+ else
+ return -EINVAL;
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+static int exynos4_get_crit_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+ /*Panic zone*/
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[3];
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+static int exynos4_bind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ /* if the cooling device is the one from exynos4 bind it */
+ if (cdev != th_zone->cool_dev)
+ return 0;
+
+ if (thermal_zone_bind_cooling_device(thermal, 0, cdev)) {
+ pr_err("error binding cooling dev\n");
+ return -EINVAL;
+ }
+ if (thermal_zone_bind_cooling_device(thermal, 1, cdev)) {
+ pr_err("error binding cooling dev\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int exynos4_unbind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ if (cdev != th_zone->cool_dev)
+ return 0;
+ if (thermal_zone_unbind_cooling_device(thermal, 0, cdev)) {
+ pr_err("error unbinding cooling dev\n");
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int exynos4_get_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ void *data;
+
+ if (!th_zone->sensor_conf) {
+ pr_info("Temperature sensor not initialised\n");
+ return -EINVAL;
+ }
+ data = th_zone->sensor_conf->private_data;
+ *temp = th_zone->sensor_conf->read_temperature(data);
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+/* bind callback functions to thermalzone */
+static struct thermal_zone_device_ops exynos4_dev_ops = {
+ .bind = exynos4_bind,
+ .unbind = exynos4_unbind,
+ .get_temp = exynos4_get_temp,
+ .get_mode = exynos4_get_mode,
+ .set_mode = exynos4_set_mode,
+ .get_trip_type = exynos4_get_trip_type,
+ .get_trip_temp = exynos4_get_trip_temp,
+ .get_crit_temp = exynos4_get_crit_temp,
+};
+
+int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf)
+{
+ int ret;
+
+ if (!sensor_conf) {
+ pr_err("Temperature sensor not initialised\n");
+ return -EINVAL;
+ }
+
+ th_zone = kzalloc(sizeof(struct exynos4_thermal_zone), GFP_KERNEL);
+ if (!th_zone) {
+ ret = -ENOMEM;
+ goto err_unregister;
+ }
+
+ th_zone->sensor_conf = sensor_conf;
+
+ th_zone->sensor_data = sensor_conf->sensor_data;
+ if (!th_zone->sensor_data) {
+ pr_err("Temperature sensor data not initialised\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->cool_dev = cpufreq_cooling_register(
+ (struct freq_pctg_table *)th_zone->sensor_data->freq_tab,
+ th_zone->sensor_data->freq_tab_count, cpumask_of(0));
+
+ if (IS_ERR(th_zone->cool_dev)) {
+ pr_err("Failed to register cpufreq cooling device\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name,
+ 3, NULL, &exynos4_dev_ops, 0, 0, 0, 1000);
+ if (IS_ERR(th_zone->therm_dev)) {
+ pr_err("Failed to register thermal zone device\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->active_interval = 1;
+ th_zone->idle_interval = 10;
+
+ exynos4_set_mode(th_zone->therm_dev, THERMAL_DEVICE_DISABLED);
+
+ pr_info("Exynos: Kernel Thermal management registered\n");
+
+ return 0;
+
+err_unregister:
+ exynos4_unregister_thermal();
+ return ret;
+}
+EXPORT_SYMBOL(exynos4_register_thermal);
+
+void exynos4_unregister_thermal(void)
+{
+ if (th_zone && th_zone->cool_dev)
+ cpufreq_cooling_unregister();
+
+ if (th_zone && th_zone->therm_dev)
+ thermal_zone_device_unregister(th_zone->therm_dev);
+
+ kfree(th_zone);
+
+ pr_info("Exynos: Kernel Thermal management unregistered\n");
+}
+EXPORT_SYMBOL(exynos4_unregister_thermal);
diff --git a/include/linux/exynos_thermal.h b/include/linux/exynos_thermal.h
new file mode 100644
index 0000000..de7195b
--- /dev/null
+++ b/include/linux/exynos_thermal.h
@@ -0,0 +1,59 @@
+/* linux/include/linux/exynos_thermal.h
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef THERMAL_INTERFACE_H
+#define THERMAL_INTERFACE_H
+/* CPU Zone information */
+
+#define SENSOR_NAME_LEN 16
+
+#define PANIC_ZONE 4
+#define WARN_ZONE 3
+#define MONITOR_ZONE 2
+#define SAFE_ZONE 1
+#define NO_ACTION 0
+
+/**
+ * struct exynos4_tmu_platform_data
+ * @name: name of the temperature sensor
+ * @read_temperature: A function pointer to read temperature info
+ * @private_data: Temperature sensor private data
+ * @sensor_data: Sensor specific information like trigger temperature, level
+ */
+struct thermal_sensor_conf {
+ char name[SENSOR_NAME_LEN];
+ int (*read_temperature)(void *data);
+ void *private_data;
+ void *sensor_data;
+};
+
+/**
+ * exynos4_register_thermal: Register to the exynos thermal interface.
+ * @sensor_conf: Structure containing temperature sensor information
+ *
+ * returns zero on success, else negative errno.
+ */
+int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf);
+
+/**
+ * exynos4_unregister_thermal: Un-register from the exynos thermal interface.
+ *
+ * return not applicable.
+ */
+void exynos4_unregister_thermal(void);
+
+/**
+ * exynos4_report_trigger: Report any trigger level crossed in the
+ * temperature sensor. This may be useful to take any cooling action.
+ *
+ * return not applicable.
+ */
+extern void exynos4_report_trigger(void);
+#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [RFC PATCH 1/3] thermal: exynos: Add thermal interface support for linux thermal layer
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 11:59 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linux-kernel, mjg59, linux-acpi, lenb, linaro-dev, lm-sensors,
amit.kachhap, patches
This codes uses the generic linux thermal layer and creates a bridge
between temperature sensors, linux thermal framework and cooling devices
for samsung exynos platform. This layer recieves or monitor the
temperature from the sensor and informs the generic thermal layer to take
the necessary cooling action.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
drivers/thermal/Kconfig | 8 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/exynos_thermal.c | 255 ++++++++++++++++++++++++++++++++++++++
include/linux/exynos_thermal.h | 59 +++++++++
4 files changed, 323 insertions(+), 0 deletions(-)
create mode 100644 drivers/thermal/exynos_thermal.c
create mode 100644 include/linux/exynos_thermal.h
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 298c1cd..4e8df56 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -29,3 +29,11 @@ config CPU_THERMAL
This will be useful for platforms using the generic thermal interface
and not the ACPI interface.
If you want this support, you should say Y or M here.
+
+config SAMSUNG_THERMAL_INTERFACE
+ bool "Samsung Thermal interface support"
+ depends on THERMAL && CPU_THERMAL
+ help
+ This is a samsung thermal interface which will be used as
+ a link between sensors and cooling devices with linux thermal
+ framework.
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 655cbc4..c67b6b2 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -4,3 +4,4 @@
obj-$(CONFIG_THERMAL) += thermal_sys.o
obj-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
+obj-$(CONFIG_SAMSUNG_THERMAL_INTERFACE) += exynos_thermal.o
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
new file mode 100644
index 0000000..7c916db
--- /dev/null
+++ b/drivers/thermal/exynos_thermal.c
@@ -0,0 +1,255 @@
+/* linux/drivers/thermal/exynos_thermal.c
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/thermal.h>
+#include <linux/platform_device.h>
+#include <linux/cpufreq.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/cpu_cooling.h>
+#include <linux/platform_data/exynos4_tmu.h>
+#include <linux/exynos_thermal.h>
+
+struct exynos4_thermal_zone {
+ unsigned int idle_interval;
+ unsigned int active_interval;
+ struct thermal_zone_device *therm_dev;
+ struct thermal_cooling_device *cool_dev;
+ struct platform_device *exynos4_dev;
+ struct thermal_sensor_conf *sensor_conf;
+ struct exynos4_tmu_platform_data *sensor_data;
+};
+
+static struct exynos4_thermal_zone *th_zone;
+
+static int exynos4_get_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode *mode)
+{
+ if (th_zone->sensor_conf) {
+ pr_info("Temperature sensor not initialised\n");
+ *mode = THERMAL_DEVICE_DISABLED;
+ } else
+ *mode = THERMAL_DEVICE_ENABLED;
+ return 0;
+}
+
+static int exynos4_set_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode mode)
+{
+ if (!th_zone->therm_dev) {
+ pr_notice("thermal zone not registered\n");
+ return 0;
+ }
+ if (mode == THERMAL_DEVICE_ENABLED)
+ th_zone->therm_dev->polling_delay =
+ th_zone->active_interval*1000;
+ else
+ th_zone->therm_dev->polling_delay =
+ th_zone->idle_interval*1000;
+
+ thermal_zone_device_update(th_zone->therm_dev);
+ pr_info("thermal polling set for duration=%d sec\n",
+ th_zone->therm_dev->polling_delay/1000);
+ return 0;
+}
+
+/*This may be called from interrupt based temperature sensor*/
+void exynos4_report_trigger(void)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+ unsigned int monitor_temp = th_temp +
+ th_zone->sensor_data->trigger_levels[1];
+
+ thermal_zone_device_update(th_zone->therm_dev);
+
+ if (th_zone->therm_dev->last_temperature > monitor_temp)
+ th_zone->therm_dev->polling_delay =
+ th_zone->active_interval*1000;
+ else
+ th_zone->therm_dev->polling_delay =
+ th_zone->idle_interval*1000;
+}
+
+static int exynos4_get_trip_type(struct thermal_zone_device *thermal, int trip,
+ enum thermal_trip_type *type)
+{
+ if (trip == 0 || trip == 1)
+ *type = THERMAL_TRIP_STATE_ACTIVE;
+ else if (trip == 2)
+ *type = THERMAL_TRIP_CRITICAL;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
+static int exynos4_get_trip_temp(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+
+ /*Monitor zone*/
+ if (trip == 0)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[1];
+ /*Warn zone*/
+ else if (trip == 1)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[2];
+ /*Panic zone*/
+ else if (trip == 2)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[3];
+ else
+ return -EINVAL;
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+static int exynos4_get_crit_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+ /*Panic zone*/
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[3];
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+static int exynos4_bind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ /* if the cooling device is the one from exynos4 bind it */
+ if (cdev != th_zone->cool_dev)
+ return 0;
+
+ if (thermal_zone_bind_cooling_device(thermal, 0, cdev)) {
+ pr_err("error binding cooling dev\n");
+ return -EINVAL;
+ }
+ if (thermal_zone_bind_cooling_device(thermal, 1, cdev)) {
+ pr_err("error binding cooling dev\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int exynos4_unbind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ if (cdev != th_zone->cool_dev)
+ return 0;
+ if (thermal_zone_unbind_cooling_device(thermal, 0, cdev)) {
+ pr_err("error unbinding cooling dev\n");
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int exynos4_get_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ void *data;
+
+ if (!th_zone->sensor_conf) {
+ pr_info("Temperature sensor not initialised\n");
+ return -EINVAL;
+ }
+ data = th_zone->sensor_conf->private_data;
+ *temp = th_zone->sensor_conf->read_temperature(data);
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+/* bind callback functions to thermalzone */
+static struct thermal_zone_device_ops exynos4_dev_ops = {
+ .bind = exynos4_bind,
+ .unbind = exynos4_unbind,
+ .get_temp = exynos4_get_temp,
+ .get_mode = exynos4_get_mode,
+ .set_mode = exynos4_set_mode,
+ .get_trip_type = exynos4_get_trip_type,
+ .get_trip_temp = exynos4_get_trip_temp,
+ .get_crit_temp = exynos4_get_crit_temp,
+};
+
+int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf)
+{
+ int ret;
+
+ if (!sensor_conf) {
+ pr_err("Temperature sensor not initialised\n");
+ return -EINVAL;
+ }
+
+ th_zone = kzalloc(sizeof(struct exynos4_thermal_zone), GFP_KERNEL);
+ if (!th_zone) {
+ ret = -ENOMEM;
+ goto err_unregister;
+ }
+
+ th_zone->sensor_conf = sensor_conf;
+
+ th_zone->sensor_data = sensor_conf->sensor_data;
+ if (!th_zone->sensor_data) {
+ pr_err("Temperature sensor data not initialised\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->cool_dev = cpufreq_cooling_register(
+ (struct freq_pctg_table *)th_zone->sensor_data->freq_tab,
+ th_zone->sensor_data->freq_tab_count, cpumask_of(0));
+
+ if (IS_ERR(th_zone->cool_dev)) {
+ pr_err("Failed to register cpufreq cooling device\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name,
+ 3, NULL, &exynos4_dev_ops, 0, 0, 0, 1000);
+ if (IS_ERR(th_zone->therm_dev)) {
+ pr_err("Failed to register thermal zone device\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->active_interval = 1;
+ th_zone->idle_interval = 10;
+
+ exynos4_set_mode(th_zone->therm_dev, THERMAL_DEVICE_DISABLED);
+
+ pr_info("Exynos: Kernel Thermal management registered\n");
+
+ return 0;
+
+err_unregister:
+ exynos4_unregister_thermal();
+ return ret;
+}
+EXPORT_SYMBOL(exynos4_register_thermal);
+
+void exynos4_unregister_thermal(void)
+{
+ if (th_zone && th_zone->cool_dev)
+ cpufreq_cooling_unregister();
+
+ if (th_zone && th_zone->therm_dev)
+ thermal_zone_device_unregister(th_zone->therm_dev);
+
+ kfree(th_zone);
+
+ pr_info("Exynos: Kernel Thermal management unregistered\n");
+}
+EXPORT_SYMBOL(exynos4_unregister_thermal);
diff --git a/include/linux/exynos_thermal.h b/include/linux/exynos_thermal.h
new file mode 100644
index 0000000..de7195b
--- /dev/null
+++ b/include/linux/exynos_thermal.h
@@ -0,0 +1,59 @@
+/* linux/include/linux/exynos_thermal.h
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef THERMAL_INTERFACE_H
+#define THERMAL_INTERFACE_H
+/* CPU Zone information */
+
+#define SENSOR_NAME_LEN 16
+
+#define PANIC_ZONE 4
+#define WARN_ZONE 3
+#define MONITOR_ZONE 2
+#define SAFE_ZONE 1
+#define NO_ACTION 0
+
+/**
+ * struct exynos4_tmu_platform_data
+ * @name: name of the temperature sensor
+ * @read_temperature: A function pointer to read temperature info
+ * @private_data: Temperature sensor private data
+ * @sensor_data: Sensor specific information like trigger temperature, level
+ */
+struct thermal_sensor_conf {
+ char name[SENSOR_NAME_LEN];
+ int (*read_temperature)(void *data);
+ void *private_data;
+ void *sensor_data;
+};
+
+/**
+ * exynos4_register_thermal: Register to the exynos thermal interface.
+ * @sensor_conf: Structure containing temperature sensor information
+ *
+ * returns zero on success, else negative errno.
+ */
+int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf);
+
+/**
+ * exynos4_unregister_thermal: Un-register from the exynos thermal interface.
+ *
+ * return not applicable.
+ */
+void exynos4_unregister_thermal(void);
+
+/**
+ * exynos4_report_trigger: Report any trigger level crossed in the
+ * temperature sensor. This may be useful to take any cooling action.
+ *
+ * return not applicable.
+ */
+extern void exynos4_report_trigger(void);
+#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2011-12-21 12:11 ` [lm-sensors] [RFC PATCH 0/3] thermal: exynos: Add kernel thermal Amit Daniel Kachhap
(?)
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
-1 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 11:59 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linaro-dev, patches, linux-kernel, lm-sensors, linux-acpi
Export and register information from the hwmon tmu sensor to the samsung
exynos kernel thermal framework where different cooling devices and thermal
zone are binded. The exported information is based according to the data
structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
functions are currently left although all of them are present in generic
linux thermal layer.
Also the platform data structure is modified to pass frequency cooling
in percentages for each thermal level.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
include/linux/platform_data/exynos4_tmu.h | 7 ++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
index f2359a0..6912a7f 100644
--- a/drivers/hwmon/exynos4_tmu.c
+++ b/drivers/hwmon/exynos4_tmu.c
@@ -37,6 +37,9 @@
#include <linux/hwmon-sysfs.h>
#include <linux/platform_data/exynos4_tmu.h>
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+#include <linux/exynos_thermal.h>
+#endif
#define EXYNOS4_TMU_REG_TRIMINFO 0x0
#define EXYNOS4_TMU_REG_CONTROL 0x20
@@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
- enable_irq(data->irq);
clk_disable(data->clk);
mutex_unlock(&data->lock);
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ exynos4_report_trigger();
+#endif
+ enable_irq(data->irq);
}
static irqreturn_t exynos4_tmu_irq(int irq, void *id)
@@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
.attrs = exynos4_tmu_attributes,
};
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+static struct thermal_sensor_conf exynos4_sensor_conf = {
+ .name = "exynos4-therm",
+ .read_temperature = (int (*)(void *))exynos4_tmu_read,
+};
+#endif
+/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
+
static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
{
struct exynos4_tmu_data *data;
@@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
}
exynos4_tmu_control(pdev, true);
-
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ (&exynos4_sensor_conf)->private_data = data;
+ (&exynos4_sensor_conf)->sensor_data = pdata;
+ ret = exynos4_register_thermal(&exynos4_sensor_conf);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to register thermal interface\n");
+ goto err_hwmon_device;
+ }
+#endif
return 0;
-
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+err_hwmon_device:
+ hwmon_device_unregister(data->hwmon_dev);
+#endif
err_create_group:
sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
err_clk:
@@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
exynos4_tmu_control(pdev, false);
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ exynos4_unregister_thermal();
+#endif
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
index 39e038c..642c508 100644
--- a/include/linux/platform_data/exynos4_tmu.h
+++ b/include/linux/platform_data/exynos4_tmu.h
@@ -21,6 +21,7 @@
#ifndef _LINUX_EXYNOS4_TMU_H
#define _LINUX_EXYNOS4_TMU_H
+#include <linux/cpu_cooling.h>
enum calibration_type {
TYPE_ONE_POINT_TRIMMING,
@@ -64,6 +65,9 @@ enum calibration_type {
* in the positive-TC generator block
* 0 <= reference_voltage <= 31
* @cal_type: calibration type for temperature
+ * @freq_pctg_table: Table representing frequency reduction percentage.
+ * @freq_tab_count: Count of the above table as frequency reduction may
+ * applicable to only some of the trigger levels.
*
* This structure is required for configuration of exynos4_tmu driver.
*/
@@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
u8 reference_voltage;
enum calibration_type cal_type;
+
+ struct freq_pctg_table freq_tab[4];
+ unsigned int freq_tab_count;
};
#endif /* _LINUX_EXYNOS4_TMU_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 11:59 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linux-kernel, mjg59, linux-acpi, lenb, linaro-dev, lm-sensors,
amit.kachhap, patches
Export and register information from the hwmon tmu sensor to the samsung
exynos kernel thermal framework where different cooling devices and thermal
zone are binded. The exported information is based according to the data
structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
functions are currently left although all of them are present in generic
linux thermal layer.
Also the platform data structure is modified to pass frequency cooling
in percentages for each thermal level.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
include/linux/platform_data/exynos4_tmu.h | 7 ++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
index f2359a0..6912a7f 100644
--- a/drivers/hwmon/exynos4_tmu.c
+++ b/drivers/hwmon/exynos4_tmu.c
@@ -37,6 +37,9 @@
#include <linux/hwmon-sysfs.h>
#include <linux/platform_data/exynos4_tmu.h>
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+#include <linux/exynos_thermal.h>
+#endif
#define EXYNOS4_TMU_REG_TRIMINFO 0x0
#define EXYNOS4_TMU_REG_CONTROL 0x20
@@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
- enable_irq(data->irq);
clk_disable(data->clk);
mutex_unlock(&data->lock);
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ exynos4_report_trigger();
+#endif
+ enable_irq(data->irq);
}
static irqreturn_t exynos4_tmu_irq(int irq, void *id)
@@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
.attrs = exynos4_tmu_attributes,
};
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+static struct thermal_sensor_conf exynos4_sensor_conf = {
+ .name = "exynos4-therm",
+ .read_temperature = (int (*)(void *))exynos4_tmu_read,
+};
+#endif
+/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
+
static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
{
struct exynos4_tmu_data *data;
@@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
}
exynos4_tmu_control(pdev, true);
-
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ (&exynos4_sensor_conf)->private_data = data;
+ (&exynos4_sensor_conf)->sensor_data = pdata;
+ ret = exynos4_register_thermal(&exynos4_sensor_conf);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to register thermal interface\n");
+ goto err_hwmon_device;
+ }
+#endif
return 0;
-
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+err_hwmon_device:
+ hwmon_device_unregister(data->hwmon_dev);
+#endif
err_create_group:
sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
err_clk:
@@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
exynos4_tmu_control(pdev, false);
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ exynos4_unregister_thermal();
+#endif
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
index 39e038c..642c508 100644
--- a/include/linux/platform_data/exynos4_tmu.h
+++ b/include/linux/platform_data/exynos4_tmu.h
@@ -21,6 +21,7 @@
#ifndef _LINUX_EXYNOS4_TMU_H
#define _LINUX_EXYNOS4_TMU_H
+#include <linux/cpu_cooling.h>
enum calibration_type {
TYPE_ONE_POINT_TRIMMING,
@@ -64,6 +65,9 @@ enum calibration_type {
* in the positive-TC generator block
* 0 <= reference_voltage <= 31
* @cal_type: calibration type for temperature
+ * @freq_pctg_table: Table representing frequency reduction percentage.
+ * @freq_tab_count: Count of the above table as frequency reduction may
+ * applicable to only some of the trigger levels.
*
* This structure is required for configuration of exynos4_tmu driver.
*/
@@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
u8 reference_voltage;
enum calibration_type cal_type;
+
+ struct freq_pctg_table freq_tab[4];
+ unsigned int freq_tab_count;
};
#endif /* _LINUX_EXYNOS4_TMU_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [RFC PATCH 3/3] ARM: exynos4: Add thermal sensor driver platform device support
2011-12-21 12:11 ` [lm-sensors] [RFC PATCH 0/3] thermal: exynos: Add kernel thermal Amit Daniel Kachhap
(?)
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
-1 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 11:59 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linaro-dev, patches, linux-kernel, lm-sensors, linux-acpi
This patch adds necessary source definations needed for TMU driver and
the platform device support.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
arch/arm/mach-exynos/Kconfig | 12 +++++
arch/arm/mach-exynos/Makefile | 1 +
arch/arm/mach-exynos/clock.c | 4 ++
arch/arm/mach-exynos/dev-tmu.c | 64 +++++++++++++++++++++++++++++
arch/arm/mach-exynos/include/mach/irqs.h | 2 +
arch/arm/mach-exynos/include/mach/map.h | 1 +
arch/arm/mach-exynos/mach-origen.c | 1 +
arch/arm/plat-samsung/include/plat/devs.h | 1 +
8 files changed, 86 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-exynos/dev-tmu.c
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 724ec0f..cfc6119 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -82,6 +82,17 @@ config EXYNOS4_DEV_DWMCI
help
Compile in platform device definitions for DWMCI
+config EXYNOS4_DEV_TMU
+ bool "Exynos4 tmu device support"
+ default n
+ depends on ARCH_EXYNOS4
+ ---help---
+ Compile in platform device definitions for TMU. This macro also
+ enables compilation hwmon base TMU driver and also allows compilation
+ of the platform device files. The platform data in this case is trip
+ temperature and some tmu h/w configurations related parameter.
+
+
config EXYNOS4_SETUP_I2C1
bool
help
@@ -288,6 +299,7 @@ config MACH_ORIGEN
select SAMSUNG_DEV_BACKLIGHT
select SAMSUNG_DEV_PWM
select EXYNOS4_DEV_PD
+ select EXYNOS4_DEV_TMU
select EXYNOS4_SETUP_FIMD0
select EXYNOS4_SETUP_SDHCI
select EXYNOS4_SETUP_USB_PHY
diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
index 59069a3..d2493e8 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_EXYNOS4_DEV_AHCI) += dev-ahci.o
obj-$(CONFIG_EXYNOS4_DEV_PD) += dev-pd.o
obj-$(CONFIG_EXYNOS4_DEV_SYSMMU) += dev-sysmmu.o
obj-$(CONFIG_EXYNOS4_DEV_DWMCI) += dev-dwmci.o
+obj-$(CONFIG_EXYNOS4_DEV_TMU) += dev-tmu.o
obj-$(CONFIG_EXYNOS4_SETUP_FIMC) += setup-fimc.o
obj-$(CONFIG_EXYNOS4_SETUP_FIMD0) += setup-fimd0.o
diff --git a/arch/arm/mach-exynos/clock.c b/arch/arm/mach-exynos/clock.c
index 2894f0a..edecc5e 100644
--- a/arch/arm/mach-exynos/clock.c
+++ b/arch/arm/mach-exynos/clock.c
@@ -567,6 +567,10 @@ static struct clk init_clocks_off[] = {
.enable = exynos4_clk_ip_peril_ctrl,
.ctrlbit = (1 << 15),
}, {
+ .name = "tmu_apbif",
+ .enable = exynos4_clk_ip_perir_ctrl,
+ .ctrlbit = (1 << 17),
+ }, {
.name = "keypad",
.enable = exynos4_clk_ip_perir_ctrl,
.ctrlbit = (1 << 16),
diff --git a/arch/arm/mach-exynos/dev-tmu.c b/arch/arm/mach-exynos/dev-tmu.c
new file mode 100644
index 0000000..2e98912
--- /dev/null
+++ b/arch/arm/mach-exynos/dev-tmu.c
@@ -0,0 +1,64 @@
+/* linux/arch/arm/mach-exynos4/dev-tmu.c
+ *
+ * Copyright 2011 by SAMSUNG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/platform_data/exynos4_tmu.h>
+#include <asm/irq.h>
+
+#include <mach/irqs.h>
+#include <mach/map.h>
+#include <plat/devs.h>
+
+static struct resource exynos4_tmu_resource[] = {
+ [0] = {
+ .start = EXYNOS4_PA_TMU,
+ .end = EXYNOS4_PA_TMU + 0xFFFF - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = IRQ_TMU_TRIG0,
+ .end = IRQ_TMU_TRIG0,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct exynos4_tmu_platform_data default_tmu_data = {
+ .threshold = 80,
+ .trigger_levels[0] = 2,
+ .trigger_levels[1] = 5,
+ .trigger_levels[2] = 20,
+ .trigger_levels[3] = 30,
+ .trigger_level0_en = 1,
+ .trigger_level1_en = 1,
+ .trigger_level2_en = 1,
+ .trigger_level3_en = 1,
+ .gain = 15,
+ .reference_voltage = 7,
+ .cal_type = TYPE_ONE_POINT_TRIMMING,
+ .freq_tab[0] = {
+ .freq_clip_pctg[0] = 30,
+ },
+ .freq_tab[1] = {
+ .freq_clip_pctg[0] = 99,
+ },
+ .freq_tab_count = 2,
+};
+
+struct platform_device exynos4_device_tmu = {
+ .name = "exynos4-tmu",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(exynos4_tmu_resource),
+ .resource = exynos4_tmu_resource,
+ .dev = {
+ .platform_data = &default_tmu_data,
+ },
+};
diff --git a/arch/arm/mach-exynos/include/mach/irqs.h b/arch/arm/mach-exynos/include/mach/irqs.h
index dfd4b7e..d66a24b 100644
--- a/arch/arm/mach-exynos/include/mach/irqs.h
+++ b/arch/arm/mach-exynos/include/mach/irqs.h
@@ -125,6 +125,8 @@
#define COMBINER_GROUP(x) ((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(128))
#define COMBINER_IRQ(x, y) (COMBINER_GROUP(x) + y)
+#define IRQ_TMU_TRIG0 COMBINER_IRQ(2, 4)
+#define IRQ_TMU_TRIG1 COMBINER_IRQ(3, 4)
#define IRQ_SYSMMU_MDMA0_0 COMBINER_IRQ(4, 0)
#define IRQ_SYSMMU_SSS_0 COMBINER_IRQ(4, 1)
#define IRQ_SYSMMU_FIMC0_0 COMBINER_IRQ(4, 2)
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 058541d..0d79b88 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -66,6 +66,7 @@
#define EXYNOS4_PA_COREPERI 0x10500000
#define EXYNOS4_PA_TWD 0x10500600
#define EXYNOS4_PA_L2CC 0x10502000
+#define EXYNOS4_PA_TMU 0x100C0000
#define EXYNOS4_PA_MDMA 0x10810000
#define EXYNOS4_PA_PDMA0 0x12680000
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index f80b563..699140a 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -615,6 +615,7 @@ static struct platform_device *origen_devices[] __initdata = {
&exynos4_device_pd[PD_MFC],
&origen_device_gpiokeys,
&origen_lcd_hv070wsa,
+ &exynos4_device_tmu,
};
/* LCD Backlight data */
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index ab633c9..74cbf0d 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -135,6 +135,7 @@ extern struct platform_device exynos4_device_pcm2;
extern struct platform_device exynos4_device_pd[];
extern struct platform_device exynos4_device_spdif;
extern struct platform_device exynos4_device_sysmmu;
+extern struct platform_device exynos4_device_tmu;
extern struct platform_device samsung_asoc_dma;
extern struct platform_device samsung_asoc_idma;
--
1.7.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [RFC PATCH 3/3] ARM: exynos4: Add thermal sensor driver platform device support
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 11:59 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linux-kernel, mjg59, linux-acpi, lenb, linaro-dev, lm-sensors,
amit.kachhap, patches
This patch adds necessary source definations needed for TMU driver and
the platform device support.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
arch/arm/mach-exynos/Kconfig | 12 +++++
arch/arm/mach-exynos/Makefile | 1 +
arch/arm/mach-exynos/clock.c | 4 ++
arch/arm/mach-exynos/dev-tmu.c | 64 +++++++++++++++++++++++++++++
arch/arm/mach-exynos/include/mach/irqs.h | 2 +
arch/arm/mach-exynos/include/mach/map.h | 1 +
arch/arm/mach-exynos/mach-origen.c | 1 +
arch/arm/plat-samsung/include/plat/devs.h | 1 +
8 files changed, 86 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-exynos/dev-tmu.c
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 724ec0f..cfc6119 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -82,6 +82,17 @@ config EXYNOS4_DEV_DWMCI
help
Compile in platform device definitions for DWMCI
+config EXYNOS4_DEV_TMU
+ bool "Exynos4 tmu device support"
+ default n
+ depends on ARCH_EXYNOS4
+ ---help---
+ Compile in platform device definitions for TMU. This macro also
+ enables compilation hwmon base TMU driver and also allows compilation
+ of the platform device files. The platform data in this case is trip
+ temperature and some tmu h/w configurations related parameter.
+
+
config EXYNOS4_SETUP_I2C1
bool
help
@@ -288,6 +299,7 @@ config MACH_ORIGEN
select SAMSUNG_DEV_BACKLIGHT
select SAMSUNG_DEV_PWM
select EXYNOS4_DEV_PD
+ select EXYNOS4_DEV_TMU
select EXYNOS4_SETUP_FIMD0
select EXYNOS4_SETUP_SDHCI
select EXYNOS4_SETUP_USB_PHY
diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
index 59069a3..d2493e8 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_EXYNOS4_DEV_AHCI) += dev-ahci.o
obj-$(CONFIG_EXYNOS4_DEV_PD) += dev-pd.o
obj-$(CONFIG_EXYNOS4_DEV_SYSMMU) += dev-sysmmu.o
obj-$(CONFIG_EXYNOS4_DEV_DWMCI) += dev-dwmci.o
+obj-$(CONFIG_EXYNOS4_DEV_TMU) += dev-tmu.o
obj-$(CONFIG_EXYNOS4_SETUP_FIMC) += setup-fimc.o
obj-$(CONFIG_EXYNOS4_SETUP_FIMD0) += setup-fimd0.o
diff --git a/arch/arm/mach-exynos/clock.c b/arch/arm/mach-exynos/clock.c
index 2894f0a..edecc5e 100644
--- a/arch/arm/mach-exynos/clock.c
+++ b/arch/arm/mach-exynos/clock.c
@@ -567,6 +567,10 @@ static struct clk init_clocks_off[] = {
.enable = exynos4_clk_ip_peril_ctrl,
.ctrlbit = (1 << 15),
}, {
+ .name = "tmu_apbif",
+ .enable = exynos4_clk_ip_perir_ctrl,
+ .ctrlbit = (1 << 17),
+ }, {
.name = "keypad",
.enable = exynos4_clk_ip_perir_ctrl,
.ctrlbit = (1 << 16),
diff --git a/arch/arm/mach-exynos/dev-tmu.c b/arch/arm/mach-exynos/dev-tmu.c
new file mode 100644
index 0000000..2e98912
--- /dev/null
+++ b/arch/arm/mach-exynos/dev-tmu.c
@@ -0,0 +1,64 @@
+/* linux/arch/arm/mach-exynos4/dev-tmu.c
+ *
+ * Copyright 2011 by SAMSUNG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/platform_data/exynos4_tmu.h>
+#include <asm/irq.h>
+
+#include <mach/irqs.h>
+#include <mach/map.h>
+#include <plat/devs.h>
+
+static struct resource exynos4_tmu_resource[] = {
+ [0] = {
+ .start = EXYNOS4_PA_TMU,
+ .end = EXYNOS4_PA_TMU + 0xFFFF - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = IRQ_TMU_TRIG0,
+ .end = IRQ_TMU_TRIG0,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct exynos4_tmu_platform_data default_tmu_data = {
+ .threshold = 80,
+ .trigger_levels[0] = 2,
+ .trigger_levels[1] = 5,
+ .trigger_levels[2] = 20,
+ .trigger_levels[3] = 30,
+ .trigger_level0_en = 1,
+ .trigger_level1_en = 1,
+ .trigger_level2_en = 1,
+ .trigger_level3_en = 1,
+ .gain = 15,
+ .reference_voltage = 7,
+ .cal_type = TYPE_ONE_POINT_TRIMMING,
+ .freq_tab[0] = {
+ .freq_clip_pctg[0] = 30,
+ },
+ .freq_tab[1] = {
+ .freq_clip_pctg[0] = 99,
+ },
+ .freq_tab_count = 2,
+};
+
+struct platform_device exynos4_device_tmu = {
+ .name = "exynos4-tmu",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(exynos4_tmu_resource),
+ .resource = exynos4_tmu_resource,
+ .dev = {
+ .platform_data = &default_tmu_data,
+ },
+};
diff --git a/arch/arm/mach-exynos/include/mach/irqs.h b/arch/arm/mach-exynos/include/mach/irqs.h
index dfd4b7e..d66a24b 100644
--- a/arch/arm/mach-exynos/include/mach/irqs.h
+++ b/arch/arm/mach-exynos/include/mach/irqs.h
@@ -125,6 +125,8 @@
#define COMBINER_GROUP(x) ((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(128))
#define COMBINER_IRQ(x, y) (COMBINER_GROUP(x) + y)
+#define IRQ_TMU_TRIG0 COMBINER_IRQ(2, 4)
+#define IRQ_TMU_TRIG1 COMBINER_IRQ(3, 4)
#define IRQ_SYSMMU_MDMA0_0 COMBINER_IRQ(4, 0)
#define IRQ_SYSMMU_SSS_0 COMBINER_IRQ(4, 1)
#define IRQ_SYSMMU_FIMC0_0 COMBINER_IRQ(4, 2)
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 058541d..0d79b88 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -66,6 +66,7 @@
#define EXYNOS4_PA_COREPERI 0x10500000
#define EXYNOS4_PA_TWD 0x10500600
#define EXYNOS4_PA_L2CC 0x10502000
+#define EXYNOS4_PA_TMU 0x100C0000
#define EXYNOS4_PA_MDMA 0x10810000
#define EXYNOS4_PA_PDMA0 0x12680000
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index f80b563..699140a 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -615,6 +615,7 @@ static struct platform_device *origen_devices[] __initdata = {
&exynos4_device_pd[PD_MFC],
&origen_device_gpiokeys,
&origen_lcd_hv070wsa,
+ &exynos4_device_tmu,
};
/* LCD Backlight data */
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index ab633c9..74cbf0d 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -135,6 +135,7 @@ extern struct platform_device exynos4_device_pcm2;
extern struct platform_device exynos4_device_pd[];
extern struct platform_device exynos4_device_spdif;
extern struct platform_device exynos4_device_sysmmu;
+extern struct platform_device exynos4_device_tmu;
extern struct platform_device samsung_asoc_dma;
extern struct platform_device samsung_asoc_idma;
--
1.7.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [lm-sensors] [RFC PATCH 0/3] thermal: exynos: Add kernel thermal
@ 2011-12-21 12:11 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 12:11 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linux-kernel, mjg59, linux-acpi, lenb, linaro-dev, lm-sensors,
amit.kachhap, patches
All the patchset based on Kernel version 3.2-rc6 and uses the cpufreq
cooling registration api's implemented in earlier patchset
http://www.spinics.net/lists/linux-pm/msg26500.html
The code added in this patchset adds a thermal interface layer for samsung
exynos platforms. This layer is registered from the hwmon based temperature
sensor and recieves/monitor the temperature from the sensor and informs the
generic thermal layer to take the necessary cooling action. Currently this
layer can be used to create only one thermal zone and hence only one
temperature sensor can register.
Some modifications are done in the temperature sensor driver to export the
information needed for the thermal interface to register with the core linux
thermal framework and with the cpu frequency based cooling devices.
A simple data/control flow diagrams to illustrate this,
Core Linux thermal <-------> Exynos thermal <-------- Temperature Sensor
| |
\|/ |
Cpufreq cooling device <-----
Amit Daniel Kachhap (3):
thermal: exynos: Add thermal interface support for linux thermal
layer
thermal: exynos4: Register the tmu sensor with the thermal interface
layer
ARM: exynos4: Add thermal sensor driver platform device support
arch/arm/mach-exynos/Kconfig | 12 ++
arch/arm/mach-exynos/Makefile | 1 +
arch/arm/mach-exynos/clock.c | 4 +
arch/arm/mach-exynos/dev-tmu.c | 64 +++++++
arch/arm/mach-exynos/include/mach/irqs.h | 2 +
arch/arm/mach-exynos/include/mach/map.h | 1 +
arch/arm/mach-exynos/mach-origen.c | 1 +
arch/arm/plat-samsung/include/plat/devs.h | 1 +
drivers/hwmon/exynos4_tmu.c | 34 ++++-
drivers/thermal/Kconfig | 8 +
drivers/thermal/Makefile | 1 +
drivers/thermal/exynos_thermal.c | 255 +++++++++++++++++++++++++++++
include/linux/exynos_thermal.h | 59 +++++++
include/linux/platform_data/exynos4_tmu.h | 7 +
14 files changed, 447 insertions(+), 3 deletions(-)
create mode 100644 arch/arm/mach-exynos/dev-tmu.c
create mode 100644 drivers/thermal/exynos_thermal.c
create mode 100644 include/linux/exynos_thermal.h
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 25+ messages in thread
* [lm-sensors] [RFC PATCH 1/3] thermal: exynos: Add thermal interface
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 12:11 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linaro-dev, patches, linux-kernel, lm-sensors, linux-acpi
This codes uses the generic linux thermal layer and creates a bridge
between temperature sensors, linux thermal framework and cooling devices
for samsung exynos platform. This layer recieves or monitor the
temperature from the sensor and informs the generic thermal layer to take
the necessary cooling action.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
drivers/thermal/Kconfig | 8 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/exynos_thermal.c | 255 ++++++++++++++++++++++++++++++++++++++
include/linux/exynos_thermal.h | 59 +++++++++
4 files changed, 323 insertions(+), 0 deletions(-)
create mode 100644 drivers/thermal/exynos_thermal.c
create mode 100644 include/linux/exynos_thermal.h
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 298c1cd..4e8df56 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -29,3 +29,11 @@ config CPU_THERMAL
This will be useful for platforms using the generic thermal interface
and not the ACPI interface.
If you want this support, you should say Y or M here.
+
+config SAMSUNG_THERMAL_INTERFACE
+ bool "Samsung Thermal interface support"
+ depends on THERMAL && CPU_THERMAL
+ help
+ This is a samsung thermal interface which will be used as
+ a link between sensors and cooling devices with linux thermal
+ framework.
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 655cbc4..c67b6b2 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -4,3 +4,4 @@
obj-$(CONFIG_THERMAL) += thermal_sys.o
obj-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
+obj-$(CONFIG_SAMSUNG_THERMAL_INTERFACE) += exynos_thermal.o
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
new file mode 100644
index 0000000..7c916db
--- /dev/null
+++ b/drivers/thermal/exynos_thermal.c
@@ -0,0 +1,255 @@
+/* linux/drivers/thermal/exynos_thermal.c
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/thermal.h>
+#include <linux/platform_device.h>
+#include <linux/cpufreq.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/cpu_cooling.h>
+#include <linux/platform_data/exynos4_tmu.h>
+#include <linux/exynos_thermal.h>
+
+struct exynos4_thermal_zone {
+ unsigned int idle_interval;
+ unsigned int active_interval;
+ struct thermal_zone_device *therm_dev;
+ struct thermal_cooling_device *cool_dev;
+ struct platform_device *exynos4_dev;
+ struct thermal_sensor_conf *sensor_conf;
+ struct exynos4_tmu_platform_data *sensor_data;
+};
+
+static struct exynos4_thermal_zone *th_zone;
+
+static int exynos4_get_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode *mode)
+{
+ if (th_zone->sensor_conf) {
+ pr_info("Temperature sensor not initialised\n");
+ *mode = THERMAL_DEVICE_DISABLED;
+ } else
+ *mode = THERMAL_DEVICE_ENABLED;
+ return 0;
+}
+
+static int exynos4_set_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode mode)
+{
+ if (!th_zone->therm_dev) {
+ pr_notice("thermal zone not registered\n");
+ return 0;
+ }
+ if (mode = THERMAL_DEVICE_ENABLED)
+ th_zone->therm_dev->polling_delay + th_zone->active_interval*1000;
+ else
+ th_zone->therm_dev->polling_delay + th_zone->idle_interval*1000;
+
+ thermal_zone_device_update(th_zone->therm_dev);
+ pr_info("thermal polling set for duration=%d sec\n",
+ th_zone->therm_dev->polling_delay/1000);
+ return 0;
+}
+
+/*This may be called from interrupt based temperature sensor*/
+void exynos4_report_trigger(void)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+ unsigned int monitor_temp = th_temp +
+ th_zone->sensor_data->trigger_levels[1];
+
+ thermal_zone_device_update(th_zone->therm_dev);
+
+ if (th_zone->therm_dev->last_temperature > monitor_temp)
+ th_zone->therm_dev->polling_delay + th_zone->active_interval*1000;
+ else
+ th_zone->therm_dev->polling_delay + th_zone->idle_interval*1000;
+}
+
+static int exynos4_get_trip_type(struct thermal_zone_device *thermal, int trip,
+ enum thermal_trip_type *type)
+{
+ if (trip = 0 || trip = 1)
+ *type = THERMAL_TRIP_STATE_ACTIVE;
+ else if (trip = 2)
+ *type = THERMAL_TRIP_CRITICAL;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
+static int exynos4_get_trip_temp(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+
+ /*Monitor zone*/
+ if (trip = 0)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[1];
+ /*Warn zone*/
+ else if (trip = 1)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[2];
+ /*Panic zone*/
+ else if (trip = 2)
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[3];
+ else
+ return -EINVAL;
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+static int exynos4_get_crit_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ unsigned int th_temp = th_zone->sensor_data->threshold;
+ /*Panic zone*/
+ *temp = th_temp + th_zone->sensor_data->trigger_levels[3];
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+static int exynos4_bind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ /* if the cooling device is the one from exynos4 bind it */
+ if (cdev != th_zone->cool_dev)
+ return 0;
+
+ if (thermal_zone_bind_cooling_device(thermal, 0, cdev)) {
+ pr_err("error binding cooling dev\n");
+ return -EINVAL;
+ }
+ if (thermal_zone_bind_cooling_device(thermal, 1, cdev)) {
+ pr_err("error binding cooling dev\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int exynos4_unbind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ if (cdev != th_zone->cool_dev)
+ return 0;
+ if (thermal_zone_unbind_cooling_device(thermal, 0, cdev)) {
+ pr_err("error unbinding cooling dev\n");
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int exynos4_get_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ void *data;
+
+ if (!th_zone->sensor_conf) {
+ pr_info("Temperature sensor not initialised\n");
+ return -EINVAL;
+ }
+ data = th_zone->sensor_conf->private_data;
+ *temp = th_zone->sensor_conf->read_temperature(data);
+ /*convert the temperature into millicelsius*/
+ *temp = *temp * 1000;
+ return 0;
+}
+
+/* bind callback functions to thermalzone */
+static struct thermal_zone_device_ops exynos4_dev_ops = {
+ .bind = exynos4_bind,
+ .unbind = exynos4_unbind,
+ .get_temp = exynos4_get_temp,
+ .get_mode = exynos4_get_mode,
+ .set_mode = exynos4_set_mode,
+ .get_trip_type = exynos4_get_trip_type,
+ .get_trip_temp = exynos4_get_trip_temp,
+ .get_crit_temp = exynos4_get_crit_temp,
+};
+
+int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf)
+{
+ int ret;
+
+ if (!sensor_conf) {
+ pr_err("Temperature sensor not initialised\n");
+ return -EINVAL;
+ }
+
+ th_zone = kzalloc(sizeof(struct exynos4_thermal_zone), GFP_KERNEL);
+ if (!th_zone) {
+ ret = -ENOMEM;
+ goto err_unregister;
+ }
+
+ th_zone->sensor_conf = sensor_conf;
+
+ th_zone->sensor_data = sensor_conf->sensor_data;
+ if (!th_zone->sensor_data) {
+ pr_err("Temperature sensor data not initialised\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->cool_dev = cpufreq_cooling_register(
+ (struct freq_pctg_table *)th_zone->sensor_data->freq_tab,
+ th_zone->sensor_data->freq_tab_count, cpumask_of(0));
+
+ if (IS_ERR(th_zone->cool_dev)) {
+ pr_err("Failed to register cpufreq cooling device\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name,
+ 3, NULL, &exynos4_dev_ops, 0, 0, 0, 1000);
+ if (IS_ERR(th_zone->therm_dev)) {
+ pr_err("Failed to register thermal zone device\n");
+ ret = -EINVAL;
+ goto err_unregister;
+ }
+
+ th_zone->active_interval = 1;
+ th_zone->idle_interval = 10;
+
+ exynos4_set_mode(th_zone->therm_dev, THERMAL_DEVICE_DISABLED);
+
+ pr_info("Exynos: Kernel Thermal management registered\n");
+
+ return 0;
+
+err_unregister:
+ exynos4_unregister_thermal();
+ return ret;
+}
+EXPORT_SYMBOL(exynos4_register_thermal);
+
+void exynos4_unregister_thermal(void)
+{
+ if (th_zone && th_zone->cool_dev)
+ cpufreq_cooling_unregister();
+
+ if (th_zone && th_zone->therm_dev)
+ thermal_zone_device_unregister(th_zone->therm_dev);
+
+ kfree(th_zone);
+
+ pr_info("Exynos: Kernel Thermal management unregistered\n");
+}
+EXPORT_SYMBOL(exynos4_unregister_thermal);
diff --git a/include/linux/exynos_thermal.h b/include/linux/exynos_thermal.h
new file mode 100644
index 0000000..de7195b
--- /dev/null
+++ b/include/linux/exynos_thermal.h
@@ -0,0 +1,59 @@
+/* linux/include/linux/exynos_thermal.h
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef THERMAL_INTERFACE_H
+#define THERMAL_INTERFACE_H
+/* CPU Zone information */
+
+#define SENSOR_NAME_LEN 16
+
+#define PANIC_ZONE 4
+#define WARN_ZONE 3
+#define MONITOR_ZONE 2
+#define SAFE_ZONE 1
+#define NO_ACTION 0
+
+/**
+ * struct exynos4_tmu_platform_data
+ * @name: name of the temperature sensor
+ * @read_temperature: A function pointer to read temperature info
+ * @private_data: Temperature sensor private data
+ * @sensor_data: Sensor specific information like trigger temperature, level
+ */
+struct thermal_sensor_conf {
+ char name[SENSOR_NAME_LEN];
+ int (*read_temperature)(void *data);
+ void *private_data;
+ void *sensor_data;
+};
+
+/**
+ * exynos4_register_thermal: Register to the exynos thermal interface.
+ * @sensor_conf: Structure containing temperature sensor information
+ *
+ * returns zero on success, else negative errno.
+ */
+int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf);
+
+/**
+ * exynos4_unregister_thermal: Un-register from the exynos thermal interface.
+ *
+ * return not applicable.
+ */
+void exynos4_unregister_thermal(void);
+
+/**
+ * exynos4_report_trigger: Report any trigger level crossed in the
+ * temperature sensor. This may be useful to take any cooling action.
+ *
+ * return not applicable.
+ */
+extern void exynos4_report_trigger(void);
+#endif
--
1.7.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 12:11 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linaro-dev, patches, linux-kernel, lm-sensors, linux-acpi
Export and register information from the hwmon tmu sensor to the samsung
exynos kernel thermal framework where different cooling devices and thermal
zone are binded. The exported information is based according to the data
structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
functions are currently left although all of them are present in generic
linux thermal layer.
Also the platform data structure is modified to pass frequency cooling
in percentages for each thermal level.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
include/linux/platform_data/exynos4_tmu.h | 7 ++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
index f2359a0..6912a7f 100644
--- a/drivers/hwmon/exynos4_tmu.c
+++ b/drivers/hwmon/exynos4_tmu.c
@@ -37,6 +37,9 @@
#include <linux/hwmon-sysfs.h>
#include <linux/platform_data/exynos4_tmu.h>
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+#include <linux/exynos_thermal.h>
+#endif
#define EXYNOS4_TMU_REG_TRIMINFO 0x0
#define EXYNOS4_TMU_REG_CONTROL 0x20
@@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
- enable_irq(data->irq);
clk_disable(data->clk);
mutex_unlock(&data->lock);
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ exynos4_report_trigger();
+#endif
+ enable_irq(data->irq);
}
static irqreturn_t exynos4_tmu_irq(int irq, void *id)
@@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
.attrs = exynos4_tmu_attributes,
};
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+static struct thermal_sensor_conf exynos4_sensor_conf = {
+ .name = "exynos4-therm",
+ .read_temperature = (int (*)(void *))exynos4_tmu_read,
+};
+#endif
+/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
+
static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
{
struct exynos4_tmu_data *data;
@@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
}
exynos4_tmu_control(pdev, true);
-
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ (&exynos4_sensor_conf)->private_data = data;
+ (&exynos4_sensor_conf)->sensor_data = pdata;
+ ret = exynos4_register_thermal(&exynos4_sensor_conf);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to register thermal interface\n");
+ goto err_hwmon_device;
+ }
+#endif
return 0;
-
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+err_hwmon_device:
+ hwmon_device_unregister(data->hwmon_dev);
+#endif
err_create_group:
sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
err_clk:
@@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
exynos4_tmu_control(pdev, false);
+#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
+ exynos4_unregister_thermal();
+#endif
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
index 39e038c..642c508 100644
--- a/include/linux/platform_data/exynos4_tmu.h
+++ b/include/linux/platform_data/exynos4_tmu.h
@@ -21,6 +21,7 @@
#ifndef _LINUX_EXYNOS4_TMU_H
#define _LINUX_EXYNOS4_TMU_H
+#include <linux/cpu_cooling.h>
enum calibration_type {
TYPE_ONE_POINT_TRIMMING,
@@ -64,6 +65,9 @@ enum calibration_type {
* in the positive-TC generator block
* 0 <= reference_voltage <= 31
* @cal_type: calibration type for temperature
+ * @freq_pctg_table: Table representing frequency reduction percentage.
+ * @freq_tab_count: Count of the above table as frequency reduction may
+ * applicable to only some of the trigger levels.
*
* This structure is required for configuration of exynos4_tmu driver.
*/
@@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
u8 reference_voltage;
enum calibration_type cal_type;
+
+ struct freq_pctg_table freq_tab[4];
+ unsigned int freq_tab_count;
};
#endif /* _LINUX_EXYNOS4_TMU_H */
--
1.7.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [lm-sensors] [RFC PATCH 3/3] ARM: exynos4: Add thermal sensor
@ 2011-12-21 11:59 ` Amit Daniel Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Daniel Kachhap @ 2011-12-21 12:11 UTC (permalink / raw)
To: linux-pm, linux-samsung-soc
Cc: linaro-dev, patches, linux-kernel, lm-sensors, linux-acpi
This patch adds necessary source definations needed for TMU driver and
the platform device support.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
arch/arm/mach-exynos/Kconfig | 12 +++++
arch/arm/mach-exynos/Makefile | 1 +
arch/arm/mach-exynos/clock.c | 4 ++
arch/arm/mach-exynos/dev-tmu.c | 64 +++++++++++++++++++++++++++++
arch/arm/mach-exynos/include/mach/irqs.h | 2 +
arch/arm/mach-exynos/include/mach/map.h | 1 +
arch/arm/mach-exynos/mach-origen.c | 1 +
arch/arm/plat-samsung/include/plat/devs.h | 1 +
8 files changed, 86 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-exynos/dev-tmu.c
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 724ec0f..cfc6119 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -82,6 +82,17 @@ config EXYNOS4_DEV_DWMCI
help
Compile in platform device definitions for DWMCI
+config EXYNOS4_DEV_TMU
+ bool "Exynos4 tmu device support"
+ default n
+ depends on ARCH_EXYNOS4
+ ---help---
+ Compile in platform device definitions for TMU. This macro also
+ enables compilation hwmon base TMU driver and also allows compilation
+ of the platform device files. The platform data in this case is trip
+ temperature and some tmu h/w configurations related parameter.
+
+
config EXYNOS4_SETUP_I2C1
bool
help
@@ -288,6 +299,7 @@ config MACH_ORIGEN
select SAMSUNG_DEV_BACKLIGHT
select SAMSUNG_DEV_PWM
select EXYNOS4_DEV_PD
+ select EXYNOS4_DEV_TMU
select EXYNOS4_SETUP_FIMD0
select EXYNOS4_SETUP_SDHCI
select EXYNOS4_SETUP_USB_PHY
diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
index 59069a3..d2493e8 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_EXYNOS4_DEV_AHCI) += dev-ahci.o
obj-$(CONFIG_EXYNOS4_DEV_PD) += dev-pd.o
obj-$(CONFIG_EXYNOS4_DEV_SYSMMU) += dev-sysmmu.o
obj-$(CONFIG_EXYNOS4_DEV_DWMCI) += dev-dwmci.o
+obj-$(CONFIG_EXYNOS4_DEV_TMU) += dev-tmu.o
obj-$(CONFIG_EXYNOS4_SETUP_FIMC) += setup-fimc.o
obj-$(CONFIG_EXYNOS4_SETUP_FIMD0) += setup-fimd0.o
diff --git a/arch/arm/mach-exynos/clock.c b/arch/arm/mach-exynos/clock.c
index 2894f0a..edecc5e 100644
--- a/arch/arm/mach-exynos/clock.c
+++ b/arch/arm/mach-exynos/clock.c
@@ -567,6 +567,10 @@ static struct clk init_clocks_off[] = {
.enable = exynos4_clk_ip_peril_ctrl,
.ctrlbit = (1 << 15),
}, {
+ .name = "tmu_apbif",
+ .enable = exynos4_clk_ip_perir_ctrl,
+ .ctrlbit = (1 << 17),
+ }, {
.name = "keypad",
.enable = exynos4_clk_ip_perir_ctrl,
.ctrlbit = (1 << 16),
diff --git a/arch/arm/mach-exynos/dev-tmu.c b/arch/arm/mach-exynos/dev-tmu.c
new file mode 100644
index 0000000..2e98912
--- /dev/null
+++ b/arch/arm/mach-exynos/dev-tmu.c
@@ -0,0 +1,64 @@
+/* linux/arch/arm/mach-exynos4/dev-tmu.c
+ *
+ * Copyright 2011 by SAMSUNG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/platform_data/exynos4_tmu.h>
+#include <asm/irq.h>
+
+#include <mach/irqs.h>
+#include <mach/map.h>
+#include <plat/devs.h>
+
+static struct resource exynos4_tmu_resource[] = {
+ [0] = {
+ .start = EXYNOS4_PA_TMU,
+ .end = EXYNOS4_PA_TMU + 0xFFFF - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = IRQ_TMU_TRIG0,
+ .end = IRQ_TMU_TRIG0,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct exynos4_tmu_platform_data default_tmu_data = {
+ .threshold = 80,
+ .trigger_levels[0] = 2,
+ .trigger_levels[1] = 5,
+ .trigger_levels[2] = 20,
+ .trigger_levels[3] = 30,
+ .trigger_level0_en = 1,
+ .trigger_level1_en = 1,
+ .trigger_level2_en = 1,
+ .trigger_level3_en = 1,
+ .gain = 15,
+ .reference_voltage = 7,
+ .cal_type = TYPE_ONE_POINT_TRIMMING,
+ .freq_tab[0] = {
+ .freq_clip_pctg[0] = 30,
+ },
+ .freq_tab[1] = {
+ .freq_clip_pctg[0] = 99,
+ },
+ .freq_tab_count = 2,
+};
+
+struct platform_device exynos4_device_tmu = {
+ .name = "exynos4-tmu",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(exynos4_tmu_resource),
+ .resource = exynos4_tmu_resource,
+ .dev = {
+ .platform_data = &default_tmu_data,
+ },
+};
diff --git a/arch/arm/mach-exynos/include/mach/irqs.h b/arch/arm/mach-exynos/include/mach/irqs.h
index dfd4b7e..d66a24b 100644
--- a/arch/arm/mach-exynos/include/mach/irqs.h
+++ b/arch/arm/mach-exynos/include/mach/irqs.h
@@ -125,6 +125,8 @@
#define COMBINER_GROUP(x) ((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(128))
#define COMBINER_IRQ(x, y) (COMBINER_GROUP(x) + y)
+#define IRQ_TMU_TRIG0 COMBINER_IRQ(2, 4)
+#define IRQ_TMU_TRIG1 COMBINER_IRQ(3, 4)
#define IRQ_SYSMMU_MDMA0_0 COMBINER_IRQ(4, 0)
#define IRQ_SYSMMU_SSS_0 COMBINER_IRQ(4, 1)
#define IRQ_SYSMMU_FIMC0_0 COMBINER_IRQ(4, 2)
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 058541d..0d79b88 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -66,6 +66,7 @@
#define EXYNOS4_PA_COREPERI 0x10500000
#define EXYNOS4_PA_TWD 0x10500600
#define EXYNOS4_PA_L2CC 0x10502000
+#define EXYNOS4_PA_TMU 0x100C0000
#define EXYNOS4_PA_MDMA 0x10810000
#define EXYNOS4_PA_PDMA0 0x12680000
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index f80b563..699140a 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -615,6 +615,7 @@ static struct platform_device *origen_devices[] __initdata = {
&exynos4_device_pd[PD_MFC],
&origen_device_gpiokeys,
&origen_lcd_hv070wsa,
+ &exynos4_device_tmu,
};
/* LCD Backlight data */
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index ab633c9..74cbf0d 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -135,6 +135,7 @@ extern struct platform_device exynos4_device_pcm2;
extern struct platform_device exynos4_device_pd[];
extern struct platform_device exynos4_device_spdif;
extern struct platform_device exynos4_device_sysmmu;
+extern struct platform_device exynos4_device_tmu;
extern struct platform_device samsung_asoc_dma;
extern struct platform_device samsung_asoc_idma;
--
1.7.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2011-12-21 11:59 ` [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer Amit Daniel Kachhap
@ 2012-01-03 22:25 ` Guenter Roeck
-1 siblings, 0 replies; 25+ messages in thread
From: Guenter Roeck @ 2012-01-03 22:25 UTC (permalink / raw)
To: Amit Daniel Kachhap
Cc: linux-pm@lists.linux-foundation.org,
linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
lenb@kernel.org
On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
> Export and register information from the hwmon tmu sensor to the samsung
> exynos kernel thermal framework where different cooling devices and thermal
> zone are binded. The exported information is based according to the data
> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
> functions are currently left although all of them are present in generic
> linux thermal layer.
> Also the platform data structure is modified to pass frequency cooling
> in percentages for each thermal level.
>
Hi Amit,
wouldn't it make more sense to merge the code as necessary from
hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
hwmon/exynos4_tmu.c entirely ?
With that, you should get the hwmon entries for free, and we would not
have to maintain two drivers with overlapping functionality.
Thanks,
Guenter
> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
> ---
> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
> 2 files changed, 38 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
> index f2359a0..6912a7f 100644
> --- a/drivers/hwmon/exynos4_tmu.c
> +++ b/drivers/hwmon/exynos4_tmu.c
> @@ -37,6 +37,9 @@
> #include <linux/hwmon-sysfs.h>
>
> #include <linux/platform_data/exynos4_tmu.h>
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> +#include <linux/exynos_thermal.h>
> +#endif
>
> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
> #define EXYNOS4_TMU_REG_CONTROL 0x20
> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>
> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>
> - enable_irq(data->irq);
>
> clk_disable(data->clk);
> mutex_unlock(&data->lock);
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> + exynos4_report_trigger();
> +#endif
> + enable_irq(data->irq);
> }
>
> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
> .attrs = exynos4_tmu_attributes,
> };
>
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> +static struct thermal_sensor_conf exynos4_sensor_conf = {
> + .name = "exynos4-therm",
> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
> +};
> +#endif
> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
> +
> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
> {
> struct exynos4_tmu_data *data;
> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
> }
>
> exynos4_tmu_control(pdev, true);
> -
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> + (&exynos4_sensor_conf)->private_data = data;
> + (&exynos4_sensor_conf)->sensor_data = pdata;
> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
> + if (ret) {
> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
> + goto err_hwmon_device;
> + }
> +#endif
> return 0;
> -
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> +err_hwmon_device:
> + hwmon_device_unregister(data->hwmon_dev);
> +#endif
> err_create_group:
> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
> err_clk:
> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>
> exynos4_tmu_control(pdev, false);
>
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> + exynos4_unregister_thermal();
> +#endif
> hwmon_device_unregister(data->hwmon_dev);
> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>
> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
> index 39e038c..642c508 100644
> --- a/include/linux/platform_data/exynos4_tmu.h
> +++ b/include/linux/platform_data/exynos4_tmu.h
> @@ -21,6 +21,7 @@
>
> #ifndef _LINUX_EXYNOS4_TMU_H
> #define _LINUX_EXYNOS4_TMU_H
> +#include <linux/cpu_cooling.h>
>
> enum calibration_type {
> TYPE_ONE_POINT_TRIMMING,
> @@ -64,6 +65,9 @@ enum calibration_type {
> * in the positive-TC generator block
> * 0 <= reference_voltage <= 31
> * @cal_type: calibration type for temperature
> + * @freq_pctg_table: Table representing frequency reduction percentage.
> + * @freq_tab_count: Count of the above table as frequency reduction may
> + * applicable to only some of the trigger levels.
> *
> * This structure is required for configuration of exynos4_tmu driver.
> */
> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
> u8 reference_voltage;
>
> enum calibration_type cal_type;
> +
> + struct freq_pctg_table freq_tab[4];
> + unsigned int freq_tab_count;
> };
> #endif /* _LINUX_EXYNOS4_TMU_H */
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu
@ 2012-01-03 22:25 ` Guenter Roeck
0 siblings, 0 replies; 25+ messages in thread
From: Guenter Roeck @ 2012-01-03 22:25 UTC (permalink / raw)
To: Amit Daniel Kachhap
Cc: linux-pm@lists.linux-foundation.org,
linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
lenb@kernel.org
On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
> Export and register information from the hwmon tmu sensor to the samsung
> exynos kernel thermal framework where different cooling devices and thermal
> zone are binded. The exported information is based according to the data
> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
> functions are currently left although all of them are present in generic
> linux thermal layer.
> Also the platform data structure is modified to pass frequency cooling
> in percentages for each thermal level.
>
Hi Amit,
wouldn't it make more sense to merge the code as necessary from
hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
hwmon/exynos4_tmu.c entirely ?
With that, you should get the hwmon entries for free, and we would not
have to maintain two drivers with overlapping functionality.
Thanks,
Guenter
> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
> ---
> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
> 2 files changed, 38 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
> index f2359a0..6912a7f 100644
> --- a/drivers/hwmon/exynos4_tmu.c
> +++ b/drivers/hwmon/exynos4_tmu.c
> @@ -37,6 +37,9 @@
> #include <linux/hwmon-sysfs.h>
>
> #include <linux/platform_data/exynos4_tmu.h>
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> +#include <linux/exynos_thermal.h>
> +#endif
>
> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
> #define EXYNOS4_TMU_REG_CONTROL 0x20
> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>
> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>
> - enable_irq(data->irq);
>
> clk_disable(data->clk);
> mutex_unlock(&data->lock);
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> + exynos4_report_trigger();
> +#endif
> + enable_irq(data->irq);
> }
>
> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
> .attrs = exynos4_tmu_attributes,
> };
>
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> +static struct thermal_sensor_conf exynos4_sensor_conf = {
> + .name = "exynos4-therm",
> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
> +};
> +#endif
> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
> +
> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
> {
> struct exynos4_tmu_data *data;
> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
> }
>
> exynos4_tmu_control(pdev, true);
> -
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> + (&exynos4_sensor_conf)->private_data = data;
> + (&exynos4_sensor_conf)->sensor_data = pdata;
> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
> + if (ret) {
> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
> + goto err_hwmon_device;
> + }
> +#endif
> return 0;
> -
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> +err_hwmon_device:
> + hwmon_device_unregister(data->hwmon_dev);
> +#endif
> err_create_group:
> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
> err_clk:
> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>
> exynos4_tmu_control(pdev, false);
>
> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
> + exynos4_unregister_thermal();
> +#endif
> hwmon_device_unregister(data->hwmon_dev);
> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>
> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
> index 39e038c..642c508 100644
> --- a/include/linux/platform_data/exynos4_tmu.h
> +++ b/include/linux/platform_data/exynos4_tmu.h
> @@ -21,6 +21,7 @@
>
> #ifndef _LINUX_EXYNOS4_TMU_H
> #define _LINUX_EXYNOS4_TMU_H
> +#include <linux/cpu_cooling.h>
>
> enum calibration_type {
> TYPE_ONE_POINT_TRIMMING,
> @@ -64,6 +65,9 @@ enum calibration_type {
> * in the positive-TC generator block
> * 0 <= reference_voltage <= 31
> * @cal_type: calibration type for temperature
> + * @freq_pctg_table: Table representing frequency reduction percentage.
> + * @freq_tab_count: Count of the above table as frequency reduction may
> + * applicable to only some of the trigger levels.
> *
> * This structure is required for configuration of exynos4_tmu driver.
> */
> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
> u8 reference_voltage;
>
> enum calibration_type cal_type;
> +
> + struct freq_pctg_table freq_tab[4];
> + unsigned int freq_tab_count;
> };
> #endif /* _LINUX_EXYNOS4_TMU_H */
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2012-01-03 22:25 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Guenter Roeck
@ 2012-01-04 10:26 ` Amit Kachhap
-1 siblings, 0 replies; 25+ messages in thread
From: Amit Kachhap @ 2012-01-04 10:14 UTC (permalink / raw)
To: guenter.roeck, Donggeun Kim
Cc: linux-pm@lists.linux-foundation.org,
linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
lenb@kernel.org
Hi Guenter,
The main idea of this work is to leave the current userspace based
notification scheme and add the kernel based cooling scheme on top of
it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
this creates 2 hwmon entries.
Adding CC: Donggeun Kim to know his opinion.
Thanks,
Amit Daniel
On 4 January 2012 03:55, Guenter Roeck <guenter.roeck@ericsson.com> wrote:
> On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
>> Export and register information from the hwmon tmu sensor to the samsung
>> exynos kernel thermal framework where different cooling devices and thermal
>> zone are binded. The exported information is based according to the data
>> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
>> functions are currently left although all of them are present in generic
>> linux thermal layer.
>> Also the platform data structure is modified to pass frequency cooling
>> in percentages for each thermal level.
>>
> Hi Amit,
>
> wouldn't it make more sense to merge the code as necessary from
> hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
> hwmon/exynos4_tmu.c entirely ?
>
> With that, you should get the hwmon entries for free, and we would not
> have to maintain two drivers with overlapping functionality.
>
> Thanks,
> Guenter
>
>> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
>> ---
>> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
>> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
>> 2 files changed, 38 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
>> index f2359a0..6912a7f 100644
>> --- a/drivers/hwmon/exynos4_tmu.c
>> +++ b/drivers/hwmon/exynos4_tmu.c
>> @@ -37,6 +37,9 @@
>> #include <linux/hwmon-sysfs.h>
>>
>> #include <linux/platform_data/exynos4_tmu.h>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +#include <linux/exynos_thermal.h>
>> +#endif
>>
>> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
>> #define EXYNOS4_TMU_REG_CONTROL 0x20
>> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>>
>> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>>
>> - enable_irq(data->irq);
>>
>> clk_disable(data->clk);
>> mutex_unlock(&data->lock);
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + exynos4_report_trigger();
>> +#endif
>> + enable_irq(data->irq);
>> }
>>
>> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
>> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
>> .attrs = exynos4_tmu_attributes,
>> };
>>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +static struct thermal_sensor_conf exynos4_sensor_conf = {
>> + .name = "exynos4-therm",
>> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
>> +};
>> +#endif
>> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
>> +
>> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>> {
>> struct exynos4_tmu_data *data;
>> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>> }
>>
>> exynos4_tmu_control(pdev, true);
>> -
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + (&exynos4_sensor_conf)->private_data = data;
>> + (&exynos4_sensor_conf)->sensor_data = pdata;
>> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
>> + if (ret) {
>> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
>> + goto err_hwmon_device;
>> + }
>> +#endif
>> return 0;
>> -
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +err_hwmon_device:
>> + hwmon_device_unregister(data->hwmon_dev);
>> +#endif
>> err_create_group:
>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>> err_clk:
>> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>>
>> exynos4_tmu_control(pdev, false);
>>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + exynos4_unregister_thermal();
>> +#endif
>> hwmon_device_unregister(data->hwmon_dev);
>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>
>> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
>> index 39e038c..642c508 100644
>> --- a/include/linux/platform_data/exynos4_tmu.h
>> +++ b/include/linux/platform_data/exynos4_tmu.h
>> @@ -21,6 +21,7 @@
>>
>> #ifndef _LINUX_EXYNOS4_TMU_H
>> #define _LINUX_EXYNOS4_TMU_H
>> +#include <linux/cpu_cooling.h>
>>
>> enum calibration_type {
>> TYPE_ONE_POINT_TRIMMING,
>> @@ -64,6 +65,9 @@ enum calibration_type {
>> * in the positive-TC generator block
>> * 0 <= reference_voltage <= 31
>> * @cal_type: calibration type for temperature
>> + * @freq_pctg_table: Table representing frequency reduction percentage.
>> + * @freq_tab_count: Count of the above table as frequency reduction may
>> + * applicable to only some of the trigger levels.
>> *
>> * This structure is required for configuration of exynos4_tmu driver.
>> */
>> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
>> u8 reference_voltage;
>>
>> enum calibration_type cal_type;
>> +
>> + struct freq_pctg_table freq_tab[4];
>> + unsigned int freq_tab_count;
>> };
>> #endif /* _LINUX_EXYNOS4_TMU_H */
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2012-01-03 22:25 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Guenter Roeck
(?)
(?)
@ 2012-01-04 10:14 ` Amit Kachhap
-1 siblings, 0 replies; 25+ messages in thread
From: Amit Kachhap @ 2012-01-04 10:14 UTC (permalink / raw)
To: guenter.roeck, Donggeun Kim
Cc: linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
linux-pm@lists.linux-foundation.org
Hi Guenter,
The main idea of this work is to leave the current userspace based
notification scheme and add the kernel based cooling scheme on top of
it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
this creates 2 hwmon entries.
Adding CC: Donggeun Kim to know his opinion.
Thanks,
Amit Daniel
On 4 January 2012 03:55, Guenter Roeck <guenter.roeck@ericsson.com> wrote:
> On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
>> Export and register information from the hwmon tmu sensor to the samsung
>> exynos kernel thermal framework where different cooling devices and thermal
>> zone are binded. The exported information is based according to the data
>> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
>> functions are currently left although all of them are present in generic
>> linux thermal layer.
>> Also the platform data structure is modified to pass frequency cooling
>> in percentages for each thermal level.
>>
> Hi Amit,
>
> wouldn't it make more sense to merge the code as necessary from
> hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
> hwmon/exynos4_tmu.c entirely ?
>
> With that, you should get the hwmon entries for free, and we would not
> have to maintain two drivers with overlapping functionality.
>
> Thanks,
> Guenter
>
>> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
>> ---
>> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
>> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
>> 2 files changed, 38 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
>> index f2359a0..6912a7f 100644
>> --- a/drivers/hwmon/exynos4_tmu.c
>> +++ b/drivers/hwmon/exynos4_tmu.c
>> @@ -37,6 +37,9 @@
>> #include <linux/hwmon-sysfs.h>
>>
>> #include <linux/platform_data/exynos4_tmu.h>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +#include <linux/exynos_thermal.h>
>> +#endif
>>
>> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
>> #define EXYNOS4_TMU_REG_CONTROL 0x20
>> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>>
>> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>>
>> - enable_irq(data->irq);
>>
>> clk_disable(data->clk);
>> mutex_unlock(&data->lock);
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + exynos4_report_trigger();
>> +#endif
>> + enable_irq(data->irq);
>> }
>>
>> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
>> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
>> .attrs = exynos4_tmu_attributes,
>> };
>>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +static struct thermal_sensor_conf exynos4_sensor_conf = {
>> + .name = "exynos4-therm",
>> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
>> +};
>> +#endif
>> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
>> +
>> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>> {
>> struct exynos4_tmu_data *data;
>> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>> }
>>
>> exynos4_tmu_control(pdev, true);
>> -
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + (&exynos4_sensor_conf)->private_data = data;
>> + (&exynos4_sensor_conf)->sensor_data = pdata;
>> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
>> + if (ret) {
>> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
>> + goto err_hwmon_device;
>> + }
>> +#endif
>> return 0;
>> -
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +err_hwmon_device:
>> + hwmon_device_unregister(data->hwmon_dev);
>> +#endif
>> err_create_group:
>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>> err_clk:
>> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>>
>> exynos4_tmu_control(pdev, false);
>>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + exynos4_unregister_thermal();
>> +#endif
>> hwmon_device_unregister(data->hwmon_dev);
>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>
>> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
>> index 39e038c..642c508 100644
>> --- a/include/linux/platform_data/exynos4_tmu.h
>> +++ b/include/linux/platform_data/exynos4_tmu.h
>> @@ -21,6 +21,7 @@
>>
>> #ifndef _LINUX_EXYNOS4_TMU_H
>> #define _LINUX_EXYNOS4_TMU_H
>> +#include <linux/cpu_cooling.h>
>>
>> enum calibration_type {
>> TYPE_ONE_POINT_TRIMMING,
>> @@ -64,6 +65,9 @@ enum calibration_type {
>> * in the positive-TC generator block
>> * 0 <= reference_voltage <= 31
>> * @cal_type: calibration type for temperature
>> + * @freq_pctg_table: Table representing frequency reduction percentage.
>> + * @freq_tab_count: Count of the above table as frequency reduction may
>> + * applicable to only some of the trigger levels.
>> *
>> * This structure is required for configuration of exynos4_tmu driver.
>> */
>> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
>> u8 reference_voltage;
>>
>> enum calibration_type cal_type;
>> +
>> + struct freq_pctg_table freq_tab[4];
>> + unsigned int freq_tab_count;
>> };
>> #endif /* _LINUX_EXYNOS4_TMU_H */
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2012-01-04 10:26 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Amit Kachhap
(?)
@ 2012-01-04 10:23 ` R, Durgadoss
-1 siblings, 0 replies; 25+ messages in thread
From: R, Durgadoss @ 2012-01-04 10:23 UTC (permalink / raw)
To: Amit Kachhap, guenter.roeck@ericsson.com, Donggeun Kim
Cc: linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
linux-pm@lists.linux-foundation.org
Hi Amit Daniel,
> Hi Guenter,
>
> The main idea of this work is to leave the current userspace based
> notification scheme and add the kernel based cooling scheme on top of
> it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
But, What I feel is, kernel based cooling scheme will work only for
Controlling 'CPU' frequency. But in SoC's there are other devices that
Contribute to Thermal. For example, GPU, Display, Battery (during charging)
etc.. In this case, we need a user space to control these devices. So, in a
way, the user space notification mechanism is a unified solution for
throttling all devices and keeps the kernel code light weight.
I am also curious to know why the existing mechanism did not work for you ?
Thanks,
Durga
> this creates 2 hwmon entries.
> Adding CC: Donggeun Kim to know his opinion.
>
> Thanks,
> Amit Daniel
[snip.]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [linux-pm] [RFC PATCH 2/3] thermal: exynos4:
@ 2012-01-04 10:23 ` R, Durgadoss
0 siblings, 0 replies; 25+ messages in thread
From: R, Durgadoss @ 2012-01-04 10:23 UTC (permalink / raw)
To: Amit Kachhap, guenter.roeck@ericsson.com, Donggeun Kim
Cc: linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
linux-pm@lists.linux-foundation.org
Hi Amit Daniel,
> Hi Guenter,
>
> The main idea of this work is to leave the current userspace based
> notification scheme and add the kernel based cooling scheme on top of
> it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
But, What I feel is, kernel based cooling scheme will work only for
Controlling 'CPU' frequency. But in SoC's there are other devices that
Contribute to Thermal. For example, GPU, Display, Battery (during charging)
etc.. In this case, we need a user space to control these devices. So, in a
way, the user space notification mechanism is a unified solution for
throttling all devices and keeps the kernel code light weight.
I am also curious to know why the existing mechanism did not work for you ?
Thanks,
Durga
> this creates 2 hwmon entries.
> Adding CC: Donggeun Kim to know his opinion.
>
> Thanks,
> Amit Daniel
[snip.]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 25+ messages in thread
* RE: [linux-pm] [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
@ 2012-01-04 10:23 ` R, Durgadoss
0 siblings, 0 replies; 25+ messages in thread
From: R, Durgadoss @ 2012-01-04 10:23 UTC (permalink / raw)
To: Amit Kachhap, guenter.roeck@ericsson.com, Donggeun Kim
Cc: linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
linux-pm@lists.linux-foundation.org
Hi Amit Daniel,
> Hi Guenter,
>
> The main idea of this work is to leave the current userspace based
> notification scheme and add the kernel based cooling scheme on top of
> it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
But, What I feel is, kernel based cooling scheme will work only for
Controlling 'CPU' frequency. But in SoC's there are other devices that
Contribute to Thermal. For example, GPU, Display, Battery (during charging)
etc.. In this case, we need a user space to control these devices. So, in a
way, the user space notification mechanism is a unified solution for
throttling all devices and keeps the kernel code light weight.
I am also curious to know why the existing mechanism did not work for you ?
Thanks,
Durga
> this creates 2 hwmon entries.
> Adding CC: Donggeun Kim to know his opinion.
>
> Thanks,
> Amit Daniel
[snip.]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu
@ 2012-01-04 10:26 ` Amit Kachhap
0 siblings, 0 replies; 25+ messages in thread
From: Amit Kachhap @ 2012-01-04 10:26 UTC (permalink / raw)
To: guenter.roeck, Donggeun Kim
Cc: linux-pm@lists.linux-foundation.org,
linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
lenb@kernel.org
Hi Guenter,
The main idea of this work is to leave the current userspace based
notification scheme and add the kernel based cooling scheme on top of
it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
this creates 2 hwmon entries.
Adding CC: Donggeun Kim to know his opinion.
Thanks,
Amit Daniel
On 4 January 2012 03:55, Guenter Roeck <guenter.roeck@ericsson.com> wrote:
> On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
>> Export and register information from the hwmon tmu sensor to the samsung
>> exynos kernel thermal framework where different cooling devices and thermal
>> zone are binded. The exported information is based according to the data
>> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
>> functions are currently left although all of them are present in generic
>> linux thermal layer.
>> Also the platform data structure is modified to pass frequency cooling
>> in percentages for each thermal level.
>>
> Hi Amit,
>
> wouldn't it make more sense to merge the code as necessary from
> hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
> hwmon/exynos4_tmu.c entirely ?
>
> With that, you should get the hwmon entries for free, and we would not
> have to maintain two drivers with overlapping functionality.
>
> Thanks,
> Guenter
>
>> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
>> ---
>> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
>> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
>> 2 files changed, 38 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
>> index f2359a0..6912a7f 100644
>> --- a/drivers/hwmon/exynos4_tmu.c
>> +++ b/drivers/hwmon/exynos4_tmu.c
>> @@ -37,6 +37,9 @@
>> #include <linux/hwmon-sysfs.h>
>>
>> #include <linux/platform_data/exynos4_tmu.h>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +#include <linux/exynos_thermal.h>
>> +#endif
>>
>> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
>> #define EXYNOS4_TMU_REG_CONTROL 0x20
>> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>>
>> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>>
>> - enable_irq(data->irq);
>>
>> clk_disable(data->clk);
>> mutex_unlock(&data->lock);
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + exynos4_report_trigger();
>> +#endif
>> + enable_irq(data->irq);
>> }
>>
>> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
>> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
>> .attrs = exynos4_tmu_attributes,
>> };
>>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +static struct thermal_sensor_conf exynos4_sensor_conf = {
>> + .name = "exynos4-therm",
>> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
>> +};
>> +#endif
>> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
>> +
>> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>> {
>> struct exynos4_tmu_data *data;
>> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>> }
>>
>> exynos4_tmu_control(pdev, true);
>> -
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + (&exynos4_sensor_conf)->private_data = data;
>> + (&exynos4_sensor_conf)->sensor_data = pdata;
>> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
>> + if (ret) {
>> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
>> + goto err_hwmon_device;
>> + }
>> +#endif
>> return 0;
>> -
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> +err_hwmon_device:
>> + hwmon_device_unregister(data->hwmon_dev);
>> +#endif
>> err_create_group:
>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>> err_clk:
>> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>>
>> exynos4_tmu_control(pdev, false);
>>
>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>> + exynos4_unregister_thermal();
>> +#endif
>> hwmon_device_unregister(data->hwmon_dev);
>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>
>> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
>> index 39e038c..642c508 100644
>> --- a/include/linux/platform_data/exynos4_tmu.h
>> +++ b/include/linux/platform_data/exynos4_tmu.h
>> @@ -21,6 +21,7 @@
>>
>> #ifndef _LINUX_EXYNOS4_TMU_H
>> #define _LINUX_EXYNOS4_TMU_H
>> +#include <linux/cpu_cooling.h>
>>
>> enum calibration_type {
>> TYPE_ONE_POINT_TRIMMING,
>> @@ -64,6 +65,9 @@ enum calibration_type {
>> * in the positive-TC generator block
>> * 0 <= reference_voltage <= 31
>> * @cal_type: calibration type for temperature
>> + * @freq_pctg_table: Table representing frequency reduction percentage.
>> + * @freq_tab_count: Count of the above table as frequency reduction may
>> + * applicable to only some of the trigger levels.
>> *
>> * This structure is required for configuration of exynos4_tmu driver.
>> */
>> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
>> u8 reference_voltage;
>>
>> enum calibration_type cal_type;
>> +
>> + struct freq_pctg_table freq_tab[4];
>> + unsigned int freq_tab_count;
>> };
>> #endif /* _LINUX_EXYNOS4_TMU_H */
>
>
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 25+ messages in thread
* RE: [linux-pm] [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2012-01-04 10:23 ` [lm-sensors] [linux-pm] [RFC PATCH 2/3] thermal: exynos4: R, Durgadoss
@ 2012-01-04 16:20 ` Guenter Roeck
-1 siblings, 0 replies; 25+ messages in thread
From: Guenter Roeck @ 2012-01-04 16:20 UTC (permalink / raw)
To: R, Durgadoss
Cc: Amit Kachhap, Donggeun Kim, linux-samsung-soc@vger.kernel.org,
linaro-dev@lists.linaro.org, patches@linaro.org,
linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
linux-acpi@vger.kernel.org, linux-pm@lists.linux-foundation.org
On Wed, 2012-01-04 at 05:23 -0500, R, Durgadoss wrote:
> Hi Amit Daniel,
>
> > Hi Guenter,
> >
> > The main idea of this work is to leave the current userspace based
> > notification scheme and add the kernel based cooling scheme on top of
> > it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
>
> But, What I feel is, kernel based cooling scheme will work only for
> Controlling 'CPU' frequency. But in SoC's there are other devices that
> Contribute to Thermal. For example, GPU, Display, Battery (during charging)
> etc.. In this case, we need a user space to control these devices. So, in a
> way, the user space notification mechanism is a unified solution for
> throttling all devices and keeps the kernel code light weight.
>
> I am also curious to know why the existing mechanism did not work for you ?
>
That is one question.
For me, the main concern is that the proposed implementation creates
duplicate hwmon entries for the same device, which is simply messy. If
both the kernel thermal mechanism and the userspace mechanism are
needed, I think it would make more sense to use a thermal driver and
have that thermal driver generate the necessary userspace events.
Thanks,
Guenter
> Thanks,
> Durga
>
> > this creates 2 hwmon entries.
> > Adding CC: Donggeun Kim to know his opinion.
> >
> > Thanks,
> > Amit Daniel
> [snip.]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [linux-pm] [RFC PATCH 2/3] thermal: exynos4:
@ 2012-01-04 16:20 ` Guenter Roeck
0 siblings, 0 replies; 25+ messages in thread
From: Guenter Roeck @ 2012-01-04 16:20 UTC (permalink / raw)
To: R, Durgadoss
Cc: Amit Kachhap, Donggeun Kim, linux-samsung-soc@vger.kernel.org,
linaro-dev@lists.linaro.org, patches@linaro.org,
linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
linux-acpi@vger.kernel.org, linux-pm@lists.linux-foundation.org
On Wed, 2012-01-04 at 05:23 -0500, R, Durgadoss wrote:
> Hi Amit Daniel,
>
> > Hi Guenter,
> >
> > The main idea of this work is to leave the current userspace based
> > notification scheme and add the kernel based cooling scheme on top of
> > it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
>
> But, What I feel is, kernel based cooling scheme will work only for
> Controlling 'CPU' frequency. But in SoC's there are other devices that
> Contribute to Thermal. For example, GPU, Display, Battery (during charging)
> etc.. In this case, we need a user space to control these devices. So, in a
> way, the user space notification mechanism is a unified solution for
> throttling all devices and keeps the kernel code light weight.
>
> I am also curious to know why the existing mechanism did not work for you ?
>
That is one question.
For me, the main concern is that the proposed implementation creates
duplicate hwmon entries for the same device, which is simply messy. If
both the kernel thermal mechanism and the userspace mechanism are
needed, I think it would make more sense to use a thermal driver and
have that thermal driver generate the necessary userspace events.
Thanks,
Guenter
> Thanks,
> Durga
>
> > this creates 2 hwmon entries.
> > Adding CC: Donggeun Kim to know his opinion.
> >
> > Thanks,
> > Amit Daniel
> [snip.]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2012-01-04 10:26 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Amit Kachhap
(?)
@ 2012-01-05 5:57 ` Donggeun Kim
-1 siblings, 0 replies; 25+ messages in thread
From: Donggeun Kim @ 2012-01-05 5:57 UTC (permalink / raw)
To: Amit Kachhap
Cc: guenter.roeck, linux-pm@lists.linux-foundation.org,
linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
lenb@kernel.org
Actually, the TMU driver is closely related to thermal layer.
I think it's okay to move it to the thermal.
Thanks.
-Donggeun
On 2012년 01월 04일 19:14, Amit Kachhap wrote:
> Hi Guenter,
>
> The main idea of this work is to leave the current userspace based
> notification scheme and add the kernel based cooling scheme on top of
> it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
> this creates 2 hwmon entries.
> Adding CC: Donggeun Kim to know his opinion.
>
> Thanks,
> Amit Daniel
>
> On 4 January 2012 03:55, Guenter Roeck <guenter.roeck@ericsson.com> wrote:
>> On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
>>> Export and register information from the hwmon tmu sensor to the samsung
>>> exynos kernel thermal framework where different cooling devices and thermal
>>> zone are binded. The exported information is based according to the data
>>> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
>>> functions are currently left although all of them are present in generic
>>> linux thermal layer.
>>> Also the platform data structure is modified to pass frequency cooling
>>> in percentages for each thermal level.
>>>
>> Hi Amit,
>>
>> wouldn't it make more sense to merge the code as necessary from
>> hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
>> hwmon/exynos4_tmu.c entirely ?
>>
>> With that, you should get the hwmon entries for free, and we would not
>> have to maintain two drivers with overlapping functionality.
>>
>> Thanks,
>> Guenter
>>
>>> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
>>> ---
>>> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
>>> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
>>> 2 files changed, 38 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
>>> index f2359a0..6912a7f 100644
>>> --- a/drivers/hwmon/exynos4_tmu.c
>>> +++ b/drivers/hwmon/exynos4_tmu.c
>>> @@ -37,6 +37,9 @@
>>> #include <linux/hwmon-sysfs.h>
>>>
>>> #include <linux/platform_data/exynos4_tmu.h>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +#include <linux/exynos_thermal.h>
>>> +#endif
>>>
>>> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
>>> #define EXYNOS4_TMU_REG_CONTROL 0x20
>>> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>>>
>>> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>>>
>>> - enable_irq(data->irq);
>>>
>>> clk_disable(data->clk);
>>> mutex_unlock(&data->lock);
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + exynos4_report_trigger();
>>> +#endif
>>> + enable_irq(data->irq);
>>> }
>>>
>>> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
>>> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
>>> .attrs = exynos4_tmu_attributes,
>>> };
>>>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +static struct thermal_sensor_conf exynos4_sensor_conf = {
>>> + .name = "exynos4-therm",
>>> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
>>> +};
>>> +#endif
>>> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
>>> +
>>> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>>> {
>>> struct exynos4_tmu_data *data;
>>> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>>> }
>>>
>>> exynos4_tmu_control(pdev, true);
>>> -
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + (&exynos4_sensor_conf)->private_data = data;
>>> + (&exynos4_sensor_conf)->sensor_data = pdata;
>>> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
>>> + if (ret) {
>>> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
>>> + goto err_hwmon_device;
>>> + }
>>> +#endif
>>> return 0;
>>> -
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +err_hwmon_device:
>>> + hwmon_device_unregister(data->hwmon_dev);
>>> +#endif
>>> err_create_group:
>>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>> err_clk:
>>> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>>>
>>> exynos4_tmu_control(pdev, false);
>>>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + exynos4_unregister_thermal();
>>> +#endif
>>> hwmon_device_unregister(data->hwmon_dev);
>>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>>
>>> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
>>> index 39e038c..642c508 100644
>>> --- a/include/linux/platform_data/exynos4_tmu.h
>>> +++ b/include/linux/platform_data/exynos4_tmu.h
>>> @@ -21,6 +21,7 @@
>>>
>>> #ifndef _LINUX_EXYNOS4_TMU_H
>>> #define _LINUX_EXYNOS4_TMU_H
>>> +#include <linux/cpu_cooling.h>
>>>
>>> enum calibration_type {
>>> TYPE_ONE_POINT_TRIMMING,
>>> @@ -64,6 +65,9 @@ enum calibration_type {
>>> * in the positive-TC generator block
>>> * 0 <= reference_voltage <= 31
>>> * @cal_type: calibration type for temperature
>>> + * @freq_pctg_table: Table representing frequency reduction percentage.
>>> + * @freq_tab_count: Count of the above table as frequency reduction may
>>> + * applicable to only some of the trigger levels.
>>> *
>>> * This structure is required for configuration of exynos4_tmu driver.
>>> */
>>> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
>>> u8 reference_voltage;
>>>
>>> enum calibration_type cal_type;
>>> +
>>> + struct freq_pctg_table freq_tab[4];
>>> + unsigned int freq_tab_count;
>>> };
>>> #endif /* _LINUX_EXYNOS4_TMU_H */
>>
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
2012-01-04 10:26 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Amit Kachhap
(?)
(?)
@ 2012-01-05 5:57 ` Donggeun Kim
-1 siblings, 0 replies; 25+ messages in thread
From: Donggeun Kim @ 2012-01-05 5:57 UTC (permalink / raw)
To: Amit Kachhap
Cc: linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
linux-pm@lists.linux-foundation.org, guenter.roeck
Actually, the TMU driver is closely related to thermal layer.
I think it's okay to move it to the thermal.
Thanks.
-Donggeun
On 2012년 01월 04일 19:14, Amit Kachhap wrote:
> Hi Guenter,
>
> The main idea of this work is to leave the current userspace based
> notification scheme and add the kernel based cooling scheme on top of
> it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
> this creates 2 hwmon entries.
> Adding CC: Donggeun Kim to know his opinion.
>
> Thanks,
> Amit Daniel
>
> On 4 January 2012 03:55, Guenter Roeck <guenter.roeck@ericsson.com> wrote:
>> On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
>>> Export and register information from the hwmon tmu sensor to the samsung
>>> exynos kernel thermal framework where different cooling devices and thermal
>>> zone are binded. The exported information is based according to the data
>>> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
>>> functions are currently left although all of them are present in generic
>>> linux thermal layer.
>>> Also the platform data structure is modified to pass frequency cooling
>>> in percentages for each thermal level.
>>>
>> Hi Amit,
>>
>> wouldn't it make more sense to merge the code as necessary from
>> hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
>> hwmon/exynos4_tmu.c entirely ?
>>
>> With that, you should get the hwmon entries for free, and we would not
>> have to maintain two drivers with overlapping functionality.
>>
>> Thanks,
>> Guenter
>>
>>> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
>>> ---
>>> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
>>> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
>>> 2 files changed, 38 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
>>> index f2359a0..6912a7f 100644
>>> --- a/drivers/hwmon/exynos4_tmu.c
>>> +++ b/drivers/hwmon/exynos4_tmu.c
>>> @@ -37,6 +37,9 @@
>>> #include <linux/hwmon-sysfs.h>
>>>
>>> #include <linux/platform_data/exynos4_tmu.h>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +#include <linux/exynos_thermal.h>
>>> +#endif
>>>
>>> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
>>> #define EXYNOS4_TMU_REG_CONTROL 0x20
>>> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>>>
>>> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>>>
>>> - enable_irq(data->irq);
>>>
>>> clk_disable(data->clk);
>>> mutex_unlock(&data->lock);
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + exynos4_report_trigger();
>>> +#endif
>>> + enable_irq(data->irq);
>>> }
>>>
>>> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
>>> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
>>> .attrs = exynos4_tmu_attributes,
>>> };
>>>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +static struct thermal_sensor_conf exynos4_sensor_conf = {
>>> + .name = "exynos4-therm",
>>> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
>>> +};
>>> +#endif
>>> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
>>> +
>>> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>>> {
>>> struct exynos4_tmu_data *data;
>>> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>>> }
>>>
>>> exynos4_tmu_control(pdev, true);
>>> -
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + (&exynos4_sensor_conf)->private_data = data;
>>> + (&exynos4_sensor_conf)->sensor_data = pdata;
>>> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
>>> + if (ret) {
>>> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
>>> + goto err_hwmon_device;
>>> + }
>>> +#endif
>>> return 0;
>>> -
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +err_hwmon_device:
>>> + hwmon_device_unregister(data->hwmon_dev);
>>> +#endif
>>> err_create_group:
>>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>> err_clk:
>>> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>>>
>>> exynos4_tmu_control(pdev, false);
>>>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + exynos4_unregister_thermal();
>>> +#endif
>>> hwmon_device_unregister(data->hwmon_dev);
>>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>>
>>> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
>>> index 39e038c..642c508 100644
>>> --- a/include/linux/platform_data/exynos4_tmu.h
>>> +++ b/include/linux/platform_data/exynos4_tmu.h
>>> @@ -21,6 +21,7 @@
>>>
>>> #ifndef _LINUX_EXYNOS4_TMU_H
>>> #define _LINUX_EXYNOS4_TMU_H
>>> +#include <linux/cpu_cooling.h>
>>>
>>> enum calibration_type {
>>> TYPE_ONE_POINT_TRIMMING,
>>> @@ -64,6 +65,9 @@ enum calibration_type {
>>> * in the positive-TC generator block
>>> * 0 <= reference_voltage <= 31
>>> * @cal_type: calibration type for temperature
>>> + * @freq_pctg_table: Table representing frequency reduction percentage.
>>> + * @freq_tab_count: Count of the above table as frequency reduction may
>>> + * applicable to only some of the trigger levels.
>>> *
>>> * This structure is required for configuration of exynos4_tmu driver.
>>> */
>>> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
>>> u8 reference_voltage;
>>>
>>> enum calibration_type cal_type;
>>> +
>>> + struct freq_pctg_table freq_tab[4];
>>> + unsigned int freq_tab_count;
>>> };
>>> #endif /* _LINUX_EXYNOS4_TMU_H */
>>
>>
>
_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-pm
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu
@ 2012-01-05 5:57 ` Donggeun Kim
0 siblings, 0 replies; 25+ messages in thread
From: Donggeun Kim @ 2012-01-05 5:57 UTC (permalink / raw)
To: Amit Kachhap
Cc: guenter.roeck, linux-pm@lists.linux-foundation.org,
linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
lenb@kernel.org
QWN0dWFsbHksIHRoZSBUTVUgZHJpdmVyIGlzIGNsb3NlbHkgcmVsYXRlZCB0byB0aGVybWFsIGxh
eWVyLgpJIHRoaW5rIGl0J3Mgb2theSB0byBtb3ZlIGl0IHRvIHRoZSB0aGVybWFsLgoKVGhhbmtz
LgotRG9uZ2dldW4KCk9uIDIwMTLrhYQgMDHsm5QgMDTsnbwgMTk6MTQsIEFtaXQgS2FjaGhhcCB3
cm90ZToKPiBIaSBHdWVudGVyLAo+IAo+IFRoZSBtYWluIGlkZWEgb2YgdGhpcyB3b3JrIGlzIHRv
IGxlYXZlIHRoZSBjdXJyZW50IHVzZXJzcGFjZSBiYXNlZAo+IG5vdGlmaWNhdGlvbiBzY2hlbWUg
YW5kIGFkZCB0aGUga2VybmVsIGJhc2VkIGNvb2xpbmcgc2NoZW1lIG9uIHRvcCBvZgo+IGl0LiBB
bnl3YXksIEl0IGlzIGEgZ29vZCBpZGVhIHRvIG1vdmUgdGhlIGZpbGUgaHdtb24vZXh5bm9zNF90
bXUuYyBhcwo+IHRoaXMgY3JlYXRlcyAyIGh3bW9uIGVudHJpZXMuCj4gQWRkaW5nIENDOiBEb25n
Z2V1biBLaW0gdG8ga25vdyBoaXMgb3Bpbmlvbi4KPiAKPiBUaGFua3MsCj4gQW1pdCBEYW5pZWwK
PiAKPiBPbiA0IEphbnVhcnkgMjAxMiAwMzo1NSwgR3VlbnRlciBSb2VjayA8Z3VlbnRlci5yb2Vj
a0Blcmljc3Nvbi5jb20+IHdyb3RlOgo+PiBPbiBXZWQsIDIwMTEtMTItMjEgYXQgMDY6NTkgLTA1
MDAsIEFtaXQgRGFuaWVsIEthY2hoYXAgd3JvdGU6Cj4+PiBFeHBvcnQgYW5kIHJlZ2lzdGVyIGlu
Zm9ybWF0aW9uIGZyb20gdGhlIGh3bW9uIHRtdSBzZW5zb3IgdG8gdGhlIHNhbXN1bmcKPj4+IGV4
eW5vcyBrZXJuZWwgdGhlcm1hbCBmcmFtZXdvcmsgd2hlcmUgZGlmZmVyZW50IGNvb2xpbmcgZGV2
aWNlcyBhbmQgdGhlcm1hbAo+Pj4gem9uZSBhcmUgYmluZGVkLiBUaGUgZXhwb3J0ZWQgaW5mb3Jt
YXRpb24gaXMgYmFzZWQgYWNjb3JkaW5nIHRvIHRoZSBkYXRhCj4+PiBzdHJ1Y3R1cmUgdGhlcm1h
bF9zZW5zb3JfY29uZiBwcmVzZW50IGluIGV4eW5vc190aGVybWFsLmguIEhXTU9OIHN5c2ZzCj4+
PiBmdW5jdGlvbnMgYXJlIGN1cnJlbnRseSBsZWZ0IGFsdGhvdWdoIGFsbCBvZiB0aGVtIGFyZSBw
cmVzZW50IGluIGdlbmVyaWMKPj4+IGxpbnV4IHRoZXJtYWwgbGF5ZXIuCj4+PiBBbHNvIHRoZSBw
bGF0Zm9ybSBkYXRhIHN0cnVjdHVyZSBpcyBtb2RpZmllZCB0byBwYXNzIGZyZXF1ZW5jeSBjb29s
aW5nCj4+PiBpbiBwZXJjZW50YWdlcyBmb3IgZWFjaCB0aGVybWFsIGxldmVsLgo+Pj4KPj4gSGkg
QW1pdCwKPj4KPj4gd291bGRuJ3QgaXQgbWFrZSBtb3JlIHNlbnNlIHRvIG1lcmdlIHRoZSBjb2Rl
IGFzIG5lY2Vzc2FyeSBmcm9tCj4+IGh3bW9uL2V4eW5vczRfdG11LmMgaW50byB0aGUgbmV3IHRo
ZXJtYWwvZXh5bm9zX3RoZXJtYWwuYywgYW5kIGRyb3AKPj4gaHdtb24vZXh5bm9zNF90bXUuYyBl
bnRpcmVseSA/Cj4+Cj4+IFdpdGggdGhhdCwgeW91IHNob3VsZCBnZXQgdGhlIGh3bW9uIGVudHJp
ZXMgZm9yIGZyZWUsIGFuZCB3ZSB3b3VsZCBub3QKPj4gaGF2ZSB0byBtYWludGFpbiB0d28gZHJp
dmVycyB3aXRoIG92ZXJsYXBwaW5nIGZ1bmN0aW9uYWxpdHkuCj4+Cj4+IFRoYW5rcywKPj4gR3Vl
bnRlcgo+Pgo+Pj4gU2lnbmVkLW9mZi1ieTogQW1pdCBEYW5pZWwgS2FjaGhhcCA8YW1pdC5rYWNo
aGFwQGxpbmFyby5vcmc+Cj4+PiAtLS0KPj4+ICBkcml2ZXJzL2h3bW9uL2V4eW5vczRfdG11LmMg
ICAgICAgICAgICAgICB8ICAgMzQgKysrKysrKysrKysrKysrKysrKysrKysrKystLQo+Pj4gIGlu
Y2x1ZGUvbGludXgvcGxhdGZvcm1fZGF0YS9leHlub3M0X3RtdS5oIHwgICAgNyArKysrKysKPj4+
ICAyIGZpbGVzIGNoYW5nZWQsIDM4IGluc2VydGlvbnMoKyksIDMgZGVsZXRpb25zKC0pCj4+Pgo+
Pj4gZGlmZiAtLWdpdCBhL2RyaXZlcnMvaHdtb24vZXh5bm9zNF90bXUuYyBiL2RyaXZlcnMvaHdt
b24vZXh5bm9zNF90bXUuYwo+Pj4gaW5kZXggZjIzNTlhMC4uNjkxMmE3ZiAxMDA2NDQKPj4+IC0t
LSBhL2RyaXZlcnMvaHdtb24vZXh5bm9zNF90bXUuYwo+Pj4gKysrIGIvZHJpdmVycy9od21vbi9l
eHlub3M0X3RtdS5jCj4+PiBAQCAtMzcsNiArMzcsOSBAQAo+Pj4gICNpbmNsdWRlIDxsaW51eC9o
d21vbi1zeXNmcy5oPgo+Pj4KPj4+ICAjaW5jbHVkZSA8bGludXgvcGxhdGZvcm1fZGF0YS9leHlu
b3M0X3RtdS5oPgo+Pj4gKyNpZmRlZiBDT05GSUdfU0FNU1VOR19USEVSTUFMX0lOVEVSRkFDRQo+
Pj4gKyNpbmNsdWRlIDxsaW51eC9leHlub3NfdGhlcm1hbC5oPgo+Pj4gKyNlbmRpZgo+Pj4KPj4+
ICAjZGVmaW5lIEVYWU5PUzRfVE1VX1JFR19UUklNSU5GTyAgICAgMHgwCj4+PiAgI2RlZmluZSBF
WFlOT1M0X1RNVV9SRUdfQ09OVFJPTCAgICAgICAgICAgICAgMHgyMAo+Pj4gQEAgLTI0OCwxMCAr
MjUxLDEzIEBAIHN0YXRpYyB2b2lkIGV4eW5vczRfdG11X3dvcmsoc3RydWN0IHdvcmtfc3RydWN0
ICp3b3JrKQo+Pj4KPj4+ICAgICAgIGtvYmplY3RfdWV2ZW50KCZkYXRhLT5od21vbl9kZXYtPmtv
YmosIEtPQkpfQ0hBTkdFKTsKPj4+Cj4+PiAtICAgICBlbmFibGVfaXJxKGRhdGEtPmlycSk7Cj4+
Pgo+Pj4gICAgICAgY2xrX2Rpc2FibGUoZGF0YS0+Y2xrKTsKPj4+ICAgICAgIG11dGV4X3VubG9j
aygmZGF0YS0+bG9jayk7Cj4+PiArI2lmZGVmIENPTkZJR19TQU1TVU5HX1RIRVJNQUxfSU5URVJG
QUNFCj4+PiArICAgICBleHlub3M0X3JlcG9ydF90cmlnZ2VyKCk7Cj4+PiArI2VuZGlmCj4+PiAr
ICAgICBlbmFibGVfaXJxKGRhdGEtPmlycSk7Cj4+PiAgfQo+Pj4KPj4+ICBzdGF0aWMgaXJxcmV0
dXJuX3QgZXh5bm9zNF90bXVfaXJxKGludCBpcnEsIHZvaWQgKmlkKQo+Pj4gQEAgLTM0NSw2ICsz
NTEsMTQgQEAgc3RhdGljIGNvbnN0IHN0cnVjdCBhdHRyaWJ1dGVfZ3JvdXAgZXh5bm9zNF90bXVf
YXR0cl9ncm91cCA9IHsKPj4+ICAgICAgIC5hdHRycyA9IGV4eW5vczRfdG11X2F0dHJpYnV0ZXMs
Cj4+PiAgfTsKPj4+Cj4+PiArI2lmZGVmIENPTkZJR19TQU1TVU5HX1RIRVJNQUxfSU5URVJGQUNF
Cj4+PiArc3RhdGljIHN0cnVjdCB0aGVybWFsX3NlbnNvcl9jb25mIGV4eW5vczRfc2Vuc29yX2Nv
bmYgPSB7Cj4+PiArICAgICAubmFtZSAgICAgICAgICAgICAgICAgICA9ICJleHlub3M0LXRoZXJt
IiwKPj4+ICsgICAgIC5yZWFkX3RlbXBlcmF0dXJlICAgICAgID0gKGludCAoKikodm9pZCAqKSll
eHlub3M0X3RtdV9yZWFkLAo+Pj4gK307Cj4+PiArI2VuZGlmCj4+PiArLypDT05GSUdfU0FNU1VO
R19USEVSTUFMX0lOVEVSRkFDRSovCj4+PiArCj4+PiAgc3RhdGljIGludCBfX2RldmluaXQgZXh5
bm9zNF90bXVfcHJvYmUoc3RydWN0IHBsYXRmb3JtX2RldmljZSAqcGRldikKPj4+ICB7Cj4+PiAg
ICAgICBzdHJ1Y3QgZXh5bm9zNF90bXVfZGF0YSAqZGF0YTsKPj4+IEBAIC00MzIsOSArNDQ2LDIw
IEBAIHN0YXRpYyBpbnQgX19kZXZpbml0IGV4eW5vczRfdG11X3Byb2JlKHN0cnVjdCBwbGF0Zm9y
bV9kZXZpY2UgKnBkZXYpCj4+PiAgICAgICB9Cj4+Pgo+Pj4gICAgICAgZXh5bm9zNF90bXVfY29u
dHJvbChwZGV2LCB0cnVlKTsKPj4+IC0KPj4+ICsjaWZkZWYgQ09ORklHX1NBTVNVTkdfVEhFUk1B
TF9JTlRFUkZBQ0UKPj4+ICsgICAgICgmZXh5bm9zNF9zZW5zb3JfY29uZiktPnByaXZhdGVfZGF0
YSA9IGRhdGE7Cj4+PiArICAgICAoJmV4eW5vczRfc2Vuc29yX2NvbmYpLT5zZW5zb3JfZGF0YSA9
IHBkYXRhOwo+Pj4gKyAgICAgcmV0ID0gZXh5bm9zNF9yZWdpc3Rlcl90aGVybWFsKCZleHlub3M0
X3NlbnNvcl9jb25mKTsKPj4+ICsgICAgIGlmIChyZXQpIHsKPj4+ICsgICAgICAgICAgICAgZGV2
X2VycigmcGRldi0+ZGV2LCAiRmFpbGVkIHRvIHJlZ2lzdGVyIHRoZXJtYWwgaW50ZXJmYWNlXG4i
KTsKPj4+ICsgICAgICAgICAgICAgZ290byBlcnJfaHdtb25fZGV2aWNlOwo+Pj4gKyAgICAgfQo+
Pj4gKyNlbmRpZgo+Pj4gICAgICAgcmV0dXJuIDA7Cj4+PiAtCj4+PiArI2lmZGVmIENPTkZJR19T
QU1TVU5HX1RIRVJNQUxfSU5URVJGQUNFCj4+PiArZXJyX2h3bW9uX2RldmljZToKPj4+ICsgICAg
IGh3bW9uX2RldmljZV91bnJlZ2lzdGVyKGRhdGEtPmh3bW9uX2Rldik7Cj4+PiArI2VuZGlmCj4+
PiAgZXJyX2NyZWF0ZV9ncm91cDoKPj4+ICAgICAgIHN5c2ZzX3JlbW92ZV9ncm91cCgmcGRldi0+
ZGV2LmtvYmosICZleHlub3M0X3RtdV9hdHRyX2dyb3VwKTsKPj4+ICBlcnJfY2xrOgo+Pj4gQEAg
LTQ1OCw2ICs0ODMsOSBAQCBzdGF0aWMgaW50IF9fZGV2ZXhpdCBleHlub3M0X3RtdV9yZW1vdmUo
c3RydWN0IHBsYXRmb3JtX2RldmljZSAqcGRldikKPj4+Cj4+PiAgICAgICBleHlub3M0X3RtdV9j
b250cm9sKHBkZXYsIGZhbHNlKTsKPj4+Cj4+PiArI2lmZGVmIENPTkZJR19TQU1TVU5HX1RIRVJN
QUxfSU5URVJGQUNFCj4+PiArICAgICBleHlub3M0X3VucmVnaXN0ZXJfdGhlcm1hbCgpOwo+Pj4g
KyNlbmRpZgo+Pj4gICAgICAgaHdtb25fZGV2aWNlX3VucmVnaXN0ZXIoZGF0YS0+aHdtb25fZGV2
KTsKPj4+ICAgICAgIHN5c2ZzX3JlbW92ZV9ncm91cCgmcGRldi0+ZGV2LmtvYmosICZleHlub3M0
X3RtdV9hdHRyX2dyb3VwKTsKPj4+Cj4+PiBkaWZmIC0tZ2l0IGEvaW5jbHVkZS9saW51eC9wbGF0
Zm9ybV9kYXRhL2V4eW5vczRfdG11LmggYi9pbmNsdWRlL2xpbnV4L3BsYXRmb3JtX2RhdGEvZXh5
bm9zNF90bXUuaAo+Pj4gaW5kZXggMzllMDM4Yy4uNjQyYzUwOCAxMDA2NDQKPj4+IC0tLSBhL2lu
Y2x1ZGUvbGludXgvcGxhdGZvcm1fZGF0YS9leHlub3M0X3RtdS5oCj4+PiArKysgYi9pbmNsdWRl
L2xpbnV4L3BsYXRmb3JtX2RhdGEvZXh5bm9zNF90bXUuaAo+Pj4gQEAgLTIxLDYgKzIxLDcgQEAK
Pj4+Cj4+PiAgI2lmbmRlZiBfTElOVVhfRVhZTk9TNF9UTVVfSAo+Pj4gICNkZWZpbmUgX0xJTlVY
X0VYWU5PUzRfVE1VX0gKPj4+ICsjaW5jbHVkZSA8bGludXgvY3B1X2Nvb2xpbmcuaD4KPj4+Cj4+
PiAgZW51bSBjYWxpYnJhdGlvbl90eXBlIHsKPj4+ICAgICAgIFRZUEVfT05FX1BPSU5UX1RSSU1N
SU5HLAo+Pj4gQEAgLTY0LDYgKzY1LDkgQEAgZW51bSBjYWxpYnJhdGlvbl90eXBlIHsKPj4+ICAg
KiAgIGluIHRoZSBwb3NpdGl2ZS1UQyBnZW5lcmF0b3IgYmxvY2sKPj4+ICAgKiAgIDAgPD0gcmVm
ZXJlbmNlX3ZvbHRhZ2UgPD0gMzEKPj4+ICAgKiBAY2FsX3R5cGU6IGNhbGlicmF0aW9uIHR5cGUg
Zm9yIHRlbXBlcmF0dXJlCj4+PiArICogQGZyZXFfcGN0Z190YWJsZTogVGFibGUgcmVwcmVzZW50
aW5nIGZyZXF1ZW5jeSByZWR1Y3Rpb24gcGVyY2VudGFnZS4KPj4+ICsgKiBAZnJlcV90YWJfY291
bnQ6IENvdW50IG9mIHRoZSBhYm92ZSB0YWJsZSBhcyBmcmVxdWVuY3kgcmVkdWN0aW9uIG1heQo+
Pj4gKyAqICAgYXBwbGljYWJsZSB0byBvbmx5IHNvbWUgb2YgdGhlIHRyaWdnZXIgbGV2ZWxzLgo+
Pj4gICAqCj4+PiAgICogVGhpcyBzdHJ1Y3R1cmUgaXMgcmVxdWlyZWQgZm9yIGNvbmZpZ3VyYXRp
b24gb2YgZXh5bm9zNF90bXUgZHJpdmVyLgo+Pj4gICAqLwo+Pj4gQEAgLTc5LDUgKzgzLDggQEAg
c3RydWN0IGV4eW5vczRfdG11X3BsYXRmb3JtX2RhdGEgewo+Pj4gICAgICAgdTggcmVmZXJlbmNl
X3ZvbHRhZ2U7Cj4+Pgo+Pj4gICAgICAgZW51bSBjYWxpYnJhdGlvbl90eXBlIGNhbF90eXBlOwo+
Pj4gKwo+Pj4gKyAgICAgc3RydWN0IGZyZXFfcGN0Z190YWJsZSBmcmVxX3RhYls0XTsKPj4+ICsg
ICAgIHVuc2lnbmVkIGludCBmcmVxX3RhYl9jb3VudDsKPj4+ICB9Owo+Pj4gICNlbmRpZiAvKiBf
TElOVVhfRVhZTk9TNF9UTVVfSCAqLwo+Pgo+Pgo+IAoKCgpfX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX19fX19fX19fX19fXwpsbS1zZW5zb3JzIG1haWxpbmcgbGlzdApsbS1zZW5z
b3JzQGxtLXNlbnNvcnMub3JnCmh0dHA6Ly9saXN0cy5sbS1zZW5zb3JzLm9yZy9tYWlsbWFuL2xp
c3RpbmZvL2xtLXNlbnNvcnM
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer
@ 2012-01-05 5:57 ` Donggeun Kim
0 siblings, 0 replies; 25+ messages in thread
From: Donggeun Kim @ 2012-01-05 5:57 UTC (permalink / raw)
To: Amit Kachhap
Cc: guenter.roeck, linux-pm@lists.linux-foundation.org,
linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
lenb@kernel.org
Actually, the TMU driver is closely related to thermal layer.
I think it's okay to move it to the thermal.
Thanks.
-Donggeun
On 2012년 01월 04일 19:14, Amit Kachhap wrote:
> Hi Guenter,
>
> The main idea of this work is to leave the current userspace based
> notification scheme and add the kernel based cooling scheme on top of
> it. Anyway, It is a good idea to move the file hwmon/exynos4_tmu.c as
> this creates 2 hwmon entries.
> Adding CC: Donggeun Kim to know his opinion.
>
> Thanks,
> Amit Daniel
>
> On 4 January 2012 03:55, Guenter Roeck <guenter.roeck@ericsson.com> wrote:
>> On Wed, 2011-12-21 at 06:59 -0500, Amit Daniel Kachhap wrote:
>>> Export and register information from the hwmon tmu sensor to the samsung
>>> exynos kernel thermal framework where different cooling devices and thermal
>>> zone are binded. The exported information is based according to the data
>>> structure thermal_sensor_conf present in exynos_thermal.h. HWMON sysfs
>>> functions are currently left although all of them are present in generic
>>> linux thermal layer.
>>> Also the platform data structure is modified to pass frequency cooling
>>> in percentages for each thermal level.
>>>
>> Hi Amit,
>>
>> wouldn't it make more sense to merge the code as necessary from
>> hwmon/exynos4_tmu.c into the new thermal/exynos_thermal.c, and drop
>> hwmon/exynos4_tmu.c entirely ?
>>
>> With that, you should get the hwmon entries for free, and we would not
>> have to maintain two drivers with overlapping functionality.
>>
>> Thanks,
>> Guenter
>>
>>> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
>>> ---
>>> drivers/hwmon/exynos4_tmu.c | 34 ++++++++++++++++++++++++++--
>>> include/linux/platform_data/exynos4_tmu.h | 7 ++++++
>>> 2 files changed, 38 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c
>>> index f2359a0..6912a7f 100644
>>> --- a/drivers/hwmon/exynos4_tmu.c
>>> +++ b/drivers/hwmon/exynos4_tmu.c
>>> @@ -37,6 +37,9 @@
>>> #include <linux/hwmon-sysfs.h>
>>>
>>> #include <linux/platform_data/exynos4_tmu.h>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +#include <linux/exynos_thermal.h>
>>> +#endif
>>>
>>> #define EXYNOS4_TMU_REG_TRIMINFO 0x0
>>> #define EXYNOS4_TMU_REG_CONTROL 0x20
>>> @@ -248,10 +251,13 @@ static void exynos4_tmu_work(struct work_struct *work)
>>>
>>> kobject_uevent(&data->hwmon_dev->kobj, KOBJ_CHANGE);
>>>
>>> - enable_irq(data->irq);
>>>
>>> clk_disable(data->clk);
>>> mutex_unlock(&data->lock);
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + exynos4_report_trigger();
>>> +#endif
>>> + enable_irq(data->irq);
>>> }
>>>
>>> static irqreturn_t exynos4_tmu_irq(int irq, void *id)
>>> @@ -345,6 +351,14 @@ static const struct attribute_group exynos4_tmu_attr_group = {
>>> .attrs = exynos4_tmu_attributes,
>>> };
>>>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +static struct thermal_sensor_conf exynos4_sensor_conf = {
>>> + .name = "exynos4-therm",
>>> + .read_temperature = (int (*)(void *))exynos4_tmu_read,
>>> +};
>>> +#endif
>>> +/*CONFIG_SAMSUNG_THERMAL_INTERFACE*/
>>> +
>>> static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>>> {
>>> struct exynos4_tmu_data *data;
>>> @@ -432,9 +446,20 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev)
>>> }
>>>
>>> exynos4_tmu_control(pdev, true);
>>> -
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + (&exynos4_sensor_conf)->private_data = data;
>>> + (&exynos4_sensor_conf)->sensor_data = pdata;
>>> + ret = exynos4_register_thermal(&exynos4_sensor_conf);
>>> + if (ret) {
>>> + dev_err(&pdev->dev, "Failed to register thermal interface\n");
>>> + goto err_hwmon_device;
>>> + }
>>> +#endif
>>> return 0;
>>> -
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> +err_hwmon_device:
>>> + hwmon_device_unregister(data->hwmon_dev);
>>> +#endif
>>> err_create_group:
>>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>> err_clk:
>>> @@ -458,6 +483,9 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev)
>>>
>>> exynos4_tmu_control(pdev, false);
>>>
>>> +#ifdef CONFIG_SAMSUNG_THERMAL_INTERFACE
>>> + exynos4_unregister_thermal();
>>> +#endif
>>> hwmon_device_unregister(data->hwmon_dev);
>>> sysfs_remove_group(&pdev->dev.kobj, &exynos4_tmu_attr_group);
>>>
>>> diff --git a/include/linux/platform_data/exynos4_tmu.h b/include/linux/platform_data/exynos4_tmu.h
>>> index 39e038c..642c508 100644
>>> --- a/include/linux/platform_data/exynos4_tmu.h
>>> +++ b/include/linux/platform_data/exynos4_tmu.h
>>> @@ -21,6 +21,7 @@
>>>
>>> #ifndef _LINUX_EXYNOS4_TMU_H
>>> #define _LINUX_EXYNOS4_TMU_H
>>> +#include <linux/cpu_cooling.h>
>>>
>>> enum calibration_type {
>>> TYPE_ONE_POINT_TRIMMING,
>>> @@ -64,6 +65,9 @@ enum calibration_type {
>>> * in the positive-TC generator block
>>> * 0 <= reference_voltage <= 31
>>> * @cal_type: calibration type for temperature
>>> + * @freq_pctg_table: Table representing frequency reduction percentage.
>>> + * @freq_tab_count: Count of the above table as frequency reduction may
>>> + * applicable to only some of the trigger levels.
>>> *
>>> * This structure is required for configuration of exynos4_tmu driver.
>>> */
>>> @@ -79,5 +83,8 @@ struct exynos4_tmu_platform_data {
>>> u8 reference_voltage;
>>>
>>> enum calibration_type cal_type;
>>> +
>>> + struct freq_pctg_table freq_tab[4];
>>> + unsigned int freq_tab_count;
>>> };
>>> #endif /* _LINUX_EXYNOS4_TMU_H */
>>
>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2012-01-05 5:57 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21 11:59 [RFC PATCH 0/3] thermal: exynos: Add kernel thermal support for exynos platform Amit Daniel Kachhap
2011-12-21 12:11 ` [lm-sensors] [RFC PATCH 0/3] thermal: exynos: Add kernel thermal Amit Daniel Kachhap
2011-12-21 11:59 ` [RFC PATCH 1/3] thermal: exynos: Add thermal interface support for linux thermal layer Amit Daniel Kachhap
2011-12-21 12:11 ` [lm-sensors] [RFC PATCH 1/3] thermal: exynos: Add thermal interface Amit Daniel Kachhap
2011-12-21 11:59 ` [RFC PATCH 1/3] thermal: exynos: Add thermal interface support for linux thermal layer Amit Daniel Kachhap
2011-12-21 11:59 ` [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer Amit Daniel Kachhap
2011-12-21 12:11 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Amit Daniel Kachhap
2011-12-21 11:59 ` [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer Amit Daniel Kachhap
2012-01-03 22:25 ` [lm-sensors] " Guenter Roeck
2012-01-03 22:25 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Guenter Roeck
2012-01-04 10:14 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer Amit Kachhap
2012-01-04 10:26 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Amit Kachhap
2012-01-04 10:23 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer R, Durgadoss
2012-01-04 10:23 ` [linux-pm] " R, Durgadoss
2012-01-04 10:23 ` [lm-sensors] [linux-pm] [RFC PATCH 2/3] thermal: exynos4: R, Durgadoss
2012-01-04 16:20 ` [linux-pm] [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer Guenter Roeck
2012-01-04 16:20 ` [lm-sensors] [linux-pm] [RFC PATCH 2/3] thermal: exynos4: Guenter Roeck
2012-01-05 5:57 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer Donggeun Kim
2012-01-05 5:57 ` Donggeun Kim
2012-01-05 5:57 ` Donggeun Kim
2012-01-05 5:57 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu Donggeun Kim
2012-01-04 10:14 ` [lm-sensors] [RFC PATCH 2/3] thermal: exynos4: Register the tmu sensor with the thermal interface layer Amit Kachhap
2011-12-21 11:59 ` [RFC PATCH 3/3] ARM: exynos4: Add thermal sensor driver platform device support Amit Daniel Kachhap
2011-12-21 12:11 ` [lm-sensors] [RFC PATCH 3/3] ARM: exynos4: Add thermal sensor Amit Daniel Kachhap
2011-12-21 11:59 ` [RFC PATCH 3/3] ARM: exynos4: Add thermal sensor driver platform device support Amit Daniel Kachhap
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.