Skip to contentSkip to conversation

thermal: Armada 375/380 SoC support

PATCH Superseded Ezequiel Garcia 2 participants 15 messages Apr 24, 2014 – Apr 28, 2014

Subsystems (6)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover thermal: Armada 375/380 SoC support

This patchset adds the support for the thermal sensor in the recently introduced Armada 375 and 38x SoC. Compared to the previous patchset version, this v2 introduces the A380 SoC support.

The first five patches are preparation work. They add a generic infrastructure that allows to support similar thermal sensors in a non-intrusive way.

Patches six and seven uses this infrastructure to support the Armada 375 and 380 SoC thermal sensor.

Since there are some issues in the Armada 375 Z1 SoC thermal sensor, patch eight adds a quirk to workaround such issues. The Z1 silicon stepping is detected and the compatible string is updated, so the driver can apply sensor initialization workarounds.

In addition, the quirk moves the offset of the thermal control register, and allows to specifiy the correct (A0 stepping) offset in the devicetree. This quirk is applied only for the A375-DB board, being the only board known to have the problematic Z1 SoC.

Finally, the last two patches enables the thermal sensor in the devicetree. for the Armada 375 A0 stepping SoC, and the Armada 380/385 SoCs.

The series applies on v3.15-rc1, and has been tested on A375-DB board and A385-DB board.

Feedback and comments are welcome!

Changes from v1:

* Introduced the Armada 380 support. In order to support this in a clean way, the 'inverted' field was added.

* Cleaned the A375 workaround in the thermal driver, by detecting the device compatible string, as suggested by Jason Cooper.

* Added details about the register offset in the Z1 stepping to the binding documentation as requested by Jason Cooper.

Ezequiel Garcia (10):
thermal: armada: Rename armada_thermal_ops struct
thermal: armada: Add infrastructure to support generic formulas
thermal: armada: Add generic infrastructure to handle the sensor
thermal: armada: Pass the platform_device to init_sensor()
thermal: armada: Allow to specify an 'inverted readout' sensor
thermal: armada: Support Armada 375 SoC
thermal: armada: Support Armada 380 SoC
ARM: mvebu: Add thermal quirk for the Armada 375 DB board
ARM: mvebu: Enable the thermal sensor in Armada 375 SoC
ARM: mvebu: Enable the thermal sensor in Armada 380/385 SoC

 .../devicetree/bindings/thermal/armada-thermal.txt |  12 +-
 arch/arm/boot/dts/armada-375.dtsi                  |   6 +
 arch/arm/boot/dts/armada-38x.dtsi                  |   6 +
 arch/arm/mach-mvebu/board-v7.c                     |  57 ++++++++
 arch/arm/mach-mvebu/mvebu-soc-id.h                 |   3 +
 drivers/thermal/armada_thermal.c                   | 158 ++++++++++++++++++---
 6 files changed, 222 insertions(+), 20 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/10 thermal: armada: Rename armada_thermal_ops struct

As preparation work to add a generic infrastructure to support different SoC variants, the armada_thermal_ops will be used to host the SoC-specific fields, such as formula values and register offsets.

For this reason, the name armada_thermal_ops is no longer suitable, and this commit replaces it with armada_thermal_data.

---
 drivers/thermal/armada_thermal.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/thermal/armada_thermal.c +10 -10
index 5e53212..c5db071 100644
@@ -38,16 +38,16 @@
 #define PMU_TDC0_OTF_CAL_MASK		(0x1 << 30)
 #define PMU_TDC0_START_CAL_MASK		(0x1 << 25)
 
-struct armada_thermal_ops;
+struct armada_thermal_data;
 
 /* Marvell EBU Thermal Sensor Dev Structure */
 struct armada_thermal_priv {
 	void __iomem *sensor;
 	void __iomem *control;
-	struct armada_thermal_ops *ops;
+	struct armada_thermal_data *data;
 };
 
-struct armada_thermal_ops {
+struct armada_thermal_data {
 	/* Initialize the sensor */
 	void (*init_sensor)(struct armada_thermal_priv *);
 
@@ -113,7 +113,7 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
 	unsigned long reg;
 
 	/* Valid check */
-	if (priv->ops->is_valid && !priv->ops->is_valid(priv)) {
+	if (priv->data->is_valid && !priv->data->is_valid(priv)) {
 		dev_err(&thermal->device,
 			"Temperature sensor reading not valid\n");
 		return -EIO;
@@ -129,11 +129,11 @@ static struct thermal_zone_device_ops ops = {
 	.get_temp = armada_get_temp,
 };
 
-static const struct armada_thermal_ops armadaxp_ops = {
+static const struct armada_thermal_data armadaxp_data = {
 	.init_sensor = armadaxp_init_sensor,
 };
 
-static const struct armada_thermal_ops armada370_ops = {
+static const struct armada_thermal_data armada370_data = {
 	.is_valid = armada_is_valid,
 	.init_sensor = armada370_init_sensor,
 };
@@ -141,11 +141,11 @@ static const struct armada_thermal_ops armada370_ops = {
 static const struct of_device_id armada_thermal_id_table[] = {
 	{
 		.compatible = "marvell,armadaxp-thermal",
-		.data       = &armadaxp_ops,
+		.data       = &armadaxp_data,
 	},
 	{
 		.compatible = "marvell,armada370-thermal",
-		.data       = &armada370_ops,
+		.data       = &armada370_data,
 	},
 	{
 		/* sentinel */
@@ -178,8 +178,8 @@ static int armada_thermal_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->control))
 		return PTR_ERR(priv->control);
 
-	priv->ops = (struct armada_thermal_ops *)match->data;
-	priv->ops->init_sensor(priv);
+	priv->data = (struct armada_thermal_data *)match->data;
+	priv->data->init_sensor(priv);
 
 	thermal = thermal_zone_device_register("armada_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/10 thermal: armada: Add infrastructure to support generic formulas

In reply to Ezequiel Garcia

In order to support other similar SoC, with different sensor coeficients, this commit adds the coeficients to the per-variant structure, instead of having the formula hardcoded.

---
 drivers/thermal/armada_thermal.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/thermal/armada_thermal.c +19 -1
index c5db071..4de6e56 100644
@@ -53,6 +53,11 @@ struct armada_thermal_data {
 
 	/* Test for a valid sensor value (optional) */
 	bool (*is_valid)(struct armada_thermal_priv *);
+
+	/* Formula coeficients: temp = (b + m * reg) / div */
+	unsigned long coef_b;
+	unsigned long coef_m;
+	unsigned long coef_div;
 };
 
 static void armadaxp_init_sensor(struct armada_thermal_priv *priv)
@@ -111,6 +116,7 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
 {
 	struct armada_thermal_priv *priv = thermal->devdata;
 	unsigned long reg;
+	unsigned long m, b, div;
 
 	/* Valid check */
 	if (priv->data->is_valid && !priv->data->is_valid(priv)) {
@@ -121,7 +127,13 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
 
 	reg = readl_relaxed(priv->sensor);
 	reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK;
-	*temp = (3153000000UL - (10000000UL*reg)) / 13825;
+
+	/* Get formula coeficients */
+	b = priv->data->coef_b;
+	m = priv->data->coef_m;
+	div = priv->data->coef_div;
+
+	*temp = (b - (m * reg)) / div;
 	return 0;
 }
 
@@ -131,11 +143,17 @@ static struct thermal_zone_device_ops ops = {
 
 static const struct armada_thermal_data armadaxp_data = {
 	.init_sensor = armadaxp_init_sensor,
+	.coef_b = 3153000000UL,
+	.coef_m = 10000000UL,
+	.coef_div = 13825,
 };
 
 static const struct armada_thermal_data armada370_data = {
 	.is_valid = armada_is_valid,
 	.init_sensor = armada370_init_sensor,
+	.coef_b = 3153000000UL,
+	.coef_m = 10000000UL,
+	.coef_div = 13825,
 };
 
 static const struct of_device_id armada_thermal_id_table[] = {
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 3/10 thermal: armada: Add generic infrastructure to handle the sensor

In reply to Ezequiel Garcia

In order to support similar SoC where the sensor value and valid bit can have different offset and/or mask, we add such fields to the per-variant structure, instead of having the values hardcoded.

---
 drivers/thermal/armada_thermal.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/thermal/armada_thermal.c +12 -5
index 4de6e56..3e4d8ef 100644
@@ -24,10 +24,7 @@
 #include <linux/of_device.h>
 #include <linux/thermal.h>
 
-#define THERMAL_VALID_OFFSET		9
 #define THERMAL_VALID_MASK		0x1
-#define THERMAL_TEMP_OFFSET		10
-#define THERMAL_TEMP_MASK		0x1ff
 
 /* Thermal Manager Control and Status Register */
 #define PMU_TDC0_SW_RST_MASK		(0x1 << 1)
@@ -58,6 +55,11 @@ struct armada_thermal_data {
 	unsigned long coef_b;
 	unsigned long coef_m;
 	unsigned long coef_div;
+
+	/* Offset and mask to access the sensor temperature */
+	unsigned int temp_offset;
+	unsigned int temp_mask;
+	unsigned int is_valid_offset;
 };
 
 static void armadaxp_init_sensor(struct armada_thermal_priv *priv)
@@ -108,7 +110,7 @@ static bool armada_is_valid(struct armada_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
 
-	return (reg >> THERMAL_VALID_OFFSET) & THERMAL_VALID_MASK;
+	return (reg >> priv->data->is_valid_offset) & THERMAL_VALID_MASK;
 }
 
 static int armada_get_temp(struct thermal_zone_device *thermal,
@@ -126,7 +128,7 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
 	}
 
 	reg = readl_relaxed(priv->sensor);
-	reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK;
+	reg = (reg >> priv->data->temp_offset) & priv->data->temp_mask;
 
 	/* Get formula coeficients */
 	b = priv->data->coef_b;
@@ -143,6 +145,8 @@ static struct thermal_zone_device_ops ops = {
 
 static const struct armada_thermal_data armadaxp_data = {
 	.init_sensor = armadaxp_init_sensor,
+	.temp_offset = 10,
+	.temp_mask = 0x1ff,
 	.coef_b = 3153000000UL,
 	.coef_m = 10000000UL,
 	.coef_div = 13825,
@@ -151,6 +155,9 @@ static const struct armada_thermal_data armadaxp_data = {
 static const struct armada_thermal_data armada370_data = {
 	.is_valid = armada_is_valid,
 	.init_sensor = armada370_init_sensor,
+	.is_valid_offset = 9,
+	.temp_offset = 10,
+	.temp_mask = 0x1ff,
 	.coef_b = 3153000000UL,
 	.coef_m = 10000000UL,
 	.coef_div = 13825,
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 4/10 thermal: armada: Pass the platform_device to init_sensor()

In reply to Ezequiel Garcia

In order to perform SoC-specific quirks on platforms that need them, this commit adds a new parameter to the init_sensor() function. This will be used to support early silicons of the Armada 375 SoC, to workaround some hardware issues.

---
 drivers/thermal/armada_thermal.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/thermal/armada_thermal.c +7 -4
index 3e4d8ef..aafcc4d 100644
@@ -46,7 +46,8 @@ struct armada_thermal_priv {
 
 struct armada_thermal_data {
 	/* Initialize the sensor */
-	void (*init_sensor)(struct armada_thermal_priv *);
+	void (*init_sensor)(struct platform_device *pdev,
+			    struct armada_thermal_priv *);
 
 	/* Test for a valid sensor value (optional) */
 	bool (*is_valid)(struct armada_thermal_priv *);
@@ -62,7 +63,8 @@ struct armada_thermal_data {
 	unsigned int is_valid_offset;
 };
 
-static void armadaxp_init_sensor(struct armada_thermal_priv *priv)
+static void armadaxp_init_sensor(struct platform_device *pdev,
+				 struct armada_thermal_priv *priv)
 {
 	unsigned long reg;
 
@@ -87,7 +89,8 @@ static void armadaxp_init_sensor(struct armada_thermal_priv *priv)
 	writel(reg, priv->sensor);
 }
 
-static void armada370_init_sensor(struct armada_thermal_priv *priv)
+static void armada370_init_sensor(struct platform_device *pdev,
+				  struct armada_thermal_priv *priv)
 {
 	unsigned long reg;
 
@@ -204,7 +207,7 @@ static int armada_thermal_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->control);
 
 	priv->data = (struct armada_thermal_data *)match->data;
-	priv->data->init_sensor(priv);
+	priv->data->init_sensor(pdev, priv);
 
 	thermal = thermal_zone_device_register("armada_thermal", 0, 0,
 					       priv, &ops, NULL, 0, 0);
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 5/10 thermal: armada: Allow to specify an 'inverted readout' sensor

In reply to Ezequiel Garcia

In order to support inverted-formula thermal sensor readout, this commit introduces an 'inverted' field in the SoC-specific structure which allows to specify an inversion of the temperature formula.

---
 drivers/thermal/armada_thermal.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/thermal/armada_thermal.c +5 -1
index aafcc4d..e228132 100644
@@ -56,6 +56,7 @@ struct armada_thermal_data {
 	unsigned long coef_b;
 	unsigned long coef_m;
 	unsigned long coef_div;
+	bool inverted;
 
 	/* Offset and mask to access the sensor temperature */
 	unsigned int temp_offset;
@@ -138,7 +139,10 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
 	m = priv->data->coef_m;
 	div = priv->data->coef_div;
 
-	*temp = (b - (m * reg)) / div;
+	if (priv->data->inverted)
+		*temp = ((m * reg) - b) / div;
+	else
+		*temp = (b - (m * reg)) / div;
 	return 0;
 }
 
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 6/10 thermal: armada: Support Armada 375 SoC

In reply to Ezequiel Garcia

Now that a generic infrastructure is in place, it's possible to support the new Armada 375 SoC thermal sensor. This sensor is similar to the one available in the already supported SoCs, with its specific temperature formula and specific sensor initialization.

In addition, we also add support for the Z1 SoC stepping, which needs an initialization-quirk to work properly.

---
 .../devicetree/bindings/thermal/armada-thermal.txt | 11 +++-
 drivers/thermal/armada_thermal.c                   | 58 ++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/armada-thermal.txt +10 -1
index fff93d5..2a67e51 100644
@@ -1,11 +1,20 @@
-* Marvell Armada 370/XP thermal management
+* Marvell Armada 370/375/XP thermal management
 
 Required properties:
 
 - compatible:	Should be set to one of the following:
 		marvell,armada370-thermal
+		marvell,armada375-thermal
+		marvell,armada375-z1-thermal
 		marvell,armadaxp-thermal
 
+		Note: As the name suggests, "marvell,armada375-z1-thermal"
+		applies for the SoC Z1 stepping only. On such stepping
+		some quirks need to be done and the register offset differs
+		from the one in the A0 stepping.
+		The operating system may auto-detect the SoC stepping and
+		update the compatible and register offsets at runtime.
+
 - reg:		Device's register space.
 		Two entries are expected, see the examples below.
 		The first one is required for the sensor register;
drivers/thermal/armada_thermal.c +58 -0

82 lines not on this page · raw message

Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 7/10 thermal: armada: Support Armada 380 SoC

In reply to Ezequiel Garcia

Now that a generic infrastructure is in place, it's possible to support the Armada 380 SoC thermal sensor. This sensor is similar to the one available in the already supported SoCs, with its specific temperature formula and specific sensor initialization.

---
 .../devicetree/bindings/thermal/armada-thermal.txt |  3 ++-
 drivers/thermal/armada_thermal.c                   | 30 ++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/armada-thermal.txt +2 -1
index 2a67e51..4cf0249 100644
@@ -1,4 +1,4 @@
-* Marvell Armada 370/375/XP thermal management
+* Marvell Armada 370/375/380/XP thermal management
 
 Required properties:
 
@@ -6,6 +6,7 @@ Required properties:
 		marvell,armada370-thermal
 		marvell,armada375-thermal
 		marvell,armada375-z1-thermal
+		marvell,armada380-thermal
 		marvell,armadaxp-thermal
 
 		Note: As the name suggests, "marvell,armada375-z1-thermal"
drivers/thermal/armada_thermal.c +30 -0
index e40cc6e..a48d0ca 100644
@@ -43,6 +43,7 @@
 #define A375_UNIT_CONTROL_MASK		0x7
 #define A375_READOUT_INVERT		BIT(15)
 #define A375_HW_RESETn			BIT(8)
+#define A380_HW_RESET			BIT(8)
 
 struct armada_thermal_data;
 
@@ -149,6 +150,19 @@ static void armada375_init_sensor(struct platform_device *pdev,
 	mdelay(50);
 }
 
+static void armada380_init_sensor(struct platform_device *pdev,
+				  struct armada_thermal_priv *priv)
+{
+	unsigned long reg = readl_relaxed(priv->control);
+
+	/* Reset hardware once */
+	if (reg & A380_HW_RESET) {
+		reg |= A380_HW_RESET;
+		writel(reg, priv->control);
+		mdelay(10);
+	}
+}
+
 static bool armada_is_valid(struct armada_thermal_priv *priv)
 {
 	unsigned long reg = readl_relaxed(priv->sensor);
@@ -220,6 +234,18 @@ static const struct armada_thermal_data armada375_data = {
 	.coef_div = 13616,
 };
 
+static const struct armada_thermal_data armada380_data = {
+	.is_valid = armada_is_valid,
+	.init_sensor = armada380_init_sensor,
+	.is_valid_offset = 10,
+	.temp_offset = 0,
+	.temp_mask = 0x3ff,
+	.coef_b = 1169498786UL,
+	.coef_m = 2000000UL,
+	.coef_div = 4289,
+	.inverted = true,
+};
+
 static const struct of_device_id armada_thermal_id_table[] = {
 	{
 		.compatible = "marvell,armadaxp-thermal",
@@ -238,6 +264,10 @@ static const struct of_device_id armada_thermal_id_table[] = {
 		.data       = &armada375_data,
 	},
 	{
+		.compatible = "marvell,armada380-thermal",
+		.data       = &armada380_data,
+	},
+	{
 		/* sentinel */
 	},
 };
Signature · 1 line
1.9.1
#8 lore raw

PATCH v2 8/10 ARM: mvebu: Add thermal quirk for the Armada 375 DB board

In reply to Ezequiel Garcia

The initial release of the Armada 375 DB board has an Armada 375 Z1 stepping silicon. This commit introduces a quirk that allows to workaround a series of issues with the thermal sensor in this stepping, but updating the devicetree:

* Updates the compatible string for the thermal, so the driver can perform a specific initialization of the sensor.

* Moves the offset of the thermal control register. This quirk allows to specifiy the correct (A0 stepping) offset in the devicetree.

---
 arch/arm/mach-mvebu/board-v7.c     | 57 ++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-mvebu/mvebu-soc-id.h |  3 ++
 2 files changed, 60 insertions(+)
arch/arm/mach-mvebu/board-v7.c +57 -0
index 333fca8..93f50f2 100644
@@ -96,10 +96,66 @@ static void __init i2c_quirk(void)
 	return;
 }
 
+#define A375_Z1_THERMAL_FIXUP_OFFSET 0xc
+
+static void __init thermal_quirk(void)
+{
+	struct device_node *np;
+	u32 dev, rev;
+
+	if (mvebu_get_soc_id(&dev, &rev) && rev > ARMADA_375_Z1_REV)
+		return;
+
+	for_each_compatible_node(np, NULL, "marvell,armada375-thermal") {
+		struct property *prop;
+		__be32 newval, *newprop, *oldprop;
+		int len;
+
+		/*
+		 * The register offset is at a wrong location. This quirk
+		 * creates a new reg property as a clone of the previous
+		 * one and corrects the offset.
+		 */
+		oldprop = (__be32 *)of_get_property(np, "reg", &len);
+		if (!oldprop)
+			continue;
+
+		/* Create a duplicate of the 'reg' property */
+		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+		prop->length = len;
+		prop->name = kstrdup("reg", GFP_KERNEL);
+		prop->value = kzalloc(len, GFP_KERNEL);
+		memcpy(prop->value, oldprop, len);
+
+		/* Fixup the register offset of the second entry */
+		oldprop += 2;
+		newprop = (__be32 *)prop->value + 2;
+		newval = cpu_to_be32(be32_to_cpu(*oldprop) -
+				     A375_Z1_THERMAL_FIXUP_OFFSET);
+		*newprop = newval;
+		of_update_property(np, prop);
+
+		/*
+		 * The thermal controller needs some quirk too, so let's change
+		 * the compatible string to reflect this.
+		 */
+		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+		prop->name = kstrdup("compatible", GFP_KERNEL);
+		prop->length = sizeof("marvell,armada375-z1-thermal");
+		prop->value = kstrdup("marvell,armada375-z1-thermal",
+						GFP_KERNEL);
+		of_update_property(np, prop);
+	}
+	return;
+}
+
 static void __init mvebu_dt_init(void)
 {
 	if (of_machine_is_compatible("plathome,openblocks-ax3-4"))
 		i2c_quirk();
+	if (of_machine_is_compatible("marvell,a375-db"))
+		thermal_quirk();
+
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
@@ -123,6 +179,7 @@ static const char * const armada_375_dt_compat[] = {
 
 DT_MACHINE_START(ARMADA_375_DT, "Marvell Armada 375 (Device Tree)")
 	.init_time	= mvebu_timer_and_clk_init,
+	.init_machine	= mvebu_dt_init,
 	.restart	= mvebu_restart,
 	.dt_compat	= armada_375_dt_compat,
 MACHINE_END
arch/arm/mach-mvebu/mvebu-soc-id.h +3 -0
index 3165425..294a443 100644
@@ -20,6 +20,9 @@
 #define MV78XX0_A0_REV	    0x1
 #define MV78XX0_B0_REV	    0x2
 
+/* Armada 375 */
+#define ARMADA_375_Z1_REV   0x0
+
 #ifdef CONFIG_ARCH_MVEBU
 int mvebu_get_soc_id(u32 *dev, u32 *rev);
 #else
Signature · 1 line
1.9.1
#9 lore raw

PATCH v2 9/10 ARM: mvebu: Enable the thermal sensor in Armada 375 SoC

In reply to Ezequiel Garcia

This commit enables the thermal sensor found in Armada 375 SoCs.

---
 arch/arm/boot/dts/armada-375.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/armada-375.dtsi +6 -0
index 3877693f..7467f9d 100644
@@ -391,6 +391,12 @@
 				status = "disabled";
 			};
 
+			thermal at e8078 {
+				compatible = "marvell,armada375-thermal";
+				reg = <0xe8078 0x4>, <0xe807c 0x8>;
+				status = "okay";
+			};
+
 			coreclk: mvebu-sar at e8204 {
 				compatible = "marvell,armada-375-core-clock";
 				reg = <0xe8204 0x04>;
Signature · 1 line
1.9.1
#10 lore raw

PATCH v2 10/10 ARM: mvebu: Enable the thermal sensor in Armada 380/385 SoC

In reply to Ezequiel Garcia

This commit enables the thermal sensor found in Armada 380/385 SoCs.

---
 arch/arm/boot/dts/armada-38x.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/armada-38x.dtsi +6 -0
index a064f59..02c6139 100644
@@ -346,6 +346,12 @@
 				clock-output-names = "nand";
 			};
 
+			thermal at e8078 {
+				compatible = "marvell,armada380-thermal";
+				reg = <0xe4078 0x4>, <0xe404 0x4>;
+				status = "okay";
+			};
+
 			flash at d0000 {
 				compatible = "marvell,armada370-nand";
 				reg = <0xd0000 0x54>;
Signature · 1 line
1.9.1
#11 lore raw

PATCH v2 10/10 ARM: mvebu: Enable the thermal sensor in Armada 380/385 SoC

Quoted 12 lines · Ezequiel Garcia

This commit enables the thermal sensor found in Armada 380/385 SoCs.

---
 arch/arm/boot/dts/armada-38x.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/armada-38x.dtsi +0 -0
index a064f59..02c6139 100644

arch/arm/boot/dts/armada-38x.dtsi line 351

Quoted 6 lines
arch/arm/boot/dts/armada-38x.dtsi +3 -0
@@ -346,6 +346,12 @@
 				clock-output-names = "nand";
 			};
 
+			thermal at e8078 {
+				compatible = "marvell,armada380-thermal";
+				reg = <0xe4078 0x4>, <0xe404 0x4>;

Dammit, there's a stupid typo in the register offset. I never noticed this, because the initialization sequence does not do much, and this register is not really used (for now). The fix is this:

arch/arm/boot/dts/armada-38x.dtsi +1 -1
index 02c6139..370220f 100644
@@ -348,7 +348,7 @@
 
 			thermal at e8078 {
 				compatible = "marvell,armada380-thermal";
-				reg = <0xe4078 0x4>, <0xe404 0x4>;
+				reg = <0xe4078 0x4>, <0xe4074 0x4>;
 				status = "okay";
 			};
 

Want me to send a follow-up patch?

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
#12 lore raw

PATCH v2 10/10 ARM: mvebu: Enable the thermal sensor in Armada 380/385 SoC

Quoted 37 lines · Ezequiel Garcia
Quoted 12 lines · Ezequiel Garcia

This commit enables the thermal sensor found in Armada 380/385 SoCs.

---
 arch/arm/boot/dts/armada-38x.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/armada-38x.dtsi +0 -0
index a064f59..02c6139 100644

arch/arm/boot/dts/armada-38x.dtsi line 351

Quoted 6 lines
arch/arm/boot/dts/armada-38x.dtsi +3 -0
@@ -346,6 +346,12 @@
 				clock-output-names = "nand";
 			};
 
+			thermal at e8078 {
+				compatible = "marvell,armada380-thermal";
+				reg = <0xe4078 0x4>, <0xe404 0x4>;

Dammit, there's a stupid typo in the register offset. I never noticed this, because the initialization sequence does not do much, and this register is not really used (for now). The fix is this:

arch/arm/boot/dts/armada-38x.dtsi +1 -1
index 02c6139..370220f 100644
@@ -348,7 +348,7 @@
 
 			thermal at e8078 {
 				compatible = "marvell,armada380-thermal";
-				reg = <0xe4078 0x4>, <0xe404 0x4>;
+				reg = <0xe4078 0x4>, <0xe4074 0x4>;
 				status = "okay";
 			};
 
Quoted 1 line

Want me to send a follow-up patch?

Nope, I squashed it in and pushed it out.

thx,

Jason.

Applied
#13 lore raw

v2 cover thermal: Armada 375/380 SoC support

In reply to Ezequiel Garcia
Quoted 40 lines · Ezequiel Garcia

This patchset adds the support for the thermal sensor in the recently introduced Armada 375 and 38x SoC. Compared to the previous patchset version, this v2 introduces the A380 SoC support.

The first five patches are preparation work. They add a generic infrastructure that allows to support similar thermal sensors in a non-intrusive way.

Patches six and seven uses this infrastructure to support the Armada 375 and 380 SoC thermal sensor.

Since there are some issues in the Armada 375 Z1 SoC thermal sensor, patch eight adds a quirk to workaround such issues. The Z1 silicon stepping is detected and the compatible string is updated, so the driver can apply sensor initialization workarounds.

In addition, the quirk moves the offset of the thermal control register, and allows to specifiy the correct (A0 stepping) offset in the devicetree. This quirk is applied only for the A375-DB board, being the only board known to have the problematic Z1 SoC.

Finally, the last two patches enables the thermal sensor in the devicetree. for the Armada 375 A0 stepping SoC, and the Armada 380/385 SoCs.

The series applies on v3.15-rc1, and has been tested on A375-DB board and A385-DB board.

Feedback and comments are welcome!

Changes from v1:

* Introduced the Armada 380 support. In order to support this in a clean way, the 'inverted' field was added.

* Cleaned the A375 workaround in the thermal driver, by detecting the device compatible string, as suggested by Jason Cooper.

* Added details about the register offset in the Z1 stepping to the binding documentation as requested by Jason Cooper.

Quoted 8 lines

Ezequiel Garcia (10):
thermal: armada: Rename armada_thermal_ops struct
thermal: armada: Add infrastructure to support generic formulas
thermal: armada: Add generic infrastructure to handle the sensor
thermal: armada: Pass the platform_device to init_sensor()
thermal: armada: Allow to specify an 'inverted readout' sensor
thermal: armada: Support Armada 375 SoC
thermal: armada: Support Armada 380 SoC

Thermal series:

Quoted 1 line

ARM: mvebu: Add thermal quirk for the Armada 375 DB board

Applied to mvebu/soc

Quoted 2 lines

ARM: mvebu: Enable the thermal sensor in Armada 375 SoC
ARM: mvebu: Enable the thermal sensor in Armada 380/385 SoC

Applied to mvebu/dt

thx,

Jason.

#14 lore raw

v2 cover thermal: Armada 375/380 SoC support

Hello Zhang,

Quoted 50 lines · Jason Cooper
Quoted 40 lines · Ezequiel Garcia

This patchset adds the support for the thermal sensor in the recently introduced Armada 375 and 38x SoC. Compared to the previous patchset version, this v2 introduces the A380 SoC support.

The first five patches are preparation work. They add a generic infrastructure that allows to support similar thermal sensors in a non-intrusive way.

Patches six and seven uses this infrastructure to support the Armada 375 and 380 SoC thermal sensor.

Since there are some issues in the Armada 375 Z1 SoC thermal sensor, patch eight adds a quirk to workaround such issues. The Z1 silicon stepping is detected and the compatible string is updated, so the driver can apply sensor initialization workarounds.

In addition, the quirk moves the offset of the thermal control register, and allows to specifiy the correct (A0 stepping) offset in the devicetree. This quirk is applied only for the A375-DB board, being the only board known to have the problematic Z1 SoC.

Finally, the last two patches enables the thermal sensor in the devicetree. for the Armada 375 A0 stepping SoC, and the Armada 380/385 SoCs.

The series applies on v3.15-rc1, and has been tested on A375-DB board and A385-DB board.

Feedback and comments are welcome!

Changes from v1:

* Introduced the Armada 380 support. In order to support this in a clean way, the 'inverted' field was added.

* Cleaned the A375 workaround in the thermal driver, by detecting the device compatible string, as suggested by Jason Cooper.

* Added details about the register offset in the Z1 stepping to the binding documentation as requested by Jason Cooper.

Quoted 8 lines

Ezequiel Garcia (10):
thermal: armada: Rename armada_thermal_ops struct
thermal: armada: Add infrastructure to support generic formulas
thermal: armada: Add generic infrastructure to handle the sensor
thermal: armada: Pass the platform_device to init_sensor()
thermal: armada: Allow to specify an 'inverted readout' sensor
thermal: armada: Support Armada 375 SoC
thermal: armada: Support Armada 380 SoC

Quoted 4 lines

Thermal series:

Do you have any comments about this?

Thanks!

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