diff options
author | Robert Marko <robimarko@gmail.com> | 2022-09-06 14:30:35 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-10-11 23:03:03 +0300 |
commit | 1fad2cb852581ff34c2f115ec07b1bba9eef8342 (patch) | |
tree | a00251f882d95cce0e5e422b5b33299cda9390c0 /drivers/thermal | |
parent | 0995e81e10c10fda32c6dec350d14473d6d1d23e (diff) | |
download | u-boot-1fad2cb852581ff34c2f115ec07b1bba9eef8342.tar.xz |
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 <robert.marko@sartura.hr>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/Makefile | 1 | ||||
-rw-r--r-- | drivers/thermal/thermal_sandbox.c | 36 |
2 files changed, 37 insertions, 0 deletions
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 <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 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 <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, +}; |