From patchwork Wed Jan 25 09:50:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 48082 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp189606wrn; Wed, 25 Jan 2023 01:56:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXu72A8EQOhvhOU53Z9thaamIzG1Zm7LLHxnpSBtoua5QcrdrQXTBYrbmQZedNoPjaySx8cO X-Received: by 2002:a17:90a:9f45:b0:226:cf55:913f with SMTP id q5-20020a17090a9f4500b00226cf55913fmr32888919pjv.29.1674640605561; Wed, 25 Jan 2023 01:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674640605; cv=none; d=google.com; s=arc-20160816; b=U48qkvEzc5fjKfszW8bXcfmh0Z5pfU9AVM5ylo06Yb2BCakrkH0gr0RphlC1Ujtzkk pZzDvicmjqqFSOpuOYFe4z4ZCOz9Vmf+/+OE8ifd1kU30MdNtsrlOXbaRa/KIGRdTKR2 FPtFG8EcjOHPG5nZBYoxS29M2xvEbqdBPaIqo8YWbCuzMOq786jz+wcdoRNcXKZsC3Da eJGX7pR4HRaGrbRXtcn0oTfeM8QRu2g8gPKrfsHoOhQXFxeYD5fRNeFaKOuGurGuGas3 z9Wa/JAWzpIjOO9exMQuIi/PimKvqMuZ6s9/NOR4RJ6V8m9DQDeBJX7DTxWgl0cS/FpN +8rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=SPsz6CoLNjPAxyd2ASpUS9AhmaiVkC3z8HgK93csZ1U=; b=g7DTRbDkfYJIyawN7yYGonF/bc25sNcvgYWtLYtoV7uhG29KsDbm7zQdsLNHX36UgD BGR+t1CXiHzV9uD/6Mv1u+z9i7TH3E5yLSguN9hFR4MF8U9Otgv82pOBcNnSeapdikD2 /NjgDeehB4G4cmNzVISBuaVnYZwTR8NsUiwbR3LP8IA4YxGSWlRka4Hrt9xGBrwcqFCZ dP/KxmHnCOAxszvqgLRBrmgN6fc6h6SpVAqY0JFpy1Noa7e6q0Szj2liUBEsCw/c+dq+ lH5bicRJpO0wFgDTdeYQQUhCz/52Yr11kNQJCmiA6JaVDzu7h/r/k2S5wtZ5GGxroA3B RI5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=atYXCcfR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 91-20020a17090a09e400b00225eda612dcsi1713858pjo.78.2023.01.25.01.56.34; Wed, 25 Jan 2023 01:56:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=atYXCcfR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235433AbjAYJvN (ORCPT + 99 others); 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-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 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= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755987947495084054?= X-GMAIL-MSGID: =?utf-8?q?1755987947495084054?= 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 family of SoCs - reg: Address range of the thermal controller - interrupts: IRQ for the thermal controller From patchwork Wed Jan 25 09:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 48081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp189569wrn; Wed, 25 Jan 2023 01:56:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLNqQKXaOBt6Uc7HhoQNx3YVYmSTi0vF+dYWEL74NVHlx5SMs20mdgTA+rkP6hTrfS+D90 X-Received: by 2002:a05:6a20:6702:b0:b8:c659:9d56 with SMTP id q2-20020a056a20670200b000b8c6599d56mr33890926pzh.46.1674640594907; Wed, 25 Jan 2023 01:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674640594; cv=none; d=google.com; s=arc-20160816; b=FR+3R1SEdO66Xvawsg3KyEEDqfHRyOrKwhQUPdHbGBuqYqR/SHAQc4ajpfdtFnu5Eg VFTbQFfLl2ciRCQ3fG3Mv1dyQc8q5CkZS4dscuRhsY293gLwLmZf/rzgW0Nvh8LQYX4n Bowm+IHFp1dzbH5bSddyimkJgkNj+74bchlMzE19F/ZbDuUSFafU+mabFl5Z0XX22gOL ttoDvPDjEMEhQQB5ygOEIHe25fBwOCSrGvv8GF9B0euNB3Ax7xRQ7k2uwwsKUWXzncJ0 6B+R94EhcyUH9PqEJy08JY4S/k4SVYh/7YL1ByVitKa5YOfjx0zJvoMXouyQrq5WUeGD ysJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=a8rG7Mbgb1oWT4fX2vZyNeYThYNVXL6oBqBlNEJwaWo=; b=rV6cuyt+LJ7uqXqU+t+MwzV8qvJmNG4KRYGl7wExgRjTcpdZ25oPzJy87RmsNkcKN1 sCRclk+KrAP0CGyePN4G4eEapLJmIt3Szpcyo4kfS5q+GSE1KVaoT9ikqczw6HgOmyNc cctvXaNvxR8CDf5Q0C4ZtfmUBSTsNxNGdOUp/AE2i/FEQQ5VvyYIRxiw2pHZMVqA4Dtm CXUEqyztRyfZJgq8wb4ns4AjLKCEZfEa7APDP+24+pFrM4MM5mea5GSDH68kmvvJ9Fv3 pOshACq1df7DRAPHIMCT/0cqOkCOMPHtYxkCYgZTvPpxdsCJDvMO7abnjAFoWIvnyENs n2Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xPWzL4S4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020aa78d9a000000b0058e0bdc7032si4919488pfr.108.2023.01.25.01.56.22; Wed, 25 Jan 2023 01:56:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xPWzL4S4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235442AbjAYJvQ (ORCPT + 99 others); Wed, 25 Jan 2023 04:51:16 -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-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 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= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755987936036630671?= X-GMAIL-MSGID: =?utf-8?q?1755987936036630671?= 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; }; struct mtk_thermal { @@ -514,6 +517,9 @@ static const struct mtk_thermal_data mt7622_thermal_data = { .adcpnp = mt7622_adcpnp, .sensor_mux_values = mt7622_mux_values, .version = MTK_THERMAL_V2, + .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1, + .apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3), + .apmixed_buffer_ctl_set = BIT(0), }; /* @@ -963,14 +969,18 @@ static const struct of_device_id mtk_thermal_of_match[] = { }; MODULE_DEVICE_TABLE(of, mtk_thermal_of_match); -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; - tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1); - tmp &= ~(0x37); - tmp |= 0x1; - writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1); + tmp = readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg); + tmp &= mt->conf->apmixed_buffer_ctl_mask; + tmp |= mt->conf->apmixed_buffer_ctl_set; + writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg); udelay(200); } @@ -1070,8 +1080,9 @@ static int mtk_thermal_probe(struct platform_device *pdev) goto err_disable_clk_auxadc; } + mtk_thermal_turn_on_buffer(mt, apmixed_base); + if (mt->conf->version == MTK_THERMAL_V2) { - mtk_thermal_turn_on_buffer(apmixed_base); mtk_thermal_release_periodic_ts(mt, auxadc_base); } From patchwork Wed Jan 25 09:50:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 48084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp189760wrn; Wed, 25 Jan 2023 01:57:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXvfy89UOj1yCPtbkQkLUeyP92pN0vqQmqvsr7Cpmkem2IakbCWuaZlLu3EZBngxX2Bi5o2V X-Received: by 2002:a17:902:6b4c:b0:194:8f4d:7126 with SMTP id g12-20020a1709026b4c00b001948f4d7126mr30174847plt.62.1674640639246; Wed, 25 Jan 2023 01:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674640639; cv=none; d=google.com; s=arc-20160816; b=MnrqZYdlJH5wy+hRqxxQ0Kc/czxO3ZMh1z9rI7VhXbw5M5FyrgudCoSVr7eLgFLTmA j8WhJWJADoa0dymLWk1q77gO0b9uqzAm9qWD2GVm13YA6cb4jTrBlcFsvov4lrIoAqto 2IYLi88VYaNxJNTOoxM3X3gbyQCou1Zt2uGwD9kY9g2fWvKLPgyujx4SoAxhlgsoryHs /X6MLHnlINmuWh1eKwAMKg+PO3It8Z5K96HRN4AjQKBeVjYedErFuwsr7mOoUBsTrYjV qrzxOu1N+A6yQXEf5ezt/CQLN+PZX7vQ1kHlezuxzjA06PgQX5LxdYJPH3HzdRu+t628 Doqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=OyXshjMx9I3FnCnbGGf131qN8E+ObNVcWzakl//37lg=; b=krX6d2FyHWHfdT9y+KTe0uJg7zDUdcIx5vvLuNgkn5ieiXe/GGS4hzMC0cHmA/5aRT DvKCM9tknVe9ENcM2nSh+6jBAHOL1adpCQGIDGebP6+8NZKe2gJv8cDsBwxhH3JxwjZK AsCl/E8nvOC0Y4YR1k9Lowb8mMSN6LQ+cVsCOXH6F138EjTnkhjiW97qkkBcc4WWuMiL YZ+koijDF6cVeWpeIkxZnksiDlgbDlw9B+NFh87YmZAIeXv5LY1HeU9Q+vyey7nraEEC /v6+9Fo0LAZTdsGJbaImSN5ApAdVQtBfg6Fkf1fTVUcvOYBzQBZthq1xqnMl7Uc5eypy lMcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=rU9nyDcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a170903018200b00188c7b09446si5772130plg.44.2023.01.25.01.57.07; Wed, 25 Jan 2023 01:57:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=rU9nyDcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235348AbjAYJvV (ORCPT + 99 others); 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-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 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= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755987982747078853?= X-GMAIL-MSGID: =?utf-8?q?1755987982747078853?= 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) +#define APMIXED_SYS_TS_CON0 0x600 #define APMIXED_SYS_TS_CON1 0x604 /* Thermal Controller Registers */ @@ -245,6 +246,17 @@ enum mtk_thermal_version { /* The calibration coefficient of sensor */ #define MT8183_CALIBRATION 153 +/* 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; struct thermal_bank_cfg { @@ -389,6 +401,24 @@ static const int mt7622_mux_values[MT7622_NUM_SENSORS] = { 0, }; static const int mt7622_vts_index[MT7622_NUM_SENSORS] = { VTS1 }; static const int mt7622_tc_offset[MT7622_NUM_CONTROLLER] = { 0x0, }; +/* MT8365 thermal sensor data */ +static const int mt8365_bank_data[MT8365_NUM_SENSORS] = { + MT8365_TS1, MT8365_TS2, MT8365_TS3 +}; + +static const int mt8365_msr[MT8365_NUM_SENSORS_PER_ZONE] = { + TEMP_MSR0, TEMP_MSR1, TEMP_MSR2 +}; + +static const int mt8365_adcpnp[MT8365_NUM_SENSORS_PER_ZONE] = { + TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2 +}; + +static const int mt8365_mux_values[MT8365_NUM_SENSORS] = { 0, 1, 2 }; +static const int mt8365_tc_offset[MT8365_NUM_CONTROLLER] = { 0 }; + +static const int mt8365_vts_index[MT8365_NUM_SENSORS] = { VTS1, VTS2, VTS3 }; + /* * 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_data = { .version = MTK_THERMAL_V1, }; +/* + * 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 = { + .auxadc_channel = MT8365_TEMP_AUXADC_CHANNEL, + .num_banks = MT8365_NUM_BANKS, + .num_sensors = MT8365_NUM_SENSORS, + .vts_index = mt8365_vts_index, + .cali_val = MT8365_CALIBRATION, + .num_controller = MT8365_NUM_CONTROLLER, + .controller_offset = mt8365_tc_offset, + .need_switch_bank = false, + .bank_data = { + { + .num_sensors = MT8365_NUM_SENSORS, + .sensors = mt8365_bank_data + }, + }, + .msr = mt8365_msr, + .adcpnp = mt8365_adcpnp, + .sensor_mux_values = mt8365_mux_values, + .version = MTK_THERMAL_V1, + .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON0, + .apmixed_buffer_ctl_mask = (u32) ~GENMASK(29, 28), + .apmixed_buffer_ctl_set = 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[] = { { .compatible = "mediatek,mt8183-thermal", .data = (void *)&mt8183_thermal_data, + }, + { + .compatible = "mediatek,mt8365-thermal", + .data = (void *)&mt8365_thermal_data, }, { }, }; From patchwork Wed Jan 25 09:50:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 48083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp189697wrn; Wed, 25 Jan 2023 01:57:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXtgCTOGwiOPUBZz4TlflP6SAwTBxMqk1GcYVQT1LDlwezdVEAEh2HCYoyRyUe34q8gdsCE8 X-Received: by 2002:a17:902:7144:b0:194:9e86:ffee with SMTP id u4-20020a170902714400b001949e86ffeemr25446622plm.44.1674640627594; Wed, 25 Jan 2023 01:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674640627; cv=none; d=google.com; s=arc-20160816; b=QrDZfilgqj2j+tF36VJssSY8cg2c1hP4K+NxmX91FoptZ1alA2SyFJzgb2CtkELglk KlZ2hovNgfKYFTMqQEvs2GdkiSBOWAcTRVmduG87vQT3UM8UiOwN6DULq7/v/vrpg/2l 41VId58a65t+C8qMiRwNm6EjnmhQJ0K47bBbXF0qjOASuhbfZK9y+IvNKesELWfUT6NI 5NjRa1dTfpqLPQl8eppFoaiEqdyJgjxQLi7y1mZAPcQak0CvC/zn7D5UfXNcPu+oB7xT j1MZLBbvstOYAlHISc9l+LE5p+OYCF3zkCLD1hapmLt8fxkEhHOWHB0gRJB7LmZftoUv 73EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=iFVYW1O2xATTJriM1RmoRREy/G+c337SmUDoCitpzco=; b=anWyvO653vOI79NoBuH9iiFcFxjEFIx584LWaSnWGNLCqxbvN7U3JRrc3Xbzb1TWqy pYWtgD9TWC7Ld4Wl8314m2fNdGc+BCy1/gN6QwSPhLd5uvMToCEcB73andl/r06o5hM1 DpKm9aZqardkdWFf2pgBxx6VB4npBJ4mE5bz8QmjJjCWnN5i2VXtOvGvdZxlxRwPFSbF kYbWrDsQ8OK8mRFbab+5/coc9YWTjNUbXT099i26nTS+dVZwS+GsVuQmKe/XbQDK0oSY GLR5UQlHseKqD2mA8/lL9ZNPIistTWHi+0ZIcmtSy1huFjZTNhdSx/A1IG9tzSEkGZCw kedA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=kHYJJNAh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc18-20020a17090325d200b0019282cb9cf1si5092843plb.201.2023.01.25.01.56.55; Wed, 25 Jan 2023 01:57:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=kHYJJNAh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235462AbjAYJvY (ORCPT + 99 others); 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-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 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= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755987970726557387?= X-GMAIL-MSGID: =?utf-8?q?1755987970726557387?= 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 { 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); }; /* MT8183 thermal sensor data */ @@ -726,13 +728,7 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank) for (i = 0; i < conf->bank_data[bank->id].num_sensors; i++) { raw = readl(mt->thermal_base + conf->msr[i]); - if (mt->conf->version == MTK_THERMAL_V1) { - temp = raw_to_mcelsius_v1( - mt, conf->bank_data[bank->id].sensors[i], raw); - } else { - temp = raw_to_mcelsius_v2( - mt, conf->bank_data[bank->id].sensors[i], raw); - } + temp = mt->raw_to_mcelsius(mt, i, raw); /* * The first read of a sensor often contains very high bogus @@ -1150,6 +1146,9 @@ static int mtk_thermal_probe(struct platform_device *pdev) mtk_thermal_turn_on_buffer(mt, apmixed_base); + mt->raw_to_mcelsius = (mt->conf->version == MTK_THERMAL_V1) ? + raw_to_mcelsius_v1 : raw_to_mcelsius_v2; + if (mt->conf->version == MTK_THERMAL_V2) { mtk_thermal_release_periodic_ts(mt, auxadc_base); } From patchwork Wed Jan 25 09:50:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 48085 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp189887wrn; Wed, 25 Jan 2023 01:57:44 -0800 (PST) X-Google-Smtp-Source: AK7set+UVrqjIb7rGAE3mbseKoS0QWBcUjkXxejGwzsBkxTlpegfdG4bIm2xgRHQSplldf6+Y5Ht X-Received: by 2002:a17:903:41d2:b0:196:2bf1:b688 with SMTP id u18-20020a17090341d200b001962bf1b688mr1625811ple.15.1674640664319; Wed, 25 Jan 2023 01:57:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674640664; cv=none; d=google.com; s=arc-20160816; b=zSMVf1/S44IGOKvV+exXpnkTWJSDbmXFjasER2fH4TGhK/fDvVkftRyvG4EcelO7JJ g3bHxMlaGSSbz9PypZuU/uvVwsGQcsNi9K9EKhtDFk9PSCEe5vWrTiXlCfAGi31awYMn D+Xh/A+PArPx9lvXrBFEfBkz1MncfiftnvMyBtpHYAWO/FMNjGbIhp6Q2bOpVjsCXjNQ Kp5zp2xIp9iXhPV+tMao/2Mf7jkUEH3dzElNE6FGdoTngfsPd2d8ezAHfgWFS5+bN/Fs 4vZvwdqDfMlFOAfDnkATaGPjRO+gQ0Oem43RJpLCzqc03GfJNLFAYgodK2nZLaIkJuNC Xg7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=nCD+Tet020QcCYVXiaAHhZ6T43mxf9NGXvGcAhM5Bko=; b=bxbbx9SvA8jedcb2vy2I/sgWYRJFUs1JukMTAXxubCHFr0o0nvBRtmRSd51toY+A8K ulFj5fDHhYupcX6uuaZNNLpJ+mGJgXNccrjxNyfWFKBlri8okEkOz3UIuQxieQ1UAsQY NgaXbxFOSUBnN3FbfzrS+0a3MdAfDqH3rZND7EbJ8pfHLWqP4vTLSu5/XepUAYWHXsx0 3Qoj8ZEJlXVNVl2EH761/+9fNW0lXcL+vnUirRN+vX+okzqTxhs5iaNatTEGgJt3P/VY JFJs4jIVDR38AESCsZpJQ8Wn6o9+D8u6Htp/1isrRh/dBRQDliUH6zPkS9IBEp0LCo5J E2uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=evdFUzWQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a1709026b4900b001898ecbeef8si4876201plt.9.2023.01.25.01.57.32; Wed, 25 Jan 2023 01:57:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=evdFUzWQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235463AbjAYJva (ORCPT + 99 others); Wed, 25 Jan 2023 04:51:30 -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-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 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= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755988009414961392?= X-GMAIL-MSGID: =?utf-8?q?1755988009414961392?= 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_thermal_bank *bank) * not immediately shut down. */ if (temp > 200000) - temp = 0; + temp = -EAGAIN; if (temp > max) max = temp;