From nobody Sat Sep 21 14:11:08 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 C98A7C6FA8E for ; Tue, 20 Sep 2022 15:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231436AbiITPEC (ORCPT ); Tue, 20 Sep 2022 11:04:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231418AbiITPDz (ORCPT ); Tue, 20 Sep 2022 11:03:55 -0400 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 80BFC371B2 for ; Tue, 20 Sep 2022 08:03:52 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id e16so4765342wrx.7 for ; Tue, 20 Sep 2022 08:03:52 -0700 (PDT) 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; bh=u7lzZcB+wCTOpq/I4J4b3D9MEs3lpsunTG7mgG7CDRI=; b=pZ6EiFLPNl8e6/H0Au0y+MFbYIanGZLwXXbLCQeDIQd1XlsPpReAgXodzTcYuT61Aa 89zzyJrGM1So1I3uZXgPgsoL53xHWUsa8nke7jyJjO2S2Fl/Tfa0JoBGJbe10ujXTy2k myFsTLnqt03KF5BNomb9iFIqvAe4dlBWsdagiF/Vb3ujI9X0v+wJXEc2gbg9pZAeJ749 rwziamgDGIcBsNEf+fdsq2/41S+l/koemt/xk+6/1HB3Ie1mdjwgzIEzjMlLMyvZo7zI 0EiFuO4Tt5w3QkwGA3VU9eTOAntFo7p2CipZVzgW+7l9UtqX6ByT9SYUKfFjnoD0uKCn xHYg== 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; bh=u7lzZcB+wCTOpq/I4J4b3D9MEs3lpsunTG7mgG7CDRI=; b=yZ3C0iWnXqJhxrh8dMfA31K5IYLcmFxcTwKxL2XNs+Tg+tGc+F/GAMVDPtwAjJNAq2 o6T7o45Gy4tkEggXhjjKkYMpdkv+Us/e0lMo05mG/NOsEUFVcJo0uYHJJyXKB5MwdURG 2cYNhuO0usJBiWpb5IKYwZsFPjopRQbDNrB2R58U0xInTv9tr/sB3b03PhaxWAP+chUP +9mL2sVHRNm0I37AfcwML9jD0/m2KcQdSaCytPusTdxXKDaP3EoCrAnHpWd3Rnkvrn5Y 8BnqQUBr+PCLVTX1UZP5XuXCv6jDnW/o6LDOA2AvP1UsE7CfmQHvpByDdecQLmzubk3m pGCQ== X-Gm-Message-State: ACrzQf1ewqZl+6BBdGqUMwyPJ1n2es6+zFV63sSKZXWg4hP18hkjU8+A NvnT1WxemR5It7WTqv9P6N/SPQ== X-Google-Smtp-Source: AMsMyM4FjLTURV4Dt0OgXUCHHJVpnZfgXmsFGwBQXoynQ3Novbcx7O0gpXHOBrzgjoeWWrmAN/7EVw== X-Received: by 2002:a5d:47c3:0:b0:22b:ac9:92e with SMTP id o3-20020a5d47c3000000b0022b0ac9092emr5164232wrc.376.1663686231003; Tue, 20 Sep 2022 08:03:51 -0700 (PDT) Received: from [127.0.1.1] (210.145.15.109.rev.sfr.net. [109.15.145.210]) by smtp.googlemail.com with ESMTPSA id u3-20020a5d4683000000b00225239d9265sm242056wrq.74.2022.09.20.08.03.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 08:03:50 -0700 (PDT) From: Amjad Ouled-Ameur Date: Tue, 20 Sep 2022 17:03:48 +0200 Subject: [PATCH v5 1/4] 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: <20220920-i350-thermal-up-v5-1-123bc852d199@baylibre.com> References: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> In-Reply-To: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> To: Amit Kucheria , Rob Herring , Zhang Rui , Daniel Lezcano , "Rafael J. Wysocki" , Krzysztof Kozlowski Cc: Fabien Parent , Hsin-Yi Wang , Markus Schneider-Pargmann , linux-pm@vger.kernel.org, AngeloGioacchino Del Regno , Matthias Brugger , Michael Kao , Amjad Ouled-Ameur , Rob Herring , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1663686228; l=1160; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=Ub01dL5lJO3HNAW69Ya4ycDE389//wyHtwywY+gaBdc=; b=74IdXWfel2MH3YMf/5GSvjnaUPFZaWOdAfv1u1EwWpISTYhcQ2znV5BZFo+6oRG+qqDuslWg7tTs 7M5ta8gcAZgPrbqwIfS95/tp8jcOcwL48HVgbtTrQygMBOSnE613 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 diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt= b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt index 5c7e7bdd029a..ba4ebffeade4 100644 --- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt @@ -14,6 +14,7 @@ Required properties: - "mediatek,mt2712-thermal" : For MT2712 family of SoCs - "mediatek,mt7622-thermal" : For MT7622 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 b4 0.10.0 From nobody Sat Sep 21 14:11:08 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 6C0D4ECAAD8 for ; Tue, 20 Sep 2022 15:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbiITPEG (ORCPT ); Tue, 20 Sep 2022 11:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231430AbiITPDz (ORCPT ); Tue, 20 Sep 2022 11:03:55 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CF73AE59 for ; Tue, 20 Sep 2022 08:03:53 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id n8so2142915wmr.5 for ; Tue, 20 Sep 2022 08:03:53 -0700 (PDT) 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; bh=TmGNn02GgjwItsyH3XavnEsHEt3aT4LQ32MW9ssWl/I=; b=2F0yiM/OgzF4Ed7A5+WPvE7Mk1nzN1Iilg59ccLi7J73+lybZivFjlO3Ll5UIxSnxr n7RS1IA6Hr050B4gC1QLs6XV3Mz3BA3f8z8nfqiJFw72iDOujNjc20MTUUvyxD++HHJt VXKqtKlf/7XaMor2XknMhXTi6u0gMulhVdrofvY6mBCdvs+naTmea49V8tGFDkhQ6apP mN2Yrm8kSCTRgCxCM9WRqqLl2PDj2ZfxpP5jJJ+ks4kllQhhpA5p3KDAo1FX6YMmJTqE mOnGI5EbKnowqU0NCoM70yjtJKEc/G07WP4YvkhkZaOK7f693MBX/sSYohYU/pPNq3tb F8HA== 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; bh=TmGNn02GgjwItsyH3XavnEsHEt3aT4LQ32MW9ssWl/I=; b=VQxCT1El4Vh8Q18kuIV4+CcJkkbb2+OlXp0s7KdHZ5VdpelYXtEuXndEjokCgPJF9D CwqC1eTBmPi/wNiuSA4je12+82dx0WOZkwv//Ec94bv21dE2X6/ECRb+S5soT6fw8mOz +0PeJG60qoJEkMjFJTomLGZzEMlwXP3Be1WJWa2WGLBAvDvqF6yUE5xu3OL6C4u1BvH1 quqd1PiZJddRaJOackb3WQqNne0HHV5ma9RoaJG64aVUHT9O7NR6PxzYkqTsYwgp1wcZ JF3xzEeVlm4P8GKyTO0a3194s2vDk3eUkAY4Ce2kuohoIduFjf9SBdp2kAGzp/yftFB2 c68g== X-Gm-Message-State: ACrzQf2KmlKUdMNljtUagHbVv7W069fAd6wa4+AUpHtMATJwIWoZUOKX pJ3qXjpe20Dljx98VysC74JLLQ== X-Google-Smtp-Source: AMsMyM4xTO6waY4g42gGq+iBbRpilZuIgppAQBmwNVrkXXSLy+/oePmPpSG/eXaojWrHeXW7Hhknqg== X-Received: by 2002:a05:600c:a09:b0:3a6:8900:c651 with SMTP id z9-20020a05600c0a0900b003a68900c651mr2786317wmp.145.1663686232198; Tue, 20 Sep 2022 08:03:52 -0700 (PDT) Received: from [127.0.1.1] (210.145.15.109.rev.sfr.net. [109.15.145.210]) by smtp.googlemail.com with ESMTPSA id u3-20020a5d4683000000b00225239d9265sm242056wrq.74.2022.09.20.08.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 08:03:51 -0700 (PDT) From: Amjad Ouled-Ameur Date: Tue, 20 Sep 2022 17:03:49 +0200 Subject: [PATCH v5 2/4] thermal: mediatek: control buffer enablement tweaks MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20220920-i350-thermal-up-v5-2-123bc852d199@baylibre.com> References: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> In-Reply-To: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> To: Amit Kucheria , Rob Herring , Zhang Rui , Daniel Lezcano , "Rafael J. Wysocki" , Krzysztof Kozlowski Cc: Fabien Parent , Hsin-Yi Wang , Markus Schneider-Pargmann , linux-pm@vger.kernel.org, AngeloGioacchino Del Regno , Matthias Brugger , Michael Kao , Amjad Ouled-Ameur , Rob Herring , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1663686228; l=2347; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=5q/fW4mpAQQZom7YMno2r4M6vJl67k0unrSVbaUfEJ8=; b=XlVTEXZVb137T29c44XMQm5WKed4jWjkqD0vT/9S8XW0ASP1lOEMbQT3VbT6aqgiabILmrb4jfbe PuxqMiI2Dm2YL6lh8uL1289P7KUrvFJ/Gw6bDdoCvJikuGYoVNVy 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 diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index 8440692e3890..d8ddceb75372 100644 Reviewed-by: AngeloGioacchino Del Regno --- 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 b4 0.10.0 From nobody Sat Sep 21 14:11:08 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 BBCF4ECAAD8 for ; Tue, 20 Sep 2022 15:04:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiITPEL (ORCPT ); Tue, 20 Sep 2022 11:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbiITPD4 (ORCPT ); Tue, 20 Sep 2022 11:03:56 -0400 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 977ED36DF1 for ; Tue, 20 Sep 2022 08:03:55 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id t7so4724156wrm.10 for ; Tue, 20 Sep 2022 08:03:55 -0700 (PDT) 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; bh=7fvVxbhAYZ7geA2TrniCTojxhYIL1wsypbBZ+bEyH5k=; b=0C6Ek8hY6ktdcuRYIZZVPgzk2HmL2zkjdSA4AA4SnCHgsos1Sn9xXF/8jZ7k6Tvoot o9JexYUc1qzLVQYT6K138kxNy47Z+AC7K//hkCVHPH6FBw01G20LIxsCOSby5vo1DBaZ ySeTUaPwHtslahcJndNwfTTbLz0ydz2dJ/51CgHy9Fo3VMrv8nG+V6+iNYP+L9qgEp8M auCWjlSpFa8I3bNJnqXDLf1oB/1nsXX2MdESA0NTlSpYxfPzLaWqph2L6rRuO/r9Cmj8 UgJphyUJ5SBgvFGKhHpMHRzY5Stw6mUjyl+N/vq8py88DOJsUEEPaHQC9P824iny7fyv LNrw== 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; bh=7fvVxbhAYZ7geA2TrniCTojxhYIL1wsypbBZ+bEyH5k=; b=bc1dzSVqhpPy6IGiz6UfoRtzHSBIpP1qIL0JHUqbYeXYehrcdSZ7I/aTwDVyu+Fn54 DrybxSfMTVXauYvIl5j5VRTht1n8l65L7bRldCZmvRW3S/64xdwmF7ZSCdLqmQlD8tnf eHuDT0GxXHgB0o5X1zGSnvIaWUlWScSRbiI1KUIELkDuI40C+M9/63zXAmZ64DL7w4NL gCPPoy0nt1k70qm8+lr9XMqpFBQ4SOlRIRoJ506WeelzUUU0DlmAxaz1mAyNQvkkfSUI tkRqsVcQGHQZt7qCFujX2smZQsxW+nZyGU7i1+wLcO8+GQWvHX9cibfTtkTgy1lEyIUn iHPw== X-Gm-Message-State: ACrzQf2ITXzRnxt7NVmKrra6bcTNRNlCl3c97WMfN3Pyjvfdf6FEj5oI oXXSZb4V1BIZOaRIrlnKduQqBw== X-Google-Smtp-Source: AMsMyM6xOPCpx11/H1SUUJlsXshwGblLd61g9dZ9XU0V7KAI69HrOZKOPKCuWrYrWJoQB9oyCwfXfw== X-Received: by 2002:a05:6000:1ac7:b0:22a:906d:3577 with SMTP id i7-20020a0560001ac700b0022a906d3577mr14951482wry.33.1663686233220; Tue, 20 Sep 2022 08:03:53 -0700 (PDT) Received: from [127.0.1.1] (210.145.15.109.rev.sfr.net. [109.15.145.210]) by smtp.googlemail.com with ESMTPSA id u3-20020a5d4683000000b00225239d9265sm242056wrq.74.2022.09.20.08.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 08:03:52 -0700 (PDT) From: Amjad Ouled-Ameur Date: Tue, 20 Sep 2022 17:03:50 +0200 Subject: [PATCH v5 3/4] 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: <20220920-i350-thermal-up-v5-3-123bc852d199@baylibre.com> References: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> In-Reply-To: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> To: Amit Kucheria , Rob Herring , Zhang Rui , Daniel Lezcano , "Rafael J. Wysocki" , Krzysztof Kozlowski Cc: Fabien Parent , Hsin-Yi Wang , Markus Schneider-Pargmann , linux-pm@vger.kernel.org, AngeloGioacchino Del Regno , Matthias Brugger , Michael Kao , Amjad Ouled-Ameur , Rob Herring , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1663686228; l=4000; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=eVZqssHa1FkQT25LvRdPA/FO390Vm6rtd7qvKHJXswg=; b=oLX5iNEqzkN15jnXT0IP6zYUCEIMuPk4gxtg06iKIX+clW57z6GnnCXS4vUbP+MOU2AS0FlNtCcQ LKfAn8DfBQn/zT3fb05jtLtSPnKIifemyG3dmGnwh5cbTcaMTzHO 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 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 b4 0.10.0 From nobody Sat Sep 21 14:11:08 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 EBAC0C54EE9 for ; Tue, 20 Sep 2022 15:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231468AbiITPES (ORCPT ); Tue, 20 Sep 2022 11:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbiITPD4 (ORCPT ); Tue, 20 Sep 2022 11:03:56 -0400 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 4AC1136DD5 for ; Tue, 20 Sep 2022 08:03:55 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id z6so4822711wrq.1 for ; Tue, 20 Sep 2022 08:03:54 -0700 (PDT) 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; bh=lgeGpTBAYoR2IF4IQP47VjInSDUdDHryBKm4+oxNgzo=; b=AwC13zQZ7kpIyEMDTyYtYKqbjeLAubqIrtdYOPfa/uOpnkkYa76Y6RtVfeAAlN/RBH sCyaomhU6F9DV37buweMO6Aw2qK5fsGJDwFR13qkaxxCdC5xqPG94t1lQmuPqI8lnmQn hlYTi7j9LyTiBwjbJ/k07izpQ+PI6w2oGpoKBa9JMt//Mc2dowHh98L5JiQkqjd0OnrG za3xPPPbS+j7n8SobpIdcq6H0m5LBKre9FPpie4aiUbaTOate1rtgKGBSmza5QIdAQ4s m0I3Er5LJgfj3TxKApCDk1qREv6rQZ/rrOZ4V1cNuGA4U3UifcyIkJvKWengp0cHlWzq tghQ== 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; bh=lgeGpTBAYoR2IF4IQP47VjInSDUdDHryBKm4+oxNgzo=; b=e23hF6fCuHZPve5Lo3JrM7+f2U+s5V5LbIGQB7APwquXc+3nbLqw/+bVbLC8Fc4uSN hpuVm4f6mcgVnSUCEftmyT1jNK1FRP/JUB8vKn1PSttdEkNPgaKEL3cUuSK3gyPI6rED WRE0pB0Uiq3qLj9K0hBX5lFCe9JSqCfQwU1ttovGyoQrkeFhPTyAzbDoeUZyuAZy7kD6 iYI5tS8t5lFIEEmv+8MoV1x8iPIqsImNLIz+/yO8LDaLzPinS6KzLqlwpXEOGUizii7n DLOmJn7kUI+cN7peNJ0HSLrHliuLAAPaFUXqmbYRDWpTRLEFx0cErHDPoBu0BwEm3/y3 Z7Xw== X-Gm-Message-State: ACrzQf20QntgmmL1YK5UVppV9qZMrbQxMVVeIRPM4pTWgb0Mc/MVjymS ZO3hJUcim5/W0+r0/jvomWo8Cg== X-Google-Smtp-Source: AMsMyM7Se7NW9TRk/0csWrLvSYf0SPYJQHiZVddFEksgD1KIkNLhxiJM/2UQYS3BzgORDTemXsFUaw== X-Received: by 2002:a05:6000:69d:b0:22a:fa56:86b9 with SMTP id bo29-20020a056000069d00b0022afa5686b9mr7899787wrb.193.1663686234509; Tue, 20 Sep 2022 08:03:54 -0700 (PDT) Received: from [127.0.1.1] (210.145.15.109.rev.sfr.net. [109.15.145.210]) by smtp.googlemail.com with ESMTPSA id u3-20020a5d4683000000b00225239d9265sm242056wrq.74.2022.09.20.08.03.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 08:03:53 -0700 (PDT) From: Amjad Ouled-Ameur Date: Tue, 20 Sep 2022 17:03:51 +0200 Subject: [PATCH v5 4/4] thermal: mediatek: add another get_temp ops for thermal sensors MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20220920-i350-thermal-up-v5-4-123bc852d199@baylibre.com> References: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> In-Reply-To: <20220920-i350-thermal-up-v5-0-123bc852d199@baylibre.com> To: Amit Kucheria , Rob Herring , Zhang Rui , Daniel Lezcano , "Rafael J. Wysocki" , Krzysztof Kozlowski Cc: Fabien Parent , Hsin-Yi Wang , Markus Schneider-Pargmann , linux-pm@vger.kernel.org, AngeloGioacchino Del Regno , Matthias Brugger , Michael Kao , Amjad Ouled-Ameur , Rob Herring , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1663686228; l=5826; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=fxjNU673oWyI9k55hJ8TJXejNRUhPRMZg1dfJg2fwYI=; b=/WAqzQvGkGzuEAKGTCj1zS0PVtjbWepDWLrysKd1rXCGSExs2zPyqTrv5WTmGzILLsZ2JwGXYouB tcIfHt4sBfp0clrszepUhqZ6eMsfkxVgJ6IL1P+CP3BMOzDaiRXx 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 Provide thermal zone to read thermal sensor in the SoC. We can read all the thermal sensors value in the SoC by the node /sys/class/thermal/ In mtk_thermal_bank_temperature, return -EAGAIN instead of -EACCESS on the first read of sensor that often are bogus values. This can avoid following warning on boot: thermal thermal_zone6: failed to read out thermal zone (-13) Signed-off-by: Michael Kao Signed-off-by: Hsin-Yi Wang Signed-off-by: Amjad Ouled-Ameur Reviewed-by: AngeloGioacchino Del Regno diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index 3a5df1440822..311ad611fdab 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -259,6 +259,11 @@ enum mtk_thermal_version { =20 struct mtk_thermal; =20 +struct mtk_thermal_zone { + struct mtk_thermal *mt; + int id; +}; + struct thermal_bank_cfg { unsigned int num_sensors; const int *sensors; @@ -307,6 +312,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 */ @@ -709,6 +716,29 @@ static void mtk_thermal_put_bank(struct mtk_thermal_ba= nk *bank) mutex_unlock(&mt->lock); } =20 +static int _get_sensor_temp(struct mtk_thermal *mt, int id) +{ + u32 raw; + int temp; + + const struct mtk_thermal_data *conf =3D mt->conf; + + raw =3D readl(mt->thermal_base + conf->msr[id]); + + temp =3D mt->raw_to_mcelsius(mt, id, raw); + + /* + * The first read of a sensor often contains very high bogus + * temperature value. Filter these out so that the system does + * not immediately shut down. + */ + + if (temp > 200000) + return -EAGAIN; + else + return temp; +} + /** * mtk_thermal_bank_temperature - get the temperature of a bank * @bank: The bank @@ -721,26 +751,9 @@ static int mtk_thermal_bank_temperature(struct mtk_the= rmal_bank *bank) struct mtk_thermal *mt =3D bank->mt; const struct mtk_thermal_data *conf =3D mt->conf; int i, temp =3D INT_MIN, max =3D INT_MIN; - u32 raw; =20 for (i =3D 0; i < conf->bank_data[bank->id].num_sensors; i++) { - raw =3D readl(mt->thermal_base + conf->msr[i]); - - 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); - } - - /* - * The first read of a sensor often contains very high bogus - * temperature value. Filter these out so that the system does - * not immediately shut down. - */ - if (temp > 200000) - temp =3D 0; + temp =3D _get_sensor_temp(mt, i); =20 if (temp > max) max =3D temp; @@ -749,9 +762,10 @@ static int mtk_thermal_bank_temperature(struct mtk_the= rmal_bank *bank) return max; } =20 -static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature) +static int mtk_read_temp(struct thermal_zone_device *tzdev, int *temperatu= re) { - struct mtk_thermal *mt =3D tz->devdata; + struct mtk_thermal_zone *tz =3D tzdev->devdata; + struct mtk_thermal *mt =3D tz->mt; int i; int tempmax =3D INT_MIN; =20 @@ -770,10 +784,28 @@ static int mtk_read_temp(struct thermal_zone_device *= tz, int *temperature) return 0; } =20 +static int mtk_read_sensor_temp(struct thermal_zone_device *tzdev, int *te= mperature) +{ + struct mtk_thermal_zone *tz =3D tzdev->devdata; + struct mtk_thermal *mt =3D tz->mt; + int id =3D tz->id - 1; + + if (id < 0) + return -EACCES; + + *temperature =3D _get_sensor_temp(mt, id); + + return 0; +} + static const struct thermal_zone_device_ops mtk_thermal_ops =3D { .get_temp =3D mtk_read_temp, }; =20 +static const struct thermal_zone_device_ops mtk_thermal_sensor_ops =3D { + .get_temp =3D mtk_read_sensor_temp, +}; + static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num, u32 apmixed_phys_base, u32 auxadc_phys_base, int ctrl_id) @@ -1072,6 +1104,7 @@ static int mtk_thermal_probe(struct platform_device *= pdev) u64 auxadc_phys_base, apmixed_phys_base; struct thermal_zone_device *tzdev; void __iomem *apmixed_base, *auxadc_base; + struct mtk_thermal_zone *tz; =20 mt =3D devm_kzalloc(&pdev->dev, sizeof(*mt), GFP_KERNEL); if (!mt) @@ -1150,6 +1183,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); } @@ -1161,11 +1197,29 @@ static int mtk_thermal_probe(struct platform_device= *pdev) =20 platform_set_drvdata(pdev, mt); =20 - tzdev =3D devm_thermal_of_zone_register(&pdev->dev, 0, mt, - &mtk_thermal_ops); - if (IS_ERR(tzdev)) { - ret =3D PTR_ERR(tzdev); - goto err_disable_clk_peri_therm; + for (i =3D 0; i < mt->conf->num_sensors + 1; i++) { + tz =3D devm_kmalloc(&pdev->dev, sizeof(*tz), GFP_KERNEL); + if (!tz) + return -ENOMEM; + + tz->mt =3D mt; + tz->id =3D i; + + tzdev =3D devm_thermal_of_zone_register(&pdev->dev, i, tz, (i =3D=3D 0) ? + &mtk_thermal_ops : + &mtk_thermal_sensor_ops); + + if (IS_ERR(tzdev)) { + if (PTR_ERR(tzdev) =3D=3D -ENODEV) { + dev_warn(&pdev->dev, + "sensor %d not registered in thermal zone in dt\n", i); + continue; + } + if (PTR_ERR(tzdev) =3D=3D -EACCES) { + ret =3D PTR_ERR(tzdev); + goto err_disable_clk_peri_therm; + } + } } =20 ret =3D devm_thermal_add_hwmon_sysfs(tzdev); --=20 b4 0.10.0