From nobody Thu Nov 14 06:54:21 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1844C25B4E for ; Tue, 24 Jan 2023 13:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233944AbjAXNR1 (ORCPT ); Tue, 24 Jan 2023 08:17:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233797AbjAXNRW (ORCPT ); Tue, 24 Jan 2023 08:17:22 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F33F445229 for ; Tue, 24 Jan 2023 05:17:19 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id b7so13858831wrt.3 for ; Tue, 24 Jan 2023 05:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.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 :message-id:reply-to; bh=MbG1VUJ5DCdqW4qKVLb28pqzoz5xr35SQ4g7vLEm4Sc=; b=HsOffWvbDcnd8huZicXYTVp9PMK8+3GkWV2bBS5qYnTquiZs31oZwtOKNKAy/6glna 8o+xXHmjVyzolHN/kgsLTeYTbuBjNaLlCSgPpYUvtTSIWVfhW1namk40gwYLUobxKjW9 UfvUBp9efU2T9WYYTOfNZWmR1+NtEmvuCCWiHgUuBe+c1Q3SWHLBlsydRY30F+gJsYi8 I5QWwyEW71KvhVNTkQL866BNUy/40BEszqzOoqctwLUx0gbhlO4j71Nt13RJcGVBlx03 +ctMyO32o8ihiZtw7LAl5UKYG4vteM3kvHye6waXxNjfcPO3rBQ4yq+XlfJJGZf76QEd IAGA== 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:message-id:reply-to; bh=MbG1VUJ5DCdqW4qKVLb28pqzoz5xr35SQ4g7vLEm4Sc=; b=klCKxFlSCBL7dzGiBcq/ExC9Cvo4QR95K2tjwFJl2uho2dxKtWqUbNoGb8ntIk9UQM u+aRDtRiknG4BeraKC76oS9Y5M6llD+BnRrDtDbJ/99WyPZqZaMWlR8lQIQJQ6+kUE1x HldMjG1n50EzmO+9ZHBUEVlCKGBvpyuzrBqbfeKoUgiLeMbzXFV7ZEWJ3efA3/tW+EIX RpY+sceEGnomkTZiwa/r8LW5QNfCj2YjKdXCZG8zzj+9S6s3K6ENvnIdBHoI+sT6gjQG 4Sf+7S5FC1xYrzLRhSED1g4Uc9M1k+fHr/DKIXI/W1ZWGlBR/AOL8N6KNnBGhEL4c1PO ZSlA== X-Gm-Message-State: AO0yUKUhsKU1jabMFKY9dVJiIlORjBr49Yoru9ymzfp8Zi/+7ZvQSdm4 PHofw40zMocgbgkksNeqlgW6uA== X-Google-Smtp-Source: AK7set+vEkto6LwyUQvRQPih1O8ez4C6gcSMIx1VwLi+U88x8djEiit6DYvHKH0C0Knqxm0WgdJCbQ== X-Received: by 2002:a05:6000:5:b0:2bf:ae2f:c6ff with SMTP id h5-20020a056000000500b002bfae2fc6ffmr2466799wrx.31.1674566238435; Tue, 24 Jan 2023 05:17:18 -0800 (PST) Received: from t480-bl003.civfrance.com (58.188.158.77.rev.sfr.net. [77.158.188.58]) by smtp.gmail.com with ESMTPSA id a5-20020adfeec5000000b002bfb5ebf8cfsm49427wrp.21.2023.01.24.05.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:17:18 -0800 (PST) From: bchihi@baylibre.com To: daniel.lezcano@linaro.org, angelogioacchino.delregno@collabora.com, rafael@kernel.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, rdunlap@infradead.org, ye.xingchen@zte.com.cn, p.zabel@pengutronix.de Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, khilman@baylibre.com, james.lo@mediatek.com, rex-bc.chen@mediatek.com Subject: [PATCH v11 1/6] thermal/drivers/mediatek: Relocate driver to mediatek folder Date: Tue, 24 Jan 2023 14:17:12 +0100 Message-Id: <20230124131717.128660-2-bchihi@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124131717.128660-1-bchihi@baylibre.com> References: <20230124131717.128660-1-bchihi@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Balsam CHIHI Add MediaTek proprietary folder to upstream more thermal zone and cooler drivers, relocate the original thermal controller driver to it, and rename = it as "auxadc_thermal.c" to show its purpose more clearly. Signed-off-by: Balsam CHIHI Reviewed-by: AngeloGioacchino Del Regno --- drivers/thermal/Kconfig | 14 ++++--------- drivers/thermal/Makefile | 2 +- drivers/thermal/mediatek/Kconfig | 21 +++++++++++++++++++ drivers/thermal/mediatek/Makefile | 1 + .../auxadc_thermal.c} | 2 +- 5 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 drivers/thermal/mediatek/Kconfig create mode 100644 drivers/thermal/mediatek/Makefile rename drivers/thermal/{mtk_thermal.c =3D> mediatek/auxadc_thermal.c} (99%) diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index eaeb2b2ee6e9..4cd7ab707315 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -416,16 +416,10 @@ config DA9062_THERMAL zone. Compatible with the DA9062 and DA9061 PMICs. =20 -config MTK_THERMAL - tristate "Temperature sensor driver for mediatek SoCs" - depends on ARCH_MEDIATEK || COMPILE_TEST - depends on HAS_IOMEM - depends on NVMEM || NVMEM=3Dn - depends on RESET_CONTROLLER - default y - help - Enable this option if you want to have support for thermal management - controller present in Mediatek SoCs +menu "Mediatek thermal drivers" +depends on ARCH_MEDIATEK || COMPILE_TEST +source "drivers/thermal/mediatek/Kconfig" +endmenu =20 config AMLOGIC_THERMAL tristate "Amlogic Thermal Support" diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 60f0dfa9aae2..1c460d189bd7 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -56,7 +56,7 @@ obj-y +=3D st/ obj-y +=3D qcom/ obj-y +=3D tegra/ obj-$(CONFIG_HISI_THERMAL) +=3D hisi_thermal.o -obj-$(CONFIG_MTK_THERMAL) +=3D mtk_thermal.o +obj-y +=3D mediatek/ obj-$(CONFIG_GENERIC_ADC_THERMAL) +=3D thermal-generic-adc.o obj-$(CONFIG_UNIPHIER_THERMAL) +=3D uniphier_thermal.o obj-$(CONFIG_AMLOGIC_THERMAL) +=3D amlogic_thermal.o diff --git a/drivers/thermal/mediatek/Kconfig b/drivers/thermal/mediatek/Kc= onfig new file mode 100644 index 000000000000..7558a847d4e9 --- /dev/null +++ b/drivers/thermal/mediatek/Kconfig @@ -0,0 +1,21 @@ +config MTK_THERMAL + tristate "MediaTek thermal drivers" + depends on THERMAL_OF + help + This is the option for MediaTek thermal software solutions. + Please enable corresponding options to get temperature + information from thermal sensors or turn on throttle + mechaisms for thermal mitigation. + +if MTK_THERMAL + +config MTK_SOC_THERMAL + tristate "AUXADC temperature sensor driver for MediaTek SoCs" + depends on HAS_IOMEM + help + Enable this option if you want to get SoC temperature + information for MediaTek platforms. + This driver configures thermal controllers to collect + temperature via AUXADC interface. + +endif diff --git a/drivers/thermal/mediatek/Makefile b/drivers/thermal/mediatek/M= akefile new file mode 100644 index 000000000000..53e86e30b26f --- /dev/null +++ b/drivers/thermal/mediatek/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_MTK_SOC_THERMAL) +=3D auxadc_thermal.o diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mediatek/auxad= c_thermal.c similarity index 99% rename from drivers/thermal/mtk_thermal.c rename to drivers/thermal/mediatek/auxadc_thermal.c index 9a8b107900e9..90ae6b5c530e 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mediatek/auxadc_thermal.c @@ -23,7 +23,7 @@ #include #include =20 -#include "thermal_hwmon.h" +#include "../thermal_hwmon.h" =20 /* AUXADC Registers */ #define AUXADC_CON1_SET_V 0x008 --=20 2.34.1 From nobody Thu Nov 14 06:54:21 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CE30C25B4E for ; Tue, 24 Jan 2023 13:17:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234005AbjAXNRb (ORCPT ); Tue, 24 Jan 2023 08:17:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbjAXNRX (ORCPT ); Tue, 24 Jan 2023 08:17:23 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F6A3FF3C for ; Tue, 24 Jan 2023 05:17:21 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id y1so9353256wru.2 for ; Tue, 24 Jan 2023 05:17:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.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 :message-id:reply-to; bh=t1Mx7/fdaOZTAyQvhijx+hcsNa4waknDOv8lEc+khP4=; b=EoOqRR3T6Ta4E3QxcuRnYWEzz9pMRdDke6GJsf9uSUye/17W+z/erW46IPFzuqZYuP eGSDTx5DtbH+WWN/oIA0PxT5tdLr0vqsPy8IY0PpUa8k805JHSSThupwcGZ+JeJHm/sL XIgmbvaXh7ij9K7UmTT+/rIL3F7YVVX+ihx7lokVc1Fw3tQmb9tSPpT54Y1nrq4xm/Nq 6oqISFQkYzEqACyezZsst9jXJV1cEw8TkXY4tsyHToXvpqvT82te0GC+u1NvuFLO0Hpe ciydRTszvegrhGQfN39GFV1goqQkQgXes2b2mm5gy4CORr8TycrqZvqr54h4uBA90sCY JqMg== 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:message-id:reply-to; bh=t1Mx7/fdaOZTAyQvhijx+hcsNa4waknDOv8lEc+khP4=; b=kmBdkOyIOjGAUFJNHQhVyl5nhs2d2OE0gg2Z+/7auQ+oImHxUEm6duYQWo8Wq+OPej SbcUBBFkKQ1Tfuj4dKbvzK/N3dcQ4fkorzOsycomKCVdiPNjo1xm3GEx45DeJ23GJwt3 03fv/ZOGBQSjE2AUbfbK9OsxtizLhXNeXlKK3j8inhiFaf36pRvh3kDLWwXWokBVNJHl QbwWck4NB25y2KPMTUgCdu/PNhwV0PDhaG7ns51KrJ6py32qIykszLfJ16usSms0hNvA DaZW8f3SJC2a3zzprM/kl3VusyQZNiP18HHgkcr8WznB4FE99wQOfdhLrQ2lsgD48vGY BgJA== X-Gm-Message-State: AO0yUKUR1+u7bZxO04EvfmfNbEU21tS20/oZBK1B/K5nHWQXtO3UyXay Ruom2e99c8bp+GcrM/qqgmNp2Q== X-Google-Smtp-Source: AK7set+Mg41hXPJ0l3tt4EGAf6QzluqgF8PoERLSORY4izIzfw6NeNTevB2exR9qCTgplKpgwwPKJA== X-Received: by 2002:adf:b351:0:b0:2bf:ae4b:4cbf with SMTP id k17-20020adfb351000000b002bfae4b4cbfmr2331594wrd.55.1674566239580; Tue, 24 Jan 2023 05:17:19 -0800 (PST) Received: from t480-bl003.civfrance.com (58.188.158.77.rev.sfr.net. [77.158.188.58]) by smtp.gmail.com with ESMTPSA id a5-20020adfeec5000000b002bfb5ebf8cfsm49427wrp.21.2023.01.24.05.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:17:19 -0800 (PST) From: bchihi@baylibre.com To: daniel.lezcano@linaro.org, angelogioacchino.delregno@collabora.com, rafael@kernel.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, rdunlap@infradead.org, ye.xingchen@zte.com.cn, p.zabel@pengutronix.de Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, khilman@baylibre.com, james.lo@mediatek.com, rex-bc.chen@mediatek.com Subject: [PATCH v11 2/6] dt-bindings/thermal/mediatek: Add LVTS thermal controllers dt-binding definition Date: Tue, 24 Jan 2023 14:17:13 +0100 Message-Id: <20230124131717.128660-3-bchihi@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124131717.128660-1-bchihi@baylibre.com> References: <20230124131717.128660-1-bchihi@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Balsam CHIHI Add LVTS thermal controllers dt-binding definition for mt8195. Signed-off-by: Balsam CHIHI --- .../thermal/mediatek,lvts-thermal.yaml | 107 ++++++++++++++++++ include/dt-bindings/thermal/mediatek-lvts.h | 19 ++++ 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts= -thermal.yaml create mode 100644 include/dt-bindings/thermal/mediatek-lvts.h diff --git a/Documentation/devicetree/bindings/thermal/mediatek,lvts-therma= l.yaml b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.ya= ml new file mode 100644 index 000000000000..12bfbdd8ff89 --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml @@ -0,0 +1,107 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/mediatek,lvts-thermal.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek SoC Low Voltage Thermal Sensor (LVTS) + +maintainers: + - Balsam CHIHI + +description: | + LVTS is a thermal management architecture composed of three subsystems, + a Sensing device - Thermal Sensing Micro Circuit Unit (TSMCU), + a Converter - Low Voltage Thermal Sensor converter (LVTS), and + a Digital controller (LVTS_CTRL). + +properties: + compatible: + enum: + - mediatek,mt8195-lvts-ap + - mediatek,mt8195-lvts-mcu + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + description: LVTS reset for clearing temporary data on AP/MCU. + + nvmem-cells: + minItems: 1 + items: + - description: Calibration eFuse data 1 for LVTS + - description: Calibration eFuse data 2 for LVTS + + nvmem-cell-names: + minItems: 1 + items: + - const: lvts-calib-data-1 + - const: lvts-calib-data-2 + + "#thermal-sensor-cells": + const: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - resets + - nvmem-cells + - nvmem-cell-names + - "#thermal-sensor-cells" + +additionalProperties: false + +examples: + - | + #include + #include + #include + #include + + soc { + #address-cells =3D <2>; + #size-cells =3D <2>; + + lvts_mcu: thermal-sensor@11278000 { + compatible =3D "mediatek,mt8195-lvts-mcu"; + reg =3D <0 0x11278000 0 0x1000>; + interrupts =3D ; + clocks =3D <&infracfg_ao CLK_INFRA_AO_THERM>; + resets =3D <&infracfg_ao MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST>; + nvmem-cells =3D <&lvts_efuse_data1 &lvts_efuse_data2>; + nvmem-cell-names =3D "lvts-calib-data-1", "lvts-calib-data-2"; + #thermal-sensor-cells =3D <1>; + }; + }; + + thermal_zones: thermal-zones { + cpu0-thermal { + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU0>; + + trips { + cpu0_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + + cpu0_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + }; diff --git a/include/dt-bindings/thermal/mediatek-lvts.h b/include/dt-bindi= ngs/thermal/mediatek-lvts.h new file mode 100644 index 000000000000..428a95c18509 --- /dev/null +++ b/include/dt-bindings/thermal/mediatek-lvts.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2023 MediaTek Inc. + * Author: Balsam CHIHI + */ + +#ifndef __MEDIATEK_LVTS_DT_H +#define __MEDIATEK_LVTS_DT_H + +#define MT8195_MCU_BIG_CPU0 0 +#define MT8195_MCU_BIG_CPU1 1 +#define MT8195_MCU_BIG_CPU2 2 +#define MT8195_MCU_BIG_CPU3 3 +#define MT8195_MCU_LITTLE_CPU0 4 +#define MT8195_MCU_LITTLE_CPU1 5 +#define MT8195_MCU_LITTLE_CPU2 6 +#define MT8195_MCU_LITTLE_CPU3 7 + +#endif /* __MEDIATEK_LVTS_DT_H */ --=20 2.34.1 From nobody Thu Nov 14 06:54:21 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2500DC38142 for ; Tue, 24 Jan 2023 13:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233988AbjAXNR3 (ORCPT ); Tue, 24 Jan 2023 08:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233860AbjAXNRY (ORCPT ); Tue, 24 Jan 2023 08:17:24 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AEDB3D08C for ; Tue, 24 Jan 2023 05:17:22 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id h16so13824549wrz.12 for ; Tue, 24 Jan 2023 05:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.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 :message-id:reply-to; bh=uRFuR+tKXTVFSVWgTM1ydP6t5wcQk1JNcVFjOiTIWVE=; b=wYEAShBZ3B+0Nockbo7T+kiNbl6jdoG36gVC3lyA2hVvJxJL0RiRp0MdmJMovKJJK4 aGr0BXt1jc14RYpVbVO5oBkCJYDoOnM/0dB5jqD4FvEPMEc7lIp5tYRg9Kpw9S7Xopot a+M9Z9kiSig3VqlH9L3ha2fs6rCiocv8t/cHS+Zz7tWwfUGsV5GPRH6UcBegCCh+wSCl EZEXkOfbeouKKwhmNUHxID2Mst+WpQBmJjuuijuOl/QMy9FTPgnr/enUT1hhQyo2TE7+ u+Q5VV3OBeAMcDntn2w61gPIYtPzZM4AjKysy1A3LriLubUDS6jTb8fFlW4sHv40C06Q AXdg== 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:message-id:reply-to; bh=uRFuR+tKXTVFSVWgTM1ydP6t5wcQk1JNcVFjOiTIWVE=; b=vQYrq4NhclvMdlT9mdeaE44vmSCNnJlAg7Y61Lg1Q1qF72VP47j92xZZzACf8wwWsg qXSOeFN5WXVqSwIJQVCzQZEgDqBxjYVjzEYHRemlJxjzMxzSxRv6hpsxXZAnrLNsCxyD jobSoda+Xnb/peGkwiiLxNjrZGJ/my6tcRR05u0xLwWQ/Ys1Qu6ArHmoRWQ50lepo+I+ Xu8K/L+J8Oxr9ai/+szdTblFUln1FGIKMJfy1o15LHgUbflqUZ8xa1CSWamyg2+wsxqH YtekAq6CnjBmf4HmJtlDPvY1VdA48QfLhJIfmmW2cOVWLaK+QzSExHI8axRCsgj+nTx5 cBtA== X-Gm-Message-State: AFqh2kqOIlBKYRkQSjm8sYXoCKbeemhtYn+uR1rfRi8xvgrRhC0HGgZf RyQkXei5R8+JPeyGL+ve2akX9A== X-Google-Smtp-Source: AMrXdXvzfegMVJZsAQeZApCFjS5isJncUHlBYtAFFI3zGp9RNZfbhsZUwriwwOkjOVH4iWWeJqAvVA== X-Received: by 2002:a5d:67c3:0:b0:242:8af9:b987 with SMTP id n3-20020a5d67c3000000b002428af9b987mr18230999wrw.13.1674566241023; Tue, 24 Jan 2023 05:17:21 -0800 (PST) Received: from t480-bl003.civfrance.com (58.188.158.77.rev.sfr.net. [77.158.188.58]) by smtp.gmail.com with ESMTPSA id a5-20020adfeec5000000b002bfb5ebf8cfsm49427wrp.21.2023.01.24.05.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:17:20 -0800 (PST) From: bchihi@baylibre.com To: daniel.lezcano@linaro.org, angelogioacchino.delregno@collabora.com, rafael@kernel.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, rdunlap@infradead.org, ye.xingchen@zte.com.cn, p.zabel@pengutronix.de Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, khilman@baylibre.com, james.lo@mediatek.com, rex-bc.chen@mediatek.com Subject: [PATCH v11 3/6] arm64/dts/mt8195: Add efuse node to mt8195 Date: Tue, 24 Jan 2023 14:17:14 +0100 Message-Id: <20230124131717.128660-4-bchihi@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124131717.128660-1-bchihi@baylibre.com> References: <20230124131717.128660-1-bchihi@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Balsam CHIHI Add efuse node. This will be required by the thermal driver to get the calibration data. Signed-off-by: Balsam CHIHI Reviewed-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi b/arch/arm64/boot/dts= /mediatek/mt8195.dtsi index 5d31536f4c48..09df105f4606 100644 --- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi @@ -1380,6 +1380,12 @@ pciephy_glb_intr: pciephy-glb-intr@193 { dp_calibration: dp-data@1ac { reg =3D <0x1ac 0x10>; }; + lvts_efuse_data1: lvts1-calib@1bc { + reg =3D <0x1bc 0x14>; + }; + lvts_efuse_data2: lvts2-calib@1d0 { + reg =3D <0x1d0 0x38>; + }; }; =20 u3phy2: t-phy@11c40000 { --=20 2.34.1 From nobody Thu Nov 14 06:54:21 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22E84C54EAA for ; Tue, 24 Jan 2023 13:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234078AbjAXNRq (ORCPT ); Tue, 24 Jan 2023 08:17:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234066AbjAXNRk (ORCPT ); Tue, 24 Jan 2023 08:17:40 -0500 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 D882240BF1 for ; Tue, 24 Jan 2023 05:17:25 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id n7so13841402wrx.5 for ; Tue, 24 Jan 2023 05:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.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 :message-id:reply-to; bh=v6xq4xH3TOuWBw8EgJ+uHtMj1R88KohKLF0EgZ+cPO8=; b=Svf1ObMJ4krl52Nlrxgj52a9/PkLrtMdGa9KuCuDRBKh9OQBsccNuyBAZcuS9vwNkz oI+2X2eN/AcEq7w/QW+5Y0kGSSGTtvhtojIMy6PxXqnK65KPLd6b+yYjphBX5Q1N5nUv +dz6jLIr4B92Bbnzh2bBFRpIpQ1NaGRxBGDuf+kI15Yq0WgSkB8a5qvSL1skpP0dwnB4 nrnqfxKfGhm5GTKDHM+HZoHKR4Jkp9DxSfn/yq2N1DazSIg/kPrz0LJ0HqrdVH4ysZwn dlR2S1NNsGVfDY6tXPGwU7omCGsA8OsEdCayPOCef0BO3+jGgsLw+DuXrty/IVXrFy+O LYiQ== 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:message-id:reply-to; bh=v6xq4xH3TOuWBw8EgJ+uHtMj1R88KohKLF0EgZ+cPO8=; b=daPKg5NT0gNs3lv8w7YM7CqagRwLsPHoEgkagl0odiW4pi/65e/TByn5+dS4lrtNPv 5ls8Gh18BxPqcemhEdErm59mzmcmZ4dtt6HD2iuDiSjiN8qnfJzFd7Hp+XXYIvAMRvHx aphnsyr8Ite1j7diSWGup8Oxe2jBJuLgpKtN8KjnZubCORjOAD+slKmZlCclnaoYY2Bk gemB+I6X0pKC38VWN1Ke8bMcn9CAV+dI/wbUD7A1aD/n2jc68ztvGxr+I5PFptp5QHlo UYM5oZEW908MySCtrrnRJlS8dBoNTtra1pKl1rOuDvM/exHhXZD4wG6O5YLF+EcE0tSl getA== X-Gm-Message-State: AFqh2koNLWMrb5nfbuhU3ouyv9OKWw3AwkkRl38AxCsVslWjPcsT+M/F Fon/DXcPMQxiNx1wNnODtNtqmw== X-Google-Smtp-Source: AMrXdXui0Iyo6JoRryTB0z140iHIQY2l0d8GEaO+PEV0ykg0va1kMgS4U4LA7q2VU4vEydqf8N+swg== X-Received: by 2002:a5d:62c7:0:b0:2bb:dbde:bde4 with SMTP id o7-20020a5d62c7000000b002bbdbdebde4mr23213098wrv.30.1674566243986; Tue, 24 Jan 2023 05:17:23 -0800 (PST) Received: from t480-bl003.civfrance.com (58.188.158.77.rev.sfr.net. [77.158.188.58]) by smtp.gmail.com with ESMTPSA id a5-20020adfeec5000000b002bfb5ebf8cfsm49427wrp.21.2023.01.24.05.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:17:23 -0800 (PST) From: bchihi@baylibre.com To: daniel.lezcano@linaro.org, angelogioacchino.delregno@collabora.com, rafael@kernel.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, rdunlap@infradead.org, ye.xingchen@zte.com.cn, p.zabel@pengutronix.de Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, khilman@baylibre.com, james.lo@mediatek.com, rex-bc.chen@mediatek.com Subject: [PATCH v11 4/6] thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver Date: Tue, 24 Jan 2023 14:17:15 +0100 Message-Id: <20230124131717.128660-5-bchihi@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124131717.128660-1-bchihi@baylibre.com> References: <20230124131717.128660-1-bchihi@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Balsam CHIHI The Low Voltage Thermal Sensor (LVTS) is a multiple sensors, multi controllers contained in a thermal domain. A thermal domains can be the MCU or the AP. Each thermal domains contain up to seven controllers, each thermal controller handle up to four thermal sensors. The LVTS has two Finite State Machines (FSM), one to handle the functionin temperatures range like hot or cold temperature and another one to handle monitoring trip point. The FSM notifies via interrupts when a trip point is crossed. The interrupt is managed at the thermal controller level, so when an interrupt occurs, the driver has to find out which sensor triggered such an interrupt. The sampling of the thermal can be filtered or immediate. For the former, the LVTS measures several points and applies a low pass filter. Signed-off-by: Balsam CHIHI Reviewed-by: AngeloGioacchino Del Regno Tested-by: AngeloGioacchino Del Regno --- drivers/thermal/mediatek/Kconfig | 15 + drivers/thermal/mediatek/Makefile | 1 + drivers/thermal/mediatek/lvts_thermal.c | 1261 +++++++++++++++++++++++ 3 files changed, 1277 insertions(+) create mode 100644 drivers/thermal/mediatek/lvts_thermal.c diff --git a/drivers/thermal/mediatek/Kconfig b/drivers/thermal/mediatek/Kc= onfig index 7558a847d4e9..99597d7b9890 100644 --- a/drivers/thermal/mediatek/Kconfig +++ b/drivers/thermal/mediatek/Kconfig @@ -18,4 +18,19 @@ config MTK_SOC_THERMAL This driver configures thermal controllers to collect temperature via AUXADC interface. =20 +config MTK_LVTS_THERMAL + tristate "LVTS Thermal Driver for MediaTek SoCs" + depends on HAS_IOMEM + help + Enable this option if you want to get SoC temperature + information for supported MediaTek platforms. + This driver configures LVTS (Low Voltage Thermal Sensor) + thermal controllers to collect temperatures via ASIF + (Analog Serial Interface). + +config MTK_LVTS_THERMAL_DEBUGFS + bool "LVTS thermal debugfs" + depends on MTK_LVTS_THERMAL && DEBUG_FS + help + Enable this option to debug the internals of the device driver. endif diff --git a/drivers/thermal/mediatek/Makefile b/drivers/thermal/mediatek/M= akefile index 53e86e30b26f..1c6daa1e644b 100644 --- a/drivers/thermal/mediatek/Makefile +++ b/drivers/thermal/mediatek/Makefile @@ -1 +1,2 @@ obj-$(CONFIG_MTK_SOC_THERMAL) +=3D auxadc_thermal.o +obj-$(CONFIG_MTK_LVTS_THERMAL) +=3D lvts_thermal.o diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/medi= atek/lvts_thermal.c new file mode 100644 index 000000000000..1e51af728aff --- /dev/null +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -0,0 +1,1261 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2023 MediaTek Inc. + * Author: Balsam CHIHI + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LVTS_MONCTL0(__base) (__base + 0x0000) +#define LVTS_MONCTL1(__base) (__base + 0x0004) +#define LVTS_MONCTL2(__base) (__base + 0x0008) +#define LVTS_MONINT(__base) (__base + 0x000C) +#define LVTS_MONINTSTS(__base) (__base + 0x0010) +#define LVTS_MONIDET0(__base) (__base + 0x0014) +#define LVTS_MONIDET1(__base) (__base + 0x0018) +#define LVTS_MONIDET2(__base) (__base + 0x001C) +#define LVTS_MONIDET3(__base) (__base + 0x0020) +#define LVTS_H2NTHRE(__base) (__base + 0x0024) +#define LVTS_HTHRE(__base) (__base + 0x0028) +#define LVTS_OFFSETH(__base) (__base + 0x0030) +#define LVTS_OFFSETL(__base) (__base + 0x0034) +#define LVTS_MSRCTL0(__base) (__base + 0x0038) +#define LVTS_MSRCTL1(__base) (__base + 0x003C) +#define LVTS_TSSEL(__base) (__base + 0x0040) +#define LVTS_CALSCALE(__base) (__base + 0x0048) +#define LVTS_ID(__base) (__base + 0x004C) +#define LVTS_CONFIG(__base) (__base + 0x0050) +#define LVTS_EDATA00(__base) (__base + 0x0054) +#define LVTS_EDATA01(__base) (__base + 0x0058) +#define LVTS_EDATA02(__base) (__base + 0x005C) +#define LVTS_EDATA03(__base) (__base + 0x0060) +#define LVTS_MSR0(__base) (__base + 0x0090) +#define LVTS_MSR1(__base) (__base + 0x0094) +#define LVTS_MSR2(__base) (__base + 0x0098) +#define LVTS_MSR3(__base) (__base + 0x009C) +#define LVTS_IMMD0(__base) (__base + 0x00A0) +#define LVTS_IMMD1(__base) (__base + 0x00A4) +#define LVTS_IMMD2(__base) (__base + 0x00A8) +#define LVTS_IMMD3(__base) (__base + 0x00AC) +#define LVTS_PROTCTL(__base) (__base + 0x00C0) +#define LVTS_PROTTA(__base) (__base + 0x00C4) +#define LVTS_PROTTB(__base) (__base + 0x00C8) +#define LVTS_PROTTC(__base) (__base + 0x00CC) +#define LVTS_CLKEN(__base) (__base + 0x00E4) + +#define LVTS_PERIOD_UNIT ((118 * 1000) / (256 * 38)) +#define LVTS_GROUP_INTERVAL 1 +#define LVTS_FILTER_INTERVAL 1 +#define LVTS_SENSOR_INTERVAL 1 +#define LVTS_HW_FILTER 0x2 +#define LVTS_TSSEL_CONF 0x13121110 +#define LVTS_CALSCALE_CONF 0x300 +#define LVTS_MONINT_CONF 0x9FBF7BDE + +#define LVTS_INT_SENSOR0 0x0009001F +#define LVTS_INT_SENSOR1 0X000881F0 +#define LVTS_INT_SENSOR2 0x00247C00 +#define LVTS_INT_SENSOR3 0x1FC00000 + +#define LVTS_SENSOR_MAX 4 +#define LVTS_GOLDEN_TEMP_MAX 62 +#define LVTS_GOLDEN_TEMP_DEFAULT 50 +#define LVTS_COEFF_A -250460 +#define LVTS_COEFF_B 250460 + +#define LVTS_MSR_IMMEDIATE_MODE 0 +#define LVTS_MSR_FILTERED_MODE 1 + +#define LVTS_HW_SHUTDOWN_MT8195 105000 + +static int golden_temp =3D LVTS_GOLDEN_TEMP_DEFAULT; +static int coeff_b =3D LVTS_COEFF_B; + +struct lvts_sensor_data { + int dt_id; +}; + +struct lvts_ctrl_data { + struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX]; + int cal_offset[LVTS_SENSOR_MAX]; + int hw_tshut_temp; + int num_lvts_sensor; + int offset; + int mode; +}; + +struct lvts_data { + struct lvts_ctrl_data *lvts_ctrl; + int num_lvts_ctrl; +}; + +struct lvts_sensor { + struct thermal_zone_device *tz; + void __iomem *msr; + void __iomem *base; + int id; + int dt_id; +}; + +struct lvts_ctrl { + struct lvts_sensor sensors[LVTS_SENSOR_MAX]; + u32 calibration[LVTS_SENSOR_MAX]; + u32 hw_tshut_raw_temp; + int num_lvts_sensor; + int mode; + void __iomem *base; +}; + +struct lvts_domain { + struct lvts_ctrl *lvts_ctrl; + struct reset_control *reset; + struct clk *clk; + int num_lvts_ctrl; + void __iomem *base; + size_t calib_len; + u8 *calib; +}; + +#ifdef CONFIG_MTK_LVTS_THERMAL_DEBUGFS + +static struct dentry *root; + +#define LVTS_DEBUG_FS_REGS(__reg) \ +{ \ + .name =3D __stringify(__reg), \ + .offset =3D __reg(0), \ +} + +static const struct debugfs_reg32 lvts_regs[] =3D { + LVTS_DEBUG_FS_REGS(LVTS_MONCTL0), + LVTS_DEBUG_FS_REGS(LVTS_MONCTL1), + LVTS_DEBUG_FS_REGS(LVTS_MONCTL2), + LVTS_DEBUG_FS_REGS(LVTS_MONINT), + LVTS_DEBUG_FS_REGS(LVTS_MONINTSTS), + LVTS_DEBUG_FS_REGS(LVTS_MONIDET0), + LVTS_DEBUG_FS_REGS(LVTS_MONIDET1), + LVTS_DEBUG_FS_REGS(LVTS_MONIDET2), + LVTS_DEBUG_FS_REGS(LVTS_MONIDET3), + LVTS_DEBUG_FS_REGS(LVTS_H2NTHRE), + LVTS_DEBUG_FS_REGS(LVTS_HTHRE), + LVTS_DEBUG_FS_REGS(LVTS_OFFSETH), + LVTS_DEBUG_FS_REGS(LVTS_OFFSETL), + LVTS_DEBUG_FS_REGS(LVTS_MSRCTL0), + LVTS_DEBUG_FS_REGS(LVTS_MSRCTL1), + LVTS_DEBUG_FS_REGS(LVTS_TSSEL), + LVTS_DEBUG_FS_REGS(LVTS_CALSCALE), + LVTS_DEBUG_FS_REGS(LVTS_ID), + LVTS_DEBUG_FS_REGS(LVTS_CONFIG), + LVTS_DEBUG_FS_REGS(LVTS_EDATA00), + LVTS_DEBUG_FS_REGS(LVTS_EDATA01), + LVTS_DEBUG_FS_REGS(LVTS_EDATA02), + LVTS_DEBUG_FS_REGS(LVTS_EDATA03), + LVTS_DEBUG_FS_REGS(LVTS_MSR0), + LVTS_DEBUG_FS_REGS(LVTS_MSR1), + LVTS_DEBUG_FS_REGS(LVTS_MSR2), + LVTS_DEBUG_FS_REGS(LVTS_MSR3), + LVTS_DEBUG_FS_REGS(LVTS_IMMD0), + LVTS_DEBUG_FS_REGS(LVTS_IMMD1), + LVTS_DEBUG_FS_REGS(LVTS_IMMD2), + LVTS_DEBUG_FS_REGS(LVTS_IMMD3), + LVTS_DEBUG_FS_REGS(LVTS_PROTCTL), + LVTS_DEBUG_FS_REGS(LVTS_PROTTA), + LVTS_DEBUG_FS_REGS(LVTS_PROTTB), + LVTS_DEBUG_FS_REGS(LVTS_PROTTC), + LVTS_DEBUG_FS_REGS(LVTS_CLKEN), +}; + +static int lvts_debugfs_init(struct device *dev, + struct lvts_domain *lvts_td) +{ + struct debugfs_regset32 *regset; + struct lvts_ctrl *lvts_ctrl; + struct dentry *dentry; + struct dentry *dom_dentry; + char name[64]; + int i; + + if (!root) + root =3D debugfs_create_dir("lvts", NULL); + + dom_dentry =3D debugfs_create_dir(dev_name(dev), root); + if (!dom_dentry) + return 0; + + for (i =3D 0; i < lvts_td->num_lvts_ctrl; i++) { + + lvts_ctrl =3D &lvts_td->lvts_ctrl[i]; + + sprintf(name, "controller%d", i); + dentry =3D debugfs_create_dir(name, dom_dentry); + if (!dentry) + continue; + + regset =3D devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL); + if (!regset) + continue; + + regset->base =3D lvts_ctrl->base; + regset->regs =3D lvts_regs; + regset->nregs =3D ARRAY_SIZE(lvts_regs); + + debugfs_create_regset32("registers", 0400, dentry, regset); + } + + return 0; +} + +static void lvts_debugfs_exit(void) +{ + debugfs_remove_recursive(root); +} + +#else + +static inline int lvts_debugfs_init(struct device *dev, + struct lvts_domain *lvts_td) +{ + return 0; +} + +static void lvts_debugfs_exit(void) { } + +#endif + +static int lvts_raw_to_temp(u32 raw_temp) +{ + int temperature; + + temperature =3D ((s64)(raw_temp & 0xFFFF) * LVTS_COEFF_A) >> 14; + temperature +=3D coeff_b; + + return temperature; +} + +static u32 lvts_temp_to_raw(int temperature) +{ + u32 raw_temp =3D ((s64)(coeff_b - temperature)) << 14; + + raw_temp =3D div_s64(raw_temp, -LVTS_COEFF_A); + + return raw_temp; +} + +static int lvts_get_temp(struct thermal_zone_device *tz, int *temp) +{ + struct lvts_sensor *lvts_sensor =3D tz->devdata; + void __iomem *msr =3D lvts_sensor->msr; + u32 value; + + /* + * Measurement registers: + * + * LVTS_MSR[0-3] / LVTS_IMMD[0-3] + * + * Bits: + * + * 32-17: Unused + * 16 : Valid temperature + * 15-0 : Raw temperature + */ + value =3D readl(msr); + + /* + * As the thermal zone temperature will read before the + * hardware sensor is fully initialized, we have to check the + * validity of the temperature returned when reading the + * measurement register. The thermal controller will set the + * valid bit temperature only when it is totally initialized. + * + * Otherwise, we may end up with garbage values out of the + * functionning temperature and directly jump to a system + * shutdown. + */ + if (!(value & BIT(16))) + return -EAGAIN; + + *temp =3D lvts_raw_to_temp(value & 0xFFFF); + + return 0; +} + +static int lvts_set_trips(struct thermal_zone_device *tz, int low, int hig= h) +{ + struct lvts_sensor *lvts_sensor =3D tz->devdata; + void __iomem *base =3D lvts_sensor->base; + u32 raw_low =3D lvts_temp_to_raw(low); + u32 raw_high =3D lvts_temp_to_raw(high); + + /* + * Hot to normal temperature threshold + * + * LVTS_H2NTHRE + * + * Bits: + * + * 14-0 : Raw temperature for threshold + */ + if (low !=3D -INT_MAX) { + dev_dbg(&tz->device, "Setting low limit temperature interrupt: %d\n", lo= w); + writel(raw_low, LVTS_H2NTHRE(base)); + } + + /* + * Hot temperature threshold + * + * LVTS_HTHRE + * + * Bits: + * + * 14-0 : Raw temperature for threshold + */ + dev_dbg(&tz->device, "Setting high limit temperature interrupt: %d\n", hi= gh); + writel(raw_high, LVTS_HTHRE(base)); + + return 0; +} + +static irqreturn_t lvts_ctrl_irq_handler(struct lvts_ctrl *lvts_ctrl) +{ + irqreturn_t iret =3D IRQ_NONE; + u32 value, masks[] =3D { + LVTS_INT_SENSOR0, + LVTS_INT_SENSOR1, + LVTS_INT_SENSOR2, + LVTS_INT_SENSOR3 + }; + int i; + + /* + * Interrupt monitoring status + * + * LVTS_MONINTST + * + * Bits: + * + * 31 : Interrupt for stage 3 + * 30 : Interrupt for stage 2 + * 29 : Interrupt for state 1 + * 28 : Interrupt using filter on sensor 3 + * + * 27 : Interrupt using immediate on sensor 3 + * 26 : Interrupt normal to hot on sensor 3 + * 25 : Interrupt high offset on sensor 3 + * 24 : Interrupt low offset on sensor 3 + * + * 23 : Interrupt hot threshold on sensor 3 + * 22 : Interrupt cold threshold on sensor 3 + * 21 : Interrupt using filter on sensor 2 + * 20 : Interrupt using filter on sensor 1 + * + * 19 : Interrupt using filter on sensor 0 + * 18 : Interrupt using immediate on sensor 2 + * 17 : Interrupt using immediate on sensor 1 + * 16 : Interrupt using immediate on sensor 0 + * + * 15 : Interrupt device access timeout interrupt + * 14 : Interrupt normal to hot on sensor 2 + * 13 : Interrupt high offset interrupt on sensor 2 + * 12 : Interrupt low offset interrupt on sensor 2 + * + * 11 : Interrupt hot threshold on sensor 2 + * 10 : Interrupt cold threshold on sensor 2 + * 9 : Interrupt normal to hot on sensor 1 + * 8 : Interrupt high offset interrupt on sensor 1 + * + * 7 : Interrupt low offset interrupt on sensor 1 + * 6 : Interrupt hot threshold on sensor 1 + * 5 : Interrupt cold threshold on sensor 1 + * 4 : Interrupt normal to hot on sensor 0 + * + * 3 : Interrupt high offset interrupt on sensor 0 + * 2 : Interrupt low offset interrupt on sensor 0 + * 1 : Interrupt hot threshold on sensor 0 + * 0 : Interrupt cold threshold on sensor 0 + * + * We are interested in the sensor(s) responsible of the + * interrupt event. We update the thermal framework with the + * thermal zone associated with the sensor. The framework will + * take care of the rest whatever the kind of interrupt, we + * are only interested in which sensor raised the interrupt. + * + * sensor 3 interrupt: 0001 1111 1100 0000 0000 0000 0000 0000 + * =3D> 0x1FC00000 + * sensor 2 interrupt: 0000 0000 0010 0100 0111 1100 0000 0000 + * =3D> 0x00247C00 + * sensor 1 interrupt: 0000 0000 0001 0001 0000 0011 1110 0000 + * =3D> 0X000881F0 + * sensor 0 interrupt: 0000 0000 0000 1001 0000 0000 0001 1111 + * =3D> 0x0009001F + */ + value =3D readl(LVTS_MONINTSTS(lvts_ctrl->base)); + + /* + * Let's figure out which sensors raised the interrupt + * + * NOTE: the masks array must be ordered with the index + * corresponding to the sensor id eg. index=3D0, mask for + * sensor0. + */ + for (i =3D 0; i < ARRAY_SIZE(masks); i++) { + + if (!(value & masks[i])) + continue; + + thermal_zone_device_update(lvts_ctrl->sensors[i].tz, + THERMAL_TRIP_VIOLATED); + iret =3D IRQ_HANDLED; + } + + /* + * Write back to clear the interrupt status (W1C) + */ + writel(value, LVTS_MONINTSTS(lvts_ctrl->base)); + + return iret; +} + +/* + * Temperature interrupt handler. Even if the driver supports more + * interrupt modes, we use the interrupt when the temperature crosses + * the hot threshold the way up and the way down (modulo the + * hysteresis). + * + * Each thermal domain has a couple of interrupts, one for hardware + * reset and another one for all the thermal events happening on the + * different sensors. + * + * The interrupt is configured for thermal events when crossing the + * hot temperature limit. At each interrupt, we check in every + * controller if there is an interrupt pending. + */ +static irqreturn_t lvts_irq_handler(int irq, void *data) +{ + struct lvts_domain *lvts_td =3D data; + irqreturn_t aux, iret =3D IRQ_NONE; + int i; + + for (i =3D 0; i < lvts_td->num_lvts_ctrl; i++) { + + aux =3D lvts_ctrl_irq_handler(lvts_td->lvts_ctrl); + if (aux !=3D IRQ_HANDLED) + continue; + + iret =3D IRQ_HANDLED; + } + + return iret; +} + +static struct thermal_zone_device_ops lvts_ops =3D { + .get_temp =3D lvts_get_temp, + .set_trips =3D lvts_set_trips, +}; + +static int __init lvts_sensor_init(struct device *dev, + struct lvts_ctrl *lvts_ctrl, + struct lvts_ctrl_data *lvts_ctrl_data) +{ + struct lvts_sensor *lvts_sensor =3D lvts_ctrl->sensors; + void __iomem *msr_regs[] =3D { + LVTS_MSR0(lvts_ctrl->base), + LVTS_MSR1(lvts_ctrl->base), + LVTS_MSR2(lvts_ctrl->base), + LVTS_MSR3(lvts_ctrl->base) + }; + + void __iomem *imm_regs[] =3D { + LVTS_IMMD0(lvts_ctrl->base), + LVTS_IMMD1(lvts_ctrl->base), + LVTS_IMMD2(lvts_ctrl->base), + LVTS_IMMD3(lvts_ctrl->base) + }; + + int i; + + for (i =3D 0; i < lvts_ctrl_data->num_lvts_sensor; i++) { + + int dt_id =3D lvts_ctrl_data->lvts_sensor[i].dt_id; + + /* + * At this point, we don't know which id matches which + * sensor. Let's set arbitrally the id from the index. + */ + lvts_sensor[i].id =3D i; + + /* + * The thermal zone registration will set the trip + * point interrupt in the thermal controller + * register. But this one will be reset in the + * initialization after. So we need to post pone the + * thermal zone creation after the controller is + * setup. For this reason, we store the device tree + * node id from the data in the sensor structure + */ + lvts_sensor[i].dt_id =3D dt_id; + + /* + * We assign the base address of the thermal + * controller as a back pointer. So it will be + * accessible from the different thermal framework ops + * as we pass the lvts_sensor pointer as thermal zone + * private data. + */ + lvts_sensor[i].base =3D lvts_ctrl->base; + + /* + * Each sensor has its own register address to read from. + */ + lvts_sensor[i].msr =3D lvts_ctrl_data->mode =3D=3D LVTS_MSR_IMMEDIATE_MO= DE ? + imm_regs[i] : msr_regs[i]; + }; + + lvts_ctrl->num_lvts_sensor =3D lvts_ctrl_data->num_lvts_sensor; + + return 0; +} + +/* + * The efuse blob values follows the sensor enumeration per thermal + * controller. The decoding of the stream is as follow: + * + * <--?-> <----big0 ???---> <-sensor0-> <-0-> + * ------------------------------------------ + * index in the stream: : | 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | + * ------------------------------------------ + * + * <--sensor1--><-0-> <----big1 ???---> <-sen + * ------------------------------------------ + * | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD | + * ------------------------------------------ + * + * sor0-> <-0-> <-sensor1-> <-0-> .......... + * ------------------------------------------ + * | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD | + * ------------------------------------------ + * + * And so on ... + * + * The data description gives the offset of the calibration data in + * this bytes stream for each sensor. + * + * Each thermal controller can handle up to 4 sensors max, we don't + * care if there are less as the array of calibration is sized to 4 + * anyway. The unused sensor slot will be zeroed. + */ +static int __init lvts_calibration_init(struct device *dev, + struct lvts_ctrl *lvts_ctrl, + struct lvts_ctrl_data *lvts_ctrl_data, + u8 *efuse_calibration) +{ + int i; + + for (i =3D 0; i < lvts_ctrl_data->num_lvts_sensor; i++) + memcpy(&lvts_ctrl->calibration[i], + efuse_calibration + lvts_ctrl_data->cal_offset[i], 2); + + return 0; +} + +/* + * The efuse bytes stream can be split into different chunk of + * nvmems. This function reads and concatenate those into a single + * buffer so it can be read sequentially when initializing the + * calibration data. + */ +static int lvts_calibration_read(struct device *dev, struct lvts_domain *l= vts_td, + struct lvts_data *lvts_data) +{ + struct device_node *np =3D dev_of_node(dev); + struct nvmem_cell *cell; + struct property *prop; + const char *cell_name; + + of_property_for_each_string(np, "nvmem-cell-names", prop, cell_name) { + size_t len; + u8 *efuse; + + cell =3D of_nvmem_cell_get(np, cell_name); + if (IS_ERR(cell)) { + dev_dbg(dev, "Failed to get cell '%s'\n", cell_name); + return PTR_ERR(cell); + } + + efuse =3D nvmem_cell_read(cell, &len); + + nvmem_cell_put(cell); + + if (IS_ERR(efuse)) { + dev_dbg(dev, "Failed to read cell '%s'\n", cell_name); + return PTR_ERR(efuse); + } + + lvts_td->calib =3D devm_krealloc(dev, lvts_td->calib, + lvts_td->calib_len + len, GFP_KERNEL); + if (!lvts_td->calib) + return -ENOMEM; + + memcpy(lvts_td->calib + lvts_td->calib_len, efuse, len); + + lvts_td->calib_len +=3D len; + + kfree(efuse); + } + + return 0; +} + +static int __init lvts_golden_temp_init(struct device *dev, u32 *value) +{ + u32 gt; + + gt =3D (*value) >> 24; + + if (gt && gt < LVTS_GOLDEN_TEMP_MAX) + golden_temp =3D gt; + + coeff_b =3D golden_temp * 500 + LVTS_COEFF_B; + + return 0; +} + +static int __init lvts_ctrl_init(struct device *dev, + struct lvts_domain *lvts_td, + struct lvts_data *lvts_data) +{ + size_t size =3D sizeof(*lvts_td->lvts_ctrl) * lvts_data->num_lvts_ctrl; + struct lvts_ctrl *lvts_ctrl; + int i, ret; + + /* + * Create the calibration bytes stream from efuse data + */ + ret =3D lvts_calibration_read(dev, lvts_td, lvts_data); + if (ret) + return ret; + + /* + * The golden temp information is contained in the first chunk + * of efuse data. + */ + ret =3D lvts_golden_temp_init(dev, (u32 *)lvts_td->calib); + if (ret) + return ret; + + lvts_ctrl =3D devm_kzalloc(dev, size, GFP_KERNEL); + if (!lvts_ctrl) + return -ENOMEM; + + for (i =3D 0; i < lvts_data->num_lvts_ctrl; i++) { + + lvts_ctrl[i].base =3D lvts_td->base + lvts_data->lvts_ctrl[i].offset; + + ret =3D lvts_sensor_init(dev, &lvts_ctrl[i], + &lvts_data->lvts_ctrl[i]); + if (ret) + return ret; + + ret =3D lvts_calibration_init(dev, &lvts_ctrl[i], + &lvts_data->lvts_ctrl[i], + lvts_td->calib); + if (ret) + return ret; + + /* + * The mode the ctrl will use to read the temperature + * (filtered or immediate) + */ + lvts_ctrl[i].mode =3D lvts_data->lvts_ctrl[i].mode; + + /* + * The temperature to raw temperature must be done + * after initializing the calibration. + */ + lvts_ctrl[i].hw_tshut_raw_temp =3D + lvts_temp_to_raw(lvts_data->lvts_ctrl[i].hw_tshut_temp); + } + + /* + * We no longer need the efuse bytes stream, let's free it + */ + devm_kfree(dev, lvts_td->calib); + + lvts_td->lvts_ctrl =3D lvts_ctrl; + lvts_td->num_lvts_ctrl =3D lvts_data->num_lvts_ctrl; + + return 0; +} + +/* + * At this point the configuration register is the only place in the + * driver where we write multiple values. Per hardware constraint, + * each write in the configuration register must be separated by a + * delay of 2 us. + */ +static void lvts_write_config(struct lvts_ctrl *lvts_ctrl, u32 *cmds, int = nr_cmds) +{ + int i; + + /* + * Configuration register + */ + for (i =3D 0; i < nr_cmds; i++) { + writel(cmds[i], LVTS_CONFIG(lvts_ctrl->base)); + usleep_range(2, 4); + } +} + +static int lvts_irq_init(struct lvts_ctrl *lvts_ctrl) +{ + /* + * LVTS_PROTCTL : Thermal Protection Sensor Selection + * + * Bits: + * + * 19-18 : Sensor to base the protection on + * 17-16 : Strategy: + * 00 : Average of 4 sensors + * 01 : Max of 4 sensors + * 10 : Selected sensor with bits 19-18 + * 11 : Reserved + */ + writel(BIT(16), LVTS_PROTCTL(lvts_ctrl->base)); + + /* + * LVTS_PROTTA : Stage 1 temperature threshold + * LVTS_PROTTB : Stage 2 temperature threshold + * LVTS_PROTTC : Stage 3 temperature threshold + * + * Bits: + * + * 14-0: Raw temperature threshold + * + * writel(0x0, LVTS_PROTTA(lvts_ctrl->base)); + * writel(0x0, LVTS_PROTTB(lvts_ctrl->base)); + */ + writel(lvts_ctrl->hw_tshut_raw_temp, LVTS_PROTTC(lvts_ctrl->base)); + + /* + * LVTS_MONINT : Interrupt configuration register + * + * The LVTS_MONINT register layout is the same as the LVTS_MONINTSTS + * register, except we set the bits to enable the interrupt. + */ + writel(LVTS_MONINT_CONF, LVTS_MONINT(lvts_ctrl->base)); + + return 0; +} + +static int lvts_domain_reset(struct device *dev, struct reset_control *res= et) +{ + int ret; + + ret =3D reset_control_assert(reset); + if (ret) + return ret; + + return reset_control_deassert(reset); +} + +/* + * Enable or disable the clocks of a specified thermal controller + */ +static int lvts_ctrl_set_enable(struct lvts_ctrl *lvts_ctrl, int enable) +{ + /* + * LVTS_CLKEN : Internal LVTS clock + * + * Bits: + * + * 0 : enable / disable clock + */ + writel(enable, LVTS_CLKEN(lvts_ctrl->base)); + + return 0; +} + +static inline int lvts_ctrl_enable(struct device *dev, struct lvts_ctrl *l= vts_ctrl) +{ + return lvts_ctrl_set_enable(lvts_ctrl, 1); +} + +static inline int lvts_ctrl_disable(struct device *dev, struct lvts_ctrl *= lvts_ctrl) +{ + return lvts_ctrl_set_enable(lvts_ctrl, 0); +} + +static int lvts_ctrl_connect(struct device *dev, struct lvts_ctrl *lvts_ct= rl) +{ + u32 id, cmds[] =3D { 0xC103FFFF, 0xC502FF55 }; + + lvts_write_config(lvts_ctrl, cmds, ARRAY_SIZE(cmds)); + + /* + * LVTS_ID : Get ID and status of the thermal controller + * + * Bits: + * + * 0-5 : thermal controller id + * 7 : thermal controller connection is valid + */ + id =3D readl(LVTS_ID(lvts_ctrl->base)); + if (!(id & BIT(7))) + return -EIO; + + return 0; +} + +static int lvts_ctrl_initialize(struct device *dev, struct lvts_ctrl *lvts= _ctrl) +{ + /* + * Write device mask: 0xC1030000 + */ + u32 cmds[] =3D { + 0xC1030E01, 0xC1030CFC, 0xC1030A8C, 0xC103098D, 0xC10308F1, + 0xC10307A6, 0xC10306B8, 0xC1030500, 0xC1030420, 0xC1030300, + 0xC1030030, 0xC10300F6, 0xC1030050, 0xC1030060, 0xC10300AC, + 0xC10300FC, 0xC103009D, 0xC10300F1, 0xC10300E1 + }; + + lvts_write_config(lvts_ctrl, cmds, ARRAY_SIZE(cmds)); + + return 0; +} + +static int lvts_ctrl_calibrate(struct device *dev, struct lvts_ctrl *lvts_= ctrl) +{ + int i; + void __iomem *lvts_edata[] =3D { + LVTS_EDATA00(lvts_ctrl->base), + LVTS_EDATA01(lvts_ctrl->base), + LVTS_EDATA02(lvts_ctrl->base), + LVTS_EDATA03(lvts_ctrl->base) + }; + + /* + * LVTS_EDATA0X : Efuse calibration reference value for sensor X + * + * Bits: + * + * 20-0 : Efuse value for normalization data + */ + for (i =3D 0; i < LVTS_SENSOR_MAX; i++) + writel(lvts_ctrl->calibration[i], lvts_edata[i]); + + return 0; +} + +static int lvts_ctrl_configure(struct device *dev, struct lvts_ctrl *lvts_= ctrl) +{ + u32 value; + + /* + * LVTS_TSSEL : Sensing point index numbering + * + * Bits: + * + * 31-24: ADC Sense 3 + * 23-16: ADC Sense 2 + * 15-8 : ADC Sense 1 + * 7-0 : ADC Sense 0 + */ + value =3D LVTS_TSSEL_CONF; + writel(value, LVTS_TSSEL(lvts_ctrl->base)); + + /* + * LVTS_CALSCALE : ADC voltage round + */ + value =3D 0x300; + value =3D LVTS_CALSCALE_CONF; + + /* + * LVTS_MSRCTL0 : Sensor filtering strategy + * + * Filters: + * + * 000 : One sample + * 001 : Avg 2 samples + * 010 : 4 samples, drop min and max, avg 2 samples + * 011 : 6 samples, drop min and max, avg 4 samples + * 100 : 10 samples, drop min and max, avg 8 samples + * 101 : 18 samples, drop min and max, avg 16 samples + * + * Bits: + * + * 0-2 : Sensor0 filter + * 3-5 : Sensor1 filter + * 6-8 : Sensor2 filter + * 9-11 : Sensor3 filter + */ + value =3D LVTS_HW_FILTER << 9 | LVTS_HW_FILTER << 6 | + LVTS_HW_FILTER << 3 | LVTS_HW_FILTER; + writel(value, LVTS_MSRCTL0(lvts_ctrl->base)); + + /* + * LVTS_MSRCTL1 : Measurement control + * + * Bits: + * + * 9: Ignore MSRCTL0 config and do immediate measurement on sensor3 + * 6: Ignore MSRCTL0 config and do immediate measurement on sensor2 + * 5: Ignore MSRCTL0 config and do immediate measurement on sensor1 + * 4: Ignore MSRCTL0 config and do immediate measurement on sensor0 + * + * That configuration will ignore the filtering and the delays + * introduced below in MONCTL1 and MONCTL2 + */ + if (lvts_ctrl->mode =3D=3D LVTS_MSR_IMMEDIATE_MODE) { + value =3D BIT(9) | BIT(6) | BIT(5) | BIT(4); + writel(value, LVTS_MSRCTL1(lvts_ctrl->base)); + } + + /* + * LVTS_MONCTL1 : Period unit and group interval configuration + * + * The clock source of LVTS thermal controller is 26MHz. + * + * The period unit is a time base for all the interval delays + * specified in the registers. By default we use 12. The time + * conversion is done by multiplying by 256 and 1/26.10^6 + * + * An interval delay multiplied by the period unit gives the + * duration in seconds. + * + * - Filter interval delay is a delay between two samples of + * the same sensor. + * + * - Sensor interval delay is a delay between two samples of + * different sensors. + * + * - Group interval delay is a delay between different rounds. + * + * For example: + * If Period unit =3D C, filter delay =3D 1, sensor delay =3D 2, grou= p delay =3D 1, + * and two sensors, TS1 and TS2, are in a LVTS thermal controller + * and then + * Period unit time =3D C * 1/26M * 256 =3D 12 * 38.46ns * 256 =3D 11= 8.149us + * Filter interval delay =3D 1 * Period unit =3D 118.149us + * Sensor interval delay =3D 2 * Period unit =3D 236.298us + * Group interval delay =3D 1 * Period unit =3D 118.149us + * + * TS1 TS1 ... TS1 TS2 TS2 ... TS2 TS1... + * <--> Filter interval delay + * <--> Sensor interval delay + * <--> Group interval delay + * Bits: + * 29 - 20 : Group interval + * 16 - 13 : Send a single interrupt when crossing the hot threshold= (1) + * or an interrupt everytime the hot threshold is crossed = (0) + * 9 - 0 : Period unit + * + */ + value =3D LVTS_GROUP_INTERVAL << 20 | LVTS_PERIOD_UNIT; + writel(value, LVTS_MONCTL1(lvts_ctrl->base)); + + /* + * LVTS_MONCTL2 : Filtering and sensor interval + * + * Bits: + * + * 25-16 : Interval unit in PERIOD_UNIT between sample on + * the same sensor, filter interval + * 9-0 : Interval unit in PERIOD_UNIT between each sensor + * + */ + value =3D LVTS_FILTER_INTERVAL << 16 | LVTS_SENSOR_INTERVAL; + writel(value, LVTS_MONCTL2(lvts_ctrl->base)); + + return lvts_irq_init(lvts_ctrl); +} + +static int lvts_ctrl_start(struct device *dev, struct lvts_ctrl *lvts_ctrl) +{ + struct lvts_sensor *lvts_sensors =3D lvts_ctrl->sensors; + struct thermal_zone_device *tz; + u32 sensor_map =3D 0; + int i; + + for (i =3D 0; i < lvts_ctrl->num_lvts_sensor; i++) { + + int dt_id =3D lvts_sensors[i].dt_id; + + tz =3D devm_thermal_of_zone_register(dev, dt_id, &lvts_sensors[i], + &lvts_ops); + if (IS_ERR(tz)) { + /* + * This thermal zone is not described in the + * device tree. It is not an error from the + * thermal OF code POV, we just continue. + */ + if (PTR_ERR(tz) =3D=3D -ENODEV) + continue; + + return PTR_ERR(tz); + } + + /* + * The thermal zone pointer will be needed in the + * interrupt handler, we store it in the sensor + * structure. The thermal domain structure will be + * passed to the interrupt handler private data as the + * interrupt is shared for all the controller + * belonging to the thermal domain. + */ + lvts_sensors[i].tz =3D tz; + + /* + * This sensor was correctly associated with a thermal + * zone, let's set the corresponding bit in the sensor + * map, so we can enable the temperature monitoring in + * the hardware thermal controller. + */ + sensor_map |=3D BIT(i); + } + + /* + * Bits: + * 9: Single point access flow + * 0-3: Enable sensing point 0-3 + * + * The initialization of the thermal zones give us + * which sensor point to enable. If any thermal zone + * was not described in the device tree, it won't be + * enabled here in the sensor map. + */ + writel(sensor_map | BIT(9), LVTS_MONCTL0(lvts_ctrl->base)); + + return 0; +} + +static int lvts_domain_init(struct device *dev, struct lvts_domain *lvts_t= d, + struct lvts_data *lvts_data) +{ + struct lvts_ctrl *lvts_ctrl; + int i, ret; + + ret =3D lvts_ctrl_init(dev, lvts_td, lvts_data); + if (ret) + return ret; + + ret =3D lvts_domain_reset(dev, lvts_td->reset); + if (ret) { + dev_dbg(dev, "Failed to reset domain"); + return ret; + } + + for (i =3D 0; i < lvts_td->num_lvts_ctrl; i++) { + + lvts_ctrl =3D &lvts_td->lvts_ctrl[i]; + + /* + * Initialization steps: + * + * - Enable the clock + * - Connect to the LVTS + * - Initialize the LVTS + * - Prepare the calibration data + * - Select monitored sensors + * [ Configure sampling ] + * [ Configure the interrupt ] + * - Start measurement + */ + ret =3D lvts_ctrl_enable(dev, lvts_ctrl); + if (ret) { + dev_dbg(dev, "Failed to enable LVTS clock"); + return ret; + } + + ret =3D lvts_ctrl_connect(dev, lvts_ctrl); + if (ret) { + dev_dbg(dev, "Failed to connect to LVTS controller"); + return ret; + } + + ret =3D lvts_ctrl_initialize(dev, lvts_ctrl); + if (ret) { + dev_dbg(dev, "Failed to initialize controller"); + return ret; + } + + ret =3D lvts_ctrl_calibrate(dev, lvts_ctrl); + if (ret) { + dev_dbg(dev, "Failed to calibrate controller"); + return ret; + } + + ret =3D lvts_ctrl_configure(dev, lvts_ctrl); + if (ret) { + dev_dbg(dev, "Failed to configure controller"); + return ret; + } + + ret =3D lvts_ctrl_start(dev, lvts_ctrl); + if (ret) { + dev_dbg(dev, "Failed to start controller"); + return ret; + } + } + + return lvts_debugfs_init(dev, lvts_td); +} + +static int lvts_probe(struct platform_device *pdev) +{ + struct lvts_data *lvts_data; + struct lvts_domain *lvts_td; + struct device *dev =3D &pdev->dev; + struct resource *res; + int irq, ret; + + lvts_td =3D devm_kzalloc(dev, sizeof(*lvts_td), GFP_KERNEL); + if (!lvts_td) + return -ENOMEM; + + lvts_data =3D (struct lvts_data *)of_device_get_match_data(dev); + if (!lvts_data) { + dev_dbg(dev, "No platforme data"); + return -ENODATA; + }; + + lvts_td->clk =3D devm_clk_get_enabled(dev, NULL); + if (IS_ERR(lvts_td->clk)) { + dev_dbg(dev, "Failed to retrieve clock\n"); + return PTR_ERR(lvts_td->clk); + } + + res =3D platform_get_mem_or_io(pdev, 0); + if (!res) { + dev_dbg(dev, "No IO resource\n"); + return -ENXIO; + } + + lvts_td->base =3D devm_ioremap_resource(dev, res); + if (IS_ERR(lvts_td->base)) { + dev_dbg(dev, "Failed to map io resource\n"); + return PTR_ERR(lvts_td->base); + } + + lvts_td->reset =3D devm_reset_control_get_by_index(dev, 0); + if (IS_ERR(lvts_td->reset)) { + dev_dbg(dev, "Failed to get reset control\n"); + return PTR_ERR(lvts_td->reset); + } + + irq =3D platform_get_irq(pdev, 0); + if (irq < 0) { + dev_dbg(dev, "No irq resource\n"); + return irq; + } + + ret =3D lvts_domain_init(dev, lvts_td, lvts_data); + if (ret) { + dev_dbg(dev, "Failed to initialize the lvts domain\n"); + return ret; + } + + /* + * At this point the LVTS is initialized and enabled. We can + * safely enable the interrupt. + */ + ret =3D devm_request_threaded_irq(dev, irq, NULL, lvts_irq_handler, + IRQF_ONESHOT, dev_name(dev), lvts_td); + if (ret) { + dev_dbg(dev, "Failed to request interrupt\n"); + return ret; + } + + platform_set_drvdata(pdev, lvts_td); + + return 0; +} + +static int lvts_remove(struct platform_device *pdev) +{ + struct lvts_domain *lvts_td; + struct device *dev =3D &pdev->dev; + int i; + + lvts_td =3D platform_get_drvdata(pdev); + + for (i =3D 0; i < lvts_td->num_lvts_ctrl; i++) + lvts_ctrl_disable(dev, &lvts_td->lvts_ctrl[i]); + + lvts_debugfs_exit(); + + return 0; +} + +static struct lvts_ctrl_data mt8195_lvts_data_ctrl[] =3D { + { + .cal_offset =3D { 0x4, 0x7 }, + .lvts_sensor =3D { + { .dt_id =3D MT8195_MCU_BIG_CPU0 }, + { .dt_id =3D MT8195_MCU_BIG_CPU1 } + }, + .num_lvts_sensor =3D 2, + .offset =3D 0x0, + .hw_tshut_temp =3D LVTS_HW_SHUTDOWN_MT8195, + }, + + { + .cal_offset =3D { 0xd, 0x10 }, + .lvts_sensor =3D { + { .dt_id =3D MT8195_MCU_BIG_CPU2 }, + { .dt_id =3D MT8195_MCU_BIG_CPU3 } + }, + .num_lvts_sensor =3D 2, + .offset =3D 0x100, + .hw_tshut_temp =3D LVTS_HW_SHUTDOWN_MT8195, + }, + + { + .cal_offset =3D { 0x16, 0x19, 0x1c, 0x1f }, + .lvts_sensor =3D { + { .dt_id =3D MT8195_MCU_LITTLE_CPU0 }, + { .dt_id =3D MT8195_MCU_LITTLE_CPU1 }, + { .dt_id =3D MT8195_MCU_LITTLE_CPU2 }, + { .dt_id =3D MT8195_MCU_LITTLE_CPU3 } + }, + .num_lvts_sensor =3D 4, + .offset =3D 0x200, + .hw_tshut_temp =3D LVTS_HW_SHUTDOWN_MT8195, + } +}; + +static struct lvts_data mt8195_lvts_mcu_data =3D { + .lvts_ctrl =3D mt8195_lvts_data_ctrl, + .num_lvts_ctrl =3D ARRAY_SIZE(mt8195_lvts_data_ctrl), +}; + +static const struct of_device_id lvts_of_match[] =3D { + { .compatible =3D "mediatek,mt8195-lvts-mcu", .data =3D &mt8195_lvts_mcu_= data }, + {}, +}; +MODULE_DEVICE_TABLE(of, lvts_of_match); + +static struct platform_driver lvts_driver =3D { + .probe =3D lvts_probe, + .remove =3D lvts_remove, + .driver =3D { + .name =3D "mtk-lvts-thermal", + .of_match_table =3D lvts_of_match, + }, +}; +module_platform_driver(lvts_driver); + +MODULE_AUTHOR("Balsam CHIHI "); +MODULE_DESCRIPTION("MediaTek LVTS Thermal Driver"); +MODULE_LICENSE("GPL"); --=20 2.34.1 From nobody Thu Nov 14 06:54:21 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C238C38142 for ; Tue, 24 Jan 2023 13:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234154AbjAXNRt (ORCPT ); Tue, 24 Jan 2023 08:17:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233859AbjAXNRl (ORCPT ); Tue, 24 Jan 2023 08:17:41 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 237F745BDF for ; Tue, 24 Jan 2023 05:17:26 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id b7so13859137wrt.3 for ; Tue, 24 Jan 2023 05:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.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 :message-id:reply-to; bh=VYZQGFlPP5P/RkMABIrbs0eSZjZa02mf4fdtuwRY9mc=; b=LvzJ5qejfKsGezJgZ0/qaFtlHArz8tyPy2zcpYrl3qtC+Md2S1iHJ5ZsZ5wgCO6dCi jn2efJJ09102dQxMA8YGKJdPa4B3GxCvLdyoGxA/3hixN9zVk0defqqVTFJdr0kOXQvi d4CI0xfE0gMAn8IwdZm1YdNL/qUxrMPP+T7P9RpUx10hzjrvU0VtOwNOx7Esq6Sq3wy/ ySLC1M37orcjxu7ivMppTIyYUkBpdA/t0auKXNDeCW3GgOPR5r9g/IHv2DQw8PW8s+Ui XI0N2i+GcazkL9WFtRcnRxx8tb8VN3R9FudUFaE9PZhcVqVZHLbS9SSzfeWKwhlh7eCA hb+A== 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:message-id:reply-to; bh=VYZQGFlPP5P/RkMABIrbs0eSZjZa02mf4fdtuwRY9mc=; b=PBGzqNTUKWKXTtx/7aEaXBF0786hivhyEJXep5Tik/rkJ1ZiO7LHzW0ApKeiYdz9sX 6y812Fd8jcD2X2k2yFzOc1Rj2dLwzEKc61Fup+yAAEqxk7OzB58kim9heMyEG8XaDroi p5ruYRKIlrmotaX4/cJX76AwKMd07oUB+9L99yGXsFBrRIc3JUPImIqTFCexM698j3yt D3lrDAo2gISsEyMJY69SE9wWBM50EThu/K7pnIHEK7XVmoutB3rgssMJHYdr6NHSHV6V tmbAZUJS+G2NcQXwJuZtmvjgZfQCs3eun2U/xsULLEMBRe8TEAVwMVW7xGBt/WRIl2mR rY6A== X-Gm-Message-State: AFqh2kpGQgO66OCIM7pz/j9l38g3mi1Dg+tv9u2aNkq1MUFrWGlLm8yi RbCfvW2FJTjyWqM1/26j1FwE9A== X-Google-Smtp-Source: AMrXdXuQYFl4pUTj0SbP3xV3T+Aw2YTblcG/tXvardPqn07thVl0y+FReYxWRPg4/OF7WMHUoCoDiQ== X-Received: by 2002:a5d:6186:0:b0:2bd:dc24:cade with SMTP id j6-20020a5d6186000000b002bddc24cademr19692374wru.16.1674566245280; Tue, 24 Jan 2023 05:17:25 -0800 (PST) Received: from t480-bl003.civfrance.com (58.188.158.77.rev.sfr.net. [77.158.188.58]) by smtp.gmail.com with ESMTPSA id a5-20020adfeec5000000b002bfb5ebf8cfsm49427wrp.21.2023.01.24.05.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:17:25 -0800 (PST) From: bchihi@baylibre.com To: daniel.lezcano@linaro.org, angelogioacchino.delregno@collabora.com, rafael@kernel.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, rdunlap@infradead.org, ye.xingchen@zte.com.cn, p.zabel@pengutronix.de Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, khilman@baylibre.com, james.lo@mediatek.com, rex-bc.chen@mediatek.com Subject: [PATCH v11 5/6] arm64/dts/mt8195: Add thermal zones and thermal nodes Date: Tue, 24 Jan 2023 14:17:16 +0100 Message-Id: <20230124131717.128660-6-bchihi@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124131717.128660-1-bchihi@baylibre.com> References: <20230124131717.128660-1-bchihi@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Balsam CHIHI Add thermal zones and thermal nodes for the mt8195. Signed-off-by: Balsam CHIHI Reviewed-by: AngeloGioacchino Del Regno --- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 129 +++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi b/arch/arm64/boot/dts= /mediatek/mt8195.dtsi index 09df105f4606..636676f4ba25 100644 --- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi @@ -14,6 +14,7 @@ #include #include #include +#include =20 / { compatible =3D "mediatek,mt8195"; @@ -954,6 +955,17 @@ spi0: spi@1100a000 { status =3D "disabled"; }; =20 + lvts_ap: thermal-sensor@1100b000 { + compatible =3D "mediatek,mt8195-lvts-ap"; + reg =3D <0 0x1100b000 0 0x1000>; + interrupts =3D ; + clocks =3D <&infracfg_ao CLK_INFRA_AO_THERM>; + resets =3D <&infracfg_ao MT8195_INFRA_RST0_THERM_CTRL_SWRST>; + nvmem-cells =3D <&lvts_efuse_data1 &lvts_efuse_data2>; + nvmem-cell-names =3D "lvts-calib-data-1", "lvts-calib-data-2"; + #thermal-sensor-cells =3D <1>; + }; + spi1: spi@11010000 { compatible =3D "mediatek,mt8195-spi", "mediatek,mt6765-spi"; @@ -1114,6 +1126,17 @@ mmc2: mmc@11250000 { status =3D "disabled"; }; =20 + lvts_mcu: thermal-sensor@11278000 { + compatible =3D "mediatek,mt8195-lvts-mcu"; + reg =3D <0 0x11278000 0 0x1000>; + interrupts =3D ; + clocks =3D <&infracfg_ao CLK_INFRA_AO_THERM>; + resets =3D <&infracfg_ao MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST>; + nvmem-cells =3D <&lvts_efuse_data1 &lvts_efuse_data2>; + nvmem-cell-names =3D "lvts-calib-data-1", "lvts-calib-data-2"; + #thermal-sensor-cells =3D <1>; + }; + xhci1: usb@11290000 { compatible =3D "mediatek,mt8195-xhci", "mediatek,mtk-xhci"; @@ -2387,4 +2410,110 @@ dp_tx: dp-tx@1c600000 { status =3D "disabled"; }; }; + + thermal_zones: thermal-zones { + cpu0-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU0>; + trips { + cpu0_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu1-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU1>; + trips { + cpu1_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu2-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU2>; + trips { + cpu2_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu3-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU3>; + trips { + cpu3_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu4-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU0>; + trips { + cpu4_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu5-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU1>; + trips { + cpu5_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu6-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU2>; + trips { + cpu6_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu7-thermal { + polling-delay =3D <0>; + polling-delay-passive =3D <0>; + thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU3>; + trips { + cpu7_crit: trip-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + }; }; --=20 2.34.1 From nobody Thu Nov 14 06:54:21 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55AFFC38142 for ; Tue, 24 Jan 2023 13:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233568AbjAXNRy (ORCPT ); Tue, 24 Jan 2023 08:17:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234082AbjAXNRm (ORCPT ); Tue, 24 Jan 2023 08:17:42 -0500 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 CA9EC40BDA for ; Tue, 24 Jan 2023 05:17:27 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id r2so13833922wrv.7 for ; Tue, 24 Jan 2023 05:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.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 :message-id:reply-to; bh=xPtScS6BY2oQMQfZghRsu5KobsKH5DtWf/rH2GOOn2E=; b=W4lKDHBsNTAbBP+sCaS3NnLnfNX0w7IFxvJzjy1O9YprvEICvju4Gm0nsIt3YvhJib rtn8xAn8YHyPQkyP1/LXYQG+JQ8fyVKzY3X0c/GfuhL2KOdcAUUnmdUobWDRAbuzhfD2 0isiHPLSm4DPlSA3JydEkUhMSe4SUMMt1pyukjgaLtuh+Q8O3EzdyylJeKTQqEjhGffc qC3N8cT++V4WQysalxniy0cQtAxwfduPUmFJjvfLAAzyQLtK2CC91xqRGl7/YNrNeD9y 2TaRElWEv/HFUY/78xNo8HJ2tYcxqr2lzmRw1IFx3zo0KPUT7nCXDidKZDVud1A8sY6P un3w== 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:message-id:reply-to; bh=xPtScS6BY2oQMQfZghRsu5KobsKH5DtWf/rH2GOOn2E=; b=4WzICS9AlsNa1Bk5wQt9SnH9JgwV4qXg2kj/9Sm/ABuIS1wUZXwPmwEplW0IIHw/O0 1ZnDg7hY/17G1Sjo8LpbJF92C/mH1FjGKqUhavBJ80lIoxNZc8DI1hANQdbgirYOgLwB xtq97h/tCHyV6bYZuH9YtrhHu4bym8LyFPYfGPW6MRb1FkRcRmScMVD6EBeWytA6k+42 sHpo0ulc0CCy5px3I3TcEGN82NFqIocATYaAafFhQ/tq2+hj8eR1p6rDGWmwFwrNhMjQ RZgSbOgFzIPISNTtf3wWdK3irYae2JIDyzAzPimD51E8i55UVhlHpr921LC9jI+t5NzJ jBhg== X-Gm-Message-State: AFqh2kowwLDZy2PTD19M+zcxaS/FrtamXx5OqPgOxBHBtzsjGx4tpvlu 6ntrxosxaF7+AjDqzyfQ7gJwBw== X-Google-Smtp-Source: AMrXdXsqFzBNFFRsfEKNgsDGLdcohtkUIEtjlnmBj53xs2rQu+gfm/nVnqvxc5b40qAwmuYSCz7WUw== X-Received: by 2002:a5d:6f15:0:b0:2b9:28ef:24c9 with SMTP id ay21-20020a5d6f15000000b002b928ef24c9mr28610014wrb.39.1674566246341; Tue, 24 Jan 2023 05:17:26 -0800 (PST) Received: from t480-bl003.civfrance.com (58.188.158.77.rev.sfr.net. [77.158.188.58]) by smtp.gmail.com with ESMTPSA id a5-20020adfeec5000000b002bfb5ebf8cfsm49427wrp.21.2023.01.24.05.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:17:26 -0800 (PST) From: bchihi@baylibre.com To: daniel.lezcano@linaro.org, angelogioacchino.delregno@collabora.com, rafael@kernel.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, rdunlap@infradead.org, ye.xingchen@zte.com.cn, p.zabel@pengutronix.de Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, khilman@baylibre.com, james.lo@mediatek.com, rex-bc.chen@mediatek.com Subject: [PATCH v11 6/6] arm64/dts/mt8195: Add temperature mitigation threshold Date: Tue, 24 Jan 2023 14:17:17 +0100 Message-Id: <20230124131717.128660-7-bchihi@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124131717.128660-1-bchihi@baylibre.com> References: <20230124131717.128660-1-bchihi@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Balsam CHIHI The mt8195 SoC has several hotspots around the CPUs. Specify the targeted temperature threshold when to apply the mitigation and define the associated cooling devices. Signed-off-by: Balsam CHIHI Reviewed-by: AngeloGioacchino Del Regno --- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 169 ++++++++++++++++++++--- 1 file changed, 153 insertions(+), 16 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi b/arch/arm64/boot/dts= /mediatek/mt8195.dtsi index 636676f4ba25..9544ae91379a 100644 --- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi @@ -14,6 +14,7 @@ #include #include #include +#include #include =20 / { @@ -2413,107 +2414,243 @@ dp_tx: dp-tx@1c600000 { =20 thermal_zones: thermal-zones { cpu0-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU0>; + trips { + cpu0_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu0_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu0_alert>; + cooling-device =3D <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; =20 cpu1-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU1>; + trips { + cpu1_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu1_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu1_alert>; + cooling-device =3D <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; =20 cpu2-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU2>; + trips { + cpu2_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu2_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu2_alert>; + cooling-device =3D <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; =20 cpu3-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_LITTLE_CPU3>; + trips { + cpu3_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu3_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu3_alert>; + cooling-device =3D <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; =20 cpu4-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU0>; + trips { + cpu4_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu4_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu4_alert>; + cooling-device =3D <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; =20 cpu5-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU1>; + trips { + cpu5_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu5_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu5_alert>; + cooling-device =3D <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; =20 cpu6-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU2>; + trips { + cpu6_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu6_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu6_alert>; + cooling-device =3D <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; =20 cpu7-thermal { - polling-delay =3D <0>; - polling-delay-passive =3D <0>; + polling-delay =3D <1000>; + polling-delay-passive =3D <250>; thermal-sensors =3D <&lvts_mcu MT8195_MCU_BIG_CPU3>; + trips { + cpu7_alert: trip-alert { + temperature =3D <85000>; + hysteresis =3D <2000>; + type =3D "passive"; + }; + cpu7_crit: trip-crit { temperature =3D <100000>; hysteresis =3D <2000>; type =3D "critical"; }; }; + + cooling-maps { + map0 { + trip =3D <&cpu7_alert>; + cooling-device =3D <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; }; }; --=20 2.34.1