Also removes random module and switches to new bcm2711 thermal driver.
Boot tested on RPi 4B v1.1 4G.
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
CONFIG_ARM_UNWIND=y
CONFIG_AUTO_ZRELADDR=y
CONFIG_BCM2708_VCMEM=y
+# CONFIG_BCM2711_THERMAL is not set
CONFIG_BCM2835_DEVGPIOMEM=y
CONFIG_BCM2835_FAST_MEMCPY=y
CONFIG_BCM2835_MBOX=y
CONFIG_BLK_DEV_SD=y
CONFIG_BLK_PM=y
CONFIG_BLK_SCSI_REQUEST=y
-# CONFIG_BRCMSTB_THERMAL is not set
CONFIG_BRCM_CHAR_DRIVERS=y
# CONFIG_CACHE_L2X0 is not set
CONFIG_CC_HAS_KASAN_GENERIC=y
CONFIG_HAVE_UID16=y
CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
CONFIG_HW_CONSOLE=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_BCM2835=y
CONFIG_HZ=100
CONFIG_HZ_100=y
CONFIG_HZ_FIXED=0
CONFIG_ASSOCIATIVE_ARRAY=y
CONFIG_AUTO_ZRELADDR=y
CONFIG_BCM2708_VCMEM=y
+CONFIG_BCM2711_THERMAL=y
CONFIG_BCM2835_DEVGPIOMEM=y
CONFIG_BCM2835_MBOX=y
CONFIG_BCM2835_POWER=y
CONFIG_BLK_PM=y
CONFIG_BLK_SCSI_REQUEST=y
CONFIG_BOUNCE=y
-CONFIG_BRCMSTB_THERMAL=y
CONFIG_BRCM_CHAR_DRIVERS=y
CONFIG_BROADCOM_PHY=y
# CONFIG_CACHE_L2X0 is not set
CONFIG_HIGHPTE=y
CONFIG_HOTPLUG_CPU=y
CONFIG_HW_CONSOLE=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_BCM2835=y
CONFIG_HZ=100
CONFIG_HZ_100=y
CONFIG_HZ_FIXED=0
CONFIG_ASSOCIATIVE_ARRAY=y
CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
CONFIG_BCM2708_VCMEM=y
+# CONFIG_BCM2711_THERMAL is not set
CONFIG_BCM2835_DEVGPIOMEM=y
CONFIG_BCM2835_MBOX=y
CONFIG_BCM2835_POWER=y
CONFIG_BLK_PM=y
CONFIG_BLK_SCSI_REQUEST=y
CONFIG_BOUNCE=y
-CONFIG_BRCMSTB_THERMAL=y
CONFIG_BRCM_CHAR_DRIVERS=y
CONFIG_CAVIUM_ERRATUM_22375=y
CONFIG_CAVIUM_ERRATUM_23154=y
CONFIG_HOLES_IN_ZONE=y
CONFIG_HOTPLUG_CPU=y
CONFIG_HW_CONSOLE=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_BCM2835=y
CONFIG_HZ=250
CONFIG_HZ_250=y
CONFIG_I2C=y
CONFIG_ASSOCIATIVE_ARRAY=y
CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
CONFIG_BCM2708_VCMEM=y
+CONFIG_BCM2711_THERMAL=y
CONFIG_BCM2835_DEVGPIOMEM=y
CONFIG_BCM2835_MBOX=y
CONFIG_BCM2835_POWER=y
CONFIG_BLK_PM=y
CONFIG_BLK_SCSI_REQUEST=y
CONFIG_BOUNCE=y
-CONFIG_BRCMSTB_THERMAL=y
CONFIG_BRCM_CHAR_DRIVERS=y
CONFIG_BROADCOM_PHY=y
CONFIG_CAVIUM_ERRATUM_22375=y
CONFIG_HOLES_IN_ZONE=y
CONFIG_HOTPLUG_CPU=y
CONFIG_HW_CONSOLE=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_BCM2835=y
CONFIG_HZ=250
CONFIG_HZ_250=y
CONFIG_I2C=y
$(eval $(call KernelPackage,pwm-bcm2835))
-define KernelPackage/random-bcm2835
- SUBMENU:=$(OTHER_MENU)
- TITLE:=BCM2835 HW Random Number Generator
- KCONFIG:= \
- CONFIG_HW_RANDOM_BCM2835
- FILES:=$(LINUX_DIR)/drivers/char/hw_random/bcm2835-rng.ko
- AUTOLOAD:=$(call AutoLoad,11,bcm2835-rng)
- DEPENDS:=@TARGET_bcm27xx +kmod-random-core
-endef
-
-define KernelPackage/random-bcm2835/description
- This package contains the Broadcom 2835 HW random number generator driver
-endef
-
-$(eval $(call KernelPackage,random-bcm2835))
-
-
define KernelPackage/smi-bcm2835
SUBMENU:=$(OTHER_MENU)
TITLE:=BCM2835 SMI driver
+++ /dev/null
-From d1066d775e67c33cc93178475c4485c5ef0a83c9 Mon Sep 17 00:00:00 2001
-From: Stefan Wahren <wahrenst@gmx.net>
-Date: Sat, 18 May 2019 12:26:11 +0200
-Subject: [PATCH] thermal: brcmstb_thermal: Add BCM2838 support
-
-The BCM2838 has an AVS TMON hardware block. This adds the necessary
-support to the brcmstb_thermal driver ( no trip handling ).
-
-Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
----
- drivers/thermal/broadcom/Kconfig | 2 +-
- drivers/thermal/broadcom/brcmstb_thermal.c | 61 +++++++++++++++++++---
- 2 files changed, 54 insertions(+), 9 deletions(-)
-
---- a/drivers/thermal/broadcom/Kconfig
-+++ b/drivers/thermal/broadcom/Kconfig
-@@ -9,7 +9,7 @@ config BCM2835_THERMAL
-
- config BRCMSTB_THERMAL
- tristate "Broadcom STB AVS TMON thermal driver"
-- depends on ARCH_BRCMSTB || COMPILE_TEST
-+ depends on ARCH_BRCMSTB || ARCH_BCM2835 || COMPILE_TEST
- help
- Enable this driver if you have a Broadcom STB SoC and would like
- thermal framework support.
---- a/drivers/thermal/broadcom/brcmstb_thermal.c
-+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
-@@ -10,6 +10,7 @@
- #define pr_fmt(fmt) DRV_NAME ": " fmt
-
- #include <linux/bitops.h>
-+#include <linux/clk.h>
- #include <linux/device.h>
- #include <linux/err.h>
- #include <linux/io.h>
-@@ -22,9 +23,6 @@
- #include <linux/thermal.h>
-
- #define AVS_TMON_STATUS 0x00
-- #define AVS_TMON_STATUS_valid_msk BIT(11)
-- #define AVS_TMON_STATUS_data_msk GENMASK(10, 1)
-- #define AVS_TMON_STATUS_data_shift 1
-
- #define AVS_TMON_EN_OVERTEMP_RESET 0x04
- #define AVS_TMON_EN_OVERTEMP_RESET_msk BIT(0)
-@@ -102,10 +100,19 @@ static struct avs_tmon_trip avs_tmon_tri
- },
- };
-
-+struct brcmstb_thermal_of_data {
-+ const struct thermal_zone_of_device_ops *of_ops;
-+ u32 status_valid_mask;
-+ u32 status_data_mask;
-+ u32 status_data_shift;
-+};
-+
- struct brcmstb_thermal_priv {
- void __iomem *tmon_base;
- struct device *dev;
- struct thermal_zone_device *thermal;
-+ struct clk *clk;
-+ const struct brcmstb_thermal_of_data *socdata;
- };
-
- /* Convert a HW code to a temperature reading (millidegree celsius) */
-@@ -142,17 +149,18 @@ static inline u32 avs_tmon_temp_to_code(
- static int brcmstb_get_temp(void *data, int *temp)
- {
- struct brcmstb_thermal_priv *priv = data;
-+ const struct brcmstb_thermal_of_data *socdata = priv->socdata;
- u32 val;
- long t;
-
- val = __raw_readl(priv->tmon_base + AVS_TMON_STATUS);
-
-- if (!(val & AVS_TMON_STATUS_valid_msk)) {
-+ if (!(val & socdata->status_valid_mask)) {
- dev_err(priv->dev, "reading not valid\n");
- return -EIO;
- }
-
-- val = (val & AVS_TMON_STATUS_data_msk) >> AVS_TMON_STATUS_data_shift;
-+ val = (val & socdata->status_data_mask) >> socdata->status_data_shift;
-
- t = avs_tmon_code_to_temp(priv->thermal, val);
- if (t < 0)
-@@ -277,13 +285,34 @@ static int brcmstb_set_trips(void *data,
- return 0;
- }
-
--static const struct thermal_zone_of_device_ops of_ops = {
-+static const struct thermal_zone_of_device_ops bcm7445_thermal_of_ops = {
- .get_temp = brcmstb_get_temp,
- .set_trips = brcmstb_set_trips,
- };
-
-+static const struct thermal_zone_of_device_ops bcm2838_thermal_of_ops = {
-+ .get_temp = brcmstb_get_temp,
-+};
-+
-+static const struct brcmstb_thermal_of_data bcm7445_thermal_of_data = {
-+ .of_ops = &bcm7445_thermal_of_ops,
-+ .status_valid_mask = BIT(11),
-+ .status_data_mask = GENMASK(10, 1),
-+ .status_data_shift = 1,
-+};
-+
-+static const struct brcmstb_thermal_of_data bcm2838_thermal_of_data = {
-+ .of_ops = &bcm2838_thermal_of_ops,
-+ .status_valid_mask = BIT(10),
-+ .status_data_mask = GENMASK(9, 0),
-+ .status_data_shift = 0,
-+};
-+
- static const struct of_device_id brcmstb_thermal_id_table[] = {
-- { .compatible = "brcm,avs-tmon" },
-+ { .compatible = "brcm,avs-tmon",
-+ .data = &bcm7445_thermal_of_data },
-+ { .compatible = "brcm,avs-tmon-bcm2838",
-+ .data = &bcm2838_thermal_of_data },
- {},
- };
- MODULE_DEVICE_TABLE(of, brcmstb_thermal_id_table);
-@@ -304,11 +333,27 @@ static int brcmstb_thermal_probe(struct
- if (IS_ERR(priv->tmon_base))
- return PTR_ERR(priv->tmon_base);
-
-+ priv->socdata = of_device_get_match_data(&pdev->dev);
-+ if (!priv->socdata) {
-+ dev_err(&pdev->dev, "no device match found\n");
-+ return -ENODEV;
-+ }
-+
-+ priv->clk = devm_clk_get(&pdev->dev, NULL);
-+ if (IS_ERR(priv->clk) && PTR_ERR(priv->clk) == -EPROBE_DEFER)
-+ return -EPROBE_DEFER;
-+
-+ if (!IS_ERR(priv->clk)) {
-+ 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,
-- &of_ops);
-+ priv->socdata->of_ops);
- if (IS_ERR(thermal)) {
- ret = PTR_ERR(thermal);
- dev_err(&pdev->dev, "could not register sensor: %d\n", ret);
+++ /dev/null
-From 9367715671c271913278a4abb43276d02ff954d6 Mon Sep 17 00:00:00 2001
-From: Phil Elwell <phil@raspberrypi.com>
-Date: Fri, 31 Jan 2020 09:33:40 +0000
-Subject: [PATCH] thermal: brcmstb_thermal: Correct SoC name
-
-The Pi 4 SoC is called BCM2711, not BCM2838.
-
-Fixes: "thermal: brcmstb_thermal: Add BCM2838 support"
-
-Signed-off-by: Phil Elwell <phil@raspberrypi.com>
----
- drivers/thermal/broadcom/brcmstb_thermal.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
---- a/drivers/thermal/broadcom/brcmstb_thermal.c
-+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
-@@ -290,7 +290,7 @@ static const struct thermal_zone_of_devi
- .set_trips = brcmstb_set_trips,
- };
-
--static const struct thermal_zone_of_device_ops bcm2838_thermal_of_ops = {
-+static const struct thermal_zone_of_device_ops bcm2711_thermal_of_ops = {
- .get_temp = brcmstb_get_temp,
- };
-
-@@ -301,8 +301,8 @@ static const struct brcmstb_thermal_of_d
- .status_data_shift = 1,
- };
-
--static const struct brcmstb_thermal_of_data bcm2838_thermal_of_data = {
-- .of_ops = &bcm2838_thermal_of_ops,
-+static const struct brcmstb_thermal_of_data bcm2711_thermal_of_data = {
-+ .of_ops = &bcm2711_thermal_of_ops,
- .status_valid_mask = BIT(10),
- .status_data_mask = GENMASK(9, 0),
- .status_data_shift = 0,
-@@ -311,8 +311,8 @@ static const struct brcmstb_thermal_of_d
- static const struct of_device_id brcmstb_thermal_id_table[] = {
- { .compatible = "brcm,avs-tmon",
- .data = &bcm7445_thermal_of_data },
-- { .compatible = "brcm,avs-tmon-bcm2838",
-- .data = &bcm2838_thermal_of_data },
-+ { .compatible = "brcm,avs-tmon-bcm2711",
-+ .data = &bcm2711_thermal_of_data },
- {},
- };
- MODULE_DEVICE_TABLE(of, brcmstb_thermal_id_table);
--- /dev/null
+From f70be37d1bd6b68ed38022580b16c972598901e2 Mon Sep 17 00:00:00 2001
+From: David Plowman <david.plowman@raspberrypi.com>
+Date: Thu, 28 May 2020 11:09:48 +0100
+Subject: [PATCH] media: bcm2835-unicam: change minimum number of
+ vb2_queue buffers to 1
+
+Since the unicam driver was modified to write to a dummy buffer when no
+user-supplied buffer is available, it can now write to and return a
+buffer even when there's only a single one. Enable this by changing the
+min_buffers_needed in the vb2_queue; it will be useful for enabling
+still captures without allocating more memory than absolutely necessary.
+
+Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
+---
+ drivers/media/platform/bcm2835/bcm2835-unicam.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
++++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
+@@ -2404,7 +2404,7 @@ static int register_node(struct unicam_d
+ q->buf_struct_size = sizeof(struct unicam_buffer);
+ q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ q->lock = &node->lock;
+- q->min_buffers_needed = 2;
++ q->min_buffers_needed = 1;
+ q->dev = &unicam->pdev->dev;
+
+ ret = vb2_queue_init(q);
--- /dev/null
+From 5bf715958613e73008ed107182306fb4f37024e5 Mon Sep 17 00:00:00 2001
+From: Stefan Wahren <stefan.wahren@i2se.com>
+Date: Mon, 13 Jan 2020 19:56:15 +0100
+Subject: [PATCH] dt-bindings: Add Broadcom AVS RO thermal
+
+Commit ee31ff373da6602e7a4e60fe11322b41ac38eb22 upstream.
+
+Since the BCM2711 doesn't have a AVS TMON block, the thermal information
+must be retrieved from the AVS ring oscillator block. This block is part
+of the AVS monitor which contains a bunch of raw sensors.
+
+Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+Link: https://lore.kernel.org/r/1578941778-23321-2-git-send-email-stefan.wahren@i2se.com
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ .../bindings/thermal/brcm,avs-ro-thermal.yaml | 45 +++++++++++++++++++
+ 1 file changed, 45 insertions(+)
+ create mode 100644 Documentation/devicetree/bindings/thermal/brcm,avs-ro-thermal.yaml
+
+--- /dev/null
++++ b/Documentation/devicetree/bindings/thermal/brcm,avs-ro-thermal.yaml
+@@ -0,0 +1,45 @@
++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
++%YAML 1.2
++---
++$id: http://devicetree.org/schemas/thermal/brcm,avs-ro-thermal.yaml#
++$schema: http://devicetree.org/meta-schemas/core.yaml#
++
++title: Broadcom AVS ring oscillator thermal
++
++maintainers:
++ - Stefan Wahren <wahrenst@gmx.net>
++
++description: |+
++ The thermal node should be the child of a syscon node with the
++ required property:
++
++ - compatible: Should be one of the following:
++ "brcm,bcm2711-avs-monitor", "syscon", "simple-mfd"
++
++ Refer to the the bindings described in
++ Documentation/devicetree/bindings/mfd/syscon.txt
++
++properties:
++ compatible:
++ const: brcm,bcm2711-thermal
++
++ reg:
++ maxItems: 1
++
++required:
++ - compatible
++ - reg
++
++examples:
++ - |
++ avs-monitor@7d5d2000 {
++ compatible = "brcm,bcm2711-avs-monitor",
++ "syscon", "simple-mfd";
++ reg = <0x7d5d2000 0xf00>;
++
++ thermal: thermal {
++ compatible = "brcm,bcm2711-thermal";
++ #thermal-sensor-cells = <0>;
++ };
++ };
++...
--- /dev/null
+From 84477b71c184345517625f5c3eccf26a29eac4df Mon Sep 17 00:00:00 2001
+From: Stefan Wahren <stefan.wahren@i2se.com>
+Date: Mon, 13 Jan 2020 19:56:16 +0100
+Subject: [PATCH] thermal: Add BCM2711 thermal driver
+
+Commit 59b781352dc4cb9ae27a8ddae0cda979d29d8af7 upstream.
+
+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 <stefan.wahren@i2se.com>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+Link: https://lore.kernel.org/r/1578941778-23321-3-git-send-email-stefan.wahren@i2se.com
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ drivers/thermal/broadcom/Kconfig | 7 ++
+ drivers/thermal/broadcom/Makefile | 1 +
+ drivers/thermal/broadcom/bcm2711_thermal.c | 123 +++++++++++++++++++++
+ 3 files changed, 131 insertions(+)
+ create mode 100644 drivers/thermal/broadcom/bcm2711_thermal.c
+
+--- a/drivers/thermal/broadcom/Kconfig
++++ b/drivers/thermal/broadcom/Kconfig
+@@ -1,4 +1,11 @@
+ # 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 THERMAL_OF && MFD_SYSCON
++ help
++ Support for thermal sensors on Broadcom BCM2711 SoCs.
++
+ config BCM2835_THERMAL
+ tristate "Thermal sensors on bcm2835 SoC"
+ depends on ARCH_BCM2835 || COMPILE_TEST
+--- 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
+--- /dev/null
++++ b/drivers/thermal/broadcom/bcm2711_thermal.c
+@@ -0,0 +1,123 @@
++// SPDX-License-Identifier: GPL-2.0+
++/*
++ * Broadcom AVS RO thermal sensor driver
++ *
++ * based on brcmstb_thermal
++ *
++ * Copyright (C) 2020 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/mfd/syscon.h>
++#include <linux/module.h>
++#include <linux/platform_device.h>
++#include <linux/of_device.h>
++#include <linux/regmap.h>
++#include <linux/thermal.h>
++
++#include "../thermal_hwmon.h"
++
++#define AVS_RO_TEMP_STATUS 0x200
++#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 {
++ struct regmap *regmap;
++ 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;
++ int ret;
++ long t;
++
++ ret = regmap_read(priv->regmap, AVS_RO_TEMP_STATUS, &val);
++ if (ret)
++ return ret;
++
++ if (!(val & AVS_RO_TEMP_STATUS_VALID_MSK))
++ return -EIO;
++
++ val &= AVS_RO_TEMP_STATUS_DATA_MSK;
++
++ /* Convert a HW code to a temperature reading (millidegree celsius) */
++ t = slope * val + offset;
++
++ *temp = t < 0 ? 0 : 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 device *dev = &pdev->dev;
++ struct device_node *parent;
++ struct regmap *regmap;
++ int ret;
++
++ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
++ if (!priv)
++ return -ENOMEM;
++
++ /* get regmap from syscon node */
++ parent = of_get_parent(dev->of_node); /* parent should be syscon node */
++ regmap = syscon_node_to_regmap(parent);
++ of_node_put(parent);
++ if (IS_ERR(regmap)) {
++ ret = PTR_ERR(regmap);
++ dev_err(dev, "failed to get regmap: %d\n", ret);
++ return ret;
++ }
++ priv->regmap = regmap;
++
++ thermal = devm_thermal_zone_of_sensor_register(dev, 0, priv,
++ &bcm2711_thermal_of_ops);
++ if (IS_ERR(thermal)) {
++ ret = PTR_ERR(thermal);
++ dev_err(dev, "could not register sensor: %d\n", ret);
++ return ret;
++ }
++
++ priv->thermal = thermal;
++
++ thermal->tzp->no_hwmon = false;
++ ret = thermal_add_hwmon_sysfs(thermal);
++ if (ret)
++ return ret;
++
++ return 0;
++}
++
++static struct platform_driver bcm2711_thermal_driver = {
++ .probe = bcm2711_thermal_probe,
++ .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");
--- /dev/null
+From 642811db6c894ee89808764d8240aa2b5b7ed4e0 Mon Sep 17 00:00:00 2001
+From: Stefan Wahren <stefan.wahren@i2se.com>
+Date: Mon, 13 Jan 2020 19:56:17 +0100
+Subject: [PATCH] ARM: dts: bcm2711: Enable thermal
+
+Commit a1d6989bf12b01cd9198e2c31a96678ac9c47415 upstream.
+
+This enables thermal for the BCM2711 (used on Raspberry Pi 4) by adding
+the AVS monitor and a subnode for the thermal part.
+
+Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
+Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+Link: https://lore.kernel.org/r/1578941778-23321-4-git-send-email-stefan.wahren@i2se.com
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ arch/arm/boot/dts/bcm2711.dtsi | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+--- a/arch/arm/boot/dts/bcm2711.dtsi
++++ b/arch/arm/boot/dts/bcm2711.dtsi
+@@ -64,6 +64,17 @@
+ IRQ_TYPE_LEVEL_HIGH)>;
+ };
+
++ avs_monitor: avs-monitor@7d5d2000 {
++ compatible = "brcm,bcm2711-avs-monitor",
++ "syscon", "simple-mfd";
++ reg = <0x7d5d2000 0xf00>;
++
++ thermal: thermal {
++ compatible = "brcm,bcm2711-thermal";
++ #thermal-sensor-cells = <0>;
++ };
++ };
++
+ dma: dma@7e007000 {
+ compatible = "brcm,bcm2835-dma";
+ reg = <0x7e007000 0xb00>;
+@@ -514,6 +525,7 @@
+
+ &cpu_thermal {
+ coefficients = <(-487) 410040>;
++ thermal-sensors = <&thermal>;
+ };
+
+ &dsi0 {
--- /dev/null
+From 2c262ae9cfd82b5b65bbb86a98da6a10c11db367 Mon Sep 17 00:00:00 2001
+From: Chen-Yu Tsai <wens@csie.org>
+Date: Thu, 14 May 2020 17:39:30 +0800
+Subject: [PATCH] ARM: dts: bcm2711-rpi: Remove downstream thermal
+ sensor node
+
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ arch/arm/boot/dts/bcm2711-rpi.dtsi | 14 --------------
+ 1 file changed, 14 deletions(-)
+
+--- a/arch/arm/boot/dts/bcm2711-rpi.dtsi
++++ b/arch/arm/boot/dts/bcm2711-rpi.dtsi
+@@ -50,16 +50,6 @@
+ };
+
+ &soc {
+- thermal: thermal@7d5d2200 {
+- compatible = "brcm,avs-tmon-bcm2711";
+- reg = <0x7d5d2200 0x2c>;
+- interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
+- interrupt-names = "tmon";
+- clocks = <&clocks BCM2835_CLOCK_TSENS>;
+- #thermal-sensor-cells = <0>;
+- status = "okay";
+- };
+-
+ /delete-node/ audio;
+ };
+
+@@ -177,10 +167,6 @@
+ <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
+ };
+
+-&cpu_thermal {
+- thermal-sensors = <&thermal>;
+-};
+-
+ &genet {
+ compatible = "brcm,bcm2711-genet-v5", "brcm,genet-v5";
+ };