* [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support
@ 2013-04-01 16:04 Eduardo Valentin
2013-04-01 16:04 ` [PATCH 01/14] staging: ti-soc-thermal: return error in case power switch is not supported Eduardo Valentin
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: devel, linux-pm, linux-omap, Eduardo Valentin
Hello Greg,
Here is a new series of patches for ti-soc-thermal. It will contain
a couple of minor fixes, but it has also support for trending,
computed by HW history buffer.
These patches are also available here:
git@gitorious.org:thermal-framework/thermal-framework.git thermal_work/omap/ti-soc-thermal-history-buffer
https://git.gitorious.org/thermal-framework/thermal-framework.git thermal_work/omap/ti-soc-thermal-history-buffer
Eduardo Valentin (4):
staging: ti-soc-thermal: return error in case power switch is not
supported
staging: ti-soc-thermal: expose ti_thermal_report_temperature
staging: ti-soc-thermal: report alert events on OMAP4 devices
staging: ti-soc-thermal: report alert events on OMAP5 devices
J Keerthy (9):
staging: ti-soc-thermal: Add counter_delay_mask field to
temp_sensor_registers struct
staging: ti-soc-thermal: Initialise counter_delay field for OMAP5
sensors
staging: ti-soc-thermal: Introduce HAS_COUNTER_DELAY feature for
bandgap
staging: ti-soc-thermal: Enable COUNTER_DELAY feature for OMAP5
staging: ti-soc-thermal: Modify update_interval r/w functions to
incorporate the OMAP5 feature of COUNTER_DELAY.
staging: ti-soc-thermal: Introduce HAS_HISTORY_BUFFER feature for
bandgap
staging: ti-soc-thermal: Enable HISTORY_BUFFER Feature for OMAP5
staging: ti-soc-thermal:Introduce ti_bandgap_get_trend function for
OMAP5
staging: ti-soc-thermal: Add get_trend support
Nishanth Menon (1):
staging: ti-soc-thermal: remove kernel-doc warnings reported with -v
.../staging/ti-soc-thermal/omap4-thermal-data.c | 2 +
.../staging/ti-soc-thermal/omap5-thermal-data.c | 8 +-
drivers/staging/ti-soc-thermal/omap5xxx-bandgap.h | 1 +
drivers/staging/ti-soc-thermal/ti-bandgap.c | 298 +++++++++++++++++---
drivers/staging/ti-soc-thermal/ti-bandgap.h | 11 +
drivers/staging/ti-soc-thermal/ti-thermal-common.c | 27 ++-
drivers/staging/ti-soc-thermal/ti-thermal.h | 7 +
7 files changed, 319 insertions(+), 35 deletions(-)
--
1.7.7.1.488.ge8e1c
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 01/14] staging: ti-soc-thermal: return error in case power switch is not supported
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 02/14] staging: ti-soc-thermal: remove kernel-doc warnings reported with -v Eduardo Valentin
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: devel, linux-pm, linux-omap, Eduardo Valentin
Improve ti_bandgap_power by returning an error code in case
the device does not support controlling its power state.
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-bandgap.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.c b/drivers/staging/ti-soc-thermal/ti-bandgap.c
index d479e50..a6aa75f 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.c
@@ -100,17 +100,19 @@ do { \
*/
static int ti_bandgap_power(struct ti_bandgap *bgp, bool on)
{
- int i;
+ int i, ret = 0;
- if (!TI_BANDGAP_HAS(bgp, POWER_SWITCH))
+ if (!TI_BANDGAP_HAS(bgp, POWER_SWITCH)) {
+ ret = -ENOTSUPP;
goto exit;
+ }
for (i = 0; i < bgp->conf->sensor_count; i++)
/* active on 0 */
RMW_BITS(bgp, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
exit:
- return 0;
+ return ret;
}
/**
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/14] staging: ti-soc-thermal: remove kernel-doc warnings reported with -v
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
2013-04-01 16:04 ` [PATCH 01/14] staging: ti-soc-thermal: return error in case power switch is not supported Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 03/14] staging: ti-soc-thermal: expose ti_thermal_report_temperature Eduardo Valentin
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, Nishanth Menon, Eduardo Valentin
From: Nishanth Menon <nm@ti.com>
Fix all kernel-doc warnings by add documentation about returns.
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-bandgap.c | 58 +++++++++++++++++++++-----
1 files changed, 47 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.c b/drivers/staging/ti-soc-thermal/ti-bandgap.c
index a6aa75f..62ffea1 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.c
@@ -50,7 +50,7 @@
* @reg: desired register (offset) to be read
*
* Helper function to read bandgap registers. It uses the io remapped area.
- * Returns the register value.
+ * Return: the register value.
*/
static u32 ti_bandgap_readl(struct ti_bandgap *bgp, u32 reg)
{
@@ -97,6 +97,8 @@ do { \
*
* Used to power on/off a bandgap device instance. Only used on those
* that features tempsoff bit.
+ *
+ * Return: 0 on success, -ENOTSUPP if tempsoff is not supported.
*/
static int ti_bandgap_power(struct ti_bandgap *bgp, bool on)
{
@@ -124,6 +126,8 @@ exit:
* This function is desired because, depending on bandgap device version,
* it might be needed to freeze the bandgap state machine, before fetching
* the register value.
+ *
+ * Return: temperature in ADC values.
*/
static u32 ti_bandgap_read_temp(struct ti_bandgap *bgp, int id)
{
@@ -164,6 +168,8 @@ static u32 ti_bandgap_read_temp(struct ti_bandgap *bgp, int id)
* conditions and acts accordingly. In case there are events pending,
* it will reset the event mask to wait for the opposite event (next event).
* Every time there is a new event, it will be reported to thermal layer.
+ *
+ * Return: IRQ_HANDLED
*/
static irqreturn_t ti_bandgap_talert_irq_handler(int irq, void *data)
{
@@ -224,6 +230,8 @@ static irqreturn_t ti_bandgap_talert_irq_handler(int irq, void *data)
* This is the Tshut handler. Use it only if bandgap device features
* HAS(TSHUT). If any sensor fires the Tshut signal, we simply shutdown
* the system.
+ *
+ * Return: IRQ_HANDLED
*/
static irqreturn_t ti_bandgap_tshut_irq_handler(int irq, void *data)
{
@@ -246,6 +254,9 @@ static irqreturn_t ti_bandgap_tshut_irq_handler(int irq, void *data)
* Simple conversion from ADC representation to mCelsius. In case the ADC value
* is out of the ADC conv table range, it returns -ERANGE, 0 on success.
* The conversion table is indexed by the ADC values.
+ *
+ * Return: 0 if conversion was successful, else -ERANGE in case the @adc_val
+ * argument is out of the ADC conv table range.
*/
static
int ti_bandgap_adc_to_mcelsius(struct ti_bandgap *bgp, int adc_val, int *t)
@@ -274,6 +285,9 @@ exit:
* Simple conversion from mCelsius to ADC values. In case the temp value
* is out of the ADC conv table range, it returns -ERANGE, 0 on success.
* The conversion table is indexed by the ADC values.
+ *
+ * Return: 0 if conversion was successful, else -ERANGE in case the @temp
+ * argument is out of the ADC conv table range.
*/
static
int ti_bandgap_mcelsius_to_adc(struct ti_bandgap *bgp, long temp, int *adc)
@@ -313,7 +327,8 @@ exit:
* @sum: address where to write the resulting temperature (in ADC scale)
*
* Adds an hysteresis value (in mCelsius) to a ADC temperature value.
- * Returns 0 on success, -ERANGE otherwise.
+ *
+ * Return: 0 on success, -ERANGE otherwise.
*/
static
int ti_bandgap_add_hyst(struct ti_bandgap *bgp, int adc_val, int hyst_val,
@@ -386,6 +401,8 @@ static void ti_bandgap_unmask_interrupts(struct ti_bandgap *bgp, int id,
* It checks the resulting t_hot and t_cold values, based on the new passed @val
* and configures the thresholds so that t_hot is always greater than t_cold.
* Call this function only if bandgap features HAS(TALERT).
+ *
+ * Return: 0 if no error, else corresponding error
*/
static int ti_bandgap_update_alert_threshold(struct ti_bandgap *bgp, int id,
int val, bool hot)
@@ -444,6 +461,9 @@ exit:
*
* Checks if the bandgap pointer is valid and if the sensor id is also
* applicable.
+ *
+ * Return: 0 if no errors, -EINVAL for invalid @bgp pointer or -ERANGE if
+ * @id cannot index @bgp sensors.
*/
static inline int ti_bandgap_validate(struct ti_bandgap *bgp, int id)
{
@@ -477,6 +497,8 @@ exit:
* This function can be used to update t_hot or t_cold, depending on @hot value.
* Validates the mCelsius range and update the requested threshold.
* Call this function only if bandgap features HAS(TALERT).
+ *
+ * Return: 0 if no error, else corresponding error value.
*/
static int _ti_bandgap_write_threshold(struct ti_bandgap *bgp, int id, int val,
bool hot)
@@ -531,6 +553,9 @@ exit:
* It will fetch the required thresholds (hot and cold) for TALERT signal.
* This function can be used to read t_hot or t_cold, depending on @hot value.
* Call this function only if bandgap features HAS(TALERT).
+ *
+ * Return: 0 if no error, -ENOTSUPP if it has no TALERT support, or the
+ * corresponding error value if some operation fails.
*/
static int _ti_bandgap_read_threshold(struct ti_bandgap *bgp, int id,
int *val, bool hot)
@@ -577,7 +602,7 @@ exit:
* @id: sensor id
* @thot: resulting current thot value
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_read_thot(struct ti_bandgap *bgp, int id, int *thot)
{
@@ -590,7 +615,7 @@ int ti_bandgap_read_thot(struct ti_bandgap *bgp, int id, int *thot)
* @id: sensor id
* @val: desired thot value
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_write_thot(struct ti_bandgap *bgp, int id, int val)
{
@@ -603,7 +628,7 @@ int ti_bandgap_write_thot(struct ti_bandgap *bgp, int id, int val)
* @id: sensor id
* @tcold: resulting current tcold value
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_read_tcold(struct ti_bandgap *bgp, int id, int *tcold)
{
@@ -616,7 +641,7 @@ int ti_bandgap_read_tcold(struct ti_bandgap *bgp, int id, int *tcold)
* @id: sensor id
* @val: desired tcold value
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_write_tcold(struct ti_bandgap *bgp, int id, int val)
{
@@ -629,7 +654,7 @@ int ti_bandgap_write_tcold(struct ti_bandgap *bgp, int id, int val)
* @id: sensor id
* @interval: resulting update interval in miliseconds
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_read_update_interval(struct ti_bandgap *bgp, int id,
int *interval)
@@ -661,7 +686,7 @@ int ti_bandgap_read_update_interval(struct ti_bandgap *bgp, int id,
* @id: sensor id
* @interval: desired update interval in miliseconds
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_write_update_interval(struct ti_bandgap *bgp,
int id, u32 interval)
@@ -687,7 +712,7 @@ int ti_bandgap_write_update_interval(struct ti_bandgap *bgp,
* @id: sensor id
* @temperature: resulting temperature
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_read_temperature(struct ti_bandgap *bgp, int id,
int *temperature)
@@ -719,7 +744,7 @@ int ti_bandgap_read_temperature(struct ti_bandgap *bgp, int id,
* @id: sensor id
* @data: thermal framework related data to be stored
*
- * returns 0 on success or the proper error code
+ * Return: 0 on success or the proper error code
*/
int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data)
{
@@ -738,7 +763,7 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data)
* @bgp: pointer to bandgap instance
* @id: sensor id
*
- * returns data stored by set function with sensor id on success or NULL
+ * Return: data stored by set function with sensor id on success or NULL
*/
void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id)
{
@@ -758,6 +783,8 @@ void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id)
*
* Used to initialize the conversion state machine and set it to a valid
* state. Called during device initialization and context restore events.
+ *
+ * Return: 0
*/
static int
ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id)
@@ -791,6 +818,8 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id)
* be used for junction temperature monitoring, it is desirable that the
* sensors are operational all the time, so that alerts are generated
* properly.
+ *
+ * Return: 0
*/
static int ti_bandgap_set_continuous_mode(struct ti_bandgap *bgp)
{
@@ -816,6 +845,8 @@ static int ti_bandgap_set_continuous_mode(struct ti_bandgap *bgp)
* to specify which GPIO line is used. TSHUT IRQ is fired anytime
* one of the bandgap sensors violates the TSHUT high/hot threshold.
* And in that case, the system must go off.
+ *
+ * Return: 0 if no error, else error status
*/
static int ti_bandgap_tshut_init(struct ti_bandgap *bgp,
struct platform_device *pdev)
@@ -855,6 +886,8 @@ static int ti_bandgap_tshut_init(struct ti_bandgap *bgp,
* TALERT is a normal IRQ and it is fired any time thresholds (hot or cold)
* are violated. In these situation, the driver must reprogram the thresholds,
* accordingly to specified policy.
+ *
+ * Return: 0 if no error, else return corresponding error.
*/
static int ti_bandgap_talert_init(struct ti_bandgap *bgp,
struct platform_device *pdev)
@@ -886,6 +919,9 @@ static const struct of_device_id of_ti_bandgap_match[];
* Used to read the device tree properties accordingly to the bandgap
* matching version. Based on bandgap version and its capabilities it
* will build a struct ti_bandgap out of the required DT entries.
+ *
+ * Return: valid bandgap structure if successful, else returns ERR_PTR
+ * return value must be verified with IS_ERR.
*/
static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev)
{
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/14] staging: ti-soc-thermal: expose ti_thermal_report_temperature
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
2013-04-01 16:04 ` [PATCH 01/14] staging: ti-soc-thermal: return error in case power switch is not supported Eduardo Valentin
2013-04-01 16:04 ` [PATCH 02/14] staging: ti-soc-thermal: remove kernel-doc warnings reported with -v Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 04/14] staging: ti-soc-thermal: report alert events on OMAP4 devices Eduardo Valentin
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: devel, linux-pm, linux-omap, Eduardo Valentin
Whenever a sensor has an alert to be reported to the thermal framework,
it can use the report ti_thermal_report_temperature helper. This patch
expose this function so that bandgap data config declarations could use it.
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-thermal.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-thermal.h b/drivers/staging/ti-soc-thermal/ti-thermal.h
index ef6981c..7b2d600 100644
--- a/drivers/staging/ti-soc-thermal/ti-thermal.h
+++ b/drivers/staging/ti-soc-thermal/ti-thermal.h
@@ -76,6 +76,7 @@
#ifdef CONFIG_TI_THERMAL
int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, char *domain);
int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id);
+int ti_thermal_report_sensor_temperature(struct ti_bandgap *bgp, int id);
int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id);
int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id);
#else
@@ -92,6 +93,12 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id)
}
static inline
+int ti_thermal_report_sensor_temperature(struct ti_bandgap *bgp, int id)
+{
+ return 0;
+}
+
+static inline
int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
{
return 0;
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/14] staging: ti-soc-thermal: report alert events on OMAP4 devices
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (2 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 03/14] staging: ti-soc-thermal: expose ti_thermal_report_temperature Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 05/14] staging: ti-soc-thermal: report alert events on OMAP5 devices Eduardo Valentin
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: devel, linux-pm, linux-omap, Eduardo Valentin
OMAP4460 and OMAP4470 devices have the capability to generate
alert temperature. Thus, whenever a T_ALERT IRQ is served,
the ti-bandgap will call .report_temperature to notify the
thermal framework about thermal zone update request.
This patch allows OMAP4460 and OMAP4470 devices to notify
the thermal framework about T_ALERT events.
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
.../staging/ti-soc-thermal/omap4-thermal-data.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/omap4-thermal-data.c b/drivers/staging/ti-soc-thermal/omap4-thermal-data.c
index 49d0324..ee9c902 100644
--- a/drivers/staging/ti-soc-thermal/omap4-thermal-data.c
+++ b/drivers/staging/ti-soc-thermal/omap4-thermal-data.c
@@ -216,6 +216,7 @@ const struct ti_bandgap_data omap4460_data = {
.adc_end_val = OMAP4460_ADC_END_VALUE,
.expose_sensor = ti_thermal_expose_sensor,
.remove_sensor = ti_thermal_remove_sensor,
+ .report_temperature = ti_thermal_report_sensor_temperature,
.sensors = {
{
.registers = &omap4460_mpu_temp_sensor_registers,
@@ -248,6 +249,7 @@ const struct ti_bandgap_data omap4470_data = {
.adc_end_val = OMAP4460_ADC_END_VALUE,
.expose_sensor = ti_thermal_expose_sensor,
.remove_sensor = ti_thermal_remove_sensor,
+ .report_temperature = ti_thermal_report_sensor_temperature,
.sensors = {
{
.registers = &omap4460_mpu_temp_sensor_registers,
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/14] staging: ti-soc-thermal: report alert events on OMAP5 devices
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (3 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 04/14] staging: ti-soc-thermal: report alert events on OMAP4 devices Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 06/14] staging: ti-soc-thermal: Add counter_delay_mask field to temp_sensor_registers struct Eduardo Valentin
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: devel, linux-pm, linux-omap, Eduardo Valentin
OMAP5430 devices have the capability to generate
alert temperature. Thus, whenever a T_ALERT IRQ is served,
the ti-bandgap will call .report_temperature to notify the
thermal framework about thermal zone update request.
This patch allows OMAP5430 devices to notify
the thermal framework about T_ALERT events.
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
.../staging/ti-soc-thermal/omap5-thermal-data.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
index 0afe9c8..aa16f92 100644
--- a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
+++ b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
@@ -323,6 +323,7 @@ const struct ti_bandgap_data omap5430_data = {
.adc_end_val = OMAP5430_ADC_END_VALUE,
.expose_sensor = ti_thermal_expose_sensor,
.remove_sensor = ti_thermal_remove_sensor,
+ .report_temperature = ti_thermal_report_sensor_temperature,
.sensors = {
{
.registers = &omap5430_mpu_temp_sensor_registers,
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/14] staging: ti-soc-thermal: Add counter_delay_mask field to temp_sensor_registers struct
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (4 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 05/14] staging: ti-soc-thermal: report alert events on OMAP5 devices Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 07/14] staging: ti-soc-thermal: Initialise counter_delay field for OMAP5 sensors Eduardo Valentin
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
Add counter_delay_mask field to temp_sensor_registers structure.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-bandgap.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.h b/drivers/staging/ti-soc-thermal/ti-bandgap.h
index 04c6ec2..8f9bdb9 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.h
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.h
@@ -79,6 +79,7 @@
* @mask_hot_mask: mask to bandgap_mask_ctrl.mask_hot
* @mask_cold_mask: mask to bandgap_mask_ctrl.mask_cold
* @mask_sidlemode_mask: mask to bandgap_mask_ctrl.mask_sidlemode
+ * @mask_counter_delay_mask: mask to bandgap_mask_ctrl.mask_counter_delay
* @mask_freeze_mask: mask to bandgap_mask_ctrl.mask_free
* @mask_clear_mask: mask to bandgap_mask_ctrl.mask_clear
* @mask_clear_accum_mask: mask to bandgap_mask_ctrl.mask_clear_accum
@@ -127,6 +128,7 @@ struct temp_sensor_registers {
u32 mask_hot_mask;
u32 mask_cold_mask;
u32 mask_sidlemode_mask; /* not used: but may be needed for pm */
+ u32 mask_counter_delay_mask;
u32 mask_freeze_mask;
u32 mask_clear_mask; /* not used: but needed for trending */
u32 mask_clear_accum_mask; /* not used: but needed for trending */
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/14] staging: ti-soc-thermal: Initialise counter_delay field for OMAP5 sensors
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (5 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 06/14] staging: ti-soc-thermal: Add counter_delay_mask field to temp_sensor_registers struct Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 08/14] staging: ti-soc-thermal: Introduce HAS_COUNTER_DELAY feature for bandgap Eduardo Valentin
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
Initialize all 3 temperature sensors of OMAP5 bandgap with the counter delay
mask.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
.../staging/ti-soc-thermal/omap5-thermal-data.c | 3 +++
drivers/staging/ti-soc-thermal/omap5xxx-bandgap.h | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
index aa16f92..a5fa113 100644
--- a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
+++ b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
@@ -39,6 +39,7 @@ omap5430_mpu_temp_sensor_registers = {
.mask_hot_mask = OMAP5430_MASK_HOT_MPU_MASK,
.mask_cold_mask = OMAP5430_MASK_COLD_MPU_MASK,
.mask_sidlemode_mask = OMAP5430_MASK_SIDLEMODE_MASK,
+ .mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
.mask_freeze_mask = OMAP5430_MASK_FREEZE_MPU_MASK,
.mask_clear_mask = OMAP5430_MASK_CLEAR_MPU_MASK,
.mask_clear_accum_mask = OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK,
@@ -84,6 +85,7 @@ omap5430_gpu_temp_sensor_registers = {
.mask_hot_mask = OMAP5430_MASK_HOT_GPU_MASK,
.mask_cold_mask = OMAP5430_MASK_COLD_GPU_MASK,
.mask_sidlemode_mask = OMAP5430_MASK_SIDLEMODE_MASK,
+ .mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
.mask_freeze_mask = OMAP5430_MASK_FREEZE_GPU_MASK,
.mask_clear_mask = OMAP5430_MASK_CLEAR_GPU_MASK,
.mask_clear_accum_mask = OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK,
@@ -129,6 +131,7 @@ omap5430_core_temp_sensor_registers = {
.mask_hot_mask = OMAP5430_MASK_HOT_CORE_MASK,
.mask_cold_mask = OMAP5430_MASK_COLD_CORE_MASK,
.mask_sidlemode_mask = OMAP5430_MASK_SIDLEMODE_MASK,
+ .mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
.mask_freeze_mask = OMAP5430_MASK_FREEZE_CORE_MASK,
.mask_clear_mask = OMAP5430_MASK_CLEAR_CORE_MASK,
.mask_clear_accum_mask = OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK,
diff --git a/drivers/staging/ti-soc-thermal/omap5xxx-bandgap.h b/drivers/staging/ti-soc-thermal/omap5xxx-bandgap.h
index 8824db4..400b55d 100644
--- a/drivers/staging/ti-soc-thermal/omap5xxx-bandgap.h
+++ b/drivers/staging/ti-soc-thermal/omap5xxx-bandgap.h
@@ -95,6 +95,7 @@
/* OMAP5430.BANDGAP_CTRL */
#define OMAP5430_MASK_SIDLEMODE_MASK (0x3 << 30)
+#define OMAP5430_MASK_COUNTER_DELAY_MASK (0x7 << 27)
#define OMAP5430_MASK_FREEZE_CORE_MASK BIT(23)
#define OMAP5430_MASK_FREEZE_GPU_MASK BIT(22)
#define OMAP5430_MASK_FREEZE_MPU_MASK BIT(21)
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/14] staging: ti-soc-thermal: Introduce HAS_COUNTER_DELAY feature for bandgap
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (6 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 07/14] staging: ti-soc-thermal: Initialise counter_delay field for OMAP5 sensors Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 09/14] staging: ti-soc-thermal: Enable COUNTER_DELAY feature for OMAP5 Eduardo Valentin
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
Introduce HAS_COUNTER_DELAY feature for bandgap.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-bandgap.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.h b/drivers/staging/ti-soc-thermal/ti-bandgap.h
index 8f9bdb9..8ee4857 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.h
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.h
@@ -312,6 +312,9 @@ struct ti_temp_sensor {
* TI_BANDGAP_FEATURE_FREEZE_BIT - used when the bandgap device features
* a history buffer that its update can be freezed/unfreezed.
*
+ * TI_BANDGAP_FEATURE_COUNTER_DELAY - used when the bandgap device features
+ * a delay programming based on distinct values.
+ *
* TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
* specific feature (above) or not. Return non-zero, if yes.
*/
@@ -323,6 +326,7 @@ struct ti_temp_sensor {
#define TI_BANDGAP_FEATURE_POWER_SWITCH BIT(5)
#define TI_BANDGAP_FEATURE_CLK_CTRL BIT(6)
#define TI_BANDGAP_FEATURE_FREEZE_BIT BIT(7)
+#define TI_BANDGAP_FEATURE_COUNTER_DELAY BIT(8)
#define TI_BANDGAP_HAS(b, f) \
((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/14] staging: ti-soc-thermal: Enable COUNTER_DELAY feature for OMAP5
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (7 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 08/14] staging: ti-soc-thermal: Introduce HAS_COUNTER_DELAY feature for bandgap Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 10/14] staging: ti-soc-thermal: Modify update_interval r/w functions to incorporate the OMAP5 feature of COUNTER_DELAY Eduardo Valentin
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
Enable COUNTER_DELAY feature for OMAP5.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
.../staging/ti-soc-thermal/omap5-thermal-data.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
index a5fa113..460a3b2 100644
--- a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
+++ b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
@@ -318,7 +318,8 @@ omap5430_adc_to_temp[
const struct ti_bandgap_data omap5430_data = {
.features = TI_BANDGAP_FEATURE_TSHUT_CONFIG |
TI_BANDGAP_FEATURE_FREEZE_BIT |
- TI_BANDGAP_FEATURE_TALERT,
+ TI_BANDGAP_FEATURE_TALERT |
+ TI_BANDGAP_FEATURE_COUNTER_DELAY,
.fclock_name = "l3instr_ts_gclk_div",
.div_ck_name = "l3instr_ts_gclk_div",
.conv_table = omap5430_adc_to_temp,
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/14] staging: ti-soc-thermal: Modify update_interval r/w functions to incorporate the OMAP5 feature of COUNTER_DELAY.
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (8 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 09/14] staging: ti-soc-thermal: Enable COUNTER_DELAY feature for OMAP5 Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 11/14] staging: ti-soc-thermal: Introduce HAS_HISTORY_BUFFER feature for bandgap Eduardo Valentin
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
Update ti_bandgap_write_update_interval and ti_bandgap_read_update_interval
functions to incorporate the OMAP5 feature of COUNTER_DELAY. The way we
program the delay between two successive temperature conversions
is different for OMAP5 as when compared with OMAP4. Incorporating
the changes required to program the delay for OMAP5.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-bandgap.c | 165 +++++++++++++++++++++++---
1 files changed, 146 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.c b/drivers/staging/ti-soc-thermal/ti-bandgap.c
index 62ffea1..cc0c4ba 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.c
@@ -649,6 +649,68 @@ int ti_bandgap_write_tcold(struct ti_bandgap *bgp, int id, int val)
}
/**
+ * ti_bandgap_read_counter() - read the sensor counter
+ * @bgp: pointer to bandgap instance
+ * @id: sensor id
+ * @interval: resulting update interval in miliseconds
+ */
+static void ti_bandgap_read_counter(struct ti_bandgap *bgp, int id,
+ int *interval)
+{
+ struct temp_sensor_registers *tsr;
+ int time;
+
+ tsr = bgp->conf->sensors[id].registers;
+ time = ti_bandgap_readl(bgp, tsr->bgap_counter);
+ time = (time & tsr->counter_mask) >>
+ __ffs(tsr->counter_mask);
+ time = time * 1000 / bgp->clk_rate;
+ *interval = time;
+}
+
+/**
+ * ti_bandgap_read_counter_delay() - read the sensor counter delay
+ * @bgp: pointer to bandgap instance
+ * @id: sensor id
+ * @interval: resulting update interval in miliseconds
+ */
+static void ti_bandgap_read_counter_delay(struct ti_bandgap *bgp, int id,
+ int *interval)
+{
+ struct temp_sensor_registers *tsr;
+ int reg_val;
+
+ tsr = bgp->conf->sensors[id].registers;
+
+ reg_val = ti_bandgap_readl(bgp, tsr->bgap_mask_ctrl);
+ reg_val = (reg_val & tsr->mask_counter_delay_mask) >>
+ __ffs(tsr->mask_counter_delay_mask);
+ switch (reg_val) {
+ case 0:
+ *interval = 0;
+ break;
+ case 1:
+ *interval = 1;
+ break;
+ case 2:
+ *interval = 10;
+ break;
+ case 3:
+ *interval = 100;
+ break;
+ case 4:
+ *interval = 250;
+ break;
+ case 5:
+ *interval = 500;
+ break;
+ default:
+ dev_warn(bgp->dev, "Wrong counter delay value read from register %X",
+ reg_val);
+ }
+}
+
+/**
* ti_bandgap_read_update_interval() - read the sensor update interval
* @bgp: pointer to bandgap instance
* @id: sensor id
@@ -659,28 +721,88 @@ int ti_bandgap_write_tcold(struct ti_bandgap *bgp, int id, int val)
int ti_bandgap_read_update_interval(struct ti_bandgap *bgp, int id,
int *interval)
{
- struct temp_sensor_registers *tsr;
- u32 time;
- int ret;
+ int ret = 0;
ret = ti_bandgap_validate(bgp, id);
if (ret)
- return ret;
+ goto exit;
- if (!TI_BANDGAP_HAS(bgp, COUNTER))
- return -ENOTSUPP;
+ if (!TI_BANDGAP_HAS(bgp, COUNTER) &&
+ !TI_BANDGAP_HAS(bgp, COUNTER_DELAY)) {
+ ret = -ENOTSUPP;
+ goto exit;
+ }
- tsr = bgp->conf->sensors[id].registers;
- time = ti_bandgap_readl(bgp, tsr->bgap_counter);
- time = (time & tsr->counter_mask) >> __ffs(tsr->counter_mask);
- time = time * 1000 / bgp->clk_rate;
+ if (TI_BANDGAP_HAS(bgp, COUNTER)) {
+ ti_bandgap_read_counter(bgp, id, interval);
+ goto exit;
+ }
- *interval = time;
+ ti_bandgap_read_counter_delay(bgp, id, interval);
+exit:
+ return ret;
+}
+
+/**
+ * ti_bandgap_write_counter_delay() - set the counter_delay
+ * @bgp: pointer to bandgap instance
+ * @id: sensor id
+ * @interval: desired update interval in miliseconds
+ *
+ * Return: 0 on success or the proper error code
+ */
+static int ti_bandgap_write_counter_delay(struct ti_bandgap *bgp, int id,
+ u32 interval)
+{
+ int rval;
+
+ switch (interval) {
+ case 0: /* Immediate conversion */
+ rval = 0x0;
+ break;
+ case 1: /* Conversion after ever 1ms */
+ rval = 0x1;
+ break;
+ case 10: /* Conversion after ever 10ms */
+ rval = 0x2;
+ break;
+ case 100: /* Conversion after ever 100ms */
+ rval = 0x3;
+ break;
+ case 250: /* Conversion after ever 250ms */
+ rval = 0x4;
+ break;
+ case 500: /* Conversion after ever 500ms */
+ rval = 0x5;
+ break;
+ default:
+ dev_warn(bgp->dev, "Delay %d ms is not supported\n", interval);
+ return -EINVAL;
+ }
+
+ spin_lock(&bgp->lock);
+ RMW_BITS(bgp, id, bgap_mask_ctrl, mask_counter_delay_mask, rval);
+ spin_unlock(&bgp->lock);
return 0;
}
/**
+ * ti_bandgap_write_counter() - set the bandgap sensor counter
+ * @bgp: pointer to bandgap instance
+ * @id: sensor id
+ * @interval: desired update interval in miliseconds
+ */
+static void ti_bandgap_write_counter(struct ti_bandgap *bgp, int id,
+ u32 interval)
+{
+ interval = interval * bgp->clk_rate / 1000;
+ spin_lock(&bgp->lock);
+ RMW_BITS(bgp, id, bgap_counter, counter_mask, interval);
+ spin_unlock(&bgp->lock);
+}
+
+/**
* ti_bandgap_write_update_interval() - set the update interval
* @bgp: pointer to bandgap instance
* @id: sensor id
@@ -693,17 +815,22 @@ int ti_bandgap_write_update_interval(struct ti_bandgap *bgp,
{
int ret = ti_bandgap_validate(bgp, id);
if (ret)
- return ret;
+ goto exit;
- if (!TI_BANDGAP_HAS(bgp, COUNTER))
- return -ENOTSUPP;
+ if (!TI_BANDGAP_HAS(bgp, COUNTER) &&
+ !TI_BANDGAP_HAS(bgp, COUNTER_DELAY)) {
+ ret = -ENOTSUPP;
+ goto exit;
+ }
- interval = interval * bgp->clk_rate / 1000;
- spin_lock(&bgp->lock);
- RMW_BITS(bgp, id, bgap_counter, counter_mask, interval);
- spin_unlock(&bgp->lock);
+ if (TI_BANDGAP_HAS(bgp, COUNTER)) {
+ ti_bandgap_write_counter(bgp, id, interval);
+ goto exit;
+ }
- return 0;
+ ret = ti_bandgap_write_counter_delay(bgp, id, interval);
+exit:
+ return ret;
}
/**
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/14] staging: ti-soc-thermal: Introduce HAS_HISTORY_BUFFER feature for bandgap
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (9 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 10/14] staging: ti-soc-thermal: Modify update_interval r/w functions to incorporate the OMAP5 feature of COUNTER_DELAY Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 12/14] staging: ti-soc-thermal: Enable HISTORY_BUFFER Feature for OMAP5 Eduardo Valentin
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
The patch introduces HISTORY_BUFFER feature. This is present in OMAP5 bandgap
and it is a hardware history buffer of previously read temperatures.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-bandgap.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.h b/drivers/staging/ti-soc-thermal/ti-bandgap.h
index 8ee4857..e29e357 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.h
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.h
@@ -315,6 +315,9 @@ struct ti_temp_sensor {
* TI_BANDGAP_FEATURE_COUNTER_DELAY - used when the bandgap device features
* a delay programming based on distinct values.
*
+ * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
+ * a history buffer of temperatures.
+ *
* TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
* specific feature (above) or not. Return non-zero, if yes.
*/
@@ -327,6 +330,7 @@ struct ti_temp_sensor {
#define TI_BANDGAP_FEATURE_CLK_CTRL BIT(6)
#define TI_BANDGAP_FEATURE_FREEZE_BIT BIT(7)
#define TI_BANDGAP_FEATURE_COUNTER_DELAY BIT(8)
+#define TI_BANDGAP_FEATURE_HISTORY_BUFFER BIT(9)
#define TI_BANDGAP_HAS(b, f) \
((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 12/14] staging: ti-soc-thermal: Enable HISTORY_BUFFER Feature for OMAP5
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (10 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 11/14] staging: ti-soc-thermal: Introduce HAS_HISTORY_BUFFER feature for bandgap Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 13/14] staging: ti-soc-thermal:Introduce ti_bandgap_get_trend function " Eduardo Valentin
2013-04-01 16:04 ` [PATCH 14/14] staging: ti-soc-thermal: Add get_trend support Eduardo Valentin
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
This patch enables the HISTORY_BUFFER eature for OMAP5.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
.../staging/ti-soc-thermal/omap5-thermal-data.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
index 460a3b2..f170211 100644
--- a/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
+++ b/drivers/staging/ti-soc-thermal/omap5-thermal-data.c
@@ -319,7 +319,8 @@ const struct ti_bandgap_data omap5430_data = {
.features = TI_BANDGAP_FEATURE_TSHUT_CONFIG |
TI_BANDGAP_FEATURE_FREEZE_BIT |
TI_BANDGAP_FEATURE_TALERT |
- TI_BANDGAP_FEATURE_COUNTER_DELAY,
+ TI_BANDGAP_FEATURE_COUNTER_DELAY |
+ TI_BANDGAP_FEATURE_HISTORY_BUFFER,
.fclock_name = "l3instr_ts_gclk_div",
.div_ck_name = "l3instr_ts_gclk_div",
.conv_table = omap5430_adc_to_temp,
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 13/14] staging: ti-soc-thermal:Introduce ti_bandgap_get_trend function for OMAP5
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (11 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 12/14] staging: ti-soc-thermal: Enable HISTORY_BUFFER Feature for OMAP5 Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
2013-04-01 16:04 ` [PATCH 14/14] staging: ti-soc-thermal: Add get_trend support Eduardo Valentin
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
The patch adds ti_bandgap_get_trend function. This is specific
to OMAP5 for now it computes the trend from the temp values stored
in the hardware history buffer.
Formula: (T1 - T2) / P.
Where:
T1: Last read valid temperature.
T2: Last but one read valid temperature.
P: Update Interval.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-bandgap.c | 67 +++++++++++++++++++++++++++
drivers/staging/ti-soc-thermal/ti-bandgap.h | 1 +
2 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.c b/drivers/staging/ti-soc-thermal/ti-bandgap.c
index cc0c4ba..5b06b12 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.c
@@ -962,6 +962,73 @@ static int ti_bandgap_set_continuous_mode(struct ti_bandgap *bgp)
}
/**
+ * ti_bandgap_get_trend() - To fetch the temperature trend of a sensor
+ * @bgp: pointer to struct ti_bandgap
+ * @id: id of the individual sensor
+ * @trend: Pointer to trend.
+ *
+ * This function needs to be called to fetch the temperature trend of a
+ * Particular sensor. The function computes the difference in temperature
+ * w.r.t time. For the bandgaps with built in history buffer the temperatures
+ * are read from the buffer and for those without the Buffer -ENOTSUPP is
+ * returned.
+ *
+ * Return: 0 if no error, else return corresponding error. If no
+ * error then the trend value is passed on to trend parameter
+ */
+int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend)
+{
+ struct temp_sensor_registers *tsr;
+ u32 temp1, temp2, reg1, reg2;
+ int t1, t2, interval, ret = 0;
+
+ ret = ti_bandgap_validate(bgp, id);
+ if (ret)
+ goto exit;
+
+ if (!TI_BANDGAP_HAS(bgp, HISTORY_BUFFER) ||
+ !TI_BANDGAP_HAS(bgp, FREEZE_BIT)) {
+ ret = -ENOTSUPP;
+ goto exit;
+ }
+
+ tsr = bgp->conf->sensors[id].registers;
+
+ /* Freeze and read the last 2 valid readings */
+ reg1 = tsr->ctrl_dtemp_1;
+ reg2 = tsr->ctrl_dtemp_2;
+
+ /* read temperature from history buffer */
+ temp1 = ti_bandgap_readl(bgp, reg1);
+ temp1 &= tsr->bgap_dtemp_mask;
+
+ temp2 = ti_bandgap_readl(bgp, reg2);
+ temp2 &= tsr->bgap_dtemp_mask;
+
+ /* Convert from adc values to mCelsius temperature */
+ ret = ti_bandgap_adc_to_mcelsius(bgp, temp1, &t1);
+ if (ret)
+ goto exit;
+
+ ret = ti_bandgap_adc_to_mcelsius(bgp, temp2, &t2);
+ if (ret)
+ goto exit;
+
+ /* Fetch the update interval */
+ ret = ti_bandgap_read_update_interval(bgp, id, &interval);
+ if (ret || !interval)
+ goto exit;
+
+ *trend = (t1 - t2) / interval;
+
+ dev_dbg(bgp->dev, "The temperatures are t1 = %d and t2 = %d and trend =%d\n",
+ t1, t2, *trend);
+
+exit:
+ return ret;
+}
+
+/**
* ti_bandgap_tshut_init() - setup and initialize tshut handling
* @bgp: pointer to struct ti_bandgap
* @pdev: pointer to device struct platform_device
diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.h b/drivers/staging/ti-soc-thermal/ti-bandgap.h
index e29e357..5f4794a 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.h
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.h
@@ -382,6 +382,7 @@ int ti_bandgap_read_temperature(struct ti_bandgap *bgp, int id,
int *temperature);
int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
+int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
#ifdef CONFIG_OMAP4_THERMAL
extern const struct ti_bandgap_data omap4430_data;
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 14/14] staging: ti-soc-thermal: Add get_trend support
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
` (12 preceding siblings ...)
2013-04-01 16:04 ` [PATCH 13/14] staging: ti-soc-thermal:Introduce ti_bandgap_get_trend function " Eduardo Valentin
@ 2013-04-01 16:04 ` Eduardo Valentin
13 siblings, 0 replies; 15+ messages in thread
From: Eduardo Valentin @ 2013-04-01 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, linux-pm, linux-omap, J Keerthy, Eduardo Valentin
From: J Keerthy <j-keerthy@ti.com>
Patch adds get_trend functionality for OMAP Bandgap thermal devices.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/ti-soc-thermal/ti-thermal-common.c | 27 +++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
index 231c549..092b39d 100644
--- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
@@ -215,6 +215,31 @@ static int ti_thermal_get_trip_temp(struct thermal_zone_device *thermal,
return 0;
}
+/* Get the temperature trend callback functions for thermal zone */
+static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
+ int trip, enum thermal_trend *trend)
+{
+ struct ti_thermal_data *data = thermal->devdata;
+ struct ti_bandgap *bgp;
+ int id, tr, ret = 0;
+
+ bgp = data->bgp;
+ id = data->sensor_id;
+
+ ret = ti_bandgap_get_trend(bgp, id, &tr);
+ if (ret)
+ return ret;
+
+ if (tr > 0)
+ *trend = THERMAL_TREND_RAISING;
+ else if (tr < 0)
+ *trend = THERMAL_TREND_DROPPING;
+ else
+ *trend = THERMAL_TREND_STABLE;
+
+ return 0;
+}
+
/* Get critical temperature callback functions for thermal zone */
static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
unsigned long *temp)
@@ -225,7 +250,7 @@ static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
static struct thermal_zone_device_ops ti_thermal_ops = {
.get_temp = ti_thermal_get_temp,
- /* TODO: add .get_trend */
+ .get_trend = ti_thermal_get_trend,
.bind = ti_thermal_bind,
.unbind = ti_thermal_unbind,
.get_mode = ti_thermal_get_mode,
--
1.7.7.1.488.ge8e1c
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-04-01 16:09 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-01 16:04 [PATCH 00/14] staging: ti-soc-thermal: fixes and trending support Eduardo Valentin
2013-04-01 16:04 ` [PATCH 01/14] staging: ti-soc-thermal: return error in case power switch is not supported Eduardo Valentin
2013-04-01 16:04 ` [PATCH 02/14] staging: ti-soc-thermal: remove kernel-doc warnings reported with -v Eduardo Valentin
2013-04-01 16:04 ` [PATCH 03/14] staging: ti-soc-thermal: expose ti_thermal_report_temperature Eduardo Valentin
2013-04-01 16:04 ` [PATCH 04/14] staging: ti-soc-thermal: report alert events on OMAP4 devices Eduardo Valentin
2013-04-01 16:04 ` [PATCH 05/14] staging: ti-soc-thermal: report alert events on OMAP5 devices Eduardo Valentin
2013-04-01 16:04 ` [PATCH 06/14] staging: ti-soc-thermal: Add counter_delay_mask field to temp_sensor_registers struct Eduardo Valentin
2013-04-01 16:04 ` [PATCH 07/14] staging: ti-soc-thermal: Initialise counter_delay field for OMAP5 sensors Eduardo Valentin
2013-04-01 16:04 ` [PATCH 08/14] staging: ti-soc-thermal: Introduce HAS_COUNTER_DELAY feature for bandgap Eduardo Valentin
2013-04-01 16:04 ` [PATCH 09/14] staging: ti-soc-thermal: Enable COUNTER_DELAY feature for OMAP5 Eduardo Valentin
2013-04-01 16:04 ` [PATCH 10/14] staging: ti-soc-thermal: Modify update_interval r/w functions to incorporate the OMAP5 feature of COUNTER_DELAY Eduardo Valentin
2013-04-01 16:04 ` [PATCH 11/14] staging: ti-soc-thermal: Introduce HAS_HISTORY_BUFFER feature for bandgap Eduardo Valentin
2013-04-01 16:04 ` [PATCH 12/14] staging: ti-soc-thermal: Enable HISTORY_BUFFER Feature for OMAP5 Eduardo Valentin
2013-04-01 16:04 ` [PATCH 13/14] staging: ti-soc-thermal:Introduce ti_bandgap_get_trend function " Eduardo Valentin
2013-04-01 16:04 ` [PATCH 14/14] staging: ti-soc-thermal: Add get_trend support Eduardo Valentin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).