Message ID | 20230610141739.999268-4-bigunclemax@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1570917vqr; Sat, 10 Jun 2023 07:22:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VzpQRwUaBqQmfnME7VQnx7vk4BIWG09/ihSEbVafhTP3y3emoU/qCmBqg1SkC9gYXYS/e X-Received: by 2002:a17:906:fe44:b0:95e:d74b:d171 with SMTP id wz4-20020a170906fe4400b0095ed74bd171mr5225713ejb.28.1686406937717; Sat, 10 Jun 2023 07:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686406937; cv=none; d=google.com; s=arc-20160816; b=0B+Z5oNsW4D4QV+cEQZGwy3+HWCLn6sVoL2LA3cBT37K2JAoMa/jUWvew6yW5xNRzt oZ7+pC4uiEYYK68ApsSGCiKH1VBLF2tnre7FPAbUinVmRBjLLVQJdLBWAC37A//F8d7q BkYE20abIpesKqiKg132G6njb3kZPNVGMrXfnPjS7Jo1D3ctPB1afzDgNpfFEoaOvu2q siOzHU1G35UKpInRajrfbhcE3uK16DhKLhYFo3m2v4wA9+z91rMnRXo9cUytehEwxuKd LpK2CPVGDDXLebUo/wrCFrkdqzTdo50zLVICcGKzPLpM/fzK71IqohAkyx6MnAvGwDkR Z2Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vsgeyxXBjiNCCbFnpasARFFtGQuGGzV0SKK6yZWlTDw=; b=gQh5y6XmhVVv3eyv4QwGr3l72YFrZH93VVjpsX9hTDbJNh/EZKFFaFxGTX+3L0S9rW DRwgPALDshuvANO/nXTq7ZBt2+wggcSsHulQopL+CpCaKbvWrLWI1DxjfcxZ1eIP6V3m jUA/3eo97x2Pycd4vqBD86qDqC0BDW8OSn9Q/Mvua2w3BBdjRQ+zQyHD0hMcD/Am6hOX hzsPip7FNJPWbWKLFDmdI4RQJUNJFjf/9Fzo2RoOuFXr2dHPbPVXr5fbV77HM8H16D0n 2d/eU0GrdbS1PtD94F36RiLSPkiuSMAJogknRj93B3eAaiPcsdt6VLIbzhWzm5iaRr8G 0v7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Rj0iUZ2J; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a170906345500b0097886880ff2si2646154ejb.959.2023.06.10.07.21.52; Sat, 10 Jun 2023 07:22:17 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=Rj0iUZ2J; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234657AbjFJOS4 (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Sat, 10 Jun 2023 10:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233498AbjFJOSj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 10 Jun 2023 10:18:39 -0400 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 75D833ABB; Sat, 10 Jun 2023 07:18:22 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f6dfc4dffaso20690955e9.0; Sat, 10 Jun 2023 07:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686406700; x=1688998700; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vsgeyxXBjiNCCbFnpasARFFtGQuGGzV0SKK6yZWlTDw=; b=Rj0iUZ2JsSMmbPNyoSYt7fdUnvvw9nf6RiHw08J+SEcYgRC/iwFSL9KNJbdd3Q+zbM UBC8+ntx2FCVoagNvELVpTs8l6Xir7IwKaGrdYAIL0tJ+fAMzpdzLg+iKSGjxj2bZ2uU 2f+F9WMXgjBEbxxuWGWFMLjBDTjp+V5nkv501v7Ycyd/wQt8N5AgIehxPmoK+m5G2bAD PBFsI5EgiiElObE7IEWbHxZrIKS1DsOwjT7UsMlDwOKRZBInEZW3GEkAqGjPoFNRdooa /zPO+XaI3R+hFQtPY4OKj/DqUCFEdXfW+jvnYs9CznNbNvrEbmk27jmbHFW4IH67tYDV luFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686406700; x=1688998700; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vsgeyxXBjiNCCbFnpasARFFtGQuGGzV0SKK6yZWlTDw=; b=IBSvVBO3o70oY3Y9QN166ZtbTJjue8hI71GokZvsteZr+My5HmjHqNzfeiW7mKa1XN Un0DNXsjKOtqaB0DOmATLFgYx5Xq7JK708GRzBY41jdYZsnvFVujkhRM46wF5b8Pu6pL 6dkh2r9il37DoKcj9JZF5RFauvPfgR6JoX4MzOeQm+HIyPslXAuaa4D109Adki84oNp7 613zqkmRyu5XqItnNjeKlCB1JGEx21hB+UZ0EsrDu51iwYuc0Z6EiDphUCKpWcwF+5TE 6yj2KhJvUxCJmZVtiNTeBrqhfBb6BcyK8WN1nrCDXb1Hl+Xe0hNN2XfVutl5S+rYxHDm HeMg== X-Gm-Message-State: AC+VfDwLrOl1kXD8fHwOjvAlOrlADlVpKdnClCYUbAlrLOwKriRIXjTo nf4nLpkStLgoGRRf+oUzkFvsjQ7jvR2m99CJ X-Received: by 2002:adf:f886:0:b0:30a:f0d8:e32e with SMTP id u6-20020adff886000000b0030af0d8e32emr1127222wrp.18.1686406700522; Sat, 10 Jun 2023 07:18:20 -0700 (PDT) Received: from user-PC.. ([178.134.198.138]) by smtp.gmail.com with ESMTPSA id z10-20020a05600c220a00b003f735d6fa74sm5841488wml.9.2023.06.10.07.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jun 2023 07:18:20 -0700 (PDT) From: Maksim Kiselev <bigunclemax@gmail.com> To: linux-kernel@vger.kernel.org Cc: Maxim Kiselev <bigunclemax@gmail.com>, Vasily Khoruzhick <anarsoul@gmail.com>, Yangtao Li <tiny.windzz@gmail.com>, "Rafael J. Wysocki" <rafael@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Cristian Ciocaltea <cristian.ciocaltea@collabora.com>, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-riscv@lists.infradead.org Subject: [PATCH v1 3/3] dt-bindings: thermal: sun8i: Add binding for D1/T113s THS controller Date: Sat, 10 Jun 2023 17:17:34 +0300 Message-Id: <20230610141739.999268-4-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230610141739.999268-1-bigunclemax@gmail.com> References: <20230610141739.999268-1-bigunclemax@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768325841035161461?= X-GMAIL-MSGID: =?utf-8?q?1768325841035161461?= |
Series |
Add D1/T113s thermal sensor controller support
|
|
Commit Message
Maxim Kiselev
June 10, 2023, 2:17 p.m. UTC
From: Maxim Kiselev <bigunclemax@gmail.com> Add a binding for D1/T113s thermal sensor controller. Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com> Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com> --- .../thermal/allwinner,sun8i-a83t-ths.yaml | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
Comments
On Sat, Jun 10, 2023 at 05:17:34PM +0300, Maksim Kiselev wrote: > From: Maxim Kiselev <bigunclemax@gmail.com> > > Add a binding for D1/T113s thermal sensor controller. > > Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com> > Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com> Why do you have 2 sign-offs that are both you w/ different spellings? Content looks fine to me, other than one commit below. > --- > .../thermal/allwinner,sun8i-a83t-ths.yaml | 20 ++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml > index fbd4212285e2..001faa37fc27 100644 > --- a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml > +++ b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml > @@ -16,6 +16,7 @@ properties: > - allwinner,sun8i-a83t-ths > - allwinner,sun8i-h3-ths > - allwinner,sun8i-r40-ths > + - allwinner,sun20i-d1-ths > - allwinner,sun50i-a64-ths > - allwinner,sun50i-a100-ths > - allwinner,sun50i-h5-ths > @@ -61,6 +62,7 @@ allOf: > compatible: > contains: > enum: > + - allwinner,sun20i-d1-ths > - allwinner,sun50i-a100-ths > - allwinner,sun50i-h6-ths > > @@ -84,7 +86,9 @@ allOf: > properties: > compatible: > contains: > - const: allwinner,sun8i-h3-ths > + enum: > + - allwinner,sun8i-h3-ths > + - allwinner,sun20i-d1-ths > > then: > properties: > @@ -103,6 +107,7 @@ allOf: > enum: > - allwinner,sun8i-h3-ths > - allwinner,sun8i-r40-ths > + - allwinner,sun20i-d1-ths > - allwinner,sun50i-a64-ths > - allwinner,sun50i-a100-ths > - allwinner,sun50i-h5-ths > @@ -159,4 +164,17 @@ examples: > #thermal-sensor-cells = <1>; > }; > > + - | > + thermal-sensor@2009400 { > + compatible = "allwinner,sun20i-d1-ths"; > + reg = <0x02009400 0x400>; > + interrupts = <0 90 0>; > + clocks = <&ccu 0>; > + clock-names = "bus"; > + resets = <&ccu 2>; > + nvmem-cells = <&ths_calibration>; > + nvmem-cell-names = "calibration"; > + #thermal-sensor-cells = <0>; Is this calibration required, or optional, for the d1? Cheers, Conor. > + }; > + > ... > -- > 2.39.2 >
сб, 10 июн. 2023 г. в 17:52, Conor Dooley <conor@kernel.org>: ... > > Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com> > Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com> > >> Why do you have 2 sign-offs that are both you w/ different spellings? Sorry for that. I accidentally signed it twice. ... > + - | > + thermal-sensor@2009400 { > + compatible = "allwinner,sun20i-d1-ths"; > + reg = <0x02009400 0x400>; > + interrupts = <0 90 0>; > + clocks = <&ccu 0>; > + clock-names = "bus"; > + resets = <&ccu 2>; > + nvmem-cells = <&ths_calibration>; > + nvmem-cell-names = "calibration"; > + #thermal-sensor-cells = <0>; > >> Is this calibration required, or optional, for the d1? Calibration data for the D1 is optional as for the H6. (But without it, the sensor data will be inaccurate).
On Sat, Jun 10, 2023 at 06:30:48PM +0300, Maxim Kiselev wrote: > сб, 10 июн. 2023 г. в 17:52, Conor Dooley <conor@kernel.org>: > > ... > > > > > Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com> > > Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com> > > > >> Why do you have 2 sign-offs that are both you w/ different spellings? > > Sorry for that. I accidentally signed it twice. > > ... > > > + - | > > + thermal-sensor@2009400 { > > + compatible = "allwinner,sun20i-d1-ths"; > > + reg = <0x02009400 0x400>; > > + interrupts = <0 90 0>; > > + clocks = <&ccu 0>; > > + clock-names = "bus"; > > + resets = <&ccu 2>; > > + nvmem-cells = <&ths_calibration>; > > + nvmem-cell-names = "calibration"; > > + #thermal-sensor-cells = <0>; > > > >> Is this calibration required, or optional, for the d1? > > Calibration data for the D1 is optional as for the H6. > (But without it, the sensor data will be inaccurate). Okay. Modulo the signoff: Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Cheers, Conor.
On Sat, Jun 10, 2023 at 06:59:29PM +0100, Conor Dooley wrote: > On Sat, Jun 10, 2023 at 06:30:48PM +0300, Maxim Kiselev wrote: > > сб, 10 июн. 2023 г. в 17:52, Conor Dooley <conor@kernel.org>: > > > > ... > > > > > > > > Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com> > > > Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com> > > > > > >> Why do you have 2 sign-offs that are both you w/ different spellings? > > > > Sorry for that. I accidentally signed it twice. > > > > ... > > > > > + - | > > > + thermal-sensor@2009400 { > > > + compatible = "allwinner,sun20i-d1-ths"; > > > + reg = <0x02009400 0x400>; > > > + interrupts = <0 90 0>; > > > + clocks = <&ccu 0>; > > > + clock-names = "bus"; > > > + resets = <&ccu 2>; > > > + nvmem-cells = <&ths_calibration>; > > > + nvmem-cell-names = "calibration"; > > > + #thermal-sensor-cells = <0>; > > > > > >> Is this calibration required, or optional, for the d1? > > > > Calibration data for the D1 is optional as for the H6. > > (But without it, the sensor data will be inaccurate). > > Okay. Modulo the signoff: > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Wait, that's not what I meant to say... Clearly turned my brain off for a moment. If it is not going to function correctly without the calibration data, why not make the calibration data required for the d1's ths? Cheers, Conor.
сб, 10 июн. 2023 г. в 21:01, Conor Dooley <conor@kernel.org>: ... > > > > + - | > > > > + thermal-sensor@2009400 { > > > > + compatible = "allwinner,sun20i-d1-ths"; > > > > + reg = <0x02009400 0x400>; > > > > + interrupts = <0 90 0>; > > > > + clocks = <&ccu 0>; > > > > + clock-names = "bus"; > > > > + resets = <&ccu 2>; > > > > + nvmem-cells = <&ths_calibration>; > > > > + nvmem-cell-names = "calibration"; > > > > + #thermal-sensor-cells = <0>; > > > > > > > >> Is this calibration required, or optional, for the d1? > > > > > > Calibration data for the D1 is optional as for the H6. > > > (But without it, the sensor data will be inaccurate). > > > > Okay. Modulo the signoff: > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > Wait, that's not what I meant to say... Clearly turned my brain off for > a moment. If it is not going to function correctly without the > calibration data, why not make the calibration data required for the > d1's ths? I don't really know why, but the calibration data is optional for other controllers. So I just did it the same way. Here is explanation comment about it from the driver: /* * Even if the external calibration data stored in sid is * not accessible, the THS hardware can still work, although * the data won't be so accurate. * * The default value of calibration register is 0x800 for * every sensor, and the calibration value is usually 0x7xx * or 0x8xx, so they won't be away from the default value * for a lot. * * So here we do not return error if the calibration data is * not available, except the probe needs deferring. */
On Sat, Jun 10, 2023 at 11:31:03PM +0300, Maxim Kiselev wrote: > сб, 10 июн. 2023 г. в 21:01, Conor Dooley <conor@kernel.org>: > > ... > > > > > > + - | > > > > > + thermal-sensor@2009400 { > > > > > + compatible = "allwinner,sun20i-d1-ths"; > > > > > + reg = <0x02009400 0x400>; > > > > > + interrupts = <0 90 0>; > > > > > + clocks = <&ccu 0>; > > > > > + clock-names = "bus"; > > > > > + resets = <&ccu 2>; > > > > > + nvmem-cells = <&ths_calibration>; > > > > > + nvmem-cell-names = "calibration"; > > > > > + #thermal-sensor-cells = <0>; > > > > > > > > > >> Is this calibration required, or optional, for the d1? > > > > > > > > Calibration data for the D1 is optional as for the H6. > > > > (But without it, the sensor data will be inaccurate). > > > > > > Okay. Modulo the signoff: > > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > > > Wait, that's not what I meant to say... Clearly turned my brain off for > > a moment. If it is not going to function correctly without the > > calibration data, why not make the calibration data required for the > > d1's ths? > > I don't really know why, but the calibration data is optional for > other controllers. > So I just did it the same way. > Here is explanation comment about it from the driver: > /* > * Even if the external calibration data stored in sid is > * not accessible, the THS hardware can still work, although > * the data won't be so accurate. > * > * The default value of calibration register is 0x800 for > * every sensor, and the calibration value is usually 0x7xx > * or 0x8xx, so they won't be away from the default value > * for a lot. > * > * So here we do not return error if the calibration data is > * not available, except the probe needs deferring. > */ Wait, so if there is no calibration data then this thing will just defer probing, ad infinitum? Looks like everything other than the a33 has the cells in the dts, and the software seems to expect the cells. What am I missing?
вс, 11 июн. 2023 г. в 01:14, Conor Dooley <conor@kernel.org>: > > On Sat, Jun 10, 2023 at 11:31:03PM +0300, Maxim Kiselev wrote: > > сб, 10 июн. 2023 г. в 21:01, Conor Dooley <conor@kernel.org>: > > > > ... > > > > > > > > + - | > > > > > > + thermal-sensor@2009400 { > > > > > > + compatible = "allwinner,sun20i-d1-ths"; > > > > > > + reg = <0x02009400 0x400>; > > > > > > + interrupts = <0 90 0>; > > > > > > + clocks = <&ccu 0>; > > > > > > + clock-names = "bus"; > > > > > > + resets = <&ccu 2>; > > > > > > + nvmem-cells = <&ths_calibration>; > > > > > > + nvmem-cell-names = "calibration"; > > > > > > + #thermal-sensor-cells = <0>; > > > > > > > > > > > >> Is this calibration required, or optional, for the d1? > > > > > > > > > > Calibration data for the D1 is optional as for the H6. > > > > > (But without it, the sensor data will be inaccurate). > > > > > > > > Okay. Modulo the signoff: > > > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > > > > > Wait, that's not what I meant to say... Clearly turned my brain off for > > > a moment. If it is not going to function correctly without the > > > calibration data, why not make the calibration data required for the > > > d1's ths? > > > > I don't really know why, but the calibration data is optional for > > other controllers. > > So I just did it the same way. > > Here is explanation comment about it from the driver: > > /* > > * Even if the external calibration data stored in sid is > > * not accessible, the THS hardware can still work, although > > * the data won't be so accurate. > > * > > * The default value of calibration register is 0x800 for > > * every sensor, and the calibration value is usually 0x7xx > > * or 0x8xx, so they won't be away from the default value > > * for a lot. > > * > > * So here we do not return error if the calibration data is > > * not available, except the probe needs deferring. > > */ > > Wait, so if there is no calibration data then this thing will just defer > probing, ad infinitum? Looks like everything other than the a33 has the > cells in the dts, and the software seems to expect the cells. > What am I missing? Not quite. If we don't have a calibration cell in the dts, then we just skip the calibration. We will only get EPROBE_DEFER if we have calibration in the dts. Here is the whole function code: static int sun8i_ths_calibrate(struct ths_device *tmdev) { struct nvmem_cell *calcell; struct device *dev = tmdev->dev; u16 *caldata; size_t callen; int ret = 0; calcell = devm_nvmem_cell_get(dev, "calibration"); if (IS_ERR(calcell)) { if (PTR_ERR(calcell) == -EPROBE_DEFER) return -EPROBE_DEFER; /* * Even if the external calibration data stored in sid is * not accessible, the THS hardware can still work, although * the data won't be so accurate. * * The default value of calibration register is 0x800 for * every sensor, and the calibration value is usually 0x7xx * or 0x8xx, so they won't be away from the default value * for a lot. * * So here we do not return error if the calibration data is * not available, except the probe needs deferring. */ goto out; } caldata = nvmem_cell_read(calcell, &callen); if (IS_ERR(caldata)) { ret = PTR_ERR(caldata); goto out; } tmdev->chip->calibrate(tmdev, caldata, callen); kfree(caldata); out: return ret; }
On Sun, Jun 11, 2023 at 10:53:56AM +0300, Maxim Kiselev wrote: > вс, 11 июн. 2023 г. в 01:14, Conor Dooley <conor@kernel.org>: > > > > On Sat, Jun 10, 2023 at 11:31:03PM +0300, Maxim Kiselev wrote: > > > сб, 10 июн. 2023 г. в 21:01, Conor Dooley <conor@kernel.org>: > > > > > > ... > > > > > > > > > > + - | > > > > > > > + thermal-sensor@2009400 { > > > > > > > + compatible = "allwinner,sun20i-d1-ths"; > > > > > > > + reg = <0x02009400 0x400>; > > > > > > > + interrupts = <0 90 0>; > > > > > > > + clocks = <&ccu 0>; > > > > > > > + clock-names = "bus"; > > > > > > > + resets = <&ccu 2>; > > > > > > > + nvmem-cells = <&ths_calibration>; > > > > > > > + nvmem-cell-names = "calibration"; > > > > > > > + #thermal-sensor-cells = <0>; > > > > > > > > > > > > > >> Is this calibration required, or optional, for the d1? > > > > > > > > > > > > Calibration data for the D1 is optional as for the H6. > > > > > > (But without it, the sensor data will be inaccurate). > > > > > > > > > > Okay. Modulo the signoff: > > > > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > > > > > > > Wait, that's not what I meant to say... Clearly turned my brain off for > > > > a moment. If it is not going to function correctly without the > > > > calibration data, why not make the calibration data required for the > > > > d1's ths? > > > > > > I don't really know why, but the calibration data is optional for > > > other controllers. > > > So I just did it the same way. > > > Here is explanation comment about it from the driver: > > > /* > > > * Even if the external calibration data stored in sid is > > > * not accessible, the THS hardware can still work, although > > > * the data won't be so accurate. > > > * > > > * The default value of calibration register is 0x800 for > > > * every sensor, and the calibration value is usually 0x7xx > > > * or 0x8xx, so they won't be away from the default value > > > * for a lot. > > > * > > > * So here we do not return error if the calibration data is > > > * not available, except the probe needs deferring. > > > */ > > > > Wait, so if there is no calibration data then this thing will just defer > > probing, ad infinitum? Looks like everything other than the a33 has the > > cells in the dts, and the software seems to expect the cells. > > What am I missing? > > Not quite. If we don't have a calibration cell in the dts, then we > just skip the calibration. > We will only get EPROBE_DEFER if we have calibration in the dts. Ah that makes a lot more sense, thanks.
diff --git a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml index fbd4212285e2..001faa37fc27 100644 --- a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml +++ b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml @@ -16,6 +16,7 @@ properties: - allwinner,sun8i-a83t-ths - allwinner,sun8i-h3-ths - allwinner,sun8i-r40-ths + - allwinner,sun20i-d1-ths - allwinner,sun50i-a64-ths - allwinner,sun50i-a100-ths - allwinner,sun50i-h5-ths @@ -61,6 +62,7 @@ allOf: compatible: contains: enum: + - allwinner,sun20i-d1-ths - allwinner,sun50i-a100-ths - allwinner,sun50i-h6-ths @@ -84,7 +86,9 @@ allOf: properties: compatible: contains: - const: allwinner,sun8i-h3-ths + enum: + - allwinner,sun8i-h3-ths + - allwinner,sun20i-d1-ths then: properties: @@ -103,6 +107,7 @@ allOf: enum: - allwinner,sun8i-h3-ths - allwinner,sun8i-r40-ths + - allwinner,sun20i-d1-ths - allwinner,sun50i-a64-ths - allwinner,sun50i-a100-ths - allwinner,sun50i-h5-ths @@ -159,4 +164,17 @@ examples: #thermal-sensor-cells = <1>; }; + - | + thermal-sensor@2009400 { + compatible = "allwinner,sun20i-d1-ths"; + reg = <0x02009400 0x400>; + interrupts = <0 90 0>; + clocks = <&ccu 0>; + clock-names = "bus"; + resets = <&ccu 2>; + nvmem-cells = <&ths_calibration>; + nvmem-cell-names = "calibration"; + #thermal-sensor-cells = <0>; + }; + ...