From: p.zabel@pengutronix.de (Philipp Zabel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] imx: thermal: imx_get_temp might be called before the sensor clock ist prepared
Date: Tue, 07 Oct 2014 15:04:31 +0200 [thread overview]
Message-ID: <1412687071.2577.1.camel@pengutronix.de> (raw)
In-Reply-To: <5432E14C.2090403@web.de>
Hi Heiner,
Am Montag, den 06.10.2014, 20:37 +0200 schrieb Heiner Kallweit:
> imx_get_temp might be called before the sensor clock ist prepared
> thus resulting in a timeout of the first attempt to read temp:
> thermal thermal_zone0: failed to read out thermal zone 0
> Happened to me on a Utilite Standard with IMX6 Dual SoC.
>
> Reason is that in imx_thermal_probe thermal_zone_device_register
> is called before the sensor clock is prepared.
> thermal_zone_device_register however calls
> thermal_zone_device_update which eventually calls imx_get_temp.
>
> Fix this by preparing the clock before calling
> thermal_zone_device_register.
>
> Signed-off-by: Heiner Kallweit <heiner.kallweit@web.de>
Looks good to me, just an issue with the error path - see below.
[...]
> @@ -551,6 +537,20 @@ static int imx_thermal_probe(struct platform_device *pdev)
> dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
> }
>
> + data->tz = thermal_zone_device_register("imx_thermal_zone",
> + IMX_TRIP_NUM,
> + BIT(IMX_TRIP_PASSIVE), data,
> + &imx_tz_ops, NULL,
> + IMX_PASSIVE_DELAY,
> + IMX_POLLING_DELAY);
> + if (IS_ERR(data->tz)) {
> + ret = PTR_ERR(data->tz);
> + dev_err(&pdev->dev,
> + "failed to register thermal zone device %d\n", ret);
If the thermal_clk was enabled before, clk_disable_unprepare() should be
called on it here.
> + cpufreq_cooling_unregister(data->cdev);
> + return ret;
> + }
> +
> /* Enable measurements at ~ 10 Hz */
> regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ);
> measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
> --
> 2.1.2
regards
Philipp
next prev parent reply other threads:[~2014-10-07 13:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-06 18:37 [PATCH] imx: thermal: imx_get_temp might be called before the sensor clock ist prepared Heiner Kallweit
2014-10-07 13:04 ` Philipp Zabel [this message]
2014-10-07 19:36 ` Heiner Kallweit
2014-10-07 19:42 ` Fabio Estevam
2014-10-08 5:27 ` Heiner Kallweit
-- strict thread matches above, loose matches on Subject: below --
2014-10-06 18:34 [Patch] " Heiner Kallweit
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=1412687071.2577.1.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).