All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "R, Durgadoss" <durgadoss.r@intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	linux ARM <linux-arm-kernel@lists.infradead.org>,
	"iwamatsu@nigauri.org" <iwamatsu@nigauri.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Jason Cooper <jason@lakedaemon.net>,
	Sebastian Hesselbarth <sebastian.hesselbarth@googlemail.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	"jgunthorpe@obsidianresearch.com"
	<jgunthorpe@obsidianresearch.com>
Subject: Re: [PATCH 1/2] thermal: Add support for thermal sensor for Orion SoC
Date: Fri, 14 Dec 2012 12:50:40 +0100	[thread overview]
Message-ID: <20121214115040.GB7717@lunn.ch> (raw)
In-Reply-To: <4D68720C2E767A4AA6A8796D42C8EB59249564@BGSMSX101.gar.corp.intel.com>

On Fri, Dec 14, 2012 at 11:30:41AM +0000, R, Durgadoss wrote:
> > -----Original Message-----
> > From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-
> > owner@vger.kernel.org] On Behalf Of Andrew Lunn
> > Sent: Friday, December 14, 2012 4:33 PM
> > To: linux ARM; iwamatsu@nigauri.org; linux-pm@vger.kernel.org
> > Cc: Jason Cooper; Sebastian Hesselbarth; Thomas Petazzoni;
> > jgunthorpe@obsidianresearch.com; Andrew Lunn
> > Subject: [PATCH 1/2] thermal: Add support for thermal sensor for Orion SoC
> > 
> > From: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> > 
> > Some Orion SoC has thermal sensor.
> > This patch adds support for 88F6282 and 88F6283.
> > 
> > Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> > ---
> >  .../devicetree/bindings/thermal/orion-thermal.txt  |   16 +++
> >  drivers/thermal/Kconfig                            |    7 ++
> >  drivers/thermal/Makefile                           |    1 +
> >  drivers/thermal/orion_thermal.c                    |  133 ++++++++++++++++++++
> >  4 files changed, 157 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/thermal/orion-
> > thermal.txt
> >  create mode 100644 drivers/thermal/orion_thermal.c
> > 
> > diff --git a/Documentation/devicetree/bindings/thermal/orion-thermal.txt
> > b/Documentation/devicetree/bindings/thermal/orion-thermal.txt
> > new file mode 100644
> > index 0000000..5ce925d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/thermal/orion-thermal.txt
> > @@ -0,0 +1,16 @@
> > +* Orion Thermal
> > +
> > +This initial version is for Kirkwood 88F8262 & 88F6283 SoCs, however
> > +it is expected the driver will sometime in the future be expanded to
> > +also support Dove, using a different compatibility string.
> > +
> > +Required properties:
> > +- compatible : "marvell,kirkwood-thermal"
> > +- reg : Address range of the thermal registers
> > +
> > +Example:
> > +
> > +	thermal@10078 {
> > +		compatible = "marvell,kirkwood";
> > +		reg = <0x10078 0x4>;
> > +	};
> > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> > index e1cb6bd..3bba13f 100644
> > --- a/drivers/thermal/Kconfig
> > +++ b/drivers/thermal/Kconfig
> > @@ -55,3 +55,10 @@ config EXYNOS_THERMAL
> >  	help
> >  	  If you say yes here you get support for TMU (Thermal Managment
> >  	  Unit) on SAMSUNG EXYNOS series of SoC.
> > +
> > +config ORION_THERMAL
> > +	tristate "Temperature sensor on Marvel Orion SoCs"
> > +	depends on PLAT_ORION && THERMAL
> 
> On what tree is this patch set based on ?

Not a good one. arm-soc/for-next

I posted these patches to let other know i'm working in the driver and
to get further feedback. I've also started on adding support for Dove,
which is similar, but different.

It will get rebased onto -rc1 in a couple of weeks time and by then i
hope i will have Dove support.

> If it is, then you don't need '&& THERMAL' in Kconfig.
> > +	reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK;
> > +	/* Calculate temperature. See Table 814 in 8262 hardware manual. */
> 
> Thanks for the comment.
> Can we move this comment one line above ? like below:
> 
> /* comment */
> reg = 
> *temp =

Sure.

> BTW, is this datasheet public ?

Humm, think so. Take a look at Documentation/arm/Marvell/REAMDE. I
will check and add a reference to this README file and the specific
datasheet.

> If so, could you please add the link to the datasheet at the top ?
> 
> > +	*temp = ((322UL - reg) * 10000UL * 1000UL) / 13625UL;
> > +
> > +	return 0;
> > +}
> > +
> > +static struct thermal_zone_device_ops ops = {
> > +	.get_temp = orion_get_temp,
> > +};
> > +
> > +static int orion_thermal_probe(struct platform_device *pdev)
> > +{
> > +	struct thermal_zone_device *thermal = NULL;
> > +	struct orion_thermal_dev *thermal_dev;
> > +	struct resource *res;
> > +
> > +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	if (!res) {
> > +		dev_err(&pdev->dev, "Failed to get platform resource\n");
> > +		return -ENODEV;
> > +	}
> > +
> > +	thermal_dev = devm_kzalloc(&pdev->dev, sizeof(*thermal_dev),
> > +				   GFP_KERNEL);
> > +	if (!thermal_dev) {
> > +		dev_err(&pdev->dev, "kzalloc fail\n");
> > +		return -ENOMEM;
> > +	}
> > +
> > +	thermal_dev->base_addr = devm_ioremap(&pdev->dev, res->start,
> > +					      resource_size(res));
> > +	if (!thermal_dev->base_addr) {
> > +		dev_err(&pdev->dev, "Failed to ioremap memory\n");
> > +		return -ENOMEM;
> > +	}
> > +
> > +	thermal = thermal_zone_device_register("orion_thermal", 0, 0,
> > +				   thermal_dev, &ops, 0, 0);
> > +	if (IS_ERR(thermal)) {
> > +		dev_err(&pdev->dev,
> > +			"Failed to register thermal zone device\n");
> 
> Don't we have to free ioremap resource ? Or devm_ takes care of that ?
> please educate me :-)

devm_ should take care of that. If the probe function returns an
error, or the driver is unloaded, all resources allocated with devm_
get automagically freed.

    Andrew

WARNING: multiple messages have this Message-ID (diff)
From: andrew@lunn.ch (Andrew Lunn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] thermal: Add support for thermal sensor for Orion SoC
Date: Fri, 14 Dec 2012 12:50:40 +0100	[thread overview]
Message-ID: <20121214115040.GB7717@lunn.ch> (raw)
In-Reply-To: <4D68720C2E767A4AA6A8796D42C8EB59249564@BGSMSX101.gar.corp.intel.com>

On Fri, Dec 14, 2012 at 11:30:41AM +0000, R, Durgadoss wrote:
> > -----Original Message-----
> > From: linux-pm-owner at vger.kernel.org [mailto:linux-pm-
> > owner at vger.kernel.org] On Behalf Of Andrew Lunn
> > Sent: Friday, December 14, 2012 4:33 PM
> > To: linux ARM; iwamatsu at nigauri.org; linux-pm at vger.kernel.org
> > Cc: Jason Cooper; Sebastian Hesselbarth; Thomas Petazzoni;
> > jgunthorpe at obsidianresearch.com; Andrew Lunn
> > Subject: [PATCH 1/2] thermal: Add support for thermal sensor for Orion SoC
> > 
> > From: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> > 
> > Some Orion SoC has thermal sensor.
> > This patch adds support for 88F6282 and 88F6283.
> > 
> > Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> > ---
> >  .../devicetree/bindings/thermal/orion-thermal.txt  |   16 +++
> >  drivers/thermal/Kconfig                            |    7 ++
> >  drivers/thermal/Makefile                           |    1 +
> >  drivers/thermal/orion_thermal.c                    |  133 ++++++++++++++++++++
> >  4 files changed, 157 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/thermal/orion-
> > thermal.txt
> >  create mode 100644 drivers/thermal/orion_thermal.c
> > 
> > diff --git a/Documentation/devicetree/bindings/thermal/orion-thermal.txt
> > b/Documentation/devicetree/bindings/thermal/orion-thermal.txt
> > new file mode 100644
> > index 0000000..5ce925d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/thermal/orion-thermal.txt
> > @@ -0,0 +1,16 @@
> > +* Orion Thermal
> > +
> > +This initial version is for Kirkwood 88F8262 & 88F6283 SoCs, however
> > +it is expected the driver will sometime in the future be expanded to
> > +also support Dove, using a different compatibility string.
> > +
> > +Required properties:
> > +- compatible : "marvell,kirkwood-thermal"
> > +- reg : Address range of the thermal registers
> > +
> > +Example:
> > +
> > +	thermal at 10078 {
> > +		compatible = "marvell,kirkwood";
> > +		reg = <0x10078 0x4>;
> > +	};
> > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> > index e1cb6bd..3bba13f 100644
> > --- a/drivers/thermal/Kconfig
> > +++ b/drivers/thermal/Kconfig
> > @@ -55,3 +55,10 @@ config EXYNOS_THERMAL
> >  	help
> >  	  If you say yes here you get support for TMU (Thermal Managment
> >  	  Unit) on SAMSUNG EXYNOS series of SoC.
> > +
> > +config ORION_THERMAL
> > +	tristate "Temperature sensor on Marvel Orion SoCs"
> > +	depends on PLAT_ORION && THERMAL
> 
> On what tree is this patch set based on ?

Not a good one. arm-soc/for-next

I posted these patches to let other know i'm working in the driver and
to get further feedback. I've also started on adding support for Dove,
which is similar, but different.

It will get rebased onto -rc1 in a couple of weeks time and by then i
hope i will have Dove support.

> If it is, then you don't need '&& THERMAL' in Kconfig.
> > +	reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK;
> > +	/* Calculate temperature. See Table 814 in 8262 hardware manual. */
> 
> Thanks for the comment.
> Can we move this comment one line above ? like below:
> 
> /* comment */
> reg = 
> *temp =

Sure.

> BTW, is this datasheet public ?

Humm, think so. Take a look at Documentation/arm/Marvell/REAMDE. I
will check and add a reference to this README file and the specific
datasheet.

> If so, could you please add the link to the datasheet at the top ?
> 
> > +	*temp = ((322UL - reg) * 10000UL * 1000UL) / 13625UL;
> > +
> > +	return 0;
> > +}
> > +
> > +static struct thermal_zone_device_ops ops = {
> > +	.get_temp = orion_get_temp,
> > +};
> > +
> > +static int orion_thermal_probe(struct platform_device *pdev)
> > +{
> > +	struct thermal_zone_device *thermal = NULL;
> > +	struct orion_thermal_dev *thermal_dev;
> > +	struct resource *res;
> > +
> > +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	if (!res) {
> > +		dev_err(&pdev->dev, "Failed to get platform resource\n");
> > +		return -ENODEV;
> > +	}
> > +
> > +	thermal_dev = devm_kzalloc(&pdev->dev, sizeof(*thermal_dev),
> > +				   GFP_KERNEL);
> > +	if (!thermal_dev) {
> > +		dev_err(&pdev->dev, "kzalloc fail\n");
> > +		return -ENOMEM;
> > +	}
> > +
> > +	thermal_dev->base_addr = devm_ioremap(&pdev->dev, res->start,
> > +					      resource_size(res));
> > +	if (!thermal_dev->base_addr) {
> > +		dev_err(&pdev->dev, "Failed to ioremap memory\n");
> > +		return -ENOMEM;
> > +	}
> > +
> > +	thermal = thermal_zone_device_register("orion_thermal", 0, 0,
> > +				   thermal_dev, &ops, 0, 0);
> > +	if (IS_ERR(thermal)) {
> > +		dev_err(&pdev->dev,
> > +			"Failed to register thermal zone device\n");
> 
> Don't we have to free ioremap resource ? Or devm_ takes care of that ?
> please educate me :-)

devm_ should take care of that. If the probe function returns an
error, or the driver is unloaded, all resources allocated with devm_
get automagically freed.

    Andrew

  reply	other threads:[~2012-12-14 11:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 11:03 [PATCH 0/2] Thermal sensor for Orion/Kirkwood Andrew Lunn
2012-12-14 11:03 ` Andrew Lunn
2012-12-14 11:03 ` [PATCH 1/2] thermal: Add support for thermal sensor for Orion SoC Andrew Lunn
2012-12-14 11:03   ` Andrew Lunn
2012-12-14 11:30   ` R, Durgadoss
2012-12-14 11:30     ` R, Durgadoss
2012-12-14 11:50     ` Andrew Lunn [this message]
2012-12-14 11:50       ` Andrew Lunn
2012-12-14 22:03       ` Nobuhiro Iwamatsu
2012-12-14 22:03         ` Nobuhiro Iwamatsu
2012-12-14 18:13   ` Jason Gunthorpe
2012-12-14 18:13     ` Jason Gunthorpe
2012-12-14 21:54   ` Nobuhiro Iwamatsu
2012-12-14 21:54     ` Nobuhiro Iwamatsu
2012-12-14 22:11     ` Andrew Lunn
2012-12-14 22:11       ` Andrew Lunn
2013-01-04  7:33       ` Zhang Rui
2013-01-04  7:33         ` Zhang Rui
2013-01-04  8:15         ` Andrew Lunn
2013-01-04  8:15           ` Andrew Lunn
2013-01-04  9:40   ` Eduardo Valentin
2013-01-04  9:40     ` Eduardo Valentin
2013-01-04  9:47     ` Eduardo Valentin
2013-01-04  9:47       ` Eduardo Valentin
2013-01-04 15:35     ` Andrew Lunn
2013-01-04 15:35       ` Andrew Lunn
2013-01-07 10:06       ` Eduardo Valentin
2013-01-07 10:06         ` Eduardo Valentin
2013-01-07 10:16         ` Andrew Lunn
2013-01-07 10:16           ` Andrew Lunn
2012-12-14 11:03 ` [PATCH 2/2] ARM: Kirkwood: Add support thermal sensor for 88F6282 and 88F6283 Andrew Lunn
2012-12-14 11:03   ` Andrew Lunn

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=20121214115040.GB7717@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=durgadoss.r@intel.com \
    --cc=iwamatsu@nigauri.org \
    --cc=jason@lakedaemon.net \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sebastian.hesselbarth@googlemail.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.