* [PATCH v3 1/7] thermal: armada: Rename armada_thermal_ops struct
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
@ 2014-05-06 16:59 ` Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 2/7] thermal: armada: Add infrastructure to support generic formulas Ezequiel Garcia
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 16:59 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth, Ezequiel Garcia
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 shifts.
For this reason, the name armada_thermal_ops is no longer suitable,
and this commit replaces it with armada_thermal_data.
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/thermal/armada_thermal.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 5e53212..c5db071 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 2/7] thermal: armada: Add infrastructure to support generic formulas
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 1/7] thermal: armada: Rename armada_thermal_ops struct Ezequiel Garcia
@ 2014-05-06 16:59 ` Ezequiel Garcia
2014-05-15 0:07 ` Eduardo Valentin
2014-05-06 16:59 ` [PATCH v3 3/7] thermal: armada: Add generic infrastructure to handle the sensor Ezequiel Garcia
` (5 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 16:59 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth, 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.
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/thermal/armada_thermal.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index c5db071..4de6e56 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -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[] = {
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3 2/7] thermal: armada: Add infrastructure to support generic formulas
2014-05-06 16:59 ` [PATCH v3 2/7] thermal: armada: Add infrastructure to support generic formulas Ezequiel Garcia
@ 2014-05-15 0:07 ` Eduardo Valentin
0 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2014-05-15 0:07 UTC (permalink / raw)
To: Ezequiel Garcia
Cc: Zhang Rui, linux-pm, Jason Cooper, Thomas Petazzoni,
Gregory Clement, Tawfik Bayouk, Lior Amsalem, Andrew Lunn,
Sebastian Hesselbarth
Hello Ezequiel,
A minor change suggestion:
On Tue, May 06, 2014 at 01:59:46PM -0300, Ezequiel Garcia wrote:
> In order to support other similar SoC, with different sensor
> coeficients, this commit adds the coeficients to the per-variant
s/coeficient/coefficient/g
> structure, instead of having the formula hardcoded.
>
> Acked-by: Jason Cooper <jason@lakedaemon.net>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
> drivers/thermal/armada_thermal.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index c5db071..4de6e56 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -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,
No difference between armada370 and armadaxp extrapolation
formula?
> };
>
> static const struct of_device_id armada_thermal_id_table[] = {
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 3/7] thermal: armada: Add generic infrastructure to handle the sensor
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 1/7] thermal: armada: Rename armada_thermal_ops struct Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 2/7] thermal: armada: Add infrastructure to support generic formulas Ezequiel Garcia
@ 2014-05-06 16:59 ` Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 4/7] thermal: armada: Pass the platform_device to init_sensor() Ezequiel Garcia
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 16:59 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth, Ezequiel Garcia
In order to support similar SoC where the sensor value and valid
bit can have different shifts and/or mask, we add such fields to the
per-variant structure, instead of having the values hardcoded.
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/thermal/armada_thermal.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 4de6e56..2fecccf 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -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;
+
+ /* Register shift and mask to access the sensor temperature */
+ unsigned int temp_shift;
+ unsigned int temp_mask;
+ unsigned int is_valid_shift;
};
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_shift) & 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_shift) & 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_shift = 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_shift = 9,
+ .temp_shift = 10,
+ .temp_mask = 0x1ff,
.coef_b = 3153000000UL,
.coef_m = 10000000UL,
.coef_div = 13825,
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 4/7] thermal: armada: Pass the platform_device to init_sensor()
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
` (2 preceding siblings ...)
2014-05-06 16:59 ` [PATCH v3 3/7] thermal: armada: Add generic infrastructure to handle the sensor Ezequiel Garcia
@ 2014-05-06 16:59 ` Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 5/7] thermal: armada: Allow to specify an 'inverted readout' sensor Ezequiel Garcia
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 16:59 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth, 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.
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/thermal/armada_thermal.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 2fecccf..6fd6483 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -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_shift;
};
-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);
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 5/7] thermal: armada: Allow to specify an 'inverted readout' sensor
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
` (3 preceding siblings ...)
2014-05-06 16:59 ` [PATCH v3 4/7] thermal: armada: Pass the platform_device to init_sensor() Ezequiel Garcia
@ 2014-05-06 16:59 ` Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 6/7] thermal: armada: Support Armada 375 SoC Ezequiel Garcia
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 16:59 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth, 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.
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/thermal/armada_thermal.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 6fd6483..f84d9f0 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -56,6 +56,7 @@ struct armada_thermal_data {
unsigned long coef_b;
unsigned long coef_m;
unsigned long coef_div;
+ bool inverted;
/* Register shift and mask to access the sensor temperature */
unsigned int temp_shift;
@@ -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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 6/7] thermal: armada: Support Armada 375 SoC
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
` (4 preceding siblings ...)
2014-05-06 16:59 ` [PATCH v3 5/7] thermal: armada: Allow to specify an 'inverted readout' sensor Ezequiel Garcia
@ 2014-05-06 16:59 ` Ezequiel Garcia
2014-05-06 16:59 ` [PATCH v3 7/7] thermal: armada: Support Armada 380 SoC Ezequiel Garcia
2014-05-06 17:31 ` [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
7 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 16:59 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth, 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.
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
.../devicetree/bindings/thermal/armada-thermal.txt | 11 +++-
drivers/thermal/armada_thermal.c | 58 ++++++++++++++++++++++
2 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/thermal/armada-thermal.txt b/Documentation/devicetree/bindings/thermal/armada-thermal.txt
index fff93d5..2a67e51 100644
--- a/Documentation/devicetree/bindings/thermal/armada-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/armada-thermal.txt
@@ -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;
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index f84d9f0..e65c5e4 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -35,6 +35,15 @@
#define PMU_TDC0_OTF_CAL_MASK (0x1 << 30)
#define PMU_TDC0_START_CAL_MASK (0x1 << 25)
+#define A375_Z1_CAL_RESET_LSB 0x8011e214
+#define A375_Z1_CAL_RESET_MSB 0x30a88019
+#define A375_Z1_WORKAROUND_BIT BIT(9)
+
+#define A375_UNIT_CONTROL_SHIFT 27
+#define A375_UNIT_CONTROL_MASK 0x7
+#define A375_READOUT_INVERT BIT(15)
+#define A375_HW_RESETn BIT(8)
+
struct armada_thermal_data;
/* Marvell EBU Thermal Sensor Dev Structure */
@@ -110,6 +119,36 @@ static void armada370_init_sensor(struct platform_device *pdev,
mdelay(10);
}
+static void armada375_init_sensor(struct platform_device *pdev,
+ struct armada_thermal_priv *priv)
+{
+ unsigned long reg;
+ bool quirk_needed =
+ !!of_device_is_compatible(pdev->dev.of_node,
+ "marvell,armada375-z1-thermal");
+
+ if (quirk_needed) {
+ /* Ensure these registers have the default (reset) values */
+ writel(A375_Z1_CAL_RESET_LSB, priv->control);
+ writel(A375_Z1_CAL_RESET_MSB, priv->control + 0x4);
+ }
+
+ reg = readl(priv->control + 4);
+ reg &= ~(A375_UNIT_CONTROL_MASK << A375_UNIT_CONTROL_SHIFT);
+ reg &= ~A375_READOUT_INVERT;
+ reg &= ~A375_HW_RESETn;
+
+ if (quirk_needed)
+ reg |= A375_Z1_WORKAROUND_BIT;
+
+ writel(reg, priv->control + 4);
+ mdelay(20);
+
+ reg |= A375_HW_RESETn;
+ writel(reg, priv->control + 4);
+ mdelay(50);
+}
+
static bool armada_is_valid(struct armada_thermal_priv *priv)
{
unsigned long reg = readl_relaxed(priv->sensor);
@@ -170,6 +209,17 @@ static const struct armada_thermal_data armada370_data = {
.coef_div = 13825,
};
+static const struct armada_thermal_data armada375_data = {
+ .is_valid = armada_is_valid,
+ .init_sensor = armada375_init_sensor,
+ .is_valid_shift = 10,
+ .temp_shift = 0,
+ .temp_mask = 0x1ff,
+ .coef_b = 3171900000UL,
+ .coef_m = 10000000UL,
+ .coef_div = 13616,
+};
+
static const struct of_device_id armada_thermal_id_table[] = {
{
.compatible = "marvell,armadaxp-thermal",
@@ -180,6 +230,14 @@ static const struct of_device_id armada_thermal_id_table[] = {
.data = &armada370_data,
},
{
+ .compatible = "marvell,armada375-thermal",
+ .data = &armada375_data,
+ },
+ {
+ .compatible = "marvell,armada375-z1-thermal",
+ .data = &armada375_data,
+ },
+ {
/* sentinel */
},
};
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 7/7] thermal: armada: Support Armada 380 SoC
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
` (5 preceding siblings ...)
2014-05-06 16:59 ` [PATCH v3 6/7] thermal: armada: Support Armada 375 SoC Ezequiel Garcia
@ 2014-05-06 16:59 ` Ezequiel Garcia
2014-05-06 17:31 ` [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
7 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 16:59 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth, 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.
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
.../devicetree/bindings/thermal/armada-thermal.txt | 3 ++-
drivers/thermal/armada_thermal.c | 30 ++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/thermal/armada-thermal.txt b/Documentation/devicetree/bindings/thermal/armada-thermal.txt
index 2a67e51..4cf0249 100644
--- a/Documentation/devicetree/bindings/thermal/armada-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/armada-thermal.txt
@@ -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"
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index e65c5e4..9d1420a 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -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_shift = 10,
+ .temp_shift = 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 */
},
};
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3 0/7] thermal: Armada 375/380 SoC support
2014-05-06 16:59 [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
` (6 preceding siblings ...)
2014-05-06 16:59 ` [PATCH v3 7/7] thermal: armada: Support Armada 380 SoC Ezequiel Garcia
@ 2014-05-06 17:31 ` Ezequiel Garcia
2014-05-15 9:14 ` Zhang Rui
7 siblings, 1 reply; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:31 UTC (permalink / raw)
To: Zhang Rui, linux-pm
Cc: Jason Cooper, Thomas Petazzoni, Gregory Clement, Tawfik Bayouk,
Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth
Just a minor clarification:
On 06 May 01:59 PM, Ezequiel Garcia wrote:
> This patchset adds the support for the thermal sensor in the recently
> introduced Armada 375 and 38x SoC. Compared to the previous patchset
> version, only the driver changes are being sent now. The rest has been
> merged by Jason Cooper through the mvebu tree.
>
> There are other very minor changes from v2, see below.
>
> 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.
>
Of course, the current series end right here, in patch seven...
> 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.
>
.. the quirk patch has been already merged through mvebu.
Thanks and sorry for the noise!
Zhang: Any comments about the driver changes?
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 0/7] thermal: Armada 375/380 SoC support
2014-05-06 17:31 ` [PATCH v3 0/7] thermal: Armada 375/380 SoC support Ezequiel Garcia
@ 2014-05-15 9:14 ` Zhang Rui
0 siblings, 0 replies; 11+ messages in thread
From: Zhang Rui @ 2014-05-15 9:14 UTC (permalink / raw)
To: Ezequiel Garcia
Cc: linux-pm, Jason Cooper, Thomas Petazzoni, Gregory Clement,
Tawfik Bayouk, Lior Amsalem, Andrew Lunn, Sebastian Hesselbarth
On 二, 2014-05-06 at 14:31 -0300, Ezequiel Garcia wrote:
> Just a minor clarification:
>
> On 06 May 01:59 PM, Ezequiel Garcia wrote:
> > This patchset adds the support for the thermal sensor in the recently
> > introduced Armada 375 and 38x SoC. Compared to the previous patchset
> > version, only the driver changes are being sent now. The rest has been
> > merged by Jason Cooper through the mvebu tree.
> >
> > There are other very minor changes from v2, see below.
> >
> > 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.
> >
>
> Of course, the current series end right here, in patch seven...
>
> > 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.
> >
>
> .. the quirk patch has been already merged through mvebu.
>
> Thanks and sorry for the noise!
>
> Zhang: Any comments about the driver changes?
The whole series has been applied, with minor typo fix of patch 2/7,
according to Eduardo' comments.
thanks,
rui
^ permalink raw reply [flat|nested] 11+ messages in thread