All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-20 22:36 ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This patchset is my first attempt at adding basic thermal sensor
support on Armada 370 and Armada XP.

Given Armada 370/XP and the other Marvell SoC with thermal support,
namely Kirkwood and Dove, have fairly similar thermal devices it 
made sense to integrate all of them into a single driver: mvebu-thermal.

The patches have been carefully splitted to make the changeset
as less invasive as possible. These changes can be divided in five stages:

  1. Rename 'kirkwood' driver to 'mvebu'
  2. Some fixes inherited from kirkwood driver applied to new mvebu driver
  3. Prepare mvebu driver to support multiple SoC
  4. Add thermal support for each Marvell SoC on top of mvebu driver
  5. Add device tree nodes for Armada 370 and Armada XP
  6. Fix defconfigs for all the platforms involved

Testing have been done on the following boards:

Kirkwood:   Plat'home Openblocks A6
Armada 370: Globalscale Mirabox and Marvell Armada 370 RD
Armada XP:  Plat'home Openblocks AX3 and Marvell Armada XP DB-MV784MP-GP

Dove is *not* tested due to lack of hardware.

Also, please note that the defconfigs for involved platforms have been fixed
deliberately in a single patch, to ease maintainer's job as the defconfigs
file goes through one tree and the thermal driver should go through another.

Since I'm merging two existing drivers into a new driver, I retained authorship
and copyright of the merged drivers and added my own. For this reason, I'd like
to have Andrew and Nobuhiro Acked (or Nacked, of course).

Any feedback or comments are welcome!


Ezequiel Garcia (16):
  thermal: Rename driver 'kirkwood' -> 'mvebu'
  thermal: mvebu: Rename symbols 'kirkwood' -> 'mvebu'
  thermal: mvebu: Move MODULE_DEVICE_TABLE upwards
  thermal: mvebu: Remove unneeded variable initialization
  thermal: mvebu: Fix valid check for thermal register
  thermal: mvebu: Convert to devm_ioremap_resource()
  thermal: mvebu: Fix license declaration
  thermal: mvebu: Fix temperature output formula for kirkwood
  thermal: mvebu: Rename kirkwood definitions to mvebu
  thermal: mvebu: Add infrastructure to support more multiple SoC
    variants
  thermal: mvebu: Add support for Armada XP thermal sensor
  thermal: mvebu: Add support for Armada 370 thermal sensor
  thermal: mvebu: Add support for Marvell Dove SoC family
  ARM: mvebu: Add thermal support to Armada XP device tree
  ARM: mvebu: Add thermal support to Armada 370 device tree
  ARM: configs: Update mvebu, dove and kirkwood defconfigs for thermal

 .../devicetree/bindings/thermal/dove-thermal.txt   |   18 -
 .../bindings/thermal/kirkwood-thermal.txt          |   15 -
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |   31 ++
 arch/arm/boot/dts/armada-370.dtsi                  |    6 +
 arch/arm/boot/dts/armada-xp.dtsi                   |    6 +
 arch/arm/configs/dove_defconfig                    |    2 +-
 arch/arm/configs/kirkwood_defconfig                |    2 +-
 arch/arm/configs/mvebu_defconfig                   |    2 +
 drivers/thermal/Kconfig                            |   18 +-
 drivers/thermal/Makefile                           |    3 +-
 drivers/thermal/dove_thermal.c                     |  209 ------------
 drivers/thermal/kirkwood_thermal.c                 |  134 --------
 drivers/thermal/mvebu_thermal.c                    |  342 ++++++++++++++++++++
 13 files changed, 395 insertions(+), 393 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/dove-thermal.txt
 delete mode 100644 Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
 delete mode 100644 drivers/thermal/dove_thermal.c
 delete mode 100644 drivers/thermal/kirkwood_thermal.c
 create mode 100644 drivers/thermal/mvebu_thermal.c

-- 
1.7.8.6


^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-20 22:36 ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This patchset is my first attempt at adding basic thermal sensor
support on Armada 370 and Armada XP.

Given Armada 370/XP and the other Marvell SoC with thermal support,
namely Kirkwood and Dove, have fairly similar thermal devices it 
made sense to integrate all of them into a single driver: mvebu-thermal.

The patches have been carefully splitted to make the changeset
as less invasive as possible. These changes can be divided in five stages:

  1. Rename 'kirkwood' driver to 'mvebu'
  2. Some fixes inherited from kirkwood driver applied to new mvebu driver
  3. Prepare mvebu driver to support multiple SoC
  4. Add thermal support for each Marvell SoC on top of mvebu driver
  5. Add device tree nodes for Armada 370 and Armada XP
  6. Fix defconfigs for all the platforms involved

Testing have been done on the following boards:

Kirkwood:   Plat'home Openblocks A6
Armada 370: Globalscale Mirabox and Marvell Armada 370 RD
Armada XP:  Plat'home Openblocks AX3 and Marvell Armada XP DB-MV784MP-GP

Dove is *not* tested due to lack of hardware.

Also, please note that the defconfigs for involved platforms have been fixed
deliberately in a single patch, to ease maintainer's job as the defconfigs
file goes through one tree and the thermal driver should go through another.

Since I'm merging two existing drivers into a new driver, I retained authorship
and copyright of the merged drivers and added my own. For this reason, I'd like
to have Andrew and Nobuhiro Acked (or Nacked, of course).

Any feedback or comments are welcome!


Ezequiel Garcia (16):
  thermal: Rename driver 'kirkwood' -> 'mvebu'
  thermal: mvebu: Rename symbols 'kirkwood' -> 'mvebu'
  thermal: mvebu: Move MODULE_DEVICE_TABLE upwards
  thermal: mvebu: Remove unneeded variable initialization
  thermal: mvebu: Fix valid check for thermal register
  thermal: mvebu: Convert to devm_ioremap_resource()
  thermal: mvebu: Fix license declaration
  thermal: mvebu: Fix temperature output formula for kirkwood
  thermal: mvebu: Rename kirkwood definitions to mvebu
  thermal: mvebu: Add infrastructure to support more multiple SoC
    variants
  thermal: mvebu: Add support for Armada XP thermal sensor
  thermal: mvebu: Add support for Armada 370 thermal sensor
  thermal: mvebu: Add support for Marvell Dove SoC family
  ARM: mvebu: Add thermal support to Armada XP device tree
  ARM: mvebu: Add thermal support to Armada 370 device tree
  ARM: configs: Update mvebu, dove and kirkwood defconfigs for thermal

 .../devicetree/bindings/thermal/dove-thermal.txt   |   18 -
 .../bindings/thermal/kirkwood-thermal.txt          |   15 -
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |   31 ++
 arch/arm/boot/dts/armada-370.dtsi                  |    6 +
 arch/arm/boot/dts/armada-xp.dtsi                   |    6 +
 arch/arm/configs/dove_defconfig                    |    2 +-
 arch/arm/configs/kirkwood_defconfig                |    2 +-
 arch/arm/configs/mvebu_defconfig                   |    2 +
 drivers/thermal/Kconfig                            |   18 +-
 drivers/thermal/Makefile                           |    3 +-
 drivers/thermal/dove_thermal.c                     |  209 ------------
 drivers/thermal/kirkwood_thermal.c                 |  134 --------
 drivers/thermal/mvebu_thermal.c                    |  342 ++++++++++++++++++++
 13 files changed, 395 insertions(+), 393 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/dove-thermal.txt
 delete mode 100644 Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
 delete mode 100644 drivers/thermal/dove_thermal.c
 delete mode 100644 drivers/thermal/kirkwood_thermal.c
 create mode 100644 drivers/thermal/mvebu_thermal.c

-- 
1.7.8.6

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 01/16] thermal: Rename driver 'kirkwood' -> 'mvebu'
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This driver will support several Marvell SoC, so it is convenient
to rename it to 'mvebu' to represent accurately the hardware it
supports.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../bindings/thermal/kirkwood-thermal.txt          |   15 ---
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |   15 +++
 drivers/thermal/Kconfig                            |   10 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/kirkwood_thermal.c                 |  134 --------------------
 drivers/thermal/mvebu_thermal.c                    |  134 ++++++++++++++++++++
 6 files changed, 155 insertions(+), 155 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
 delete mode 100644 drivers/thermal/kirkwood_thermal.c
 create mode 100644 drivers/thermal/mvebu_thermal.c

diff --git a/Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt b/Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
deleted file mode 100644
index 8c0f5eb..0000000
--- a/Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-* Kirkwood Thermal
-
-This version is for Kirkwood 88F8262 & 88F6283 SoCs. Other kirkwoods
-don't contain a thermal sensor.
-
-Required properties:
-- compatible : "marvell,kirkwood-thermal"
-- reg : Address range of the thermal registers
-
-Example:
-
-	thermal@10078 {
-		compatible = "marvell,kirkwood-thermal";
-		reg = <0x10078 0x4>;
-	};
diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
new file mode 100644
index 0000000..8c0f5eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -0,0 +1,15 @@
+* Kirkwood Thermal
+
+This version is for Kirkwood 88F8262 & 88F6283 SoCs. Other kirkwoods
+don't contain a thermal sensor.
+
+Required properties:
+- compatible : "marvell,kirkwood-thermal"
+- reg : Address range of the thermal registers
+
+Example:
+
+	thermal@10078 {
+		compatible = "marvell,kirkwood-thermal";
+		reg = <0x10078 0x4>;
+	};
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index a764f16..74f6b97 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -101,13 +101,13 @@ config RCAR_THERMAL
 	  Enable this to plug the R-Car thermal sensor driver into the Linux
 	  thermal framework
 
-config KIRKWOOD_THERMAL
-	tristate "Temperature sensor on Marvell Kirkwood SoCs"
-	depends on ARCH_KIRKWOOD
+config MVEBU_THERMAL
+	tristate "Temperature sensor on Marvell EBU SoCs"
+	depends on PLAT_ORION
 	depends on OF
 	help
-	  Support for the Kirkwood thermal sensor driver into the Linux thermal
-	  framework. Only kirkwood 88F6282 and 88F6283 have this sensor.
+	  Support for the thermal controllers available in several Marvell
+	  EBU SoCs in the thermal framework.
 
 config EXYNOS_THERMAL
 	tristate "Temperature sensor on Samsung EXYNOS"
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index d3a2b38..40293a1 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
 # platform thermal drivers
 obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
 obj-$(CONFIG_RCAR_THERMAL)	+= rcar_thermal.o
-obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
+obj-$(CONFIG_MVEBU_THERMAL)	+= mvebu_thermal.o
 obj-$(CONFIG_EXYNOS_THERMAL)	+= exynos_thermal.o
 obj-$(CONFIG_DOVE_THERMAL)  	+= dove_thermal.o
 obj-$(CONFIG_DB8500_THERMAL)	+= db8500_thermal.o
diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c
deleted file mode 100644
index 65cb4f0..0000000
--- a/drivers/thermal/kirkwood_thermal.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Kirkwood 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 KIRKWOOD_THERMAL_VALID_OFFSET	9
-#define KIRKWOOD_THERMAL_VALID_MASK	0x1
-#define KIRKWOOD_THERMAL_TEMP_OFFSET	10
-#define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
-
-/* Kirkwood Thermal Sensor Dev Structure */
-struct kirkwood_thermal_priv {
-	void __iomem *sensor;
-};
-
-static int kirkwood_get_temp(struct thermal_zone_device *thermal,
-			  unsigned long *temp)
-{
-	unsigned long reg;
-	struct kirkwood_thermal_priv *priv = thermal->devdata;
-
-	reg = readl_relaxed(priv->sensor);
-
-	/* Valid check */
-	if (!(reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
-	    KIRKWOOD_THERMAL_VALID_MASK) {
-		dev_err(&thermal->device,
-			"Temperature sensor reading not valid\n");
-		return -EIO;
-	}
-
-	/*
-	 * Calculate temperature. See Section 8.10.1 of the 88AP510,
-	 * datasheet, which has the same sensor.
-	 * Documentation/arm/Marvell/README
-	 */
-	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
-		KIRKWOOD_THERMAL_TEMP_MASK;
-	*temp = ((2281638UL - (7298*reg)) / 10);
-
-	return 0;
-}
-
-static struct thermal_zone_device_ops ops = {
-	.get_temp = kirkwood_get_temp,
-};
-
-static const struct of_device_id kirkwood_thermal_id_table[] = {
-	{ .compatible = "marvell,kirkwood-thermal" },
-	{}
-};
-
-static int kirkwood_thermal_probe(struct platform_device *pdev)
-{
-	struct thermal_zone_device *thermal = NULL;
-	struct kirkwood_thermal_priv *priv;
-	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;
-	}
-
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->sensor) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
-		return -EADDRNOTAVAIL;
-	}
-
-	thermal = thermal_zone_device_register("kirkwood_thermal", 0, 0,
-					       priv, &ops, NULL, 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);
-
-	return 0;
-}
-
-static int kirkwood_thermal_exit(struct platform_device *pdev)
-{
-	struct thermal_zone_device *kirkwood_thermal =
-		platform_get_drvdata(pdev);
-
-	thermal_zone_device_unregister(kirkwood_thermal);
-	platform_set_drvdata(pdev, NULL);
-
-	return 0;
-}
-
-MODULE_DEVICE_TABLE(of, kirkwood_thermal_id_table);
-
-static struct platform_driver kirkwood_thermal_driver = {
-	.probe = kirkwood_thermal_probe,
-	.remove = kirkwood_thermal_exit,
-	.driver = {
-		.name = "kirkwood_thermal",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(kirkwood_thermal_id_table),
-	},
-};
-
-module_platform_driver(kirkwood_thermal_driver);
-
-MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
-MODULE_DESCRIPTION("kirkwood thermal driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
new file mode 100644
index 0000000..65cb4f0
--- /dev/null
+++ b/drivers/thermal/mvebu_thermal.c
@@ -0,0 +1,134 @@
+/*
+ * Kirkwood 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 KIRKWOOD_THERMAL_VALID_OFFSET	9
+#define KIRKWOOD_THERMAL_VALID_MASK	0x1
+#define KIRKWOOD_THERMAL_TEMP_OFFSET	10
+#define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
+
+/* Kirkwood Thermal Sensor Dev Structure */
+struct kirkwood_thermal_priv {
+	void __iomem *sensor;
+};
+
+static int kirkwood_get_temp(struct thermal_zone_device *thermal,
+			  unsigned long *temp)
+{
+	unsigned long reg;
+	struct kirkwood_thermal_priv *priv = thermal->devdata;
+
+	reg = readl_relaxed(priv->sensor);
+
+	/* Valid check */
+	if (!(reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
+	    KIRKWOOD_THERMAL_VALID_MASK) {
+		dev_err(&thermal->device,
+			"Temperature sensor reading not valid\n");
+		return -EIO;
+	}
+
+	/*
+	 * Calculate temperature. See Section 8.10.1 of the 88AP510,
+	 * datasheet, which has the same sensor.
+	 * Documentation/arm/Marvell/README
+	 */
+	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
+		KIRKWOOD_THERMAL_TEMP_MASK;
+	*temp = ((2281638UL - (7298*reg)) / 10);
+
+	return 0;
+}
+
+static struct thermal_zone_device_ops ops = {
+	.get_temp = kirkwood_get_temp,
+};
+
+static const struct of_device_id kirkwood_thermal_id_table[] = {
+	{ .compatible = "marvell,kirkwood-thermal" },
+	{}
+};
+
+static int kirkwood_thermal_probe(struct platform_device *pdev)
+{
+	struct thermal_zone_device *thermal = NULL;
+	struct kirkwood_thermal_priv *priv;
+	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;
+	}
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
+	if (!priv->sensor) {
+		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
+		return -EADDRNOTAVAIL;
+	}
+
+	thermal = thermal_zone_device_register("kirkwood_thermal", 0, 0,
+					       priv, &ops, NULL, 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);
+
+	return 0;
+}
+
+static int kirkwood_thermal_exit(struct platform_device *pdev)
+{
+	struct thermal_zone_device *kirkwood_thermal =
+		platform_get_drvdata(pdev);
+
+	thermal_zone_device_unregister(kirkwood_thermal);
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
+MODULE_DEVICE_TABLE(of, kirkwood_thermal_id_table);
+
+static struct platform_driver kirkwood_thermal_driver = {
+	.probe = kirkwood_thermal_probe,
+	.remove = kirkwood_thermal_exit,
+	.driver = {
+		.name = "kirkwood_thermal",
+		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(kirkwood_thermal_id_table),
+	},
+};
+
+module_platform_driver(kirkwood_thermal_driver);
+
+MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
+MODULE_DESCRIPTION("kirkwood thermal driver");
+MODULE_LICENSE("GPL");
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 01/16] thermal: Rename driver 'kirkwood' -> 'mvebu'
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This driver will support several Marvell SoC, so it is convenient
to rename it to 'mvebu' to represent accurately the hardware it
supports.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../bindings/thermal/kirkwood-thermal.txt          |   15 ---
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |   15 +++
 drivers/thermal/Kconfig                            |   10 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/kirkwood_thermal.c                 |  134 --------------------
 drivers/thermal/mvebu_thermal.c                    |  134 ++++++++++++++++++++
 6 files changed, 155 insertions(+), 155 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
 delete mode 100644 drivers/thermal/kirkwood_thermal.c
 create mode 100644 drivers/thermal/mvebu_thermal.c

diff --git a/Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt b/Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
deleted file mode 100644
index 8c0f5eb..0000000
--- a/Documentation/devicetree/bindings/thermal/kirkwood-thermal.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-* Kirkwood Thermal
-
-This version is for Kirkwood 88F8262 & 88F6283 SoCs. Other kirkwoods
-don't contain a thermal sensor.
-
-Required properties:
-- compatible : "marvell,kirkwood-thermal"
-- reg : Address range of the thermal registers
-
-Example:
-
-	thermal at 10078 {
-		compatible = "marvell,kirkwood-thermal";
-		reg = <0x10078 0x4>;
-	};
diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
new file mode 100644
index 0000000..8c0f5eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -0,0 +1,15 @@
+* Kirkwood Thermal
+
+This version is for Kirkwood 88F8262 & 88F6283 SoCs. Other kirkwoods
+don't contain a thermal sensor.
+
+Required properties:
+- compatible : "marvell,kirkwood-thermal"
+- reg : Address range of the thermal registers
+
+Example:
+
+	thermal at 10078 {
+		compatible = "marvell,kirkwood-thermal";
+		reg = <0x10078 0x4>;
+	};
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index a764f16..74f6b97 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -101,13 +101,13 @@ config RCAR_THERMAL
 	  Enable this to plug the R-Car thermal sensor driver into the Linux
 	  thermal framework
 
-config KIRKWOOD_THERMAL
-	tristate "Temperature sensor on Marvell Kirkwood SoCs"
-	depends on ARCH_KIRKWOOD
+config MVEBU_THERMAL
+	tristate "Temperature sensor on Marvell EBU SoCs"
+	depends on PLAT_ORION
 	depends on OF
 	help
-	  Support for the Kirkwood thermal sensor driver into the Linux thermal
-	  framework. Only kirkwood 88F6282 and 88F6283 have this sensor.
+	  Support for the thermal controllers available in several Marvell
+	  EBU SoCs in the thermal framework.
 
 config EXYNOS_THERMAL
 	tristate "Temperature sensor on Samsung EXYNOS"
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index d3a2b38..40293a1 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
 # platform thermal drivers
 obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
 obj-$(CONFIG_RCAR_THERMAL)	+= rcar_thermal.o
-obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
+obj-$(CONFIG_MVEBU_THERMAL)	+= mvebu_thermal.o
 obj-$(CONFIG_EXYNOS_THERMAL)	+= exynos_thermal.o
 obj-$(CONFIG_DOVE_THERMAL)  	+= dove_thermal.o
 obj-$(CONFIG_DB8500_THERMAL)	+= db8500_thermal.o
diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c
deleted file mode 100644
index 65cb4f0..0000000
--- a/drivers/thermal/kirkwood_thermal.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Kirkwood 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 KIRKWOOD_THERMAL_VALID_OFFSET	9
-#define KIRKWOOD_THERMAL_VALID_MASK	0x1
-#define KIRKWOOD_THERMAL_TEMP_OFFSET	10
-#define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
-
-/* Kirkwood Thermal Sensor Dev Structure */
-struct kirkwood_thermal_priv {
-	void __iomem *sensor;
-};
-
-static int kirkwood_get_temp(struct thermal_zone_device *thermal,
-			  unsigned long *temp)
-{
-	unsigned long reg;
-	struct kirkwood_thermal_priv *priv = thermal->devdata;
-
-	reg = readl_relaxed(priv->sensor);
-
-	/* Valid check */
-	if (!(reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
-	    KIRKWOOD_THERMAL_VALID_MASK) {
-		dev_err(&thermal->device,
-			"Temperature sensor reading not valid\n");
-		return -EIO;
-	}
-
-	/*
-	 * Calculate temperature. See Section 8.10.1 of the 88AP510,
-	 * datasheet, which has the same sensor.
-	 * Documentation/arm/Marvell/README
-	 */
-	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
-		KIRKWOOD_THERMAL_TEMP_MASK;
-	*temp = ((2281638UL - (7298*reg)) / 10);
-
-	return 0;
-}
-
-static struct thermal_zone_device_ops ops = {
-	.get_temp = kirkwood_get_temp,
-};
-
-static const struct of_device_id kirkwood_thermal_id_table[] = {
-	{ .compatible = "marvell,kirkwood-thermal" },
-	{}
-};
-
-static int kirkwood_thermal_probe(struct platform_device *pdev)
-{
-	struct thermal_zone_device *thermal = NULL;
-	struct kirkwood_thermal_priv *priv;
-	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;
-	}
-
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->sensor) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
-		return -EADDRNOTAVAIL;
-	}
-
-	thermal = thermal_zone_device_register("kirkwood_thermal", 0, 0,
-					       priv, &ops, NULL, 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);
-
-	return 0;
-}
-
-static int kirkwood_thermal_exit(struct platform_device *pdev)
-{
-	struct thermal_zone_device *kirkwood_thermal =
-		platform_get_drvdata(pdev);
-
-	thermal_zone_device_unregister(kirkwood_thermal);
-	platform_set_drvdata(pdev, NULL);
-
-	return 0;
-}
-
-MODULE_DEVICE_TABLE(of, kirkwood_thermal_id_table);
-
-static struct platform_driver kirkwood_thermal_driver = {
-	.probe = kirkwood_thermal_probe,
-	.remove = kirkwood_thermal_exit,
-	.driver = {
-		.name = "kirkwood_thermal",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(kirkwood_thermal_id_table),
-	},
-};
-
-module_platform_driver(kirkwood_thermal_driver);
-
-MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
-MODULE_DESCRIPTION("kirkwood thermal driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
new file mode 100644
index 0000000..65cb4f0
--- /dev/null
+++ b/drivers/thermal/mvebu_thermal.c
@@ -0,0 +1,134 @@
+/*
+ * Kirkwood 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 KIRKWOOD_THERMAL_VALID_OFFSET	9
+#define KIRKWOOD_THERMAL_VALID_MASK	0x1
+#define KIRKWOOD_THERMAL_TEMP_OFFSET	10
+#define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
+
+/* Kirkwood Thermal Sensor Dev Structure */
+struct kirkwood_thermal_priv {
+	void __iomem *sensor;
+};
+
+static int kirkwood_get_temp(struct thermal_zone_device *thermal,
+			  unsigned long *temp)
+{
+	unsigned long reg;
+	struct kirkwood_thermal_priv *priv = thermal->devdata;
+
+	reg = readl_relaxed(priv->sensor);
+
+	/* Valid check */
+	if (!(reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
+	    KIRKWOOD_THERMAL_VALID_MASK) {
+		dev_err(&thermal->device,
+			"Temperature sensor reading not valid\n");
+		return -EIO;
+	}
+
+	/*
+	 * Calculate temperature. See Section 8.10.1 of the 88AP510,
+	 * datasheet, which has the same sensor.
+	 * Documentation/arm/Marvell/README
+	 */
+	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
+		KIRKWOOD_THERMAL_TEMP_MASK;
+	*temp = ((2281638UL - (7298*reg)) / 10);
+
+	return 0;
+}
+
+static struct thermal_zone_device_ops ops = {
+	.get_temp = kirkwood_get_temp,
+};
+
+static const struct of_device_id kirkwood_thermal_id_table[] = {
+	{ .compatible = "marvell,kirkwood-thermal" },
+	{}
+};
+
+static int kirkwood_thermal_probe(struct platform_device *pdev)
+{
+	struct thermal_zone_device *thermal = NULL;
+	struct kirkwood_thermal_priv *priv;
+	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;
+	}
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
+	if (!priv->sensor) {
+		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
+		return -EADDRNOTAVAIL;
+	}
+
+	thermal = thermal_zone_device_register("kirkwood_thermal", 0, 0,
+					       priv, &ops, NULL, 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);
+
+	return 0;
+}
+
+static int kirkwood_thermal_exit(struct platform_device *pdev)
+{
+	struct thermal_zone_device *kirkwood_thermal =
+		platform_get_drvdata(pdev);
+
+	thermal_zone_device_unregister(kirkwood_thermal);
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
+MODULE_DEVICE_TABLE(of, kirkwood_thermal_id_table);
+
+static struct platform_driver kirkwood_thermal_driver = {
+	.probe = kirkwood_thermal_probe,
+	.remove = kirkwood_thermal_exit,
+	.driver = {
+		.name = "kirkwood_thermal",
+		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(kirkwood_thermal_id_table),
+	},
+};
+
+module_platform_driver(kirkwood_thermal_driver);
+
+MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
+MODULE_DESCRIPTION("kirkwood thermal driver");
+MODULE_LICENSE("GPL");
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 02/16] thermal: mvebu: Rename symbols 'kirkwood' -> 'mvebu'
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This driver will be used to support Marvell EBU SoC thermal
sensors. Therefore, we change every symbol and comment
accordingly, before we make any functionality change.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |   42 +++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 65cb4f0..d61a750 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -1,5 +1,5 @@
 /*
- * Kirkwood thermal sensor driver
+ * Marvell EBU thermal sensor driver
  *
  * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  *
@@ -27,16 +27,16 @@
 #define KIRKWOOD_THERMAL_TEMP_OFFSET	10
 #define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
 
-/* Kirkwood Thermal Sensor Dev Structure */
-struct kirkwood_thermal_priv {
+/* Marvell EBU Thermal Sensor Dev Structure */
+struct mvebu_thermal_priv {
 	void __iomem *sensor;
 };
 
-static int kirkwood_get_temp(struct thermal_zone_device *thermal,
+static int mvebu_get_temp(struct thermal_zone_device *thermal,
 			  unsigned long *temp)
 {
 	unsigned long reg;
-	struct kirkwood_thermal_priv *priv = thermal->devdata;
+	struct mvebu_thermal_priv *priv = thermal->devdata;
 
 	reg = readl_relaxed(priv->sensor);
 
@@ -61,18 +61,18 @@ static int kirkwood_get_temp(struct thermal_zone_device *thermal,
 }
 
 static struct thermal_zone_device_ops ops = {
-	.get_temp = kirkwood_get_temp,
+	.get_temp = mvebu_get_temp,
 };
 
-static const struct of_device_id kirkwood_thermal_id_table[] = {
+static const struct of_device_id mvebu_thermal_id_table[] = {
 	{ .compatible = "marvell,kirkwood-thermal" },
 	{}
 };
 
-static int kirkwood_thermal_probe(struct platform_device *pdev)
+static int mvebu_thermal_probe(struct platform_device *pdev)
 {
 	struct thermal_zone_device *thermal = NULL;
-	struct kirkwood_thermal_priv *priv;
+	struct mvebu_thermal_priv *priv;
 	struct resource *res;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -91,7 +91,7 @@ static int kirkwood_thermal_probe(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	thermal = thermal_zone_device_register("kirkwood_thermal", 0, 0,
+	thermal = thermal_zone_device_register("mvebu_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
 	if (IS_ERR(thermal)) {
 		dev_err(&pdev->dev,
@@ -104,31 +104,31 @@ static int kirkwood_thermal_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int kirkwood_thermal_exit(struct platform_device *pdev)
+static int mvebu_thermal_exit(struct platform_device *pdev)
 {
-	struct thermal_zone_device *kirkwood_thermal =
+	struct thermal_zone_device *mvebu_thermal =
 		platform_get_drvdata(pdev);
 
-	thermal_zone_device_unregister(kirkwood_thermal);
+	thermal_zone_device_unregister(mvebu_thermal);
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;
 }
 
-MODULE_DEVICE_TABLE(of, kirkwood_thermal_id_table);
+MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
-static struct platform_driver kirkwood_thermal_driver = {
-	.probe = kirkwood_thermal_probe,
-	.remove = kirkwood_thermal_exit,
+static struct platform_driver mvebu_thermal_driver = {
+	.probe = mvebu_thermal_probe,
+	.remove = mvebu_thermal_exit,
 	.driver = {
-		.name = "kirkwood_thermal",
+		.name = "mvebu_thermal",
 		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(kirkwood_thermal_id_table),
+		.of_match_table = of_match_ptr(mvebu_thermal_id_table),
 	},
 };
 
-module_platform_driver(kirkwood_thermal_driver);
+module_platform_driver(mvebu_thermal_driver);
 
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
-MODULE_DESCRIPTION("kirkwood thermal driver");
+MODULE_DESCRIPTION("mvebu thermal driver");
 MODULE_LICENSE("GPL");
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 02/16] thermal: mvebu: Rename symbols 'kirkwood' -> 'mvebu'
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This driver will be used to support Marvell EBU SoC thermal
sensors. Therefore, we change every symbol and comment
accordingly, before we make any functionality change.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |   42 +++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 65cb4f0..d61a750 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -1,5 +1,5 @@
 /*
- * Kirkwood thermal sensor driver
+ * Marvell EBU thermal sensor driver
  *
  * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  *
@@ -27,16 +27,16 @@
 #define KIRKWOOD_THERMAL_TEMP_OFFSET	10
 #define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
 
-/* Kirkwood Thermal Sensor Dev Structure */
-struct kirkwood_thermal_priv {
+/* Marvell EBU Thermal Sensor Dev Structure */
+struct mvebu_thermal_priv {
 	void __iomem *sensor;
 };
 
-static int kirkwood_get_temp(struct thermal_zone_device *thermal,
+static int mvebu_get_temp(struct thermal_zone_device *thermal,
 			  unsigned long *temp)
 {
 	unsigned long reg;
-	struct kirkwood_thermal_priv *priv = thermal->devdata;
+	struct mvebu_thermal_priv *priv = thermal->devdata;
 
 	reg = readl_relaxed(priv->sensor);
 
@@ -61,18 +61,18 @@ static int kirkwood_get_temp(struct thermal_zone_device *thermal,
 }
 
 static struct thermal_zone_device_ops ops = {
-	.get_temp = kirkwood_get_temp,
+	.get_temp = mvebu_get_temp,
 };
 
-static const struct of_device_id kirkwood_thermal_id_table[] = {
+static const struct of_device_id mvebu_thermal_id_table[] = {
 	{ .compatible = "marvell,kirkwood-thermal" },
 	{}
 };
 
-static int kirkwood_thermal_probe(struct platform_device *pdev)
+static int mvebu_thermal_probe(struct platform_device *pdev)
 {
 	struct thermal_zone_device *thermal = NULL;
-	struct kirkwood_thermal_priv *priv;
+	struct mvebu_thermal_priv *priv;
 	struct resource *res;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -91,7 +91,7 @@ static int kirkwood_thermal_probe(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	thermal = thermal_zone_device_register("kirkwood_thermal", 0, 0,
+	thermal = thermal_zone_device_register("mvebu_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
 	if (IS_ERR(thermal)) {
 		dev_err(&pdev->dev,
@@ -104,31 +104,31 @@ static int kirkwood_thermal_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int kirkwood_thermal_exit(struct platform_device *pdev)
+static int mvebu_thermal_exit(struct platform_device *pdev)
 {
-	struct thermal_zone_device *kirkwood_thermal =
+	struct thermal_zone_device *mvebu_thermal =
 		platform_get_drvdata(pdev);
 
-	thermal_zone_device_unregister(kirkwood_thermal);
+	thermal_zone_device_unregister(mvebu_thermal);
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;
 }
 
-MODULE_DEVICE_TABLE(of, kirkwood_thermal_id_table);
+MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
-static struct platform_driver kirkwood_thermal_driver = {
-	.probe = kirkwood_thermal_probe,
-	.remove = kirkwood_thermal_exit,
+static struct platform_driver mvebu_thermal_driver = {
+	.probe = mvebu_thermal_probe,
+	.remove = mvebu_thermal_exit,
 	.driver = {
-		.name = "kirkwood_thermal",
+		.name = "mvebu_thermal",
 		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(kirkwood_thermal_id_table),
+		.of_match_table = of_match_ptr(mvebu_thermal_id_table),
 	},
 };
 
-module_platform_driver(kirkwood_thermal_driver);
+module_platform_driver(mvebu_thermal_driver);
 
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
-MODULE_DESCRIPTION("kirkwood thermal driver");
+MODULE_DESCRIPTION("mvebu thermal driver");
 MODULE_LICENSE("GPL");
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 03/16] thermal: mvebu: Move MODULE_DEVICE_TABLE upwards
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This table will be needed by mvebu_thermal_probe() so we move
it just below the declaration of the compatible device table.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index d61a750..77c488c 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -68,6 +68,7 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 	{ .compatible = "marvell,kirkwood-thermal" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
 static int mvebu_thermal_probe(struct platform_device *pdev)
 {
@@ -115,8 +116,6 @@ static int mvebu_thermal_exit(struct platform_device *pdev)
 	return 0;
 }
 
-MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
-
 static struct platform_driver mvebu_thermal_driver = {
 	.probe = mvebu_thermal_probe,
 	.remove = mvebu_thermal_exit,
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 03/16] thermal: mvebu: Move MODULE_DEVICE_TABLE upwards
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This table will be needed by mvebu_thermal_probe() so we move
it just below the declaration of the compatible device table.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index d61a750..77c488c 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -68,6 +68,7 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 	{ .compatible = "marvell,kirkwood-thermal" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
 static int mvebu_thermal_probe(struct platform_device *pdev)
 {
@@ -115,8 +116,6 @@ static int mvebu_thermal_exit(struct platform_device *pdev)
 	return 0;
 }
 
-MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
-
 static struct platform_driver mvebu_thermal_driver = {
 	.probe = mvebu_thermal_probe,
 	.remove = mvebu_thermal_exit,
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 04/16] thermal: mvebu: Remove unneeded variable initialization
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This variable is used only after it's properly initialized,
so there's no need to set it to NULL in its declaration.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 77c488c..d54f90c 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -72,7 +72,7 @@ MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
 static int mvebu_thermal_probe(struct platform_device *pdev)
 {
-	struct thermal_zone_device *thermal = NULL;
+	struct thermal_zone_device *thermal;
 	struct mvebu_thermal_priv *priv;
 	struct resource *res;
 
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 04/16] thermal: mvebu: Remove unneeded variable initialization
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This variable is used only after it's properly initialized,
so there's no need to set it to NULL in its declaration.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 77c488c..d54f90c 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -72,7 +72,7 @@ MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
 static int mvebu_thermal_probe(struct platform_device *pdev)
 {
-	struct thermal_zone_device *thermal = NULL;
+	struct thermal_zone_device *thermal;
 	struct mvebu_thermal_priv *priv;
 	struct resource *res;
 
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

The correct value is obtain by first shifting the register by the offset,
later applying the valid mask and finally invert the result.
This check was lacking an extra parenthesis to be strictly correct.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index d54f90c..ef04e4e 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -41,8 +41,8 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	reg = readl_relaxed(priv->sensor);
 
 	/* Valid check */
-	if (!(reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
-	    KIRKWOOD_THERMAL_VALID_MASK) {
+	if (!((reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
+	    KIRKWOOD_THERMAL_VALID_MASK)) {
 		dev_err(&thermal->device,
 			"Temperature sensor reading not valid\n");
 		return -EIO;
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

The correct value is obtain by first shifting the register by the offset,
later applying the valid mask and finally invert the result.
This check was lacking an extra parenthesis to be strictly correct.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index d54f90c..ef04e4e 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -41,8 +41,8 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	reg = readl_relaxed(priv->sensor);
 
 	/* Valid check */
-	if (!(reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
-	    KIRKWOOD_THERMAL_VALID_MASK) {
+	if (!((reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
+	    KIRKWOOD_THERMAL_VALID_MASK)) {
 		dev_err(&thermal->device,
 			"Temperature sensor reading not valid\n");
 		return -EIO;
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

Convert devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index ef04e4e..089b43d 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->sensor) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
+	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
+	if (!priv->sensor)
 		return -EADDRNOTAVAIL;
-	}
 
 	thermal = thermal_zone_device_register("mvebu_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

Convert devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index ef04e4e..089b43d 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->sensor) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
+	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
+	if (!priv->sensor)
 		return -EADDRNOTAVAIL;
-	}
 
 	thermal = thermal_zone_device_register("mvebu_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 07/16] thermal: mvebu: Fix license declaration
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

The license text declared in the header explicit says GPL v2 only,
but the MODULE_LICENSE macro says GPL, which means GPL v2 or later. Fix it.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 089b43d..5886a9c 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -128,4 +128,4 @@ module_platform_driver(mvebu_thermal_driver);
 
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
 MODULE_DESCRIPTION("mvebu thermal driver");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 07/16] thermal: mvebu: Fix license declaration
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

The license text declared in the header explicit says GPL v2 only,
but the MODULE_LICENSE macro says GPL, which means GPL v2 or later. Fix it.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 089b43d..5886a9c 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -128,4 +128,4 @@ module_platform_driver(mvebu_thermal_driver);
 
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
 MODULE_DESCRIPTION("mvebu thermal driver");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

The temperature formula was taken from the Armada 510 datasheet.
This is wrong because the Kirkwood SoC thermal sensor has
different coefficients.

Fix it using values from 88F682/88F683 Kirkwood datasheet.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 5886a9c..ed4c9b0 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -48,14 +48,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 		return -EIO;
 	}
 
-	/*
-	 * Calculate temperature. See Section 8.10.1 of the 88AP510,
-	 * datasheet, which has the same sensor.
-	 * Documentation/arm/Marvell/README
-	 */
 	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
 		KIRKWOOD_THERMAL_TEMP_MASK;
-	*temp = ((2281638UL - (7298*reg)) / 10);
+	*temp = ((2363302UL - (7339*reg)) / 10);
 
 	return 0;
 }
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

The temperature formula was taken from the Armada 510 datasheet.
This is wrong because the Kirkwood SoC thermal sensor has
different coefficients.

Fix it using values from 88F682/88F683 Kirkwood datasheet.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 5886a9c..ed4c9b0 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -48,14 +48,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 		return -EIO;
 	}
 
-	/*
-	 * Calculate temperature. See Section 8.10.1 of the 88AP510,
-	 * datasheet, which has the same sensor.
-	 * Documentation/arm/Marvell/README
-	 */
 	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
 		KIRKWOOD_THERMAL_TEMP_MASK;
-	*temp = ((2281638UL - (7298*reg)) / 10);
+	*temp = ((2363302UL - (7339*reg)) / 10);
 
 	return 0;
 }
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 09/16] thermal: mvebu: Rename kirkwood definitions to mvebu
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This definitions will be also valid for other SoC,
such as Armada 370 and Armada XP. Therefore we rename them as 'mvebu'.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index ed4c9b0..3304057 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -22,10 +22,10 @@
 #include <linux/platform_device.h>
 #include <linux/thermal.h>
 
-#define KIRKWOOD_THERMAL_VALID_OFFSET	9
-#define KIRKWOOD_THERMAL_VALID_MASK	0x1
-#define KIRKWOOD_THERMAL_TEMP_OFFSET	10
-#define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
+#define MVEBU_THERMAL_VALID_OFFSET	9
+#define MVEBU_THERMAL_VALID_MASK	0x1
+#define MVEBU_THERMAL_TEMP_OFFSET	10
+#define MVEBU_THERMAL_TEMP_MASK		0x1FF
 
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
@@ -41,15 +41,15 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	reg = readl_relaxed(priv->sensor);
 
 	/* Valid check */
-	if (!((reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
-	    KIRKWOOD_THERMAL_VALID_MASK)) {
+	if (!((reg >> MVEBU_THERMAL_VALID_OFFSET) &
+	    MVEBU_THERMAL_VALID_MASK)) {
 		dev_err(&thermal->device,
 			"Temperature sensor reading not valid\n");
 		return -EIO;
 	}
 
-	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
-		KIRKWOOD_THERMAL_TEMP_MASK;
+	reg = (reg >> MVEBU_THERMAL_TEMP_OFFSET) &
+		MVEBU_THERMAL_TEMP_MASK;
 	*temp = ((2363302UL - (7339*reg)) / 10);
 
 	return 0;
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 09/16] thermal: mvebu: Rename kirkwood definitions to mvebu
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This definitions will be also valid for other SoC,
such as Armada 370 and Armada XP. Therefore we rename them as 'mvebu'.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index ed4c9b0..3304057 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -22,10 +22,10 @@
 #include <linux/platform_device.h>
 #include <linux/thermal.h>
 
-#define KIRKWOOD_THERMAL_VALID_OFFSET	9
-#define KIRKWOOD_THERMAL_VALID_MASK	0x1
-#define KIRKWOOD_THERMAL_TEMP_OFFSET	10
-#define KIRKWOOD_THERMAL_TEMP_MASK	0x1FF
+#define MVEBU_THERMAL_VALID_OFFSET	9
+#define MVEBU_THERMAL_VALID_MASK	0x1
+#define MVEBU_THERMAL_TEMP_OFFSET	10
+#define MVEBU_THERMAL_TEMP_MASK		0x1FF
 
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
@@ -41,15 +41,15 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	reg = readl_relaxed(priv->sensor);
 
 	/* Valid check */
-	if (!((reg >> KIRKWOOD_THERMAL_VALID_OFFSET) &
-	    KIRKWOOD_THERMAL_VALID_MASK)) {
+	if (!((reg >> MVEBU_THERMAL_VALID_OFFSET) &
+	    MVEBU_THERMAL_VALID_MASK)) {
 		dev_err(&thermal->device,
 			"Temperature sensor reading not valid\n");
 		return -EIO;
 	}
 
-	reg = (reg >> KIRKWOOD_THERMAL_TEMP_OFFSET) &
-		KIRKWOOD_THERMAL_TEMP_MASK;
+	reg = (reg >> MVEBU_THERMAL_TEMP_OFFSET) &
+		MVEBU_THERMAL_TEMP_MASK;
 	*temp = ((2363302UL - (7339*reg)) / 10);
 
 	return 0;
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 10/16] thermal: mvebu: Add infrastructure to support more multiple SoC variants
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This commit adds the infrastructure required for mvebu thermal driver
to support multiple SoC variants.
In particular, we add support for an optional memory resource, and a
couple of optionals function pointers:
  * one to handle the case where the thermal sensor needs initialization,
  * another one to support for valid sensor value checking

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |   68 ++++++++++++++++++++++++++++++++++----
 1 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 3304057..bfe4817 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -20,8 +20,11 @@
 #include <linux/of.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/of_device.h>
 #include <linux/thermal.h>
 
+#define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
+
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
 #define MVEBU_THERMAL_TEMP_OFFSET	10
@@ -30,28 +33,48 @@
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
 	void __iomem *sensor;
+	void __iomem *control;
+	int soc_variant;
+
+	/* Initialize the sensor (optional) */
+	void (*init_sensor)(struct mvebu_thermal_priv *);
+
+	/* Test for a valid sensor value (optional) */
+	bool (*is_valid)(struct mvebu_thermal_priv *);
 };
 
+static bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg = readl_relaxed(priv->sensor);
+
+	return (reg >> MVEBU_THERMAL_VALID_OFFSET) &
+		MVEBU_THERMAL_VALID_MASK;
+}
+
 static int mvebu_get_temp(struct thermal_zone_device *thermal,
 			  unsigned long *temp)
 {
 	unsigned long reg;
 	struct mvebu_thermal_priv *priv = thermal->devdata;
 
-	reg = readl_relaxed(priv->sensor);
-
 	/* Valid check */
-	if (!((reg >> MVEBU_THERMAL_VALID_OFFSET) &
-	    MVEBU_THERMAL_VALID_MASK)) {
+	if (priv->is_valid && !priv->is_valid(priv)) {
 		dev_err(&thermal->device,
 			"Temperature sensor reading not valid\n");
 		return -EIO;
 	}
 
-	reg = (reg >> MVEBU_THERMAL_TEMP_OFFSET) &
+	reg = (readl_relaxed(priv->sensor) >> MVEBU_THERMAL_TEMP_OFFSET) &
 		MVEBU_THERMAL_TEMP_MASK;
-	*temp = ((2363302UL - (7339*reg)) / 10);
 
+	switch (priv->soc_variant) {
+	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
+		*temp = ((2363302UL - (7339*reg)) / 10);
+		break;
+	default:
+		*temp = 0;
+		break;
+	}
 	return 0;
 }
 
@@ -60,17 +83,27 @@ static struct thermal_zone_device_ops ops = {
 };
 
 static const struct of_device_id mvebu_thermal_id_table[] = {
-	{ .compatible = "marvell,kirkwood-thermal" },
-	{}
+	{
+		.compatible = "marvell,kirkwood-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD,
+	},
+	{
+		/* sentinel */
+	},
 };
 MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
 static int mvebu_thermal_probe(struct platform_device *pdev)
 {
 	struct thermal_zone_device *thermal;
+	const struct of_device_id *match;
 	struct mvebu_thermal_priv *priv;
 	struct resource *res;
 
+	match = of_match_device(mvebu_thermal_id_table, &pdev->dev);
+	if (!match)
+		return -ENODEV;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(&pdev->dev, "Failed to get platform resource\n");
@@ -85,6 +118,25 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	if (!priv->sensor)
 		return -EADDRNOTAVAIL;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res) {
+		priv->control = devm_ioremap_resource(&pdev->dev, res);
+		if (!priv->control)
+			return -EADDRNOTAVAIL;
+	}
+
+	priv->soc_variant = (int)match->data;
+	switch (priv->soc_variant) {
+	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
+		priv->is_valid = mvebu_is_valid;
+		break;
+	default:
+		break;
+	}
+
+	if (priv->init_sensor)
+		priv->init_sensor(priv);
+
 	thermal = thermal_zone_device_register("mvebu_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
 	if (IS_ERR(thermal)) {
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 10/16] thermal: mvebu: Add infrastructure to support more multiple SoC variants
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This commit adds the infrastructure required for mvebu thermal driver
to support multiple SoC variants.
In particular, we add support for an optional memory resource, and a
couple of optionals function pointers:
  * one to handle the case where the thermal sensor needs initialization,
  * another one to support for valid sensor value checking

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/thermal/mvebu_thermal.c |   68 ++++++++++++++++++++++++++++++++++----
 1 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 3304057..bfe4817 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -20,8 +20,11 @@
 #include <linux/of.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/of_device.h>
 #include <linux/thermal.h>
 
+#define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
+
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
 #define MVEBU_THERMAL_TEMP_OFFSET	10
@@ -30,28 +33,48 @@
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
 	void __iomem *sensor;
+	void __iomem *control;
+	int soc_variant;
+
+	/* Initialize the sensor (optional) */
+	void (*init_sensor)(struct mvebu_thermal_priv *);
+
+	/* Test for a valid sensor value (optional) */
+	bool (*is_valid)(struct mvebu_thermal_priv *);
 };
 
+static bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg = readl_relaxed(priv->sensor);
+
+	return (reg >> MVEBU_THERMAL_VALID_OFFSET) &
+		MVEBU_THERMAL_VALID_MASK;
+}
+
 static int mvebu_get_temp(struct thermal_zone_device *thermal,
 			  unsigned long *temp)
 {
 	unsigned long reg;
 	struct mvebu_thermal_priv *priv = thermal->devdata;
 
-	reg = readl_relaxed(priv->sensor);
-
 	/* Valid check */
-	if (!((reg >> MVEBU_THERMAL_VALID_OFFSET) &
-	    MVEBU_THERMAL_VALID_MASK)) {
+	if (priv->is_valid && !priv->is_valid(priv)) {
 		dev_err(&thermal->device,
 			"Temperature sensor reading not valid\n");
 		return -EIO;
 	}
 
-	reg = (reg >> MVEBU_THERMAL_TEMP_OFFSET) &
+	reg = (readl_relaxed(priv->sensor) >> MVEBU_THERMAL_TEMP_OFFSET) &
 		MVEBU_THERMAL_TEMP_MASK;
-	*temp = ((2363302UL - (7339*reg)) / 10);
 
+	switch (priv->soc_variant) {
+	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
+		*temp = ((2363302UL - (7339*reg)) / 10);
+		break;
+	default:
+		*temp = 0;
+		break;
+	}
 	return 0;
 }
 
@@ -60,17 +83,27 @@ static struct thermal_zone_device_ops ops = {
 };
 
 static const struct of_device_id mvebu_thermal_id_table[] = {
-	{ .compatible = "marvell,kirkwood-thermal" },
-	{}
+	{
+		.compatible = "marvell,kirkwood-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD,
+	},
+	{
+		/* sentinel */
+	},
 };
 MODULE_DEVICE_TABLE(of, mvebu_thermal_id_table);
 
 static int mvebu_thermal_probe(struct platform_device *pdev)
 {
 	struct thermal_zone_device *thermal;
+	const struct of_device_id *match;
 	struct mvebu_thermal_priv *priv;
 	struct resource *res;
 
+	match = of_match_device(mvebu_thermal_id_table, &pdev->dev);
+	if (!match)
+		return -ENODEV;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(&pdev->dev, "Failed to get platform resource\n");
@@ -85,6 +118,25 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	if (!priv->sensor)
 		return -EADDRNOTAVAIL;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res) {
+		priv->control = devm_ioremap_resource(&pdev->dev, res);
+		if (!priv->control)
+			return -EADDRNOTAVAIL;
+	}
+
+	priv->soc_variant = (int)match->data;
+	switch (priv->soc_variant) {
+	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
+		priv->is_valid = mvebu_is_valid;
+		break;
+	default:
+		break;
+	}
+
+	if (priv->init_sensor)
+		priv->init_sensor(priv);
+
 	thermal = thermal_zone_device_register("mvebu_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
 	if (IS_ERR(thermal)) {
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 11/16] thermal: mvebu: Add support for Armada XP thermal sensor
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

With the infrastructure introduced to support more SoC, we can
now easily add another thermal sensor.

The Armada XP sensor has no register to check for a valid temperature,
and has a special formula to obtain the temperature from the thermal
sensor output register.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |   21 ++++++---
 drivers/thermal/mvebu_thermal.c                    |   50 ++++++++++++++++++++
 2 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
index 8c0f5eb..7cc3fd4 100644
--- a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -1,13 +1,20 @@
-* Kirkwood Thermal
-
-This version is for Kirkwood 88F8262 & 88F6283 SoCs. Other kirkwoods
-don't contain a thermal sensor.
+* Marvell EBU Thermal
 
 Required properties:
-- compatible : "marvell,kirkwood-thermal"
-- reg : Address range of the thermal registers
 
-Example:
+- compatible:	Should be set to one of the following:
+		marvell,kirkwood-thermal
+		marvell,armadaxp-thermal
+
+- reg:		Device's register space.
+		One or two entries are expected, see the examples below.
+		The first one is required for the sensor register;
+		the second one is optional and is used as the control
+		register for sensor calibration.
+		Currently the only SoC variant having one register range
+		is Kirkwood.
+
+Kirkwood example:
 
 	thermal@10078 {
 		compatible = "marvell,kirkwood-thermal";
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index bfe4817..50f13e7 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -1,6 +1,7 @@
 /*
  * Marvell EBU thermal sensor driver
  *
+ * Copyright (C) 2013 Marvell
  * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  *
  * This software is licensed under the terms of the GNU General Public
@@ -24,12 +25,21 @@
 #include <linux/thermal.h>
 
 #define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
+#define MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP   0x2
 
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
 #define MVEBU_THERMAL_TEMP_OFFSET	10
 #define MVEBU_THERMAL_TEMP_MASK		0x1FF
 
+/* Thermal Manager Control and Status Register */
+#define PMU_TDC0_SW_RST_MASK		(0x1 << 1)
+#define PMU_TM_DISABLE_OFFS		0
+#define PMU_TM_DISABLE_MASK		(0x1 << PMU_TM_DISABLE_OFFS)
+#define PMU_TDC0_REF_CAL_CNT_OFFS	11
+#define PMU_TDC0_REF_CAL_CNT_MASK	(0x1ff << PMU_TDC0_REF_CAL_CNT_OFFS)
+#define PMU_TDC0_OTF_CAL_MASK		(0x1 << 30)
+
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
 	void __iomem *sensor;
@@ -43,6 +53,35 @@ struct mvebu_thermal_priv {
 	bool (*is_valid)(struct mvebu_thermal_priv *);
 };
 
+static void armadaxp_init_sensor(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg;
+
+	if (!priv->control)
+		return;
+
+	/* ??? */
+	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);
+
+	/* 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 bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
@@ -71,6 +110,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
 		*temp = ((2363302UL - (7339*reg)) / 10);
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
+		*temp = (3153000000UL - (10000000UL*reg)) / 13825;
+		break;
 	default:
 		*temp = 0;
 		break;
@@ -88,6 +130,10 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD,
 	},
 	{
+		.compatible = "marvell,armadaxp-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP,
+	},
+	{
 		/* sentinel */
 	},
 };
@@ -130,6 +176,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
 		priv->is_valid = mvebu_is_valid;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
+		priv->init_sensor = armadaxp_init_sensor;
+		break;
 	default:
 		break;
 	}
@@ -174,5 +223,6 @@ static struct platform_driver mvebu_thermal_driver = {
 module_platform_driver(mvebu_thermal_driver);
 
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
+MODULE_AUTHOR("Ezequiel Garcia <ezequiel.garcia@free-electrons.com>");
 MODULE_DESCRIPTION("mvebu thermal driver");
 MODULE_LICENSE("GPL v2");
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 11/16] thermal: mvebu: Add support for Armada XP thermal sensor
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

With the infrastructure introduced to support more SoC, we can
now easily add another thermal sensor.

The Armada XP sensor has no register to check for a valid temperature,
and has a special formula to obtain the temperature from the thermal
sensor output register.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |   21 ++++++---
 drivers/thermal/mvebu_thermal.c                    |   50 ++++++++++++++++++++
 2 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
index 8c0f5eb..7cc3fd4 100644
--- a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -1,13 +1,20 @@
-* Kirkwood Thermal
-
-This version is for Kirkwood 88F8262 & 88F6283 SoCs. Other kirkwoods
-don't contain a thermal sensor.
+* Marvell EBU Thermal
 
 Required properties:
-- compatible : "marvell,kirkwood-thermal"
-- reg : Address range of the thermal registers
 
-Example:
+- compatible:	Should be set to one of the following:
+		marvell,kirkwood-thermal
+		marvell,armadaxp-thermal
+
+- reg:		Device's register space.
+		One or two entries are expected, see the examples below.
+		The first one is required for the sensor register;
+		the second one is optional and is used as the control
+		register for sensor calibration.
+		Currently the only SoC variant having one register range
+		is Kirkwood.
+
+Kirkwood example:
 
 	thermal at 10078 {
 		compatible = "marvell,kirkwood-thermal";
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index bfe4817..50f13e7 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -1,6 +1,7 @@
 /*
  * Marvell EBU thermal sensor driver
  *
+ * Copyright (C) 2013 Marvell
  * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  *
  * This software is licensed under the terms of the GNU General Public
@@ -24,12 +25,21 @@
 #include <linux/thermal.h>
 
 #define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
+#define MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP   0x2
 
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
 #define MVEBU_THERMAL_TEMP_OFFSET	10
 #define MVEBU_THERMAL_TEMP_MASK		0x1FF
 
+/* Thermal Manager Control and Status Register */
+#define PMU_TDC0_SW_RST_MASK		(0x1 << 1)
+#define PMU_TM_DISABLE_OFFS		0
+#define PMU_TM_DISABLE_MASK		(0x1 << PMU_TM_DISABLE_OFFS)
+#define PMU_TDC0_REF_CAL_CNT_OFFS	11
+#define PMU_TDC0_REF_CAL_CNT_MASK	(0x1ff << PMU_TDC0_REF_CAL_CNT_OFFS)
+#define PMU_TDC0_OTF_CAL_MASK		(0x1 << 30)
+
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
 	void __iomem *sensor;
@@ -43,6 +53,35 @@ struct mvebu_thermal_priv {
 	bool (*is_valid)(struct mvebu_thermal_priv *);
 };
 
+static void armadaxp_init_sensor(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg;
+
+	if (!priv->control)
+		return;
+
+	/* ??? */
+	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);
+
+	/* 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 bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
@@ -71,6 +110,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
 		*temp = ((2363302UL - (7339*reg)) / 10);
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
+		*temp = (3153000000UL - (10000000UL*reg)) / 13825;
+		break;
 	default:
 		*temp = 0;
 		break;
@@ -88,6 +130,10 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD,
 	},
 	{
+		.compatible = "marvell,armadaxp-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP,
+	},
+	{
 		/* sentinel */
 	},
 };
@@ -130,6 +176,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	case MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD:
 		priv->is_valid = mvebu_is_valid;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
+		priv->init_sensor = armadaxp_init_sensor;
+		break;
 	default:
 		break;
 	}
@@ -174,5 +223,6 @@ static struct platform_driver mvebu_thermal_driver = {
 module_platform_driver(mvebu_thermal_driver);
 
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
+MODULE_AUTHOR("Ezequiel Garcia <ezequiel.garcia@free-electrons.com>");
 MODULE_DESCRIPTION("mvebu thermal driver");
 MODULE_LICENSE("GPL v2");
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 12/16] thermal: mvebu: Add support for Armada 370 thermal sensor
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

The Armada 370 has a register to check a valid temperature,
and its own formula to obtain the temperature from the thermal
sensor output register.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |    1 +
 drivers/thermal/mvebu_thermal.c                    |   39 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
index 7cc3fd4..49d55a9 100644
--- a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -5,6 +5,7 @@ Required properties:
 - compatible:	Should be set to one of the following:
 		marvell,kirkwood-thermal
 		marvell,armadaxp-thermal
+		marvell,armada370-thermal
 
 - reg:		Device's register space.
 		One or two entries are expected, see the examples below.
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 50f13e7..0b1e7a8 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -20,12 +20,14 @@
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/module.h>
+#include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/of_device.h>
 #include <linux/thermal.h>
 
 #define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
 #define MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP   0x2
+#define MVEBU_THERMAL_SOC_VARIANT_ARMADA_370  0x3
 
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
@@ -39,6 +41,7 @@
 #define PMU_TDC0_REF_CAL_CNT_OFFS	11
 #define PMU_TDC0_REF_CAL_CNT_MASK	(0x1ff << PMU_TDC0_REF_CAL_CNT_OFFS)
 #define PMU_TDC0_OTF_CAL_MASK		(0x1 << 30)
+#define PMU_TDC0_START_CAL_MASK		(0x1 << 25)
 
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
@@ -82,6 +85,31 @@ static void armadaxp_init_sensor(struct mvebu_thermal_priv *priv)
 	writel(reg, priv->sensor);
 }
 
+static void armada370_init_sensor(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg;
+
+	if (!priv->control)
+		return;
+
+	/* ??? */
+	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 mvebu_is_valid(struct mvebu_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
@@ -113,6 +141,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
 		*temp = (3153000000UL - (10000000UL*reg)) / 13825;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_370:
+		*temp = (228000UL - 723*reg);
+		break;
 	default:
 		*temp = 0;
 		break;
@@ -134,6 +165,10 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP,
 	},
 	{
+		.compatible = "marvell,armada370-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_370,
+	},
+	{
 		/* sentinel */
 	},
 };
@@ -179,6 +214,10 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
 		priv->init_sensor = armadaxp_init_sensor;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_370:
+		priv->is_valid = mvebu_is_valid;
+		priv->init_sensor = armada370_init_sensor;
+		break;
 	default:
 		break;
 	}
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 12/16] thermal: mvebu: Add support for Armada 370 thermal sensor
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

The Armada 370 has a register to check a valid temperature,
and its own formula to obtain the temperature from the thermal
sensor output register.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |    1 +
 drivers/thermal/mvebu_thermal.c                    |   39 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
index 7cc3fd4..49d55a9 100644
--- a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -5,6 +5,7 @@ Required properties:
 - compatible:	Should be set to one of the following:
 		marvell,kirkwood-thermal
 		marvell,armadaxp-thermal
+		marvell,armada370-thermal
 
 - reg:		Device's register space.
 		One or two entries are expected, see the examples below.
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 50f13e7..0b1e7a8 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -20,12 +20,14 @@
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/module.h>
+#include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/of_device.h>
 #include <linux/thermal.h>
 
 #define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
 #define MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP   0x2
+#define MVEBU_THERMAL_SOC_VARIANT_ARMADA_370  0x3
 
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
@@ -39,6 +41,7 @@
 #define PMU_TDC0_REF_CAL_CNT_OFFS	11
 #define PMU_TDC0_REF_CAL_CNT_MASK	(0x1ff << PMU_TDC0_REF_CAL_CNT_OFFS)
 #define PMU_TDC0_OTF_CAL_MASK		(0x1 << 30)
+#define PMU_TDC0_START_CAL_MASK		(0x1 << 25)
 
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
@@ -82,6 +85,31 @@ static void armadaxp_init_sensor(struct mvebu_thermal_priv *priv)
 	writel(reg, priv->sensor);
 }
 
+static void armada370_init_sensor(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg;
+
+	if (!priv->control)
+		return;
+
+	/* ??? */
+	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 mvebu_is_valid(struct mvebu_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
@@ -113,6 +141,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
 		*temp = (3153000000UL - (10000000UL*reg)) / 13825;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_370:
+		*temp = (228000UL - 723*reg);
+		break;
 	default:
 		*temp = 0;
 		break;
@@ -134,6 +165,10 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP,
 	},
 	{
+		.compatible = "marvell,armada370-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_370,
+	},
+	{
 		/* sentinel */
 	},
 };
@@ -179,6 +214,10 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP:
 		priv->init_sensor = armadaxp_init_sensor;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_370:
+		priv->is_valid = mvebu_is_valid;
+		priv->init_sensor = armada370_init_sensor;
+		break;
 	default:
 		break;
 	}
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 13/16] thermal: mvebu: Add support for Marvell Dove SoC family
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

With the infrastructure added in mvebu-thermal to support multiple SoC
families, it is now possible to add support for Dove SoC.
This patch adds such support taking the implementation from the
dove-thermal driver, and then removing it.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../devicetree/bindings/thermal/dove-thermal.txt   |   18 --
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |    8 +
 drivers/thermal/Kconfig                            |    8 -
 drivers/thermal/Makefile                           |    1 -
 drivers/thermal/dove_thermal.c                     |  209 --------------------
 drivers/thermal/mvebu_thermal.c                    |   75 +++++++
 6 files changed, 83 insertions(+), 236 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/dove-thermal.txt
 delete mode 100644 drivers/thermal/dove_thermal.c

diff --git a/Documentation/devicetree/bindings/thermal/dove-thermal.txt b/Documentation/devicetree/bindings/thermal/dove-thermal.txt
deleted file mode 100644
index 6f47467..0000000
--- a/Documentation/devicetree/bindings/thermal/dove-thermal.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-* Dove Thermal
-
-This driver is for Dove SoCs which contain a thermal sensor.
-
-Required properties:
-- compatible : "marvell,dove-thermal"
-- reg : Address range of the thermal registers
-
-The reg properties should contain two ranges. The first is for the
-three Thermal Manager registers, while the second range contains the
-Thermal Diode Control Registers.
-
-Example:
-
-	thermal@10078 {
-		compatible = "marvell,dove-thermal";
-		reg = <0xd001c 0x0c>, <0xd005c 0x08>;
-	};
diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
index 49d55a9..2c5297a 100644
--- a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -6,6 +6,7 @@ Required properties:
 		marvell,kirkwood-thermal
 		marvell,armadaxp-thermal
 		marvell,armada370-thermal
+		marvell,dove-thermal
 
 - reg:		Device's register space.
 		One or two entries are expected, see the examples below.
@@ -21,3 +22,10 @@ Kirkwood example:
 		compatible = "marvell,kirkwood-thermal";
 		reg = <0x10078 0x4>;
 	};
+
+Dove example:
+
+	thermal: thermal@d001c {
+		compatible = "marvell,dove-thermal";
+		reg = <0xd001c 0x0c>, <0xd005c 0x08>;
+	};
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 74f6b97..237c3e6 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -126,14 +126,6 @@ config EXYNOS_THERMAL_EMUL
 	  device directory to support emulation mode. With emulation mode sysfs
 	  node, you can manually input temperature to TMU for simulation purpose.
 
-config DOVE_THERMAL
-	tristate "Temperature sensor on Marvell Dove SoCs"
-	depends on ARCH_DOVE
-	depends on OF
-	help
-	  Support for the Dove thermal sensor driver in the Linux thermal
-	  framework.
-
 config DB8500_THERMAL
 	bool "DB8500 thermal management"
 	depends on ARCH_U8500
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 40293a1..ddd77f4 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -17,7 +17,6 @@ obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
 obj-$(CONFIG_RCAR_THERMAL)	+= rcar_thermal.o
 obj-$(CONFIG_MVEBU_THERMAL)	+= mvebu_thermal.o
 obj-$(CONFIG_EXYNOS_THERMAL)	+= exynos_thermal.o
-obj-$(CONFIG_DOVE_THERMAL)  	+= dove_thermal.o
 obj-$(CONFIG_DB8500_THERMAL)	+= db8500_thermal.o
 obj-$(CONFIG_DB8500_CPUFREQ_COOLING)	+= db8500_cpufreq_cooling.o
 obj-$(CONFIG_INTEL_POWERCLAMP)	+= intel_powerclamp.o
diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c
deleted file mode 100644
index 7b0bfa0..0000000
--- a/drivers/thermal/dove_thermal.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Dove thermal sensor driver
- *
- * Copyright (C) 2013 Andrew Lunn <andrew@lunn.ch>
- *
- * 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 DOVE_THERMAL_TEMP_OFFSET	1
-#define DOVE_THERMAL_TEMP_MASK		0x1FF
-
-/* Dove Thermal Manager Control and Status Register */
-#define PMU_TM_DISABLE_OFFS		0
-#define PMU_TM_DISABLE_MASK		(0x1 << PMU_TM_DISABLE_OFFS)
-
-/* Dove Theraml Diode Control 0 Register */
-#define PMU_TDC0_SW_RST_MASK		(0x1 << 1)
-#define PMU_TDC0_SEL_VCAL_OFFS		5
-#define PMU_TDC0_SEL_VCAL_MASK		(0x3 << PMU_TDC0_SEL_VCAL_OFFS)
-#define PMU_TDC0_REF_CAL_CNT_OFFS	11
-#define PMU_TDC0_REF_CAL_CNT_MASK	(0x1FF << PMU_TDC0_REF_CAL_CNT_OFFS)
-#define PMU_TDC0_AVG_NUM_OFFS		25
-#define PMU_TDC0_AVG_NUM_MASK		(0x7 << PMU_TDC0_AVG_NUM_OFFS)
-
-/* Dove Thermal Diode Control 1 Register */
-#define PMU_TEMP_DIOD_CTRL1_REG		0x04
-#define PMU_TDC1_TEMP_VALID_MASK	(0x1 << 10)
-
-/* Dove Thermal Sensor Dev Structure */
-struct dove_thermal_priv {
-	void __iomem *sensor;
-	void __iomem *control;
-};
-
-static int dove_init_sensor(const struct dove_thermal_priv *priv)
-{
-	u32 reg;
-	u32 i;
-
-	/* Configure the Diode Control Register #0 */
-	reg = readl_relaxed(priv->control);
-
-	/* Use average of 2 */
-	reg &= ~PMU_TDC0_AVG_NUM_MASK;
-	reg |= (0x1 << PMU_TDC0_AVG_NUM_OFFS);
-
-	/* Reference calibration value */
-	reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
-	reg |= (0x0F1 << PMU_TDC0_REF_CAL_CNT_OFFS);
-
-	/* Set the high level reference for calibration */
-	reg &= ~PMU_TDC0_SEL_VCAL_MASK;
-	reg |= (0x2 << PMU_TDC0_SEL_VCAL_OFFS);
-	writel(reg, priv->control);
-
-	/* 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);
-
-	/* Poll the sensor for the first reading */
-	for (i = 0; i < 1000000; i++) {
-		reg = readl_relaxed(priv->sensor);
-		if (reg & DOVE_THERMAL_TEMP_MASK)
-			break;
-	}
-
-	if (i == 1000000)
-		return -EIO;
-
-	return 0;
-}
-
-static int dove_get_temp(struct thermal_zone_device *thermal,
-			  unsigned long *temp)
-{
-	unsigned long reg;
-	struct dove_thermal_priv *priv = thermal->devdata;
-
-	/* Valid check */
-	reg = readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG);
-	if ((reg & PMU_TDC1_TEMP_VALID_MASK) == 0x0) {
-		dev_err(&thermal->device,
-			"Temperature sensor reading not valid\n");
-		return -EIO;
-	}
-
-	/*
-	 * Calculate temperature. See Section 8.10.1 of 88AP510,
-	 * Documentation/arm/Marvell/README
-	 */
-	reg = readl_relaxed(priv->sensor);
-	reg = (reg >> DOVE_THERMAL_TEMP_OFFSET) & DOVE_THERMAL_TEMP_MASK;
-	*temp = ((2281638UL - (7298*reg)) / 10);
-
-	return 0;
-}
-
-static struct thermal_zone_device_ops ops = {
-	.get_temp = dove_get_temp,
-};
-
-static const struct of_device_id dove_thermal_id_table[] = {
-	{ .compatible = "marvell,dove-thermal" },
-	{}
-};
-
-static int dove_thermal_probe(struct platform_device *pdev)
-{
-	struct thermal_zone_device *thermal = NULL;
-	struct dove_thermal_priv *priv;
-	struct resource *res;
-	int ret;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Failed to get platform resource\n");
-		return -ENODEV;
-	}
-
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->sensor) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
-		return -EADDRNOTAVAIL;
-	}
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (!res) {
-		dev_err(&pdev->dev, "Failed to get platform resource\n");
-		return -ENODEV;
-	}
-	priv->control = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->control) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
-		return -EADDRNOTAVAIL;
-	}
-
-	ret = dove_init_sensor(priv);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to initialize sensor\n");
-		return ret;
-	}
-
-	thermal = thermal_zone_device_register("dove_thermal", 0, 0,
-					       priv, &ops, NULL, 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);
-
-	return 0;
-}
-
-static int dove_thermal_exit(struct platform_device *pdev)
-{
-	struct thermal_zone_device *dove_thermal =
-		platform_get_drvdata(pdev);
-
-	thermal_zone_device_unregister(dove_thermal);
-	platform_set_drvdata(pdev, NULL);
-
-	return 0;
-}
-
-MODULE_DEVICE_TABLE(of, dove_thermal_id_table);
-
-static struct platform_driver dove_thermal_driver = {
-	.probe = dove_thermal_probe,
-	.remove = dove_thermal_exit,
-	.driver = {
-		.name = "dove_thermal",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(dove_thermal_id_table),
-	},
-};
-
-module_platform_driver(dove_thermal_driver);
-
-MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
-MODULE_DESCRIPTION("Dove thermal driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 0b1e7a8..fbb0612 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -2,6 +2,7 @@
  * Marvell EBU thermal sensor driver
  *
  * Copyright (C) 2013 Marvell
+ * Copyright (C) 2013 Andrew Lunn <andrew@lunn.ch>
  * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  *
  * This software is licensed under the terms of the GNU General Public
@@ -28,6 +29,7 @@
 #define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
 #define MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP   0x2
 #define MVEBU_THERMAL_SOC_VARIANT_ARMADA_370  0x3
+#define MVEBU_THERMAL_SOC_VARIANT_DOVE        0x4
 
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
@@ -42,6 +44,14 @@
 #define PMU_TDC0_REF_CAL_CNT_MASK	(0x1ff << PMU_TDC0_REF_CAL_CNT_OFFS)
 #define PMU_TDC0_OTF_CAL_MASK		(0x1 << 30)
 #define PMU_TDC0_START_CAL_MASK		(0x1 << 25)
+#define PMU_TDC0_AVG_NUM_OFFS		25
+#define PMU_TDC0_AVG_NUM_MASK		(0x7 << PMU_TDC0_AVG_NUM_OFFS)
+#define PMU_TDC0_SEL_VCAL_OFFS		5
+#define PMU_TDC0_SEL_VCAL_MASK		(0x3 << PMU_TDC0_SEL_VCAL_OFFS)
+
+/* Dove Thermal Diode Control 1 Register */
+#define PMU_TEMP_DIOD_CTRL1_REG		0x04
+#define PMU_TDC1_TEMP_VALID_MASK	(0x1 << 10)
 
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
@@ -110,6 +120,53 @@ static void armada370_init_sensor(struct mvebu_thermal_priv *priv)
 	mdelay(10);
 }
 
+static void dove_init_sensor(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg;
+	int i;
+
+	if (!priv->control)
+		return;
+
+	/* Configure the Diode Control Register #0 */
+	reg = readl_relaxed(priv->control);
+
+	/* Use average of 2 */
+	reg &= ~PMU_TDC0_AVG_NUM_MASK;
+	reg |= (0x1 << PMU_TDC0_AVG_NUM_OFFS);
+
+	/* Reference calibration value */
+	reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
+	reg |= (0x0F1 << PMU_TDC0_REF_CAL_CNT_OFFS);
+
+	/* Set the high level reference for calibration */
+	reg &= ~PMU_TDC0_SEL_VCAL_MASK;
+	reg |= (0x2 << PMU_TDC0_SEL_VCAL_OFFS);
+	writel(reg, priv->control);
+
+	/* 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);
+
+	/*
+	 * FIXME: This looks really ugly. Can't we just remove it?
+	 * Poll the sensor for the first reading
+	 */
+	for (i = 0; i < 1000000; i++) {
+		reg = (readl_relaxed(priv->sensor) >> MVEBU_THERMAL_TEMP_OFFSET)
+			& MVEBU_THERMAL_TEMP_MASK;
+		if (reg)
+			break;
+	}
+	return;
+}
+
 static bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
@@ -118,6 +175,13 @@ static bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
 		MVEBU_THERMAL_VALID_MASK;
 }
 
+static bool dove_is_valid(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg =
+		readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG);
+	return reg & PMU_TDC1_TEMP_VALID_MASK;
+}
+
 static int mvebu_get_temp(struct thermal_zone_device *thermal,
 			  unsigned long *temp)
 {
@@ -144,6 +208,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_370:
 		*temp = (228000UL - 723*reg);
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_DOVE:
+		*temp = ((2281638UL - (7298*reg)) / 10);
+		break;
 	default:
 		*temp = 0;
 		break;
@@ -169,6 +236,10 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_370,
 	},
 	{
+		.compatible = "marvell,dove-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_DOVE,
+	},
+	{
 		/* sentinel */
 	},
 };
@@ -218,6 +289,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 		priv->is_valid = mvebu_is_valid;
 		priv->init_sensor = armada370_init_sensor;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_DOVE:
+		priv->is_valid = dove_is_valid;
+		priv->init_sensor = dove_init_sensor;
 	default:
 		break;
 	}
@@ -261,6 +335,7 @@ static struct platform_driver mvebu_thermal_driver = {
 
 module_platform_driver(mvebu_thermal_driver);
 
+MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
 MODULE_AUTHOR("Ezequiel Garcia <ezequiel.garcia@free-electrons.com>");
 MODULE_DESCRIPTION("mvebu thermal driver");
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 13/16] thermal: mvebu: Add support for Marvell Dove SoC family
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

With the infrastructure added in mvebu-thermal to support multiple SoC
families, it is now possible to add support for Dove SoC.
This patch adds such support taking the implementation from the
dove-thermal driver, and then removing it.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 .../devicetree/bindings/thermal/dove-thermal.txt   |   18 --
 .../devicetree/bindings/thermal/mvebu-thermal.txt  |    8 +
 drivers/thermal/Kconfig                            |    8 -
 drivers/thermal/Makefile                           |    1 -
 drivers/thermal/dove_thermal.c                     |  209 --------------------
 drivers/thermal/mvebu_thermal.c                    |   75 +++++++
 6 files changed, 83 insertions(+), 236 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/dove-thermal.txt
 delete mode 100644 drivers/thermal/dove_thermal.c

diff --git a/Documentation/devicetree/bindings/thermal/dove-thermal.txt b/Documentation/devicetree/bindings/thermal/dove-thermal.txt
deleted file mode 100644
index 6f47467..0000000
--- a/Documentation/devicetree/bindings/thermal/dove-thermal.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-* Dove Thermal
-
-This driver is for Dove SoCs which contain a thermal sensor.
-
-Required properties:
-- compatible : "marvell,dove-thermal"
-- reg : Address range of the thermal registers
-
-The reg properties should contain two ranges. The first is for the
-three Thermal Manager registers, while the second range contains the
-Thermal Diode Control Registers.
-
-Example:
-
-	thermal at 10078 {
-		compatible = "marvell,dove-thermal";
-		reg = <0xd001c 0x0c>, <0xd005c 0x08>;
-	};
diff --git a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
index 49d55a9..2c5297a 100644
--- a/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mvebu-thermal.txt
@@ -6,6 +6,7 @@ Required properties:
 		marvell,kirkwood-thermal
 		marvell,armadaxp-thermal
 		marvell,armada370-thermal
+		marvell,dove-thermal
 
 - reg:		Device's register space.
 		One or two entries are expected, see the examples below.
@@ -21,3 +22,10 @@ Kirkwood example:
 		compatible = "marvell,kirkwood-thermal";
 		reg = <0x10078 0x4>;
 	};
+
+Dove example:
+
+	thermal: thermal at d001c {
+		compatible = "marvell,dove-thermal";
+		reg = <0xd001c 0x0c>, <0xd005c 0x08>;
+	};
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 74f6b97..237c3e6 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -126,14 +126,6 @@ config EXYNOS_THERMAL_EMUL
 	  device directory to support emulation mode. With emulation mode sysfs
 	  node, you can manually input temperature to TMU for simulation purpose.
 
-config DOVE_THERMAL
-	tristate "Temperature sensor on Marvell Dove SoCs"
-	depends on ARCH_DOVE
-	depends on OF
-	help
-	  Support for the Dove thermal sensor driver in the Linux thermal
-	  framework.
-
 config DB8500_THERMAL
 	bool "DB8500 thermal management"
 	depends on ARCH_U8500
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 40293a1..ddd77f4 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -17,7 +17,6 @@ obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
 obj-$(CONFIG_RCAR_THERMAL)	+= rcar_thermal.o
 obj-$(CONFIG_MVEBU_THERMAL)	+= mvebu_thermal.o
 obj-$(CONFIG_EXYNOS_THERMAL)	+= exynos_thermal.o
-obj-$(CONFIG_DOVE_THERMAL)  	+= dove_thermal.o
 obj-$(CONFIG_DB8500_THERMAL)	+= db8500_thermal.o
 obj-$(CONFIG_DB8500_CPUFREQ_COOLING)	+= db8500_cpufreq_cooling.o
 obj-$(CONFIG_INTEL_POWERCLAMP)	+= intel_powerclamp.o
diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c
deleted file mode 100644
index 7b0bfa0..0000000
--- a/drivers/thermal/dove_thermal.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Dove thermal sensor driver
- *
- * Copyright (C) 2013 Andrew Lunn <andrew@lunn.ch>
- *
- * 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 DOVE_THERMAL_TEMP_OFFSET	1
-#define DOVE_THERMAL_TEMP_MASK		0x1FF
-
-/* Dove Thermal Manager Control and Status Register */
-#define PMU_TM_DISABLE_OFFS		0
-#define PMU_TM_DISABLE_MASK		(0x1 << PMU_TM_DISABLE_OFFS)
-
-/* Dove Theraml Diode Control 0 Register */
-#define PMU_TDC0_SW_RST_MASK		(0x1 << 1)
-#define PMU_TDC0_SEL_VCAL_OFFS		5
-#define PMU_TDC0_SEL_VCAL_MASK		(0x3 << PMU_TDC0_SEL_VCAL_OFFS)
-#define PMU_TDC0_REF_CAL_CNT_OFFS	11
-#define PMU_TDC0_REF_CAL_CNT_MASK	(0x1FF << PMU_TDC0_REF_CAL_CNT_OFFS)
-#define PMU_TDC0_AVG_NUM_OFFS		25
-#define PMU_TDC0_AVG_NUM_MASK		(0x7 << PMU_TDC0_AVG_NUM_OFFS)
-
-/* Dove Thermal Diode Control 1 Register */
-#define PMU_TEMP_DIOD_CTRL1_REG		0x04
-#define PMU_TDC1_TEMP_VALID_MASK	(0x1 << 10)
-
-/* Dove Thermal Sensor Dev Structure */
-struct dove_thermal_priv {
-	void __iomem *sensor;
-	void __iomem *control;
-};
-
-static int dove_init_sensor(const struct dove_thermal_priv *priv)
-{
-	u32 reg;
-	u32 i;
-
-	/* Configure the Diode Control Register #0 */
-	reg = readl_relaxed(priv->control);
-
-	/* Use average of 2 */
-	reg &= ~PMU_TDC0_AVG_NUM_MASK;
-	reg |= (0x1 << PMU_TDC0_AVG_NUM_OFFS);
-
-	/* Reference calibration value */
-	reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
-	reg |= (0x0F1 << PMU_TDC0_REF_CAL_CNT_OFFS);
-
-	/* Set the high level reference for calibration */
-	reg &= ~PMU_TDC0_SEL_VCAL_MASK;
-	reg |= (0x2 << PMU_TDC0_SEL_VCAL_OFFS);
-	writel(reg, priv->control);
-
-	/* 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);
-
-	/* Poll the sensor for the first reading */
-	for (i = 0; i < 1000000; i++) {
-		reg = readl_relaxed(priv->sensor);
-		if (reg & DOVE_THERMAL_TEMP_MASK)
-			break;
-	}
-
-	if (i == 1000000)
-		return -EIO;
-
-	return 0;
-}
-
-static int dove_get_temp(struct thermal_zone_device *thermal,
-			  unsigned long *temp)
-{
-	unsigned long reg;
-	struct dove_thermal_priv *priv = thermal->devdata;
-
-	/* Valid check */
-	reg = readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG);
-	if ((reg & PMU_TDC1_TEMP_VALID_MASK) == 0x0) {
-		dev_err(&thermal->device,
-			"Temperature sensor reading not valid\n");
-		return -EIO;
-	}
-
-	/*
-	 * Calculate temperature. See Section 8.10.1 of 88AP510,
-	 * Documentation/arm/Marvell/README
-	 */
-	reg = readl_relaxed(priv->sensor);
-	reg = (reg >> DOVE_THERMAL_TEMP_OFFSET) & DOVE_THERMAL_TEMP_MASK;
-	*temp = ((2281638UL - (7298*reg)) / 10);
-
-	return 0;
-}
-
-static struct thermal_zone_device_ops ops = {
-	.get_temp = dove_get_temp,
-};
-
-static const struct of_device_id dove_thermal_id_table[] = {
-	{ .compatible = "marvell,dove-thermal" },
-	{}
-};
-
-static int dove_thermal_probe(struct platform_device *pdev)
-{
-	struct thermal_zone_device *thermal = NULL;
-	struct dove_thermal_priv *priv;
-	struct resource *res;
-	int ret;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Failed to get platform resource\n");
-		return -ENODEV;
-	}
-
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->sensor) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
-		return -EADDRNOTAVAIL;
-	}
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (!res) {
-		dev_err(&pdev->dev, "Failed to get platform resource\n");
-		return -ENODEV;
-	}
-	priv->control = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->control) {
-		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
-		return -EADDRNOTAVAIL;
-	}
-
-	ret = dove_init_sensor(priv);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to initialize sensor\n");
-		return ret;
-	}
-
-	thermal = thermal_zone_device_register("dove_thermal", 0, 0,
-					       priv, &ops, NULL, 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);
-
-	return 0;
-}
-
-static int dove_thermal_exit(struct platform_device *pdev)
-{
-	struct thermal_zone_device *dove_thermal =
-		platform_get_drvdata(pdev);
-
-	thermal_zone_device_unregister(dove_thermal);
-	platform_set_drvdata(pdev, NULL);
-
-	return 0;
-}
-
-MODULE_DEVICE_TABLE(of, dove_thermal_id_table);
-
-static struct platform_driver dove_thermal_driver = {
-	.probe = dove_thermal_probe,
-	.remove = dove_thermal_exit,
-	.driver = {
-		.name = "dove_thermal",
-		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(dove_thermal_id_table),
-	},
-};
-
-module_platform_driver(dove_thermal_driver);
-
-MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
-MODULE_DESCRIPTION("Dove thermal driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
index 0b1e7a8..fbb0612 100644
--- a/drivers/thermal/mvebu_thermal.c
+++ b/drivers/thermal/mvebu_thermal.c
@@ -2,6 +2,7 @@
  * Marvell EBU thermal sensor driver
  *
  * Copyright (C) 2013 Marvell
+ * Copyright (C) 2013 Andrew Lunn <andrew@lunn.ch>
  * Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  *
  * This software is licensed under the terms of the GNU General Public
@@ -28,6 +29,7 @@
 #define MVEBU_THERMAL_SOC_VARIANT_KIRKWOOD    0x1
 #define MVEBU_THERMAL_SOC_VARIANT_ARMADA_XP   0x2
 #define MVEBU_THERMAL_SOC_VARIANT_ARMADA_370  0x3
+#define MVEBU_THERMAL_SOC_VARIANT_DOVE        0x4
 
 #define MVEBU_THERMAL_VALID_OFFSET	9
 #define MVEBU_THERMAL_VALID_MASK	0x1
@@ -42,6 +44,14 @@
 #define PMU_TDC0_REF_CAL_CNT_MASK	(0x1ff << PMU_TDC0_REF_CAL_CNT_OFFS)
 #define PMU_TDC0_OTF_CAL_MASK		(0x1 << 30)
 #define PMU_TDC0_START_CAL_MASK		(0x1 << 25)
+#define PMU_TDC0_AVG_NUM_OFFS		25
+#define PMU_TDC0_AVG_NUM_MASK		(0x7 << PMU_TDC0_AVG_NUM_OFFS)
+#define PMU_TDC0_SEL_VCAL_OFFS		5
+#define PMU_TDC0_SEL_VCAL_MASK		(0x3 << PMU_TDC0_SEL_VCAL_OFFS)
+
+/* Dove Thermal Diode Control 1 Register */
+#define PMU_TEMP_DIOD_CTRL1_REG		0x04
+#define PMU_TDC1_TEMP_VALID_MASK	(0x1 << 10)
 
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct mvebu_thermal_priv {
@@ -110,6 +120,53 @@ static void armada370_init_sensor(struct mvebu_thermal_priv *priv)
 	mdelay(10);
 }
 
+static void dove_init_sensor(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg;
+	int i;
+
+	if (!priv->control)
+		return;
+
+	/* Configure the Diode Control Register #0 */
+	reg = readl_relaxed(priv->control);
+
+	/* Use average of 2 */
+	reg &= ~PMU_TDC0_AVG_NUM_MASK;
+	reg |= (0x1 << PMU_TDC0_AVG_NUM_OFFS);
+
+	/* Reference calibration value */
+	reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
+	reg |= (0x0F1 << PMU_TDC0_REF_CAL_CNT_OFFS);
+
+	/* Set the high level reference for calibration */
+	reg &= ~PMU_TDC0_SEL_VCAL_MASK;
+	reg |= (0x2 << PMU_TDC0_SEL_VCAL_OFFS);
+	writel(reg, priv->control);
+
+	/* 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);
+
+	/*
+	 * FIXME: This looks really ugly. Can't we just remove it?
+	 * Poll the sensor for the first reading
+	 */
+	for (i = 0; i < 1000000; i++) {
+		reg = (readl_relaxed(priv->sensor) >> MVEBU_THERMAL_TEMP_OFFSET)
+			& MVEBU_THERMAL_TEMP_MASK;
+		if (reg)
+			break;
+	}
+	return;
+}
+
 static bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
@@ -118,6 +175,13 @@ static bool mvebu_is_valid(struct mvebu_thermal_priv *priv)
 		MVEBU_THERMAL_VALID_MASK;
 }
 
+static bool dove_is_valid(struct mvebu_thermal_priv *priv)
+{
+	unsigned long reg =
+		readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG);
+	return reg & PMU_TDC1_TEMP_VALID_MASK;
+}
+
 static int mvebu_get_temp(struct thermal_zone_device *thermal,
 			  unsigned long *temp)
 {
@@ -144,6 +208,9 @@ static int mvebu_get_temp(struct thermal_zone_device *thermal,
 	case MVEBU_THERMAL_SOC_VARIANT_ARMADA_370:
 		*temp = (228000UL - 723*reg);
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_DOVE:
+		*temp = ((2281638UL - (7298*reg)) / 10);
+		break;
 	default:
 		*temp = 0;
 		break;
@@ -169,6 +236,10 @@ static const struct of_device_id mvebu_thermal_id_table[] = {
 		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_ARMADA_370,
 	},
 	{
+		.compatible = "marvell,dove-thermal",
+		.data       = (void *) MVEBU_THERMAL_SOC_VARIANT_DOVE,
+	},
+	{
 		/* sentinel */
 	},
 };
@@ -218,6 +289,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
 		priv->is_valid = mvebu_is_valid;
 		priv->init_sensor = armada370_init_sensor;
 		break;
+	case MVEBU_THERMAL_SOC_VARIANT_DOVE:
+		priv->is_valid = dove_is_valid;
+		priv->init_sensor = dove_init_sensor;
 	default:
 		break;
 	}
@@ -261,6 +335,7 @@ static struct platform_driver mvebu_thermal_driver = {
 
 module_platform_driver(mvebu_thermal_driver);
 
+MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
 MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
 MODULE_AUTHOR("Ezequiel Garcia <ezequiel.garcia@free-electrons.com>");
 MODULE_DESCRIPTION("mvebu thermal driver");
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 14/16] ARM: mvebu: Add thermal support to Armada XP device tree
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This patch depends on the patch to support Armada XP
in mvebu_thermal driver:
'thermal: mvebu: Add support for Armada XP thermal sensor'

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 arch/arm/boot/dts/armada-xp.dtsi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/armada-xp.dtsi b/arch/arm/boot/dts/armada-xp.dtsi
index 1443949..d85fa6a 100644
--- a/arch/arm/boot/dts/armada-xp.dtsi
+++ b/arch/arm/boot/dts/armada-xp.dtsi
@@ -151,5 +151,11 @@
 			status = "disabled";
 		};
 
+		thermal@d00182b0 {
+			compatible = "marvell,armadaxp-thermal";
+			reg = <0xd00182b0 0x4
+			       0xd00184d0 0x4>;
+			status = "okay";
+		};
 	};
 };
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 14/16] ARM: mvebu: Add thermal support to Armada XP device tree
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This patch depends on the patch to support Armada XP
in mvebu_thermal driver:
'thermal: mvebu: Add support for Armada XP thermal sensor'

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 arch/arm/boot/dts/armada-xp.dtsi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/armada-xp.dtsi b/arch/arm/boot/dts/armada-xp.dtsi
index 1443949..d85fa6a 100644
--- a/arch/arm/boot/dts/armada-xp.dtsi
+++ b/arch/arm/boot/dts/armada-xp.dtsi
@@ -151,5 +151,11 @@
 			status = "disabled";
 		};
 
+		thermal at d00182b0 {
+			compatible = "marvell,armadaxp-thermal";
+			reg = <0xd00182b0 0x4
+			       0xd00184d0 0x4>;
+			status = "okay";
+		};
 	};
 };
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 15/16] ARM: mvebu: Add thermal support to Armada 370 device tree
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

This patch depends on the patch to add Armada 370 support
in the mvebu_thermal driver:
'thermal: mvebu: Add support for Armada 370 thermal sensor'

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 arch/arm/boot/dts/armada-370.dtsi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/armada-370.dtsi b/arch/arm/boot/dts/armada-370.dtsi
index 8188d13..5831994 100644
--- a/arch/arm/boot/dts/armada-370.dtsi
+++ b/arch/arm/boot/dts/armada-370.dtsi
@@ -153,5 +153,11 @@
 			clocks = <&coreclk 0>;
 		};
 
+		thermal@d0018300 {
+			compatible = "marvell,armada370-thermal";
+			reg = <0xd0018300 0x4
+			       0xd0018304 0x4>;
+			status = "okay";
+		};
 	};
 };
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 15/16] ARM: mvebu: Add thermal support to Armada 370 device tree
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

This patch depends on the patch to add Armada 370 support
in the mvebu_thermal driver:
'thermal: mvebu: Add support for Armada 370 thermal sensor'

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 arch/arm/boot/dts/armada-370.dtsi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/armada-370.dtsi b/arch/arm/boot/dts/armada-370.dtsi
index 8188d13..5831994 100644
--- a/arch/arm/boot/dts/armada-370.dtsi
+++ b/arch/arm/boot/dts/armada-370.dtsi
@@ -153,5 +153,11 @@
 			clocks = <&coreclk 0>;
 		};
 
+		thermal at d0018300 {
+			compatible = "marvell,armada370-thermal";
+			reg = <0xd0018300 0x4
+			       0xd0018304 0x4>;
+			status = "okay";
+		};
 	};
 };
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 16/16] ARM: configs: Update mvebu, dove and kirkwood defconfigs for thermal
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-20 22:36   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem, Ezequiel Garcia

The driver for Dove, Kirkwood and Armada XP/370 SoC
has been integrated in a single driver called mvebu-thermal.
Update the defconfig for each platform to reflect this.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
Please note that this change was done independentely from the
thermal driver patch in order to facilitate its merge by the
respective maintainers.

 arch/arm/configs/dove_defconfig     |    2 +-
 arch/arm/configs/kirkwood_defconfig |    2 +-
 arch/arm/configs/mvebu_defconfig    |    2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/configs/dove_defconfig b/arch/arm/configs/dove_defconfig
index 4364eff..2136442 100644
--- a/arch/arm/configs/dove_defconfig
+++ b/arch/arm/configs/dove_defconfig
@@ -76,7 +76,7 @@ CONFIG_SPI=y
 CONFIG_SPI_ORION=y
 # CONFIG_HWMON is not set
 CONFIG_THERMAL=y
-CONFIG_DOVE_THERMAL=y
+CONFIG_MVEBU_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig
index 8f0065b..081d39f 100644
--- a/arch/arm/configs/kirkwood_defconfig
+++ b/arch/arm/configs/kirkwood_defconfig
@@ -120,7 +120,7 @@ CONFIG_SPI_ORION=y
 CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 CONFIG_THERMAL=y
-CONFIG_KIRKWOOD_THERMAL=y
+CONFIG_MVEBU_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_ORION_WATCHDOG=y
 CONFIG_HID_DRAGONRISE=y
diff --git a/arch/arm/configs/mvebu_defconfig b/arch/arm/configs/mvebu_defconfig
index 2ec8119..f2ac593 100644
--- a/arch/arm/configs/mvebu_defconfig
+++ b/arch/arm/configs/mvebu_defconfig
@@ -49,6 +49,8 @@ CONFIG_MTD_M25P80=y
 CONFIG_SERIAL_8250_DW=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_SYSFS=y
+CONFIG_THERMAL=y
+CONFIG_MVEBU_THERMAL=y
 CONFIG_USB_SUPPORT=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 16/16] ARM: configs: Update mvebu, dove and kirkwood defconfigs for thermal
@ 2013-03-20 22:36   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-20 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

The driver for Dove, Kirkwood and Armada XP/370 SoC
has been integrated in a single driver called mvebu-thermal.
Update the defconfig for each platform to reflect this.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
Please note that this change was done independentely from the
thermal driver patch in order to facilitate its merge by the
respective maintainers.

 arch/arm/configs/dove_defconfig     |    2 +-
 arch/arm/configs/kirkwood_defconfig |    2 +-
 arch/arm/configs/mvebu_defconfig    |    2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/configs/dove_defconfig b/arch/arm/configs/dove_defconfig
index 4364eff..2136442 100644
--- a/arch/arm/configs/dove_defconfig
+++ b/arch/arm/configs/dove_defconfig
@@ -76,7 +76,7 @@ CONFIG_SPI=y
 CONFIG_SPI_ORION=y
 # CONFIG_HWMON is not set
 CONFIG_THERMAL=y
-CONFIG_DOVE_THERMAL=y
+CONFIG_MVEBU_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig
index 8f0065b..081d39f 100644
--- a/arch/arm/configs/kirkwood_defconfig
+++ b/arch/arm/configs/kirkwood_defconfig
@@ -120,7 +120,7 @@ CONFIG_SPI_ORION=y
 CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 CONFIG_THERMAL=y
-CONFIG_KIRKWOOD_THERMAL=y
+CONFIG_MVEBU_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_ORION_WATCHDOG=y
 CONFIG_HID_DRAGONRISE=y
diff --git a/arch/arm/configs/mvebu_defconfig b/arch/arm/configs/mvebu_defconfig
index 2ec8119..f2ac593 100644
--- a/arch/arm/configs/mvebu_defconfig
+++ b/arch/arm/configs/mvebu_defconfig
@@ -49,6 +49,8 @@ CONFIG_MTD_M25P80=y
 CONFIG_SERIAL_8250_DW=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_SYSFS=y
+CONFIG_THERMAL=y
+CONFIG_MVEBU_THERMAL=y
 CONFIG_USB_SUPPORT=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21  6:10     ` Andrew Lunn
  -1 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:10 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> Convert devm_request_and_ioremap() to the newly introduced
> devm_ioremap_resource() which provides more consistent error handling.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> index ef04e4e..089b43d 100644
> --- a/drivers/thermal/mvebu_thermal.c
> +++ b/drivers/thermal/mvebu_thermal.c
> @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
>  	if (!priv)
>  		return -ENOMEM;
>  
> -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->sensor) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> +	if (!priv->sensor)
>  		return -EADDRNOTAVAIL;
> -	}

Hi Ezequiel

It would be better to return priv->sensor, not a fixed error code.

   Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-21  6:10     ` Andrew Lunn
  0 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> Convert devm_request_and_ioremap() to the newly introduced
> devm_ioremap_resource() which provides more consistent error handling.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> index ef04e4e..089b43d 100644
> --- a/drivers/thermal/mvebu_thermal.c
> +++ b/drivers/thermal/mvebu_thermal.c
> @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
>  	if (!priv)
>  		return -ENOMEM;
>  
> -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->sensor) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> +	if (!priv->sensor)
>  		return -EADDRNOTAVAIL;
> -	}

Hi Ezequiel

It would be better to return priv->sensor, not a fixed error code.

   Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 13/16] thermal: mvebu: Add support for Marvell Dove SoC family
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21  6:23     ` Andrew Lunn
  -1 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:23 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem



> -	priv->control = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->control) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> -		return -EADDRNOTAVAIL;
> -	}


Hi Ezequiel

I've not looked too hard, but i don't see the equivalent of the above
in your new probe function.

   Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 13/16] thermal: mvebu: Add support for Marvell Dove SoC family
@ 2013-03-21  6:23     ` Andrew Lunn
  0 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:23 UTC (permalink / raw)
  To: linux-arm-kernel



> -	priv->control = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->control) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> -		return -EADDRNOTAVAIL;
> -	}


Hi Ezequiel

I've not looked too hard, but i don't see the equivalent of the above
in your new probe function.

   Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 13/16] thermal: mvebu: Add support for Marvell Dove SoC family
  2013-03-21  6:23     ` Andrew Lunn
@ 2013-03-21  6:26       ` Andrew Lunn
  -1 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:26 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Ezequiel Garcia, linux-arm-kernel, Zhang Rui, linux-pm,
	Thomas Petazzoni, Gregory Clement, Nobuhiro Iwamatsu,
	Jason Cooper, Florian Fainelli, Sebastian Hesselbarth,
	Lior Amsalem

On Thu, Mar 21, 2013 at 07:23:07AM +0100, Andrew Lunn wrote:
> 
> 
> > -	priv->control = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->control) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > -		return -EADDRNOTAVAIL;
> > -	}
> 
> 
> Hi Ezequiel
> 
> I've not looked too hard, but i don't see the equivalent of the above
> in your new probe function.

Upps, Sorry, found it. Does exists.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 13/16] thermal: mvebu: Add support for Marvell Dove SoC family
@ 2013-03-21  6:26       ` Andrew Lunn
  0 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 07:23:07AM +0100, Andrew Lunn wrote:
> 
> 
> > -	priv->control = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->control) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > -		return -EADDRNOTAVAIL;
> > -	}
> 
> 
> Hi Ezequiel
> 
> I've not looked too hard, but i don't see the equivalent of the above
> in your new probe function.

Upps, Sorry, found it. Does exists.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 00/16] Marvell EBU thermal sensor consolidation
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-21  6:45   ` Andrew Lunn
  -1 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:45 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> This patchset is my first attempt at adding basic thermal sensor
> support on Armada 370 and Armada XP.
> 
> Given Armada 370/XP and the other Marvell SoC with thermal support,
> namely Kirkwood and Dove, have fairly similar thermal devices it 
> made sense to integrate all of them into a single driver: mvebu-thermal.

Hi Ezequiel

I went this way to start with, merging Dove, Kirkwood and something
which nearly worked for 370. But then i looked at the code, at how
little is actually shared, and went back to separate drivers.

Kirkwood has no control registers, so needs a special case in the probe.
The bit location of the temperate value moves around in the register.
Each SoC needs its own initialization sequence.
Each SoC needs its own is_valid() function.
Each Soc needs its own formula to convert to milli centigrad.

I've never seen the datasheets for 370/XP, just a list of registers for
370. But i get the impression it has two temperate sensors, so should
export two values?

Also, kirkwood will never be built into the same kernel as
Dove/370/XP.  So we end up with "bloat" in the driver, or at least a
collection of #ifdefs.

In the end, i decided it was simpler and cleaner to just have separate
drivers. This is something which we should think about and discuss.

	 Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-21  6:45   ` Andrew Lunn
  0 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21  6:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> This patchset is my first attempt at adding basic thermal sensor
> support on Armada 370 and Armada XP.
> 
> Given Armada 370/XP and the other Marvell SoC with thermal support,
> namely Kirkwood and Dove, have fairly similar thermal devices it 
> made sense to integrate all of them into a single driver: mvebu-thermal.

Hi Ezequiel

I went this way to start with, merging Dove, Kirkwood and something
which nearly worked for 370. But then i looked at the code, at how
little is actually shared, and went back to separate drivers.

Kirkwood has no control registers, so needs a special case in the probe.
The bit location of the temperate value moves around in the register.
Each SoC needs its own initialization sequence.
Each SoC needs its own is_valid() function.
Each Soc needs its own formula to convert to milli centigrad.

I've never seen the datasheets for 370/XP, just a list of registers for
370. But i get the impression it has two temperate sensors, so should
export two values?

Also, kirkwood will never be built into the same kernel as
Dove/370/XP.  So we end up with "bloat" in the driver, or at least a
collection of #ifdefs.

In the end, i decided it was simpler and cleaner to just have separate
drivers. This is something which we should think about and discuss.

	 Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 00/16] Marvell EBU thermal sensor consolidation
  2013-03-21  6:45   ` Andrew Lunn
@ 2013-03-21  9:42     ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21  9:42 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Jason Cooper,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

Hi Andrew,

On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:
> On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> > This patchset is my first attempt at adding basic thermal sensor
> > support on Armada 370 and Armada XP.
> > 
> > Given Armada 370/XP and the other Marvell SoC with thermal support,
> > namely Kirkwood and Dove, have fairly similar thermal devices it 
> > made sense to integrate all of them into a single driver: mvebu-thermal.
> 
> 
> I went this way to start with, merging Dove, Kirkwood and something
> which nearly worked for 370. But then i looked at the code, at how
> little is actually shared, and went back to separate drivers.
> 
> Kirkwood has no control registers, so needs a special case in the probe.
> The bit location of the temperate value moves around in the register.
> Each SoC needs its own initialization sequence.
> Each SoC needs its own is_valid() function.
> Each Soc needs its own formula to convert to milli centigrad.
> 
> I've never seen the datasheets for 370/XP, just a list of registers for
> 370. But i get the impression it has two temperate sensors, so should
> export two values?
> 
> Also, kirkwood will never be built into the same kernel as
> Dove/370/XP.  So we end up with "bloat" in the driver, or at least a
> collection of #ifdefs.
> 
> In the end, i decided it was simpler and cleaner to just have separate
> drivers. This is something which we should think about and discuss.
> 

Thanks for your comments.

I had the same concerns about a single driver against many;
after trying this approach I was convinced by the diffstat:

13 files changed, 395 insertions(+), 393 deletions(-)

So we have almost no LoC increase and two new SoCs are supported.

The alternative would mean to have one driver for Armada 370
and yet another one for Armada XP, with some common boilerplate
in each driver and only the differences you mention: a different
initialization and a different conversion formula.
The initialization is solved my means of a function pointer,
and the conversion is just a switch.

FWIW, the is_valid() is actually the same on Kirkwood and 370.

I debated myself a lot before unifying the drivers: in the end
it seemed a proper solution: less maintainance, less configuration
options, happier hackers :)

What do you think?
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-21  9:42     ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21  9:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:
> On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> > This patchset is my first attempt at adding basic thermal sensor
> > support on Armada 370 and Armada XP.
> > 
> > Given Armada 370/XP and the other Marvell SoC with thermal support,
> > namely Kirkwood and Dove, have fairly similar thermal devices it 
> > made sense to integrate all of them into a single driver: mvebu-thermal.
> 
> 
> I went this way to start with, merging Dove, Kirkwood and something
> which nearly worked for 370. But then i looked at the code, at how
> little is actually shared, and went back to separate drivers.
> 
> Kirkwood has no control registers, so needs a special case in the probe.
> The bit location of the temperate value moves around in the register.
> Each SoC needs its own initialization sequence.
> Each SoC needs its own is_valid() function.
> Each Soc needs its own formula to convert to milli centigrad.
> 
> I've never seen the datasheets for 370/XP, just a list of registers for
> 370. But i get the impression it has two temperate sensors, so should
> export two values?
> 
> Also, kirkwood will never be built into the same kernel as
> Dove/370/XP.  So we end up with "bloat" in the driver, or at least a
> collection of #ifdefs.
> 
> In the end, i decided it was simpler and cleaner to just have separate
> drivers. This is something which we should think about and discuss.
> 

Thanks for your comments.

I had the same concerns about a single driver against many;
after trying this approach I was convinced by the diffstat:

13 files changed, 395 insertions(+), 393 deletions(-)

So we have almost no LoC increase and two new SoCs are supported.

The alternative would mean to have one driver for Armada 370
and yet another one for Armada XP, with some common boilerplate
in each driver and only the differences you mention: a different
initialization and a different conversion formula.
The initialization is solved my means of a function pointer,
and the conversion is just a switch.

FWIW, the is_valid() is actually the same on Kirkwood and 370.

I debated myself a lot before unifying the drivers: in the end
it seemed a proper solution: less maintainance, less configuration
options, happier hackers :)

What do you think?
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-21  6:10     ` Andrew Lunn
@ 2013-03-21  9:43       ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21  9:43 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Jason Cooper,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Thu, Mar 21, 2013 at 07:10:24AM +0100, Andrew Lunn wrote:
> On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> > Convert devm_request_and_ioremap() to the newly introduced
> > devm_ioremap_resource() which provides more consistent error handling.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/thermal/mvebu_thermal.c |    6 ++----
> >  1 files changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > index ef04e4e..089b43d 100644
> > --- a/drivers/thermal/mvebu_thermal.c
> > +++ b/drivers/thermal/mvebu_thermal.c
> > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> >  	if (!priv)
> >  		return -ENOMEM;
> >  
> > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->sensor) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > +	if (!priv->sensor)
> >  		return -EADDRNOTAVAIL;
> > -	}
> 
> 
> It would be better to return priv->sensor, not a fixed error code.
> 

Good catch! I missed that.

Thanks,
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-21  9:43       ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21  9:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 07:10:24AM +0100, Andrew Lunn wrote:
> On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> > Convert devm_request_and_ioremap() to the newly introduced
> > devm_ioremap_resource() which provides more consistent error handling.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/thermal/mvebu_thermal.c |    6 ++----
> >  1 files changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > index ef04e4e..089b43d 100644
> > --- a/drivers/thermal/mvebu_thermal.c
> > +++ b/drivers/thermal/mvebu_thermal.c
> > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> >  	if (!priv)
> >  		return -ENOMEM;
> >  
> > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->sensor) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > +	if (!priv->sensor)
> >  		return -EADDRNOTAVAIL;
> > -	}
> 
> 
> It would be better to return priv->sensor, not a fixed error code.
> 

Good catch! I missed that.

Thanks,
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-21  9:43       ` Ezequiel Garcia
@ 2013-03-21 10:08         ` Andrew Lunn
  -1 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21 10:08 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Andrew Lunn, linux-arm-kernel, Zhang Rui, linux-pm,
	Thomas Petazzoni, Gregory Clement, Nobuhiro Iwamatsu,
	Jason Cooper, Florian Fainelli, Sebastian Hesselbarth,
	Lior Amsalem

On Thu, Mar 21, 2013 at 06:43:26AM -0300, Ezequiel Garcia wrote:
> On Thu, Mar 21, 2013 at 07:10:24AM +0100, Andrew Lunn wrote:
> > On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> > > Convert devm_request_and_ioremap() to the newly introduced
> > > devm_ioremap_resource() which provides more consistent error handling.
> > > 
> > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > ---
> > >  drivers/thermal/mvebu_thermal.c |    6 ++----
> > >  1 files changed, 2 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > > index ef04e4e..089b43d 100644
> > > --- a/drivers/thermal/mvebu_thermal.c
> > > +++ b/drivers/thermal/mvebu_thermal.c
> > > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> > >  	if (!priv)
> > >  		return -ENOMEM;
> > >  
> > > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > > -	if (!priv->sensor) {
> > > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > > +	if (!priv->sensor)
> > >  		return -EADDRNOTAVAIL;
> > > -	}
> > 
> > 
> > It would be better to return priv->sensor, not a fixed error code.
> > 
> 
> Good catch! I missed that.

And the same where the priv->control is introduced.

    Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-21 10:08         ` Andrew Lunn
  0 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21 10:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 06:43:26AM -0300, Ezequiel Garcia wrote:
> On Thu, Mar 21, 2013 at 07:10:24AM +0100, Andrew Lunn wrote:
> > On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> > > Convert devm_request_and_ioremap() to the newly introduced
> > > devm_ioremap_resource() which provides more consistent error handling.
> > > 
> > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > ---
> > >  drivers/thermal/mvebu_thermal.c |    6 ++----
> > >  1 files changed, 2 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > > index ef04e4e..089b43d 100644
> > > --- a/drivers/thermal/mvebu_thermal.c
> > > +++ b/drivers/thermal/mvebu_thermal.c
> > > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> > >  	if (!priv)
> > >  		return -ENOMEM;
> > >  
> > > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > > -	if (!priv->sensor) {
> > > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > > +	if (!priv->sensor)
> > >  		return -EADDRNOTAVAIL;
> > > -	}
> > 
> > 
> > It would be better to return priv->sensor, not a fixed error code.
> > 
> 
> Good catch! I missed that.

And the same where the priv->control is introduced.

    Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 00/16] Marvell EBU thermal sensor consolidation
  2013-03-20 22:36 ` Ezequiel Garcia
@ 2013-03-21 12:26   ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 12:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Zhang Rui, linux-pm, Thomas Petazzoni, Gregory Clement,
	Nobuhiro Iwamatsu, Andrew Lunn, Jason Cooper, Florian Fainelli,
	Sebastian Hesselbarth, Lior Amsalem

On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> This patchset is my first attempt at adding basic thermal sensor
> support on Armada 370 and Armada XP.
> 
> Given Armada 370/XP and the other Marvell SoC with thermal support,
> namely Kirkwood and Dove, have fairly similar thermal devices it 
> made sense to integrate all of them into a single driver: mvebu-thermal.
> 
> The patches have been carefully splitted to make the changeset
> as less invasive as possible. These changes can be divided in five stages:
> 
>   1. Rename 'kirkwood' driver to 'mvebu'
>   2. Some fixes inherited from kirkwood driver applied to new mvebu driver
>   3. Prepare mvebu driver to support multiple SoC
>   4. Add thermal support for each Marvell SoC on top of mvebu driver
>   5. Add device tree nodes for Armada 370 and Armada XP
>   6. Fix defconfigs for all the platforms involved
> 
> Testing have been done on the following boards:
> 
> Kirkwood:   Plat'home Openblocks A6
> Armada 370: Globalscale Mirabox and Marvell Armada 370 RD
> Armada XP:  Plat'home Openblocks AX3 and Marvell Armada XP DB-MV784MP-GP
> 
> Dove is *not* tested due to lack of hardware.
> 

If anyone wants to test this patchset, I've prepared a public branch:

https://github.com/MISL-EBU-System-SW/mainline-public/tree/mvebu-thermal-v1

This branch is based on v3.9-rc1, with this patches:
  arm: mvebu: Reduce reg-io-width with UARTs
  ARM: Kirkwood: Add support thermal sensor for 88F6282 and 88F6283
  Dove: Thermal: Add DT node and enable in defconfig

Thanks a lot,
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-21 12:26   ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 12:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> This patchset is my first attempt at adding basic thermal sensor
> support on Armada 370 and Armada XP.
> 
> Given Armada 370/XP and the other Marvell SoC with thermal support,
> namely Kirkwood and Dove, have fairly similar thermal devices it 
> made sense to integrate all of them into a single driver: mvebu-thermal.
> 
> The patches have been carefully splitted to make the changeset
> as less invasive as possible. These changes can be divided in five stages:
> 
>   1. Rename 'kirkwood' driver to 'mvebu'
>   2. Some fixes inherited from kirkwood driver applied to new mvebu driver
>   3. Prepare mvebu driver to support multiple SoC
>   4. Add thermal support for each Marvell SoC on top of mvebu driver
>   5. Add device tree nodes for Armada 370 and Armada XP
>   6. Fix defconfigs for all the platforms involved
> 
> Testing have been done on the following boards:
> 
> Kirkwood:   Plat'home Openblocks A6
> Armada 370: Globalscale Mirabox and Marvell Armada 370 RD
> Armada XP:  Plat'home Openblocks AX3 and Marvell Armada XP DB-MV784MP-GP
> 
> Dove is *not* tested due to lack of hardware.
> 

If anyone wants to test this patchset, I've prepared a public branch:

https://github.com/MISL-EBU-System-SW/mainline-public/tree/mvebu-thermal-v1

This branch is based on v3.9-rc1, with this patches:
  arm: mvebu: Reduce reg-io-width with UARTs
  ARM: Kirkwood: Add support thermal sensor for 88F6282 and 88F6283
  Dove: Thermal: Add DT node and enable in defconfig

Thanks a lot,
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 00/16] Marvell EBU thermal sensor consolidation
  2013-03-21  6:45   ` Andrew Lunn
@ 2013-03-21 12:35     ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 12:35 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Jason Cooper,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:
> On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> > This patchset is my first attempt at adding basic thermal sensor
> > support on Armada 370 and Armada XP.
> > 
> > Given Armada 370/XP and the other Marvell SoC with thermal support,
> > namely Kirkwood and Dove, have fairly similar thermal devices it 
> > made sense to integrate all of them into a single driver: mvebu-thermal.
> 
> I went this way to start with, merging Dove, Kirkwood and something
> which nearly worked for 370. But then i looked at the code, at how
> little is actually shared, and went back to separate drivers.
> 
> Kirkwood has no control registers, so needs a special case in the probe.
> The bit location of the temperate value moves around in the register.
> Each SoC needs its own initialization sequence.
> Each SoC needs its own is_valid() function.
> Each Soc needs its own formula to convert to milli centigrad.
> 
> I've never seen the datasheets for 370/XP, just a list of registers for
> 370. But i get the impression it has two temperate sensors, so should
> export two values?
> 

Why do you think it has two sensors?

-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-21 12:35     ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:
> On Wed, Mar 20, 2013 at 07:36:21PM -0300, Ezequiel Garcia wrote:
> > This patchset is my first attempt at adding basic thermal sensor
> > support on Armada 370 and Armada XP.
> > 
> > Given Armada 370/XP and the other Marvell SoC with thermal support,
> > namely Kirkwood and Dove, have fairly similar thermal devices it 
> > made sense to integrate all of them into a single driver: mvebu-thermal.
> 
> I went this way to start with, merging Dove, Kirkwood and something
> which nearly worked for 370. But then i looked at the code, at how
> little is actually shared, and went back to separate drivers.
> 
> Kirkwood has no control registers, so needs a special case in the probe.
> The bit location of the temperate value moves around in the register.
> Each SoC needs its own initialization sequence.
> Each SoC needs its own is_valid() function.
> Each Soc needs its own formula to convert to milli centigrad.
> 
> I've never seen the datasheets for 370/XP, just a list of registers for
> 370. But i get the impression it has two temperate sensors, so should
> export two values?
> 

Why do you think it has two sensors?

-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 00/16] Marvell EBU thermal sensor consolidation
  2013-03-21 12:35     ` Ezequiel Garcia
@ 2013-03-21 13:36       ` Andrew Lunn
  -1 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21 13:36 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Andrew Lunn, linux-arm-kernel, Zhang Rui, linux-pm,
	Thomas Petazzoni, Gregory Clement, Nobuhiro Iwamatsu,
	Jason Cooper, Florian Fainelli, Sebastian Hesselbarth,
	Lior Amsalem

> Why do you think it has two sensors?

The register set i've seen talks of a junction temperate and a
"thermal manager current temperature". The thermal manager temperature
went up as i loaded the CPU and dropped down again as it was idle and
cooled. I've no idea if these are two different sensors, or one is an
averaged value of the other, etc. I would hope the datasheet gives a
description.....

     Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-21 13:36       ` Andrew Lunn
  0 siblings, 0 replies; 86+ messages in thread
From: Andrew Lunn @ 2013-03-21 13:36 UTC (permalink / raw)
  To: linux-arm-kernel

> Why do you think it has two sensors?

The register set i've seen talks of a junction temperate and a
"thermal manager current temperature". The thermal manager temperature
went up as i loaded the CPU and dropped down again as it was idle and
cooled. I've no idea if these are two different sensors, or one is an
averaged value of the other, etc. I would hope the datasheet gives a
description.....

     Andrew

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 15/16] ARM: mvebu: Add thermal support to Armada 370 device tree
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21 14:03     ` Sergei Shtylyov
  -1 siblings, 0 replies; 86+ messages in thread
From: Sergei Shtylyov @ 2013-03-21 14:03 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Thomas Petazzoni, Andrew Lunn, Jason Cooper,
	Nobuhiro Iwamatsu, linux-pm, Lior Amsalem, Gregory Clement,
	Zhang Rui, Florian Fainelli, Sebastian Hesselbarth

Hello.

On 21-03-2013 2:36, Ezequiel Garcia wrote:

> This patch depends on the patch to add Armada 370 support
> in the mvebu_thermal driver:
> 'thermal: mvebu: Add support for Armada 370 thermal sensor'

   Sch comments should follow the --- tear line, not precede it.

> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>   arch/arm/boot/dts/armada-370.dtsi |    6 ++++++
>   1 files changed, 6 insertions(+), 0 deletions(-)

WBR, Sergei


^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 15/16] ARM: mvebu: Add thermal support to Armada 370 device tree
@ 2013-03-21 14:03     ` Sergei Shtylyov
  0 siblings, 0 replies; 86+ messages in thread
From: Sergei Shtylyov @ 2013-03-21 14:03 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 21-03-2013 2:36, Ezequiel Garcia wrote:

> This patch depends on the patch to add Armada 370 support
> in the mvebu_thermal driver:
> 'thermal: mvebu: Add support for Armada 370 thermal sensor'

   Sch comments should follow the --- tear line, not precede it.

> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>   arch/arm/boot/dts/armada-370.dtsi |    6 ++++++
>   1 files changed, 6 insertions(+), 0 deletions(-)

WBR, Sergei

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21 14:04     ` Sergei Shtylyov
  -1 siblings, 0 replies; 86+ messages in thread
From: Sergei Shtylyov @ 2013-03-21 14:04 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Thomas Petazzoni, Andrew Lunn, Jason Cooper,
	Nobuhiro Iwamatsu, linux-pm, Lior Amsalem, Gregory Clement,
	Zhang Rui, Florian Fainelli, Sebastian Hesselbarth

Hello.

On 21-03-2013 2:36, Ezequiel Garcia wrote:

> Convert devm_request_and_ioremap() to the newly introduced
> devm_ioremap_resource() which provides more consistent error handling.

> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>   drivers/thermal/mvebu_thermal.c |    6 ++----
>   1 files changed, 2 insertions(+), 4 deletions(-)

> diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> index ef04e4e..089b43d 100644
> --- a/drivers/thermal/mvebu_thermal.c
> +++ b/drivers/thermal/mvebu_thermal.c
> @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
>   	if (!priv)
>   		return -ENOMEM;
>
> -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->sensor) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> +	if (!priv->sensor)

    devm_ioremap_resource() returns error code, not NULL.

WBR, Sergei


^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-21 14:04     ` Sergei Shtylyov
  0 siblings, 0 replies; 86+ messages in thread
From: Sergei Shtylyov @ 2013-03-21 14:04 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 21-03-2013 2:36, Ezequiel Garcia wrote:

> Convert devm_request_and_ioremap() to the newly introduced
> devm_ioremap_resource() which provides more consistent error handling.

> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>   drivers/thermal/mvebu_thermal.c |    6 ++----
>   1 files changed, 2 insertions(+), 4 deletions(-)

> diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> index ef04e4e..089b43d 100644
> --- a/drivers/thermal/mvebu_thermal.c
> +++ b/drivers/thermal/mvebu_thermal.c
> @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
>   	if (!priv)
>   		return -ENOMEM;
>
> -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->sensor) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> +	if (!priv->sensor)

    devm_ioremap_resource() returns error code, not NULL.

WBR, Sergei

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21 14:35     ` Jason Cooper
  -1 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 14:35 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

Ezequiel,

On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> The correct value is obtain by first shifting the register by the offset,
> later applying the valid mask and finally invert the result.
> This check was lacking an extra parenthesis to be strictly correct.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

For the next version of this series, could you please put this fix first
in the series?  In this state, it can't be applied to v3.9-rcX, nor
-stable.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
@ 2013-03-21 14:35     ` Jason Cooper
  0 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

Ezequiel,

On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> The correct value is obtain by first shifting the register by the offset,
> later applying the valid mask and finally invert the result.
> This check was lacking an extra parenthesis to be strictly correct.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

For the next version of this series, could you please put this fix first
in the series?  In this state, it can't be applied to v3.9-rcX, nor
-stable.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21 14:41     ` Jason Cooper
  -1 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 14:41 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Wed, Mar 20, 2013 at 07:36:29PM -0300, Ezequiel Garcia wrote:
> The temperature formula was taken from the Armada 510 datasheet.
> This is wrong because the Kirkwood SoC thermal sensor has
> different coefficients.
> 
> Fix it using values from 88F682/88F683 Kirkwood datasheet.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    7 +------
>  1 files changed, 1 insertions(+), 6 deletions(-)

This is also a fix which should go at the beginning of the series.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
@ 2013-03-21 14:41     ` Jason Cooper
  0 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 14:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Mar 20, 2013 at 07:36:29PM -0300, Ezequiel Garcia wrote:
> The temperature formula was taken from the Armada 510 datasheet.
> This is wrong because the Kirkwood SoC thermal sensor has
> different coefficients.
> 
> Fix it using values from 88F682/88F683 Kirkwood datasheet.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    7 +------
>  1 files changed, 1 insertions(+), 6 deletions(-)

This is also a fix which should go at the beginning of the series.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
  2013-03-21 14:35     ` Jason Cooper
@ 2013-03-21 15:16       ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 15:16 UTC (permalink / raw)
  To: Jason Cooper
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

Hi Jason,

On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > The correct value is obtain by first shifting the register by the offset,
> > later applying the valid mask and finally invert the result.
> > This check was lacking an extra parenthesis to be strictly correct.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/thermal/mvebu_thermal.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> For the next version of this series, could you please put this fix first
> in the series?  In this state, it can't be applied to v3.9-rcX, nor
> -stable.
> 

Given we're still discussing the aproach of this patchset.
I think I prefer to send the fixes now, not as part of the
current series but as independent patches.

What do you think?
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
@ 2013-03-21 15:16       ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jason,

On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > The correct value is obtain by first shifting the register by the offset,
> > later applying the valid mask and finally invert the result.
> > This check was lacking an extra parenthesis to be strictly correct.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/thermal/mvebu_thermal.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> For the next version of this series, could you please put this fix first
> in the series?  In this state, it can't be applied to v3.9-rcX, nor
> -stable.
> 

Given we're still discussing the aproach of this patchset.
I think I prefer to send the fixes now, not as part of the
current series but as independent patches.

What do you think?
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-21 14:04     ` Sergei Shtylyov
@ 2013-03-21 15:17       ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 15:17 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-arm-kernel, Thomas Petazzoni, Andrew Lunn, Jason Cooper,
	Nobuhiro Iwamatsu, linux-pm, Lior Amsalem, Gregory Clement,
	Zhang Rui, Florian Fainelli, Sebastian Hesselbarth

Hi Sergei,

On Thu, Mar 21, 2013 at 06:04:58PM +0400, Sergei Shtylyov wrote:
> On 21-03-2013 2:36, Ezequiel Garcia wrote:
> 
> > Convert devm_request_and_ioremap() to the newly introduced
> > devm_ioremap_resource() which provides more consistent error handling.
> 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >   drivers/thermal/mvebu_thermal.c |    6 ++----
> >   1 files changed, 2 insertions(+), 4 deletions(-)
> 
> > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > index ef04e4e..089b43d 100644
> > --- a/drivers/thermal/mvebu_thermal.c
> > +++ b/drivers/thermal/mvebu_thermal.c
> > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> >   	if (!priv)
> >   		return -ENOMEM;
> >
> > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->sensor) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > +	if (!priv->sensor)
> 
>     devm_ioremap_resource() returns error code, not NULL.
> 

Yes, you're right. Andrew has already pointed this out
and I'll fix it in the next round.

Thanks for the review!
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-21 15:17       ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 15:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Thu, Mar 21, 2013 at 06:04:58PM +0400, Sergei Shtylyov wrote:
> On 21-03-2013 2:36, Ezequiel Garcia wrote:
> 
> > Convert devm_request_and_ioremap() to the newly introduced
> > devm_ioremap_resource() which provides more consistent error handling.
> 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >   drivers/thermal/mvebu_thermal.c |    6 ++----
> >   1 files changed, 2 insertions(+), 4 deletions(-)
> 
> > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > index ef04e4e..089b43d 100644
> > --- a/drivers/thermal/mvebu_thermal.c
> > +++ b/drivers/thermal/mvebu_thermal.c
> > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> >   	if (!priv)
> >   		return -ENOMEM;
> >
> > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->sensor) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > +	if (!priv->sensor)
> 
>     devm_ioremap_resource() returns error code, not NULL.
> 

Yes, you're right. Andrew has already pointed this out
and I'll fix it in the next round.

Thanks for the review!
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 15/16] ARM: mvebu: Add thermal support to Armada 370 device tree
  2013-03-21 14:03     ` Sergei Shtylyov
@ 2013-03-21 15:18       ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 15:18 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-arm-kernel, Thomas Petazzoni, Andrew Lunn, Jason Cooper,
	Nobuhiro Iwamatsu, linux-pm, Lior Amsalem, Gregory Clement,
	Zhang Rui, Florian Fainelli, Sebastian Hesselbarth

Hi Sergei,

On Thu, Mar 21, 2013 at 06:03:31PM +0400, Sergei Shtylyov wrote:
> On 21-03-2013 2:36, Ezequiel Garcia wrote:
> 
> > This patch depends on the patch to add Armada 370 support
> > in the mvebu_thermal driver:
> > 'thermal: mvebu: Add support for Armada 370 thermal sensor'
> 
>    Sch comments should follow the --- tear line, not precede it.
> 

Ouch. Yes, that was the original intention!

Thanks,
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 15/16] ARM: mvebu: Add thermal support to Armada 370 device tree
@ 2013-03-21 15:18       ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 15:18 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Thu, Mar 21, 2013 at 06:03:31PM +0400, Sergei Shtylyov wrote:
> On 21-03-2013 2:36, Ezequiel Garcia wrote:
> 
> > This patch depends on the patch to add Armada 370 support
> > in the mvebu_thermal driver:
> > 'thermal: mvebu: Add support for Armada 370 thermal sensor'
> 
>    Sch comments should follow the --- tear line, not precede it.
> 

Ouch. Yes, that was the original intention!

Thanks,
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
  2013-03-21 15:16       ` Ezequiel Garcia
@ 2013-03-21 15:24         ` Jason Cooper
  -1 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 15:24 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Thu, Mar 21, 2013 at 12:16:10PM -0300, Ezequiel Garcia wrote:
> Hi Jason,
> 
> On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> > On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > > The correct value is obtain by first shifting the register by the offset,
> > > later applying the valid mask and finally invert the result.
> > > This check was lacking an extra parenthesis to be strictly correct.
> > > 
> > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > ---
> > >  drivers/thermal/mvebu_thermal.c |    4 ++--
> > >  1 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > For the next version of this series, could you please put this fix first
> > in the series?  In this state, it can't be applied to v3.9-rcX, nor
> > -stable.
> > 
> 
> Given we're still discussing the aproach of this patchset.
> I think I prefer to send the fixes now, not as part of the
> current series but as independent patches.
> 
> What do you think?

I agree.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
@ 2013-03-21 15:24         ` Jason Cooper
  0 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 15:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 12:16:10PM -0300, Ezequiel Garcia wrote:
> Hi Jason,
> 
> On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> > On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > > The correct value is obtain by first shifting the register by the offset,
> > > later applying the valid mask and finally invert the result.
> > > This check was lacking an extra parenthesis to be strictly correct.
> > > 
> > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > ---
> > >  drivers/thermal/mvebu_thermal.c |    4 ++--
> > >  1 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > For the next version of this series, could you please put this fix first
> > in the series?  In this state, it can't be applied to v3.9-rcX, nor
> > -stable.
> > 
> 
> Given we're still discussing the aproach of this patchset.
> I think I prefer to send the fixes now, not as part of the
> current series but as independent patches.
> 
> What do you think?

I agree.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 00/16] Marvell EBU thermal sensor consolidation
  2013-03-21  6:45   ` Andrew Lunn
@ 2013-03-21 17:32     ` Jason Gunthorpe
  -1 siblings, 0 replies; 86+ messages in thread
From: Jason Gunthorpe @ 2013-03-21 17:32 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Ezequiel Garcia, Thomas Petazzoni, Jason Cooper,
	Nobuhiro Iwamatsu, linux-pm, Lior Amsalem, Gregory Clement,
	Zhang Rui, Florian Fainelli, linux-arm-kernel,
	Sebastian Hesselbarth

On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:

> In the end, i decided it was simpler and cleaner to just have separate
> drivers. This is something which we should think about and discuss.

When I looked through the merge'd driver I thought the shared code
really had little to do with Marvell, it was mostly boilerplate that
would be common to any memory mapped temperature sensor - so maybe the
drivers should be kept apart and the boiler plate could be factored?

 thermal_platform_mmio_init(pdev,&ops);

Where ops has the is_valid, init_sensor, get_sensor functions

Or something?

...

BTW, Ezequiel your driver is probably a bit smaller if you do

struct mvebu_ops {
	/* Initialize the sensor (optional) */
	void (*init_sensor)(struct mvebu_thermal_priv *);

	/* Test for a valid sensor value (optional) */
	bool (*is_valid)(struct mvebu_thermal_priv *);
};

static const struct mvebu_ops kirkwood_ops = {..};

static const struct of_device_id mvebu_thermal_id_table[] = {
	{
		.compatible = "marvell,kirkwood-thermal",
		.data       = &kirkwood_ops,
	},

And drop the switch statement and the MVEBU_THERMAL_SOC_* constants..

Cheers,
Jason

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-21 17:32     ` Jason Gunthorpe
  0 siblings, 0 replies; 86+ messages in thread
From: Jason Gunthorpe @ 2013-03-21 17:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:

> In the end, i decided it was simpler and cleaner to just have separate
> drivers. This is something which we should think about and discuss.

When I looked through the merge'd driver I thought the shared code
really had little to do with Marvell, it was mostly boilerplate that
would be common to any memory mapped temperature sensor - so maybe the
drivers should be kept apart and the boiler plate could be factored?

 thermal_platform_mmio_init(pdev,&ops);

Where ops has the is_valid, init_sensor, get_sensor functions

Or something?

...

BTW, Ezequiel your driver is probably a bit smaller if you do

struct mvebu_ops {
	/* Initialize the sensor (optional) */
	void (*init_sensor)(struct mvebu_thermal_priv *);

	/* Test for a valid sensor value (optional) */
	bool (*is_valid)(struct mvebu_thermal_priv *);
};

static const struct mvebu_ops kirkwood_ops = {..};

static const struct of_device_id mvebu_thermal_id_table[] = {
	{
		.compatible = "marvell,kirkwood-thermal",
		.data       = &kirkwood_ops,
	},

And drop the switch statement and the MVEBU_THERMAL_SOC_* constants..

Cheers,
Jason

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21 19:17     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King - ARM Linux @ 2013-03-21 19:17 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Thomas Petazzoni, Andrew Lunn, Jason Cooper, Nobuhiro Iwamatsu,
	linux-pm, Lior Amsalem, Gregory Clement, Zhang Rui,
	Florian Fainelli, linux-arm-kernel, Sebastian Hesselbarth

On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> Convert devm_request_and_ioremap() to the newly introduced
> devm_ioremap_resource() which provides more consistent error handling.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> index ef04e4e..089b43d 100644
> --- a/drivers/thermal/mvebu_thermal.c
> +++ b/drivers/thermal/mvebu_thermal.c
> @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
>  	if (!priv)
>  		return -ENOMEM;
>  
> -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->sensor) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> +	if (!priv->sensor)
>  		return -EADDRNOTAVAIL;

NAK.  It pays to understand the interface that you're using.  In this
case, it *doesn't* return NULL on error, so you'll never reach
-EADDRNOTAVAIL.  Please look this function up in lib/devres.c and
understand its API.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-21 19:17     ` Russell King - ARM Linux
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King - ARM Linux @ 2013-03-21 19:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> Convert devm_request_and_ioremap() to the newly introduced
> devm_ioremap_resource() which provides more consistent error handling.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/thermal/mvebu_thermal.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> index ef04e4e..089b43d 100644
> --- a/drivers/thermal/mvebu_thermal.c
> +++ b/drivers/thermal/mvebu_thermal.c
> @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
>  	if (!priv)
>  		return -ENOMEM;
>  
> -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> -	if (!priv->sensor) {
> -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> +	if (!priv->sensor)
>  		return -EADDRNOTAVAIL;

NAK.  It pays to understand the interface that you're using.  In this
case, it *doesn't* return NULL on error, so you'll never reach
-EADDRNOTAVAIL.  Please look this function up in lib/devres.c and
understand its API.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
  2013-03-20 22:36   ` Ezequiel Garcia
@ 2013-03-21 19:20     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 86+ messages in thread
From: Russell King - ARM Linux @ 2013-03-21 19:20 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Thomas Petazzoni, Andrew Lunn, Jason Cooper, Nobuhiro Iwamatsu,
	linux-pm, Lior Amsalem, Gregory Clement, Zhang Rui,
	Florian Fainelli, linux-arm-kernel, Sebastian Hesselbarth

On Wed, Mar 20, 2013 at 07:36:29PM -0300, Ezequiel Garcia wrote:
> The temperature formula was taken from the Armada 510 datasheet.
> This is wrong because the Kirkwood SoC thermal sensor has
> different coefficients.
> 
> Fix it using values from 88F682/88F683 Kirkwood datasheet.

Err, hang on.  You've changed this from being a Kirkwood specific
driver to being a "mvebu" driver, which I had understood was being
done to cover all Kirkwood, Dove, etc SoCs.

If that's the case, then this change is wrong because you break it
for Dove.

If the coefficients are different between Kirkwood and Dove, then
it needs to be adapted at run time depending on whether it's running
on Kirkwood or Dove - not just having the coefficients changed at
compile time to suit a different set of platforms.

If it's worth making a change, do it *properly*.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
@ 2013-03-21 19:20     ` Russell King - ARM Linux
  0 siblings, 0 replies; 86+ messages in thread
From: Russell King - ARM Linux @ 2013-03-21 19:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Mar 20, 2013 at 07:36:29PM -0300, Ezequiel Garcia wrote:
> The temperature formula was taken from the Armada 510 datasheet.
> This is wrong because the Kirkwood SoC thermal sensor has
> different coefficients.
> 
> Fix it using values from 88F682/88F683 Kirkwood datasheet.

Err, hang on.  You've changed this from being a Kirkwood specific
driver to being a "mvebu" driver, which I had understood was being
done to cover all Kirkwood, Dove, etc SoCs.

If that's the case, then this change is wrong because you break it
for Dove.

If the coefficients are different between Kirkwood and Dove, then
it needs to be adapted at run time depending on whether it's running
on Kirkwood or Dove - not just having the coefficients changed at
compile time to suit a different set of platforms.

If it's worth making a change, do it *properly*.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
  2013-03-21 15:24         ` Jason Cooper
@ 2013-03-21 19:57           ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 19:57 UTC (permalink / raw)
  To: Jason Cooper
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Thu, Mar 21, 2013 at 11:24:00AM -0400, Jason Cooper wrote:
> On Thu, Mar 21, 2013 at 12:16:10PM -0300, Ezequiel Garcia wrote:
> > Hi Jason,
> > 
> > On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> > > On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > > > The correct value is obtain by first shifting the register by the offset,
> > > > later applying the valid mask and finally invert the result.
> > > > This check was lacking an extra parenthesis to be strictly correct.
> > > > 
> > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > > ---
> > > >  drivers/thermal/mvebu_thermal.c |    4 ++--
> > > >  1 files changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > For the next version of this series, could you please put this fix first
> > > in the series?  In this state, it can't be applied to v3.9-rcX, nor
> > > -stable.
> > > 
> > 
> > Given we're still discussing the aproach of this patchset.
> > I think I prefer to send the fixes now, not as part of the
> > current series but as independent patches.
> > 
> > What do you think?
> 
> I agree.
> 

I have a question about this though: Who should pick patches for
drivers/thermal/{dove,kirkwood,mvebu} ? You or Zhang?

-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
@ 2013-03-21 19:57           ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 19:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 11:24:00AM -0400, Jason Cooper wrote:
> On Thu, Mar 21, 2013 at 12:16:10PM -0300, Ezequiel Garcia wrote:
> > Hi Jason,
> > 
> > On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> > > On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > > > The correct value is obtain by first shifting the register by the offset,
> > > > later applying the valid mask and finally invert the result.
> > > > This check was lacking an extra parenthesis to be strictly correct.
> > > > 
> > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > > ---
> > > >  drivers/thermal/mvebu_thermal.c |    4 ++--
> > > >  1 files changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > For the next version of this series, could you please put this fix first
> > > in the series?  In this state, it can't be applied to v3.9-rcX, nor
> > > -stable.
> > > 
> > 
> > Given we're still discussing the aproach of this patchset.
> > I think I prefer to send the fixes now, not as part of the
> > current series but as independent patches.
> > 
> > What do you think?
> 
> I agree.
> 

I have a question about this though: Who should pick patches for
drivers/thermal/{dove,kirkwood,mvebu} ? You or Zhang?

-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
  2013-03-21 19:57           ` Ezequiel Garcia
@ 2013-03-21 20:06             ` Jason Cooper
  -1 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 20:06 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-arm-kernel, Zhang Rui, linux-pm, Thomas Petazzoni,
	Gregory Clement, Nobuhiro Iwamatsu, Andrew Lunn,
	Florian Fainelli, Sebastian Hesselbarth, Lior Amsalem

On Thu, Mar 21, 2013 at 04:57:09PM -0300, Ezequiel Garcia wrote:
> On Thu, Mar 21, 2013 at 11:24:00AM -0400, Jason Cooper wrote:
> > On Thu, Mar 21, 2013 at 12:16:10PM -0300, Ezequiel Garcia wrote:
> > > Hi Jason,
> > > 
> > > On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> > > > On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > > > > The correct value is obtain by first shifting the register by the offset,
> > > > > later applying the valid mask and finally invert the result.
> > > > > This check was lacking an extra parenthesis to be strictly correct.
> > > > > 
> > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > > > ---
> > > > >  drivers/thermal/mvebu_thermal.c |    4 ++--
> > > > >  1 files changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > For the next version of this series, could you please put this fix first
> > > > in the series?  In this state, it can't be applied to v3.9-rcX, nor
> > > > -stable.
> > > > 
> > > 
> > > Given we're still discussing the aproach of this patchset.
> > > I think I prefer to send the fixes now, not as part of the
> > > current series but as independent patches.
> > > 
> > > What do you think?
> > 
> > I agree.
> > 
> 
> I have a question about this though: Who should pick patches for
> drivers/thermal/{dove,kirkwood,mvebu} ? You or Zhang?

That's up to Zhang.  If he has a lot of changes going on this cycle,
he'll probably want to take them through his tree.  However, if he
doesn't, and we have a lot of stuff depending on it (the rest of your
series), he'll probably be ok with Ack'ing it and letting us take it
through our tree.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register
@ 2013-03-21 20:06             ` Jason Cooper
  0 siblings, 0 replies; 86+ messages in thread
From: Jason Cooper @ 2013-03-21 20:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 04:57:09PM -0300, Ezequiel Garcia wrote:
> On Thu, Mar 21, 2013 at 11:24:00AM -0400, Jason Cooper wrote:
> > On Thu, Mar 21, 2013 at 12:16:10PM -0300, Ezequiel Garcia wrote:
> > > Hi Jason,
> > > 
> > > On Thu, Mar 21, 2013 at 10:35:39AM -0400, Jason Cooper wrote:
> > > > On Wed, Mar 20, 2013 at 07:36:26PM -0300, Ezequiel Garcia wrote:
> > > > > The correct value is obtain by first shifting the register by the offset,
> > > > > later applying the valid mask and finally invert the result.
> > > > > This check was lacking an extra parenthesis to be strictly correct.
> > > > > 
> > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > > > ---
> > > > >  drivers/thermal/mvebu_thermal.c |    4 ++--
> > > > >  1 files changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > For the next version of this series, could you please put this fix first
> > > > in the series?  In this state, it can't be applied to v3.9-rcX, nor
> > > > -stable.
> > > > 
> > > 
> > > Given we're still discussing the aproach of this patchset.
> > > I think I prefer to send the fixes now, not as part of the
> > > current series but as independent patches.
> > > 
> > > What do you think?
> > 
> > I agree.
> > 
> 
> I have a question about this though: Who should pick patches for
> drivers/thermal/{dove,kirkwood,mvebu} ? You or Zhang?

That's up to Zhang.  If he has a lot of changes going on this cycle,
he'll probably want to take them through his tree.  However, if he
doesn't, and we have a lot of stuff depending on it (the rest of your
series), he'll probably be ok with Ack'ing it and letting us take it
through our tree.

thx,

Jason.

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
  2013-03-21 19:17     ` Russell King - ARM Linux
@ 2013-03-21 20:21       ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 20:21 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Thomas Petazzoni, Andrew Lunn, Jason Cooper, Nobuhiro Iwamatsu,
	linux-pm, Lior Amsalem, Gregory Clement, Zhang Rui,
	Florian Fainelli, linux-arm-kernel, Sebastian Hesselbarth

On Thu, Mar 21, 2013 at 07:17:51PM +0000, Russell King - ARM Linux wrote:
> On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> > Convert devm_request_and_ioremap() to the newly introduced
> > devm_ioremap_resource() which provides more consistent error handling.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/thermal/mvebu_thermal.c |    6 ++----
> >  1 files changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > index ef04e4e..089b43d 100644
> > --- a/drivers/thermal/mvebu_thermal.c
> > +++ b/drivers/thermal/mvebu_thermal.c
> > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> >  	if (!priv)
> >  		return -ENOMEM;
> >  
> > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->sensor) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > +	if (!priv->sensor)
> >  		return -EADDRNOTAVAIL;
> 
> NAK.  It pays to understand the interface that you're using.  In this
> case, it *doesn't* return NULL on error, so you'll never reach
> -EADDRNOTAVAIL.  Please look this function up in lib/devres.c and
> understand its API.
> 

Yes, you're right, I'll fix this on v2.

Thanks,
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource()
@ 2013-03-21 20:21       ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 20:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 07:17:51PM +0000, Russell King - ARM Linux wrote:
> On Wed, Mar 20, 2013 at 07:36:27PM -0300, Ezequiel Garcia wrote:
> > Convert devm_request_and_ioremap() to the newly introduced
> > devm_ioremap_resource() which provides more consistent error handling.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/thermal/mvebu_thermal.c |    6 ++----
> >  1 files changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/thermal/mvebu_thermal.c b/drivers/thermal/mvebu_thermal.c
> > index ef04e4e..089b43d 100644
> > --- a/drivers/thermal/mvebu_thermal.c
> > +++ b/drivers/thermal/mvebu_thermal.c
> > @@ -86,11 +86,9 @@ static int mvebu_thermal_probe(struct platform_device *pdev)
> >  	if (!priv)
> >  		return -ENOMEM;
> >  
> > -	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);
> > -	if (!priv->sensor) {
> > -		dev_err(&pdev->dev, "Failed to request_ioremap memory\n");
> > +	priv->sensor = devm_ioremap_resource(&pdev->dev, res);
> > +	if (!priv->sensor)
> >  		return -EADDRNOTAVAIL;
> 
> NAK.  It pays to understand the interface that you're using.  In this
> case, it *doesn't* return NULL on error, so you'll never reach
> -EADDRNOTAVAIL.  Please look this function up in lib/devres.c and
> understand its API.
> 

Yes, you're right, I'll fix this on v2.

Thanks,
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
  2013-03-21 19:20     ` Russell King - ARM Linux
@ 2013-03-21 20:38       ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 20:38 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, Thomas Petazzoni, Andrew Lunn, Jason Cooper,
	Nobuhiro Iwamatsu, linux-pm, Lior Amsalem, Gregory Clement,
	Zhang Rui, Florian Fainelli, Sebastian Hesselbarth

On Thu, Mar 21, 2013 at 07:20:46PM +0000, Russell King - ARM Linux wrote:
> On Wed, Mar 20, 2013 at 07:36:29PM -0300, Ezequiel Garcia wrote:
> > The temperature formula was taken from the Armada 510 datasheet.
> > This is wrong because the Kirkwood SoC thermal sensor has
> > different coefficients.
> > 
> > Fix it using values from 88F682/88F683 Kirkwood datasheet.
> 
> Err, hang on.  You've changed this from being a Kirkwood specific
> driver to being a "mvebu" driver, which I had understood was being
> done to cover all Kirkwood, Dove, etc SoCs.
> 
> If that's the case, then this change is wrong because you break it
> for Dove.
> 
> If the coefficients are different between Kirkwood and Dove, then
> it needs to be adapted at run time depending on whether it's running
> on Kirkwood or Dove - not just having the coefficients changed at
> compile time to suit a different set of platforms.
> 
> If it's worth making a change, do it *properly*.

I'm not sure I'm following you.

This patch fixes the Kirkwood formula on a driver that,
at this point, only supports Kirkwood.

Dove SoC thermal sensor is supported in dove-thermal,
until it's merged in patch 13/16 (i.e. after this patch).

AFAIK, I'm not breaking support for any platform in any
point of the patchset.

Perhaps I'm missing something?
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood
@ 2013-03-21 20:38       ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-21 20:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 07:20:46PM +0000, Russell King - ARM Linux wrote:
> On Wed, Mar 20, 2013 at 07:36:29PM -0300, Ezequiel Garcia wrote:
> > The temperature formula was taken from the Armada 510 datasheet.
> > This is wrong because the Kirkwood SoC thermal sensor has
> > different coefficients.
> > 
> > Fix it using values from 88F682/88F683 Kirkwood datasheet.
> 
> Err, hang on.  You've changed this from being a Kirkwood specific
> driver to being a "mvebu" driver, which I had understood was being
> done to cover all Kirkwood, Dove, etc SoCs.
> 
> If that's the case, then this change is wrong because you break it
> for Dove.
> 
> If the coefficients are different between Kirkwood and Dove, then
> it needs to be adapted at run time depending on whether it's running
> on Kirkwood or Dove - not just having the coefficients changed at
> compile time to suit a different set of platforms.
> 
> If it's worth making a change, do it *properly*.

I'm not sure I'm following you.

This patch fixes the Kirkwood formula on a driver that,
at this point, only supports Kirkwood.

Dove SoC thermal sensor is supported in dove-thermal,
until it's merged in patch 13/16 (i.e. after this patch).

AFAIK, I'm not breaking support for any platform in any
point of the patchset.

Perhaps I'm missing something?
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 00/16] Marvell EBU thermal sensor consolidation
  2013-03-21 17:32     ` Jason Gunthorpe
@ 2013-03-22 14:23       ` Ezequiel Garcia
  -1 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-22 14:23 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Andrew Lunn, Thomas Petazzoni, Jason Cooper, Nobuhiro Iwamatsu,
	linux-pm, Lior Amsalem, Gregory Clement, Zhang Rui,
	Florian Fainelli, linux-arm-kernel, Sebastian Hesselbarth

On Thu, Mar 21, 2013 at 11:32:51AM -0600, Jason Gunthorpe wrote:
> On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:
> 
> > In the end, i decided it was simpler and cleaner to just have separate
> > drivers. This is something which we should think about and discuss.
> 
> When I looked through the merge'd driver I thought the shared code
> really had little to do with Marvell, it was mostly boilerplate that
> would be common to any memory mapped temperature sensor - so maybe the
> drivers should be kept apart and the boiler plate could be factored?
> 
>  thermal_platform_mmio_init(pdev,&ops);
> 
> Where ops has the is_valid, init_sensor, get_sensor functions
> 
> Or something?
> 

Mmm... I'm not entirely sure. It might make sense if we could have
thermal drivers for mor SoC than just Marvell's.

Is it judicious to have a thermal-mmio based on Marvell-only devices?

> ...
> 
> BTW, Ezequiel your driver is probably a bit smaller if you do
> 
> struct mvebu_ops {
> 	/* Initialize the sensor (optional) */
> 	void (*init_sensor)(struct mvebu_thermal_priv *);
> 
> 	/* Test for a valid sensor value (optional) */
> 	bool (*is_valid)(struct mvebu_thermal_priv *);
> };
> 
> static const struct mvebu_ops kirkwood_ops = {..};
> 
> static const struct of_device_id mvebu_thermal_id_table[] = {
> 	{
> 		.compatible = "marvell,kirkwood-thermal",
> 		.data       = &kirkwood_ops,
> 	},
> 
> And drop the switch statement and the MVEBU_THERMAL_SOC_* constants..
> 

Yes, this sounds like a very good idea. I'll try it and see what happens.

Thanks,
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 00/16] Marvell EBU thermal sensor consolidation
@ 2013-03-22 14:23       ` Ezequiel Garcia
  0 siblings, 0 replies; 86+ messages in thread
From: Ezequiel Garcia @ 2013-03-22 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 21, 2013 at 11:32:51AM -0600, Jason Gunthorpe wrote:
> On Thu, Mar 21, 2013 at 07:45:01AM +0100, Andrew Lunn wrote:
> 
> > In the end, i decided it was simpler and cleaner to just have separate
> > drivers. This is something which we should think about and discuss.
> 
> When I looked through the merge'd driver I thought the shared code
> really had little to do with Marvell, it was mostly boilerplate that
> would be common to any memory mapped temperature sensor - so maybe the
> drivers should be kept apart and the boiler plate could be factored?
> 
>  thermal_platform_mmio_init(pdev,&ops);
> 
> Where ops has the is_valid, init_sensor, get_sensor functions
> 
> Or something?
> 

Mmm... I'm not entirely sure. It might make sense if we could have
thermal drivers for mor SoC than just Marvell's.

Is it judicious to have a thermal-mmio based on Marvell-only devices?

> ...
> 
> BTW, Ezequiel your driver is probably a bit smaller if you do
> 
> struct mvebu_ops {
> 	/* Initialize the sensor (optional) */
> 	void (*init_sensor)(struct mvebu_thermal_priv *);
> 
> 	/* Test for a valid sensor value (optional) */
> 	bool (*is_valid)(struct mvebu_thermal_priv *);
> };
> 
> static const struct mvebu_ops kirkwood_ops = {..};
> 
> static const struct of_device_id mvebu_thermal_id_table[] = {
> 	{
> 		.compatible = "marvell,kirkwood-thermal",
> 		.data       = &kirkwood_ops,
> 	},
> 
> And drop the switch statement and the MVEBU_THERMAL_SOC_* constants..
> 

Yes, this sounds like a very good idea. I'll try it and see what happens.

Thanks,
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2013-03-22 14:23 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-20 22:36 [PATCH 00/16] Marvell EBU thermal sensor consolidation Ezequiel Garcia
2013-03-20 22:36 ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 01/16] thermal: Rename driver 'kirkwood' -> 'mvebu' Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 02/16] thermal: mvebu: Rename symbols " Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 03/16] thermal: mvebu: Move MODULE_DEVICE_TABLE upwards Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 04/16] thermal: mvebu: Remove unneeded variable initialization Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 05/16] thermal: mvebu: Fix valid check for thermal register Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-21 14:35   ` Jason Cooper
2013-03-21 14:35     ` Jason Cooper
2013-03-21 15:16     ` Ezequiel Garcia
2013-03-21 15:16       ` Ezequiel Garcia
2013-03-21 15:24       ` Jason Cooper
2013-03-21 15:24         ` Jason Cooper
2013-03-21 19:57         ` Ezequiel Garcia
2013-03-21 19:57           ` Ezequiel Garcia
2013-03-21 20:06           ` Jason Cooper
2013-03-21 20:06             ` Jason Cooper
2013-03-20 22:36 ` [PATCH 06/16] thermal: mvebu: Convert to devm_ioremap_resource() Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-21  6:10   ` Andrew Lunn
2013-03-21  6:10     ` Andrew Lunn
2013-03-21  9:43     ` Ezequiel Garcia
2013-03-21  9:43       ` Ezequiel Garcia
2013-03-21 10:08       ` Andrew Lunn
2013-03-21 10:08         ` Andrew Lunn
2013-03-21 14:04   ` Sergei Shtylyov
2013-03-21 14:04     ` Sergei Shtylyov
2013-03-21 15:17     ` Ezequiel Garcia
2013-03-21 15:17       ` Ezequiel Garcia
2013-03-21 19:17   ` Russell King - ARM Linux
2013-03-21 19:17     ` Russell King - ARM Linux
2013-03-21 20:21     ` Ezequiel Garcia
2013-03-21 20:21       ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 07/16] thermal: mvebu: Fix license declaration Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 08/16] thermal: mvebu: Fix temperature output formula for kirkwood Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-21 14:41   ` Jason Cooper
2013-03-21 14:41     ` Jason Cooper
2013-03-21 19:20   ` Russell King - ARM Linux
2013-03-21 19:20     ` Russell King - ARM Linux
2013-03-21 20:38     ` Ezequiel Garcia
2013-03-21 20:38       ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 09/16] thermal: mvebu: Rename kirkwood definitions to mvebu Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 10/16] thermal: mvebu: Add infrastructure to support more multiple SoC variants Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 11/16] thermal: mvebu: Add support for Armada XP thermal sensor Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 12/16] thermal: mvebu: Add support for Armada 370 " Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 13/16] thermal: mvebu: Add support for Marvell Dove SoC family Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-21  6:23   ` Andrew Lunn
2013-03-21  6:23     ` Andrew Lunn
2013-03-21  6:26     ` Andrew Lunn
2013-03-21  6:26       ` Andrew Lunn
2013-03-20 22:36 ` [PATCH 14/16] ARM: mvebu: Add thermal support to Armada XP device tree Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 15/16] ARM: mvebu: Add thermal support to Armada 370 " Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-21 14:03   ` Sergei Shtylyov
2013-03-21 14:03     ` Sergei Shtylyov
2013-03-21 15:18     ` Ezequiel Garcia
2013-03-21 15:18       ` Ezequiel Garcia
2013-03-20 22:36 ` [PATCH 16/16] ARM: configs: Update mvebu, dove and kirkwood defconfigs for thermal Ezequiel Garcia
2013-03-20 22:36   ` Ezequiel Garcia
2013-03-21  6:45 ` [PATCH 00/16] Marvell EBU thermal sensor consolidation Andrew Lunn
2013-03-21  6:45   ` Andrew Lunn
2013-03-21  9:42   ` Ezequiel Garcia
2013-03-21  9:42     ` Ezequiel Garcia
2013-03-21 12:35   ` Ezequiel Garcia
2013-03-21 12:35     ` Ezequiel Garcia
2013-03-21 13:36     ` Andrew Lunn
2013-03-21 13:36       ` Andrew Lunn
2013-03-21 17:32   ` Jason Gunthorpe
2013-03-21 17:32     ` Jason Gunthorpe
2013-03-22 14:23     ` Ezequiel Garcia
2013-03-22 14:23       ` Ezequiel Garcia
2013-03-21 12:26 ` Ezequiel Garcia
2013-03-21 12:26   ` Ezequiel Garcia

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.