From: Leonard Crestez <leonard.crestez-3arQi8VN3Tc@public.gmane.org>
To: Eduardo Valentin <edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "Shawn Guo" <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Srinivas Kandagatla"
<srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"Zhang Rui" <rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"Rob Herring" <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Mark Rutland" <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
"Lothar Waßmann"
<LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org>,
"Fabio Estevam" <fabio.estevam-3arQi8VN3Tc@public.gmane.org>,
"Bai Ping" <ping.bai-3arQi8VN3Tc@public.gmane.org>,
"Anson Huang" <Anson.Huang-3arQi8VN3Tc@public.gmane.org>,
"Dong Aisheng" <aisheng.dong-3arQi8VN3Tc@public.gmane.org>,
"Octavian Purdila"
<octavian.purdila-3arQi8VN3Tc@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] thermal: imx: interpret fsl,tempmon-data through nvmem
Date: Wed, 5 Jul 2017 15:33:05 +0300 [thread overview]
Message-ID: <1499257985.23291.7.camel@nxp.com> (raw)
In-Reply-To: <20170704185400.GB18084-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
On Tue, 2017-07-04 at 11:54 -0700, Eduardo Valentin wrote:
> On Mon, Jun 19, 2017 at 04:40:43PM +0300, Leonard Crestez wrote:
> >
> > On imx6sx accessing the ocotp memory area directly is wrong because the
> > ocotp clock needs to be enabled first. Fix this by reinterpreting the
> > fsl,tempmon-data phandle as a reference to a nvmem_device and doing all
> > the read through that.
> >
> > @@ -347,29 +348,39 @@ static struct thermal_zone_device_ops imx_tz_ops = {
> > static int imx_get_sensor_data(struct platform_device *pdev)
> > {
> > struct imx_thermal_data *data = platform_get_drvdata(pdev);
> > - struct regmap *map;
> > + struct device_node *ocotp_np;
> > + struct nvmem_device *ocotp;
> > int t1, n1;
> > int ret;
> > u32 val;
> > u64 temp64;
> >
> > - map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
> > - "fsl,tempmon-data");
> > - if (IS_ERR(map)) {
> > - ret = PTR_ERR(map);
> > - dev_err(&pdev->dev, "failed to get sensor regmap: %d\n", ret);
> > + ocotp_np = of_parse_phandle(pdev->dev.of_node, "fsl,tempmon-data", 0);
> > + if (IS_ERR(ocotp_np)) {
> > + ret = PTR_ERR(ocotp_np);
> > + dev_err(&pdev->dev, "failed to parse fsl,tempmon-data phandle: %d\n", ret);
> > + return ret;
> > + }
> > + ocotp = of_nvmem_device_phandle_get(ocotp_np);
> > + of_node_put(ocotp_np);
> > + if (IS_ERR(ocotp)) {
> > + ret = PTR_ERR(ocotp);
> > + if (ret != -EPROBE_DEFER)
> > + dev_err(&pdev->dev, "failed to get fsl,tempmon-data nvmem device: %d\n", ret);
> > return ret;
> > }
> >
> > @@ -404,10 +415,11 @@ static int imx_get_sensor_data(struct platform_device *pdev)
> > data->c2 = n1 * data->c1 + 1000 * t1;
> >
> > /* use OTP for thermal grade */
> > - ret = regmap_read(map, OCOTP_MEM0, &val);
> > - if (ret) {
> > - dev_err(&pdev->dev, "failed to read temp grade: %d\n", ret);
> > - return ret;
> I see a few other occurences of regmap_read() in this driver, for
> example, inside imx_get_temp(). Do they also get affect by the reported
> bug? Should they be replaced with nvmem_device_read() too?
No, most of the code uses regmap to read from the tempmon device
itself.
It is only imx_get_sensor_data which uses syscon_regmap_lookup to fetch
the regmap for another device (ocotp) in order to read calibration data
and thermal grading at probe time. Perhaps this function should be
renamed to something like imx_tempmon_init_calib.
The problem is that on newer imx SOCs reading directly from OCOTP like
that doesn't work if the ocotp clock is not enabled.
--
Regards,
Leonard
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-07-05 12:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 13:40 [PATCH] thermal: imx: interpret fsl,tempmon-data through nvmem Leonard Crestez
2017-07-04 11:51 ` Leonard Crestez
2017-07-04 18:54 ` Eduardo Valentin
[not found] ` <20170704185400.GB18084-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2017-07-05 12:33 ` Leonard Crestez [this message]
[not found] ` <d1a8ec1ef73aefe6018f6a4923bd04b3ac34a5d4.1497879110.git.leonard.crestez-3arQi8VN3Tc@public.gmane.org>
2017-07-05 5:06 ` Srinivas Kandagatla
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=1499257985.23291.7.camel@nxp.com \
--to=leonard.crestez-3arqi8vn3tc@public.gmane.org \
--cc=Anson.Huang-3arQi8VN3Tc@public.gmane.org \
--cc=LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org \
--cc=aisheng.dong-3arQi8VN3Tc@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=fabio.estevam-3arQi8VN3Tc@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=octavian.purdila-3arQi8VN3Tc@public.gmane.org \
--cc=ping.bai-3arQi8VN3Tc@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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).