From nobody Fri Sep 25 11:05:06 2026 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 532F8330B3F for ; Sun, 13 Sep 2026 14:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311370; cv=none; b=g7qsBBl0YKC2gri0u5WG6NQafF+d3XPfg1JrhBkf60WZGKnSlPjoKA/Lltk9r/Ffi8xfmynv80D3F8aZPhO7y1Mf0gtKeDoXNAoO8NVTlEYA+Ae1vNa/6w4KvzREoatQ8K5PqNDXS4AlwvExBIhzRAiBC69pNeFMpHVZ2QTYNLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311370; c=relaxed/simple; bh=c0FwilGJH257Vmi4WBaFoyoKQXfgT/wqYU4kh/brsPk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EsFh2FV33hDWpY7rdO6ATEZpHW1xm6PA5wh/YR/mr7ygOF9vFQPTtS+KPyZUOvg4CpsJvuFaBtcDgS5M9WuTe77YSb/j8s6FOgx2E28MUcH/4W4/G9CC6y76213oQhkFX1Pw4wRKNCldGkt3WcxtrJvAQWzfake/TbxRpDbRozU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MLIX36Kt; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MLIX36Kt" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-cc4dbcf2b85so713613a12.3 for ; Sun, 13 Sep 2026 07:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789311368; x=1789916168; darn=vger.kernel.org; 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:content-type; bh=z/z4QNBtUdI4E15ZNXPZtkbjaHvGmUhKoMr+O5uGaIE=; b=MLIX36KtvIrguZxHl4EIN4ZYIT5d/rtKSSQDUPsisRKi+NQnTebcXHH+K3HunAlv7a 2bocY7STE+TrXzmT2T7v09GLH2t5A7O3YPZ9c/dBr3oZlmKcArlNJn+BnUp71k1nH46y 7ur6zghuzwFXN/uHcYKeny6LR/AbP53U+fLtEa2ZBnqZCCiTEhTm8+HwVv3rJykr2caW cgDq/DfNdwaOcPjlGbMZXm5/XeTV/7yWJGbESGuk7hT4E0bQzE0VyTPzyB0nJz6yo6nc qWJ9FRlH6xnDT+B8Vxg9woD3B7bNxp4JVoJqvTqCu22YYAPL+ui++kZPfv9LWQDyqQFg aBtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789311368; x=1789916168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=z/z4QNBtUdI4E15ZNXPZtkbjaHvGmUhKoMr+O5uGaIE=; b=rQd8JkMZDwmNi6BHQJ3YG1W0t++yw1LgftqIO6rfSNwr3OnWV3EGl5+U9/kGeUVFJD Z5eF/qx0slc68smnCXiyDgK6zUxNtyi7LgNfxGEwpaOvrAU4bTPi9qwnj826Zm0N10dF MvRVq8MU6czT22fLkK7+g/3XlDrs9s4u4PAx24Y88Pai8NPONGQmZaI3gF+7Jf45Af2H fnD7ugBMjoGGYcxnc+u/eMbqyoX3bYUsn0ukPsXIKbGMQ0ABbFl4hNZPZSMX/ui4RCqQ 8+JXc849pMWpVhjwDqvFdMfcXQA4Xk37r3xFEmskDUjRBRA4SCz3ohFuk8fgHJnlo+G2 o8Pw== X-Forwarded-Encrypted: i=1; AKwUvByzY+WT/CZs0cces40pA9NVlEqsF6GASELXgClSuiviwPvbdidZTve1DmsAekt1Tw0YUonzJgNPG2eJdaM=@vger.kernel.org X-Gm-Message-State: AFuF++nbyKCJm5ZxwGqTktP9xaduSmkayevjpmngwLx6VufuWcwr8Xhx iOAiKeo4Q0o/dPx5OobL6LzPoQN/ngrZmzVCTGN+9rVfowHS+q0b4UJt X-Gm-Gg: AYBFou2E4xunsbTrlQpADjFLq5uzrpx7o1Icv6rg0Sd8DlFuxwPDLQiZxp8R8p2odIK y/DjM4eEoP5m09FEG4TAKpCA1S63JIHRO++cyRICV0KIx94vXOEVcfOB1sHI1PhBID6f8459Fhk kX1OvoLexKIzDA9AL7qisUjO7K7qY76aXNeig9xYkHPqJ3GpDNc34GiB485ls3AZkiZkkc0oAFr 2UkZdBAkuzodHq+7phBnWaDIZnouMwGYTbg3YUVqWHTVfU8RdwSxiahQGBSGEZcaPqPApoVr9tp doNtuIZfRKFTSXEmBQ+yYWYumvwX7NISlVOSNTtmd0cDEkJdyHKzrsTv1CxRqS2VHoDbLu02orx UmRHCO36tnF85wUxgsP11XqhQuedbt2ibg1F5AHu8v/yC8jsQswJRB0zcKWNZvIuKWwgSrmm2Rd LlejtCoDOLs9R7F/ufNswGLx4yuz2Yv6e+C3Nq/CUUUhQL+J3J14gXHpYOAFX3IzOQ X-Received: by 2002:a05:6a21:46c5:b0:3d1:60d3:99f8 with SMTP id adf61e73a8af0-3daed46ad42mr25849990637.5.1789311368455; Sun, 13 Sep 2026 07:56:08 -0700 (PDT) Received: from archlinux ([207.90.239.231]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33ba7a9bb56sm21467366eec.31.2026.09.13.07.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 07:56:08 -0700 (PDT) From: Mikhail Kalashnikov To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Philipp Zabel , =?UTF-8?q?Juan=20Manuel=20L=C3=B3pez=20Carrillo?= , Andre Przywara Subject: [PATCH v6 1/5] dt-bindings: thermal: sun8i: Add A523 THS0/1 controllers Date: Sun, 13 Sep 2026 22:55:23 +0800 Message-ID: <20260913145527.18148-2-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145527.18148-1-iuncuim@gmail.com> References: <20260913145527.18148-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mikhail Kalashnikov Add dt-bindings description of the thermal sensors in the A523 processor. The calibration data for both thermal controllers (THS0, THS1) is split across two nvmem cells at different offsets, requiring the two cells to be read and merged. To maintain backward compatibility, the name of the old cell remains "calibration" and the new cell is named "calibration-second-part". Signed-off-by: Mikhail Kalashnikov Reviewed-by: Chen-Yu Tsai --- .../thermal/allwinner,sun8i-a83t-ths.yaml | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t= -ths.yaml b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-= ths.yaml index 3e61689f6..792081af5 100644 --- a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.ya= ml +++ b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.ya= ml @@ -24,6 +24,8 @@ properties: - allwinner,sun50i-h5-ths - allwinner,sun50i-h6-ths - allwinner,sun50i-h616-ths + - allwinner,sun55i-a523-ths0 + - allwinner,sun55i-a523-ths1 =20 clocks: minItems: 1 @@ -47,11 +49,16 @@ properties: maxItems: 1 =20 nvmem-cells: - maxItems: 1 - description: Calibration data for thermal sensors + minItems: 1 + items: + - description: Calibration data for thermal sensors + - description: Additional cell in case of separate calibration data =20 nvmem-cell-names: - const: calibration + minItems: 1 + items: + - const: calibration + - const: calibration-second-part =20 allwinner,sram: maxItems: 1 @@ -107,6 +114,7 @@ allOf: enum: - allwinner,sun8i-h3-ths - allwinner,sun20i-d1-ths + - allwinner,sun55i-a523-ths0 =20 then: properties: @@ -132,6 +140,26 @@ allOf: - clock-names - resets =20 + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun55i-a523-ths0 + - allwinner,sun55i-a523-ths1 + then: + properties: + nvmem-cells: + minItems: 2 + nvmem-cell-names: + minItems: 2 + else: + properties: + nvmem-cells: + maxItems: 1 + nvmem-cell-names: + maxItems: 1 + required: - compatible - reg --=20 2.55.0 From nobody Fri Sep 25 11:05:06 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32CCE33689D for ; Sun, 13 Sep 2026 14:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311386; cv=none; b=MKfMvrPUpdBKU8YKYhIy472BZ4wyNnaTxQjjeU0g4Jb1WZQX580Eaq67ANCf2AR1l9y2dN5hR9sQAD1ARjcBJ2RQft1cycikFzCti5g8Adq3koQ4ppBuguRX9CvFW9zvg0W58m7XbX1CmPg+aW0Hk6rWxWxhoWkAMq3qqyeMwYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311386; c=relaxed/simple; bh=0TPiKoG4GPPZx3Popa85L5Rb7uSjVhIAcmRo7lxz1XQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t3xu5u7ps+3b2cHEfiQj7R/5l4ewt4PXhGfU5mxifi6UFYz4TpLdsKP65wIGdIuSXEMI5s/ClaQhoNFBa+1H7MZm/WzQ+8r5ZZnYnr/CCd/e4U2Q2rT8xafB3bghubWD3ajHf9Rxctq+cd+bTWIrPDIbOTXdYE/7hQAsCFUpQmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Euc4+sc2; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Euc4+sc2" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2caced6038eso23562725ad.0 for ; Sun, 13 Sep 2026 07:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789311382; x=1789916182; darn=vger.kernel.org; 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:content-type; bh=VAFG6OrHDCLtY8RoJ0lJqtavylNBVWsmbDH0jNrFE9U=; b=Euc4+sc2LqV719c98ngqmSxq8ZVip309CKJwJlTojf9JVo7MkbL1jwwtRLzn4lflkf Jrg1c1eEf4/pJrl2TnopxH7uyq+u0ohHUAuB7j5UZM3cc+kkyereDuvuoANelVPrlrRl FoJ3wB8mRxpVD75x0X6OZbkrwQydvNlTAdXCXrMq5W30VdjeiCUA0eEZObJTx7DKGq5Z lm4+n1rEqxTeoOSqPKptpfk9YA+0fKKHZ08AvYX5//toHTUWpdwa8jWLvLmM4U0YewLH Nznh+SNJKTHxm7VRzc3xqko9TkjXtpBbmGMZ7bFUY0wEVR8EFOFtkAeab4gPa9rXDwy4 tAlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789311382; x=1789916182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=VAFG6OrHDCLtY8RoJ0lJqtavylNBVWsmbDH0jNrFE9U=; b=FFWpjWOo3L61kaZK9fdBkJWg2Zhrvc2A64BEWdc6R96TImqrJDOGDekrGdCbw+4wxr +HBdgLNiBQO0cDcGf3To2zyZPFQsj3YINFQr/pCsg6pWnQTGNXBVTXGrWgq+dywEgkCV EQ8qveSyptGQa0AYczu9P1v8B7MFrO7i3YTxz3RPzC5hucvb9+Dt4s8dDnIq7B/9mYWL 38x9dMOpKWJr8mydNkruEJx0sOiJJoosO998KLY2oONzshOpEsdHixzsLrxrekCuLeMa Av6SuqDU3KENdAyrJzI+n5egtVPDgSO7TVJ5KThDfsVxZR9oiavdb3uNo2nphhgNQmjy D5sg== X-Forwarded-Encrypted: i=1; AKwUvBy0+DUbzqn0DMbCSNAv9KnnYeuyzQgfLiqa/QYCVt28RFGPIAQgzG90LbZklCWjWHKKrkj89WCuJuV53PA=@vger.kernel.org X-Gm-Message-State: AFuF++mdLansLRMk6cntGB6LkHNDlSb2l2bwybpzJl/hErhT9WCJHBJt hr4HhfL6iqfcw9P0RiwAX/AkhmpeKZ0rQ+DJSoQBSRpVghtvhXmihy+A X-Gm-Gg: AYBFou0Y6csZ9Dl/b2NE8LdeimUb1JkzE7BSBBCQQMlM2DrnGAHotnHHOoNKYYp+z3t ZglzmlQriaLaGra+QWA+DS3GTP6efUbwE3yO8NkYLf/ZkMX1jzN3kx/9LFDucsdvkNBXsJGdRWw ITBQcJYTrT+16Tf0WWn8uIDZdm3KhdM+b0wPbALU5MnFwT5kEiSIWKioPY43PT0W5C4eF+lXGTJ fm4E43R47oXpLBKh8L1YyGb/z5J1aavtmZ4V0sdExJvankIpDFDDWbxzyjj7ttXxNDiA5cqO8xW cf1kBR8fWxTGIZKqndX8RitIXugyaBw40w8EOtAGEGy+Y0MSh8ZvrZq+fPQg/Yb03ylPdsMmig6 Ad6od8ADwzO/4IcRwP1VuPeaQfcm+ICZY/cDmDqkwnTVGvRA+yVJa3t5PYnElvqBnbP24uBT+tc zqbtsAkcRe3OQdjuTE8B5CRAQM0t3+wYJ6AcxE5rRAkl0zWF8HfN2g97KOoJ4hxMQq X-Received: by 2002:a17:902:f786:b0:2d8:d4d2:d138 with SMTP id d9443c01a7336-2dd5f1bc196mr31924865ad.20.1789311382058; Sun, 13 Sep 2026 07:56:22 -0700 (PDT) Received: from archlinux ([207.90.239.231]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33ba7a9bb56sm21467366eec.31.2026.09.13.07.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 07:56:21 -0700 (PDT) From: Mikhail Kalashnikov To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Philipp Zabel , =?UTF-8?q?Juan=20Manuel=20L=C3=B3pez=20Carrillo?= , Andre Przywara Subject: [PATCH v6 2/5] thermal/drivers/sun8i: replace devm_reset_control_get to devm_reset_control_get_shared_deasserted Date: Sun, 13 Sep 2026 22:55:24 +0800 Message-ID: <20260913145527.18148-3-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145527.18148-1-iuncuim@gmail.com> References: <20260913145527.18148-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mikhail Kalashnikov The A523 processor has two temperature controllers, but they share a common reset line. Make it shared with the shared variant of devm_reset_control_get(), and also simplify the driver by switching to devm_reset_control_get_shared_deasserted(). Signed-off-by: Mikhail Kalashnikov Reviewed-by: Chen-Yu Tsai Reviewed-by: Philipp Zabel --- drivers/thermal/sun8i_thermal.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_therma= l.c index 284684137..1412bce63 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -341,11 +341,6 @@ static int sun8i_ths_calibrate(struct ths_device *tmde= v) return ret; } =20 -static void sun8i_ths_reset_control_assert(void *data) -{ - reset_control_assert(data); -} - static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) { struct platform_device *sram_pdev; @@ -388,19 +383,10 @@ static int sun8i_ths_resource_init(struct ths_device = *tmdev) return PTR_ERR(tmdev->regmap); =20 if (tmdev->chip->has_bus_clk_reset) { - tmdev->reset =3D devm_reset_control_get(dev, NULL); + tmdev->reset =3D devm_reset_control_get_shared_deasserted(dev, NULL); if (IS_ERR(tmdev->reset)) return PTR_ERR(tmdev->reset); =20 - ret =3D reset_control_deassert(tmdev->reset); - if (ret) - return ret; - - ret =3D devm_add_action_or_reset(dev, sun8i_ths_reset_control_assert, - tmdev->reset); - if (ret) - return ret; - tmdev->bus_clk =3D devm_clk_get_enabled(&pdev->dev, "bus"); if (IS_ERR(tmdev->bus_clk)) return PTR_ERR(tmdev->bus_clk); --=20 2.55.0 From nobody Fri Sep 25 11:05:06 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7CCA32E73E for ; Sun, 13 Sep 2026 14:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311399; cv=none; b=TWwdIyCY+bX9VGau+5HRBeE1dJ/jEW5bL1mBh2UWOrCf/MO3O29U4STprtKwSSH7aX+qq3oYZ8XLV/kNNUbZ3nPDtdMHzkKE8HkRmYI6gxXZ+nF4GHlpWZqjrP9HSKZvJQTuL/+EztU3io54wuAAdqhZSlKWtyTuC5uab2GVh2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311399; c=relaxed/simple; bh=eAYwAL+ffPnZAqP7POHGmOo+jkIZt7HAkY6H3prb/vA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=njcjq1MMNuwXmbNauUNSomeS4WWXB1x31mUSyLrENAOmnljJc4dBAysUbAeA/FxF7OyaIfozX/9f8qLWI4+Vh2wmHuRZl2UGJF3a9k6kopXC92IkdhI0OU2zygQGV5pHtbYgTSSprcqx2lfN0Hf1nWJOiWvkBDmyNB3Ob23q+HQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OcaqpT0+; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OcaqpT0+" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2dd1dcdcf95so18420845ad.1 for ; Sun, 13 Sep 2026 07:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789311397; x=1789916197; darn=vger.kernel.org; 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:content-type; bh=CdQEo7CCMpGixzfwvENOdVkMVrSMvvagZo4VCY8/koc=; b=OcaqpT0+gBFQrkMzyr2vzf5Y4zk3uknGTv8HE3sNmaVO80G8Vrqq7/fPvCwEtp1xb5 LEH38vyKs46GhO01o2hImbmgipOC3yP9BdpCxdSnQofG9AWadmtedu/0bgN73rhfBCvV YnMXRd/rMvQwHYOMzQU39Ci7EEK4oBIN9CVEH5BZMBurauh5IAiQjM648g9Ox25bHZVM t4RfOoTVEuEEbd7M1RHO7MCRe8BLRDiduUyTjgbm/QgbDIhMcHQ141+/IvtsOc4kdpmS J9+ZmiXnvo7023xnR386dUI0UsnjZ5UJBeiXGVBkfaYfJO5h0i3QHdGHzuKJ924Vo5sA /rlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789311397; x=1789916197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=CdQEo7CCMpGixzfwvENOdVkMVrSMvvagZo4VCY8/koc=; b=NVv8gX3lXWA7VynF3uxsWM0N8kHFZ/sv5H5tp08Z7MOSE/o0dhKlKVZO2aR9AEw6Vz nfXbc7XQZFZOEY/nEUV9NliFCRJWvkUkF43nBDKyFU54jwwCxsRmiltFragH5ZM1RF1e c68fIm/fwth1b+R0pWUCf/sZIgzdtMgvYMlmtMFw7ZVb2GHrCRWf/jAdl77ioCvEkSrp UWKmtK4+wtDo5/UoctJOt9aunqgo07KOvpndjKsPmaeeGUO7YhuB5JQ4jRa975h7KwzA EikylpK/dzvub5YqwYQD+rjTzCSiKZ+KCXs9XwBnVzuhMv5BPKBkMdaqLaec/vAbkRVm nPNA== X-Forwarded-Encrypted: i=1; AKwUvBw6biXHOLB33+lqWv1+lIrK00D63gUlNbVycddaA/p6GLn0Rago3T9aybQ92B8f5xSTZ7D0YQql2QwWM+A=@vger.kernel.org X-Gm-Message-State: AFuF++nnB7kUTcOvOugVy+Dhle7AJ6nriC4+twtyUqWicR8X/s7JdEd6 v4PmZ4MBf+HBMSJnlEetbFVdz9fVszLWSRVvZH9y00WUgRnXnYLRGFz6 X-Gm-Gg: AYBFou1Y46pmPx/2zNgXqvlJMoLUn7SGWUf1bIH9IRu/DdHc+Xv3dvvoGZjbdsOZhza mWriAerY5mO+kyEtaIDixhkDIyR7m/C0LAf+GDF94R7fmsJ+axA/aO/iqShht4H9zXweqtla3lw akSGKTuybnc5uJ2/nJhbHToMHDrSk5+KUoYMiD36o6R2KazTIA81rghvlxHqdNeVCZ/oAOnvLo7 X/j8+WJYaHa6CSqqTg+vXXwLszfDWsZN5hYcqM+BK/eLRm4CjQa+ruUInVjKuT936jgEPeQDIyI L0xhZBasPlo1m2GV4T7namrs6M0kJra8gcmiat0EefCpKOQC2YwTLmBvGb4j9xgtcalRFVyMYH7 bPWgXVHEn873RnHj9q15eXJbYb5zKRIXTX15RFtCIrnPZsF4PNJYnlcfSlCZRZlZly1+W5+4o4U DVs5FxC1SCVSMpEDSmtQdlq6IxvAC09Bkdec3FF+7QK8yS0kRPiS/WKHjQhzr5DacH X-Received: by 2002:a17:902:c409:b0:2d9:2ff6:246e with SMTP id d9443c01a7336-2dd5f1d74d6mr32381155ad.23.1789311397076; Sun, 13 Sep 2026 07:56:37 -0700 (PDT) Received: from archlinux ([207.90.239.231]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33ba7a9bb56sm21467366eec.31.2026.09.13.07.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 07:56:36 -0700 (PDT) From: Mikhail Kalashnikov To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Philipp Zabel , =?UTF-8?q?Juan=20Manuel=20L=C3=B3pez=20Carrillo?= , Andre Przywara Subject: [PATCH v6 3/5] thermal/drivers/sun8i: get calibration data from two nvmem cells Date: Sun, 13 Sep 2026 22:55:25 +0800 Message-ID: <20260913145527.18148-4-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145527.18148-1-iuncuim@gmail.com> References: <20260913145527.18148-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mikhail Kalashnikov The A523 processor has calibration data in two nvmem cells. To be able to add support, the ability to add data from two cells into one array must be added. Signed-off-by: Mikhail Kalashnikov Reviewed-by: Chen-Yu Tsai --- drivers/thermal/sun8i_thermal.c | 81 +++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_therma= l.c index 1412bce63..360654880 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -300,43 +300,68 @@ static int sun50i_h6_ths_calibrate(struct ths_device = *tmdev, =20 static int sun8i_ths_calibrate(struct ths_device *tmdev) { - struct nvmem_cell *calcell; + struct nvmem_cell *calcell =3D NULL; struct device *dev =3D tmdev->dev; - u16 *caldata; - size_t callen; + struct device_node *np =3D dev_of_node(dev); + struct property *prop; + const char *cellname; + u8 *caldata =3D NULL; + size_t callen =3D 0; int ret =3D 0; =20 - calcell =3D nvmem_cell_get(dev, "calibration"); - if (IS_ERR(calcell)) { - if (PTR_ERR(calcell) =3D=3D -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; + of_property_for_each_string(np, "nvmem-cell-names", prop, cellname) { + size_t len; + u8 *caldatapart; + + calcell =3D of_nvmem_cell_get(np, cellname); + if (IS_ERR(calcell)) { + if (PTR_ERR(calcell) =3D=3D -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; + } + + caldatapart =3D nvmem_cell_read(calcell, &len); + nvmem_cell_put(calcell); + calcell =3D NULL; + if (IS_ERR(caldatapart)) { + ret =3D PTR_ERR(caldatapart); + goto out; + } + + caldata =3D devm_krealloc(dev, caldata, callen + len, GFP_KERNEL); + if (!caldata) { + kfree(caldatapart); + ret =3D -ENOMEM; + goto out; + } + + memcpy(caldata + callen, caldatapart, len); + callen +=3D len; + kfree(caldatapart); } =20 - caldata =3D nvmem_cell_read(calcell, &callen); - if (IS_ERR(caldata)) { - ret =3D PTR_ERR(caldata); + if (!caldata) goto out; - } =20 - tmdev->chip->calibrate(tmdev, caldata, callen); + tmdev->chip->calibrate(tmdev, (u16 *)caldata, callen); =20 - kfree(caldata); + devm_kfree(dev, caldata); + caldata =3D NULL; out: - if (!IS_ERR(calcell)) + if (!IS_ERR_OR_NULL(calcell)) nvmem_cell_put(calcell); return ret; } --=20 2.55.0 From nobody Fri Sep 25 11:05:06 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CED55331A53 for ; Sun, 13 Sep 2026 14:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311416; cv=none; b=VxZlzGp3z+5GRVccwvElbgqdi7AS9PVfvqLtqSPn2ru3Zp0BGdve0utbrbRUrV1rliWCYNvh8jhfbQKIVspJuyBhxRuE3LnX7vTGGkqhM+AqwpseEq0z/ebJ1IbkcDhc9gfvydBAKmmcA53vhUKBa0mZK+xrm0+iUaaFBPhw7FA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311416; c=relaxed/simple; bh=002rqKnwYlIeVlmK+OrjXg0dmApCO+jy4dOIn8rGOwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jH70TQkDGGgZjQ/P2QoxRKOE7izCBWuz50FgY9ygnzNSVYy3q0X+KlRXBhk74mE4Wk8yNm6RmMNcCG5RAt6uBVqIe6fJfwLMSbWQd1r3mFaLwCd12RqE8svCVuuwHbBuPWZjWPpjXSLhmg+abdRj99D0MKBufF2tATCMNItAlVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=axNCiK0X; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="axNCiK0X" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2dd664da0f5so453735ad.0 for ; Sun, 13 Sep 2026 07:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789311411; x=1789916211; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MFmILcFARM3nbjJrUrOfoTXP5jUQVkRuUWrnpYTCEmM=; b=axNCiK0X16xSYIUjGMsp36VBO8SCzpYWM8SSINH0g9mtGnwz6dHHvLGBhckM76n67S OOYQc5yjRlUQRd7kEq4AwwyOnpC2df+CC1o4F8fDYSZjmb5qfS+faPVek8Pd699qIrhL Q9G0A5pZ+xObc1/KUtm2r6ciiqDuKIHIO6UoYFORmXEdjENfR5dXxTzZCLNUKcvFPnbU cwnumFe7MNqWkyFsbH/Y8oY4nIybovzmaW9F3AjFNxvun8uoEFVNXW6YDN0xMxUI4osQ 3xwAg0GA/IABwucDXyq8r38gyv0nW7TZSabX3yW5C57IlcJPaajHc0zZtxxVzQQ88WJi bz1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789311411; x=1789916211; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MFmILcFARM3nbjJrUrOfoTXP5jUQVkRuUWrnpYTCEmM=; b=U45XD9jBZ5tvTglq116d1XShdqrZ9ie2F3Q8hUYV30uSWYwJNieEv3t/EHSP+aA54W ksuzYF8IHw0OsUfWI65oKzFrdO5CNxTVfdc8MK38+UUb6wnwSaWhZf+CtCH6hsz0H2Cs kTUEV2ni3wU68rB0UzAD9gSizNMhaUSf79gCcFYgtEDFmrWkRwW++7StvMVWK3pYxMUL hhoW943rBuI3sKFyXythoNO8XY9xUZw+E6igKaY9CG026C32Tr3JEkuuQ3jWevy1Xfnf VylxZSrWqqMdGF5sibjrJ2LMSfzvR54Cdyfc1D0YI9ZxyYVCkfiiP/003Dqq0JjBHGAT bDHg== X-Forwarded-Encrypted: i=1; AKwUvBzV3HHrtSWJRuptjr82C5AmZWv6QcfNwsoC7LQdwKvReJ5c6CwK4CVruVtdip5rsuFBStsyPO/dJil4H30=@vger.kernel.org X-Gm-Message-State: AFuF++nIH/mRGa9eQb8/KI+84sHGa1D84lceugTXAh3qHKi1D0q6p+iu tyo11V0LQCxUHwvkGacbfTtQG7gIPN/vFpus9IKjU4+4gHXdMTRpEMCP X-Gm-Gg: AYBFou2fpjipICLQWt6wbsS4e+ztjAsTnWFzINJbKnDYqN+5Ehu2G2bHcDwTkNtmMtJ BohfRGv3krQK/hW4WKC3L3TYOPWEAnLlCeENW6zMIMbOxQhmJuDGKWgQHtwODNaRJ7Dq3i4cPmx iZYqOeZa27FArsxgMEagzbgHOoylwrzBgasCmzIdbYA/cz4fXVpLddUBgBEM3H5osfY8wK3xP28 Q8KsG9sYCHD7L/8py4GLXVS3RJJIvAvYlDjtd9FiA0KR6jHjiZAojCTh4BSlm8Mx9qaFtyKfP+w gbXWGF4aQasYcuBbtEePD59UL5o7jTarfVBx6lEAcTXFEJu7us+CubzXVsoZNLRxj5gwO2/O9K2 4LIfeIilaqDVgy7NHy8ILlv7vfMQPNr6JlatYhCjKUYMAwQ9HEUGdNUGnccKDmf/oD1R9vnW6eB l4o26RTNGN8eVMk0iSGvor6ZNS2j7LRHPOaz/04VH/SatuIe3jwNntiYvuMVNf8AXt X-Received: by 2002:a17:90b:51c8:b0:38e:5b59:c2ff with SMTP id 98e67ed59e1d1-39d9bbc802bmr22552630a91.3.1789311411298; Sun, 13 Sep 2026 07:56:51 -0700 (PDT) Received: from archlinux ([207.90.239.231]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33ba7a9bb56sm21467366eec.31.2026.09.13.07.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 07:56:50 -0700 (PDT) From: Mikhail Kalashnikov To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Philipp Zabel , =?UTF-8?q?Juan=20Manuel=20L=C3=B3pez=20Carrillo?= , Andre Przywara Subject: [PATCH v6 4/5] thermal/drivers/sun8i: Add support for A523 THS0/1 controllers Date: Sun, 13 Sep 2026 22:55:26 +0800 Message-ID: <20260913145527.18148-5-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145527.18148-1-iuncuim@gmail.com> References: <20260913145527.18148-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Mikhail Kalashnikov The A523 processor has two temperature controllers, THS0 and THS1. THS0 has only one temperature sensor, which is located in the DRAM controller. THS1 does have 4 sensors: ths1_0 - "big" cores ths1_1 - "little" cores ths1_2 - gpu ths1_3 - npu The user manual for the T527 processor describes 4 sensors, whereas the one for the A523 describes only 3. As additional information, the BSP driver was used, in which the value SUN55IW3_CAL_COM(5000) is used as the calibration value in the formula; in the mainline driver it is treated as the ft_deviation value. Also, in the BSP driver the NPU sensor is used for both the GPU and the NPU =E2=80=94 its actual purpose is unclea= r; both sensors are functional and show temperature changes depending on load. Signed-off-by: Mikhail Kalashnikov Reviewed-by: Chen-Yu Tsai --- drivers/thermal/sun8i_thermal.c | 147 ++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_therma= l.c index 360654880..4a81486f8 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -59,6 +59,12 @@ #define SUN50I_H6_THS_PC_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12) #define SUN50I_H6_THS_DATA_IRQ_STS(x) BIT(x) =20 +#define SUN55I_A523_DELIMITER 0x7c8 +#define SUN55I_A523_OFFSET_BELOW 2736 +#define SUN55I_A523_OFFSET_ABOVE 2825 +#define SUN55I_A523_SCALE_BELOW 74 +#define SUN55I_A523_SCALE_ABOVE 65 + struct tsensor { struct ths_device *tmdev; struct thermal_zone_device *tzd; @@ -114,6 +120,21 @@ static int sun50i_h5_calc_temp(struct ths_device *tmde= v, return -1590 * reg / 10 + 276000; } =20 +/* + * The constant names were chosen in accordance with the BSP driver; + * they indicate whether the value corresponds to a high or low + * temperature (relative to a value of ~55 =C2=B0C), rather than the reg v= alue + * that was read. + */ +static int sun55i_a523_calc_temp(struct ths_device *tmdev, + int id, int reg) +{ + if (reg >=3D SUN55I_A523_DELIMITER) + return SUN55I_A523_SCALE_BELOW * (SUN55I_A523_OFFSET_BELOW - reg); + else + return SUN55I_A523_SCALE_ABOVE * (SUN55I_A523_OFFSET_ABOVE - reg); +} + static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp) { struct tsensor *s =3D thermal_zone_device_priv(tz); @@ -298,6 +319,105 @@ static int sun50i_h6_ths_calibrate(struct ths_device = *tmdev, return 0; } =20 +/* + * The A523 calibration data is stored in the eFuse, split across two + * nvmem cells. THS1 has four sensors, including ths1_3 which is used + * for the NPU, each with its own calibration value. The fields are + * packed as shown in the layouts below. + * + * efuse layout 0x38-0x3F (caldata[0..3]): + * caldata[0] caldata[1] caldata[2] caldata[3] + * 0 16 24 32 36 48 60 64 + * +---------------+---------------+---------------+---------------+ + * | | | temp | ths1_0 | ths1_1 | + + * +---------------+---------------+---------------+---------------+ + * + * efuse layout 0x44-0x4B (caldata[4..7]): + * caldata[4] caldata[5] caldata[6] caldata[7] + * 0 12 16 24 32 36 48 64 + * +---------------+---------------+---------------+---------------+ + * | ths1_2 | ths1_3 | ths0 | | + + * +---------------+---------------+---------------+---------------+ + */ +static int sun55i_a523_ths_calibrate(struct ths_device *tmdev, + u16 *caldata, int callen) +{ + struct device *dev =3D tmdev->dev; + int i, ft_temp; + + if (!caldata[1]) + return -EINVAL; + + ft_temp =3D (((caldata[2] << 8) | (caldata[1] >> 8)) & FT_TEMP_MASK) * 10= 0; + + for (i =3D 0; i < tmdev->chip->sensor_num; i++) { + int sensor_reg, sensor_temp, cdata, offset; + /* + * Chips ths0 and ths1 have common parameters for value + * calibration. To separate them we can use the number of + * temperature sensors on each chip. + * For ths0 this value is 1. + */ + if (tmdev->chip->sensor_num =3D=3D 1) { + sensor_reg =3D ((caldata[5] >> 8) | + (caldata[6] << 8)) & TEMP_CALIB_MASK; + } else { + switch (i) { + case 0: + sensor_reg =3D (caldata[2] >> 4) & TEMP_CALIB_MASK; + break; + case 1: + sensor_reg =3D caldata[3] & TEMP_CALIB_MASK; + break; + case 2: + sensor_reg =3D caldata[4] & TEMP_CALIB_MASK; + break; + case 3: + sensor_reg =3D ((caldata[4] >> 12) | + (caldata[5] << 4)) & TEMP_CALIB_MASK; + break; + default: + sensor_reg =3D 0; + break; + } + } + + sensor_temp =3D tmdev->chip->calc_temp(tmdev, i, sensor_reg); + + /* + * Calibration data is CALIBRATE_DEFAULT - (calculated + * temperature from sensor reading at factory temperature + * minus actual factory temperature) * X (scale from + * temperature to register values). + * + * The BSP's SUN55IW3_CAL_COM(5000) is applied as ft_deviation + * in sun8i_ths_get_temp(), after calc_temp(), and therefore + * intentionally not repeated here. + */ + cdata =3D CALIBRATE_DEFAULT - + ((sensor_temp - ft_temp) / SUN55I_A523_SCALE_BELOW); + + if (cdata & ~TEMP_CALIB_MASK) { + /* + * Calibration value more than 12-bit, but calibration + * register is 12-bit. In this case, ths hardware can + * still work without calibration, although the data + * won't be so accurate. + */ + dev_warn(dev, "sensor%d is not calibrated.\n", i); + continue; + } + + offset =3D (i % 2) * 16; + regmap_update_bits(tmdev->regmap, + SUN50I_H6_THS_TEMP_CALIB + (i / 2 * 4), + TEMP_CALIB_MASK << offset, + cdata << offset); + } + + return 0; +} + static int sun8i_ths_calibrate(struct ths_device *tmdev) { struct nvmem_cell *calcell =3D NULL; @@ -719,6 +839,31 @@ static const struct ths_thermal_chip sun50i_h616_ths = =3D { .calc_temp =3D sun8i_ths_calc_temp, }; =20 +/* The A523 has a shared reset line for both chips */ +static const struct ths_thermal_chip sun55i_a523_ths0 =3D { + .sensor_num =3D 1, + .has_bus_clk_reset =3D true, + .has_mod_clk =3D true, + .ft_deviation =3D 5000, + .temp_data_base =3D SUN50I_H6_THS_TEMP_DATA, + .calibrate =3D sun55i_a523_ths_calibrate, + .init =3D sun50i_h6_thermal_init, + .irq_ack =3D sun50i_h6_irq_ack, + .calc_temp =3D sun55i_a523_calc_temp, +}; + +static const struct ths_thermal_chip sun55i_a523_ths1 =3D { + .sensor_num =3D 4, + .has_bus_clk_reset =3D true, + .has_mod_clk =3D true, + .ft_deviation =3D 5000, + .temp_data_base =3D SUN50I_H6_THS_TEMP_DATA, + .calibrate =3D sun55i_a523_ths_calibrate, + .init =3D sun50i_h6_thermal_init, + .irq_ack =3D sun50i_h6_irq_ack, + .calc_temp =3D sun55i_a523_calc_temp, +}; + static const struct of_device_id of_ths_match[] =3D { { .compatible =3D "allwinner,sun8i-a83t-ths", .data =3D &sun8i_a83t_ths }, { .compatible =3D "allwinner,sun8i-h3-ths", .data =3D &sun8i_h3_ths }, @@ -729,6 +874,8 @@ static const struct of_device_id of_ths_match[] =3D { { .compatible =3D "allwinner,sun50i-h6-ths", .data =3D &sun50i_h6_ths }, { .compatible =3D "allwinner,sun20i-d1-ths", .data =3D &sun20i_d1_ths }, { .compatible =3D "allwinner,sun50i-h616-ths", .data =3D &sun50i_h616_ths= }, + { .compatible =3D "allwinner,sun55i-a523-ths0", .data =3D &sun55i_a523_th= s0 }, + { .compatible =3D "allwinner,sun55i-a523-ths1", .data =3D &sun55i_a523_th= s1 }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, of_ths_match); --=20 2.55.0 From nobody Fri Sep 25 11:05:06 2026 Received: from mail-pz2-f12.google.com (mail-pz2-f12.google.com [74.125.228.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCAD3331EC0 for ; Sun, 13 Sep 2026 14:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311429; cv=none; b=u/23FsyHFysGvqyefqjnLERQEeRhBYJCnVVi263+DKQBLFQhBIRC/uiVAH/vnXB2peBvuWuvBDZH3IBLN+dGf/rs70uSCuwuYiaLZZRW48FPUU64Jy/K3r4Uc39IDdYPAtiGcYQIYp38rDPDaOuTiyShL9TTm/hXgUzd6EKOchg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789311429; c=relaxed/simple; bh=U8TcarFOSxPgPS3gl1vJEnVGMW4O7dlmLEDGi+5O5hE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ihjq+fUantCY4phcT1iQh/IGh7KbysvdrOeItyJVuHKCIr8xfwi4mT1CdmI5ZTCJJuR1OOH/QLrdS1mtershMqfsPGKXcGRZLspAYam7Y2ZqnHBR9oExmH12uDGgFp7BhMF8MATGF2I4mJNIBbikHigG18KhJP8fXS9uzpkJNWQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AEfLhEb1; arc=none smtp.client-ip=74.125.228.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AEfLhEb1" Received: by mail-pz2-f12.google.com with SMTP id 41be03b00d2f7-cc4aa0f1766so804995a12.0 for ; Sun, 13 Sep 2026 07:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789311426; x=1789916226; darn=vger.kernel.org; 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:content-type; bh=Ojm3inVGHkUK0yBRj0L32h8BiK2OtTXiQ8B+T74NBtE=; b=AEfLhEb11jba8BEBJ0eQLfnmkrhwaXaKs8cRlDEmc0TbBYl+AJLg1C3zFB86Y2V37m UYH6SYLqsgUoDiDKFgKjL2bpEiZP/mRwBcZhdITc12HR/4BLCOz2rh66csm4fXwnhPym sZq30PdzbV9ll5m8F11HpFMVsRm7GcZolm7sizA1O2Wc2A1vH55m2/FXyhaMOTXzVWNO R/z/82MH4sgRPRyWgGtfF7wsPNXHkwbUpKIt0a+Ih3D6mfUwrb3WlAr8grUt0Rz1+II3 dx7JZftfKT8aMq6QA4y1Wh2GzG3cEEbmvrivpkqutpwgWmUBmoI1PYYFyoj3CZHltS3k m7bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789311426; x=1789916226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Ojm3inVGHkUK0yBRj0L32h8BiK2OtTXiQ8B+T74NBtE=; b=rXPX/kiZJQL1lDoXh2tlJsig8M4XI4wvrqSizg0Vi4VAEbumsoEIjDc2ZJlsbzYNTX n2avqWfAxugK7ljdSRghW2cxUuXia6w3EmXAyAPeWTQqRXC0jp642wuHE+oXMd69u5jh SFeWIqjEYWdVy2eojpi/kA0PT8PBwdtRoCH8xytk8qMVqTVLuf9yTTR4JQln+gsDSxqP gfuCUWtAzkA6f9/jxkhc7Ys9lvAvQWd9+wtMIXnkYMXEDwex8dLhXz0JJK3XvL0CNZO2 p1c0xtd+jevVm5usTDuPpPSUfQGW6QtCqSXMcSfhrIlnAhjDB50ntQjv4/kMXqJx4Qqn BJtg== X-Forwarded-Encrypted: i=1; AKwUvByRfQp0VZAdB7CIcuFCzN1Rbo4iSkRny+LxDU4S/KC6DNm+tYFFtwkfc4TeanSBWbU/fekqRf/90GQI4Bo=@vger.kernel.org X-Gm-Message-State: AFuF++ksn1wQe87Qyw0gV16cEnHEZBK/sb46tNAvhfG6+V9gQyMvNFl2 qwAN8k+f9RlCiaZifD8F8isjE3lH3YoL6CS0G+E4jr3T4SCCjbJwz3SE X-Gm-Gg: AYBFou2RlUlhNAo//5FGeYNfSCltpKiQ7Oed14JOkB7jFIbToApxOF5cxKhK70X4wy0 fyrReQHon8Zug5sPn0KKeZzzpQoePBdk/K2tCbFBVgzHhus+iz5fhgc6NfRZ7tGIhAgsyWImFjP jU2Tld4rjUlGqoH8l/zoQFyMuXmdgPknB8KRztVSXKLw/hwMWDdQbFcDXChOm4qZ+Ex1P0Cuj2V 5Dq53oYUpxq5O4t7E04Ypo1TNTlEe3gDODpSkuc+aTzF9xmUKJeMISXImh9sDAjP+DH5CJRZhsG oiOlvUU3X9FDRMfUxshqzuYdqgo58tbsdxYGSLvsXoOWDhAcej9OwDbzJP4WxcvhTJuXe6JdwPn HEHu075x6cCfnUF4dy2zzB62H6WE4nnIFq/Gj/PEMgHjIXHoUiKBEMwvHSfs1xsn9+tnQhl9D91 EfrXU0XHz4ShnSaG0fXcMFP9VHZeYJPF2SwM6athyo78xTyaYepz5PPwhJMsWXd6Ng X-Received: by 2002:a05:6300:83:b0:3da:755f:a031 with SMTP id adf61e73a8af0-3db0e1440cdmr14771539637.12.1789311426035; Sun, 13 Sep 2026 07:57:06 -0700 (PDT) Received: from archlinux ([207.90.239.231]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33ba7a9bb56sm21467366eec.31.2026.09.13.07.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 07:57:05 -0700 (PDT) From: Mikhail Kalashnikov To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Philipp Zabel , =?UTF-8?q?Juan=20Manuel=20L=C3=B3pez=20Carrillo?= , Andre Przywara Subject: [PATCH v6 5/5] arm64: dts: allwinner: sun55i: add thermal sensors Date: Sun, 13 Sep 2026 22:55:27 +0800 Message-ID: <20260913145527.18148-6-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145527.18148-1-iuncuim@gmail.com> References: <20260913145527.18148-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mikhail Kalashnikov The A523 processor has two temperature controllers, THS0 and THS1. THS0 has only one temperature sensor, which is located in the DRAM controller. THS1 does have 4 sensors: ths1_0 - "big" cores ths1_1 - "little" cores ths1_2 - gpu ths1_3 - npu Add the thermal sensor configuration and the thermal zones. Trips temperature, polling-delay and sustainable-power parameters are derived from the manufacturer's BSP. Signed-off-by: Mikhail Kalashnikov --- .../arm64/boot/dts/allwinner/sun55i-a523.dtsi | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi b/arch/arm64/bo= ot/dts/allwinner/sun55i-a523.dtsi index 85ef492ff..ced544154 100644 --- a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi @@ -11,6 +11,7 @@ #include #include #include +#include =20 / { interrupt-parent =3D <&gic>; @@ -26,6 +27,7 @@ cpu0: cpu@0 { device_type =3D "cpu"; reg =3D <0x000>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; =20 cpu1: cpu@100 { @@ -33,6 +35,7 @@ cpu1: cpu@100 { device_type =3D "cpu"; reg =3D <0x100>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; =20 cpu2: cpu@200 { @@ -40,6 +43,7 @@ cpu2: cpu@200 { device_type =3D "cpu"; reg =3D <0x200>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; =20 cpu3: cpu@300 { @@ -47,6 +51,7 @@ cpu3: cpu@300 { device_type =3D "cpu"; reg =3D <0x300>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; =20 cpu4: cpu@400 { @@ -54,6 +59,7 @@ cpu4: cpu@400 { device_type =3D "cpu"; reg =3D <0x400>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; =20 cpu5: cpu@500 { @@ -61,6 +67,7 @@ cpu5: cpu@500 { device_type =3D "cpu"; reg =3D <0x500>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; =20 cpu6: cpu@600 { @@ -68,6 +75,7 @@ cpu6: cpu@600 { device_type =3D "cpu"; reg =3D <0x600>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; =20 cpu7: cpu@700 { @@ -75,6 +83,7 @@ cpu7: cpu@700 { device_type =3D "cpu"; reg =3D <0x700>; enable-method =3D "psci"; + #cooling-cells =3D <2>; }; }; =20 @@ -380,6 +389,30 @@ gpadc: adc@2009000 { status =3D "disabled"; }; =20 + ths1: thermal-sensor@2009400 { + compatible =3D "allwinner,sun55i-a523-ths1"; + reg =3D <0x02009400 0x400>; + interrupts =3D ; + clocks =3D <&ccu CLK_BUS_THS>, <&ccu CLK_GPADC1>; + clock-names =3D "bus", "mod"; + resets =3D <&ccu RST_BUS_THS>; + nvmem-cells =3D <&ths_calibration0>, <&ths_calibration1>; + nvmem-cell-names =3D "calibration", "calibration-second-part"; + #thermal-sensor-cells =3D <1>; + }; + + ths0: thermal-sensor@200a000 { + compatible =3D "allwinner,sun55i-a523-ths0"; + reg =3D <0x0200a000 0x400>; + interrupts =3D ; + clocks =3D <&ccu CLK_BUS_THS>, <&ccu CLK_GPADC0>; + clock-names =3D "bus", "mod"; + resets =3D <&ccu RST_BUS_THS>; + nvmem-cells =3D <&ths_calibration0>, <&ths_calibration1>; + nvmem-cell-names =3D "calibration", "calibration-second-part"; + #thermal-sensor-cells =3D <0>; + }; + wdt: watchdog@2050000 { compatible =3D "allwinner,sun55i-a523-wdt"; reg =3D <0x2050000 0x20>; @@ -611,6 +644,14 @@ sid: efuse@3006000 { reg =3D <0x03006000 0x1000>; #address-cells =3D <1>; #size-cells =3D <1>; + + ths_calibration0: ths-calibration0@38 { + reg =3D <0x38 0x8>; + }; + + ths_calibration1: ths-calibration1@44 { + reg =3D <0x44 0x8>; + }; }; =20 gic: interrupt-controller@3400000 { @@ -1145,4 +1186,135 @@ npu: npu@7122000 { power-domains =3D <&ppu PD_NPU>; }; }; + + thermal-zones { + cpu0-thermal { + polling-delay-passive =3D <100>; + polling-delay =3D <1000>; + thermal-sensors =3D <&ths1 1>; + sustainable-power =3D <1200>; + + trips { + cpu-trip-0 { + temperature =3D <70000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + cpu0_target: cpu-trip-1 { + temperature =3D <90000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + cpu-trip-2 { + temperature =3D <110000>; + type =3D "critical"; + hysteresis =3D <0>; + }; + }; + + cooling-maps { + map0 { + trip =3D <&cpu0_target>; + cooling-device =3D <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu4-thermal { + polling-delay-passive =3D <100>; + polling-delay =3D <1000>; + thermal-sensors =3D <&ths1 0>; + sustainable-power =3D <1600>; + + trips { + cpu-trip-0 { + temperature =3D <70000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + cpu4_target: cpu-trip-1 { + temperature =3D <90000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + cpu-trip-2 { + temperature =3D <110000>; + type =3D "critical"; + hysteresis =3D <0>; + }; + }; + + cooling-maps { + map0 { + trip =3D <&cpu4_target>; + cooling-device =3D <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + gpu-thermal { + polling-delay-passive =3D <100>; + polling-delay =3D <1000>; + thermal-sensors =3D <&ths1 2>; + sustainable-power =3D <2400>; + + trips { + gpu-trip-0 { + temperature =3D <60000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + gpu-trip-1 { + temperature =3D <90000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + gpu-trip-2 { + temperature =3D <110000>; + type =3D "critical"; + hysteresis =3D <0>; + }; + }; + }; + + npu-thermal { + polling-delay-passive =3D <100>; + polling-delay =3D <1000>; + thermal-sensors =3D <&ths1 3>; + + trips { + npu-trip-0 { + temperature =3D <110000>; + type =3D "critical"; + hysteresis =3D <0>; + }; + }; + }; + + ddr-thermal { + polling-delay-passive =3D <0>; + polling-delay =3D <0>; + thermal-sensors =3D <&ths0>; + + trips { + ddr-trip-0 { + temperature =3D <110000>; + type =3D "critical"; + hysteresis =3D <0>; + }; + }; + }; + }; }; --=20 2.55.0