From patchwork Tue Sep 6 11:30:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 1674759 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WNaYPPCf; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MMPPP6Qwlz1yh5 for ; Tue, 6 Sep 2022 22:11:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AC00C84A2F; Tue, 6 Sep 2022 14:10:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WNaYPPCf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E4827849B9; Tue, 6 Sep 2022 13:30:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C2E89849C9 for ; Tue, 6 Sep 2022 13:30:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=robimarko@gmail.com Received: by mail-ed1-x52e.google.com with SMTP id s11so14682180edd.13 for ; Tue, 06 Sep 2022 04:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=lNrRuXnczfcm/GCknCnGJFSb8fPiEBtPLAn+3MD9GfE=; b=WNaYPPCfmsPSE7f/YANDMEglUpRHMKIhE7bVJKm0eEnbSp933MUKhhFp0hjdE/Z0lD 7xmFv9wzx1YBwzYIDRXe7Rn7h7wYnwSKG5p0nNqLkWEsLnUTUKKAcxQZFupSsvJfjqzF 5IRrbhPYohEBhcagTLxKgnw89qhSWV1xbNQdKtIDmk4Zh0LCchlBbSigy+ZDL8Qdpev/ /AuBLiUPSM5eDlOJJyZOdwsWNk3I4Hm3uhJEueOrL+7KrsmUwrpl5EyuQOwt7GNeoT+U RdeX8a7eYu0BlyQ+qNvZO6Yit169NvQJWFU+3FX74QGrHe0eVKd0BP++xRKK7iDIL9yc f4TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=lNrRuXnczfcm/GCknCnGJFSb8fPiEBtPLAn+3MD9GfE=; b=1wA2RHyxSmM9NiZQ8MRqVxjlSS/B+41N9xdaVSkmBbZqmclEusT3WyU1uJ+zV9vo0X IzvdQeP+l176gizdTPs3AZeNy8y4Vo8vruv7BJug3A4VH6cpc2vVDN5uAk74Zis+pszq 9MdTHoW+0uqyVNd0E/tkWqqoaiWryzl8wPweGc3lje9GGMBwdOBlMIQaOugAVFmK346z RPkAKzYjenEOLuaubK2nFx17bpKRRTyVpXhphZGszUOCtCoPjjBwvFSMqisv5X3IgSJf lZ93kUNYx9UTm96mK4ZTdS+9fQVO4OYtAufsQkijiZHxA769SNm2xGmOlYORc8RwVBXp 5Q6g== X-Gm-Message-State: ACgBeo278PjaU5aPjvh5nFVSizDrpN+Zhb/YaevkX3WwXedca+WAxdMY MnxRiDh5A6uOQNGcGh1kUTM= X-Google-Smtp-Source: AA6agR7wK4MYJ/fWwCwQB6uoHOeTCL28s9GnMDDPWeITDnN9n88nRC/vWvYNkQui81ZHuVYxnn/ykA== X-Received: by 2002:aa7:ccd3:0:b0:44e:6c07:6b8 with SMTP id y19-20020aa7ccd3000000b0044e6c0706b8mr9723536edt.426.1662463841457; Tue, 06 Sep 2022 04:30:41 -0700 (PDT) Received: from fedora.. (dh207-96-48.xnet.hr. [88.207.96.48]) by smtp.googlemail.com with ESMTPSA id x68-20020a50baca000000b0044bfdbd8a33sm8310867ede.88.2022.09.06.04.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 04:30:41 -0700 (PDT) From: Robert Marko X-Google-Original-From: Robert Marko To: sjg@chromium.org, pali@kernel.org, u-boot@lists.denx.de, trini@konsulko.com Cc: luka.perkov@sartura.hr, Robert Marko Subject: [PATCH v3 3/4] thermal: add sandbox driver Date: Tue, 6 Sep 2022 13:30:35 +0200 Message-Id: <20220906113036.1768055-3-robert.marko@sartura.hr> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906113036.1768055-1-robert.marko@sartura.hr> References: <20220906113036.1768055-1-robert.marko@sartura.hr> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 06 Sep 2022 14:10:39 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 --- Changes in v3: * Enable thermal class and temperature command in Sandbox SPL, flattree and noinstall defconfigs as well to fix make check failing --- 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 ++ drivers/thermal/Makefile | 1 + drivers/thermal/thermal_sandbox.c | 36 ++++++++++++++++++++++++++++++ 8 files changed, 53 insertions(+) create mode 100644 drivers/thermal/thermal_sandbox.c diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index 56e6b38bfa..a7b6a010ea 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -439,6 +439,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 2761588f0d..e7cc5384d5 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1683,6 +1683,10 @@ compatible = "sandbox,regmap_test"; }; }; + + thermal { + compatible = "sandbox,thermal"; + }; }; #include "sandbox_pmic.dtsi" diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index ab5d3f19bf..80397a4a38 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -77,6 +77,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 @@ -280,6 +281,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 a8b439faa9..4c206afe53 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 @@ -185,6 +186,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 3d34d81731..c3d84bc61c 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 @@ -212,6 +213,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 76e8acd126..53c48d1285 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 @@ -215,6 +216,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/drivers/thermal/Makefile b/drivers/thermal/Makefile index 6dda62bcd1..f2ee1df394 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_SPARX5_THERMAL) += sparx5-temp.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, +};