* [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
@ 2017-03-18 0:01 ` Rafał Miłecki
0 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:01 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin
Cc: Mark Rutland, devicetree, Florian Fainelli, Scott Branden,
Stephen Warren, Ray Jui, linux-pm, Lee Jones, Eric Anholt,
Rob Herring, bcm-kernel-feedback-list, linux-rpi-kernel,
Rafał Miłecki, linux-arm-kernel
From: Rafał Miłecki <rafal@milecki.pl>
This commit documents binding for BCM2835 SoC thermal used in Raspberry
Pi devices.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
.../bindings/thermal/raspberrypi,bcm2835-thermal | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
diff --git a/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
new file mode 100644
index 000000000000..fbffa9291ba9
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
@@ -0,0 +1,17 @@
+* Broadcom BCM2835 SoC Raspberry Pi Thermal
+
+This binding describes thermal sensor that is part of BCM2835 SoC.
+
+Required properties:
+- compatible : Must be "raspberrypi,bcm2835-thermal"
+- firmware : Reference to the Raspberry Pi firmware device node, see
+ raspberrypi,bcm2835-firmware for details
+- #thermal-sensor-cells : Should be <0>
+
+Example:
+
+thermal {
+ compatible = "raspberrypi,bcm2835-thermal";
+ firmware = <&firmware>;
+ #thermal-sensor-cells = <0>;
+};
--
2.11.0
_______________________________________________
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] 12+ messages in thread
* [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
@ 2017-03-18 0:01 ` Rafał Miłecki
0 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:01 UTC (permalink / raw)
To: linux-arm-kernel
From: Rafa? Mi?ecki <rafal@milecki.pl>
This commit documents binding for BCM2835 SoC thermal used in Raspberry
Pi devices.
Signed-off-by: Rafa? Mi?ecki <rafal@milecki.pl>
---
.../bindings/thermal/raspberrypi,bcm2835-thermal | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
diff --git a/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
new file mode 100644
index 000000000000..fbffa9291ba9
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
@@ -0,0 +1,17 @@
+* Broadcom BCM2835 SoC Raspberry Pi Thermal
+
+This binding describes thermal sensor that is part of BCM2835 SoC.
+
+Required properties:
+- compatible : Must be "raspberrypi,bcm2835-thermal"
+- firmware : Reference to the Raspberry Pi firmware device node, see
+ raspberrypi,bcm2835-firmware for details
+- #thermal-sensor-cells : Should be <0>
+
+Example:
+
+thermal {
+ compatible = "raspberrypi,bcm2835-thermal";
+ firmware = <&firmware>;
+ #thermal-sensor-cells = <0>;
+};
--
2.11.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] thermal: broadcom: add Raspberry Pi thermal driver
2017-03-18 0:01 ` Rafał Miłecki
@ 2017-03-18 0:01 ` Rafał Miłecki
-1 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:01 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin
Cc: Mark Rutland, devicetree, Florian Fainelli, Scott Branden,
Stephen Warren, Ray Jui, linux-pm, Lee Jones, Eric Anholt,
Rob Herring, bcm-kernel-feedback-list, linux-rpi-kernel,
Rafał Miłecki, linux-arm-kernel
From: Rafał Miłecki <rafal@milecki.pl>
Raspberry Pi devices use BCM283[567] SoCs with a thermal device inside.
Querying it is possible using Raspberry specific firmware interface.
This simple driver allows reading SoC temperature.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/thermal/Kconfig | 5 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/broadcom/Kconfig | 7 +++
drivers/thermal/broadcom/Makefile | 1 +
drivers/thermal/broadcom/raspberrypi-thermal.c | 85 ++++++++++++++++++++++++++
5 files changed, 99 insertions(+)
create mode 100644 drivers/thermal/broadcom/Kconfig
create mode 100644 drivers/thermal/broadcom/Makefile
create mode 100644 drivers/thermal/broadcom/raspberrypi-thermal.c
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 776b34396144..008e173ec825 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -392,6 +392,11 @@ config MTK_THERMAL
Enable this option if you want to have support for thermal management
controller present in Mediatek SoCs
+menu "Broadcom thermal drivers"
+depends on ARCH_BCM || COMPILE_TEST
+source "drivers/thermal/broadcom/Kconfig"
+endmenu
+
menu "Texas Instruments thermal drivers"
depends on ARCH_HAS_BANDGAP || COMPILE_TEST
depends on HAS_IOMEM
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 7adae2029355..549d81b6363c 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -27,6 +27,7 @@ thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o
thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
# platform thermal drivers
+obj-y += broadcom/
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
diff --git a/drivers/thermal/broadcom/Kconfig b/drivers/thermal/broadcom/Kconfig
new file mode 100644
index 000000000000..03d52d1d1403
--- /dev/null
+++ b/drivers/thermal/broadcom/Kconfig
@@ -0,0 +1,7 @@
+config RASPBERRYPI_THERMAL
+ tristate "Raspberry Pi thermal driver"
+ depends on ARCH_BCM2835 || COMPILE_TEST
+ depends on RASPBERRYPI_FIRMWARE=y
+ help
+ This enables support for the RPi power domains which can be enabled
+ or disabled via the RPi firmware.
diff --git a/drivers/thermal/broadcom/Makefile b/drivers/thermal/broadcom/Makefile
new file mode 100644
index 000000000000..5ea7f8819b7d
--- /dev/null
+++ b/drivers/thermal/broadcom/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_RASPBERRYPI_THERMAL) += raspberrypi-thermal.o
diff --git a/drivers/thermal/broadcom/raspberrypi-thermal.c b/drivers/thermal/broadcom/raspberrypi-thermal.c
new file mode 100644
index 000000000000..d9c1db06f806
--- /dev/null
+++ b/drivers/thermal/broadcom/raspberrypi-thermal.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/thermal.h>
+
+#include <soc/bcm2835/raspberrypi-firmware.h>
+
+struct rpi_thermal {
+ struct rpi_firmware *fw;
+};
+
+static int rpi_thermal_get_temp(void *data, int *temp)
+{
+ struct rpi_thermal *rpi_thermal = data;
+ struct {
+ u32 id;
+ u32 temp;
+ } tag_data = {};
+ int err;
+
+ err = rpi_firmware_property(rpi_thermal->fw,
+ RPI_FIRMWARE_GET_TEMPERATURE,
+ &tag_data, sizeof(tag_data));
+ if (!err)
+ *temp = tag_data.temp;
+
+ return err;
+}
+
+const struct thermal_zone_of_device_ops rpi_thermal_ops = {
+ .get_temp = rpi_thermal_get_temp,
+};
+
+static int rpi_thermal_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct rpi_thermal *rpi_thermal;
+ struct device_node *fw_np;
+ struct thermal_zone_device *tzd;
+
+ rpi_thermal = devm_kzalloc(dev, sizeof(*rpi_thermal), GFP_KERNEL);
+ if (!rpi_thermal)
+ return -ENOMEM;
+
+ fw_np = of_parse_phandle(dev->of_node, "firmware", 0);
+ if (!fw_np) {
+ dev_err(dev, "Failed to get firmware phandle\n");
+ return -ENOENT;
+ }
+
+ rpi_thermal->fw = rpi_firmware_get(fw_np);
+ of_node_put(fw_np);
+ if (!rpi_thermal->fw)
+ return -ENODEV;
+
+ tzd = devm_thermal_zone_of_sensor_register(dev, 0, rpi_thermal,
+ &rpi_thermal_ops);
+
+ return PTR_ERR_OR_ZERO(tzd);
+}
+
+static const struct of_device_id rpi_thermal_of_match[] = {
+ { .compatible = "raspberrypi,bcm2835-thermal", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, rpi_thermal_of_match);
+
+static struct platform_driver rpi_thermal_driver = {
+ .probe = rpi_thermal_probe,
+ .driver = {
+ .name = "raspberrypi-thermal",
+ .of_match_table = rpi_thermal_of_match,
+ },
+};
+module_platform_driver(rpi_thermal_driver);
+
+MODULE_DESCRIPTION("Raspberry Pi thermal driver");
+MODULE_LICENSE("GPL v2");
--
2.11.0
_______________________________________________
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] 12+ messages in thread
* [PATCH 2/2] thermal: broadcom: add Raspberry Pi thermal driver
@ 2017-03-18 0:01 ` Rafał Miłecki
0 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:01 UTC (permalink / raw)
To: linux-arm-kernel
From: Rafa? Mi?ecki <rafal@milecki.pl>
Raspberry Pi devices use BCM283[567] SoCs with a thermal device inside.
Querying it is possible using Raspberry specific firmware interface.
This simple driver allows reading SoC temperature.
Signed-off-by: Rafa? Mi?ecki <rafal@milecki.pl>
---
drivers/thermal/Kconfig | 5 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/broadcom/Kconfig | 7 +++
drivers/thermal/broadcom/Makefile | 1 +
drivers/thermal/broadcom/raspberrypi-thermal.c | 85 ++++++++++++++++++++++++++
5 files changed, 99 insertions(+)
create mode 100644 drivers/thermal/broadcom/Kconfig
create mode 100644 drivers/thermal/broadcom/Makefile
create mode 100644 drivers/thermal/broadcom/raspberrypi-thermal.c
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 776b34396144..008e173ec825 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -392,6 +392,11 @@ config MTK_THERMAL
Enable this option if you want to have support for thermal management
controller present in Mediatek SoCs
+menu "Broadcom thermal drivers"
+depends on ARCH_BCM || COMPILE_TEST
+source "drivers/thermal/broadcom/Kconfig"
+endmenu
+
menu "Texas Instruments thermal drivers"
depends on ARCH_HAS_BANDGAP || COMPILE_TEST
depends on HAS_IOMEM
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 7adae2029355..549d81b6363c 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -27,6 +27,7 @@ thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o
thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
# platform thermal drivers
+obj-y += broadcom/
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
diff --git a/drivers/thermal/broadcom/Kconfig b/drivers/thermal/broadcom/Kconfig
new file mode 100644
index 000000000000..03d52d1d1403
--- /dev/null
+++ b/drivers/thermal/broadcom/Kconfig
@@ -0,0 +1,7 @@
+config RASPBERRYPI_THERMAL
+ tristate "Raspberry Pi thermal driver"
+ depends on ARCH_BCM2835 || COMPILE_TEST
+ depends on RASPBERRYPI_FIRMWARE=y
+ help
+ This enables support for the RPi power domains which can be enabled
+ or disabled via the RPi firmware.
diff --git a/drivers/thermal/broadcom/Makefile b/drivers/thermal/broadcom/Makefile
new file mode 100644
index 000000000000..5ea7f8819b7d
--- /dev/null
+++ b/drivers/thermal/broadcom/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_RASPBERRYPI_THERMAL) += raspberrypi-thermal.o
diff --git a/drivers/thermal/broadcom/raspberrypi-thermal.c b/drivers/thermal/broadcom/raspberrypi-thermal.c
new file mode 100644
index 000000000000..d9c1db06f806
--- /dev/null
+++ b/drivers/thermal/broadcom/raspberrypi-thermal.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2017 Rafa? Mi?ecki <rafal@milecki.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/thermal.h>
+
+#include <soc/bcm2835/raspberrypi-firmware.h>
+
+struct rpi_thermal {
+ struct rpi_firmware *fw;
+};
+
+static int rpi_thermal_get_temp(void *data, int *temp)
+{
+ struct rpi_thermal *rpi_thermal = data;
+ struct {
+ u32 id;
+ u32 temp;
+ } tag_data = {};
+ int err;
+
+ err = rpi_firmware_property(rpi_thermal->fw,
+ RPI_FIRMWARE_GET_TEMPERATURE,
+ &tag_data, sizeof(tag_data));
+ if (!err)
+ *temp = tag_data.temp;
+
+ return err;
+}
+
+const struct thermal_zone_of_device_ops rpi_thermal_ops = {
+ .get_temp = rpi_thermal_get_temp,
+};
+
+static int rpi_thermal_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct rpi_thermal *rpi_thermal;
+ struct device_node *fw_np;
+ struct thermal_zone_device *tzd;
+
+ rpi_thermal = devm_kzalloc(dev, sizeof(*rpi_thermal), GFP_KERNEL);
+ if (!rpi_thermal)
+ return -ENOMEM;
+
+ fw_np = of_parse_phandle(dev->of_node, "firmware", 0);
+ if (!fw_np) {
+ dev_err(dev, "Failed to get firmware phandle\n");
+ return -ENOENT;
+ }
+
+ rpi_thermal->fw = rpi_firmware_get(fw_np);
+ of_node_put(fw_np);
+ if (!rpi_thermal->fw)
+ return -ENODEV;
+
+ tzd = devm_thermal_zone_of_sensor_register(dev, 0, rpi_thermal,
+ &rpi_thermal_ops);
+
+ return PTR_ERR_OR_ZERO(tzd);
+}
+
+static const struct of_device_id rpi_thermal_of_match[] = {
+ { .compatible = "raspberrypi,bcm2835-thermal", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, rpi_thermal_of_match);
+
+static struct platform_driver rpi_thermal_driver = {
+ .probe = rpi_thermal_probe,
+ .driver = {
+ .name = "raspberrypi-thermal",
+ .of_match_table = rpi_thermal_of_match,
+ },
+};
+module_platform_driver(rpi_thermal_driver);
+
+MODULE_DESCRIPTION("Raspberry Pi thermal driver");
+MODULE_LICENSE("GPL v2");
--
2.11.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH V2 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
2017-03-18 0:01 ` Rafał Miłecki
@ 2017-03-18 0:06 ` Rafał Miłecki
-1 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:06 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin
Cc: Rob Herring, Mark Rutland, Stephen Warren, Lee Jones,
Eric Anholt, Florian Fainelli, Ray Jui, Scott Branden,
bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
linux-pm-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Rafał Miłecki
From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
This commit documents binding for BCM2835 SoC thermal used in Raspberry
Pi devices.
Signed-off-by: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
---
.../bindings/thermal/raspberrypi,bcm2835-thermal | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
diff --git a/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
new file mode 100644
index 000000000000..fbffa9291ba9
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
@@ -0,0 +1,17 @@
+* Broadcom BCM2835 SoC Raspberry Pi Thermal
+
+This binding describes thermal sensor that is part of BCM2835 SoC.
+
+Required properties:
+- compatible : Must be "raspberrypi,bcm2835-thermal"
+- firmware : Reference to the Raspberry Pi firmware device node, see
+ raspberrypi,bcm2835-firmware for details
+- #thermal-sensor-cells : Should be <0>
+
+Example:
+
+thermal {
+ compatible = "raspberrypi,bcm2835-thermal";
+ firmware = <&firmware>;
+ #thermal-sensor-cells = <0>;
+};
--
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH V2 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
@ 2017-03-18 0:06 ` Rafał Miłecki
0 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:06 UTC (permalink / raw)
To: linux-arm-kernel
From: Rafa? Mi?ecki <rafal@milecki.pl>
This commit documents binding for BCM2835 SoC thermal used in Raspberry
Pi devices.
Signed-off-by: Rafa? Mi?ecki <rafal@milecki.pl>
---
.../bindings/thermal/raspberrypi,bcm2835-thermal | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
diff --git a/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
new file mode 100644
index 000000000000..fbffa9291ba9
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/raspberrypi,bcm2835-thermal
@@ -0,0 +1,17 @@
+* Broadcom BCM2835 SoC Raspberry Pi Thermal
+
+This binding describes thermal sensor that is part of BCM2835 SoC.
+
+Required properties:
+- compatible : Must be "raspberrypi,bcm2835-thermal"
+- firmware : Reference to the Raspberry Pi firmware device node, see
+ raspberrypi,bcm2835-firmware for details
+- #thermal-sensor-cells : Should be <0>
+
+Example:
+
+thermal {
+ compatible = "raspberrypi,bcm2835-thermal";
+ firmware = <&firmware>;
+ #thermal-sensor-cells = <0>;
+};
--
2.11.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH V2 2/2] thermal: broadcom: add Raspberry Pi thermal driver
2017-03-18 0:06 ` Rafał Miłecki
@ 2017-03-18 0:06 ` Rafał Miłecki
-1 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:06 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin
Cc: Rob Herring, Mark Rutland, Stephen Warren, Lee Jones,
Eric Anholt, Florian Fainelli, Ray Jui, Scott Branden,
bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
linux-pm-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Rafał Miłecki
From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
Raspberry Pi devices use BCM283[567] SoCs with a thermal device inside.
Querying it is possible using Raspberry specific firmware interface.
This simple driver allows reading SoC temperature.
Signed-off-by: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
---
V2: Update Kconfig help message. I forgot to locally rebase & fixup before
sending, sorry.
---
drivers/thermal/Kconfig | 5 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/broadcom/Kconfig | 7 +++
drivers/thermal/broadcom/Makefile | 1 +
drivers/thermal/broadcom/raspberrypi-thermal.c | 85 ++++++++++++++++++++++++++
5 files changed, 99 insertions(+)
create mode 100644 drivers/thermal/broadcom/Kconfig
create mode 100644 drivers/thermal/broadcom/Makefile
create mode 100644 drivers/thermal/broadcom/raspberrypi-thermal.c
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 776b34396144..008e173ec825 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -392,6 +392,11 @@ config MTK_THERMAL
Enable this option if you want to have support for thermal management
controller present in Mediatek SoCs
+menu "Broadcom thermal drivers"
+depends on ARCH_BCM || COMPILE_TEST
+source "drivers/thermal/broadcom/Kconfig"
+endmenu
+
menu "Texas Instruments thermal drivers"
depends on ARCH_HAS_BANDGAP || COMPILE_TEST
depends on HAS_IOMEM
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 7adae2029355..549d81b6363c 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -27,6 +27,7 @@ thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o
thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
# platform thermal drivers
+obj-y += broadcom/
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
diff --git a/drivers/thermal/broadcom/Kconfig b/drivers/thermal/broadcom/Kconfig
new file mode 100644
index 000000000000..2524b2ff16f6
--- /dev/null
+++ b/drivers/thermal/broadcom/Kconfig
@@ -0,0 +1,7 @@
+config RASPBERRYPI_THERMAL
+ tristate "Raspberry Pi thermal driver"
+ depends on ARCH_BCM2835 || COMPILE_TEST
+ depends on RASPBERRYPI_FIRMWARE=y
+ help
+ This enables support for the RPi thermal that is part of BCM2835 SoC
+ and can be accessed using firmware interface.
diff --git a/drivers/thermal/broadcom/Makefile b/drivers/thermal/broadcom/Makefile
new file mode 100644
index 000000000000..5ea7f8819b7d
--- /dev/null
+++ b/drivers/thermal/broadcom/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_RASPBERRYPI_THERMAL) += raspberrypi-thermal.o
diff --git a/drivers/thermal/broadcom/raspberrypi-thermal.c b/drivers/thermal/broadcom/raspberrypi-thermal.c
new file mode 100644
index 000000000000..d9c1db06f806
--- /dev/null
+++ b/drivers/thermal/broadcom/raspberrypi-thermal.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2017 Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/thermal.h>
+
+#include <soc/bcm2835/raspberrypi-firmware.h>
+
+struct rpi_thermal {
+ struct rpi_firmware *fw;
+};
+
+static int rpi_thermal_get_temp(void *data, int *temp)
+{
+ struct rpi_thermal *rpi_thermal = data;
+ struct {
+ u32 id;
+ u32 temp;
+ } tag_data = {};
+ int err;
+
+ err = rpi_firmware_property(rpi_thermal->fw,
+ RPI_FIRMWARE_GET_TEMPERATURE,
+ &tag_data, sizeof(tag_data));
+ if (!err)
+ *temp = tag_data.temp;
+
+ return err;
+}
+
+const struct thermal_zone_of_device_ops rpi_thermal_ops = {
+ .get_temp = rpi_thermal_get_temp,
+};
+
+static int rpi_thermal_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct rpi_thermal *rpi_thermal;
+ struct device_node *fw_np;
+ struct thermal_zone_device *tzd;
+
+ rpi_thermal = devm_kzalloc(dev, sizeof(*rpi_thermal), GFP_KERNEL);
+ if (!rpi_thermal)
+ return -ENOMEM;
+
+ fw_np = of_parse_phandle(dev->of_node, "firmware", 0);
+ if (!fw_np) {
+ dev_err(dev, "Failed to get firmware phandle\n");
+ return -ENOENT;
+ }
+
+ rpi_thermal->fw = rpi_firmware_get(fw_np);
+ of_node_put(fw_np);
+ if (!rpi_thermal->fw)
+ return -ENODEV;
+
+ tzd = devm_thermal_zone_of_sensor_register(dev, 0, rpi_thermal,
+ &rpi_thermal_ops);
+
+ return PTR_ERR_OR_ZERO(tzd);
+}
+
+static const struct of_device_id rpi_thermal_of_match[] = {
+ { .compatible = "raspberrypi,bcm2835-thermal", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, rpi_thermal_of_match);
+
+static struct platform_driver rpi_thermal_driver = {
+ .probe = rpi_thermal_probe,
+ .driver = {
+ .name = "raspberrypi-thermal",
+ .of_match_table = rpi_thermal_of_match,
+ },
+};
+module_platform_driver(rpi_thermal_driver);
+
+MODULE_DESCRIPTION("Raspberry Pi thermal driver");
+MODULE_LICENSE("GPL v2");
--
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH V2 2/2] thermal: broadcom: add Raspberry Pi thermal driver
@ 2017-03-18 0:06 ` Rafał Miłecki
0 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 0:06 UTC (permalink / raw)
To: linux-arm-kernel
From: Rafa? Mi?ecki <rafal@milecki.pl>
Raspberry Pi devices use BCM283[567] SoCs with a thermal device inside.
Querying it is possible using Raspberry specific firmware interface.
This simple driver allows reading SoC temperature.
Signed-off-by: Rafa? Mi?ecki <rafal@milecki.pl>
---
V2: Update Kconfig help message. I forgot to locally rebase & fixup before
sending, sorry.
---
drivers/thermal/Kconfig | 5 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/broadcom/Kconfig | 7 +++
drivers/thermal/broadcom/Makefile | 1 +
drivers/thermal/broadcom/raspberrypi-thermal.c | 85 ++++++++++++++++++++++++++
5 files changed, 99 insertions(+)
create mode 100644 drivers/thermal/broadcom/Kconfig
create mode 100644 drivers/thermal/broadcom/Makefile
create mode 100644 drivers/thermal/broadcom/raspberrypi-thermal.c
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 776b34396144..008e173ec825 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -392,6 +392,11 @@ config MTK_THERMAL
Enable this option if you want to have support for thermal management
controller present in Mediatek SoCs
+menu "Broadcom thermal drivers"
+depends on ARCH_BCM || COMPILE_TEST
+source "drivers/thermal/broadcom/Kconfig"
+endmenu
+
menu "Texas Instruments thermal drivers"
depends on ARCH_HAS_BANDGAP || COMPILE_TEST
depends on HAS_IOMEM
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 7adae2029355..549d81b6363c 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -27,6 +27,7 @@ thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o
thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
# platform thermal drivers
+obj-y += broadcom/
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
diff --git a/drivers/thermal/broadcom/Kconfig b/drivers/thermal/broadcom/Kconfig
new file mode 100644
index 000000000000..2524b2ff16f6
--- /dev/null
+++ b/drivers/thermal/broadcom/Kconfig
@@ -0,0 +1,7 @@
+config RASPBERRYPI_THERMAL
+ tristate "Raspberry Pi thermal driver"
+ depends on ARCH_BCM2835 || COMPILE_TEST
+ depends on RASPBERRYPI_FIRMWARE=y
+ help
+ This enables support for the RPi thermal that is part of BCM2835 SoC
+ and can be accessed using firmware interface.
diff --git a/drivers/thermal/broadcom/Makefile b/drivers/thermal/broadcom/Makefile
new file mode 100644
index 000000000000..5ea7f8819b7d
--- /dev/null
+++ b/drivers/thermal/broadcom/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_RASPBERRYPI_THERMAL) += raspberrypi-thermal.o
diff --git a/drivers/thermal/broadcom/raspberrypi-thermal.c b/drivers/thermal/broadcom/raspberrypi-thermal.c
new file mode 100644
index 000000000000..d9c1db06f806
--- /dev/null
+++ b/drivers/thermal/broadcom/raspberrypi-thermal.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2017 Rafa? Mi?ecki <rafal@milecki.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/thermal.h>
+
+#include <soc/bcm2835/raspberrypi-firmware.h>
+
+struct rpi_thermal {
+ struct rpi_firmware *fw;
+};
+
+static int rpi_thermal_get_temp(void *data, int *temp)
+{
+ struct rpi_thermal *rpi_thermal = data;
+ struct {
+ u32 id;
+ u32 temp;
+ } tag_data = {};
+ int err;
+
+ err = rpi_firmware_property(rpi_thermal->fw,
+ RPI_FIRMWARE_GET_TEMPERATURE,
+ &tag_data, sizeof(tag_data));
+ if (!err)
+ *temp = tag_data.temp;
+
+ return err;
+}
+
+const struct thermal_zone_of_device_ops rpi_thermal_ops = {
+ .get_temp = rpi_thermal_get_temp,
+};
+
+static int rpi_thermal_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct rpi_thermal *rpi_thermal;
+ struct device_node *fw_np;
+ struct thermal_zone_device *tzd;
+
+ rpi_thermal = devm_kzalloc(dev, sizeof(*rpi_thermal), GFP_KERNEL);
+ if (!rpi_thermal)
+ return -ENOMEM;
+
+ fw_np = of_parse_phandle(dev->of_node, "firmware", 0);
+ if (!fw_np) {
+ dev_err(dev, "Failed to get firmware phandle\n");
+ return -ENOENT;
+ }
+
+ rpi_thermal->fw = rpi_firmware_get(fw_np);
+ of_node_put(fw_np);
+ if (!rpi_thermal->fw)
+ return -ENODEV;
+
+ tzd = devm_thermal_zone_of_sensor_register(dev, 0, rpi_thermal,
+ &rpi_thermal_ops);
+
+ return PTR_ERR_OR_ZERO(tzd);
+}
+
+static const struct of_device_id rpi_thermal_of_match[] = {
+ { .compatible = "raspberrypi,bcm2835-thermal", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, rpi_thermal_of_match);
+
+static struct platform_driver rpi_thermal_driver = {
+ .probe = rpi_thermal_probe,
+ .driver = {
+ .name = "raspberrypi-thermal",
+ .of_match_table = rpi_thermal_of_match,
+ },
+};
+module_platform_driver(rpi_thermal_driver);
+
+MODULE_DESCRIPTION("Raspberry Pi thermal driver");
+MODULE_LICENSE("GPL v2");
--
2.11.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
2017-03-18 0:01 ` Rafał Miłecki
@ 2017-03-18 0:09 ` Eric Anholt
-1 siblings, 0 replies; 12+ messages in thread
From: Eric Anholt @ 2017-03-18 0:09 UTC (permalink / raw)
To: Rafał Miłecki, Zhang Rui, Eduardo Valentin
Cc: Rob Herring, Mark Rutland, Stephen Warren, Lee Jones,
Florian Fainelli, Ray Jui, Scott Branden,
bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
linux-pm-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Rafał Miłecki
[-- Attachment #1: Type: text/plain, Size: 405 bytes --]
Rafał Miłecki <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
>
> This commit documents binding for BCM2835 SoC thermal used in Raspberry
> Pi devices.
There's already a native (non-firmware) thermal driver just waiting for
the maintainer to merge it.
https://www.spinics.net/lists/arm-kernel/msg566217.html
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
@ 2017-03-18 0:09 ` Eric Anholt
0 siblings, 0 replies; 12+ messages in thread
From: Eric Anholt @ 2017-03-18 0:09 UTC (permalink / raw)
To: linux-arm-kernel
Rafa? Mi?ecki <zajec5@gmail.com> writes:
> From: Rafa? Mi?ecki <rafal@milecki.pl>
>
> This commit documents binding for BCM2835 SoC thermal used in Raspberry
> Pi devices.
There's already a native (non-firmware) thermal driver just waiting for
the maintainer to merge it.
https://www.spinics.net/lists/arm-kernel/msg566217.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170317/d9d6890a/attachment.sig>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
2017-03-18 0:09 ` Eric Anholt
@ 2017-03-18 8:58 ` Rafał Miłecki
-1 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 8:58 UTC (permalink / raw)
To: Eric Anholt
Cc: Mark Rutland, devicetree, Florian Fainelli, Scott Branden,
Stephen Warren, Ray Jui, linux-pm, Lee Jones, Eduardo Valentin,
Rob Herring, bcm-kernel-feedback-list, linux-rpi-kernel,
Rafał Miłecki, Zhang Rui, linux-arm-kernel
On 18 March 2017 at 01:09, Eric Anholt <eric@anholt.net> wrote:
> Rafał Miłecki <zajec5@gmail.com> writes:
>
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> This commit documents binding for BCM2835 SoC thermal used in Raspberry
>> Pi devices.
>
> There's already a native (non-firmware) thermal driver just waiting for
> the maintainer to merge it.
>
> https://www.spinics.net/lists/arm-kernel/msg566217.html
Oh my, you did a nice work there guys! Well, this patch can obviously
be dropped.
--
Rafał
_______________________________________________
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] 12+ messages in thread
* [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal
@ 2017-03-18 8:58 ` Rafał Miłecki
0 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2017-03-18 8:58 UTC (permalink / raw)
To: linux-arm-kernel
On 18 March 2017 at 01:09, Eric Anholt <eric@anholt.net> wrote:
> Rafa? Mi?ecki <zajec5@gmail.com> writes:
>
>> From: Rafa? Mi?ecki <rafal@milecki.pl>
>>
>> This commit documents binding for BCM2835 SoC thermal used in Raspberry
>> Pi devices.
>
> There's already a native (non-firmware) thermal driver just waiting for
> the maintainer to merge it.
>
> https://www.spinics.net/lists/arm-kernel/msg566217.html
Oh my, you did a nice work there guys! Well, this patch can obviously
be dropped.
--
Rafa?
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-03-18 8:58 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18 0:01 [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal Rafał Miłecki
2017-03-18 0:01 ` Rafał Miłecki
2017-03-18 0:01 ` [PATCH 2/2] thermal: broadcom: add Raspberry Pi thermal driver Rafał Miłecki
2017-03-18 0:01 ` Rafał Miłecki
[not found] ` <20170318000132.9212-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-18 0:06 ` [PATCH V2 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal Rafał Miłecki
2017-03-18 0:06 ` Rafał Miłecki
[not found] ` <20170318000603.10158-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-18 0:06 ` [PATCH V2 2/2] thermal: broadcom: add Raspberry Pi thermal driver Rafał Miłecki
2017-03-18 0:06 ` Rafał Miłecki
2017-03-18 0:09 ` [PATCH 1/2] dt-bindings: thermal: add support for Raspberry Pi thermal Eric Anholt
2017-03-18 0:09 ` Eric Anholt
2017-03-18 8:58 ` Rafał Miłecki
2017-03-18 8:58 ` Rafał Miłecki
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.