All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: linux ARM <linux-arm-kernel@lists.infradead.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
Subject: Re: [PATCH 1/2] thermal: Add support for thermal sensor for Orion SoC
Date: Sat, 15 Dec 2012 06:54:17 +0900	[thread overview]
Message-ID: <CABMQnV+zNWz4UJ_127Xe+MkTt9eQVPA8StJzyEXt58Z4OqZBYw@mail.gmail.com> (raw)
In-Reply-To: <1355482986-885-2-git-send-email-andrew@lunn.ch>

Hi,

Thanks you for your work.
Sorry, I dont hava a time at this week about this.

On Fri, Dec 14, 2012 at 8:03 PM, Andrew Lunn <andrew@lunn.ch> wrote:
> 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";

compatible = "marvell,kirkwood-thermal"; ?

> +               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"

Marvel -> Marvell

> +       depends on PLAT_ORION && THERMAL
> +       help
> +         Support for the Orion thermal sensor driver into the Linux thermal
> +         framework. This currently supports only 88F6282 and 88F6283.
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 885550d..2fc64aa 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -6,4 +6,5 @@ obj-$(CONFIG_THERMAL)           += thermal_sys.o
>  obj-$(CONFIG_CPU_THERMAL)              += cpu_cooling.o
>  obj-$(CONFIG_SPEAR_THERMAL)            += spear_thermal.o
>  obj-$(CONFIG_RCAR_THERMAL)     += rcar_thermal.o
> +obj-$(CONFIG_ORION_THERMAL)            += orion_thermal.o
>  obj-$(CONFIG_EXYNOS_THERMAL)           += exynos_thermal.o
> diff --git a/drivers/thermal/orion_thermal.c b/drivers/thermal/orion_thermal.c
> new file mode 100644
> index 0000000..e8a2a68
> --- /dev/null
> +++ b/drivers/thermal/orion_thermal.c
> @@ -0,0 +1,133 @@
> +/*
> + * Orion thermal sensor driver
> + *
> + * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + */
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/of.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/thermal.h>
> +
> +#define THERMAL_VALID_OFFSET   9
> +#define THERMAL_VALID_MASK     0x1
> +#define THERMAL_TEMP_OFFSET    10
> +#define THERMAL_TEMP_MASK      0x1FF
> +
> +/* Orion Thermal Sensor Dev Structure */
> +struct orion_thermal_dev {
> +       void __iomem *base_addr;
> +};
> +
> +static int orion_get_temp(struct thermal_zone_device *thermal,
> +                         unsigned long *temp)
> +{
> +       unsigned long reg;
> +       struct orion_thermal_dev *thermal_dev = thermal->devdata;
> +
> +       reg = readl_relaxed(thermal_dev->base_addr);
> +
> +       /* Valid check */
> +       if (!(reg >> THERMAL_VALID_OFFSET) & THERMAL_VALID_MASK) {
> +               dev_info(&thermal->device,
> +                        "Temperature sensor reading not valid\n");
> +               return -EIO;
> +       }
> +
> +       reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK;
> +       /* Calculate temperature. See Table 814 in 8262 hardware manual. */
> +       *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");
> +               return  PTR_ERR(thermal);
> +       }
> +
> +       platform_set_drvdata(pdev, thermal);
> +
> +       dev_info(&thermal->device,
> +                KBUILD_MODNAME ": Thermal sensor registered\n");
> +
> +       return 0;
> +}
> +
> +static int orion_thermal_exit(struct platform_device *pdev)
> +{
> +       struct thermal_zone_device *orion_thermal = platform_get_drvdata(pdev);
> +
> +       thermal_zone_device_unregister(orion_thermal);
> +       platform_set_drvdata(pdev, NULL);
> +
> +       return 0;
> +}
> +
> +static const struct of_device_id orion_thermal_id_table[] = {
> +       { .compatible = "marvell,kirkwood-thermal" },
> +       {}
> +};
> +MODULE_DEVICE_TABLE(of, orion_thermal_id_table);
> +
> +static struct platform_driver orion_thermal_driver = {
> +       .probe = orion_thermal_probe,
> +       .remove = orion_thermal_exit,
> +       .driver = {
> +               .name = "orion_thermal",
> +               .owner = THIS_MODULE,
> +               .of_match_table = of_match_ptr(orion_thermal_id_table),
> +       },
> +};
> +
> +module_platform_driver(orion_thermal_driver);
> +
> +MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
> +MODULE_DESCRIPTION("orion thermal driver");
> +MODULE_LICENSE("GPL");
> --
> 1.7.10.4
>

Tested-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

Best regard,
  Nobuhiro

-- 
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org}
   GPG ID: 40AD1FA6

WARNING: multiple messages have this Message-ID (diff)
From: iwamatsu@nigauri.org (Nobuhiro Iwamatsu)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] thermal: Add support for thermal sensor for Orion SoC
Date: Sat, 15 Dec 2012 06:54:17 +0900	[thread overview]
Message-ID: <CABMQnV+zNWz4UJ_127Xe+MkTt9eQVPA8StJzyEXt58Z4OqZBYw@mail.gmail.com> (raw)
In-Reply-To: <1355482986-885-2-git-send-email-andrew@lunn.ch>

Hi,

Thanks you for your work.
Sorry, I dont hava a time at this week about this.

On Fri, Dec 14, 2012 at 8:03 PM, Andrew Lunn <andrew@lunn.ch> wrote:
> 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";

compatible = "marvell,kirkwood-thermal"; ?

> +               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"

Marvel -> Marvell

> +       depends on PLAT_ORION && THERMAL
> +       help
> +         Support for the Orion thermal sensor driver into the Linux thermal
> +         framework. This currently supports only 88F6282 and 88F6283.
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 885550d..2fc64aa 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -6,4 +6,5 @@ obj-$(CONFIG_THERMAL)           += thermal_sys.o
>  obj-$(CONFIG_CPU_THERMAL)              += cpu_cooling.o
>  obj-$(CONFIG_SPEAR_THERMAL)            += spear_thermal.o
>  obj-$(CONFIG_RCAR_THERMAL)     += rcar_thermal.o
> +obj-$(CONFIG_ORION_THERMAL)            += orion_thermal.o
>  obj-$(CONFIG_EXYNOS_THERMAL)           += exynos_thermal.o
> diff --git a/drivers/thermal/orion_thermal.c b/drivers/thermal/orion_thermal.c
> new file mode 100644
> index 0000000..e8a2a68
> --- /dev/null
> +++ b/drivers/thermal/orion_thermal.c
> @@ -0,0 +1,133 @@
> +/*
> + * Orion thermal sensor driver
> + *
> + * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + */
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/of.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/thermal.h>
> +
> +#define THERMAL_VALID_OFFSET   9
> +#define THERMAL_VALID_MASK     0x1
> +#define THERMAL_TEMP_OFFSET    10
> +#define THERMAL_TEMP_MASK      0x1FF
> +
> +/* Orion Thermal Sensor Dev Structure */
> +struct orion_thermal_dev {
> +       void __iomem *base_addr;
> +};
> +
> +static int orion_get_temp(struct thermal_zone_device *thermal,
> +                         unsigned long *temp)
> +{
> +       unsigned long reg;
> +       struct orion_thermal_dev *thermal_dev = thermal->devdata;
> +
> +       reg = readl_relaxed(thermal_dev->base_addr);
> +
> +       /* Valid check */
> +       if (!(reg >> THERMAL_VALID_OFFSET) & THERMAL_VALID_MASK) {
> +               dev_info(&thermal->device,
> +                        "Temperature sensor reading not valid\n");
> +               return -EIO;
> +       }
> +
> +       reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK;
> +       /* Calculate temperature. See Table 814 in 8262 hardware manual. */
> +       *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");
> +               return  PTR_ERR(thermal);
> +       }
> +
> +       platform_set_drvdata(pdev, thermal);
> +
> +       dev_info(&thermal->device,
> +                KBUILD_MODNAME ": Thermal sensor registered\n");
> +
> +       return 0;
> +}
> +
> +static int orion_thermal_exit(struct platform_device *pdev)
> +{
> +       struct thermal_zone_device *orion_thermal = platform_get_drvdata(pdev);
> +
> +       thermal_zone_device_unregister(orion_thermal);
> +       platform_set_drvdata(pdev, NULL);
> +
> +       return 0;
> +}
> +
> +static const struct of_device_id orion_thermal_id_table[] = {
> +       { .compatible = "marvell,kirkwood-thermal" },
> +       {}
> +};
> +MODULE_DEVICE_TABLE(of, orion_thermal_id_table);
> +
> +static struct platform_driver orion_thermal_driver = {
> +       .probe = orion_thermal_probe,
> +       .remove = orion_thermal_exit,
> +       .driver = {
> +               .name = "orion_thermal",
> +               .owner = THIS_MODULE,
> +               .of_match_table = of_match_ptr(orion_thermal_id_table),
> +       },
> +};
> +
> +module_platform_driver(orion_thermal_driver);
> +
> +MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
> +MODULE_DESCRIPTION("orion thermal driver");
> +MODULE_LICENSE("GPL");
> --
> 1.7.10.4
>

Tested-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

Best regard,
  Nobuhiro

-- 
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org}
   GPG ID: 40AD1FA6

  parent reply	other threads:[~2012-12-14 21:54 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
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 [this message]
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=CABMQnV+zNWz4UJ_127Xe+MkTt9eQVPA8StJzyEXt58Z4OqZBYw@mail.gmail.com \
    --to=iwamatsu@nigauri.org \
    --cc=andrew@lunn.ch \
    --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.