From patchwork Fri Jan 27 15:44:42 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: 49467 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp901852wrn; Fri, 27 Jan 2023 07:48:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXsSYKR9Vdj9qU4cU+xa1nHNntRFBYEz5fWfuJZxTMAwZtbdB4miaBlZDoMBDhgCgzBR/gLE X-Received: by 2002:a17:906:51b:b0:815:8942:dde with SMTP id j27-20020a170906051b00b0081589420ddemr39289941eja.23.1674834490350; Fri, 27 Jan 2023 07:48:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674834490; cv=none; d=google.com; s=arc-20160816; b=gfropfzb2JvazeTZNXN07GSy68H1brJAxHCVNpDwSRDbhsUZEGFbtdqeuKuPkE8A/1 COVEqjLSnC6hSrrR2e54JG+pantHkzymbo7Fquy6xdn2BI+5yMBnAjVmz3mCnlUlBKrF PJjF8fQmI9TTN1Hjc6o/JYXnEx5bMMze7CllwCWbwC3M9iPpqXkZhjxQvt4mAN+SqDbq 3v6FDP/LEFqbB0qDt/oO2Z6hI7AkiOtz3b6zOyLFzPD0kfJhHDz+dy3eeqmcOFkbVPhf +z7+wFveCII5+1jM9JaKroyShQhYekbj8CcftnxNCSaz6ocfeWRREG0KxcUBRwWsX2qP Nj+g== 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=Wc8FY15N3IbFmSBvPEOu/nx12A5IbZPrhUvo1cGqextLjYQVPlQm9Qaf4J3I9MYDGU tkriYB5KL8RdFvVEh0eMpjm7gV12T+YbbfhCWKyl8Z9eibLei3X6HuTe+wx09/3wxV1L As8TNqnMypACmCnKNUWuOGRNSt1xI1rRcnG7UqQsEvtd5sO+td03AAvFzfMojuTOFsOB Yd2sVMy31WHfb9HOZXgoVUEHcI8Y4rekRZRJp8uN4MLtweLKrEXzqogU9xqjXUlJwlUl K+Sx9Zy47SJ+oYOvKiG1mx754VkSJ9I3RUDFQ4QWMnmqv0xYtVq7SyTQeHkpufZZWTwO P/YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=0naiJqR3; 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 m7-20020a170906848700b0084d37a7d9casi4907851ejx.187.2023.01.27.07.47.46; Fri, 27 Jan 2023 07:48:10 -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=0naiJqR3; 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 S234623AbjA0Ppx (ORCPT + 99 others); Fri, 27 Jan 2023 10:45:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234648AbjA0Ppf (ORCPT ); Fri, 27 Jan 2023 10:45:35 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 264F28716A for ; Fri, 27 Jan 2023 07:45:18 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id e19-20020a05600c439300b003db1cac0c1fso5675909wmn.5 for ; Fri, 27 Jan 2023 07:45:18 -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=0naiJqR3CXP1CSUH1JQR7KqPG5pckDblSfUbPNiY67L+/CLsqv4wi5V5lnThoQnQfl XBC9cwMNuPjcBILcxSYXsUZqO9BE9yCR+xJTVP4s/uQnxBlrR2Pr8EuZ6r4G4RbpAur5 fLaMjFycUMucwjXPSWBteTfKo2O7UPlo5UnMzfZRccczYDKBW7lwXcpvQoooB9qX9cjY D/Wt7zpopMVtACqOu/iwYdKALBWTYIdAamnjV1/C4XrzUr+jGYs8W6BG6YjXMwmbukX1 Wn1lkzevcAlX5ax3PXci1dCalYpVZi9obzdYHx850/weXQ5a2jdpRJfni0sUdxt1bsEU 4nrw== 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=GfqcKL89ig8bf85cPeiOCh7T0fiRgQY2TIJps0rrpTM6BnZBBUwhw6F7qWiU8dog5+ qgL7WSzENkS8ie4sEtZ3SW/74YlcZHCknbgU/uFPUAHkHBwjKkBoBBg94BiYF70ypCz1 /TTFejVL3Mkux/uMxUqEzjaTeBEvAwv3AqHM6VATJ5xvG0QS3mE2rKePpMbaYKG3htJD Qnk21ta/Pz6SCBeS+dGKVP4Mgp8XNvto6mkJ9n3RbcTngRzLYCDVIKhfRcSJYeu5eYge jAVP96tTqeTPvM4ALBmQvxcf1smq9LHBG36QsCjKv+lqn49zT3Dny/hux2QYBY9jM80G lksw== X-Gm-Message-State: AFqh2kpjfyAdfLYdswO400AGUR21R52Ij4criMKcFFd8qQHL5F9CI7Z4 aV6aVxmaMCttUpB4Jog5aSDy5w== X-Received: by 2002:a05:600c:3b83:b0:3d9:f758:e280 with SMTP id n3-20020a05600c3b8300b003d9f758e280mr41502552wms.24.1674834315495; Fri, 27 Jan 2023 07:45:15 -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 z12-20020adff74c000000b00291f1a5ced6sm4381153wrp.53.2023.01.27.07.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:45:15 -0800 (PST) From: Amjad Ouled-Ameur Date: Fri, 27 Jan 2023 16:44:42 +0100 Subject: [PATCH v9 1/5] dt-bindings: thermal: mediatek: add binding documentation for MT8365 SoC MIME-Version: 1.0 Message-Id: <20221018-up-i350-thermal-bringup-v9-1-55a1ae14af74@baylibre.com> References: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@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=1674834313; l=1282; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=C4Y1Pt62EoG+4OlWvlrEg4v27fXBsImkQVLZNvvWkNY=; b=p84J/BeWtHAWzJ/Wpyo21Fc9gYwpI3/1DIJKFge6sSwRcon816f95HVnjLyZsd4fyWILpsQ8U34m FjtNhucEBTBh/OBALocVjgieplh21yx7IezruVT933+1fiowOTEA 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?1756191250218492095?= X-GMAIL-MSGID: =?utf-8?q?1756191250218492095?= 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 Fri Jan 27 15:44:43 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: 49471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp902588wrn; Fri, 27 Jan 2023 07:49:59 -0800 (PST) X-Google-Smtp-Source: AK7set85tDmjOiDKSZio3CIShrmpe6bcaxnQkIM1vJrI3jZsPjZhsenIizw6fhw4y3CzUEqObhBH X-Received: by 2002:a17:90b:17c8:b0:22c:4dd3:5c4b with SMTP id me8-20020a17090b17c800b0022c4dd35c4bmr2599397pjb.19.1674834599308; Fri, 27 Jan 2023 07:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674834599; cv=none; d=google.com; s=arc-20160816; b=C5U6sjwu+/4nc9zG8PqPoqq9ly5grhOPwh94UOekw2okz4wrERuOwVYNAPKCjBF1Ui cv92fCxH3Z5Hj/6REPVwCFYQ8RHGHYzMdmDYAVDs2QfhCgDpV5Ha3cHfLqXK1GWqmMPY N3eyyc6Lrf51NQ/oiN6bNcoPd8VSkFfhnvcf99jtcS2ysbMIk8f5LI/l7xiCu7oGRjpY no1yRTPOmp0Uy6+OvE/hVE+3cDK0nsIfcNz+UvTZMaBEgQkmny3vZ/rBveQJXmJ06Wy+ XbcEzw8GuVF2wDrpuR9sSMeIBqtAL2bll97CsR4trZHgzcI5x6sPtlAfR1Yu1k/3mVPd JO7Q== 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=CAzjyMHqKAA/cDC0XVjD50fuFkP4dHkeOOv8vTdPWaNfBzRg3B1z4EXJJLRO3eQXg9 1ytaKASaamyUhnwciuwjxrh1+qrRGDFIAQOaUD0kpXdTtbXLv9gyxpNE7ueoZDHLaBb7 ra3qc2YNT8B3/yw2Cu8yRyF7BKKeijAXk6/nm11j5Vq6FaPvK6Lot8JZ60cFsgsLXNd8 9wb3TyOEIhGt7bxe2NxeSdHjnWgdyWJRgS8mPMik55SYVSNobEeZP1uOO9/lYEn5c0Ix xNoFe5wnWpk7OBq7ikaPeTDOcgXdVz6CR0u6BklPQLE1ccuwJ9MBw6D0JfVwnxakBcv1 rGDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Ak0M4S3P; 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 c18-20020a17090ab29200b00229c1a4a338si8190740pjr.106.2023.01.27.07.49.46; Fri, 27 Jan 2023 07:49:59 -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=Ak0M4S3P; 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 S233726AbjA0Ppt (ORCPT + 99 others); Fri, 27 Jan 2023 10:45:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233077AbjA0Ppe (ORCPT ); Fri, 27 Jan 2023 10:45:34 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14A387159 for ; Fri, 27 Jan 2023 07:45:16 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id c10-20020a05600c0a4a00b003db0636ff84so3801844wmq.0 for ; Fri, 27 Jan 2023 07:45:16 -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=Ak0M4S3PP2YfIwMvpC1g+jI3DK7R1uaawLMfTZ0B+Xmk4DxyWTByJZK3Dmitz/w8Vr NU5W6K27YWXTm6TU2/5v3fcvIW6/wSHEQOjujgrdPGF/vPlAZUWto2qjHb+xtAZZ0RHb qLYGFOx94tqTuNhEXB3dt9u7qlScW/U8SLYNNsMxIyQ41/GZEPxgM41PBw16Wdmtqk23 UtHO1XWKLi6QbL236FphQaWX7e39VoxyHgXwSXUb35QcSfDdt78VTHSS3CP6C+6mB8zJ HeV+XJ2M+fwE5J6e0rPj+3zKqU9z73pgCVfbUgXfkfpv3T4icegBZufAkLZr7LSrJ2ve WUDw== 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=X2kOEzi4RkvGJOsI7jqFm4+spREXgRjtaktMzVOCkLYmHi3qdqMOL3WPREhht/rxKM 7Dgz63nSFYdUxxBfEOJJxC5mM+EZ9iOk2pyzjQAVMWXh+fKWg1Q5BD18AmxSOpdxBeFD X8VilnwYalSBSb12u9KXBIn0LFqPGc/czbgpMECl4eEy7+FzvwRFzEmDaum+vQQcud9Y bwVir4gN3XVyhIyQOrtIj9hoc614fxDkdpf32CvW/KIqNljGe56a8j7PZz/XRvIZWhcB nAnhzMjnVQfjevY8aLABWIUzFux/UHb/0KKK+s0zP/F7Nsoombk5uvkOQhpit7Fufun4 /YRg== X-Gm-Message-State: AO0yUKU3sRelGea8flNzch0XDgdsU1vFmLUCOPShUOF+iKvwIGdzdzRn HLjVLc7c7OiR/cdhicQQkd70iQ== X-Received: by 2002:a05:600c:1551:b0:3dc:18de:b221 with SMTP id f17-20020a05600c155100b003dc18deb221mr12151943wmg.21.1674834316515; Fri, 27 Jan 2023 07:45:16 -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 z12-20020adff74c000000b00291f1a5ced6sm4381153wrp.53.2023.01.27.07.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:45:16 -0800 (PST) From: Amjad Ouled-Ameur Date: Fri, 27 Jan 2023 16:44:43 +0100 Subject: [PATCH v9 2/5] thermal: mediatek: control buffer enablement tweaks MIME-Version: 1.0 Message-Id: <20221018-up-i350-thermal-bringup-v9-2-55a1ae14af74@baylibre.com> References: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@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=1674834313; l=2546; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=o4V8Nb038m3SOSHzM/Z25bSLgf/ue1pK+n3hiU0se4A=; b=F/MJjX8JLy8QavZIEwP1xSnnGVqcwpuAksMQF4r8pFpwR5bs7BQ9ybmGwstHL43WvEIYyvHZN05C lkzKS4DUD0yH20B1pwekw5XCea4gDE3mVOIjb32AynRNE1hEa6HL 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?1756191364721481905?= X-GMAIL-MSGID: =?utf-8?q?1756191364721481905?= 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 Fri Jan 27 15:44:44 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: 49470 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp902381wrn; Fri, 27 Jan 2023 07:49:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXs4Y0O9n+EgK9GF1av7KdEvYyS1feO8zrfZ6SgyLAVqiBd7nq4Dez/O0gkj9EZaeIUe1qhz X-Received: by 2002:a05:6a20:1596:b0:b8:5f00:bbdc with SMTP id h22-20020a056a20159600b000b85f00bbdcmr53988893pzj.50.1674834571554; Fri, 27 Jan 2023 07:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674834571; cv=none; d=google.com; s=arc-20160816; b=WzvqSV7VivNyOJDW08HZn/uqGx4DzcKXHlU1B3XDAwJkRLwZzY7lfGgdyoaQaTb8e7 8L5lN9OpO7M4qNfeDuPP6nMakorg9znm1v+EZP97DpEsiWHJzqkC8VgM7Q9AljAVgn40 FMln4mkp8Z08+iniH46wa+02PrRsAxOGwQUCKQP7L2Js/kMeC0qT2iLJCqjK8kFZ4Wce K1A0iVDlvkDS4subApKfJ7b2i+DXvfqgC0rHwupZ1UIcL0nCBalJ1p6WN5ehQii/0VHF c6aqJZlQUUyfmtq1hEBdytDROy27eiBIA876ITcBKEKNtSWwibTDSrDvcSJnhoA9/S/F V/FA== 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=FLQCQuXOK5wUfn6JO/omNuynSjdXcJfHP7llGwHOFbsQUbva5+mY8Sj6JiGmNhocvJ 5r7Bc1txzpB2accQ9Ud5MrM27rX0b85YV5YKn9Gju7aHp8E0Cat1MbjbRY4PlUED9dh0 ChZegfutSG7V0Ok4TTXp7o9xrHRPzLgYKomBkZyH9SYWSKIBVsQrKu6MLyEgghDlUN6E sDWw2yvtiO2df9bksgBDbes7FIhyk1rZrTQRyT2iYtAtm4n2iZayZE7PINvNnOx0O2rX B+mA1hoDEB7jf6W2xz/3+HjsT8k46PpNgIk/NxfHDfQo1l9DDCPxkE9sKy9j5qTYdcKO OD7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=MiCfWVmg; 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 n64-20020a632743000000b00484cee96fcbsi4506233pgn.229.2023.01.27.07.49.19; Fri, 27 Jan 2023 07:49:31 -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=MiCfWVmg; 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 S233760AbjA0PqH (ORCPT + 99 others); Fri, 27 Jan 2023 10:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbjA0Ppv (ORCPT ); Fri, 27 Jan 2023 10:45:51 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 201B386256 for ; Fri, 27 Jan 2023 07:45:28 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id j17so3778358wms.0 for ; Fri, 27 Jan 2023 07:45:28 -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=MiCfWVmguKcPEbFYmVu79Px01l/+CDutY7lhKn/KIoOP8o8ZbuGRCoY+a2HYfE8yNk x/d9mAE/QjibCsBuOnkjC9/ZJxwiMjnyuCPezR+ZGMUGMdwwyLh+o1R0WG7wjjwKHy2V PLJLciLzmrcprfyzTsDmf38wG8GQCLSbw08FSMkJCgkCSE7jnIBcw2eb6g9afwh6pGxD 1Ud+s+M1CuupQQnhBI0cBVOsE8gFAAvVlDAoxfgj5FxV4gdhoTY44Ed99J+ZKuYjATSP LLv2KP8IsAXwwa4Embn6WWa4/U+xYo213dM8nnvZSRXhD0M1mcarRW1I5/m+Gu/9U82M OZyA== 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=cEgQ/fWOzVId38qigDPX1takjUsPr57AbiFf7olG01xOB7tbnSxEwMfJXJMSpUQfiQ V3UtDlAuFrC8HgcOvWyL4PzjH/TOw5GwQ51pyzQkOLLDkNCJk7G6F024PDRk6im9COiw 38nA8bV/9pTbPQPuekdoZhFuP6jyvEeCu3VHpu6drzPsWLKrd1Su+NJq5c/sd3WZ9XzA SVU6BlHvvxLIjE5KU9DdpvzXMdNXhpF0ytHoSsDhdfssN6u78N0L6if5GlOEsOdcHoid AJ5PpocngGEWx2qZnzRA6W2AemI3l1jaQ8QMPPaP0ttWZdQRsxpFyICmH/eHWYWgQOJN tUrw== X-Gm-Message-State: AO0yUKUHMbfTvOnR/nlC6ILC6wskhXwlAxL30I7tYrV2/47EKYWuQbJN iZd3WYA7GB9IW7bYfxwuz91zBg== X-Received: by 2002:a05:600c:3510:b0:3dc:3da0:172f with SMTP id h16-20020a05600c351000b003dc3da0172fmr2020491wmq.13.1674834317549; Fri, 27 Jan 2023 07:45:17 -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 z12-20020adff74c000000b00291f1a5ced6sm4381153wrp.53.2023.01.27.07.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:45:17 -0800 (PST) From: Amjad Ouled-Ameur Date: Fri, 27 Jan 2023 16:44:44 +0100 Subject: [PATCH v9 3/5] thermal: mediatek: add support for MT8365 SoC MIME-Version: 1.0 Message-Id: <20221018-up-i350-thermal-bringup-v9-3-55a1ae14af74@baylibre.com> References: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@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=1674834313; l=4118; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=5wYWtfcDejCyI0VxehU2OxyAav1D8CtnJv0pDQf46Ho=; b=h98Z9Y9mb76P05nyRDPtw0n3FMjqiP1QP+LjtEgxyhA0n5FDOut80DuP8KYSrxKDjiIT44rIHJg4 c7bpTkX3B+Sr2CqU/0GNhpQxm0EpwFp9lA5JxNyhomdoniC3P/Ih 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?1756191335569455707?= X-GMAIL-MSGID: =?utf-8?q?1756191335569455707?= 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 Fri Jan 27 15:44:45 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: 49468 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp902032wrn; Fri, 27 Jan 2023 07:48:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtTxe64A2ESqy0jHqTtjkh8q0ev1AAI/NZrLsU615VxQSgl3CGbsueySU1TL3gXCG8TuuH2 X-Received: by 2002:a05:6a21:8cc3:b0:b8:7d27:2cbd with SMTP id ta3-20020a056a218cc300b000b87d272cbdmr40003832pzb.43.1674834515334; Fri, 27 Jan 2023 07:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674834515; cv=none; d=google.com; s=arc-20160816; b=jrCP11kArO7F9iga9B0FEETiyA2Nvc3EoI1Cwi7ZldbBQXCyEQtk2aXdxZ93JjaVKq gz2LVRhjKlJKkiabsfBQB0AW63RUeF1sA2iI58Wtlckj6funlzWJbvjajLNEGeDZ4pMA eLyFrB3gJWm6TI3OHnXAGhA85eTtnlqbkRUiCcS//5FDnBVo5LktQ8elx/a5ViNHxFge PfU879FhwdmvzpshdQbu2CQpxJ+KkV9dRGJOLEWpsW01X30nHXVOLXbhTL393saPZHYk O5KvQvfudiLrCxRN6z3I0kzLNr9+aMpf0IEAm6YVasIanPtiCOckezz47kXlf6hlRwne jF1w== 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=KvL1VibzYma8FnJI/rs3ykOzORZEDQmZRy1SDSZp75Z/0as5FsqmEKZCUTF8dJ/82t qd3pCRCy/RPVOW2Gd+HB/tCmmPIidEP9hlVHtXMZ0LyV2UPUDa4vzNQLdcgpF2C0FYa6 e/dTKAu8qRw4wnKhjCYDBRLFZldTSFse/sEloWIAmfB0EeupUcz3444NzG3cQ0f3pcWz FyUUfdU/N5twO0k+/ZoLeVp96eohJQXb47z97Lo8o5/7Wi3WHGJipHMFQftIJlNMX8wy wlm+38Wb+r/hVloDg9VXKI0XactelAnyvw39SR/cQ/uJLxZHTH8uDjAtR6yJslsPFcGG xylg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=491Ky8Tr; 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 l16-20020a170903245000b00186abd0c784si1285315pls.217.2023.01.27.07.48.23; Fri, 27 Jan 2023 07:48:35 -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=491Ky8Tr; 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 S233182AbjA0PqL (ORCPT + 99 others); Fri, 27 Jan 2023 10:46:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbjA0Ppv (ORCPT ); Fri, 27 Jan 2023 10:45:51 -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 21FF08625B for ; Fri, 27 Jan 2023 07:45:28 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id b7so5354057wrt.3 for ; Fri, 27 Jan 2023 07:45:28 -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=491Ky8TrcAcsgeprw2ZEB8sgi6R/oZLzhKDU0+d3vG7v1nc6h3yA74RGbYkvWZUGx7 Q0tkN7Dadn3um5AJed8e+Uxhes1ERabJDnCU7A/6BYpFnpWWdaXrjj6Il3p1I8VpHSkG GcA/06V6Xi9eNuaFlGDUTvJpxTr14Y8ACoeJpbQF/LNMv1Wf6ztmsMWEw5xZ+CFIsPM2 kvhpuAsK+d+Qf4DWi8UDauaU6DtDoRIbhKjGCPvOGetFluXBsSa2quz3+OMoDtbDdLRE 9m3F2z8NigSQc5pUGYdpfWr19F6Ur2lAMmbkHomvcHHW3zFYNsJTejBJ00gnD8XDdA2M n2vQ== 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=e40M06c0jPS/3Jgcuz4RNsxUn9kyr8/Sg6mOrlQbk7NQmt0Avs4ZoxZP2DSRMKQn4B GFNYjpe24PW6f1Pemf3hLh08Lkuh+QQxCAsB/DwCAyadWCFEoe/qWNKHwJwjvcO5RohW myLtAU9s/IP3NJAIOe2EX51eu0m1LUwjXAReucm+NI7L5VRp7RlLvPDghiw8vLHngELL jQvQTY/3CSo5rDumEPT/639iTQ/G1Ktawa1ECllyMBXvTGY01yzMY0KT4yWOwo2bT39N EOF26jTGM2zaCL2L/dODVD3kg3egD1rk04dlj8PYiLUN9w7FP/3FFTpg7p/wZmo7m/Ao VmvA== X-Gm-Message-State: AFqh2kqG4PBQfHC4h28xhWvq3kG/m+/s8MPN0WcfW8WpcI4BbyGb+no7 anHln1XzzX6NejZnkw6INM+chw== X-Received: by 2002:a5d:6e8b:0:b0:2bd:d9b5:8191 with SMTP id k11-20020a5d6e8b000000b002bdd9b58191mr35643805wrz.61.1674834318557; Fri, 27 Jan 2023 07:45:18 -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 z12-20020adff74c000000b00291f1a5ced6sm4381153wrp.53.2023.01.27.07.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:45:18 -0800 (PST) From: Amjad Ouled-Ameur Date: Fri, 27 Jan 2023 16:44:45 +0100 Subject: [PATCH v9 4/5] thermal: mediatek: add callback for raw to mcelsius conversion MIME-Version: 1.0 Message-Id: <20221018-up-i350-thermal-bringup-v9-4-55a1ae14af74@baylibre.com> References: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@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=1674834313; l=1727; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=oneS0GOcwyJu/jpresdHeaeVd8flLXASRISr19OSr48=; b=PnXR/TW2vh+td5o1N+8uUQCOh9ZzJAzZGpiVAX0YLZpxZwaJwd1lZr59Yb9Anlyb3xTwr21LnY1B TWBcJGy7ALBoVPKUNGYbCNIimiZR/rmYuY5AQNwYV5OoL/voXYml 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?1756191276552679985?= X-GMAIL-MSGID: =?utf-8?q?1756191276552679985?= 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 Fri Jan 27 15:44:46 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: 49469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp902181wrn; Fri, 27 Jan 2023 07:49:00 -0800 (PST) X-Google-Smtp-Source: AK7set9N9LckaTMDYeOb4ZqDt24JKr/OT/dq1TQcBek50SNh+XSwwG2spITPP2zdiNt+WpibU3Mx X-Received: by 2002:a17:90b:4a51:b0:229:f4f3:e904 with SMTP id lb17-20020a17090b4a5100b00229f4f3e904mr7304905pjb.11.1674834540539; Fri, 27 Jan 2023 07:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674834540; cv=none; d=google.com; s=arc-20160816; b=XsCRPJpi2Ew2LD1wZsxACxlyhtVFI6N4R+fhEThMM/mWjcygurMl2pyEpXtekKG9bw UJUjtOeylfwRToYmDLCPfyQC/YVozozJoSFWT+nDvQxQYK3oT2CRcRC0+W6ouKc1kK9J 4JlEv5zlPtNIaKNxbKRx+SiBuwR+E+5KPRp+IwrXeCQVV0++UTi/mKEHp4fMe0oFYn8d ONMVKCkNtrOqZY9PSHjD6oQhiFJ4daezp+N4FWsxVYjt7m2zoIlfGxUVboKTfArb9E5c csrv2KWwSL8fNa8NqAfw+xnn/GyuMT5Q7X3D1v/94F0UVpdpf5P2R98jY8K784rzOJSA vdMQ== 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=pizfg/aH6e9K5CXGoTWYposMWJMO47zqqi8cq0NPoNU=; b=n2xvCOK1X6cJvK06iQIKRyCtfHC2/Gn/TVcssJ/idZsPXl02CKUyU/0G6NrUcQlXFa 2oPr4ukgHkrYMDRgkiUNEuxk6POUC9MwuTYLxjJKsABSyjlgfrpNAkWjTbgknOPUjIMK CprazxvetS1ZOMXKTVehJbmjwqfcw3uc5DcnnZaT6gpHtANSjakvaT2gZcdXk3hRwNUs 5FTrfOOLL0lHn3+Msj7JcRA2BM1XrAAs6KdC6di2hLr/lwei/zu2Jqnxs5VtvVZOQpZt 9sCG4Ps7RxqyrS2I9CTDP337h7xG8waveLbCkBjH3eWsIlqU0uxZbadZAFCi1Ga8ziLN DJaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=hWjOUen6; 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 h184-20020a6383c1000000b004cc3c59b5e7si3723722pge.21.2023.01.27.07.48.48; Fri, 27 Jan 2023 07:49:00 -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=hWjOUen6; 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 S234480AbjA0PqW (ORCPT + 99 others); Fri, 27 Jan 2023 10:46:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234591AbjA0Ppx (ORCPT ); Fri, 27 Jan 2023 10:45:53 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A4F386269 for ; Fri, 27 Jan 2023 07:45:29 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id b7so5354102wrt.3 for ; Fri, 27 Jan 2023 07:45:29 -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=pizfg/aH6e9K5CXGoTWYposMWJMO47zqqi8cq0NPoNU=; b=hWjOUen6VB+r+Bf1HFCafrQMXmXl835/ZOBdz6umvqbR2mgz2vUW+KQX09IJ3SXHuK 1A76JaZo2UnxxNAMibz/Udf2YyQ/sHrcmJnIVTJLHKRGOd2HO1rnEStn5OTWu3m7BAat KBvJlh88kgcaYcz41Z0B5ZdJ54uGX/gpZZpkfd+7Df2sSviqRuwpvQ63BEMF2+gO8SjX YXg0dXoyWCbmkn/9CWLD1BOBdUQ4OeACCNUl5j5ZUkz6TLPnEgHoSmE2k5z3FtcdD7vX peDYH9vTTwsaCSY/l5pDqN18pjrTIXMNDCfLmQjPIje48qWGzMBoA0sOtxKV53J/2lkR ckAw== 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=pizfg/aH6e9K5CXGoTWYposMWJMO47zqqi8cq0NPoNU=; b=Lz6X6TlV7ujBF7EJ1xVhV8qB2kfmzb/aY0r/AQP0XgNWHwdRUfIEn6jNk4cGaYPPCI 3L35HECs4Tps7qFT4uBgwHGas5/kzAk9OTQW01h+TZ9CYsGxhiQu2rMqdu9Evl8WagM+ Tb6CyJVB6S2SizbTkVMLVtdzfr22b3DaaZJP6emvbc7rjfylSM2UvVGTvFf+Zq/Ds8VU f16gxMfS+kPAOFStEq2TfYqgLtAcxDuS1D3lyuBEXE7Pz0wo393HxNH43G0w7ddZhmRb t8M7mRYfyaAORhPVpQizu4MzfprTv1zPsyxArcDSZ3i0wQWl71xrsaJp2WJ6defSCDHe 5N8A== X-Gm-Message-State: AFqh2kpCUXCnjDXAyQFVmAAdxgh4ghjEhCADr4MWE+qVessmlg4sphAv QItyr2Gq1MuCBr7YRzmRN8Xlrw== X-Received: by 2002:a05:6000:98d:b0:2bd:f172:94fe with SMTP id by13-20020a056000098d00b002bdf17294femr38050435wrb.17.1674834319583; Fri, 27 Jan 2023 07:45:19 -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 z12-20020adff74c000000b00291f1a5ced6sm4381153wrp.53.2023.01.27.07.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:45:19 -0800 (PST) From: Amjad Ouled-Ameur Date: Fri, 27 Jan 2023 16:44:46 +0100 Subject: [PATCH v9 5/5] thermal: mediatek: add delay after thermal banks initialization MIME-Version: 1.0 Message-Id: <20221018-up-i350-thermal-bringup-v9-5-55a1ae14af74@baylibre.com> References: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@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=1674834313; l=1567; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=fzmYYuArpv3TgjQmZi16fKXqYLE8Qo9JdtSrD1YAY5s=; b=MFTrCKH6Grd+hiqf7XlaT3d7PqHP384ilZ1t/Y0qFtXPGTpXcf79S/w4BloEnMVX32kgpJ/LQKIK q29F4NunDC16TysUENhaOg467p+38Wwi/oLGbSzCHLmF+AGZ0vQC 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?1756191303013485599?= X-GMAIL-MSGID: =?utf-8?q?1756191303013485599?= Thermal sensor reads performed immediately after thermal bank initialization returns bogus values. This is currently tackled by returning 0 if the temperature is bogus (exceeding 200000). Instead, add a delay between the bank init and the thermal zone device register to properly fix this. 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 | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index b8e06f6c7c42..ab7db385afb3 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -730,14 +730,6 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank) temp = mt->raw_to_mcelsius(mt, 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 = 0; - if (temp > max) max = temp; } @@ -1160,6 +1152,9 @@ static int mtk_thermal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mt); + // Delay for thermal banks to be ready + msleep(30); + tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt, &mtk_thermal_ops); if (IS_ERR(tzdev)) {