* [PATCHv6 1/4] thermal: rcar_gen3_thermal: Document the R-Car Gen3
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
@ 2016-12-22 10:38 ` Niklas Söderlund
2016-12-22 10:38 ` [PATCHv6 2/4] thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver Niklas Söderlund
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Niklas Söderlund @ 2016-12-22 10:38 UTC (permalink / raw)
To: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto
Cc: linux-renesas-soc, Zhang Rui, Eduardo Valentin,
Geert Uytterhoeven, Hien Dang, Niklas Söderlund
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
.../bindings/thermal/rcar-gen3-thermal.txt | 56 ++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
diff --git a/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
new file mode 100644
index 000000000000..07a9713ae6a7
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
@@ -0,0 +1,56 @@
+* DT bindings for Renesas R-Car Gen3 Thermal Sensor driver
+
+On R-Car Gen3 SoCs, the thermal sensor controllers (TSC) control the thermal
+sensors (THS) which are the analog circuits for measuring temperature (Tj)
+inside the LSI.
+
+Required properties:
+- compatible : "renesas,<soctype>-thermal",
+ Examples with soctypes are:
+ - "renesas,r8a7795-thermal" (R-Car H3)
+ - "renesas,r8a7796-thermal" (R-Car M3-W)
+- reg : Address ranges of the thermal registers. Each sensor
+ needs one address range. Sorting must be done in
+ increasing order according to datasheet, i.e.
+ TSC1, TSC2, ...
+- clocks : Must contain a reference to the functional clock.
+- #thermal-sensor-cells : must be <1>.
+
+Optional properties:
+
+- interrupts : interrupts routed to the TSC (3 for H3 and M3-W)
+- power-domain : Must contain a reference to the power domain. This
+ property is mandatory if the thermal sensor instance
+ is part of a controllable power domain.
+
+Example:
+
+ tsc: thermal@e6198000 {
+ compatible = "renesas,r8a7795-thermal";
+ reg = <0 0xe6198000 0 0x68>,
+ <0 0xe61a0000 0 0x5c>,
+ <0 0xe61a8000 0 0x5c>;
+ interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 522>;
+ power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+ #thermal-sensor-cells = <1>;
+ status = "okay";
+ };
+
+ thermal-zones {
+ sensor_thermal1: sensor-thermal1 {
+ polling-delay-passive = <250>;
+ polling-delay = <1000>;
+ thermal-sensors = <&tsc 0>;
+
+ trips {
+ sensor1_crit: sensor1-crit {
+ temperature = <90000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+ };
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCHv6 2/4] thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
2016-12-22 10:38 ` [PATCHv6 1/4] thermal: rcar_gen3_thermal: Document the " Niklas Söderlund
@ 2016-12-22 10:38 ` Niklas Söderlund
2016-12-22 10:38 ` [PATCHv6 3/4] arm64: dts: r8a7795: Add R-Car Gen3 thermal support Niklas Söderlund
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Niklas Söderlund @ 2016-12-22 10:38 UTC (permalink / raw)
To: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto
Cc: linux-renesas-soc, Zhang Rui, Eduardo Valentin,
Geert Uytterhoeven, Hien Dang, Thao Nguyen, Niklas Söderlund
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Add support for R-Car Gen3 thermal sensors. Polling only for now,
interrupts will be added incrementally. Same goes for reading fuses.
This is documented already, but no hardware available for now.
Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
Signed-off-by: Thao Nguyen <thao.nguyen.yb@rvc.renesas.com>
Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
[Niklas: document and rework temperature calculation]
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/thermal/Kconfig | 9 +
drivers/thermal/Makefile | 1 +
drivers/thermal/rcar_gen3_thermal.c | 335 ++++++++++++++++++++++++++++++++++++
3 files changed, 345 insertions(+)
create mode 100644 drivers/thermal/rcar_gen3_thermal.c
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index a13541bdc726..da71f94d2d33 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -243,6 +243,15 @@ config RCAR_THERMAL
Enable this to plug the R-Car thermal sensor driver into the Linux
thermal framework.
+config RCAR_GEN3_THERMAL
+ tristate "Renesas R-Car Gen3 thermal driver"
+ depends on ARCH_RENESAS || COMPILE_TEST
+ depends on HAS_IOMEM
+ depends on OF
+ help
+ Enable this to plug the R-Car Gen3 thermal sensor driver into the Linux
+ thermal framework.
+
config KIRKWOOD_THERMAL
tristate "Temperature sensor on Marvell Kirkwood SoCs"
depends on MACH_KIRKWOOD || COMPILE_TEST
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index c92eb22a41ff..1216fb31ed40 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o
obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o
obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
+obj-$(CONFIG_RCAR_GEN3_THERMAL) += rcar_gen3_thermal.o
obj-$(CONFIG_KIRKWOOD_THERMAL) += kirkwood_thermal.o
obj-y += samsung/
obj-$(CONFIG_DOVE_THERMAL) += dove_thermal.o
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
new file mode 100644
index 000000000000..d33c845244b1
--- /dev/null
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -0,0 +1,335 @@
+/*
+ * R-Car Gen3 THS thermal sensor driver
+ * Based on rcar_thermal.c and work from Hien Dang and Khiem Nguyen.
+ *
+ * Copyright (C) 2016 Renesas Electronics Corporation.
+ * Copyright (C) 2016 Sang Engineering
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * 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/delay.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/thermal.h>
+
+/* Register offsets */
+#define REG_GEN3_IRQSTR 0x04
+#define REG_GEN3_IRQMSK 0x08
+#define REG_GEN3_IRQCTL 0x0C
+#define REG_GEN3_IRQEN 0x10
+#define REG_GEN3_IRQTEMP1 0x14
+#define REG_GEN3_IRQTEMP2 0x18
+#define REG_GEN3_IRQTEMP3 0x1C
+#define REG_GEN3_CTSR 0x20
+#define REG_GEN3_THCTR 0x20
+#define REG_GEN3_TEMP 0x28
+#define REG_GEN3_THCODE1 0x50
+#define REG_GEN3_THCODE2 0x54
+#define REG_GEN3_THCODE3 0x58
+
+/* CTSR bits */
+#define CTSR_PONM BIT(8)
+#define CTSR_AOUT BIT(7)
+#define CTSR_THBGR BIT(5)
+#define CTSR_VMEN BIT(4)
+#define CTSR_VMST BIT(1)
+#define CTSR_THSST BIT(0)
+
+/* THCTR bits */
+#define THCTR_PONM BIT(6)
+#define THCTR_THSST BIT(0)
+
+#define CTEMP_MASK 0xFFF
+
+#define MCELSIUS(temp) ((temp) * 1000)
+#define GEN3_FUSE_MASK 0xFFF
+
+#define TSC_MAX_NUM 3
+
+/* Structure for thermal temperature calculation */
+struct equation_coefs {
+ int a1;
+ int b1;
+ int a2;
+ int b2;
+};
+
+struct rcar_gen3_thermal_tsc {
+ void __iomem *base;
+ struct thermal_zone_device *zone;
+ struct equation_coefs coef;
+ struct mutex lock;
+};
+
+struct rcar_gen3_thermal_priv {
+ struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
+};
+
+struct rcar_gen3_thermal_data {
+ void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc);
+};
+
+static inline u32 rcar_gen3_thermal_read(struct rcar_gen3_thermal_tsc *tsc,
+ u32 reg)
+{
+ return ioread32(tsc->base + reg);
+}
+
+static inline void rcar_gen3_thermal_write(struct rcar_gen3_thermal_tsc *tsc,
+ u32 reg, u32 data)
+{
+ iowrite32(data, tsc->base + reg);
+}
+
+/*
+ * Linear approximation for temperature
+ *
+ * [reg] = [temp] * a + b => [temp] = ([reg] - b) / a
+ *
+ * The constants a and b are calculated using two triplets of int values PTAT
+ * and THCODE. PTAT and THCODE can either be read from hardware or use hard
+ * coded values from driver. The formula to calculate a and b are taken from
+ * BSP and sparsely documented and understood.
+ *
+ * Examining the linear formula and the formula used to calculate constants a
+ * and b while knowing that the span for PTAT and THCODE values are between
+ * 0x000 and 0xfff the largest integer possible is 0xfff * 0xfff == 0xffe001.
+ * Integer also needs to be signed so that leaves 7 bits for binary
+ * fixed point scaling.
+ */
+
+#define FIXPT_SHIFT 7
+#define FIXPT_INT(_x) ((_x) << FIXPT_SHIFT)
+#define FIXPT_DIV(_a, _b) DIV_ROUND_CLOSEST(((_a) << FIXPT_SHIFT), (_b))
+#define FIXPT_TO_MCELSIUS(_x) ((_x) * 1000 >> FIXPT_SHIFT)
+
+#define RCAR3_THERMAL_GRAN 500 /* mili Celsius */
+
+/* no idea where these constants come from */
+#define TJ_1 96
+#define TJ_3 -41
+
+static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef,
+ int *ptat, int *thcode)
+{
+ int tj_2;
+
+ /* TODO: Find documentation and document constant calculation formula */
+
+ /*
+ * Division is not scaled in BSP and if scaled it might overflow
+ * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled
+ */
+ tj_2 = (FIXPT_INT((ptat[1] - ptat[2]) * 137)
+ / (ptat[0] - ptat[2])) - FIXPT_INT(41);
+
+ coef->a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]),
+ tj_2 - FIXPT_INT(TJ_3));
+ coef->b1 = FIXPT_INT(thcode[2]) - coef->a1 * TJ_3;
+
+ coef->a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]),
+ tj_2 - FIXPT_INT(TJ_1));
+ coef->b2 = FIXPT_INT(thcode[0]) - coef->a2 * TJ_1;
+}
+
+static int rcar_gen3_thermal_round(int temp)
+{
+ int result, round_offs;
+
+ round_offs = temp >= 0 ? RCAR3_THERMAL_GRAN / 2 :
+ -RCAR3_THERMAL_GRAN / 2;
+ result = (temp + round_offs) / RCAR3_THERMAL_GRAN;
+ return result * RCAR3_THERMAL_GRAN;
+}
+
+static int rcar_gen3_thermal_get_temp(void *devdata, int *temp)
+{
+ struct rcar_gen3_thermal_tsc *tsc = devdata;
+ int mcelsius, val1, val2;
+ u32 reg;
+
+ /* Read register and convert to mili Celsius */
+ mutex_lock(&tsc->lock);
+
+ reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK;
+
+ val1 = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1, tsc->coef.a1);
+ val2 = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2, tsc->coef.a2);
+ mcelsius = FIXPT_TO_MCELSIUS((val1 + val2) / 2);
+
+ mutex_unlock(&tsc->lock);
+
+ /* Make sure we are inside specifications */
+ if ((mcelsius < MCELSIUS(-40)) || (mcelsius > MCELSIUS(125)))
+ return -EIO;
+
+ /* Round value to device granularity setting */
+ *temp = rcar_gen3_thermal_round(mcelsius);
+
+ return 0;
+}
+
+static struct thermal_zone_of_device_ops rcar_gen3_tz_of_ops = {
+ .get_temp = rcar_gen3_thermal_get_temp,
+};
+
+static void r8a7795_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
+{
+ rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR);
+ rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0);
+
+ usleep_range(1000, 2000);
+
+ rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_PONM);
+ rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F);
+ rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR,
+ CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN);
+
+ usleep_range(100, 200);
+
+ rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR,
+ CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN |
+ CTSR_VMST | CTSR_THSST);
+
+ usleep_range(1000, 2000);
+}
+
+static void r8a7796_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
+{
+ u32 reg_val;
+
+ reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR);
+ reg_val &= ~THCTR_PONM;
+ rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val);
+
+ usleep_range(1000, 2000);
+
+ rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F);
+ reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR);
+ reg_val |= THCTR_THSST;
+ rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val);
+}
+
+static const struct rcar_gen3_thermal_data r8a7795_data = {
+ .thermal_init = r8a7795_thermal_init,
+};
+
+static const struct rcar_gen3_thermal_data r8a7796_data = {
+ .thermal_init = r8a7796_thermal_init,
+};
+
+static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
+ { .compatible = "renesas,r8a7795-thermal", .data = &r8a7795_data},
+ { .compatible = "renesas,r8a7796-thermal", .data = &r8a7796_data},
+ {},
+};
+MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids);
+
+static int rcar_gen3_thermal_remove(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+
+ pm_runtime_put(dev);
+ pm_runtime_disable(dev);
+
+ return 0;
+}
+
+static int rcar_gen3_thermal_probe(struct platform_device *pdev)
+{
+ struct rcar_gen3_thermal_priv *priv;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ struct thermal_zone_device *zone;
+ int ret, i;
+ const struct rcar_gen3_thermal_data *match_data =
+ of_device_get_match_data(dev);
+
+ /* default values if FUSEs are missing */
+ /* TODO: Read values from hardware on supported platforms */
+ int ptat[3] = { 2351, 1509, 435 };
+ int thcode[TSC_MAX_NUM][3] = {
+ { 3248, 2800, 2221 },
+ { 3245, 2795, 2216 },
+ { 3250, 2805, 2237 },
+ };
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, priv);
+
+ pm_runtime_enable(dev);
+ pm_runtime_get_sync(dev);
+
+ for (i = 0; i < TSC_MAX_NUM; i++) {
+ struct rcar_gen3_thermal_tsc *tsc;
+
+ tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL);
+ if (!tsc) {
+ ret = -ENOMEM;
+ goto error_unregister;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, i);
+ if (!res)
+ break;
+
+ tsc->base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(tsc->base)) {
+ ret = PTR_ERR(tsc->base);
+ goto error_unregister;
+ }
+
+ priv->tscs[i] = tsc;
+ mutex_init(&tsc->lock);
+
+ match_data->thermal_init(tsc);
+ rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]);
+
+ zone = devm_thermal_zone_of_sensor_register(dev, i, tsc,
+ &rcar_gen3_tz_of_ops);
+ if (IS_ERR(zone)) {
+ dev_err(dev, "Can't register thermal zone\n");
+ ret = PTR_ERR(zone);
+ goto error_unregister;
+ }
+ tsc->zone = zone;
+ }
+
+ return 0;
+
+error_unregister:
+ rcar_gen3_thermal_remove(pdev);
+
+ return ret;
+}
+
+static struct platform_driver rcar_gen3_thermal_driver = {
+ .driver = {
+ .name = "rcar_gen3_thermal",
+ .of_match_table = rcar_gen3_thermal_dt_ids,
+ },
+ .probe = rcar_gen3_thermal_probe,
+ .remove = rcar_gen3_thermal_remove,
+};
+module_platform_driver(rcar_gen3_thermal_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("R-Car Gen3 THS thermal sensor driver");
+MODULE_AUTHOR("Wolfram Sang <wsa+renesas@sang-engineering.com>");
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCHv6 3/4] arm64: dts: r8a7795: Add R-Car Gen3 thermal support
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
2016-12-22 10:38 ` [PATCHv6 1/4] thermal: rcar_gen3_thermal: Document the " Niklas Söderlund
2016-12-22 10:38 ` [PATCHv6 2/4] thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver Niklas Söderlund
@ 2016-12-22 10:38 ` Niklas Söderlund
2016-12-22 10:38 ` [PATCHv6 4/4] arm64: dts: r8a7796: " Niklas Söderlund
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Niklas Söderlund @ 2016-12-22 10:38 UTC (permalink / raw)
To: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto
Cc: linux-renesas-soc, Zhang Rui, Eduardo Valentin,
Geert Uytterhoeven, Hien Dang, Thao Nguyen, Niklas Söderlund
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
Signed-off-by: Thao Nguyen <thao.nguyen.yb@rvc.renesas.com>
Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
arch/arm64/boot/dts/renesas/r8a7795.dtsi | 58 ++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index 8c15040f2540..0699e04fbdf2 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1541,5 +1541,63 @@
};
};
};
+
+ tsc: thermal@e6198000 {
+ compatible = "renesas,r8a7795-thermal";
+ reg = <0 0xe6198000 0 0x68>,
+ <0 0xe61a0000 0 0x5c>,
+ <0 0xe61a8000 0 0x5c>;
+ interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 522>;
+ power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+ #thermal-sensor-cells = <1>;
+ status = "okay";
+ };
+
+ thermal-zones {
+ sensor_thermal1: sensor-thermal1 {
+ polling-delay-passive = <250>;
+ polling-delay = <1000>;
+ thermal-sensors = <&tsc 0>;
+
+ trips {
+ sensor1_crit: sensor1-crit {
+ temperature = <90000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ sensor_thermal2: sensor-thermal2 {
+ polling-delay-passive = <250>;
+ polling-delay = <1000>;
+ thermal-sensors = <&tsc 1>;
+
+ trips {
+ sensor2_crit: sensor2-crit {
+ temperature = <90000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ sensor_thermal3: sensor-thermal3 {
+ polling-delay-passive = <250>;
+ polling-delay = <1000>;
+ thermal-sensors = <&tsc 2>;
+
+ trips {
+ sensor3_crit: sensor3-crit {
+ temperature = <90000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+ };
};
};
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCHv6 4/4] arm64: dts: r8a7796: Add R-Car Gen3 thermal support
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
` (2 preceding siblings ...)
2016-12-22 10:38 ` [PATCHv6 3/4] arm64: dts: r8a7795: Add R-Car Gen3 thermal support Niklas Söderlund
@ 2016-12-22 10:38 ` Niklas Söderlund
2016-12-23 11:02 ` [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Wolfram Sang
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Niklas Söderlund @ 2016-12-22 10:38 UTC (permalink / raw)
To: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto
Cc: linux-renesas-soc, Zhang Rui, Eduardo Valentin,
Geert Uytterhoeven, Hien Dang, Thao Nguyen, Niklas Söderlund
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
Signed-off-by: Thao Nguyen <thao.nguyen.yb@rvc.renesas.com>
Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
arch/arm64/boot/dts/renesas/r8a7796.dtsi | 58 ++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index 9217da983525..5261f0f77ce2 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -251,5 +251,63 @@
power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
status = "disabled";
};
+
+ tsc: thermal@e6198000 {
+ compatible = "renesas,r8a7796-thermal";
+ reg = <0 0xe6198000 0 0x68>,
+ <0 0xe61a0000 0 0x5c>,
+ <0 0xe61a8000 0 0x5c>;
+ interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 522>;
+ power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+ #thermal-sensor-cells = <1>;
+ status = "okay";
+ };
+
+ thermal-zones {
+ sensor_thermal1: sensor-thermal1 {
+ polling-delay-passive = <250>;
+ polling-delay = <1000>;
+ thermal-sensors = <&tsc 0>;
+
+ trips {
+ sensor1_crit: sensor1-crit {
+ temperature = <90000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ sensor_thermal2: sensor-thermal2 {
+ polling-delay-passive = <250>;
+ polling-delay = <1000>;
+ thermal-sensors = <&tsc 1>;
+
+ trips {
+ sensor2_crit: sensor2-crit {
+ temperature = <90000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ sensor_thermal3: sensor-thermal3 {
+ polling-delay-passive = <250>;
+ polling-delay = <1000>;
+ thermal-sensors = <&tsc 2>;
+
+ trips {
+ sensor3_crit: sensor3-crit {
+ temperature = <90000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+ };
};
};
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCHv6 0/4] thermal: add driver for R-Car Gen3
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
` (3 preceding siblings ...)
2016-12-22 10:38 ` [PATCHv6 4/4] arm64: dts: r8a7796: " Niklas Söderlund
@ 2016-12-23 11:02 ` Wolfram Sang
2017-01-04 23:41 ` Wolfram Sang
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2016-12-23 11:02 UTC (permalink / raw)
To: Niklas Söderlund
Cc: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto,
linux-renesas-soc, Zhang Rui, Eduardo Valentin,
Geert Uytterhoeven
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
> Changes since v5
> - Switch fixpoint scaling from decimal with a factor 100 to binary with
> a shift of 7 bits to increase accuracy. In v5 decimal scaling was used
> since it closest resembled the v4 implementation of a decimal scaling
> with 1000 as a factor. The big change in v5 was to fit all
> calculations inside a int instead of s64.
Pity, I couldn't test it on HW before leaving for christmas. Will
definately do when I come back!
Thanks for this update!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCHv6 0/4] thermal: add driver for R-Car Gen3
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
` (4 preceding siblings ...)
2016-12-23 11:02 ` [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Wolfram Sang
@ 2017-01-04 23:41 ` Wolfram Sang
2017-01-19 12:19 ` Wolfram Sang
2017-01-20 4:31 ` Eduardo Valentin
7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2017-01-04 23:41 UTC (permalink / raw)
To: Niklas Söderlund
Cc: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto,
linux-renesas-soc, Zhang Rui, Eduardo Valentin,
Geert Uytterhoeven
On Thu, Dec 22, 2016 at 11:38:19AM +0100, Niklas Söderlund wrote:
> Hi all,
>
> The series adds thermal support to Renesas R-Car Gen3 SoCs. It's tested
> on Salvator-X H3 and M3-W SoC.
>
> Wolfram asked me to have a look at the comments for v4 and to try and
> rework the temperature formulas to work with only ints and if it worked
> out resend the series. I have reworked code in 2/4 but kept Wolfram as
> the author and added my SoB, hope this is OK.
>
> Reworking the formulas involved moving from s64 to int as the data type
> used to store coefficients used in binary scaled fixed point
> calculations. By examining the largest values which could be produced in
> these calculations a shift of 7 is the maximum scaling which is
> possible and still fit inside an int, previously with s64 the decimal scaling
> was 1000.
>
> Changing the decimal scaling also reduces the accuracy of the
> calculations. In my tests this was hardly noticeable as the granularity
> of the reported temperature to user-space is 0.5C, comparing the value
> reported in the s64 vs int implementation only differ very slightly when
> it rounded the value to the next 0.5C level.
>
> However the formulas used to calculate the coefficients are not
> documented and none obvious (at lest not to me) so given different
> initial values to calculate the coefficients the error might become
> larger. Therefore I would like to ask Morimoto-san and/or Khiem to
> provide or proxy testing of this less accurate formula and feedback if
> it's OK, let me know if there is anything I can do to help out.
Tested on H3 and M3-W. The temperatures I get when plugging the fan
on/off are very very similar to previous versions of this driver. Thus:
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCHv6 0/4] thermal: add driver for R-Car Gen3
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
` (5 preceding siblings ...)
2017-01-04 23:41 ` Wolfram Sang
@ 2017-01-19 12:19 ` Wolfram Sang
2017-01-20 4:31 ` Eduardo Valentin
7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2017-01-19 12:19 UTC (permalink / raw)
To: Niklas Söderlund
Cc: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto,
linux-renesas-soc, Zhang Rui, Eduardo Valentin,
Geert Uytterhoeven
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
> larger. Therefore I would like to ask Morimoto-san and/or Khiem to
> provide or proxy testing of this less accurate formula and feedback if
> it's OK, let me know if there is anything I can do to help out.
We now got the results of Renesas internal testing via internal
channels. So, for this series:
Tested-by: Hien Dang <hien.dang.eb@renesas.com>
So, from our point of view, this series is ready to go upstream. 4.11
would be most welcome.
Thanks,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCHv6 0/4] thermal: add driver for R-Car Gen3
2016-12-22 10:38 [PATCHv6 0/4] thermal: add driver for R-Car Gen3 Niklas Söderlund
` (6 preceding siblings ...)
2017-01-19 12:19 ` Wolfram Sang
@ 2017-01-20 4:31 ` Eduardo Valentin
2017-01-20 7:13 ` Niklas Söderlund
2017-01-20 11:20 ` Wolfram Sang
7 siblings, 2 replies; 11+ messages in thread
From: Eduardo Valentin @ 2017-01-20 4:31 UTC (permalink / raw)
To: Niklas Söderlund
Cc: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto,
linux-renesas-soc, Zhang Rui, Geert Uytterhoeven
On Thu, Dec 22, 2016 at 11:38:19AM +0100, Niklas Söderlund wrote:
> Hi all,
>
Add this to my tree and to my linux-next branch. However, as usual, I am
taking the driver+docs, the dt binding must go through your arch tree,
to avoid conflicts. And you my add my
Acked-by: Eduardo Valentin <edubezval@gmail.com>
>
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCHv6 0/4] thermal: add driver for R-Car Gen3
2017-01-20 4:31 ` Eduardo Valentin
@ 2017-01-20 7:13 ` Niklas Söderlund
2017-01-20 11:20 ` Wolfram Sang
1 sibling, 0 replies; 11+ messages in thread
From: Niklas Söderlund @ 2017-01-20 7:13 UTC (permalink / raw)
To: Eduardo Valentin
Cc: linux-pm, Wolfram Sang, Khiem Nguyen, Kuninori Morimoto,
linux-renesas-soc, Zhang Rui, Geert Uytterhoeven
Hi Eduardo,
On 2017-01-19 20:31:03 -0800, Eduardo Valentin wrote:
> On Thu, Dec 22, 2016 at 11:38:19AM +0100, Niklas Söderlund wrote:
> > Hi all,
> >
>
> Add this to my tree and to my linux-next branch. However, as usual, I am
> taking the driver+docs, the dt binding must go through your arch tree,
> to avoid conflicts. And you my add my
>
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
Thanks!
>
> >
> > --
> > 2.11.0
> >
--
Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCHv6 0/4] thermal: add driver for R-Car Gen3
2017-01-20 4:31 ` Eduardo Valentin
2017-01-20 7:13 ` Niklas Söderlund
@ 2017-01-20 11:20 ` Wolfram Sang
1 sibling, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2017-01-20 11:20 UTC (permalink / raw)
To: Eduardo Valentin
Cc: Niklas Söderlund, linux-pm, Wolfram Sang, Khiem Nguyen,
Kuninori Morimoto, linux-renesas-soc, Zhang Rui,
Geert Uytterhoeven
> Add this to my tree and to my linux-next branch. However, as usual, I am
Thanks!
> taking the driver+docs, the dt binding must go through your arch tree,
Yes, sure. I do the same in the I2C subsystem.
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
Done. Will resend the DTS patches in a minute.
^ permalink raw reply [flat|nested] 11+ messages in thread