From patchwork Tue Sep 6 11:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 1674756 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=qPQebMlj; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4MMPNz1xzPz1yh5 for ; Tue, 6 Sep 2022 22:10:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A6078849D9; Tue, 6 Sep 2022 14:10:43 +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="qPQebMlj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B1AD8499A; Tue, 6 Sep 2022 13:30:42 +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-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 3538F849AA for ; Tue, 6 Sep 2022 13:30:40 +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-ej1-x636.google.com with SMTP id lx1so22438939ejb.12 for ; Tue, 06 Sep 2022 04:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=udLo3G84zUIf+zXOeY0R1O0V3BrpkIK+M9z1Iii1crI=; b=qPQebMljo8tS3jTySa/Ips6hfg4D4NMWGfSHx5IrZY6Hszll6/tuHJcSQBlYRvQL5O AzfCDuqm3dWlmBDwoMhK9hKgVuvPqopvRpAO5xeP1Hz/239pb4fsGwRx+UrIaSWAnQLH 2CgHd8zESIaQMCi5iH/ACtZ8plGvftA8eeiyNyweQbpY1hlBsTLQsG5dYC/Q1gNSKMUG Q4Yp2Mqt4Ap7p8RJ1D4rZ2NwszOwVANYMt4LtW5qCK2wmDF2KEaW25fjk+SHoraOhMJr dT1k7YGkcYrMq3HszBZorMlaQTNxAaShSChbcnsrao03SWIo14Q3zfoMUwBNfEytb4/k 5m5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=udLo3G84zUIf+zXOeY0R1O0V3BrpkIK+M9z1Iii1crI=; b=WpPt9cny/2D4c+OaL8l0i1vficb+OQnqzOvhs1ck/WM3EhNx1VWIvoZDyjxzlX1HHm 1nckVpIxsFQdHRyVWL9Y6mUcPzx9h/fVbt/Nv/mkj3E9x0DidGI7CR2PzCgGnm0OKmLc 1tI8Q8yjgKgL22TDLi3dkTrAMVf+if94/UFt8xuMKtrfBugQyjeVV7Rg58Er117/xWr5 EvmCLsIHXusYnXWdrmLSWu5b6xw6jg6i5a5yB1frXsC0pKsHg6LfTiCI42DQltSRL579 FpY4jezJ38tUf4Ks+6cv8AQhpgKXv8XWEJ0/lTHGiK7eIx8a4EXiKIPII6FDW5FSM6Ca SMZw== X-Gm-Message-State: ACgBeo3DlBb7t1d7JiGRu+iLEXHtHR5OQyzzA5bR+qBahwvgu4WJgE6t YZzZNWNJyUuEZVWnM8xkZdI= X-Google-Smtp-Source: AA6agR7byIfq8EMFd7KjMKiWC884Ea/0AnQ4iiUktdQ3yPdkDdSBerPU5IbvcA37FbS0DpGs+CzxvQ== X-Received: by 2002:a17:907:9625:b0:730:ad62:9c86 with SMTP id gb37-20020a170907962500b00730ad629c86mr38704454ejc.281.1662463839581; Tue, 06 Sep 2022 04:30:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 04:30:38 -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 1/4] cmd: add temperature command Date: Tue, 6 Sep 2022 13:30:33 +0200 Message-Id: <20220906113036.1768055-1-robert.marko@sartura.hr> X-Mailer: git-send-email 2.37.3 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 Currently, there is no way for users to check the readings from thermal sensors from U-boot console, only some boards print it during boot. So, lets add a simple "temperature" command that allows listing thermal uclass devices and getting their value. Note that the thermal devices are intenionally probed if list is used as almost always they will not get probed otherwise and there is no way for users to manually call probe on a certain device from console. Assumption is made that temperature is returned in degrees C and not milidegrees like in Linux as this is what most drivers seem to return. Signed-off-by: Robert Marko Reviewed-by: Simon Glass --- Changes in v2: * Drop by using uclass_get_device_by_name() * Make the unit clear in help * Expand Kconfig boolean and help * Drop degree symbol as test doesnt work with it. --- cmd/Kconfig | 6 ++++ cmd/Makefile | 1 + cmd/temperature.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 cmd/temperature.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 8ea064b8d2..4376909ca8 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1445,6 +1445,12 @@ config DEFAULT_SPI_MODE depends on CMD_SPI default 0 +config CMD_TEMPERATURE + bool "temperature - display the temperature from thermal sensors" + depends on DM_THERMAL + help + Provides a way to list thermal sensors and to get their readings. + config CMD_TSI148 bool "tsi148 - Command to access tsi148 device" help diff --git a/cmd/Makefile b/cmd/Makefile index 6e87522b62..141e440d01 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -152,6 +152,7 @@ obj-$(CONFIG_CMD_STRINGS) += strings.o obj-$(CONFIG_CMD_SMC) += smccc.o obj-$(CONFIG_CMD_SYSBOOT) += sysboot.o obj-$(CONFIG_CMD_STACKPROTECTOR_TEST) += stackprot_test.o +obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o obj-$(CONFIG_CMD_TERMINAL) += terminal.o obj-$(CONFIG_CMD_TIME) += time.o obj-$(CONFIG_CMD_TIMER) += timer.o diff --git a/cmd/temperature.c b/cmd/temperature.c new file mode 100644 index 0000000000..420965de14 --- /dev/null +++ b/cmd/temperature.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Copyright (c) 2022 Sartura Ltd. + * Written by Robert Marko + */ + +#include +#include +#include +#include + +#define LIMIT_DEVNAME 30 + +static int do_get(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + int ret, temp; + + if (argc < 2) { + printf("thermal device not selected\n"); + return CMD_RET_FAILURE; + } + + ret = uclass_get_device_by_name(UCLASS_THERMAL, argv[1], &dev); + if (ret) { + printf("thermal device not found\n"); + return CMD_RET_FAILURE; + } + + ret = thermal_get_temp(dev, &temp); + if (ret) + return CMD_RET_FAILURE; + + printf("%s: %d C\n", dev->name, temp); + + return CMD_RET_SUCCESS; +} + +static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + + printf("| %-*.*s| %-*.*s| %s\n", + LIMIT_DEVNAME, LIMIT_DEVNAME, "Device", + LIMIT_DEVNAME, LIMIT_DEVNAME, "Driver", + "Parent"); + + uclass_foreach_dev_probe(UCLASS_THERMAL, dev) { + printf("| %-*.*s| %-*.*s| %s\n", + LIMIT_DEVNAME, LIMIT_DEVNAME, dev->name, + LIMIT_DEVNAME, LIMIT_DEVNAME, dev->driver->name, + dev->parent->name); + } + + return CMD_RET_SUCCESS; +} + +static struct cmd_tbl temperature_subcmd[] = { + U_BOOT_CMD_MKENT(list, 1, 1, do_list, "", ""), + U_BOOT_CMD_MKENT(get, 2, 1, do_get, "", ""), +}; + +static int do_temperature(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cmd_tbl *cmd; + + argc--; + argv++; + + cmd = find_cmd_tbl(argv[0], temperature_subcmd, ARRAY_SIZE(temperature_subcmd)); + if (!cmd || argc > cmd->maxargs) + return CMD_RET_USAGE; + + return cmd->cmd(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD(temperature, CONFIG_SYS_MAXARGS, 1, do_temperature, + "thermal sensor temperature", + "list\t\tshow list of temperature sensors\n" + "get [thermal device name]\tprint temperature in degrees C" +); From patchwork Tue Sep 6 11:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 1674757 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=ZCN8u2vD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4MMPP96hz3z1yh5 for ; Tue, 6 Sep 2022 22:11:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 34A6684A14; Tue, 6 Sep 2022 14:10:46 +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="ZCN8u2vD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 81F1B849AA; 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-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 D580D849B9 for ; Tue, 6 Sep 2022 13:30:40 +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-x533.google.com with SMTP id 29so9640100edv.2 for ; Tue, 06 Sep 2022 04:30:40 -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=I6R6iWwZqoZjON1RtstLU4QYFbOhYvszvnGDkuTB4ug=; b=ZCN8u2vDYZsTqBApc4D9QLH4z0xTaKO0F2bdanrkKJCNB6yBffAOn/tMCSMwoh2SGV LUUPHyxpeCasW8MwHs/72BgjNn73B0VbzVXrgg1HCz71M/X5IJZISEpP/7mV1Lownlv4 9YIuAIqU5MuV1AkQ7RGpV7AttjU0AgunfALSi8rfcJWI24WDcFmEragh76frtnPA8A+P Ec5ignFgW7EL0U6jPZQxgLwvD8fzh8LoTDW0LLBFObqWfgAs5SrKHRkX3Lwaj5Bw0rAM g4X03ziQEd7cz+HOipveEimdjU8LKcPoGSwVntwVLh7R5Q018eFFdMa011fdEjxGR+KU VAOQ== 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=I6R6iWwZqoZjON1RtstLU4QYFbOhYvszvnGDkuTB4ug=; b=Vt5JsN4j/E2Az1zLsLUqb0M+8UW+2rSCeVocJXBlSHaGCEtD0Efjs4Z4GBmv/uA/6a ymFYRUc4mbq5CmJ5LuLgz3jFZwrJhmx5t/dZAAK37n+VBpYOFMFRxB2KOc7zVUN6JmfM C0i46anPzLXvts9e9mP4vGvSln3P9oDvhYO11NGQWpN8kcKzudMibkDnbeTWuPHkOp8t CIYBdakAgjcLJYB5ucXa19IT4a4pi4suYZlz91sIXVye5SzRMu5G1MeJ7SHb8fEPMWYX dyk+ibFRd6+Zvm7XmbVgIq31O9YFdXvFOMj04s5DxmBFSrSeSwbc1xqj2Xhy/TI8w2RN 9NMg== X-Gm-Message-State: ACgBeo0V+3fhnm970/CxCqR39NGHtbW8uiJGyOAZj0fX4l6sw+0DcAnW zBu6RwXHzz9zXWtRa68HFvY= X-Google-Smtp-Source: AA6agR6k6GQ2t9K8Kacnuey3tSyfsPmfdsGz1BpkEQNXgiSuHUkXXadVizLecN6AezdokP66XZ/NdA== X-Received: by 2002:aa7:db8b:0:b0:44e:5ce1:f29a with SMTP id u11-20020aa7db8b000000b0044e5ce1f29amr10247213edt.109.1662463840465; Tue, 06 Sep 2022 04:30:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 04:30:40 -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 2/4] doc: cmd: temperature: add documentation Date: Tue, 6 Sep 2022 13:30:34 +0200 Message-Id: <20220906113036.1768055-2-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 Add documentation for the temperature command. Signed-off-by: Robert Marko Reviewed-by: Simon Glass --- doc/usage/cmd/temperature.rst | 50 +++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + 2 files changed, 51 insertions(+) create mode 100644 doc/usage/cmd/temperature.rst diff --git a/doc/usage/cmd/temperature.rst b/doc/usage/cmd/temperature.rst new file mode 100644 index 0000000000..a5144ec50f --- /dev/null +++ b/doc/usage/cmd/temperature.rst @@ -0,0 +1,50 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +temperature command +=================== + +Synopsis +-------- + +:: + + temperature list + temperature get [thermal device name] + +Description +----------- + +The *temperature* command is used to list thermal sensors and get their +readings. + +The 'temperature list' command diplays the available thermal devices. + +The 'temperature get' command is used to get the reading in degrees C from +the desired device which is selected by passing its device name. + + thermal device name + device name of thermal sensor to select + +Example +------- + +:: + + + => temperature list + | Device | Driver | Parent + | tmon@610508110 | sparx5-temp | axi@600000000 + => + => temperature get tmon@610508110 + tmon@610508110: 42 C + +Configuration +------------- + +The *temperature* command is only available if CONFIG_CMD_TEMPERATURE=y. + +Return value +------------ + +The return value $? is set to 0 (true) if the command succeeded and to 1 (false) +otherwise. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 28f9683a3e..92967efdd2 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -63,6 +63,7 @@ Shell commands cmd/scp03 cmd/setexpr cmd/size + cmd/temperature cmd/true cmd/ums cmd/wdt 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, +}; From patchwork Tue Sep 6 11:30:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 1674761 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=FRDSrLV6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4MMPPg4JWRz1yh5 for ; Tue, 6 Sep 2022 22:11:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C497D84A56; Tue, 6 Sep 2022 14:10:50 +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="FRDSrLV6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4B800849AA; Tue, 6 Sep 2022 13:30:45 +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-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 E92148499C for ; Tue, 6 Sep 2022 13:30:42 +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-ej1-x629.google.com with SMTP id fy31so22481311ejc.6 for ; Tue, 06 Sep 2022 04:30:42 -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=B3Z1UmgAOVrj9dbkFL1usgjv6yZ4ZNUgXjxVbeNtVUU=; b=FRDSrLV6ItlzpWlPEeYWig9ShaWa0/bmm4v7wNd7B9ljzyvU/VsN1R2gFIpfWYj53S v6LMmCAmhODTmeDsRVUB+506Qz74ypuRCueMyBa73ZXYEn96C/8B6gz/HaYtLvFia8YU sSzbSPXFwb7Z6XR4suvU7WXrzXuM3GqTcHbx70pn6h+J5d0aHsaag5aykf1caz1kXXsR DTM999XZqPKDig1rVWO859GwqWbmJpCb2lcVKa77LagrW8jq17K8A17lOv2axbbKQYnB 9ieEH43NirJRENiH+6v4DiMSoXMtwDqjdkTIpP8fF6A1JSTbRyauV358/Q+HxGeht+1m qICQ== 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=B3Z1UmgAOVrj9dbkFL1usgjv6yZ4ZNUgXjxVbeNtVUU=; b=QmQOEsKiEB7IEbRrcDX/YVLMbchEPLBcn5XzmmSB3leA4RXzd1qbr1r36qe8tsGFGu XLYrMV2l50x/iYxNdE/D3071Bu1IDqj04MQriHFLXfi5MCmmU62G2Ea2EFHStpTRtjQS 6x9LlsT3SuG5W2Yj4lcYOyZV/g9Bv6pb6Az7qzMclLRNV6F2uIfm4tOWJEBVOUQFwxGP ld8EfYy40gO0RJ+Oc/+nR2M8ECWflKfmTtMyyGmiU3JwCQ+Shor+N+cgTWM9H1qQDxGZ gVVXJo3g6ef37jsn/mNoBf88VRyC/Y6kDYp1WgqaWPaIx5uGFblg8Ea4+34Hel71eSsK d2qw== X-Gm-Message-State: ACgBeo0nquCqYwv44oG4uEexRJCKJI82pQFCl17GRH4xj/oKVYRAyvTW QFkc+Ukiv89WD344uV5/ydY= X-Google-Smtp-Source: AA6agR5OKzYkW755IOdQR+aWglFXaDxEbSyrE/ao/5LRe3ainwWD5OMJGvewEivT7wJ4u2X7xy40pQ== X-Received: by 2002:a17:907:20d1:b0:731:5169:106b with SMTP id qq17-20020a17090720d100b007315169106bmr40358640ejb.667.1662463842312; Tue, 06 Sep 2022 04:30:42 -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.41 (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 4/4] test: cmd: add test for temperature command Date: Tue, 6 Sep 2022 13:30:36 +0200 Message-Id: <20220906113036.1768055-4-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 Add simple test for the temperature command. Signed-off-by: Robert Marko Reviewed-by: Simon Glass --- test/cmd/Makefile | 1 + test/cmd/temperature.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/cmd/temperature.c diff --git a/test/cmd/Makefile b/test/cmd/Makefile index c331757425..f9493357a5 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o obj-$(CONFIG_CMD_PINMUX) += pinmux.o obj-$(CONFIG_CMD_PWM) += pwm.o obj-$(CONFIG_CMD_SETEXPR) += setexpr.o +obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o diff --git a/test/cmd/temperature.c b/test/cmd/temperature.c new file mode 100644 index 0000000000..2a1ea0611d --- /dev/null +++ b/test/cmd/temperature.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Executes tests for temperature command + * + * Copyright (C) 2022 Sartura Ltd. + */ + +#include +#include +#include +#include +#include +#include + +static int dm_test_cmd_temperature(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_get_device(UCLASS_THERMAL, 0, &dev)); + ut_assertnonnull(dev); + + ut_assertok(console_record_reset_enable()); + + /* Test that "temperature list" shows the sandbox device */ + ut_assertok(run_command("temperature list", 0)); + ut_assert_nextline("| Device | Driver | Parent"); + ut_assert_nextline("| thermal | thermal-sandbox | root_driver"); + ut_assert_console_end(); + + /* Test that "temperature get thermal" returns expected value */ + console_record_reset(); + ut_assertok(run_command("temperature get thermal", 0)); + ut_assert_nextline("thermal: 100 C"); + ut_assert_console_end(); + + return 0; +} + +DM_TEST(dm_test_cmd_temperature, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);