From nobody Sat Jul 4 19:59:45 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 706C5372ED7 for ; Sat, 4 Jul 2026 17:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185299; cv=none; b=rSicSatDGHYeeZDEOVsvIDuII3ahtCRqIJ6QyLYb3AOnJr0icQqqZ3nHogUM9Wjx/wbRLJcf+bXTxkjvw0/2E+BBlYJXO/PmVWEbu/CSZINyNzRx46FsP+aOyPHqOYZadyhnLgaX3uQDovkMtbvS/EWuUDpqiNGrv8ofo3Duqaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185299; c=relaxed/simple; bh=NNneVdy0HhxnlGFqTwE8omGAtOyN6+sEw6Qa8xG+YSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HPLKpzPakWUkb8v0ZXzZKi51KC4BG8A3k57zH6cbqA/o+CkUYTxqqW1Sk4ATaOCGersPfAg+x+MtIlW6gXXMZEKaVqR64V+cPB/CriUyxTXcjKVlocFKZBRxSZhBXgv63s/crGuv6/jZSWjOc5wGELdI1FG/jxt1xVirSeLcGOU= 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=cbfJ0Jxz; arc=none smtp.client-ip=209.85.210.181 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="cbfJ0Jxz" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-847a52edeb2so1185573b3a.0 for ; Sat, 04 Jul 2026 10:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783185298; x=1783790098; 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; bh=k6kKI5J8Ttv5I5yUn+NLV5sWRapXSwcPAxycZh/dkxc=; b=cbfJ0JxznZueHu7afssZnib+ma3xmpWl9ynuEYQPl2wTJfq3N6TKcSIPPQFaMr2mMW 83b7uvAiVUJUirC4A/YI7y3jAYLid340UzF4ic04/gJf1jLccjjri+bGyg/nc8BsmXB3 Pzbx01yC+hCt5FdDy9pFvBVFaGEc+3PAG7pmn0odc3Yq7YSsusjIY1nWxt7TVNvu04fC PjFnu2QVhklOM4LPjGmIQdnVHg3Ai3TFXpCnD0r1/2DRYRkZHv1YisSNTxLP+ffmqLLS Y62pbXu+LO/IfCbZgkAzQ7CpipNODBPPb/OPlCTc7d0X+FoHuxQM45JJEaesuQ2Ob0GK bPZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783185298; x=1783790098; 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; bh=k6kKI5J8Ttv5I5yUn+NLV5sWRapXSwcPAxycZh/dkxc=; b=V4cQGOMAtYQ1DcGnYmP8CU1dqTxwg8p8koEhl0nYoqZvY8/qmGipRj0xEbStGc/8II mb/EYRNyc5lN3WUrC8Z2NVIGk5AOh3/oUB368u7yAaUI3RpGBI7R8GasqDGakRPZxEZk XEXt7x9RFhMK9X+vUoqaOxiWLJqBzZJU3GjxV5DXP/wOniCzo0mSmO8j9Q9fKvdl2BgF J0wXG8pDJQUsz1lnq2GH5pvKL13a77akxZTByJLSR1bSZy2aPa/8H7fEyL8S+J5HWyeu Bv0ugRNZvd0Fb5eHYGSx2Hv1/atyeLLfpneWv8YIolWVEHkc//Sf9yZsnoZ/hdV3PfZt iI3A== X-Forwarded-Encrypted: i=1; AFNElJ/uOVzwiRKLtHlG9PBiwyIsUvRBbmpQHzdaX6NqQ9rQnjRdzVtxS5/3qjH733N/vkK8LuyGz96LS7eL/Ps=@vger.kernel.org X-Gm-Message-State: AOJu0YyBa2pYLkiXyg5QTkluYd1wFcxjoCfKStMdaDzmgjoE4nDy+1OV QNxX6dUWSfLTMgVFikGjZBkF1Gkt8Dbf/QSq82o0pdLjKeazX+hFGRy2 X-Gm-Gg: AfdE7cnB1MtnEMGZWKzAH8YI/zPWhoAQ/+UyivltSZ1YmwsiisQirWD63T7g7jvkYIo LTpjVXNlJ08MkJdnfrNhZ2MVtBDy/kkmSap34slNr2rgzr3Rah4lmztxJ1uWHXe5WOpBHsun5WA CmpWAygGxEeg5H54Q+Pjeq0tZJK2rb+qhNIoWIQcYUyzzpsutnB0A6bqaOWPShqeuf09dXHFHED X1JyhQf6i3E5IObkg79pOZLRAxNnTv9KVKWoqRWMteqf1M123wZKyTwpHqtaLVgD3fG7X7CLNMz sCuKY2mF+7dt3k82y2gvjvZ2yAWxItA8Qp4owHGl8tMaF0De6snsDjvm0X6GyerlNH3WsfTa1j3 JIqbliTgcW8hg4lp7Hh32My+xkhUO3MhFp5Pm6WFNnPJTyMP6TBrP+EWqbq0uu0ACZBgEAUcO4f ddpMJ9 X-Received: by 2002:a05:6a00:4f92:b0:842:2ddb:e305 with SMTP id d2e1a72fcca58-847f6f69949mr3837076b3a.43.1783185297621; Sat, 04 Jul 2026 10:14:57 -0700 (PDT) Received: from archlinux ([212.192.12.80]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6d498adsm1379101b3a.32.2026.07.04.10.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2026 10:14:56 -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 , Philipp Zabel 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 Subject: [PATCH v5 1/5] dt-bindings: thermal: sun8i: Add A523 THS0/1 controllers Date: Sun, 5 Jul 2026 01:14:07 +0800 Message-ID: <20260704171411.1413349-2-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260704171411.1413349-1-iuncuim@gmail.com> References: <20260704171411.1413349-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" Add dt-bindings description of the thermal sensors in the A523 processor. The controllers require activation of the additional frequency of the associated gpadc controller, so a mod clock property required. 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 | 54 +++++++++++++++++-- 1 file changed, 51 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..6f5b2f3b9 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,29 @@ allOf: - clock-names - resets =20 + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun55i-a523-ths0 + - allwinner,sun55i-a523-ths1 + then: + properties: + clocks: + minItems: 2 + nvmem-cells: + minItems: 2 + nvmem-cell-names: + minItems: 2 + else: + properties: + nvmem-cells: + maxItems: 1 + nvmem-cell-names: + items: + - const: calibration + required: - compatible - reg @@ -176,4 +207,21 @@ examples: #thermal-sensor-cells =3D <1>; }; =20 + - | + #include + #include + #include + + 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>; + }; ... --=20 2.55.0 From nobody Sat Jul 4 19:59:45 2026 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 16F27374E4C for ; Sat, 4 Jul 2026 17:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185317; cv=none; b=puO3e8g0PMMimZQn7RUqYNYmBt+RtTRq3dyorjXYaDZqnS/V57oHKQYEE7KRKCzr4deMUEV3CNxeGa2SasozwM0wXsmX9Xcm1rM7vqHP4BzSUD/zlj8eH3WnFHv9smFCMUHd55vG4KdKBFj+Eh/ZMDTsMUFDGBhNvN4SOCxiUa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185317; c=relaxed/simple; bh=hiDqfxEwo2m08vVR+XmTBBNvFPcoR44JVTQtfXJLBKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LHxqCF6FXQFyK/L+rol0ivuG1eBwPYR/n8bU9QZMc26EUeeQKuV8JoJZ9TtlcCNT53SDZsVD3ZxMZJcpHvS189MPQ0eq37aPgrxmtMAy6y48HAkHXbGvaDs4pcpxQxxjn5g5GphYgFhXp+XCcPqJ0Rc1SYz/YeokSa8m+OCy9hA= 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=pzAyaGoY; arc=none smtp.client-ip=209.85.210.173 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="pzAyaGoY" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-84347ad88edso2279306b3a.1 for ; Sat, 04 Jul 2026 10:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783185315; x=1783790115; 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; bh=baNPOtnreWkoR3AhhTVFf+uOWjoLtova69oE/tcCCJk=; b=pzAyaGoYVxV9mic82r2ywwZ8C1KB2oxpJZosNFQzBJuOjkSymmYiQbs/N7ZMyB7gP5 bHGFfFHvHj8Dobn1e/QP2wEsuhr7D+zhU3UI/JySUPVJOfBsfU1wkQ6Xzd7QoGaGBgbK YicXQPiZvfOg4su8i46vB9EtWUvZcFemGnFg9B6iWgMTsgZ9BDlTimpdHH0+ia+GJazn eu0SxEI1jeVWuC1RPyibEl6+M91bas8Mc2gJyCpXN39NyU7ZiRa1LOgI9USsqk/xK0eV 5f2JtlgWRKznGvmFicbFe+EwvhUyqH45HEc2l4gT6klnFTNvrCJqYkHUVHfFSiQXN0Xo KOkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783185315; x=1783790115; 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; bh=baNPOtnreWkoR3AhhTVFf+uOWjoLtova69oE/tcCCJk=; b=HmTgexw8OMfO3P6/QNBMYwlQs1i6NfEYnA1LYw8Kb1Uv+6PRDKbxQ0VGSzF3c3MD9C EarDihkk3bA79ZvF8ODM4liBgmoRZy6XDheI9vMjc1d8OkP7mpqy6ZnUjesTiZm6YUit Qol4a+Hmo2UjgSj+OwP/HJyy1NlZD0teXtJd9M4JNvrIbLVKi6sN7lZbbcp/JnJPYKwa DiRFV2mJRu6ZIvpLj0HWOWJUVun7rionKQtv09grXp99+BoM14QPHZym87Fh8+ZPSw8E XOufnEph+1w280dGdSgMbzrdI5McKr8m8ccPCIK/7TgN9Dlo1EF6jGNegekX2oIbnYIp /9hw== X-Forwarded-Encrypted: i=1; AHgh+RqsZLBxLRNe4jj/exOsxSU8fqF7XshEPwYgmhnfoj2gkBX93jBdQCULaVTzL6OA8tiRkY5f9xey4+AWHOU=@vger.kernel.org X-Gm-Message-State: AOJu0YxbKpEDRiGaxbBPzgzynsai13Ocs42mi3se0VwJyRFzKcxRNQPK 4viqhPjgSGCKnDWZEk9k0fFda8EJq3P5AAUYkzfH6Yn910eCx7JjDkRT X-Gm-Gg: AfdE7ckIKeaNUqYlho6oKNltE0nrBSK3kDuT/f89UfiAU/WznfxkNmmj8zqJH4rUw3D H+WKZ9EB/rE0ffOsOS+V21YVQPcfBk7qZKkTLoPKYGEkO+gVGp4SkNXn/IzaNDquFIBnkEKdWdb vYbJtWotkRnCcB2kCh3pk3Vc+IDT+XL6V8KubTUe5QAYA+YdPdq16x0gZlVaT1RdSB9FwJtZUph 3BXaqKHPe5qmy48ziTZofiEJ6MVRK3oAdfSi+hrvSuuxxEx8+W5BGx1WrJn6KW+1RwHSnK5z9s+ IIJVZ9OnJ6tXliD8dQiWz+2xAlR+J+W/f8NZ3HEjDwyYVPfxwqD+qTFliknKZ3hskcOxj+jb6sd sVhqzhTZXfV/dfEdZNHhMdLfkEerIum3QoF1eBIq0ucDzvWxNUU04OLuU4BkXFi2pEaJ5TON8Ur Vu19ME X-Received: by 2002:a05:6a00:1c86:b0:82f:9407:d167 with SMTP id d2e1a72fcca58-847f6ee42c4mr3927100b3a.38.1783185315280; Sat, 04 Jul 2026 10:15:15 -0700 (PDT) Received: from archlinux ([212.192.12.80]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6d498adsm1379101b3a.32.2026.07.04.10.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2026 10:15:14 -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 , Philipp Zabel 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 Subject: [PATCH v5 2/5] thermal/drivers/sun8i: replace devm_reset_control_get to devm_reset_control_get_shared_deasserted Date: Sun, 5 Jul 2026 01:14:08 +0800 Message-ID: <20260704171411.1413349-3-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260704171411.1413349-1-iuncuim@gmail.com> References: <20260704171411.1413349-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" 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 --- 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 226747906..df0c26970 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -342,11 +342,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; @@ -389,19 +384,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 Sat Jul 4 19:59:45 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 E4B12348C4C for ; Sat, 4 Jul 2026 17:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185338; cv=none; b=u2YflAgWeupOMXj4J2sFUmvNkyCWluj2/VBT+h4rXhEVxT4H8+9f5WyGg4CSEpeZeIpNaxbmBbl5OtzcD9LzOk7bqK11Z4wFtfNRbE6AMIOA8n79X5ZEd33K/v9z/sWtZ8ytcjmaeLxhFGfZxN7VVy9hUHhQtVEtryaONpldpeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185338; c=relaxed/simple; bh=NL0+DczK+bX7h5aeTAoVt3cN5b8jI07kISjmFCzG0dY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YMHMOeRQA4UlkhvvMWDqTgGC4ULIvJmaZ1Ake26o9kR385jKuOxaq2CMZjnJ89sHlGgrSCyCDH8aVE62QusB+a36ylSHUv/OvUexW2Gkkp+j8KUppom0mk/r0fDK5ysRxYOcq2EeODPA4jnFNycpElDDHZ8y8sq5zPCzyZ0lX4g= 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=Ka/d2E4n; arc=none smtp.client-ip=209.85.210.175 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="Ka/d2E4n" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-847d1e9db22so1820708b3a.2 for ; Sat, 04 Jul 2026 10:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783185336; x=1783790136; 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; bh=JsQaU9uZZtvn5+lIZrSejmQfTd4zI1y5dE5Iy0qO9rc=; b=Ka/d2E4ndWwH8xyqTyI3x5s9987AxA5ijuEEJxZuXre0Yt6r16Xx1prOxtBvYZTYyT E4lUUIPox88dz8qz7VOis23Ulrb0HqHl6S00YSwAxrcvuw6Yv30hMjPTCn1xQ4uQtl6h yWfP+xDkqPC/UFGWXuSnpM935LFKS6c6n23oOTnRY8/Ah0CQIOKwdwFePxAClT7cmC60 vZIFJrOOqy7ezC+7aq9fMuRPP5iUPSAE09kV2ZrcxWouLh32BqqcInkQflFRRqcVd87I 2KhYdO4UA8vvilOIvCk1dnIOIOR/h+H/CKvmiDsfpw7bgbLxIyWiPHpxmjuY95P2rOgT dqQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783185336; x=1783790136; 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; bh=JsQaU9uZZtvn5+lIZrSejmQfTd4zI1y5dE5Iy0qO9rc=; b=qTmMAUImwMWtDKUi9fwcKsQaFA5XC8iaMgbxcfXS8pWwxI5H2iy1vB98ov6IplYVaH AwAxp34zGzEz93eDUXP8c0I8NqrPaGSFikFY3R8BIpgGpyM7LzVH80nqTEQwac7q9ve1 GoGUFSXUSzMWTjA6NtVnFJfrHGLYoRi1DNV/U7p8LDqRn1AMPojIQ+pqPeE6jcYTV21n M25ChqI07kQqAmmAYl98dvyaV/C063PP+KO6+t5/FvGjd2EKAvcwI4Fq0Tf8RpTW0G67 Qxjzl0ykw+9oBisYtoZchwiQqPfFHlxz/TsC36AMbAb/xbDJD3bB0RUm29I1SY9DLgh1 beaQ== X-Forwarded-Encrypted: i=1; AFNElJ9HATLk0lIIIj5IuNi38QnWNMUDcLLmPLX++kOXLlZIw2QMG7f/zr+ZwQxYwyVAFJx9qM2fntSW1YLY518=@vger.kernel.org X-Gm-Message-State: AOJu0YxfxZIbkWbrNMHHEQRHv0svl2NVdNxLk7vTjDwlY2gawGcFl596 pbvUVIHxLwIZiF2RMrPZkCXZudYOVBsEyvBqLJG0QkxHoSxzgxUAVCtc X-Gm-Gg: AfdE7cmHthSUmHR94GTVQGtob9mW7iNR4OcGvc8B0SREUdlf5LAUhMpspj9ZH05vYED Vp3gVOCfT4bHk3EJN9vGdw2RUkH6BU9tFePI+TajfBXiSYqBbv/wP4zSGlizvQ0gfTkTq7Bm9z4 fXFMDvl3WSbcu1V9yuK2XEiCJMi8cSAl1YABVJgqa4ESv6439B7VQ4pHbS1u89NLSJzoCv/Yv3j glovEv4N+8xPccQ4dCjzBmAM1jLmyz9xK/L4wwesaaLLWFHO597kHv26qFkGyjteWGVi24wMN10 OWynVkwO/UmwUs/RZzzaTgjH4GtEyH/3yKAKNN+MY5uoHvS4To0cXPSTWH/e7r+pfOlk2ixMUVZ hKdBvWl2xMmTItqBjO1lZFDDfLuQNjhYHLfb8oYmLyNBH5HbE0iAdJrbog+tyXgjVyFCBttX4+u WKW7qq X-Received: by 2002:a05:6a00:3305:b0:847:902a:57c1 with SMTP id d2e1a72fcca58-847f6f84d6fmr4092931b3a.57.1783185336159; Sat, 04 Jul 2026 10:15:36 -0700 (PDT) Received: from archlinux ([212.192.12.80]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6d498adsm1379101b3a.32.2026.07.04.10.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2026 10:15:35 -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 , Philipp Zabel 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 Subject: [PATCH v5 3/5] thermal/drivers/sun8i: get calibration data from two nvmem cells Date: Sun, 5 Jul 2026 01:14:09 +0800 Message-ID: <20260704171411.1413349-4-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260704171411.1413349-1-iuncuim@gmail.com> References: <20260704171411.1413349-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" 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 --- drivers/thermal/sun8i_thermal.c | 80 +++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_therma= l.c index df0c26970..3bdd62aa8 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -301,43 +301,65 @@ 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; + } =20 - caldata =3D nvmem_cell_read(calcell, &callen); - if (IS_ERR(caldata)) { - ret =3D PTR_ERR(caldata); - goto out; + memcpy(caldata + callen, caldatapart, len); + callen +=3D len; + kfree(caldatapart); } =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 Sat Jul 4 19:59:45 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.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 374DF374A19 for ; Sat, 4 Jul 2026 17:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185360; cv=none; b=Cwo1nTDLbjTNwUQxuIOSZ70M8k+iO1Y8rfVv+mZuzuwOMMne2jIWMYaFWw9RI5F6oG0Ct5jkc3wtc2WXsufUhFqkZLMOsp1/drTFoQG6ePGqPXYfZYwvJLAxI89MtmEQf8WmRzi2UtAfuK6uIWfWNSj7WnncX02Xd/30deGUitE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185360; c=relaxed/simple; bh=seTZIEtXtqVVYV7kSKXvd99fs7QNW1ZFwg2DmcgKEAI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bkexuWF9BcIEkvpsqUFahHLZTFBKw3UWde+RkpNmrO1OMBgkkBJEN057Uio01H70qcleLvSs45WXXXEaoEmysXrTidRmRdnxDOkiyxntBg2efkdvXOuFv3p0AK8pVUg56+cc/f034u4KaWX6Gq+BjE4PSWQma2J8itYz70PE5Gk= 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=dy+mFCHB; arc=none smtp.client-ip=209.85.210.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="dy+mFCHB" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-8423f236418so909183b3a.1 for ; Sat, 04 Jul 2026 10:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783185356; x=1783790156; 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=+gR5VfBTV21+OrP9WqQJ4BqzawxRB45whAsA2GtJSFg=; b=dy+mFCHByZyvfcVBuxwJpu3WoDvoehWfRzLu4VJ22LAGqbijV6GRFLbhwuyhXLQOg5 OMpQYFbRQmN0hRbPrh0lSQnOqSmf1Tst5SwT6PdV1XUMKlHoooCEGwiWyg+kkwXnVgMt yoOLGmI5l44pcpaV78Z1VV9tmGtnLRDakCZOBfpoKlBItA0244CGwXdLIVuSzDrzMd96 TQinnYN208bqqsRZzQXzlSOoLUJdEW5G3HWOFHO9zQEIvOLeflLcGiWiJy9BaVmYdWuz Rp6OSG82Q0cG0fYwzKkwJO/z6RHqQrkkB6dfmgvfuiCDCEZtNM2x28kVnn8ypKMFpKEn NH9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783185356; x=1783790156; 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=+gR5VfBTV21+OrP9WqQJ4BqzawxRB45whAsA2GtJSFg=; b=VmB5Ua7qtqjaP/5mMl2HF9jezsAoImyiQ20DtNR92b5HXY1pn9WDar/821wz3Sd6Ym rurkbzyZM8CNvhMU4o8iKxjf/DFhyDipJyyvuM6sfMRkrF0CgqR5sLd61i6MSaYM+LYv /ysRXdW4uRDaFbsGWkE0OL33vMW9T+7cURsDrpWwH+emJwIVi7G7I5cpZ7Py3FaQfOmF FO9mBThYZoWqjL39a1fpa57HrNe7y2/hIvGJW5yCAW3p1Jn/URbIijHLj54byuUbiW/C EXCANAUH7PXJ70TaOAlXn6vC8kDS5YQVFtNnNmLazQvbE2lPgJrpnIVdObSi/O3v5h+e 2BtA== X-Forwarded-Encrypted: i=1; AFNElJ+sPmfmV8KpeWcVPIWyZN1nLcMIZ6XU3/mvkQ1AF6DZFDA/++kgscFWuMnsTUxJWXVCW+Fugl1uQ/oGBEw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz08b2A1az5HbWPPG/59uR9w7/uWN9T+FYcfCwr3J6ICZf3Mnie bySpxSicNVJSnTl0OrIvNUlolMp9x+WYzwl3VdGrHu4Jd6Q1oKFvlUwe X-Gm-Gg: AfdE7cnuwc27zIfcUFabIYAmlfT2nSHlOCztFrpzqFNN+7mCYIo44SXZ/EHDVB7PTaw cMaFlrqS+ZCm4aRQ65vtmhZWFzEYcGrQ1y8tJJZImhwtDSf86s5kSPFLLw4Jo6Z3Xb/a36GjlLG Lwfinb6YAGfNpeMcUk/9raVuWEr1z3bbalF0ebqS6kiibuMuHoLUh1owgiLuTZYr+zyumvoYG5+ nH2ryNa/FJGcRgupk9a491QC3F8np8Q7UJMPJQRYAQ+smIlI4erOKCY0Jvt0TBI8IIw7PiGQxKG KUyuYFyvqAPxf8BH1VPdetyanDC8i1sz/yip7ObPY5P1Qby+HTC5sXoKZpZsr+nyPczWgh8nUHs O15E9t73DLi0Ij2aojBacEuPVWnz83BI+jcmAgPbnmAu6Am4rRytmsPk/Na3houoBQKjW7En3Xq k8gTONK4cJRfTbNxQ= X-Received: by 2002:a05:6a00:2394:b0:845:ec31:26cd with SMTP id d2e1a72fcca58-847f6f4fe9bmr3324398b3a.46.1783185356439; Sat, 04 Jul 2026 10:15:56 -0700 (PDT) Received: from archlinux ([212.192.12.80]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6d498adsm1379101b3a.32.2026.07.04.10.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2026 10:15:54 -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 , Philipp Zabel 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 Subject: [PATCH v5 4/5] thermal/drivers/sun8i: Add support for A523 THS0/1 controllers Date: Sun, 5 Jul 2026 01:14:10 +0800 Message-ID: <20260704171411.1413349-5-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260704171411.1413349-1-iuncuim@gmail.com> References: <20260704171411.1413349-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" 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 3 sensors: ths1_0 - "big" cores ths1_1 - "little" cores ths1_2 - gpu The datasheet mentions a fourth sensor in the NPU, but lacks any registers for operation other than calibration registers. The vendor code reads the value from ths1_2, but uses separate calibration data, so we get two different values from real one. Signed-off-by: Mikhail Kalashnikov Reviewed-by: Chen-Yu Tsai --- drivers/thermal/sun8i_thermal.c | 133 ++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_therma= l.c index 3bdd62aa8..f48ed9eae 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_ABOVE 2736 +#define SUN55I_A523_OFFSET_BELOW 2825 +#define SUN55I_A523_SCALE_ABOVE 74 +#define SUN55I_A523_SCALE_BELOW 65 + struct tsensor { struct ths_device *tmdev; struct thermal_zone_device *tzd; @@ -114,6 +120,15 @@ static int sun50i_h5_calc_temp(struct ths_device *tmde= v, return -1590 * reg / 10 + 276000; } =20 +static int sun55i_a523_calc_temp(struct ths_device *tmdev, + int id, int reg) +{ + if (reg >=3D SUN55I_A523_DELIMITER) + return SUN55I_A523_SCALE_ABOVE * (SUN55I_A523_OFFSET_ABOVE - reg); + else + return SUN55I_A523_SCALE_BELOW * (SUN55I_A523_OFFSET_BELOW - reg); +} + static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp) { struct tsensor *s =3D thermal_zone_device_priv(tz); @@ -299,6 +314,97 @@ static int sun50i_h6_ths_calibrate(struct ths_device *= tmdev, return 0; } =20 +/* + * The A523 nvmem calibration values. The ths1_3 is not used as it + * doesn't have its own sensor and doesn't have any internal switch. + * Instead, the value from the ths1_2 sensor is used, which gives the + * illusion of an independent sensor for NPU and GPU when using + * different calibration values. + * + * 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[0]) + 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_MAS= K; + } 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; + 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) + */ + cdata =3D CALIBRATE_DEFAULT - + ((sensor_temp - ft_temp) / SUN55I_A523_SCALE_ABOVE); + + 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; @@ -717,6 +823,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 3, + .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 }, @@ -727,6 +858,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 Sat Jul 4 19:59:45 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 A57A327A91D for ; Sat, 4 Jul 2026 17:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185377; cv=none; b=SRAw197+ybUmuEOhb5xjSo9WTGX06TwVh870b6HrbBGxMB5QBFSZbVH6KwxLstBs2O+lnxs3bjHBWbO+PsZZL14zi5W8jX73BgqzA8C3NHmxe6IlI+KhDkdVw+7OIQR4IhGGauzjlYWwhwW00azYMeA/6rhmhQBjhSsln1IPkIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783185377; c=relaxed/simple; bh=UwcwC3xtFbMfaEu/qElwOXnRVv0bbJHNhKNq97pt4IE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kVsG2xCz7jucw4UhcHsJGGqIkUE6C5l17WOa8QpM06qRZ7fHhks/PZdzL2ZtfwNEaczHrNRqth3M1lw81UNCoctdmpi0TBnAxMtml8t6xlYDnpB5Zzly2mlW1aosebXVE9NFLnbCbzRNw6LfM9Bahsds/SH14UwSJyUyPaMDJ6E= 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=g/n/mAic; arc=none smtp.client-ip=209.85.210.175 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="g/n/mAic" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-845e47133c9so1360643b3a.0 for ; Sat, 04 Jul 2026 10:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783185374; x=1783790174; 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; bh=d95C5AOhdaLbCgZk6LC0vYbHPRqhfdHed++OCDXOWh4=; b=g/n/mAicuzym+RdvEzrHjrqYth6pf+V/WNOH0jGYV759sZXB5PInZ7wcbUVOu9GaSa 5ASEM7+azfTzO65Tb5oTFgsOWrktOWiiaK7fKYDrF2PnlH/xUSdXjZQUGONUTffDkWEl KsYi9wN6d0Z4RE6V9A1DZSFiZvPU/i0clIMBrfZ32X33+1QqBcMHcqOZ9pV7ynLBASW/ W2GtpWOh6je+jGgHMKkWRISzsvYcEpHNL7qzYPVdYwzV/S3lKgEpDeVMGV/Q/96a2GEI ndrZCrEKmiszNJTGLQxezNBBff4wwTuaHDJoonhe+BJR0AADfeSSoKaRhQIGSa1IEqfm KotA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783185374; x=1783790174; 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; bh=d95C5AOhdaLbCgZk6LC0vYbHPRqhfdHed++OCDXOWh4=; b=AGEtSlgUSxpOfiQbWmLmpWEbgk1JG5bxPNAmE8/SCSSKZIt53tHQXbiHZuqK1DvUcf 3FesLHdjJ+EmSKvWsak4qvAxvMI8tWao1rIpGyuDa351szfRdovC1ekVg6OojcJYA1AE Xv2wuCd06uULOUQQc/czLwFycfG+mPvFrx9hCuEJ6Ztoem8iRAGIzRzQQkoIhdgZL00n +/SQUQNzJnxWJwqPXk+w/2Yhe9Rby2EyJm5u2vVn5MF2KEUjE6xpUBSYlxAMAczhLlpW ZicU3XWUr+9Yp5LocVWix3LIt+FFTiEBPnk7/QSD7f1O0S3EVsHvYDEcXaAZxomBa2z/ m2GA== X-Forwarded-Encrypted: i=1; AFNElJ9LZr0X4ssG42yHS1WNLC/W06/gLucxalWW/QOJmbWTyBjNXVIwLx7rJjnGPlTp5RYN/zGmnPW2dpo3sac=@vger.kernel.org X-Gm-Message-State: AOJu0YzQ0Dh1peqJa8RppvEw9rK0yuT0O/74V+Rn0eOGPngzVN25bXVh 492QoyFdCm4aeqVqYChbfNuRoDnkgarNT2GCIKBWEB1bjZaCRD21k8NW X-Gm-Gg: AfdE7ckdWSU0iWYos3TkXq0BfT+jhN9sjzd/aX+sZBOZmguELiJuL7JukV+/mQLHgiu 5CqBriQjI9mAkAns7Pc0So1GaTD9di7x/dcnQAsD4vCDSc1wECmLmx0eND+0elW8Sf9aV9k+coB lDLpeTKYcJmXGKVltdjYxFqywkh5V8CXnK0vNoV+zf0pQ0X0D5AyOgLGNv0lJ/qxZ1ZyqGEJqwg J2P3OsQY9rZrQ0E5UgE/0+O2Cg24IqsCtrZcVmRu0dvZIv40UW8/ezpvxJ6FpQv2A0KE5XzyNuF 5MhyMM5MmcEdEgq0EQxaIBvFVFVMvfjw16LOtni0R8DhP4n92kmhNAosreWT3enjIzJnN2a32w1 mfBp9SsdQe7p+/B+qvOCbsRpyz4mUjX14DgRAfF5M2e96u0igyfrcZHeeiqOw/f7fqXhUQO/lGi ayhKbZ X-Received: by 2002:a05:6a21:3394:b0:3bf:aa29:1612 with SMTP id adf61e73a8af0-3c03fa43612mr3885982637.28.1783185373846; Sat, 04 Jul 2026 10:16:13 -0700 (PDT) Received: from archlinux ([212.192.12.80]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6d498adsm1379101b3a.32.2026.07.04.10.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2026 10:16:13 -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 , Philipp Zabel 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 Subject: [PATCH v5 5/5] arm64: dts: allwinner: sun55i: add thermal sensors Date: Sun, 5 Jul 2026 01:14:11 +0800 Message-ID: <20260704171411.1413349-6-iuncuim@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260704171411.1413349-1-iuncuim@gmail.com> References: <20260704171411.1413349-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" 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 3 sensors: ths1_0 - "big" cores ths1_1 - "little" cores ths1_2 - gpu 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 | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi b/arch/arm64/bo= ot/dts/allwinner/sun55i-a523.dtsi index ca6a16807..2ed00e7a7 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 @@ -355,6 +364,32 @@ 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>; @@ -586,6 +621,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 { @@ -1102,4 +1145,121 @@ npu: npu@7122000 { power-domains =3D <&ppu PD_NPU>; }; }; + + thermal-zones { + cpu0_thermal: cpu0-thermal { + polling-delay-passive =3D <100>; + polling-delay =3D <1000>; + thermal-sensors =3D <&ths1 1>; + sustainable-power =3D <1200>; + + trips { + cpu0_threshold: 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>; + }; + + cpu0_critical: 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: cpu4-thermal { + polling-delay-passive =3D <100>; + polling-delay =3D <1000>; + thermal-sensors =3D <&ths1 0>; + sustainable-power =3D <1600>; + + trips { + cpu4_threshold: 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>; + }; + + cpu4_critical: 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>; + + gpu-trips { + gpu_temp_threshold: gpu-trip-0 { + temperature =3D <60000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + gpu_temp_target: gpu-trip-1 { + temperature =3D <90000>; + type =3D "passive"; + hysteresis =3D <0>; + }; + + gpu_temp_critical: gpu-trip-2 { + 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_temp_critical: ddr-trip-0 { + temperature =3D <110000>; + type =3D "critical"; + hysteresis =3D <0>; + }; + }; + }; + }; }; --=20 2.55.0