Devicetree
 help / color / mirror / Atom feed
From: "Anson.Huang@freescale.com" <Anson.Huang@freescale.com>
To: Shawn Guo <shawn.guo@linaro.org>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"eduardo.valentin@ti.com" <eduardo.valentin@ti.com>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"rui.zhang@intel.com" <rui.zhang@intel.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: RE: [PATCH V2 2/2] thermal: imx: add necessary clk operation
Date: Thu, 19 Dec 2013 09:10:58 +0000	[thread overview]
Message-ID: <8f8f5bf77c824fef92cacf4cfb314243@DM2PR03MB317.namprd03.prod.outlook.com> (raw)
In-Reply-To: <20131219091107.GF6691@S2101-09.ap.freescale.net>



Best Regards.
Anson huang 黄勇才
 
Freescale Semiconductor Shanghai
上海浦东新区亮景路192号A座2楼
201203
Tel:021-28937058


>-----Original Message-----
>From: Shawn Guo [mailto:shawn.guo@linaro.org]
>Sent: Thursday, December 19, 2013 5:11 PM
>To: Huang Yongcai-B20788
>Cc: kernel@pengutronix.de; rui.zhang@intel.com; eduardo.valentin@ti.com;
>devicetree@vger.kernel.org; linux-doc@vger.kernel.org; linux-arm-
>kernel@lists.infradead.org; linux-pm@vger.kernel.org
>Subject: Re: [PATCH V2 2/2] thermal: imx: add necessary clk operation
>
>On Thu, Dec 19, 2013 at 03:53:22PM -0500, Anson Huang wrote:
>> Thermal sensor needs pll3_usb_otg when measuring temperature,
>> otherwise the temperature read will be incorrect, so need to enable
>> this clk before sensor working, for alarm function, as hardware will
>> take measurement periodically, so we should keep this clk always on
>> once alarm function is enabled.
>>
>> Signed-off-by: Anson Huang <b20788@freescale.com>
>> ---
>>  .../devicetree/bindings/thermal/imx-thermal.txt    |    2 ++
>>  drivers/thermal/imx_thermal.c                      |   18
>++++++++++++++++++
>>  2 files changed, 20 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/imx-thermal.txt
>> b/Documentation/devicetree/bindings/thermal/imx-thermal.txt
>> index 541c25e..e518c6e 100644
>> --- a/Documentation/devicetree/bindings/thermal/imx-thermal.txt
>> +++ b/Documentation/devicetree/bindings/thermal/imx-thermal.txt
>> @@ -7,6 +7,7 @@ Required properties:
>>  - fsl,tempmon-data : phandle pointer to fuse controller that contains
>TEMPMON
>>    calibration data, e.g. OCOTP on imx6q.  The details about calibration
>data
>>    can be found in SoC Reference Manual.
>> +- clocks : thermal sensor's clock source.
>
>This should be listed in 'Optional properties:' now.

Right, will send a V3 later.
 

>
>Shawn
>
>>
>>  Example:
>>
>> @@ -14,4 +15,5 @@ tempmon {
>>  	compatible = "fsl,imx6q-tempmon";
>>  	fsl,tempmon = <&anatop>;
>>  	fsl,tempmon-data = <&ocotp>;
>> +	clocks = <&clks 172>;
>>  };
>> diff --git a/drivers/thermal/imx_thermal.c
>> b/drivers/thermal/imx_thermal.c index 1d6c801..c2b8173 100644
>> --- a/drivers/thermal/imx_thermal.c
>> +++ b/drivers/thermal/imx_thermal.c
>> @@ -7,6 +7,7 @@
>>   *
>>   */
>>
>> +#include <linux/clk.h>
>>  #include <linux/cpu_cooling.h>
>>  #include <linux/cpufreq.h>
>>  #include <linux/delay.h>
>> @@ -73,6 +74,7 @@ struct imx_thermal_data {
>>  	unsigned long last_temp;
>>  	bool irq_enabled;
>>  	int irq;
>> +	struct clk *thermal_clk;
>>  };
>>
>>  static void imx_set_alarm_temp(struct imx_thermal_data *data, @@
>> -457,6 +459,22 @@ 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 */
>> --
>> 1.7.9.5
>>
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2013-12-19  9:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19 20:53 [PATCH V2 2/2] thermal: imx: add necessary clk operation Anson Huang
2013-12-19  9:11 ` Shawn Guo
2013-12-19  9:10   ` Anson.Huang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f8f5bf77c824fef92cacf4cfb314243@DM2PR03MB317.namprd03.prod.outlook.com \
    --to=anson.huang@freescale.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eduardo.valentin@ti.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox