All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4
@ 2019-11-01 13:42 ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-pm, devicetree, Stefan Wahren

This series enables thermal support for the Raspberry Pi 4. Neither the
bcm2835_thermal nor the brcmstb_thermal are suitable for the BCM2711.
So add a new thermal driver to read out the SoC temperature from the
AVS RO block of the BCM2711.

Stefan Wahren (4):
  dt-bindings: Add BCM2711 thermal
  thermal: Add BCM2711 thermal driver
  ARM: dts: bcm2711: Enable thermal
  ARM: configs: Build BCM2711 thermal as module

 .../bindings/thermal/brcm,bcm2711-thermal.txt      |  39 ++++++
 arch/arm/boot/dts/bcm2711.dtsi                     |   9 ++
 arch/arm/configs/multi_v7_defconfig                |   1 +
 arch/arm64/configs/defconfig                       |   1 +
 drivers/thermal/broadcom/Kconfig                   |   8 ++
 drivers/thermal/broadcom/Makefile                  |   1 +
 drivers/thermal/broadcom/bcm2711_thermal.c         | 146 +++++++++++++++++++++
 7 files changed, 205 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
 create mode 100644 drivers/thermal/broadcom/bcm2711_thermal.c

--
2.7.4


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

* [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4
@ 2019-11-01 13:42 ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, linux-pm, bcm-kernel-feedback-list, Stefan Wahren,
	Chen-Yu Tsai, linux-arm-kernel

This series enables thermal support for the Raspberry Pi 4. Neither the
bcm2835_thermal nor the brcmstb_thermal are suitable for the BCM2711.
So add a new thermal driver to read out the SoC temperature from the
AVS RO block of the BCM2711.

Stefan Wahren (4):
  dt-bindings: Add BCM2711 thermal
  thermal: Add BCM2711 thermal driver
  ARM: dts: bcm2711: Enable thermal
  ARM: configs: Build BCM2711 thermal as module

 .../bindings/thermal/brcm,bcm2711-thermal.txt      |  39 ++++++
 arch/arm/boot/dts/bcm2711.dtsi                     |   9 ++
 arch/arm/configs/multi_v7_defconfig                |   1 +
 arch/arm64/configs/defconfig                       |   1 +
 drivers/thermal/broadcom/Kconfig                   |   8 ++
 drivers/thermal/broadcom/Makefile                  |   1 +
 drivers/thermal/broadcom/bcm2711_thermal.c         | 146 +++++++++++++++++++++
 7 files changed, 205 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
 create mode 100644 drivers/thermal/broadcom/bcm2711_thermal.c

--
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/4] dt-bindings: Add BCM2711 thermal
  2019-11-01 13:42 ` Stefan Wahren
@ 2019-11-01 13:42   ` Stefan Wahren
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-pm, devicetree, Stefan Wahren

Since the BCM2711 doesn't have a AVS TMON block, the thermal information
must be retrieved from the AVS ring oscillator block. So add a new
suitable binding.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 .../bindings/thermal/brcm,bcm2711-thermal.txt      | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt

diff --git a/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
new file mode 100644
index 0000000..5531d3f
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
@@ -0,0 +1,39 @@
+Binding for Thermal Sensor driver for BCM2711 SoCs.
+
+Required properties:
+- compatible:		must be: "brcm,bcm2711-thermal"
+- reg:			Address range of the thermal registers.
+- clocks:		Phandle of the clock used by the thermal sensor.
+- #thermal-sensor-cells:	should be 0 (see thermal.txt)
+
+Example:
+
+thermal-zones {
+	cpu_thermal: cpu-thermal {
+		polling-delay-passive = <0>;
+		polling-delay = <1000>;
+
+		thermal-sensors = <&thermal>;
+
+		trips {
+			cpu-crit {
+				temperature	= <80000>;
+				hysteresis	= <0>;
+				type		= "critical";
+			};
+		};
+
+		coefficients = <(-487)  410040>;
+
+		cooling-maps {
+		};
+	};
+};
+
+thermal@7d5d2200 {
+	compatible = "brcm,bcm2711-thermal";
+	reg = <0x7d5d2200 0x4>;
+	clocks = <&clocks BCM2835_CLOCK_TSENS>;
+	#thermal-sensor-cells = <0>;
+};
+
--
2.7.4


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

* [PATCH 1/4] dt-bindings: Add BCM2711 thermal
@ 2019-11-01 13:42   ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, linux-pm, bcm-kernel-feedback-list, Stefan Wahren,
	Chen-Yu Tsai, linux-arm-kernel

Since the BCM2711 doesn't have a AVS TMON block, the thermal information
must be retrieved from the AVS ring oscillator block. So add a new
suitable binding.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 .../bindings/thermal/brcm,bcm2711-thermal.txt      | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt

diff --git a/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
new file mode 100644
index 0000000..5531d3f
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
@@ -0,0 +1,39 @@
+Binding for Thermal Sensor driver for BCM2711 SoCs.
+
+Required properties:
+- compatible:		must be: "brcm,bcm2711-thermal"
+- reg:			Address range of the thermal registers.
+- clocks:		Phandle of the clock used by the thermal sensor.
+- #thermal-sensor-cells:	should be 0 (see thermal.txt)
+
+Example:
+
+thermal-zones {
+	cpu_thermal: cpu-thermal {
+		polling-delay-passive = <0>;
+		polling-delay = <1000>;
+
+		thermal-sensors = <&thermal>;
+
+		trips {
+			cpu-crit {
+				temperature	= <80000>;
+				hysteresis	= <0>;
+				type		= "critical";
+			};
+		};
+
+		coefficients = <(-487)  410040>;
+
+		cooling-maps {
+		};
+	};
+};
+
+thermal@7d5d2200 {
+	compatible = "brcm,bcm2711-thermal";
+	reg = <0x7d5d2200 0x4>;
+	clocks = <&clocks BCM2835_CLOCK_TSENS>;
+	#thermal-sensor-cells = <0>;
+};
+
--
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/4] thermal: Add BCM2711 thermal driver
  2019-11-01 13:42 ` Stefan Wahren
@ 2019-11-01 13:42   ` Stefan Wahren
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-pm, devicetree, Stefan Wahren

This adds the thermal sensor driver for the Broadcom BCM2711 SoC,
which is placed on the Raspberry Pi 4. The driver only provides
SoC temperature reading so far.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/thermal/broadcom/Kconfig           |   8 ++
 drivers/thermal/broadcom/Makefile          |   1 +
 drivers/thermal/broadcom/bcm2711_thermal.c | 146 +++++++++++++++++++++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 drivers/thermal/broadcom/bcm2711_thermal.c

diff --git a/drivers/thermal/broadcom/Kconfig b/drivers/thermal/broadcom/Kconfig
index cf43e15..b970295 100644
--- a/drivers/thermal/broadcom/Kconfig
+++ b/drivers/thermal/broadcom/Kconfig
@@ -1,4 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config BCM2711_THERMAL
+	tristate "Broadcom AVS RO thermal sensor driver"
+	depends on ARCH_BCM2835 || COMPILE_TEST
+	depends on HAS_IOMEM
+	depends on THERMAL_OF
+	help
+	  Support for thermal sensors on Broadcom BCM2711 SoCs.
+
 config BCM2835_THERMAL
 	tristate "Thermal sensors on bcm2835 SoC"
 	depends on ARCH_BCM2835 || COMPILE_TEST
diff --git a/drivers/thermal/broadcom/Makefile b/drivers/thermal/broadcom/Makefile
index 490ab1f..c917b24 100644
--- a/drivers/thermal/broadcom/Makefile
+++ b/drivers/thermal/broadcom/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_BCM2711_THERMAL)		+= bcm2711_thermal.o
 obj-$(CONFIG_BCM2835_THERMAL)		+= bcm2835_thermal.o
 obj-$(CONFIG_BRCMSTB_THERMAL)		+= brcmstb_thermal.o
 obj-$(CONFIG_BCM_NS_THERMAL)		+= ns-thermal.o
diff --git a/drivers/thermal/broadcom/bcm2711_thermal.c b/drivers/thermal/broadcom/bcm2711_thermal.c
new file mode 100644
index 0000000..214a305
--- /dev/null
+++ b/drivers/thermal/broadcom/bcm2711_thermal.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Broadcom AVS RO thermal sensor driver
+ *
+ * based on brcmstb_thermal
+ *
+ * Copyright (C) 2019 Stefan Wahren
+ */
+
+#include <linux/bitops.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of_device.h>
+#include <linux/thermal.h>
+
+#include "../thermal_hwmon.h"
+
+#define AVS_RO_TEMP_STATUS		0x00
+ #define AVS_RO_TEMP_STATUS_valid_msk	(BIT(16) | BIT(10))
+ #define AVS_RO_TEMP_STATUS_data_msk	GENMASK(9, 0)
+
+struct bcm2711_thermal_priv {
+	void __iomem *base;
+	struct device *dev;
+	struct clk *clk;
+	struct thermal_zone_device *thermal;
+};
+
+static int bcm2711_get_temp(void *data, int *temp)
+{
+	struct bcm2711_thermal_priv *priv = data;
+	int slope = thermal_zone_get_slope(priv->thermal);
+	int offset = thermal_zone_get_offset(priv->thermal);
+	u32 val;
+	long t;
+
+	val = __raw_readl(priv->base + AVS_RO_TEMP_STATUS);
+
+	if (!(val & AVS_RO_TEMP_STATUS_valid_msk)) {
+		dev_err(priv->dev, "reading not valid\n");
+		return -EIO;
+	}
+
+	val &= AVS_RO_TEMP_STATUS_data_msk;
+
+	/* Convert a HW code to a temperature reading (millidegree celsius) */
+	t = slope * val + offset;
+	if (t < 0)
+		*temp = 0;
+	else
+		*temp = t;
+
+	return 0;
+}
+
+static const struct thermal_zone_of_device_ops bcm2711_thermal_of_ops = {
+	.get_temp	= bcm2711_get_temp,
+};
+
+static const struct of_device_id bcm2711_thermal_id_table[] = {
+	{ .compatible = "brcm,bcm2711-thermal" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, bcm2711_thermal_id_table);
+
+static int bcm2711_thermal_probe(struct platform_device *pdev)
+{
+	struct thermal_zone_device *thermal;
+	struct bcm2711_thermal_priv *priv;
+	struct resource *res;
+	int ret;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	priv->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
+
+	priv->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(priv->clk)) {
+		ret = PTR_ERR(priv->clk);
+		if (ret != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "could not get clk: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(priv->clk);
+	if (ret)
+		return ret;
+
+	priv->dev = &pdev->dev;
+	platform_set_drvdata(pdev, priv);
+
+	thermal = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, priv,
+						       &bcm2711_thermal_of_ops);
+	if (IS_ERR(thermal)) {
+		ret = PTR_ERR(thermal);
+		dev_err(&pdev->dev, "could not register sensor: %d\n", ret);
+		goto err_clk;
+	}
+
+	priv->thermal = thermal;
+
+	thermal->tzp->no_hwmon = false;
+	ret = thermal_add_hwmon_sysfs(thermal);
+	if (ret)
+		return ret;
+
+	return 0;
+
+err_clk:
+	clk_disable_unprepare(priv->clk);
+
+	return ret;
+}
+
+static int bcm2711_thermal_remove(struct platform_device *pdev)
+{
+	struct bcm2711_thermal_priv *priv = platform_get_drvdata(pdev);
+
+	clk_disable_unprepare(priv->clk);
+
+	return 0;
+}
+
+static struct platform_driver bcm2711_thermal_driver = {
+	.probe = bcm2711_thermal_probe,
+	.remove = bcm2711_thermal_remove,
+	.driver = {
+		.name = "bcm2711_thermal",
+		.of_match_table = bcm2711_thermal_id_table,
+	},
+};
+module_platform_driver(bcm2711_thermal_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Stefan Wahren");
+MODULE_DESCRIPTION("Broadcom AVS RO thermal sensor driver");
--
2.7.4


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

* [PATCH 2/4] thermal: Add BCM2711 thermal driver
@ 2019-11-01 13:42   ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, linux-pm, bcm-kernel-feedback-list, Stefan Wahren,
	Chen-Yu Tsai, linux-arm-kernel

This adds the thermal sensor driver for the Broadcom BCM2711 SoC,
which is placed on the Raspberry Pi 4. The driver only provides
SoC temperature reading so far.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/thermal/broadcom/Kconfig           |   8 ++
 drivers/thermal/broadcom/Makefile          |   1 +
 drivers/thermal/broadcom/bcm2711_thermal.c | 146 +++++++++++++++++++++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 drivers/thermal/broadcom/bcm2711_thermal.c

diff --git a/drivers/thermal/broadcom/Kconfig b/drivers/thermal/broadcom/Kconfig
index cf43e15..b970295 100644
--- a/drivers/thermal/broadcom/Kconfig
+++ b/drivers/thermal/broadcom/Kconfig
@@ -1,4 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config BCM2711_THERMAL
+	tristate "Broadcom AVS RO thermal sensor driver"
+	depends on ARCH_BCM2835 || COMPILE_TEST
+	depends on HAS_IOMEM
+	depends on THERMAL_OF
+	help
+	  Support for thermal sensors on Broadcom BCM2711 SoCs.
+
 config BCM2835_THERMAL
 	tristate "Thermal sensors on bcm2835 SoC"
 	depends on ARCH_BCM2835 || COMPILE_TEST
diff --git a/drivers/thermal/broadcom/Makefile b/drivers/thermal/broadcom/Makefile
index 490ab1f..c917b24 100644
--- a/drivers/thermal/broadcom/Makefile
+++ b/drivers/thermal/broadcom/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_BCM2711_THERMAL)		+= bcm2711_thermal.o
 obj-$(CONFIG_BCM2835_THERMAL)		+= bcm2835_thermal.o
 obj-$(CONFIG_BRCMSTB_THERMAL)		+= brcmstb_thermal.o
 obj-$(CONFIG_BCM_NS_THERMAL)		+= ns-thermal.o
diff --git a/drivers/thermal/broadcom/bcm2711_thermal.c b/drivers/thermal/broadcom/bcm2711_thermal.c
new file mode 100644
index 0000000..214a305
--- /dev/null
+++ b/drivers/thermal/broadcom/bcm2711_thermal.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Broadcom AVS RO thermal sensor driver
+ *
+ * based on brcmstb_thermal
+ *
+ * Copyright (C) 2019 Stefan Wahren
+ */
+
+#include <linux/bitops.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of_device.h>
+#include <linux/thermal.h>
+
+#include "../thermal_hwmon.h"
+
+#define AVS_RO_TEMP_STATUS		0x00
+ #define AVS_RO_TEMP_STATUS_valid_msk	(BIT(16) | BIT(10))
+ #define AVS_RO_TEMP_STATUS_data_msk	GENMASK(9, 0)
+
+struct bcm2711_thermal_priv {
+	void __iomem *base;
+	struct device *dev;
+	struct clk *clk;
+	struct thermal_zone_device *thermal;
+};
+
+static int bcm2711_get_temp(void *data, int *temp)
+{
+	struct bcm2711_thermal_priv *priv = data;
+	int slope = thermal_zone_get_slope(priv->thermal);
+	int offset = thermal_zone_get_offset(priv->thermal);
+	u32 val;
+	long t;
+
+	val = __raw_readl(priv->base + AVS_RO_TEMP_STATUS);
+
+	if (!(val & AVS_RO_TEMP_STATUS_valid_msk)) {
+		dev_err(priv->dev, "reading not valid\n");
+		return -EIO;
+	}
+
+	val &= AVS_RO_TEMP_STATUS_data_msk;
+
+	/* Convert a HW code to a temperature reading (millidegree celsius) */
+	t = slope * val + offset;
+	if (t < 0)
+		*temp = 0;
+	else
+		*temp = t;
+
+	return 0;
+}
+
+static const struct thermal_zone_of_device_ops bcm2711_thermal_of_ops = {
+	.get_temp	= bcm2711_get_temp,
+};
+
+static const struct of_device_id bcm2711_thermal_id_table[] = {
+	{ .compatible = "brcm,bcm2711-thermal" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, bcm2711_thermal_id_table);
+
+static int bcm2711_thermal_probe(struct platform_device *pdev)
+{
+	struct thermal_zone_device *thermal;
+	struct bcm2711_thermal_priv *priv;
+	struct resource *res;
+	int ret;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	priv->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
+
+	priv->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(priv->clk)) {
+		ret = PTR_ERR(priv->clk);
+		if (ret != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "could not get clk: %d\n", ret);
+		return ret;
+	}
+
+	ret = clk_prepare_enable(priv->clk);
+	if (ret)
+		return ret;
+
+	priv->dev = &pdev->dev;
+	platform_set_drvdata(pdev, priv);
+
+	thermal = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, priv,
+						       &bcm2711_thermal_of_ops);
+	if (IS_ERR(thermal)) {
+		ret = PTR_ERR(thermal);
+		dev_err(&pdev->dev, "could not register sensor: %d\n", ret);
+		goto err_clk;
+	}
+
+	priv->thermal = thermal;
+
+	thermal->tzp->no_hwmon = false;
+	ret = thermal_add_hwmon_sysfs(thermal);
+	if (ret)
+		return ret;
+
+	return 0;
+
+err_clk:
+	clk_disable_unprepare(priv->clk);
+
+	return ret;
+}
+
+static int bcm2711_thermal_remove(struct platform_device *pdev)
+{
+	struct bcm2711_thermal_priv *priv = platform_get_drvdata(pdev);
+
+	clk_disable_unprepare(priv->clk);
+
+	return 0;
+}
+
+static struct platform_driver bcm2711_thermal_driver = {
+	.probe = bcm2711_thermal_probe,
+	.remove = bcm2711_thermal_remove,
+	.driver = {
+		.name = "bcm2711_thermal",
+		.of_match_table = bcm2711_thermal_id_table,
+	},
+};
+module_platform_driver(bcm2711_thermal_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Stefan Wahren");
+MODULE_DESCRIPTION("Broadcom AVS RO thermal sensor driver");
--
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/4] ARM: dts: bcm2711: Enable thermal
  2019-11-01 13:42 ` Stefan Wahren
@ 2019-11-01 13:42   ` Stefan Wahren
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-pm, devicetree, Stefan Wahren

This enables thermal for the BCM2711 and the Raspberry Pi 4.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 arch/arm/boot/dts/bcm2711.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index ac83dac..950e43f 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -46,6 +46,14 @@
 						 IRQ_TYPE_LEVEL_HIGH)>;
 		};

+		thermal: thermal@7d5d2200 {
+			compatible = "brcm,bcm2711-thermal";
+			reg = <0x7d5d2200 0x4>;
+			clocks = <&clocks BCM2835_CLOCK_TSENS>;
+			#thermal-sensor-cells = <0>;
+			status = "okay";
+		};
+
 		dma: dma@7e007000 {
 			compatible = "brcm,bcm2835-dma";
 			reg = <0x7e007000 0xb00>;
@@ -317,6 +325,7 @@

 &cpu_thermal {
 	coefficients = <(-487) 410040>;
+	thermal-sensors = <&thermal>;
 };

 &dsi0 {
--
2.7.4


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

* [PATCH 3/4] ARM: dts: bcm2711: Enable thermal
@ 2019-11-01 13:42   ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, linux-pm, bcm-kernel-feedback-list, Stefan Wahren,
	Chen-Yu Tsai, linux-arm-kernel

This enables thermal for the BCM2711 and the Raspberry Pi 4.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 arch/arm/boot/dts/bcm2711.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index ac83dac..950e43f 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -46,6 +46,14 @@
 						 IRQ_TYPE_LEVEL_HIGH)>;
 		};

+		thermal: thermal@7d5d2200 {
+			compatible = "brcm,bcm2711-thermal";
+			reg = <0x7d5d2200 0x4>;
+			clocks = <&clocks BCM2835_CLOCK_TSENS>;
+			#thermal-sensor-cells = <0>;
+			status = "okay";
+		};
+
 		dma: dma@7e007000 {
 			compatible = "brcm,bcm2835-dma";
 			reg = <0x7e007000 0xb00>;
@@ -317,6 +325,7 @@

 &cpu_thermal {
 	coefficients = <(-487) 410040>;
+	thermal-sensors = <&thermal>;
 };

 &dsi0 {
--
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 4/4] ARM: configs: Build BCM2711 thermal as module
  2019-11-01 13:42 ` Stefan Wahren
@ 2019-11-01 13:42   ` Stefan Wahren
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-pm, devicetree, Stefan Wahren

This builds the BCM2711 thermal driver as module for the Raspberry Pi 4.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 arch/arm64/configs/defconfig        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 13ba532..441b795 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -487,6 +487,7 @@ CONFIG_IMX_THERMAL=y
 CONFIG_ROCKCHIP_THERMAL=y
 CONFIG_RCAR_THERMAL=y
 CONFIG_ARMADA_THERMAL=y
+CONFIG_BCM2711_THERMAL=m
 CONFIG_BCM2835_THERMAL=m
 CONFIG_BRCMSTB_THERMAL=m
 CONFIG_ST_THERMAL_MEMMAP=y
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 8e05c39..0a52987 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -444,6 +444,7 @@ CONFIG_ROCKCHIP_THERMAL=m
 CONFIG_RCAR_THERMAL=y
 CONFIG_RCAR_GEN3_THERMAL=y
 CONFIG_ARMADA_THERMAL=y
+CONFIG_BCM2711_THERMAL=m
 CONFIG_BCM2835_THERMAL=m
 CONFIG_BRCMSTB_THERMAL=m
 CONFIG_EXYNOS_THERMAL=y
--
2.7.4


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

* [PATCH 4/4] ARM: configs: Build BCM2711 thermal as module
@ 2019-11-01 13:42   ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-01 13:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Rob Herring, Mark Rutland, Eric Anholt, Florian Fainelli,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, linux-pm, bcm-kernel-feedback-list, Stefan Wahren,
	Chen-Yu Tsai, linux-arm-kernel

This builds the BCM2711 thermal driver as module for the Raspberry Pi 4.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 arch/arm64/configs/defconfig        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 13ba532..441b795 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -487,6 +487,7 @@ CONFIG_IMX_THERMAL=y
 CONFIG_ROCKCHIP_THERMAL=y
 CONFIG_RCAR_THERMAL=y
 CONFIG_ARMADA_THERMAL=y
+CONFIG_BCM2711_THERMAL=m
 CONFIG_BCM2835_THERMAL=m
 CONFIG_BRCMSTB_THERMAL=m
 CONFIG_ST_THERMAL_MEMMAP=y
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 8e05c39..0a52987 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -444,6 +444,7 @@ CONFIG_ROCKCHIP_THERMAL=m
 CONFIG_RCAR_THERMAL=y
 CONFIG_RCAR_GEN3_THERMAL=y
 CONFIG_ARMADA_THERMAL=y
+CONFIG_BCM2711_THERMAL=m
 CONFIG_BCM2835_THERMAL=m
 CONFIG_BRCMSTB_THERMAL=m
 CONFIG_EXYNOS_THERMAL=y
--
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4
  2019-11-01 13:42 ` Stefan Wahren
@ 2019-11-02 20:08   ` Florian Fainelli
  -1 siblings, 0 replies; 20+ messages in thread
From: Florian Fainelli @ 2019-11-02 20:08 UTC (permalink / raw)
  To: Stefan Wahren, Zhang Rui, Eduardo Valentin, Daniel Lezcano,
	Amit Kucheria, Rob Herring, Mark Rutland, Eric Anholt,
	Florian Fainelli, Catalin Marinas, Will Deacon, Markus Mayer
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-pm, devicetree

On 11/1/2019 6:42 AM, Stefan Wahren wrote:
> This series enables thermal support for the Raspberry Pi 4. Neither the
> bcm2835_thermal nor the brcmstb_thermal are suitable for the BCM2711.
> So add a new thermal driver to read out the SoC temperature from the
> AVS RO block of the BCM2711.

It seems to me that with minor tweaks you could use the brcmstb_thermal
driver, since the two key differences are essentially:

- lack of interrupt, which is also the case on the latest STB SoCs
- different way to determine that data is valid, by checking both bit 16
and bit 10, as opposed to bit 11, and a reduced ADC code from 11 bits
down to 10.

This seems like a simple enough set of changes to build on top of this
patch series:

https://lore.kernel.org/linux-arm-kernel/20191030182132.25763-1-f.fainelli@gmail.com/

My concern is that we went down that road before with other drivers like
bcm2835-rng and bcm63xx-rng, when really there were little to no
differences other than some integrations bits (different clock,
compatible, and more important people having worked separately on those
things).

Your call, the patch series looks good to me otherwise:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4
@ 2019-11-02 20:08   ` Florian Fainelli
  0 siblings, 0 replies; 20+ messages in thread
From: Florian Fainelli @ 2019-11-02 20:08 UTC (permalink / raw)
  To: Stefan Wahren, Zhang Rui, Eduardo Valentin, Daniel Lezcano,
	Amit Kucheria, Rob Herring, Mark Rutland, Eric Anholt,
	Florian Fainelli, Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, Chen-Yu Tsai, bcm-kernel-feedback-list,
	linux-arm-kernel, linux-pm

On 11/1/2019 6:42 AM, Stefan Wahren wrote:
> This series enables thermal support for the Raspberry Pi 4. Neither the
> bcm2835_thermal nor the brcmstb_thermal are suitable for the BCM2711.
> So add a new thermal driver to read out the SoC temperature from the
> AVS RO block of the BCM2711.

It seems to me that with minor tweaks you could use the brcmstb_thermal
driver, since the two key differences are essentially:

- lack of interrupt, which is also the case on the latest STB SoCs
- different way to determine that data is valid, by checking both bit 16
and bit 10, as opposed to bit 11, and a reduced ADC code from 11 bits
down to 10.

This seems like a simple enough set of changes to build on top of this
patch series:

https://lore.kernel.org/linux-arm-kernel/20191030182132.25763-1-f.fainelli@gmail.com/

My concern is that we went down that road before with other drivers like
bcm2835-rng and bcm63xx-rng, when really there were little to no
differences other than some integrations bits (different clock,
compatible, and more important people having worked separately on those
things).

Your call, the patch series looks good to me otherwise:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4
  2019-11-02 20:08   ` Florian Fainelli
@ 2019-11-03  8:43     ` Stefan Wahren
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-03  8:43 UTC (permalink / raw)
  To: Florian Fainelli, Zhang Rui, Eduardo Valentin, Daniel Lezcano,
	Amit Kucheria, Rob Herring, Mark Rutland, Eric Anholt,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, Chen-Yu Tsai, bcm-kernel-feedback-list,
	linux-arm-kernel, linux-pm

Hi Florian,

Am 02.11.19 um 21:08 schrieb Florian Fainelli:
> On 11/1/2019 6:42 AM, Stefan Wahren wrote:
>> This series enables thermal support for the Raspberry Pi 4. Neither the
>> bcm2835_thermal nor the brcmstb_thermal are suitable for the BCM2711.
>> So add a new thermal driver to read out the SoC temperature from the
>> AVS RO block of the BCM2711.
> It seems to me that with minor tweaks you could use the brcmstb_thermal
> driver, since the two key differences are essentially:
>
> - lack of interrupt, which is also the case on the latest STB SoCs
> - different way to determine that data is valid, by checking both bit 16
> and bit 10, as opposed to bit 11, and a reduced ADC code from 11 bits
> down to 10.
>
> This seems like a simple enough set of changes to build on top of this
> patch series:
>
> https://lore.kernel.org/linux-arm-kernel/20191030182132.25763-1-f.fainelli@gmail.com/
this was the downstream approach until i was informed that the thermal
part of the RO block is used. I don't have a good feeling about misusing
the wrong binding. I still hope that the RPI folks release some kind of
memory map for the BCM2711 and maybe extend this driver. So i prefer to
start with a separate binding.

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

* Re: [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4
@ 2019-11-03  8:43     ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-03  8:43 UTC (permalink / raw)
  To: Florian Fainelli, Zhang Rui, Eduardo Valentin, Daniel Lezcano,
	Amit Kucheria, Rob Herring, Mark Rutland, Eric Anholt,
	Catalin Marinas, Will Deacon, Markus Mayer
  Cc: devicetree, Chen-Yu Tsai, bcm-kernel-feedback-list,
	linux-arm-kernel, linux-pm

Hi Florian,

Am 02.11.19 um 21:08 schrieb Florian Fainelli:
> On 11/1/2019 6:42 AM, Stefan Wahren wrote:
>> This series enables thermal support for the Raspberry Pi 4. Neither the
>> bcm2835_thermal nor the brcmstb_thermal are suitable for the BCM2711.
>> So add a new thermal driver to read out the SoC temperature from the
>> AVS RO block of the BCM2711.
> It seems to me that with minor tweaks you could use the brcmstb_thermal
> driver, since the two key differences are essentially:
>
> - lack of interrupt, which is also the case on the latest STB SoCs
> - different way to determine that data is valid, by checking both bit 16
> and bit 10, as opposed to bit 11, and a reduced ADC code from 11 bits
> down to 10.
>
> This seems like a simple enough set of changes to build on top of this
> patch series:
>
> https://lore.kernel.org/linux-arm-kernel/20191030182132.25763-1-f.fainelli@gmail.com/
this was the downstream approach until i was informed that the thermal
part of the RO block is used. I don't have a good feeling about misusing
the wrong binding. I still hope that the RPI folks release some kind of
memory map for the BCM2711 and maybe extend this driver. So i prefer to
start with a separate binding.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/4] dt-bindings: Add BCM2711 thermal
  2019-11-01 13:42   ` Stefan Wahren
@ 2019-11-06  4:21     ` Rob Herring
  -1 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2019-11-06  4:21 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Mark Rutland, Eric Anholt, Florian Fainelli, Catalin Marinas,
	Will Deacon, Markus Mayer, Chen-Yu Tsai,
	bcm-kernel-feedback-list, linux-arm-kernel, linux-pm, devicetree

On Fri, Nov 01, 2019 at 02:42:26PM +0100, Stefan Wahren wrote:
> Since the BCM2711 doesn't have a AVS TMON block, the thermal information
> must be retrieved from the AVS ring oscillator block. So add a new
> suitable binding.

Anything else in that block? 
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
>  .../bindings/thermal/brcm,bcm2711-thermal.txt      | 39 ++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
> 
> diff --git a/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
> new file mode 100644
> index 0000000..5531d3f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
> @@ -0,0 +1,39 @@
> +Binding for Thermal Sensor driver for BCM2711 SoCs.
> +
> +Required properties:
> +- compatible:		must be: "brcm,bcm2711-thermal"

If the block is called 'AVS ring oscillator', then the compatible name 
should mirror that.

> +- reg:			Address range of the thermal registers.
> +- clocks:		Phandle of the clock used by the thermal sensor.
> +- #thermal-sensor-cells:	should be 0 (see thermal.txt)
> +
> +Example:
> +
> +thermal-zones {
> +	cpu_thermal: cpu-thermal {
> +		polling-delay-passive = <0>;
> +		polling-delay = <1000>;
> +
> +		thermal-sensors = <&thermal>;
> +
> +		trips {
> +			cpu-crit {
> +				temperature	= <80000>;
> +				hysteresis	= <0>;
> +				type		= "critical";
> +			};
> +		};
> +
> +		coefficients = <(-487)  410040>;
> +
> +		cooling-maps {
> +		};
> +	};
> +};
> +
> +thermal@7d5d2200 {
> +	compatible = "brcm,bcm2711-thermal";
> +	reg = <0x7d5d2200 0x4>;
> +	clocks = <&clocks BCM2835_CLOCK_TSENS>;
> +	#thermal-sensor-cells = <0>;
> +};
> +
> --
> 2.7.4
> 

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

* Re: [PATCH 1/4] dt-bindings: Add BCM2711 thermal
@ 2019-11-06  4:21     ` Rob Herring
  0 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2019-11-06  4:21 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, devicetree, Amit Kucheria, Florian Fainelli,
	linux-pm, Catalin Marinas, Daniel Lezcano, Eduardo Valentin,
	Eric Anholt, bcm-kernel-feedback-list, Markus Mayer, Zhang Rui,
	Chen-Yu Tsai, Will Deacon, linux-arm-kernel

On Fri, Nov 01, 2019 at 02:42:26PM +0100, Stefan Wahren wrote:
> Since the BCM2711 doesn't have a AVS TMON block, the thermal information
> must be retrieved from the AVS ring oscillator block. So add a new
> suitable binding.

Anything else in that block? 
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
>  .../bindings/thermal/brcm,bcm2711-thermal.txt      | 39 ++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
> 
> diff --git a/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
> new file mode 100644
> index 0000000..5531d3f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
> @@ -0,0 +1,39 @@
> +Binding for Thermal Sensor driver for BCM2711 SoCs.
> +
> +Required properties:
> +- compatible:		must be: "brcm,bcm2711-thermal"

If the block is called 'AVS ring oscillator', then the compatible name 
should mirror that.

> +- reg:			Address range of the thermal registers.
> +- clocks:		Phandle of the clock used by the thermal sensor.
> +- #thermal-sensor-cells:	should be 0 (see thermal.txt)
> +
> +Example:
> +
> +thermal-zones {
> +	cpu_thermal: cpu-thermal {
> +		polling-delay-passive = <0>;
> +		polling-delay = <1000>;
> +
> +		thermal-sensors = <&thermal>;
> +
> +		trips {
> +			cpu-crit {
> +				temperature	= <80000>;
> +				hysteresis	= <0>;
> +				type		= "critical";
> +			};
> +		};
> +
> +		coefficients = <(-487)  410040>;
> +
> +		cooling-maps {
> +		};
> +	};
> +};
> +
> +thermal@7d5d2200 {
> +	compatible = "brcm,bcm2711-thermal";
> +	reg = <0x7d5d2200 0x4>;
> +	clocks = <&clocks BCM2835_CLOCK_TSENS>;
> +	#thermal-sensor-cells = <0>;
> +};
> +
> --
> 2.7.4
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/4] dt-bindings: Add BCM2711 thermal
  2019-11-06  4:21     ` Rob Herring
@ 2019-11-06  4:41       ` Florian Fainelli
  -1 siblings, 0 replies; 20+ messages in thread
From: Florian Fainelli @ 2019-11-06  4:41 UTC (permalink / raw)
  To: Rob Herring, Stefan Wahren
  Cc: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Mark Rutland, Eric Anholt, Florian Fainelli, Catalin Marinas,
	Will Deacon, Markus Mayer, Chen-Yu Tsai,
	bcm-kernel-feedback-list, linux-arm-kernel, linux-pm, devicetree



On 11/5/2019 8:21 PM, Rob Herring wrote:
> On Fri, Nov 01, 2019 at 02:42:26PM +0100, Stefan Wahren wrote:
>> Since the BCM2711 doesn't have a AVS TMON block, the thermal information
>> must be retrieved from the AVS ring oscillator block. So add a new
>> suitable binding.
> 
> Anything else in that block? 

Yes, the register space is quite big, and contains a bunch of raw
sensors (voltage, ring oscillators etc.). It might be more appropriate
to define the ring oscillator node and then use a syscon phandle to it
with the appropriate register offset within that block.

>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>>  .../bindings/thermal/brcm,bcm2711-thermal.txt      | 39 ++++++++++++++++++++++
>>  1 file changed, 39 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
>> new file mode 100644
>> index 0000000..5531d3f
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
>> @@ -0,0 +1,39 @@
>> +Binding for Thermal Sensor driver for BCM2711 SoCs.
>> +
>> +Required properties:
>> +- compatible:		must be: "brcm,bcm2711-thermal"
> 
> If the block is called 'AVS ring oscillator', then the compatible name 
> should mirror that.
> 
>> +- reg:			Address range of the thermal registers.
>> +- clocks:		Phandle of the clock used by the thermal sensor.
>> +- #thermal-sensor-cells:	should be 0 (see thermal.txt)
>> +
>> +Example:
>> +
>> +thermal-zones {
>> +	cpu_thermal: cpu-thermal {
>> +		polling-delay-passive = <0>;
>> +		polling-delay = <1000>;
>> +
>> +		thermal-sensors = <&thermal>;
>> +
>> +		trips {
>> +			cpu-crit {
>> +				temperature	= <80000>;
>> +				hysteresis	= <0>;
>> +				type		= "critical";
>> +			};
>> +		};
>> +
>> +		coefficients = <(-487)  410040>;
>> +
>> +		cooling-maps {
>> +		};
>> +	};
>> +};
>> +
>> +thermal@7d5d2200 {
>> +	compatible = "brcm,bcm2711-thermal";
>> +	reg = <0x7d5d2200 0x4>;
>> +	clocks = <&clocks BCM2835_CLOCK_TSENS>;
>> +	#thermal-sensor-cells = <0>;
>> +};
>> +
>> --
>> 2.7.4
>>

-- 
Florian

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

* Re: [PATCH 1/4] dt-bindings: Add BCM2711 thermal
@ 2019-11-06  4:41       ` Florian Fainelli
  0 siblings, 0 replies; 20+ messages in thread
From: Florian Fainelli @ 2019-11-06  4:41 UTC (permalink / raw)
  To: Rob Herring, Stefan Wahren
  Cc: Mark Rutland, devicetree, Amit Kucheria, Florian Fainelli,
	linux-pm, Catalin Marinas, Daniel Lezcano, Eduardo Valentin,
	Eric Anholt, bcm-kernel-feedback-list, Markus Mayer, Zhang Rui,
	Chen-Yu Tsai, Will Deacon, linux-arm-kernel



On 11/5/2019 8:21 PM, Rob Herring wrote:
> On Fri, Nov 01, 2019 at 02:42:26PM +0100, Stefan Wahren wrote:
>> Since the BCM2711 doesn't have a AVS TMON block, the thermal information
>> must be retrieved from the AVS ring oscillator block. So add a new
>> suitable binding.
> 
> Anything else in that block? 

Yes, the register space is quite big, and contains a bunch of raw
sensors (voltage, ring oscillators etc.). It might be more appropriate
to define the ring oscillator node and then use a syscon phandle to it
with the appropriate register offset within that block.

>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>>  .../bindings/thermal/brcm,bcm2711-thermal.txt      | 39 ++++++++++++++++++++++
>>  1 file changed, 39 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
>> new file mode 100644
>> index 0000000..5531d3f
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/thermal/brcm,bcm2711-thermal.txt
>> @@ -0,0 +1,39 @@
>> +Binding for Thermal Sensor driver for BCM2711 SoCs.
>> +
>> +Required properties:
>> +- compatible:		must be: "brcm,bcm2711-thermal"
> 
> If the block is called 'AVS ring oscillator', then the compatible name 
> should mirror that.
> 
>> +- reg:			Address range of the thermal registers.
>> +- clocks:		Phandle of the clock used by the thermal sensor.
>> +- #thermal-sensor-cells:	should be 0 (see thermal.txt)
>> +
>> +Example:
>> +
>> +thermal-zones {
>> +	cpu_thermal: cpu-thermal {
>> +		polling-delay-passive = <0>;
>> +		polling-delay = <1000>;
>> +
>> +		thermal-sensors = <&thermal>;
>> +
>> +		trips {
>> +			cpu-crit {
>> +				temperature	= <80000>;
>> +				hysteresis	= <0>;
>> +				type		= "critical";
>> +			};
>> +		};
>> +
>> +		coefficients = <(-487)  410040>;
>> +
>> +		cooling-maps {
>> +		};
>> +	};
>> +};
>> +
>> +thermal@7d5d2200 {
>> +	compatible = "brcm,bcm2711-thermal";
>> +	reg = <0x7d5d2200 0x4>;
>> +	clocks = <&clocks BCM2835_CLOCK_TSENS>;
>> +	#thermal-sensor-cells = <0>;
>> +};
>> +
>> --
>> 2.7.4
>>

-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/4] dt-bindings: Add BCM2711 thermal
  2019-11-06  4:41       ` Florian Fainelli
@ 2019-11-07 19:26         ` Stefan Wahren
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-07 19:26 UTC (permalink / raw)
  To: Florian Fainelli, Rob Herring
  Cc: Mark Rutland, devicetree, Amit Kucheria, linux-pm,
	Catalin Marinas, Daniel Lezcano, Eduardo Valentin, Eric Anholt,
	bcm-kernel-feedback-list, Markus Mayer, Zhang Rui, Chen-Yu Tsai,
	Will Deacon, linux-arm-kernel

Am 06.11.19 um 05:41 schrieb Florian Fainelli:
>
> On 11/5/2019 8:21 PM, Rob Herring wrote:
>> On Fri, Nov 01, 2019 at 02:42:26PM +0100, Stefan Wahren wrote:
>>> Since the BCM2711 doesn't have a AVS TMON block, the thermal information
>>> must be retrieved from the AVS ring oscillator block. So add a new
>>> suitable binding.
>> Anything else in that block?
> Yes, the register space is quite big, and contains a bunch of raw
> sensors (voltage, ring oscillators etc.). It might be more appropriate
> to define the ring oscillator node and then use a syscon phandle to it
> with the appropriate register offset within that block.
AVS_MONITOR: 0x7d5d2000 - 0x7d5d2eff
AVS_RO_REGISTERS_0: 0x7d5d2200 - 0x7d5d22e3

So i should define a node for AVS_RO_REGISTERS_0 ?


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

* Re: [PATCH 1/4] dt-bindings: Add BCM2711 thermal
@ 2019-11-07 19:26         ` Stefan Wahren
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Wahren @ 2019-11-07 19:26 UTC (permalink / raw)
  To: Florian Fainelli, Rob Herring
  Cc: Mark Rutland, devicetree, Amit Kucheria, linux-pm,
	Catalin Marinas, Daniel Lezcano, Eduardo Valentin, Eric Anholt,
	bcm-kernel-feedback-list, Markus Mayer, Zhang Rui, Chen-Yu Tsai,
	Will Deacon, linux-arm-kernel

Am 06.11.19 um 05:41 schrieb Florian Fainelli:
>
> On 11/5/2019 8:21 PM, Rob Herring wrote:
>> On Fri, Nov 01, 2019 at 02:42:26PM +0100, Stefan Wahren wrote:
>>> Since the BCM2711 doesn't have a AVS TMON block, the thermal information
>>> must be retrieved from the AVS ring oscillator block. So add a new
>>> suitable binding.
>> Anything else in that block?
> Yes, the register space is quite big, and contains a bunch of raw
> sensors (voltage, ring oscillators etc.). It might be more appropriate
> to define the ring oscillator node and then use a syscon phandle to it
> with the appropriate register offset within that block.
AVS_MONITOR: 0x7d5d2000 - 0x7d5d2eff
AVS_RO_REGISTERS_0: 0x7d5d2200 - 0x7d5d22e3

So i should define a node for AVS_RO_REGISTERS_0 ?


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-11-07 19:26 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 13:42 [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4 Stefan Wahren
2019-11-01 13:42 ` Stefan Wahren
2019-11-01 13:42 ` [PATCH 1/4] dt-bindings: Add BCM2711 thermal Stefan Wahren
2019-11-01 13:42   ` Stefan Wahren
2019-11-06  4:21   ` Rob Herring
2019-11-06  4:21     ` Rob Herring
2019-11-06  4:41     ` Florian Fainelli
2019-11-06  4:41       ` Florian Fainelli
2019-11-07 19:26       ` Stefan Wahren
2019-11-07 19:26         ` Stefan Wahren
2019-11-01 13:42 ` [PATCH 2/4] thermal: Add BCM2711 thermal driver Stefan Wahren
2019-11-01 13:42   ` Stefan Wahren
2019-11-01 13:42 ` [PATCH 3/4] ARM: dts: bcm2711: Enable thermal Stefan Wahren
2019-11-01 13:42   ` Stefan Wahren
2019-11-01 13:42 ` [PATCH 4/4] ARM: configs: Build BCM2711 thermal as module Stefan Wahren
2019-11-01 13:42   ` Stefan Wahren
2019-11-02 20:08 ` [PATCH 0/4] ARM: Enable thermal support for Raspberry Pi 4 Florian Fainelli
2019-11-02 20:08   ` Florian Fainelli
2019-11-03  8:43   ` Stefan Wahren
2019-11-03  8:43     ` Stefan Wahren

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.