From 9f77b24905e7fdb1316da3170b748a04b6eb7b30 Mon Sep 17 00:00:00 2001 From: Anson Huang Date: Mon, 19 Aug 2013 16:49:17 -0400 Subject: [PATCH] ENGR00275542-2 thermal: imx: Add necessary clk operation Thermal sensor's clock is from pll3_usb_otg 480MHz, we need to enable it before getting thermal sensor to work and disable it after thermal sensor stop working. Signed-off-by: Anson Huang --- drivers/thermal/imx_thermal.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 7343476c5964..7e2cea3f581f 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -7,6 +7,7 @@ * */ +#include #include #include #include @@ -77,6 +78,7 @@ struct imx_thermal_data { struct regmap *tempmon; unsigned long trip_temp[IMX_TRIP_NUM]; u32 c1, c2; /* See formula in imx_get_sensor_data() */ + struct clk *thermal_clk; }; static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp) @@ -87,6 +89,7 @@ static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp) unsigned int n_meas; u32 val; + clk_prepare_enable(data->thermal_clk); /* * Every time we measure the temperature, we will power on the * temperature sensor, enable measurements, take a reading, @@ -120,6 +123,8 @@ static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp) last_temp = *temp; } + clk_disable_unprepare(data->thermal_clk); + return 0; } @@ -344,6 +349,13 @@ static int imx_thermal_probe(struct platform_device *pdev) return ret; } + data->thermal_clk = devm_clk_get(&pdev->dev, NULL); + ret = IS_ERR(data->thermal_clk); + if (ret) { + dev_err(&pdev->dev, "failed to get thermal clk!\n"); + return ret; + } + /* Make sure sensor is in known good state for measurements */ regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN); regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP); -- 2.39.5