linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 1/5] thermal: qoriq: Add clock operations
@ 2019-07-30  2:21 Anson.Huang
  2019-07-30  2:21 ` [PATCH V3 2/5] thermal: qoriq: Fix error path of calling qoriq_tmu_register_tmu_zone fail Anson.Huang
                   ` (5 more replies)
  0 siblings, 6 replies; 25+ messages in thread
From: Anson.Huang @ 2019-07-30  2:21 UTC (permalink / raw)
  To: rui.zhang, edubezval, daniel.lezcano, robh+dt, mark.rutland,
	linux-pm, devicetree, linux-kernel
  Cc: Linux-imx

From: Anson Huang <Anson.Huang@nxp.com>

Some platforms like i.MX8MQ has clock control for this module,
need to add clock operations to make sure the driver is working
properly.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
---
Changes since V2:
	- move this patch as first patch in the series;
	- add clock disable handling in error path of probe.
---
 drivers/thermal/qoriq_thermal.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
index 7b36493..2893947 100644
--- a/drivers/thermal/qoriq_thermal.c
+++ b/drivers/thermal/qoriq_thermal.c
@@ -2,6 +2,7 @@
 //
 // Copyright 2016 Freescale Semiconductor, Inc.
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/err.h>
@@ -72,6 +73,7 @@ struct qoriq_sensor {
 
 struct qoriq_tmu_data {
 	struct qoriq_tmu_regs __iomem *regs;
+	struct clk *clk;
 	bool little_endian;
 	struct qoriq_sensor	*sensor[SITES_MAX];
 };
@@ -209,6 +211,16 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
 		goto err_iomap;
 	}
 
+	data->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	if (IS_ERR(data->clk))
+		return PTR_ERR(data->clk);
+
+	ret = clk_prepare_enable(data->clk);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to enable clock\n");
+		return ret;
+	}
+
 	qoriq_tmu_init_device(data);	/* TMU initialization */
 
 	ret = qoriq_tmu_calibration(pdev);	/* TMU calibration */
@@ -225,6 +237,7 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
 	return 0;
 
 err_tmu:
+	clk_disable_unprepare(data->clk);
 	iounmap(data->regs);
 
 err_iomap:
@@ -241,6 +254,9 @@ static int qoriq_tmu_remove(struct platform_device *pdev)
 	tmu_write(data, TMR_DISABLE, &data->regs->tmr);
 
 	iounmap(data->regs);
+
+	clk_disable_unprepare(data->clk);
+
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;
@@ -257,14 +273,21 @@ static int qoriq_tmu_suspend(struct device *dev)
 	tmr &= ~TMR_ME;
 	tmu_write(data, tmr, &data->regs->tmr);
 
+	clk_disable_unprepare(data->clk);
+
 	return 0;
 }
 
 static int qoriq_tmu_resume(struct device *dev)
 {
 	u32 tmr;
+	int ret;
 	struct qoriq_tmu_data *data = dev_get_drvdata(dev);
 
+	ret = clk_prepare_enable(data->clk);
+	if (ret)
+		return ret;
+
 	/* Enable monitoring */
 	tmr = tmu_read(data, &data->regs->tmr);
 	tmr |= TMR_ME;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2019-08-29  3:01 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30  2:21 [PATCH V3 1/5] thermal: qoriq: Add clock operations Anson.Huang
2019-07-30  2:21 ` [PATCH V3 2/5] thermal: qoriq: Fix error path of calling qoriq_tmu_register_tmu_zone fail Anson.Huang
2019-08-05  7:01   ` Aisheng Dong
2019-07-30  2:21 ` [PATCH V3 3/5] thermal: qoriq: Use devm_platform_ioremap_resource() instead of of_iomap() Anson.Huang
2019-08-05  7:01   ` Aisheng Dong
2019-07-30  2:21 ` [PATCH V3 4/5] thermal: qoriq: Use __maybe_unused instead of #if CONFIG_PM_SLEEP Anson.Huang
2019-08-05  7:02   ` Aisheng Dong
2019-07-30  2:21 ` [PATCH V3 5/5] dt-bindings: thermal: qoriq: Add optional clocks property Anson.Huang
2019-08-05  7:02   ` Aisheng Dong
2019-08-05  7:00 ` [PATCH V3 1/5] thermal: qoriq: Add clock operations Aisheng Dong
2019-08-26 14:45 ` Leonard Crestez
2019-08-27  1:51   ` Anson Huang
2019-08-27  3:09     ` Zhang Rui
2019-08-27  3:24       ` Anson Huang
2019-08-27 12:41     ` Leonard Crestez
2019-08-28  8:32       ` Zhang Rui
2019-08-28  8:35         ` Zhang Rui
2019-08-28  8:49           ` Anson Huang
2019-08-28  9:01             ` Zhang Rui
2019-08-28  9:12               ` Anson Huang
2019-08-28  8:51         ` Anson Huang
2019-08-28  9:03           ` Zhang Rui
2019-08-28  9:10             ` Anson Huang
2019-08-29  2:49               ` Anson Huang
2019-08-29  3:01                 ` Zhang Rui

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).