From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
To: "R, Durgadoss" <durgadoss.r@intel.com>
Cc: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
Lior Amsalem <alior@marvell.com>,
Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
"Zhang, Rui" <rui.zhang@intel.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Gregory Clement <gregory.clement@free-electrons.com>,
Jason Cooper <jason@lakedaemon.net>
Subject: Re: [PATCH 1/4] thermal: Add driver for Armada 370/XP SoC thermal management
Date: Tue, 26 Mar 2013 05:59:25 -0300 [thread overview]
Message-ID: <20130326085924.GA2454@localhost> (raw)
In-Reply-To: <4D68720C2E767A4AA6A8796D42C8EB59C587D8@BGSMSX101.gar.corp.intel.com>
Hi Durgadoss,
On Mon, Mar 25, 2013 at 05:27:24PM +0000, R, Durgadoss wrote:
[...]
> > +static void armadaxp_init_sensor(struct armada_thermal_priv *priv)
> > +{
> > + unsigned long reg;
> > +
> > + /* ??? */
> > + reg = readl_relaxed(priv->control);
> > + reg |= PMU_TDC0_OTF_CAL_MASK;
> > + writel(reg, priv->control);
> > +
> > + /* Reference calibration value */
> > + reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
> > + reg |= (0xf1 << PMU_TDC0_REF_CAL_CNT_OFFS);
> > + writel(reg, priv->control);
>
> I see these two blocks of code being the same for the below
> function as well. Any specific reason for not making this block
> as a common function and calling it from both the
> _init_sensor functions ?
>
I think it's more clear if we define one init_sensor function per SoC.
The common code is really little and factor that out seems to me like
too much modularization.
> > +
> > + /* Reset the sensor */
> > + reg = readl_relaxed(priv->control);
> > + writel((reg | PMU_TDC0_SW_RST_MASK), priv->control);
> > +
> > + writel(reg, priv->control);
> > +
> > + /* Enable the sensor */
> > + reg = readl_relaxed(priv->sensor);
> > + reg &= ~PMU_TM_DISABLE_MASK;
> > + writel(reg, priv->sensor);
> > +}
> > +
> > +static void armada370_init_sensor(struct armada_thermal_priv *priv)
> > +{
> > + unsigned long reg;
> > +
> > + /* ??? */
> > + reg = readl_relaxed(priv->control);
> > + reg |= PMU_TDC0_OTF_CAL_MASK;
> > + writel(reg, priv->control);
> > +
> > + /* Reference calibration value */
> > + reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
> > + reg |= (0xf1 << PMU_TDC0_REF_CAL_CNT_OFFS);
> > + writel(reg, priv->control);
> > +
> > + /* ??? */
> > + reg &= ~PMU_TDC0_START_CAL_MASK;
> > + writel(reg, priv->control);
> > +
> > + /* FIXME: Why do we need this delay? */
> > + mdelay(10);
> > +}
> > +
> > +static bool armada_is_valid(struct armada_thermal_priv *priv)
> > +{
> > + unsigned long reg = readl_relaxed(priv->sensor);
> > +
> > + return (reg >> THERMAL_VALID_OFFSET) & THERMAL_VALID_MASK;
> > +}
> > +
> > +static int armada_get_temp(struct thermal_zone_device *thermal,
> > + unsigned long *temp)
> > +{
> > + struct armada_thermal_priv *priv = thermal->devdata;
> > + unsigned long reg;
> > +
> > + /* Valid check */
> > + if (priv->ops->is_valid && !priv->ops->is_valid(priv)) {
> > + dev_err(&thermal->device,
> > + "Temperature sensor reading not valid\n");
> > + return -EIO;
> > + }
> > +
> > + reg = (readl_relaxed(priv->sensor) >> THERMAL_TEMP_OFFSET) &
>
> Can we have the readl_relaxed call as a separate statement ?
>
Why would we want that? Do you think it'll be more readable?
> > + THERMAL_TEMP_MASK;
> > + *temp = (3153000000UL - (10000000UL*reg)) / 13825;
>
> If I substitute 1 for 'reg' I get 227341.7721...
> Does this mean the temperature is 227 C ??
>
Yes, I guess so.
> If you have the info, can you add a comment on what is the
> valid range that 'reg' can take ?
>
No, I don't have the info. I guess that the valid range 'reg'
can take are the values that span a temperature between 25 ºC (or
lower if it's winter) and when your CPU is on fire :-)
> Also, Is the resulting temperature
> in MillidegreeCelsius ? If so, please add a comment saying so.
>
Yes, the resulting temperature is in millidegree celsius,
as required by the thermal framework:
Documentation/thermal/sysfs-api.txt
Thanks for the review!
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
WARNING: multiple messages have this Message-ID (diff)
From: ezequiel.garcia@free-electrons.com (Ezequiel Garcia)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] thermal: Add driver for Armada 370/XP SoC thermal management
Date: Tue, 26 Mar 2013 05:59:25 -0300 [thread overview]
Message-ID: <20130326085924.GA2454@localhost> (raw)
In-Reply-To: <4D68720C2E767A4AA6A8796D42C8EB59C587D8@BGSMSX101.gar.corp.intel.com>
Hi Durgadoss,
On Mon, Mar 25, 2013 at 05:27:24PM +0000, R, Durgadoss wrote:
[...]
> > +static void armadaxp_init_sensor(struct armada_thermal_priv *priv)
> > +{
> > + unsigned long reg;
> > +
> > + /* ??? */
> > + reg = readl_relaxed(priv->control);
> > + reg |= PMU_TDC0_OTF_CAL_MASK;
> > + writel(reg, priv->control);
> > +
> > + /* Reference calibration value */
> > + reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
> > + reg |= (0xf1 << PMU_TDC0_REF_CAL_CNT_OFFS);
> > + writel(reg, priv->control);
>
> I see these two blocks of code being the same for the below
> function as well. Any specific reason for not making this block
> as a common function and calling it from both the
> _init_sensor functions ?
>
I think it's more clear if we define one init_sensor function per SoC.
The common code is really little and factor that out seems to me like
too much modularization.
> > +
> > + /* Reset the sensor */
> > + reg = readl_relaxed(priv->control);
> > + writel((reg | PMU_TDC0_SW_RST_MASK), priv->control);
> > +
> > + writel(reg, priv->control);
> > +
> > + /* Enable the sensor */
> > + reg = readl_relaxed(priv->sensor);
> > + reg &= ~PMU_TM_DISABLE_MASK;
> > + writel(reg, priv->sensor);
> > +}
> > +
> > +static void armada370_init_sensor(struct armada_thermal_priv *priv)
> > +{
> > + unsigned long reg;
> > +
> > + /* ??? */
> > + reg = readl_relaxed(priv->control);
> > + reg |= PMU_TDC0_OTF_CAL_MASK;
> > + writel(reg, priv->control);
> > +
> > + /* Reference calibration value */
> > + reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
> > + reg |= (0xf1 << PMU_TDC0_REF_CAL_CNT_OFFS);
> > + writel(reg, priv->control);
> > +
> > + /* ??? */
> > + reg &= ~PMU_TDC0_START_CAL_MASK;
> > + writel(reg, priv->control);
> > +
> > + /* FIXME: Why do we need this delay? */
> > + mdelay(10);
> > +}
> > +
> > +static bool armada_is_valid(struct armada_thermal_priv *priv)
> > +{
> > + unsigned long reg = readl_relaxed(priv->sensor);
> > +
> > + return (reg >> THERMAL_VALID_OFFSET) & THERMAL_VALID_MASK;
> > +}
> > +
> > +static int armada_get_temp(struct thermal_zone_device *thermal,
> > + unsigned long *temp)
> > +{
> > + struct armada_thermal_priv *priv = thermal->devdata;
> > + unsigned long reg;
> > +
> > + /* Valid check */
> > + if (priv->ops->is_valid && !priv->ops->is_valid(priv)) {
> > + dev_err(&thermal->device,
> > + "Temperature sensor reading not valid\n");
> > + return -EIO;
> > + }
> > +
> > + reg = (readl_relaxed(priv->sensor) >> THERMAL_TEMP_OFFSET) &
>
> Can we have the readl_relaxed call as a separate statement ?
>
Why would we want that? Do you think it'll be more readable?
> > + THERMAL_TEMP_MASK;
> > + *temp = (3153000000UL - (10000000UL*reg)) / 13825;
>
> If I substitute 1 for 'reg' I get 227341.7721...
> Does this mean the temperature is 227 C ??
>
Yes, I guess so.
> If you have the info, can you add a comment on what is the
> valid range that 'reg' can take ?
>
No, I don't have the info. I guess that the valid range 'reg'
can take are the values that span a temperature between 25 ?C (or
lower if it's winter) and when your CPU is on fire :-)
> Also, Is the resulting temperature
> in MillidegreeCelsius ? If so, please add a comment saying so.
>
Yes, the resulting temperature is in millidegree celsius,
as required by the thermal framework:
Documentation/thermal/sysfs-api.txt
Thanks for the review!
--
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
next prev parent reply other threads:[~2013-03-26 8:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 15:27 [PATCH for 3.10 0/4] thermal: Add Armada 370/XP support Ezequiel Garcia
2013-03-25 15:27 ` Ezequiel Garcia
2013-03-25 15:27 ` [PATCH 1/4] thermal: Add driver for Armada 370/XP SoC thermal management Ezequiel Garcia
2013-03-25 15:27 ` Ezequiel Garcia
2013-03-25 17:27 ` R, Durgadoss
2013-03-25 17:27 ` R, Durgadoss
2013-03-26 8:59 ` Ezequiel Garcia [this message]
2013-03-26 8:59 ` Ezequiel Garcia
2013-03-26 9:10 ` R, Durgadoss
2013-03-26 9:10 ` R, Durgadoss
2013-03-25 18:33 ` Andrew Lunn
2013-03-25 18:33 ` Andrew Lunn
2013-03-25 15:27 ` [PATCH 2/4] ARM: mvebu: Add thermal support to Armada XP device tree Ezequiel Garcia
2013-03-25 15:27 ` Ezequiel Garcia
2013-03-25 15:27 ` [PATCH 3/4] ARM: mvebu: Add thermal support to Armada 370 " Ezequiel Garcia
2013-03-25 15:27 ` Ezequiel Garcia
2013-03-25 15:27 ` [PATCH 4/4] ARM: configs: Update mvebu defconfig for thermal Ezequiel Garcia
2013-03-25 15:27 ` Ezequiel Garcia
2013-03-27 8:54 ` [PATCH for 3.10 0/4] thermal: Add Armada 370/XP support Ezequiel Garcia
2013-03-27 8:54 ` Ezequiel Garcia
2013-03-27 15:04 ` Jason Cooper
2013-03-27 15:04 ` Jason Cooper
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=20130326085924.GA2454@localhost \
--to=ezequiel.garcia@free-electrons.com \
--cc=alior@marvell.com \
--cc=andrew@lunn.ch \
--cc=durgadoss.r@intel.com \
--cc=gregory.clement@free-electrons.com \
--cc=iwamatsu@nigauri.org \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
--cc=sebastian.hesselbarth@gmail.com \
--cc=thomas.petazzoni@free-electrons.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.