]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00275542-2 thermal: imx: Add necessary clk operation
authorAnson Huang <b20788@freescale.com>
Mon, 19 Aug 2013 20:49:17 +0000 (16:49 -0400)
committerJason Liu <r64343@freescale.com>
Wed, 30 Oct 2013 01:54:54 +0000 (09:54 +0800)
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 <b20788@freescale.com>
drivers/thermal/imx_thermal.c

index 7343476c5964c11787f7aebdb89cffcf4f8350ee..7e2cea3f581fba016e0f503670bdfaf15718e8e5 100644 (file)
@@ -7,6 +7,7 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/cpu_cooling.h>
 #include <linux/cpufreq.h>
 #include <linux/delay.h>
@@ -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);