From patchwork Fri Sep 17 07:27:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12501311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF9D3C433EF for ; Fri, 17 Sep 2021 07:25:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9634D6113E for ; Fri, 17 Sep 2021 07:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236277AbhIQH1H (ORCPT ); Fri, 17 Sep 2021 03:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234640AbhIQH1G (ORCPT ); Fri, 17 Sep 2021 03:27:06 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EADC061764 for ; Fri, 17 Sep 2021 00:25:44 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id q11so13541362wrr.9 for ; Fri, 17 Sep 2021 00:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y4d5OAb4cgWF2zYKyVkgoZXkk7R3WAwmBlyHddfAZBk=; b=0PXYxtvF3gigYifimzVnGXkU5t9bm+Nz7pn5cAnGnjUQXZkEZGT5njvCmyFo6jtYON fEuF28Yzj+sngIuI7/DpAHcGLnYRhk2i1FMaNIn2OpJIEq95LbgKkIAhimn2THuFckC3 snrvoq5gOpNIVpsaqGlipeSapbgh3tAUnod+ZVtezDIunpfuOYRUN+IO/aJKoqfCwnBk vbc9+OXBW0uq+6TqQ7+TWnRB5ekawkiUfrnyQ8ByaP7tU2THCFnQ6xOmcQX//0xi4Yer DnEQE0Vi66JWgy4Oa2Uc9luE06afkFKPSR4uxWSwVQSBwH7iE0ZLdnL054MsJo9Qnx76 H/Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y4d5OAb4cgWF2zYKyVkgoZXkk7R3WAwmBlyHddfAZBk=; b=EZ6iawNXtnZLHMqbcZKwyULAntXsxci9YooaM6qROCtbKYOgBIhaqtTJ3ZBmV4bEo5 fklDfKraRP3UYJacKGjkbhlxVR5rsgrp9ehB4tE75lHa4YLWkZF1rdaNSAiW2DbwOfn5 lEXwRRJ1SKlHGZRGgZQ+hXwEJXz//VFf+hDL1agQZYaKT+cQvOdTsrMaIweImmSI6rTD dMijDWEjbha+mHh4FZHU0aWZDxVLn5utMeNPdvu7nSG+IMGxwSz3zTHr24YVUkJAzDls CRBZQu8a+2bO62nakKNElUqmn8Sks5Vz9SQE7RjDXfcCNZGzcNLVAHY9rqRtKasW6Hnn e/hA== X-Gm-Message-State: AOAM530NZL9DkOoRerHyVS/N7dTX/Uf4Oe2wODijtxGvcQCfWfslXl7E 4Of62kS/bpTYrd5H6eHAYHGZbQ== X-Google-Smtp-Source: ABdhPJyxlLSj2pj4ulF02mNqOXuSeO9zYOOxqIKrs7UIgmUXfXoCjT/ukJuSl3nb+TbyqV67OT7Gsg== X-Received: by 2002:a5d:4f06:: with SMTP id c6mr10264482wru.384.1631863543196; Fri, 17 Sep 2021 00:25:43 -0700 (PDT) Received: from localhost.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id z19sm11777565wma.0.2021.09.17.00.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 00:25:42 -0700 (PDT) From: Alexandre Bailon To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, ben.tseng@mediatek.com, khilman@baylibre.com, mka@chromium.org, Alexandre Bailon Subject: [PATCH v2 0/2] Add a generic virtual thermal sensor Date: Fri, 17 Sep 2021 09:27:30 +0200 Message-Id: <20210917072732.611140-1-abailon@baylibre.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This series add a virtual thermal sensor. It could be used to get a temperature using some thermal sensors. Currently, the supported operations are max, min and avg. The virtual sensor could be easily extended to support others operations. Note: Currently, thermal drivers must explicitly register their sensors to make them available to the virtual sensor. This doesn't seem a good solution to me and I think it would be preferable to update the framework to register the list of each available sensors. Changes in v2: - Fix some warnings / errors reported by kernel test robot - rename some struct and functions with a more accurate name - update the dt bindings: rename type attribute to aggregation-function - factorize a little bit the aggregation functions Alexandre Bailon (2): dt-bindings: Add bindings for the virtual thermal sensor thermal: add a virtual sensor to aggregate temperatures .../thermal/virtual,thermal-sensor.yaml | 67 +++ drivers/thermal/Kconfig | 8 + drivers/thermal/Makefile | 1 + drivers/thermal/virtual-sensor.h | 51 +++ drivers/thermal/virtual_sensor.c | 400 ++++++++++++++++++ include/dt-bindings/thermal/virtual-sensor.h | 15 + 6 files changed, 542 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/virtual,thermal-sensor.yaml create mode 100644 drivers/thermal/virtual-sensor.h create mode 100644 drivers/thermal/virtual_sensor.c create mode 100644 include/dt-bindings/thermal/virtual-sensor.h