From 1fad2cb852581ff34c2f115ec07b1bba9eef8342 Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Tue, 6 Sep 2022 13:30:35 +0200 Subject: [PATCH] thermal: add sandbox driver Provide a simple sandbox driver for the thermal uclass. It simply registers and returns 100 degrees C if requested. Signed-off-by: Robert Marko Reviewed-by: Simon Glass --- arch/sandbox/dts/sandbox.dtsi | 4 ++++ arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox_defconfig | 2 ++ configs/sandbox_flattree_defconfig | 2 ++ configs/sandbox_noinst_defconfig | 2 ++ configs/sandbox_spl_defconfig | 2 ++ configs/sandbox_vpl_defconfig | 2 ++ drivers/thermal/Makefile | 1 + drivers/thermal/thermal_sandbox.c | 36 ++++++++++++++++++++++++++++++ 9 files changed, 55 insertions(+) create mode 100644 drivers/thermal/thermal_sandbox.c diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index de7a218f45..d2db1ea522 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -443,6 +443,10 @@ sandbox_tee { compatible = "sandbox,tee"; }; + + thermal { + compatible = "sandbox,thermal"; + }; }; &cros_ec { diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index a7b49f315b..b853e13f92 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1694,6 +1694,10 @@ compatible = "sandbox,regmap_test"; }; }; + + thermal { + compatible = "sandbox,thermal"; + }; }; #include "sandbox_pmic.dtsi" diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 195271463b..1f821cd472 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -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 diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index a2eb7afcf9..fdd7b35118 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -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 diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig index 8bf10bb3ee..8e69f084ed 100644 --- a/configs/sandbox_noinst_defconfig +++ b/configs/sandbox_noinst_defconfig @@ -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 diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index c33f17186d..af5092b5ca 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -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 diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig index be8186ead3..c31adbbcf7 100644 --- a/configs/sandbox_vpl_defconfig +++ b/configs/sandbox_vpl_defconfig @@ -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 diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 15fe847d9f..8acc7d20cb 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -4,6 +4,7 @@ # Author: Nitin Garg 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 index 0000000000..acc364feb0 --- /dev/null +++ b/drivers/thermal/thermal_sandbox.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2022 Sartura Ltd. + * Written by Robert Marko + * + * Sandbox driver for the thermal uclass. + */ + +#include +#include +#include + +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, +}; -- 2.39.5