RE: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux thermal layer
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 > --- > 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#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 || !th_zone->therm_dev) >
Re: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux thermal layer
Hi Durgadoss, Thanks for the detailed review. On 12 March 2012 16:21, R, Durgadoss 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 >> --- >> 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 >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#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_devi
RE: [PATCH 1/4] thermal: exynos: Add thermal interface support for linux thermal layer
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