From nobody Fri Jul 24 22:19:05 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 5D5A335202D for ; Wed, 22 Jul 2026 21:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754079; cv=none; b=KFItdQzUP5V7ZkTXRTGVHfYDTyxICu6UZ0l8fLa+09M0tYQQT5/eLT6hCEuhUcJouH9qLHsi280k/9VgTd6oOVKFtt/LzyIX8Ap+Z3EVaIFHw/NSbOOCdmfLepa3fF/9/RePjxgvlwvFsT9M2fHMlOo44fTaAtheZUvIvXI+nCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754079; c=relaxed/simple; bh=H7gc8EHhrE54TIGFPE01knw9jDcZnFRii3hzkCBNdj4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k2B73kyYNxU4RZgcv9LNobDWB+evG9tsj73PIQnKIcfRWMjECpSGA+nRLzW+trA5VS4IIzfi5Xh3oe41qDTmQhWl7sGm1XUTTCJI3fU9P0wQdXsYJrlicVByU8ltB138B7c2X++JQ7iUUuWb6B1feZqf47tW8+j+luktoeXzTvc= 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=RH8S4vZf; arc=none smtp.client-ip=209.85.221.42 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="RH8S4vZf" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-47ddf7b09aaso8568152f8f.3 for ; Wed, 22 Jul 2026 14:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784754076; x=1785358876; 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=xSx084TFnzGFnpguxyZxDPEBlEGv6khf3RChBzg4a7A=; b=RH8S4vZfb50yXjg0ty/ETibkY8ORHiSmDI+54v6XsHEn4gnCjABpKFB7BheWkuQHgI WsbxkgNhGoxbO/1gOvc0JCAmOAIY8wg/B0jsDPESfUGYOARrJNdEP2qkLLpgrlUDMarK n34jIxg1/HMXxv7ITHrI+dSk7yB7sIAw/H2dNF/NezpWUla8+OmEWHHx6hiyrX4WtRgw UxDwHZorsd5aGprtRpqy99fIxr3NrGDmKuW/hpZAZ1Fz4YX9LRrn/LnKzGXcYar1caMM zQkVeEPrH9SIk4wTtx7ewEU23Yi0XRxYJYL6IwXH5pcI2qtgSieeKeN1WTHV7WawnTi8 BgwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784754076; x=1785358876; 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=xSx084TFnzGFnpguxyZxDPEBlEGv6khf3RChBzg4a7A=; b=TqfULSgz4iK6AHozrbhdnvspbaB9HTrb6KrFxIj4MAvLUgHdtbQ6hj4VaO+0MKN28y oKnZTlwNOrinSOiezhw35z/HJv+r5RYgeGNs5dIc48dfXLW2An6YOlqf5zsMcFpwqYtw Oc8CZa0MUuA+kdsMnNeBz9XFjeCsNJnJhAGecj1YzDy8znCasGfD2YEwBiDLi2EswMA1 m1igVaauM3jJxYkxSEyUTyzEAI+fmxbo1Zp70COsExOayWGoB9NfuBp+iHGL2wUlXSev T5XHd76xvv2BZHeMjDsP6uhkewip4TN8ToHGRckaapYvCNLwBlqme0wTVh3mEV1xMNJi h3xA== X-Forwarded-Encrypted: i=1; AHgh+RoP2L2dpFlq2Whkf6tiBDiQ5Qgi08JDC0v988k8Js4bEM6b7Cjqbqoxw38GIsYjWv/qxd8JS2J5DbI3o2I=@vger.kernel.org X-Gm-Message-State: AOJu0Yxyxz0mD5Rlo/f3eTaa34q8WeENGFB5eDnvP2smvgnB3HxWmEl4 v6aMWyAwVV/B1i15KPmf3Z8fLDCb3L+il3m9Au7/N/m3a2w2ycCVdazq X-Gm-Gg: AR+sD11BDSf+YIWKCp1x3XGoImYbfBbfg3kag/SAeOmyIQ9FH6Qzgh1AZOc801GnE80 sFzOlW6Uo2Nh9c2gmbO/ek2loI5hL/BNNEtCtxMRZAI3S2Dj5vVQk0V3lNgiTdL9sQkbIC8yz43 fBKVRFOTWQNUls03XuR+8tNfsRjBfuJd3r0R0We410u2k4GcnYcsgB3XWKEt6MecCJak4S8u34Y Cdln+x0TAi2g58pySdMvk+mK79TcQusi5ebMar2D6lbMkEwtsBEWtzKPp4HC/7SFKK6GxiW4ibT 9kQruZ/qnWvZxlqBNHe94nw2tNuQRwS5lgrRKE7fdw2m4CnBgbWxZW2BlOk3dzzeE4MI222eEQ3 WZOr4dYGzVNUmi5wi/Y7GFzBZDdVo0/Re0yJ1q3NSFHVCmcK8XCcHHDcDOrvFspFYVxFZ0hTbo/ OWDeldowPfBK4HGXARcgIqBTTV X-Received: by 2002:a05:6000:4282:b0:462:ce05:c5e4 with SMTP id ffacd0b85a97d-47f8d755525mr573989f8f.37.1784754075574; Wed, 22 Jul 2026 14:01:15 -0700 (PDT) Received: from coolemuke.fritz.box ([2a00:6020:b320:1a00:c256:1463:a40b:d8c6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85c63678sm8610812f8f.29.2026.07.22.14.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 14:01:15 -0700 (PDT) From: "=?UTF-8?q?S=C3=B6ren=20Hantel?=" X-Google-Original-From: =?UTF-8?q?S=C3=B6ren=20Hantel?= To: linux-pm@vger.kernel.org Cc: Vasily Khoruzhick , Yangtao Li , "Rafael J . Wysocki" , Daniel Lezcano , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Rossak , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, =?UTF-8?q?S=C3=B6ren=20Hantel?= , Claude Fable 5 Subject: [PATCH v2 1/3] dt-bindings: thermal: sun8i: Add binding for the A80 THS controller Date: Wed, 22 Jul 2026 23:00:44 +0200 Message-ID: <20260722210046.2932498-2-fugininsane@googlemail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260722210046.2932498-1-fugininsane@googlemail.com> References: <20260722203341.2917852-1-fugininsane@googlemail.com> <20260722210046.2932498-1-fugininsane@googlemail.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 The Allwinner A80 has a thermal sensor with four channels which shares its MMIO block, bus gate, module clock and reset line with the GPADC. Register-wise it is an early version of the THS found in the A83T and later SoCs, with the THS registers starting at offset 0x40 of the shared block. Add the compatible to the sun8i THS binding. The A80 takes a bus and a module clock plus a reset line, so the existing conditionals already describe it correctly. Co-authored-by: Claude Fable 5 Signed-off-by: S=C3=B6ren Hantel --- .../devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t= -ths.yaml b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-= ths.yaml index 3e61689..718c44d 100644 --- a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.ya= ml +++ b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.ya= ml @@ -18,6 +18,7 @@ properties: - allwinner,sun8i-a83t-ths - allwinner,sun8i-h3-ths - allwinner,sun8i-r40-ths + - allwinner,sun9i-a80-ths - allwinner,sun20i-d1-ths - allwinner,sun50i-a64-ths - allwinner,sun50i-a100-ths --=20 2.43.0 From nobody Fri Jul 24 22:19:05 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 C27DE400DE8 for ; Wed, 22 Jul 2026 21:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754081; cv=none; b=feM5hhlgdT1yxwrrYb/ddgkvVVQM944DWykonU0wCp4Q7cXuUmO3ZC+brM0TRxraIYD8McwwV01GWx+NI3IqsPiuhP1kgatW4aanIL7XSKIdEhok1cof2BnBCz8uA2CWsGxxIiMeSjNDERBp8p3osQkNTMcsA9C1AytfpObFHb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754081; c=relaxed/simple; bh=QfEiZ1MBoePzf0Zzf6Vklru7ufE2oWiROW1QfAEBbtg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bpVdVpD7sFhZRhzyEKz8CByrrgoDJUm/qdKCLdqKgv3PAVq5M8VJHaZLMK7IYb1M2650JgciL939R+cLtY/dJwKVZbqDv05q5nYuwfrbNvcyf9P91U9xHDri60pDY6H7R+jest471pEKx/BetpLM+Ws6RwAsbMo5yBnCReW6bQI= 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=MnNjb+AW; arc=none smtp.client-ip=209.85.221.43 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="MnNjb+AW" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-47362928f65so11834529f8f.2 for ; Wed, 22 Jul 2026 14:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784754077; x=1785358877; 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=B4bcrjfjaOxCTjFJ1nEuge+dwYCIOai8f6MdCth28oQ=; b=MnNjb+AWcvBIhjG1V0zsmHK8/x6xkLNeT0SVIfTZinXgl57a32M601pzurqkb7znDk gSeBXD/p6Ibv1O3kSMVSPvCo7QpDv3lj2URKkjymuqv4DPr2unfRf63GotsKXBchSxGp Xo2f/BEGVICKFsvcqQbI+aj7UxgQKbJAe40wTBBluZymjyyDV1lYGKaR+50kqBA6skzG ydXse6/bFZUNTqMN5R4J6arzjTWee0Lf0Ayx10QNcpLz+zAG9iNO/y1gvi6zNoXYf64r o60jbAlnBhDd+eFzS/pexHOjhHRMXYqi2XKoPL9e6P6CML1HDLatmJNkV6xZ3zDIDBvK rLCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784754077; x=1785358877; 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=B4bcrjfjaOxCTjFJ1nEuge+dwYCIOai8f6MdCth28oQ=; b=ieqSUqah+KGk4lfyr3nNqeGOCjW1Tij5OU4ug+tQtU2bdJEA6d9/20riCz7giIFY8i pUudU7bOmMh771L4NWuP5uH7rg6JZ8XS7+/kCpWWwYlBbO9ceGQ09fztbT2n80O4ffUo aHuzIWSkZWlwWAHvecioA3plbeox2Z4Q+T2cVInGw4qsCf0PESqM+0nBSUUjh2w5ZBts YIS9ITt2OQHEsUGMbx70y53J4kPBIjPRP8sSm/9+kptNrrT1q4//x0DjieKGiwfTMXRy KPnPv5z0Q8IDPN3sD+hg/7oOqOKCs6e8LvopEqO/PLbk6W/w3ffWf547KBwJivt9q7Vx fzbw== X-Forwarded-Encrypted: i=1; AHgh+RqbmsB1A3/wuVJpHBufyWQZJY51q3m0ZwOSywYYfC35TUg816KutJvn6PTNmLovQGUa6RHTc/e+tRAIWu4=@vger.kernel.org X-Gm-Message-State: AOJu0Yzg/T9cvNvpyjKmj9nbDTDt+y0UXN1qd5nR1UKrzcZiXp5m8SqD NXhUoLa+5kMybQC42PKNdpe3P66/pelfvfz6BDHlo6mVoZzfR9ykAlAH X-Gm-Gg: AR+sD13mnCXTpkSlnirfrPtLpY/1SaS/Fq/OVLc9BPUzB5SjBl9hkuI9a2XNKta/iJx xQ4KZfIFNdRBIhjK+JFcmq8sUL17Vu1JcAfh7OA4fYuIFBcKDPKxl+eUMTu5msuTAnY8CsNXLDA 7Rfn55syIp8yMVoHNN8IHYKe81EpZ6pJri6xK/JoEYm64EnVvnI8wIjYjjX3IJsHhvlnJIcBSfG 4gqEisyQxuXuPd3VmlU10Yh6T2+BciqRWR7QiatK0L6r4nL37OSYwx+cMeCwJTjoSij9u3aOl2t gpWjPlk9bkD+ZVXQd3fwZrVij27f8GUbR0ZLYn6ZERYZFzH7ucqDwZccogorpn0/4uADfEZWX5n t8kng71KBg/WeGKBCbcUbChm/epR0GlpyGck4zEvZiFb8nwE4NCVlEHXO2uetcg+r3H0c9PqSC/ sn+hWOZ9XOwG6Ge1czZJfiAPTz X-Received: by 2002:a05:6000:4903:b0:46f:a0f1:c33f with SMTP id ffacd0b85a97d-47f8d7565a2mr481160f8f.32.1784754076687; Wed, 22 Jul 2026 14:01:16 -0700 (PDT) Received: from coolemuke.fritz.box ([2a00:6020:b320:1a00:c256:1463:a40b:d8c6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85c63678sm8610812f8f.29.2026.07.22.14.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 14:01:16 -0700 (PDT) From: "=?UTF-8?q?S=C3=B6ren=20Hantel?=" X-Google-Original-From: =?UTF-8?q?S=C3=B6ren=20Hantel?= To: linux-pm@vger.kernel.org Cc: Vasily Khoruzhick , Yangtao Li , "Rafael J . Wysocki" , Daniel Lezcano , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Rossak , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, =?UTF-8?q?S=C3=B6ren=20Hantel?= , Claude Fable 5 Subject: [PATCH v2 2/3] thermal/drivers/sun8i: Add support for the A80 THS Date: Wed, 22 Jul 2026 23:00:45 +0200 Message-ID: <20260722210046.2932498-3-fugininsane@googlemail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260722210046.2932498-1-fugininsane@googlemail.com> References: <20260722203341.2917852-1-fugininsane@googlemail.com> <20260722210046.2932498-1-fugininsane@googlemail.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 The Allwinner A80 thermal sensor is an early relative of the THS found in the A83T and later SoCs. It shares its register block, bus gate, 4 MHz module clock and reset line with the GPADC; the THS registers live at offset 0x40 of the shared block, with four data registers for the four sensors (0: big cluster, 1: DRAM, 2: GPU, 3: little cluster). Register layout, initialization values and the temperature formula (T =3D 190 - raw * 1000 / 14543, i.e. offset 190000 / scale 688 in this driver's convention) are taken from the vendor BSP kernel. The init sequence also programs the hardware alarm (~90 degC) and emergency shutdown (~105 degC) thresholds the BSP uses, since their reset defaults are undefined. Unlike on later SoCs the data-ready interrupt fires at the conversion rate (tens of kHz), and the level triggered alarm interrupt would retrigger for as long as an over-temperature condition persists, so both stay disabled and the thermal core polls the sensors; only the emergency shutdown event keeps its interrupt enabled. Since the A80 chip description has no calibrate callback, guard the callback invocation in sun8i_ths_calibrate(); the A80 SID is not yet supported by the sunxi nvmem driver anyway, so calibration data is currently unavailable and the driver falls back to the defaults, which yield plausible results (idle temperatures around 40 degC, full-load peaks in the mid 50s on a Cubieboard4). Tested on a Cubietech Cubieboard4: all four zones report load-reactive temperatures via polling. Co-authored-by: Claude Fable 5 Signed-off-by: S=C3=B6ren Hantel --- drivers/thermal/sun8i_thermal.c | 98 ++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_therma= l.c index 2267479..c906dea 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -65,8 +65,27 @@ struct tsensor { int id; }; =20 +/* + * The A80 thermal sensor shares its register block with the GPADC. + * The THS registers start at offset 0x40 within that block. + */ +#define SUN9I_THS_CTRL 0x40 +#define SUN9I_THS_IC 0x44 +#define SUN9I_THS_IS 0x48 +#define SUN9I_THS_ALARM_TH(x) (0x50 + (x) * 0x4) +#define SUN9I_THS_SHUT_TH(x) (0x60 + (x) * 0x4) +#define SUN9I_THS_MFC 0x70 +#define SUN9I_THS_TEMP_DATA 0x80 +#define SUN9I_THS_CTRL_ACQ(x) ((x) << 16) +#define SUN9I_THS_CTRL_SENSOR_EN GENMASK(3, 0) +#define SUN9I_THS_ALARM_IRQ_EN GENMASK(3, 0) +#define SUN9I_THS_SHUT_IRQ_EN GENMASK(7, 4) +#define SUN9I_THS_ALARM_IRQ_STS(x) BIT(x) +#define SUN9I_THS_SHUT_IRQ_STS(x) BIT(4 + (x)) + struct ths_thermal_chip { bool has_mod_clk; + unsigned long mod_clk_rate; bool has_bus_clk_reset; bool needs_sram; int sensor_num; @@ -307,6 +326,9 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) size_t callen; int ret =3D 0; =20 + if (!tmdev->chip->calibrate) + return 0; + calcell =3D nvmem_cell_get(dev, "calibration"); if (IS_ERR(calcell)) { if (PTR_ERR(calcell) =3D=3D -EPROBE_DEFER) @@ -413,7 +435,8 @@ static int sun8i_ths_resource_init(struct ths_device *t= mdev) return PTR_ERR(tmdev->mod_clk); } =20 - ret =3D clk_set_rate(tmdev->mod_clk, 24000000); + ret =3D clk_set_rate(tmdev->mod_clk, tmdev->chip->mod_clk_rate ?: + 24000000); if (ret) return ret; =20 @@ -596,6 +619,78 @@ static int sun8i_ths_probe(struct platform_device *pde= v) return 0; } =20 +static int sun9i_a80_thermal_init(struct ths_device *tmdev) +{ + int i; + + /* clear any pending interrupt status */ + regmap_write(tmdev->regmap, SUN9I_THS_IS, 0xfff); + /* set up the median filter, average over 8 samples */ + regmap_write(tmdev->regmap, SUN9I_THS_MFC, 0x5); + + /* + * Program the protection thresholds with the values the vendor + * BSP uses (thresholds are in raw sensor units, which decrease + * with rising temperature): an alarm interrupt at ~90 degC and + * an emergency hardware shutdown at ~105 degC. + */ + for (i =3D 0; i < tmdev->chip->sensor_num; i++) { + regmap_write(tmdev->regmap, SUN9I_THS_ALARM_TH(i), + (1454 << 16) | 0xfff); + regmap_write(tmdev->regmap, SUN9I_THS_SHUT_TH(i), + (1231 << 16) | 0xfff); + } + + /* + * Unlike on later SoCs, the data-ready interrupt fires at the + * conversion rate (tens of kHz), and the level triggered alarm + * interrupt would retrigger for as long as the over-temperature + * condition persists. Leave both disabled and let the thermal + * core poll the data registers; only the emergency shutdown + * interrupt stays enabled, as by the time it fires the hardware + * is powering off anyway. + */ + regmap_write(tmdev->regmap, SUN9I_THS_IC, SUN9I_THS_SHUT_IRQ_EN); + /* acquire time 0x2f, enable all four sensors */ + regmap_write(tmdev->regmap, SUN9I_THS_CTRL, + SUN9I_THS_CTRL_ACQ(0x2f) | SUN9I_THS_CTRL_SENSOR_EN); + + return 0; +} + +static unsigned long sun9i_a80_irq_ack(struct ths_device *tmdev) +{ + unsigned long irq_bitmap =3D 0; + int i, state; + + regmap_read(tmdev->regmap, SUN9I_THS_IS, &state); + + for (i =3D 0; i < MAX_SENSOR_NUM; i++) { + if (state & (SUN9I_THS_ALARM_IRQ_STS(i) | + SUN9I_THS_SHUT_IRQ_STS(i))) { + regmap_write(tmdev->regmap, SUN9I_THS_IS, + state & (SUN9I_THS_ALARM_IRQ_STS(i) | + SUN9I_THS_SHUT_IRQ_STS(i))); + set_bit(i, &irq_bitmap); + } + } + + return irq_bitmap; +} + +static const struct ths_thermal_chip sun9i_a80_ths =3D { + .sensor_num =3D 4, + .has_mod_clk =3D true, + .mod_clk_rate =3D 4000000, + .has_bus_clk_reset =3D true, + .scale =3D 688, + .offset =3D 190000, + .temp_data_base =3D SUN9I_THS_TEMP_DATA, + .init =3D sun9i_a80_thermal_init, + .irq_ack =3D sun9i_a80_irq_ack, + .calc_temp =3D sun8i_ths_calc_temp, +}; + static const struct ths_thermal_chip sun8i_a83t_ths =3D { .sensor_num =3D 3, .scale =3D 705, @@ -711,6 +806,7 @@ static const struct ths_thermal_chip sun50i_h616_ths = =3D { =20 static const struct of_device_id of_ths_match[] =3D { { .compatible =3D "allwinner,sun8i-a83t-ths", .data =3D &sun8i_a83t_ths }, + { .compatible =3D "allwinner,sun9i-a80-ths", .data =3D &sun9i_a80_ths }, { .compatible =3D "allwinner,sun8i-h3-ths", .data =3D &sun8i_h3_ths }, { .compatible =3D "allwinner,sun8i-r40-ths", .data =3D &sun8i_r40_ths }, { .compatible =3D "allwinner,sun50i-a64-ths", .data =3D &sun50i_a64_ths }, --=20 2.43.0 From nobody Fri Jul 24 22:19:05 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 BD70A4399E9 for ; Wed, 22 Jul 2026 21:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754081; cv=none; b=i5gRu2R6/uSZbtX3CD8HrMkyNT6Ui5NFL70CREdZf0fCQ8qMyK/NqWOHx+irVt8nn6tPg0VtJNnr7AkK/j+PLO8W7bN5oRJ4uhd4MIuLg1BIjVp1pjfPXifiH1DfBR06G9mFYDRtJTdSmCjoQFjCsXGziT39Vbvbf7FxDzZNTxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754081; c=relaxed/simple; bh=6esLaWMxVzWgBgD3LBUpQLC+g+cCbkEItwcvYGe7Tc8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C2ExdW9j5XX9uBMtV+MM3BkyE75Ugu7VK7GqxUN0tyTdFxOcgtD8V/pfE91fmQwAcwWRP2IwRXeHzo4/zo2sPisNqzZrQAgB48Q67uf8hecjCLPBDOV/OW4wSTX0++HVhRqq0cMqoTNEWCFlIXFk5Cju8ouQ6UjxbFw7B4iZzK8= 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=R8gjKHif; arc=none smtp.client-ip=209.85.221.48 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="R8gjKHif" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-4728c12ba97so6802083f8f.0 for ; Wed, 22 Jul 2026 14:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784754078; x=1785358878; 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=WOd+XZss+YRv1olA4v5j/GA2GS28MPr0U93YAb8IAO0=; b=R8gjKHiflKoKhfDdkGvyt9M9SfD6jEqxmIiv8g4tECiLkBGxA9z9MbUT2i8OCYOZOE V/AhWFyWnpHHbrupmMD76FvO1sXgJ1X5Y3knlZeBL2VYBnd7IAXy798BNjAmlC3HHhel /+Qk39EVKnGU+gGkqeXKISaO+CsMYIVJRYLwTk5xYmYsYQYVcsvQmR4FKgy78y4A7RxH Sed6e3Hd5p65drijOOinFF6mHoaNca4ffl7zr6eJ1t262weSJG8qbd+d/bgPfOApMEMH GJ5GvAAFnydk5aY81heivqiwmh0j4SS1WIgPCCL1dWibalfzl6Uk/9VPSGCBWAqRvQX2 LPqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784754078; x=1785358878; 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=WOd+XZss+YRv1olA4v5j/GA2GS28MPr0U93YAb8IAO0=; b=htDQyZzVn0Bx9uCnvYoxalRXWiUAl3W9pKnK6aZgXM45nfQYhyforcj8q/A+LnGJdc /jM4LPGFS91gUGp30qn/V3J0mqOSFMpi9vs2RejXpk7G/CCt9HcJLDQruoYAP5JR4ve6 1cNEoamkACTZwefcKbo7Knnjdr2QQmcwxcMzgoXnFp0qeeP/GNq4IxR2wquXq2a07SrI LnrHlQkVpYPfJRttzfS4ZaNyUVmIECwsbVz+yboqhYeVzHlFdPfS7lf2K3b+WmSVinsC dVlJBPAS2BkbHjnRd7ITw61zBcUoTAf0NBgfijWMZ45bk7pvoOpoHXBq8MuZL7k/JVUz upRA== X-Forwarded-Encrypted: i=1; AHgh+RohjrWJRsKSgYemSq4FZv0FLVnQZg74oWjybc1NIPlQ59CHHz2ZsSOPVQQv9S77LETXLazy5mKo8fdZCsA=@vger.kernel.org X-Gm-Message-State: AOJu0YxJHAxZum2Dlzl/sCFUstZ0eirwL4G+E1AUjcJ2i10ZU9axq3rT /3ld7DlgDiokHFHIICpkpCFgJcVh20KtQSroOO9gmu7tfkjeT9XB6B2Z X-Gm-Gg: AR+sD13ASxwGNoqsV/3KqywqIJ61IzmujaHyBhJ3mCqR37HAaepr+l0h5aUcC/PXkmH BLaFTTcmRBrx8n8rSVLcudqajVhpwWVM28wnBKo3rGi48pKU4YL6IojYXA+r6fEGZ2FOxXqLGka 5cYySMW6flLBFVkT0GkK6z1uj6CBVX8oXoSMcdnIpuAaWgQk2zMwIDESLlK1QDdvL4bg0DRgMeV g9QONOczyis3/3FMLOwPCsx5+GOmg5xvIgPye8sBm24qBgqoXTDYDTKBKD6OBEj4K9C9dGCqq0e T+NykQMq7UJ+ujICs38Y6MpOMuGiip1gwm/3hE5DFDd6hEqqyPhvwxY+lZB9tKHuDkse/aLUSpk ppZ6dML37njGA+5GRcFAelKp8chs1K7ktBAzGr1l+I3jssNEAnJ5jBjM7lDbVWhO9vYOurn+4Ys boZAYaa+2c2SBva28e0+zBi1zS X-Received: by 2002:a05:6000:2387:b0:47f:6fbd:89eb with SMTP id ffacd0b85a97d-47f8dc936b1mr487157f8f.57.1784754077794; Wed, 22 Jul 2026 14:01:17 -0700 (PDT) Received: from coolemuke.fritz.box ([2a00:6020:b320:1a00:c256:1463:a40b:d8c6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85c63678sm8610812f8f.29.2026.07.22.14.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 14:01:17 -0700 (PDT) From: "=?UTF-8?q?S=C3=B6ren=20Hantel?=" X-Google-Original-From: =?UTF-8?q?S=C3=B6ren=20Hantel?= To: linux-pm@vger.kernel.org Cc: Vasily Khoruzhick , Yangtao Li , "Rafael J . Wysocki" , Daniel Lezcano , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Rossak , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Claude Fable 5 , =?UTF-8?q?S=C3=B6ren=20Hantel?= Subject: [PATCH v2 3/3] ARM: dts: sun9i-a80: Add thermal sensor and thermal zones Date: Wed, 22 Jul 2026 23:00:46 +0200 Message-ID: <20260722210046.2932498-4-fugininsane@googlemail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260722210046.2932498-1-fugininsane@googlemail.com> References: <20260722203341.2917852-1-fugininsane@googlemail.com> <20260722210046.2932498-1-fugininsane@googlemail.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: Philipp Rossak Now that the A80 thermal sensor is supported, add its device node and the thermal zones to the device tree. The clocks and the resets are shared between the GPADC and the THS sensor. Sensor 0 is located beside the big CPU cluster, sensor 1 beside the DRAM controller, sensor 2 beside the GPU and sensor 3 beside the little CPU cluster. Signed-off-by: Philipp Rossak [soeren: rebased from the 2018 series, fixed the interrupt number (SPI 115 as in the vendor BSP; verified on hardware - SPI 31 stays silent), added critical trip points matching the driver's emergency shutdown threshold] Co-authored-by: Claude Fable 5 Signed-off-by: S=C3=B6ren Hantel --- arch/arm/boot/dts/allwinner/sun9i-a80.dtsi | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/arch/arm/boot/dts/allwinner/sun9i-a80.dtsi b/arch/arm/boot/dts= /allwinner/sun9i-a80.dtsi index a1ae092..8e7f8cd 100644 --- a/arch/arm/boot/dts/allwinner/sun9i-a80.dtsi +++ b/arch/arm/boot/dts/allwinner/sun9i-a80.dtsi @@ -941,6 +941,16 @@ #reset-cells =3D <1>; }; =20 + ths: thermal-sensor@6004c00 { + compatible =3D "allwinner,sun9i-a80-ths"; + reg =3D <0x06004c00 0x100>; + interrupts =3D ; + clocks =3D <&ccu CLK_BUS_GPADC>, <&ccu CLK_GPADC>; + clock-names =3D "bus", "mod"; + resets =3D <&ccu RST_BUS_GPADC>; + #thermal-sensor-cells =3D <1>; + }; + timer@6000c00 { compatible =3D "allwinner,sun4i-a10-timer"; reg =3D <0x06000c00 0xa0>; @@ -1250,4 +1260,62 @@ #size-cells =3D <0>; }; }; + + thermal-zones { + cpu0_thermal: cpu0-thermal { + polling-delay-passive =3D <1000>; + polling-delay =3D <5000>; + thermal-sensors =3D <&ths 0>; + + trips { + cpu0_crit: cpu0-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + dram_thermal: dram-thermal { + polling-delay-passive =3D <1000>; + polling-delay =3D <5000>; + thermal-sensors =3D <&ths 1>; + + trips { + dram_crit: dram-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + gpu_thermal: gpu-thermal { + polling-delay-passive =3D <1000>; + polling-delay =3D <5000>; + thermal-sensors =3D <&ths 2>; + + trips { + gpu_crit: gpu-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + + cpu2_thermal: cpu2-thermal { + polling-delay-passive =3D <1000>; + polling-delay =3D <5000>; + thermal-sensors =3D <&ths 3>; + + trips { + cpu2_crit: cpu2-crit { + temperature =3D <100000>; + hysteresis =3D <2000>; + type =3D "critical"; + }; + }; + }; + }; }; --=20 2.43.0