summaryrefslogtreecommitdiff
path: root/drivers/thermal/imx_thermal.c
diff options
context:
space:
mode:
authorAnson Huang <b20788@freescale.com>2015-01-16 21:16:35 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-04-14 14:01:55 -0500
commitb8a87778acfdc57089e34337f1880b6b3e269f32 (patch)
treef6d7f02270ba3102264391789ecb83e9c0421513 /drivers/thermal/imx_thermal.c
parent537a27810ac734b46548205f6de3ebe336d4aadc (diff)
MLK-10106 thermal: imx: correct clk enable and thermal sensor init sequence
thermal sensor's irq init should be done after clk enabled, also, the low alarm value should be set correctly before clearing its irq status. Signed-off-by: Anson Huang <b20788@freescale.com> Signed-off-by: Bai Ping <b51503@freescale.com>
Diffstat (limited to 'drivers/thermal/imx_thermal.c')
-rw-r--r--drivers/thermal/imx_thermal.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index bf886c4a7f90..37f3be286335 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -538,31 +538,39 @@ static int imx_thermal_probe(struct platform_device *pdev)
data->socdata = of_id->data;
+ data->thermal_clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(data->thermal_clk)) {
+ dev_warn(&pdev->dev, "failed to get thermal clk!\n");
+ } else {
+ /*
+ * Thermal sensor needs clk on to get correct value, normally
+ * we should enable its clk before taking measurement and disable
+ * clk after measurement is done, but if alarm function is enabled,
+ * hardware will auto measure the temperature periodically, so we
+ * need to keep the clk always on for alarm function.
+ */
+ ret = clk_prepare_enable(data->thermal_clk);
+ if (ret)
+ dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
+ }
+
/* make sure the IRQ flag is clear before enable irq */
regmap_write(map, MISC1 + REG_CLR, MISC1_IRQ_TEMPHIGH);
if (data->socdata->version == TEMPMON_V2) {
- regmap_write(map, MISC1 + REG_CLR, MISC1_IRQ_TEMPLOW |
- MISC1_IRQ_TEMPPANIC);
/*
* reset value of LOW ALARM is incorrect, set it to lowest
* value to avoid false trigger of low alarm.
*/
regmap_write(map, TEMPSENSE2 + REG_SET,
TEMPSENSE2_LOW_VALUE_MASK);
+ regmap_write(map, MISC1 + REG_CLR, MISC1_IRQ_TEMPLOW |
+ MISC1_IRQ_TEMPPANIC);
}
data->irq = platform_get_irq(pdev, 0);
if (data->irq < 0)
return data->irq;
- ret = devm_request_threaded_irq(&pdev->dev, data->irq,
- imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread,
- 0, "imx_thermal", data);
- if (ret < 0) {
- dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret);
- return ret;
- }
-
platform_set_drvdata(pdev, data);
ret = imx_get_sensor_data(pdev);
@@ -610,22 +618,6 @@ static int imx_thermal_probe(struct platform_device *pdev)
return ret;
}
- data->thermal_clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(data->thermal_clk)) {
- dev_warn(&pdev->dev, "failed to get thermal clk!\n");
- } else {
- /*
- * Thermal sensor needs clk on to get correct value, normally
- * we should enable its clk before taking measurement and disable
- * clk after measurement is done, but if alarm function is enabled,
- * hardware will auto measure the temperature periodically, so we
- * need to keep the clk always on for alarm function.
- */
- ret = clk_prepare_enable(data->thermal_clk);
- if (ret)
- dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
- }
-
/* Enable measurements at ~ 10 Hz */
regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ);
measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
@@ -638,6 +630,13 @@ static int imx_thermal_probe(struct platform_device *pdev)
regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
+ ret = devm_request_threaded_irq(&pdev->dev, data->irq,
+ imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread,
+ 0, "imx_thermal", data);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret);
+ return ret;
+ }
data->irq_enabled = true;
data->mode = THERMAL_DEVICE_ENABLED;
/* register the busfreq notifier called in low bus freq */