]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
thermal: add sandbox driver
authorRobert Marko <robimarko@gmail.com>
Tue, 6 Sep 2022 11:30:35 +0000 (13:30 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 11 Oct 2022 20:03:03 +0000 (16:03 -0400)
Provide a simple sandbox driver for the thermal uclass.
It simply registers and returns 100 degrees C if requested.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/sandbox.dtsi
arch/sandbox/dts/test.dts
configs/sandbox_defconfig
configs/sandbox_flattree_defconfig
configs/sandbox_noinst_defconfig
configs/sandbox_spl_defconfig
configs/sandbox_vpl_defconfig
drivers/thermal/Makefile
drivers/thermal/thermal_sandbox.c [new file with mode: 0644]

index de7a218f4574ab90ee75b8ecd577fdddccd15527..d2db1ea5220afded50eaa08ee59f49d52e7dbd61 100644 (file)
        sandbox_tee {
                compatible = "sandbox,tee";
        };
+
+       thermal {
+               compatible = "sandbox,thermal";
+       };
 };
 
 &cros_ec {
index a7b49f315bebea9ed71e157de7cba6007f1a4c16..b853e13f9222b41eec07a611baa0a071d050f5a7 100644 (file)
                        compatible = "sandbox,regmap_test";
                };
        };
+
+       thermal {
+               compatible = "sandbox,thermal";
+       };
 };
 
 #include "sandbox_pmic.dtsi"
index 195271463ba539a16b3afe13b38fda57539b9931..1f821cd47210e7d937e95ca9ae70ae99ab0076f8 100644 (file)
@@ -79,6 +79,7 @@ CONFIG_CMD_PCI=y
 CONFIG_CMD_READ=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_TEMPERATURE=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_AXI=y
 CONFIG_CMD_SETEXPR_FMT=y
@@ -281,6 +282,7 @@ CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSINFO_GPIO=y
 CONFIG_SYSRESET=y
+CONFIG_DM_THERMAL=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
index a2eb7afcf9bd3f7cf1b3f2487c3373b29302aa25..fdd7b35118905b1879fbcfae69ff8b0da6256509 100644 (file)
@@ -45,6 +45,7 @@ CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_TEMPERATURE=y
 CONFIG_CMD_USB=y
 CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_TFTPPUT=y
@@ -186,6 +187,7 @@ CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSINFO_GPIO=y
 CONFIG_SYSRESET=y
+CONFIG_DM_THERMAL=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
index 8bf10bb3ee10d139cc54a4b15e25b81a4127c9f4..8e69f084ed703b182e0e8ed839e7d3a48d25180b 100644 (file)
@@ -62,6 +62,7 @@ CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_TEMPERATURE=y
 CONFIG_CMD_USB=y
 CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_TFTPPUT=y
@@ -213,6 +214,7 @@ CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSINFO_GPIO=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
+CONFIG_DM_THERMAL=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
index c33f17186de2c429d9e18760711bff85fbea2096..af5092b5ca95e67143142de8591a67a95166bbdc 100644 (file)
@@ -62,6 +62,7 @@ CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_TEMPERATURE=y
 CONFIG_CMD_USB=y
 CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_TFTPPUT=y
@@ -216,6 +217,7 @@ CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSINFO_GPIO=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
+CONFIG_DM_THERMAL=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
index be8186ead3215a98c6362b05d72e330bcf848be2..c31adbbcf73fec93d800f43c7e886b81de7a7124 100644 (file)
@@ -74,6 +74,7 @@ CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_TEMPERATURE=y
 CONFIG_CMD_USB=y
 CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_TFTPPUT=y
@@ -223,6 +224,7 @@ CONFIG_SYSINFO_GPIO=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_TPL_SYSRESET=y
+CONFIG_DM_THERMAL=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
index 15fe847d9f789910df9d2a6f169ec18a9a83aba3..8acc7d20cb9f0fbb04405c0900d314359e46101a 100644 (file)
@@ -4,6 +4,7 @@
 # Author: Nitin Garg <nitin.garg@freescale.com>
 
 obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o
+obj-$(CONFIG_SANDBOX) += thermal_sandbox.o
 obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
 obj-$(CONFIG_IMX_SCU_THERMAL) += imx_scu_thermal.o
 obj-$(CONFIG_TI_DRA7_THERMAL) += ti-bandgap.o
diff --git a/drivers/thermal/thermal_sandbox.c b/drivers/thermal/thermal_sandbox.c
new file mode 100644 (file)
index 0000000..acc364f
--- /dev/null
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022 Sartura Ltd.
+ * Written by Robert Marko <robert.marko@sartura.hr>
+ *
+ * Sandbox driver for the thermal uclass.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <thermal.h>
+
+int sandbox_thermal_get_temp(struct udevice *dev, int *temp)
+{
+       /* Simply return 100°C */
+       *temp = 100;
+
+       return 0;
+}
+
+static const struct dm_thermal_ops sandbox_thermal_ops = {
+       .get_temp = sandbox_thermal_get_temp,
+};
+
+static const struct udevice_id sandbox_thermal_ids[] = {
+       { .compatible = "sandbox,thermal" },
+       { }
+};
+
+U_BOOT_DRIVER(thermal_sandbox) = {
+       .name           = "thermal-sandbox",
+       .id             = UCLASS_THERMAL,
+       .of_match       = sandbox_thermal_ids,
+       .ops            = &sandbox_thermal_ops,
+       .flags          = DM_FLAG_PRE_RELOC,
+};