From nobody Fri Sep 25 16:51:47 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2176C3D3339; Thu, 10 Sep 2026 06:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022337; cv=none; b=JrIzsxQqnXbHoP5b45yvQsrWTGOWE4prO5aKKtmSjOAulzGQmVpV5Zl5LzU2cwrWVUbdkTFHPbVBV13cfUjJ370PqliEQL9bzU2/pspzfRkKKxE5u91AZ2ftg+iZim9vXr0yc5KUhUm6IS80fbuEsi8P6j+Q+FalJwj3PYZi0j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022337; c=relaxed/simple; bh=2TU5UtSqlTK5Fx9D95GxY0TfdDPbOgZck8finK/MKtM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kHEetB6Xz7uYV7BVKZTCJ29hoinqQrpS+g9jBSxj+u2JeArTlVyox7FqGlVM/FjYvl/ZDZrzIzKx5TowKkeT4tODPZn8j11lzOBvYGWfzaU1dpPY/DrFkqzAGpC2hJZYv9zDMTuyTiSxl6gp9nM7eLmSOK5WuwqWY56FGXzJI9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BFsf7P2z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BFsf7P2z" Received: by smtp.kernel.org (Postfix) with ESMTPS id 91F01C2BCFC; Thu, 10 Sep 2026 06:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1789022336; bh=2TU5UtSqlTK5Fx9D95GxY0TfdDPbOgZck8finK/MKtM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BFsf7P2zElLdbO5Q0ymkbWVfDBWZDNXAgIrMIRK7VgkT45En02HXgiunXNP/8/liU K0ZsJw+yQ9hTTs6Rczdyo5vBDeUfi09GJubqI89hesR7U/9nAQld+IBDuBktxlhB6f UBy82UkmbU2S+CVhQFFUpnescSUFVqvTlLhWbwTqg1UGNY7elBr6ix2V+rjiiah6Vv /5D/zXdb0ag5JEbqzW6Tmvmj7YxkHNxfxNnISxtaYwyuPfpf1swlMLlbVHaUYSttMq J6L0kHq0n5E3BcJc6pL9WSwqec+ESpyl67np9ZkcpL6j+X98YCeI3Y5JMQe3bOW6pl In3Fm/sn88A+g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DFBAC79FB7; Thu, 10 Sep 2026 06:38:56 +0000 (UTC) From: Xianwei Zhao via B4 Relay Date: Thu, 10 Sep 2026 06:38:52 +0000 Subject: [PATCH v5 1/2] dt-bindings: thermal: amlogic: Add A9 thermal bindings 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 Message-Id: <20260910-a9-thermal-v5-1-892d798723e1@amlogic.com> References: <20260910-a9-thermal-v5-0-892d798723e1@amlogic.com> In-Reply-To: <20260910-a9-thermal-v5-0-892d798723e1@amlogic.com> To: Guillaume La Roque , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pm@vger.kernel.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Xianwei Zhao , Conor Dooley X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1789022333; l=1701; i=xianwei.zhao@amlogic.com; s=20251216; h=from:subject:message-id; bh=z03XxmpaVvRhkUiS0uq3ppP3WR/hzF6qXYwRuBxcXJE=; b=e5xlU76hScLnEWkvmwjg2BCWQHDq5iPnOnS9y+eaQqxdcGEpopL6reLgsKb3f/49yx6JkQyuI XwTcKScieLXC6weiHMdMNl4dIEW4HOEIJMy6NPXF7rCPMdzsP7AYx+V X-Developer-Key: i=xianwei.zhao@amlogic.com; a=ed25519; pk=dWwxtWCxC6FHRurOmxEtr34SuBYU+WJowV/ZmRJ7H+k= X-Endpoint-Received: by B4 Relay for xianwei.zhao@amlogic.com/20251216 with auth_id=578 X-Original-From: Xianwei Zhao Reply-To: xianwei.zhao@amlogic.com From: Xianwei Zhao Document the thermal controller compatibles for the Amlogic A9 SoC. Describe the required "core" and "pclk" clocks, and update the schema constraints for A9-specific thermal controllers. Acked-by: Conor Dooley Signed-off-by: Xianwei Zhao --- .../bindings/thermal/amlogic,thermal.yaml | 27 ++++++++++++++++++= +++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml= b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml index 8cfa44dcda58..1b02404d67d5 100644 --- a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml +++ b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml @@ -23,6 +23,7 @@ properties: - const: amlogic,g12a-thermal - enum: - amlogic,a1-cpu-thermal + - amlogic,a9-thermal - amlogic,t7-thermal =20 reg: @@ -32,7 +33,13 @@ properties: maxItems: 1 =20 clocks: - maxItems: 1 + minItems: 1 + maxItems: 2 + + clock-names: + items: + - const: core + - const: pclk =20 power-domains: maxItems: 1 @@ -73,6 +80,24 @@ allOf: required: - amlogic,secure-monitor =20 + - if: + properties: + compatible: + contains: + enum: + - amlogic,a9-thermal + then: + properties: + clocks: + minItems: 2 + required: + - clock-names + else: + properties: + clocks: + maxItems: 1 + clock-names: false + unevaluatedProperties: false =20 examples: --=20 2.52.0 From nobody Fri Sep 25 16:51:47 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 218453D3492; Thu, 10 Sep 2026 06:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022337; cv=none; b=V8/B8zoAjIw7NPr+xGuy/FodQwh2vKDUQwqiynmwD9LWeaj1Zj+WoTemy31NHCEKZ4dBL7zR7WM/7IhlNRxIL67f+hBDqYFWPq8q9qurrHPbDfaArKWQMXD79sd+oA3dq8FfhJMd38Kz7kc3Lzbgzmytdm7MjKQ5X0N3bX/vIBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022337; c=relaxed/simple; bh=Zb/LwgGr7DEM3tO0ucLyrTnmcy1CRThDJrc9WTV8lvw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=afjRr2zWZpnAnzCjEgkIezwjQgHvBJotjs/GEg8uEuINYqKYfSAsWDuHQSRYQr2oPSTOChg2oKyooP9nYTMev2WDtWXY0GDMEqwygGVTsRpH2yrfuu9Ey6UGXDn/Q65vOVhPtT2pwb9v7/IV29Uc4X8n+UWzxkCAqZXdlMx5/zY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jv4CuJQm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jv4CuJQm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9E9A6C2BCFB; Thu, 10 Sep 2026 06:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1789022336; bh=Zb/LwgGr7DEM3tO0ucLyrTnmcy1CRThDJrc9WTV8lvw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jv4CuJQmb8nCqAad34jJJ7eAqEyxRXKYwxyoeWs4KA2t06fCOI2WaNNztsTtnFRzY hNTs4Fk3df2gx5L9r8Rvh3yM2M/+Z74AU+4mioBV+ZXTQZCSoN3+gJKNJoI28TlB3M QPbmGVPsZIOF3rCV81+PU9Mqf5gllxX7c0AObjYaBPFGMc14HoEYovbVmVFCaIHPol tFe72Vhl2yCWaHXEw3wI2gAUtjnE1QgP/aJmn4rzgnWt2XgfTa6pEL4mM3wfpS7e3d Nvyo/Bjo0b8KH8juVwL0jgRuHSdMKn4sOG/zj7S9CI8izJrNAseckbKOyp3OqsXjy2 Dh539ky6MmItw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E749C79FB9; Thu, 10 Sep 2026 06:38:56 +0000 (UTC) From: Xianwei Zhao via B4 Relay Date: Thu, 10 Sep 2026 06:38:53 +0000 Subject: [PATCH v5 2/2] thermal: amlogic: Add support for A9 thermal controller 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 Message-Id: <20260910-a9-thermal-v5-2-892d798723e1@amlogic.com> References: <20260910-a9-thermal-v5-0-892d798723e1@amlogic.com> In-Reply-To: <20260910-a9-thermal-v5-0-892d798723e1@amlogic.com> To: Guillaume La Roque , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pm@vger.kernel.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Xianwei Zhao X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1789022333; l=7899; i=xianwei.zhao@amlogic.com; s=20251216; h=from:subject:message-id; bh=oYdIslolzA3DJMsonLIFZ8XXaiSWr9vCeZbDJqhZZ+8=; b=8afdYiCb4M8S5u40CzJgmoU1mo831WNIy/wj2QJ06RlamFx1QDeoS/lru0BoJBN4I4aJlQf6/ rCWVeUwDL8pBtiK0Ech4QGd6MsoxGEcOkjFRcCM0dKwLiI0kpYPcB29 X-Developer-Key: i=xianwei.zhao@amlogic.com; a=ed25519; pk=dWwxtWCxC6FHRurOmxEtr34SuBYU+WJowV/ZmRJ7H+k= X-Endpoint-Received: by B4 Relay for xianwei.zhao@amlogic.com/20251216 with auth_id=578 X-Original-From: Xianwei Zhao Reply-To: xianwei.zhao@amlogic.com From: Xianwei Zhao Add support for the Amlogic A9 thermal controller. The A9 thermal controller uses different calibration parameters, requires separate core and bus clocks, and supports a hardware over-temperature reset mechanism, and restore the hardware reset configuration after resume. Signed-off-by: Xianwei Zhao --- drivers/thermal/amlogic_thermal.c | 121 ++++++++++++++++++++++++++++++++++= +++- 1 file changed, 118 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/amlogic_thermal.c b/drivers/thermal/amlogic_th= ermal.c index a0b530624b60..e7cedb944315 100644 --- a/drivers/thermal/amlogic_thermal.c +++ b/drivers/thermal/amlogic_thermal.c @@ -45,6 +45,19 @@ TSENSOR_CFG_REG1_DEM_EN | \ TSENSOR_CFG_REG1_CH_SEL) =20 +#define TSENSOR_CFG_REG2 0x8 + #define TSENSOR_CFG_REG2_HITEMP_EN BIT(31) + #define TSENSOR_CFG_REG2_REBOOT_EN BIT(30) + #define TSENSOR_CFG_REG2_REBOOT_CODE GENMASK(15, 4) + #define TSENSOR_CFG_REG2_REBOOT_TIME GENMASK(23, 16) + #define TSENSOR_CFG_REG2_ENABLE \ + (TSENSOR_CFG_REG2_HITEMP_EN | \ + TSENSOR_CFG_REG2_REBOOT_EN) + +#define TSENSOR_REBOOT_TIME_MAX (0xff << 16) + +#define TSENSOR_TEMP_CAL 1 + #define TSENSOR_STAT0 0x40 =20 #define TSENSOR_STAT9 0x64 @@ -63,6 +76,7 @@ =20 #define TSENSOR_CALIB_OFFSET 1 #define TSENSOR_CALIB_SHIFT 4 +#define TSENSOR_HW_RESET_DEFAULT_TEMP 110000 =20 /** * struct amlogic_thermal_soc_calib_data @@ -85,14 +99,18 @@ struct amlogic_thermal_soc_calib_data { * @u_efuse_off: register offset to read fused calibration value * @calibration_parameters: calibration parameters structure pointer * @regmap_config: regmap config for the device + * @reset_temp: the hardware-controlled reset temperature value * @use_sm: read data from secure monitor instead of efuse + * @has_sysclk: sensor driver control sysclk * This structure is required for configuration of amlogic thermal driver. */ struct amlogic_thermal_data { int u_efuse_off; const struct amlogic_thermal_soc_calib_data *calibration_parameters; const struct regmap_config *regmap_config; + u32 reset_temp; bool use_sm; + bool has_sysclk; }; =20 struct amlogic_thermal { @@ -101,8 +119,10 @@ struct amlogic_thermal { struct regmap *regmap; struct regmap *sec_ao_map; struct clk *clk; + struct clk *sysclk; struct thermal_zone_device *tzd; u32 trim_info; + u32 temp_code; struct meson_sm_firmware *sm_fw; u32 tsensor_id; }; @@ -138,6 +158,51 @@ static int amlogic_thermal_code_to_millicelsius(struct= amlogic_thermal *pdata, return temp; } =20 +/* + * Calculate a temperature code from a temperature value . + * The unit of the temperature is degree milliCelsius. + */ +static u32 amlogic_thermal_millicelsius_to_code(struct amlogic_thermal *pd= ata, int millicelsius) +{ + const struct amlogic_thermal_soc_calib_data *param =3D + pdata->data->calibration_parameters; + s64 factor, uptat, uefuse; + u32 temp_code; + + uefuse =3D pdata->trim_info & TSENSOR_TRIM_SIGN_MASK ? + ~(pdata->trim_info & TSENSOR_TRIM_TEMP_MASK) + 1 : + (pdata->trim_info & TSENSOR_TRIM_TEMP_MASK); + + factor =3D param->B + div_s64(millicelsius, 100); + factor =3D BIT(16) * factor; + factor =3D div_s64(factor, param->A); + factor =3D factor - uefuse; + + uptat =3D param->n * factor; + uptat =3D div_s64(uptat, BIT(16)); + uptat =3D param->m - uptat; + + factor =3D factor * 100; + if (!uptat) + factor =3D (TSENSOR_TEMP_MASK - TSENSOR_TEMP_CAL) << 0x4; + else + factor =3D div_s64(factor, uptat); + + temp_code =3D ((factor >> 0x4) & TSENSOR_TEMP_MASK) + TSENSOR_TEMP_CAL; + + return temp_code; +} + +static void amlogic_tsensor_setup_hw_reset(struct amlogic_thermal *data) +{ + regmap_update_bits(data->regmap, TSENSOR_CFG_REG2, TSENSOR_CFG_REG2_REBOO= T_CODE, + data->temp_code << 0x4); + regmap_update_bits(data->regmap, TSENSOR_CFG_REG2, TSENSOR_CFG_REG2_REBOO= T_TIME, + TSENSOR_REBOOT_TIME_MAX); + regmap_update_bits(data->regmap, TSENSOR_CFG_REG2, + TSENSOR_CFG_REG2_ENABLE, TSENSOR_CFG_REG2_ENABLE); +} + static int amlogic_thermal_enable(struct amlogic_thermal *data) { int ret; @@ -254,6 +319,13 @@ static const struct amlogic_thermal_soc_calib_data aml= ogic_thermal_g12a =3D { .n =3D 324, }; =20 +static const struct amlogic_thermal_soc_calib_data amlogic_thermal_a9 =3D { + .A =3D 9164, + .B =3D 2747, + .m =3D 370, + .n =3D 270, +}; + static const struct amlogic_thermal_data amlogic_thermal_g12a_cpu_param = =3D { .u_efuse_off =3D 0x128, .calibration_parameters =3D &amlogic_thermal_g12a, @@ -272,6 +344,14 @@ static const struct amlogic_thermal_data amlogic_therm= al_a1_cpu_param =3D { .regmap_config =3D &amlogic_thermal_regmap_config_g12a, }; =20 +static const struct amlogic_thermal_data amlogic_thermal_a9_param =3D { + .use_sm =3D true, + .has_sysclk =3D true, + .calibration_parameters =3D &amlogic_thermal_a9, + .regmap_config =3D &amlogic_thermal_regmap_config_g12a, + .reset_temp =3D 110000, +}; + static const struct amlogic_thermal_data amlogic_thermal_t7_param =3D { .use_sm =3D true, .calibration_parameters =3D &amlogic_thermal_g12a, @@ -291,6 +371,10 @@ static const struct of_device_id of_amlogic_thermal_ma= tch[] =3D { .compatible =3D "amlogic,a1-cpu-thermal", .data =3D &amlogic_thermal_a1_cpu_param, }, + { + .compatible =3D "amlogic,a9-thermal", + .data =3D &amlogic_thermal_a9_param, + }, { .compatible =3D "amlogic,t7-thermal", .data =3D &amlogic_thermal_t7_param, @@ -305,6 +389,7 @@ static int amlogic_thermal_probe(struct platform_device= *pdev) struct device *dev =3D &pdev->dev; void __iomem *base; int ret; + u32 reset_temp; =20 pdata =3D devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) @@ -323,9 +408,18 @@ static int amlogic_thermal_probe(struct platform_devic= e *pdev) if (IS_ERR(pdata->regmap)) return PTR_ERR(pdata->regmap); =20 - pdata->clk =3D devm_clk_get(dev, NULL); - if (IS_ERR(pdata->clk)) - return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get clock\n"); + if (pdata->data->has_sysclk) { + pdata->clk =3D devm_clk_get(dev, "core"); + if (IS_ERR(pdata->clk)) + return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get core clk\= n"); + pdata->sysclk =3D devm_clk_get_enabled(dev, "pclk"); + if (IS_ERR(pdata->sysclk)) + return dev_err_probe(dev, PTR_ERR(pdata->sysclk), "failed to get pclk\n= "); + } else { + pdata->clk =3D devm_clk_get(dev, NULL); + if (IS_ERR(pdata->clk)) + return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get clock\n"); + } =20 if (pdata->data->use_sm) ret =3D amlogic_thermal_probe_sm(pdev, pdata); @@ -346,6 +440,17 @@ static int amlogic_thermal_probe(struct platform_devic= e *pdev) =20 devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd); =20 + if (pdata->data->reset_temp) { + reset_temp =3D pdata->data->reset_temp; + } else { + dev_dbg(dev, "using default hardware reset temperature\n"); + reset_temp =3D TSENSOR_HW_RESET_DEFAULT_TEMP; + } + + pdata->temp_code =3D amlogic_thermal_millicelsius_to_code(pdata, reset_te= mp); + + amlogic_tsensor_setup_hw_reset(pdata); + ret =3D amlogic_thermal_enable(pdata); =20 return ret; @@ -363,6 +468,8 @@ static int amlogic_thermal_suspend(struct device *dev) struct amlogic_thermal *data =3D dev_get_drvdata(dev); =20 amlogic_thermal_disable(data); + if (data->data->has_sysclk) + clk_disable_unprepare(data->sysclk); =20 return 0; } @@ -370,7 +477,15 @@ static int amlogic_thermal_suspend(struct device *dev) static int amlogic_thermal_resume(struct device *dev) { struct amlogic_thermal *data =3D dev_get_drvdata(dev); + int ret; + + if (data->data->has_sysclk) { + ret =3D clk_prepare_enable(data->sysclk); + if (ret) + return ret; + } =20 + amlogic_tsensor_setup_hw_reset(data); return amlogic_thermal_enable(data); } =20 --=20 2.52.0