From nobody Sat Sep 21 04:34:34 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 18056C54E94 for ; Wed, 25 Jan 2023 09:51:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235424AbjAYJvN (ORCPT ); Wed, 25 Jan 2023 04:51:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235346AbjAYJvH (ORCPT ); Wed, 25 Jan 2023 04:51:07 -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 8DFD43ABE for ; Wed, 25 Jan 2023 01:51:03 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id bk16so16430930wrb.11 for ; Wed, 25 Jan 2023 01:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SPsz6CoLNjPAxyd2ASpUS9AhmaiVkC3z8HgK93csZ1U=; b=atYXCcfROx7XbUn/LZ+kGkjUtnHTe+RMm1MuS5SWM+LzKJizJlgLzVVqP0QyPeYu6F aHTWuUChw1wGBB40BThmH8Y8mP6onEz5fBTtxMMerW/SBmRLNKqNvHog954EYkxbPC5C nTP6s/sO3jQnZ4vceHG51c24JT07I1p/iRwUiMQHlK0qEJEk3HyljgDNsY7VjMcHG05u ItflGdO/S19WJKwTfoxvJTm//chzfWC4bu/WpNjEVShv4M/xh/2dA/4eHG0PyxpmuMff gHlVjtLklONEyQs/Dvjb4CCSwalhw1QRg9AZeSsTEiGHvGEGGKQYCveiIeTDnoNCMPqj Gv/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SPsz6CoLNjPAxyd2ASpUS9AhmaiVkC3z8HgK93csZ1U=; b=gq6tTJhS/J9Hl+AUNoKu/v/5rCne6bNaCY8l9Bw1Wp1nLeOa+GonUDWlLsYsOTdAGD k1oc0DwkYq/OlyAQveB+5CuGjElNtwGvN3EePvWwNGtvqt3sAI+0++iCYARWomBratlO uhYm4M8AYRS5+/4ZkLlWctQnvEFPEQMjezh+kSf11isqMUTklWHjPWSW11+ob61ywJNB MqSLr871K3/4u0BD2/5h+Qn8zH+AClPNTW3NAR/wajvUkQOUHDGHHvnp+zu3rootSTpR RTpxgyuqcg9+uxbfy086MzCRK1BvCCnSjnHwmTvkb/3vFbLZASsoJgHwVcbvLD91wPSL 543Q== X-Gm-Message-State: AO0yUKV/FS6N46yXRP3Je3DNn/M93+Hey61+pZ/p4oUU/LogalNFdmJd ZY7UFZgozVXA3GvRqZgdv+s06w== X-Google-Smtp-Source: AK7set/16CPFtxuNwWrrIsJHEQdd6BbpeVn/tMdMC7hRCr1vC2L5+u84jU88vqJoTNvl4fhYH4s9jg== X-Received: by 2002:adf:a38c:0:b0:2bf:bd9f:23cb with SMTP id l12-20020adfa38c000000b002bfbd9f23cbmr828592wrb.52.1674640262041; Wed, 25 Jan 2023 01:51:02 -0800 (PST) Received: from [127.0.1.1] (62.213.132.195.rev.sfr.net. [195.132.213.62]) by smtp.googlemail.com with ESMTPSA id j26-20020a5d453a000000b002bdf3809f59sm3955072wra.38.2023.01.25.01.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 01:51:01 -0800 (PST) From: Amjad Ouled-Ameur Date: Wed, 25 Jan 2023 10:50:29 +0100 Subject: [PATCH v8 1/5] dt-bindings: thermal: mediatek: add binding documentation for MT8365 SoC MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20221018-up-i350-thermal-bringup-v8-1-23e8fbb08837@baylibre.com> References: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Markus Schneider-Pargmann , Hsin-Yi Wang , Amjad Ouled-Ameur , Michael Kao X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1674640259; l=1282; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=C4Y1Pt62EoG+4OlWvlrEg4v27fXBsImkQVLZNvvWkNY=; b=uD21fUR/ws6xOLFPdRjyxdjDPlgRNM1W/KbrrSQK0yePNU+jk8+RDZVIRiljHH9YhIUoHdXfL610 77rP5aXeBnwY8vNXCIeKsqzHT+I7iazUu7nOuyhH1XkSUFQH50HC X-Developer-Key: i=aouledameur@baylibre.com; a=ed25519; pk=HgYWawSL4qLGPx+RzJ+Cuu+V8Pi/KQnDDm1wjWPMOFE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabien Parent Add the binding documentation for the thermal support on MT8365 SoC. Signed-off-by: Fabien Parent Signed-off-by: Amjad Ouled-Ameur Reviewed-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Acked-by: Rob Herring --- Documentation/devicetree/bindings/thermal/mediatek-thermal.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt= b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt index 38b32bb447e3..ac39c7156fde 100644 --- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt @@ -16,6 +16,7 @@ Required properties: - "mediatek,mt7981-thermal", "mediatek,mt7986-thermal" : For MT7981 SoC - "mediatek,mt7986-thermal" : For MT7986 SoC - "mediatek,mt8183-thermal" : For MT8183 family of SoCs + - "mediatek,mt8365-thermal" : For MT8365 family of SoCs - "mediatek,mt8516-thermal", "mediatek,mt2701-thermal : For MT8516 famil= y of SoCs - reg: Address range of the thermal controller - interrupts: IRQ for the thermal controller --=20 2.39.1 From nobody Sat Sep 21 04:34:34 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 0676DC27C76 for ; Wed, 25 Jan 2023 09:51:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235416AbjAYJvR (ORCPT ); Wed, 25 Jan 2023 04:51:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235347AbjAYJvH (ORCPT ); Wed, 25 Jan 2023 04:51:07 -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 BC1FE4C2A for ; Wed, 25 Jan 2023 01:51:04 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id q5so11778639wrv.0 for ; Wed, 25 Jan 2023 01:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=a8rG7Mbgb1oWT4fX2vZyNeYThYNVXL6oBqBlNEJwaWo=; b=xPWzL4S43VKse9dWE8bt5cpWWfxCYYdjSEnvvA18Lvlhc/05RPdQbUtIXakb3vBwOr yvTO5WToHjWPcxv2LW1ueJxhU0PfaDPRmCtYjxQsZ3sU1yQmGMS3+a9TqsoIteKsbReD E6udwR9XHgscFD4p3EXKzHbpMD+F6R1VBsvHQ8tJoRRyV4M0XEzwFOp3eQVwWN5CF1gS /wszNzazSfHLc52rPtQ1ybUM/SwoxBBoW8g2fNCzZouSJ1SJ2BIglkEJXL7vmff1zvPJ PY4u69Zcwb/CGFAYHJ5szMqb1+PkSMyrvhSnRyjsC2FX/XUN4MtNGpJiZbfy3+9Oc7ch PTAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a8rG7Mbgb1oWT4fX2vZyNeYThYNVXL6oBqBlNEJwaWo=; b=70KSABZ9JZaVS5FSy2vPh+VGvzZ96/smmV+QaW1Y930ryfM05+3aC2T+1oWg+ds/n+ 8xv0+JdjwBGuOys87rPL2QQifz3MkchHvgZoG9MNwG7l0/GXlw7E6Zsg0ZtUXR01MfYj 7j5O+31MMhOhP6reU2p4IE6MmiHoDD4QrcEHKwjLObK94tCzQAKoe6pJx33khjdU6dW1 z8mei5RmbkwgunqHXSEXMQevHXiSC7C8p6D2gECTI0eNNXnVt+oXO5S53gJV8wtNigWC 2MBXuCw+OgSo8KnZ+AIY0oMBWQNbhIj9yA4+MGdpoJc8bzLdOEpY7udARlYZPtIRh/fn KtIA== X-Gm-Message-State: AO0yUKUCwyBZwkcOw3TKbEhwV10I2KOgM/ZK4VMKimaYpesDczTntib9 OG1yIFlNAYQBcAZk8b6FHDDKTA== X-Google-Smtp-Source: AK7set9P75tmgvXzlQ7uRit1xFYJrLg1XymQi858p0cz6PXUglNd52fGr5orgcHOWHr8J38C041+KA== X-Received: by 2002:a5d:66ce:0:b0:2bf:b765:74cf with SMTP id k14-20020a5d66ce000000b002bfb76574cfmr2102506wrw.30.1674640263230; Wed, 25 Jan 2023 01:51:03 -0800 (PST) Received: from [127.0.1.1] (62.213.132.195.rev.sfr.net. [195.132.213.62]) by smtp.googlemail.com with ESMTPSA id j26-20020a5d453a000000b002bdf3809f59sm3955072wra.38.2023.01.25.01.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 01:51:02 -0800 (PST) From: Amjad Ouled-Ameur Date: Wed, 25 Jan 2023 10:50:30 +0100 Subject: [PATCH v8 2/5] thermal: mediatek: control buffer enablement tweaks MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20221018-up-i350-thermal-bringup-v8-2-23e8fbb08837@baylibre.com> References: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Markus Schneider-Pargmann , Hsin-Yi Wang , Amjad Ouled-Ameur , Michael Kao X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1674640259; l=2546; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=o4V8Nb038m3SOSHzM/Z25bSLgf/ue1pK+n3hiU0se4A=; b=z+eBUVG5tTpkdOflpaYTVv0RLdNKf8a4pIUewm6Ch4PuTfzhjtAJJ58QazUubZZjO6YaNfGgl8VM yS/u5hKRAwrw+zWBjbi6O4hrypwnQNNl63tdF+8pse8qmBDQEers X-Developer-Key: i=aouledameur@baylibre.com; a=ed25519; pk=HgYWawSL4qLGPx+RzJ+Cuu+V8Pi/KQnDDm1wjWPMOFE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Schneider-Pargmann Add logic in order to be able to turn on the control buffer on MT8365. This change now allows to have control buffer support for MTK_THERMAL_V1, and it allows to define the register offset, and mask used to enable it. Signed-off-by: Markus Schneider-Pargmann Signed-off-by: Fabien Parent Signed-off-by: Amjad Ouled-Ameur Reviewed-by: AngeloGioacchino Del Regno --- drivers/thermal/mtk_thermal.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index 8440692e3890..d8ddceb75372 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -271,6 +271,9 @@ struct mtk_thermal_data { bool need_switch_bank; struct thermal_bank_cfg bank_data[MAX_NUM_ZONES]; enum mtk_thermal_version version; + u32 apmixed_buffer_ctl_reg; + u32 apmixed_buffer_ctl_mask; + u32 apmixed_buffer_ctl_set; }; =20 struct mtk_thermal { @@ -514,6 +517,9 @@ static const struct mtk_thermal_data mt7622_thermal_dat= a =3D { .adcpnp =3D mt7622_adcpnp, .sensor_mux_values =3D mt7622_mux_values, .version =3D MTK_THERMAL_V2, + .apmixed_buffer_ctl_reg =3D APMIXED_SYS_TS_CON1, + .apmixed_buffer_ctl_mask =3D GENMASK(31, 6) | BIT(3), + .apmixed_buffer_ctl_set =3D BIT(0), }; =20 /* @@ -963,14 +969,18 @@ static const struct of_device_id mtk_thermal_of_match= [] =3D { }; MODULE_DEVICE_TABLE(of, mtk_thermal_of_match); =20 -static void mtk_thermal_turn_on_buffer(void __iomem *apmixed_base) +static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt, + void __iomem *apmixed_base) { - int tmp; + u32 tmp; + + if (!mt->conf->apmixed_buffer_ctl_reg) + return; =20 - tmp =3D readl(apmixed_base + APMIXED_SYS_TS_CON1); - tmp &=3D ~(0x37); - tmp |=3D 0x1; - writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1); + tmp =3D readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg); + tmp &=3D mt->conf->apmixed_buffer_ctl_mask; + tmp |=3D mt->conf->apmixed_buffer_ctl_set; + writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg); udelay(200); } =20 @@ -1070,8 +1080,9 @@ static int mtk_thermal_probe(struct platform_device *= pdev) goto err_disable_clk_auxadc; } =20 + mtk_thermal_turn_on_buffer(mt, apmixed_base); + if (mt->conf->version =3D=3D MTK_THERMAL_V2) { - mtk_thermal_turn_on_buffer(apmixed_base); mtk_thermal_release_periodic_ts(mt, auxadc_base); } =20 --=20 2.39.1 From nobody Sat Sep 21 04:34:34 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 12ED6C27C76 for ; Wed, 25 Jan 2023 09:51:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235456AbjAYJvV (ORCPT ); Wed, 25 Jan 2023 04:51:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235370AbjAYJvH (ORCPT ); Wed, 25 Jan 2023 04:51:07 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC455BA0 for ; Wed, 25 Jan 2023 01:51:05 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id r9so16431062wrw.4 for ; Wed, 25 Jan 2023 01:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OyXshjMx9I3FnCnbGGf131qN8E+ObNVcWzakl//37lg=; b=rU9nyDcS6Yug4sV8lkQBjQq/2kpXGhYUsaGJE4dEDxHUN/K5FUUsf2JWefjvrwf2WB zyKGhXde/FIur7H6R7MbEOWn01kBea3fuDbakvCWPH+qiO2Q1ez/j0+T0M0BC2TRPVsI sexHqMk2k27vgwGZPaoK3WsNEeeyC0VfCyhCy/YKXUQQpwg+ZpNcJ9ebv3lj5Vg7CAHZ XrfT3K0XG2oNd8v5axK5h1Mt6dw9pt1LByJLD3na2M0w8dFtR056orrDMvUPoqHzlhAZ 63pjLECFJPoevHLV0YWZKniRr71DExHWHzwgXuY9YAy9r9puSxVBJKyot1AL63hiOnVC HFdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OyXshjMx9I3FnCnbGGf131qN8E+ObNVcWzakl//37lg=; b=fT06Mqy9abwaTVjFdUBa7NwyulipcKyvoj+qPUzg6UVxgbh4tp0QwfJ2TlU26m7sw8 hCMMz47ghN21P/myf1+9Z+aEtaomY3Ef/aKm/5FW8lybbEDabb2kr2iPmIXyeDro7oAV P84SOj4+yWhBdMoJXN2knZ/2fYjvpqsdkAVdl8ItgmGNmPvG01fH56+DmpotyzNw0rjB C7XCmKh1z66yXHRrjgK4ETgqtjhbkGTJp2N0jBxCNooB7rRgODjv8hNAIr3CSliXbKEy WDNv3XAn/muzOR7B+h7vZfCUgS3GitVTz7MD7ZkkD8DQJcmQaPPeBckU9gQXcKTjEV62 TgrA== X-Gm-Message-State: AFqh2krypDZ0MwIIGkV5Sd2LKsVtaHZpkxV+7lP9Qb31JPT9glf/GKqE JnCN+foHYYO+MqDLLoiRZ3Rn9g== X-Google-Smtp-Source: AMrXdXvstwzCHoHfXYLM88Bd3jRwDFl8qih26EAc+jcGd/2uXd/3uQ3HEo2EBiEOPUxaDj1yFJ4SAA== X-Received: by 2002:a05:6000:a03:b0:2b9:9e7b:be6b with SMTP id co3-20020a0560000a0300b002b99e7bbe6bmr29755750wrb.45.1674640264432; Wed, 25 Jan 2023 01:51:04 -0800 (PST) Received: from [127.0.1.1] (62.213.132.195.rev.sfr.net. [195.132.213.62]) by smtp.googlemail.com with ESMTPSA id j26-20020a5d453a000000b002bdf3809f59sm3955072wra.38.2023.01.25.01.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 01:51:03 -0800 (PST) From: Amjad Ouled-Ameur Date: Wed, 25 Jan 2023 10:50:31 +0100 Subject: [PATCH v8 3/5] thermal: mediatek: add support for MT8365 SoC MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20221018-up-i350-thermal-bringup-v8-3-23e8fbb08837@baylibre.com> References: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Markus Schneider-Pargmann , Hsin-Yi Wang , Amjad Ouled-Ameur , Michael Kao X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1674640259; l=4118; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=5wYWtfcDejCyI0VxehU2OxyAav1D8CtnJv0pDQf46Ho=; b=0S5dMH4Z4r9DBBXAI9xNY/z4liRRYeX/HohWSknTGPStRQprPlqAnbHvVbeVjlSxHl7ll9nIeJ00 HQOVkFZ+A1Zo7aT7utX2bgiWRqhkgWn5AUVt/0qXSGZWUBMRxy9X X-Developer-Key: i=aouledameur@baylibre.com; a=ed25519; pk=HgYWawSL4qLGPx+RzJ+Cuu+V8Pi/KQnDDm1wjWPMOFE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabien Parent MT8365 is similar to the other SoCs supported by the driver. It has only one bank and 3 actual sensors that can be multiplexed. There is another one sensor that does not have usable data. Signed-off-by: Fabien Parent Signed-off-by: Amjad Ouled-Ameur Reviewed-by: AngeloGioacchino Del Regno --- drivers/thermal/mtk_thermal.c | 68 +++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 68 insertions(+) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index d8ddceb75372..3a5df1440822 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -31,6 +31,7 @@ #define AUXADC_CON2_V 0x010 #define AUXADC_DATA(channel) (0x14 + (channel) * 4) =20 +#define APMIXED_SYS_TS_CON0 0x600 #define APMIXED_SYS_TS_CON1 0x604 =20 /* Thermal Controller Registers */ @@ -245,6 +246,17 @@ enum mtk_thermal_version { /* The calibration coefficient of sensor */ #define MT8183_CALIBRATION 153 =20 +/* MT8365 */ +#define MT8365_TEMP_AUXADC_CHANNEL 11 +#define MT8365_CALIBRATION 164 +#define MT8365_NUM_CONTROLLER 1 +#define MT8365_NUM_BANKS 1 +#define MT8365_NUM_SENSORS 3 +#define MT8365_NUM_SENSORS_PER_ZONE 3 +#define MT8365_TS1 0 +#define MT8365_TS2 1 +#define MT8365_TS3 2 + struct mtk_thermal; =20 struct thermal_bank_cfg { @@ -389,6 +401,24 @@ static const int mt7622_mux_values[MT7622_NUM_SENSORS]= =3D { 0, }; static const int mt7622_vts_index[MT7622_NUM_SENSORS] =3D { VTS1 }; static const int mt7622_tc_offset[MT7622_NUM_CONTROLLER] =3D { 0x0, }; =20 +/* MT8365 thermal sensor data */ +static const int mt8365_bank_data[MT8365_NUM_SENSORS] =3D { + MT8365_TS1, MT8365_TS2, MT8365_TS3 +}; + +static const int mt8365_msr[MT8365_NUM_SENSORS_PER_ZONE] =3D { + TEMP_MSR0, TEMP_MSR1, TEMP_MSR2 +}; + +static const int mt8365_adcpnp[MT8365_NUM_SENSORS_PER_ZONE] =3D { + TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2 +}; + +static const int mt8365_mux_values[MT8365_NUM_SENSORS] =3D { 0, 1, 2 }; +static const int mt8365_tc_offset[MT8365_NUM_CONTROLLER] =3D { 0 }; + +static const int mt8365_vts_index[MT8365_NUM_SENSORS] =3D { VTS1, VTS2, VT= S3 }; + /* * The MT8173 thermal controller has four banks. Each bank can read up to * four temperature sensors simultaneously. The MT8173 has a total of 5 @@ -463,6 +493,40 @@ static const struct mtk_thermal_data mt2701_thermal_da= ta =3D { .version =3D MTK_THERMAL_V1, }; =20 +/* + * The MT8365 thermal controller has one bank, which can read up to + * four temperature sensors simultaneously. The MT8365 has a total of 3 + * temperature sensors. + * + * The thermal core only gets the maximum temperature of this one bank, + * so the bank concept wouldn't be necessary here. However, the SVS (Smart + * Voltage Scaling) unit makes its decisions based on the same bank + * data. + */ +static const struct mtk_thermal_data mt8365_thermal_data =3D { + .auxadc_channel =3D MT8365_TEMP_AUXADC_CHANNEL, + .num_banks =3D MT8365_NUM_BANKS, + .num_sensors =3D MT8365_NUM_SENSORS, + .vts_index =3D mt8365_vts_index, + .cali_val =3D MT8365_CALIBRATION, + .num_controller =3D MT8365_NUM_CONTROLLER, + .controller_offset =3D mt8365_tc_offset, + .need_switch_bank =3D false, + .bank_data =3D { + { + .num_sensors =3D MT8365_NUM_SENSORS, + .sensors =3D mt8365_bank_data + }, + }, + .msr =3D mt8365_msr, + .adcpnp =3D mt8365_adcpnp, + .sensor_mux_values =3D mt8365_mux_values, + .version =3D MTK_THERMAL_V1, + .apmixed_buffer_ctl_reg =3D APMIXED_SYS_TS_CON0, + .apmixed_buffer_ctl_mask =3D (u32) ~GENMASK(29, 28), + .apmixed_buffer_ctl_set =3D 0, +}; + /* * The MT2712 thermal controller has one bank, which can read up to * four temperature sensors simultaneously. The MT2712 has a total of 4 @@ -964,6 +1028,10 @@ static const struct of_device_id mtk_thermal_of_match= [] =3D { { .compatible =3D "mediatek,mt8183-thermal", .data =3D (void *)&mt8183_thermal_data, + }, + { + .compatible =3D "mediatek,mt8365-thermal", + .data =3D (void *)&mt8365_thermal_data, }, { }, }; --=20 2.39.1 From nobody Sat Sep 21 04:34:34 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 B51C0C27C76 for ; Wed, 25 Jan 2023 09:51:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234946AbjAYJvY (ORCPT ); Wed, 25 Jan 2023 04:51:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235401AbjAYJvI (ORCPT ); Wed, 25 Jan 2023 04:51:08 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0984D2D59 for ; Wed, 25 Jan 2023 01:51:07 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id e19-20020a05600c439300b003db1cac0c1fso812547wmn.5 for ; Wed, 25 Jan 2023 01:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iFVYW1O2xATTJriM1RmoRREy/G+c337SmUDoCitpzco=; b=kHYJJNAhyMxJs8rkZvXLxWwfNTqjAfmgeTQtNCp+pVmtiHt3Btxu1d51Qr9n5mnFP4 AEVq9BdfmEOyr2Z5LFxjbteGEHhVu39IkOS1Js+eLiU15JOQEQvVPQcpih8Tq4VZ9Buy AxTyr9W6afzaSmaZhNSSNJRXlamcFEi92QU9UrWUd7O0Sd+7+CRkV7WgTMw4HdtcgWHB DlmkE1v+nySG8zIJ3ISUVWqIFgTQSzd/1OgGNclv/5bld3QHriKJ+oJ9BtuUg6VED7Ac A3VmR0eflI6+PAGi51W9ERZtd/1qH5k26oAfqdgM3RoHATBOnm2cyxoSJejkRUdcHQWd nGmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iFVYW1O2xATTJriM1RmoRREy/G+c337SmUDoCitpzco=; b=Rrz+nIhQjbTJa3lqmwKhV/QH0ZHz/i1B0/Gb4e12wtqbn0ju7XRyGODWwwne8dANXa sWVFlW4BWfTGjP098H2rX0dNXQJNGQumsAQ3v+FlES6eqm4VndsMwrhDHdmyw7Oytio/ pt2JqTwj/0Azj4loF4DDuSD6SE8FLlIfst+ABEjbuLxJ3O9JJRxdttm/iZTEJmvvluYQ Z3YHODQWSUaDrJ+I2amK2YJCFBxfntknq8A05k0hC1XdkeunjMXpP9AgXHbgjnXdcdaQ QEElcnIISOj1KfDf77LB+bW3w1lhVqIfFr4EGZFsj9ilYrZWiSZ45odsur4obSlo7XSq EImA== X-Gm-Message-State: AFqh2kphl7M4dmNCSc7yUeCyCZa7ULOi2t0nHlCTYGp2zIuz8bu+Q9pf 3XDszdPOPDMY89nWCvEF+q7RrQ== X-Google-Smtp-Source: AMrXdXtA0Nn0nf947A5sN2hj321whK94v/6tvKmmHq+k8ZtS0NuCX+YbPAErtq0itIP8sXDcBvF2eQ== X-Received: by 2002:a05:600c:3d8d:b0:3d2:bca5:10a2 with SMTP id bi13-20020a05600c3d8d00b003d2bca510a2mr30621063wmb.22.1674640265478; Wed, 25 Jan 2023 01:51:05 -0800 (PST) Received: from [127.0.1.1] (62.213.132.195.rev.sfr.net. [195.132.213.62]) by smtp.googlemail.com with ESMTPSA id j26-20020a5d453a000000b002bdf3809f59sm3955072wra.38.2023.01.25.01.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 01:51:05 -0800 (PST) From: Amjad Ouled-Ameur Date: Wed, 25 Jan 2023 10:50:32 +0100 Subject: [PATCH v8 4/5] thermal: mediatek: add callback for raw to mcelsius conversion MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20221018-up-i350-thermal-bringup-v8-4-23e8fbb08837@baylibre.com> References: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Markus Schneider-Pargmann , Hsin-Yi Wang , Amjad Ouled-Ameur , Michael Kao X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1674640259; l=1727; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=oneS0GOcwyJu/jpresdHeaeVd8flLXASRISr19OSr48=; b=ZV5aCgX9PkZJa0Sypvo2hM4krEb1MLQZDO4q5TsQiehLB9e0NmzlMDH9KDCXcuqTkcNTPHu0QxdJ +O/VpQoWAYxYvRvjtEkQUXuX7tCJB33JiSrJaQOk25Vd5W+U1S1h X-Developer-Key: i=aouledameur@baylibre.com; a=ed25519; pk=HgYWawSL4qLGPx+RzJ+Cuu+V8Pi/KQnDDm1wjWPMOFE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set a callback at probe time instead of checking the version at each get_sensor_temp(). Signed-off-by: Amjad Ouled-Ameur Reviewed-by: AngeloGioacchino Del Regno --- drivers/thermal/mtk_thermal.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index 3a5df1440822..b8e06f6c7c42 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -307,6 +307,8 @@ struct mtk_thermal { =20 const struct mtk_thermal_data *conf; struct mtk_thermal_bank banks[MAX_NUM_ZONES]; + + int (*raw_to_mcelsius)(struct mtk_thermal *mt, int sensno, s32 raw); }; =20 /* MT8183 thermal sensor data */ @@ -726,13 +728,7 @@ static int mtk_thermal_bank_temperature(struct mtk_the= rmal_bank *bank) for (i =3D 0; i < conf->bank_data[bank->id].num_sensors; i++) { raw =3D readl(mt->thermal_base + conf->msr[i]); =20 - if (mt->conf->version =3D=3D MTK_THERMAL_V1) { - temp =3D raw_to_mcelsius_v1( - mt, conf->bank_data[bank->id].sensors[i], raw); - } else { - temp =3D raw_to_mcelsius_v2( - mt, conf->bank_data[bank->id].sensors[i], raw); - } + temp =3D mt->raw_to_mcelsius(mt, i, raw); =20 /* * The first read of a sensor often contains very high bogus @@ -1150,6 +1146,9 @@ static int mtk_thermal_probe(struct platform_device *= pdev) =20 mtk_thermal_turn_on_buffer(mt, apmixed_base); =20 + mt->raw_to_mcelsius =3D (mt->conf->version =3D=3D MTK_THERMAL_V1) ? + raw_to_mcelsius_v1 : raw_to_mcelsius_v2; + if (mt->conf->version =3D=3D MTK_THERMAL_V2) { mtk_thermal_release_periodic_ts(mt, auxadc_base); } --=20 2.39.1 From nobody Sat Sep 21 04:34:34 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 8B717C54E94 for ; Wed, 25 Jan 2023 09:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235465AbjAYJvb (ORCPT ); Wed, 25 Jan 2023 04:51:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235418AbjAYJvJ (ORCPT ); Wed, 25 Jan 2023 04:51:09 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ECF344A2 for ; Wed, 25 Jan 2023 01:51:08 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id h12so12448096wrv.10 for ; Wed, 25 Jan 2023 01:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nCD+Tet020QcCYVXiaAHhZ6T43mxf9NGXvGcAhM5Bko=; b=evdFUzWQ1Z6fmorAAHX/2rx1JsI1ucqR/2YMkGAAzJFPBQG40c0oaoquu3sfWeDTD9 3bbW4b1CwJW2ZtdWk1rskgF9jbFqKw3nADhOCTcIMfnjYXu6ZIy189AvlcMMHgvDfJzY 9afQYjTJqO9rdAxD9pEToliDpS2q7owdH91h9+JBz1LbNAll9s6Hgdia7e+DWdO+w3y4 Sa0NSD8NOfnnL+oK/62NjEgHOpuCEJCGAlnK5JxTKv14/TerzMWhOLbvVwhYti7mQztX CFEwt9AP2Kw+GhKwzuBAxI734uWRGbh4f9+9kYKnBVb02juwMrhdxeOFZh5DSK7RuYiZ KJlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nCD+Tet020QcCYVXiaAHhZ6T43mxf9NGXvGcAhM5Bko=; b=3eHqhQY8SCEurrBvtCJXSLKwEa5FLfoR6qsoi1eKRWA5wKgESbAGJFXi/NWEwEbJW0 Z+51xgJp56w5yiEJVLu2a5T5jjSQmcCDDE0QaNJ1kYygPvfyRc3BP44XArKvLNFWMcNe OaHzATRDaUzpDVBzGksgJT74uAo0ydwRElkFYHlCTK/sg2gV19nf5IOq37/aNNGDT1wl DzxnPh0ndWbVb2CqgXZELCw6G7h3N0hN63wod58gFtkqg4VST1d+FI21WXnnxJfTzFCQ Ye3WJvt75kR+FjW/OAo5bZRS6GE+08I8ahzCzwrxpVuF7Vi8UNMcA4dgPmX8Vx+KEOTF i3cA== X-Gm-Message-State: AFqh2kquvqZOBplLAKUozksehAC6kSjVlQfeXKFn1WrYEu7P/Avn5Avt vdWfvb/ro1H90CukIoXG8nmkhg== X-Google-Smtp-Source: AMrXdXtW4LbC59RXC+dBFm0EBBki8tu4RWZohenwoLSN2vVO4YuGlip37uSG6yoG1MbxuFzynf8qPw== X-Received: by 2002:a05:6000:1e18:b0:2bc:846a:8ead with SMTP id bj24-20020a0560001e1800b002bc846a8eadmr29665011wrb.37.1674640266621; Wed, 25 Jan 2023 01:51:06 -0800 (PST) Received: from [127.0.1.1] (62.213.132.195.rev.sfr.net. [195.132.213.62]) by smtp.googlemail.com with ESMTPSA id j26-20020a5d453a000000b002bdf3809f59sm3955072wra.38.2023.01.25.01.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 01:51:06 -0800 (PST) From: Amjad Ouled-Ameur Date: Wed, 25 Jan 2023 10:50:33 +0100 Subject: [PATCH v8 5/5] thermal: mediatek: try again if first temp read is bogus MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20221018-up-i350-thermal-bringup-v8-5-23e8fbb08837@baylibre.com> References: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Markus Schneider-Pargmann , Hsin-Yi Wang , Amjad Ouled-Ameur , Michael Kao X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1674640259; l=905; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=SvQ8R3apCWGsjdAHgfNQVmNogbxTjihw270BNNJBqk0=; b=pkHFI5a45MlA9rGXHv3vKkA9DV+cFpeLSRC2m5W4FWHIP47gcqAI0gZg8YNrfVLt5u+BTkZkthhA AcisRwV0A8EpqInMTUpFXoe4B4+xb7FfJNqyqIZ9hzAgaCL0DM3w X-Developer-Key: i=aouledameur@baylibre.com; a=ed25519; pk=HgYWawSL4qLGPx+RzJ+Cuu+V8Pi/KQnDDm1wjWPMOFE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In mtk_thermal_bank_temperature, return -EAGAIN instead of 0 on the first read of sensor that often are bogus values. Signed-off-by: Michael Kao Signed-off-by: Hsin-Yi Wang Signed-off-by: Amjad Ouled-Ameur Reviewed-by: AngeloGioacchino Del Regno --- drivers/thermal/mtk_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index b8e06f6c7c42..e7be450cd40a 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -736,7 +736,7 @@ static int mtk_thermal_bank_temperature(struct mtk_ther= mal_bank *bank) * not immediately shut down. */ if (temp > 200000) - temp =3D 0; + temp =3D -EAGAIN; =20 if (temp > max) max =3D temp; --=20 2.39.1