From: muhammed.efecetin.67@gmail.com
To: linux-rockchip@lists.infradead.org
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de,
neil.armstrong@linaro.org, lee@kernel.org, rafael@kernel.org,
efectn@protonmail.com, daniel.lezcano@linaro.org
Subject: [PATCH v3 4/5] thermal: khadas_mcu_fan: add support for Khadas Edge 2
Date: Tue, 21 Oct 2025 17:22:44 +0200 [thread overview]
Message-ID: <68fbedccd22459c3fb5bff8a41c485075799a111.1761059314.git.efectn@protonmail.com> (raw)
In-Reply-To: <cover.1761059314.git.efectn@protonmail.com>
From: Muhammed Efe Cetin <efectn@protonmail.com>
Fan control on the Khadas Edge 2 is controlled with the 0x8A register,
using percentage values from 0 to 100, whereas there are only 3 constant
steps in previous Khadas boards. Therefore, i adjusted max_level and
fan_ctrl_reg when the mcu node is defined with khadas,mcu-edge2 compatible.
Signed-off-by: Muhammed Efe Cetin <efectn@protonmail.com>
---
drivers/thermal/khadas_mcu_fan.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/thermal/khadas_mcu_fan.c b/drivers/thermal/khadas_mcu_fan.c
index d35e5313bea41..e3ac4fb6d1f82 100644
--- a/drivers/thermal/khadas_mcu_fan.c
+++ b/drivers/thermal/khadas_mcu_fan.c
@@ -15,10 +15,13 @@
#include <linux/thermal.h>
#define MAX_LEVEL 3
+#define MAX_LEVEL_EDGE2 100
struct khadas_mcu_fan_ctx {
struct khadas_mcu *mcu;
unsigned int level;
+ unsigned int max_level;
+ unsigned int fan_ctrl_reg;
struct thermal_cooling_device *cdev;
};
@@ -26,8 +29,7 @@ static int khadas_mcu_fan_set_level(struct khadas_mcu_fan_ctx *ctx,
unsigned int level)
{
int ret;
-
- ret = regmap_write(ctx->mcu->regmap, KHADAS_MCU_CMD_FAN_STATUS_CTRL_REG,
+ ret = regmap_write(ctx->mcu->regmap, ctx->fan_ctrl_reg,
level);
if (ret)
return ret;
@@ -40,7 +42,9 @@ static int khadas_mcu_fan_set_level(struct khadas_mcu_fan_ctx *ctx,
static int khadas_mcu_fan_get_max_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{
- *state = MAX_LEVEL;
+ struct khadas_mcu_fan_ctx *ctx = cdev->devdata;
+
+ *state = ctx->max_level;
return 0;
}
@@ -61,7 +65,7 @@ khadas_mcu_fan_set_cur_state(struct thermal_cooling_device *cdev,
{
struct khadas_mcu_fan_ctx *ctx = cdev->devdata;
- if (state > MAX_LEVEL)
+ if (state > ctx->max_level)
return -EINVAL;
if (state == ctx->level)
@@ -88,6 +92,14 @@ static int khadas_mcu_fan_probe(struct platform_device *pdev)
if (!ctx)
return -ENOMEM;
ctx->mcu = mcu;
+ ctx->max_level = MAX_LEVEL;
+ ctx->fan_ctrl_reg = KHADAS_MCU_CMD_FAN_STATUS_CTRL_REG;
+
+ if (of_device_is_compatible(mcu->dev->of_node, "khadas,mcu-edge2")) {
+ ctx->fan_ctrl_reg = KHADAS_MCU_EDGE2_FAN_CTRL_REG;
+ ctx->max_level = MAX_LEVEL_EDGE2;
+ }
+
platform_set_drvdata(pdev, ctx);
cdev = devm_thermal_of_cooling_device_register(dev->parent,
--
2.51.1.dirty
next prev parent reply other threads:[~2025-10-21 15:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 15:22 [PATCH v3 0/5] Add Khadas MCU and fan control " muhammed.efecetin.67
2025-10-21 15:22 ` [PATCH v3 1/5] dt-bindings: mfd: khadas-mcu: add new compatible " muhammed.efecetin.67
2025-10-22 17:37 ` Conor Dooley
2025-10-21 15:22 ` [PATCH v3 2/5] mfd: khadas-mcu: drop unused nvmem code muhammed.efecetin.67
2025-10-21 15:22 ` [PATCH v3 3/5] mfd: add Khadas Edge 2 registers to khadas-mcu muhammed.efecetin.67
2025-10-22 7:18 ` kernel test robot
2025-10-23 2:03 ` kernel test robot
2025-10-21 15:22 ` muhammed.efecetin.67 [this message]
2025-10-21 15:22 ` [PATCH v3 5/5] arm64: dts: rockchip: add Khadas MCU and fan control nodes muhammed.efecetin.67
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68fbedccd22459c3fb5bff8a41c485075799a111.1761059314.git.efectn@protonmail.com \
--to=muhammed.efecetin.67@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=efectn@protonmail.com \
--cc=heiko@sntech.de \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=rafael@kernel.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®