RE: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux thermal layer

2012-03-12 Thread R, Durgadoss
Hi Amit,

Thanks for keeping this up. And Sorry for late reply.

 -Original Message-
 From: amit kachhap [mailto:amitdani...@gmail.com] On Behalf Of Amit Daniel
 Kachhap
 Sent: Saturday, March 03, 2012 4:36 PM
 To: linux...@lists.linux-foundation.org; linux-samsung-soc@vger.kernel.org
 Cc: linux-ker...@vger.kernel.org; mj...@srcf.ucam.org; linux-
 a...@vger.kernel.org; l...@kernel.org; linaro-...@lists.linaro.org; lm-
 sens...@lm-sensors.org; amit.kach...@linaro.org; eduardo.valen...@ti.com; R,
 Durgadoss; patc...@linaro.org
 Subject: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux
 thermal layer
 
 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.kach...@linaro.org
 ---
  drivers/thermal/Kconfig  |8 +
  drivers/thermal/Makefile |1 +
  drivers/thermal/exynos_thermal.c |  272 
 ++
  include/linux/exynos_thermal.h   |   72 ++
  4 files changed, 353 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 000..878d45c
 --- /dev/null
 +++ b/drivers/thermal/exynos_thermal.c
 @@ -0,0 +1,272 @@
 +/* 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/exynos_thermal.h
 +
 +#define MAX_COOLING_DEVICE 4
 +struct exynos4_thermal_zone {
 + unsigned int idle_interval;
 + unsigned int active_interval;
 + struct thermal_zone_device *therm_dev;
 + struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
 + unsigned int cool_dev_size;
 + struct platform_device *exynos4_dev;
 + struct thermal_sensor_conf *sensor_conf;
 +};
 +
 +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;

If it is 'DISABLED' mode, shouldn't the polling delay be just 0 ?

 +
 + 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 monitor_temp;
 +
 + if (!th_zone

Re: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux thermal layer

2012-03-12 Thread Amit Kachhap
Hi Durgadoss,

Thanks for the detailed review.

On 12 March 2012 16:21, R, Durgadoss durgados...@intel.com wrote:
 Hi Amit,

 Thanks for keeping this up. And Sorry for late reply.

 -Original Message-
 From: amit kachhap [mailto:amitdani...@gmail.com] On Behalf Of Amit Daniel
 Kachhap
 Sent: Saturday, March 03, 2012 4:36 PM
 To: linux...@lists.linux-foundation.org; linux-samsung-soc@vger.kernel.org
 Cc: linux-ker...@vger.kernel.org; mj...@srcf.ucam.org; linux-
 a...@vger.kernel.org; l...@kernel.org; linaro-...@lists.linaro.org; lm-
 sens...@lm-sensors.org; amit.kach...@linaro.org; eduardo.valen...@ti.com; R,
 Durgadoss; patc...@linaro.org
 Subject: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux
 thermal layer

 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.kach...@linaro.org
 ---
  drivers/thermal/Kconfig          |    8 +
  drivers/thermal/Makefile         |    1 +
  drivers/thermal/exynos_thermal.c |  272 
 ++
  include/linux/exynos_thermal.h   |   72 ++
  4 files changed, 353 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 000..878d45c
 --- /dev/null
 +++ b/drivers/thermal/exynos_thermal.c
 @@ -0,0 +1,272 @@
 +/* 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/exynos_thermal.h
 +
 +#define MAX_COOLING_DEVICE 4
 +struct exynos4_thermal_zone {
 +     unsigned int idle_interval;
 +     unsigned int active_interval;
 +     struct thermal_zone_device *therm_dev;
 +     struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
 +     unsigned int cool_dev_size;
 +     struct platform_device *exynos4_dev;
 +     struct thermal_sensor_conf *sensor_conf;
 +};
 +
 +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;

 If it is 'DISABLED' mode, shouldn't the polling delay be just 0 ?
Yes Ideally this should be zero. But I wanted thermal monitoring to
always happen with some long interval in case of error scenarios.
Anyway I will check this again.

 +
 +     thermal_zone_device_update(th_zone-therm_dev);
 +     pr_info(thermal polling set

RE: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux thermal layer

2012-03-12 Thread R, Durgadoss
Hi Amit,

[snip.]

  +
  +     kobject_uevent(th_zone-therm_dev-device.kobj, KOBJ_CHANGE);
 
  Wouldn't it make more sense to pass the trip point id also as an 'env'
  parameter ? This way, the user space can easily figure out which trip
  point has been crossed.
 Its a good suggestion. I will check if some uevent property allows that.

The kobject_uevent_env(...) call allows that. The third argument takes a
char *envp[]. For example, We could pass trip=0 to indicate the trip point.
I should have mentioned this in my previous reply itself..missed it..

Thanks,
Durga
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] thermal: exynos: Add thermal interface support for linux thermal layer

2012-03-03 Thread Amit Daniel Kachhap
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.kach...@linaro.org
---
 drivers/thermal/Kconfig  |8 +
 drivers/thermal/Makefile |1 +
 drivers/thermal/exynos_thermal.c |  272 ++
 include/linux/exynos_thermal.h   |   72 ++
 4 files changed, 353 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 000..878d45c
--- /dev/null
+++ b/drivers/thermal/exynos_thermal.c
@@ -0,0 +1,272 @@
+/* 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/exynos_thermal.h
+
+#define MAX_COOLING_DEVICE 4
+struct exynos4_thermal_zone {
+   unsigned int idle_interval;
+   unsigned int active_interval;
+   struct thermal_zone_device *therm_dev;
+   struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
+   unsigned int cool_dev_size;
+   struct platform_device *exynos4_dev;
+   struct thermal_sensor_conf *sensor_conf;
+};
+
+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 monitor_temp;
+
+   if (!th_zone || !th_zone-therm_dev)
+   return;
+
+   monitor_temp = th_zone-sensor_conf-trip_data.trip_val[0];
+
+   thermal_zone_device_update(th_zone-therm_dev);
+
+   mutex_lock(th_zone-therm_dev-lock);
+   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;
+
+   kobject_uevent(th_zone-therm_dev-device.kobj, KOBJ_CHANGE);
+   mutex_unlock(th_zone-therm_dev-lock);
+}
+
+static int exynos4_get_trip_type(struct thermal_zone_device *thermal, int trip,
+