From: Binbin Zhou <zhoubinbin@loongson.cn>
To: Binbin Zhou <zhoubb.aaron@gmail.com>,
Huacai Chen <chenhuacai@loongson.cn>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Yinbo Zhu <zhuyinbo@loongson.cn>,
zhanghongchen <zhanghongchen@loongson.cn>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>,
Xuerui Wang <kernel@xen0n.name>,
loongarch@lists.linux.dev, devicetree@vger.kernel.org,
linux-pm@vger.kernel.org, Binbin Zhou <zhoubinbin@loongson.cn>
Subject: [PATCH v7 0/8] thermal/drivers/loongson2: Fix trip programming and add Loongson-2K0300 support
Date: Fri, 9 Oct 2026 10:57:03 +0800 [thread overview]
Message-ID: <cover.1791512067.git.zhoubinbin@loongson.cn> (raw)
This series fixes trip-point handling in the Loongson-2 thermal driver,
refactors the driver around per-SoC chip data, and adds support for the
Loongson-2K0300 thermal sensor.
The Loongson-2K0300's thermal sensor is generally compatible with the
existing Loongson-2K series, but it features several key differences:
1. It has an independent CPU ID register for reading chip version
information.
2. The raw temperature output field has been extended from 8 bits to 11
bits.
3. The temperature calculation formula has been updated to incorporate a
correction factor based on the version information.
To ensure robustness on older hardware revisions, a fallback mechanism
is included: if the calculated temperature falls outside the valid range
(-40 to 125), the driver falls back to a simpler calculation and prints
a warning.
The first three patches are fixes:
- Patch 1 fixes signed division when converting negative milli-degree
trip points to degrees Celsius.
- Patch 2 fixes the arguments to clamp() so trip points are limited to
the supported sensor range.
- Patch 3 fixes Loongson-2K2000 trip-point programming by adding a
per-SoC register callback and handling the split HI_GATE register.
Patches 4-6 are cleanups and preparation work:
- Patch 4 removes the unnecessary multi-sensor registration loop.
- Patch 5 replaces open-coded bit operations with bitfield helpers and
splits the per-SoC thermal ops.
- Patch 6 moves the per-SoC ops and hardware initialization into chip
data.
Patch 7 adds the Loongson-2K0300 DT binding, and patch 8 adds driver
support for the Loongson-2K0300 thermal sensor.
The patchset have been validated on the Loongson-2K series development
boards.
Thanks.
Binbin
=========
V7:
Patch (1/8):
- New patch;
- Fix negative temperature conversion in set_trips;
Patch (3/8):
- Use writew()/writeb() in loongson2_2k2000_set_trips_regs;
Patch (4/8):
- Rewite the thermal sensor registration loop to clearer;
Patch (5/8):
- Fix `loognson2_thermal_set_trips` typo;
Patch (8/8):
- Read CHIP_ID1 only when EXTERN_ID is set;
- Simplify the Internal ID calculation;
- Add necessary comments.
Link to V6:
https://lore.kernel.org/all/cover.1790561983.git.zhoubinbin@loongson.cn/
V6:
- Rebase on linux-pm/thermal;
Patch (2/7):
- New patch;
- Fix incorrect clamp() argument order for thermal trip points;
Patch (3/7):
- New patch;
- Fix Loongson-2K2000 trip point programming by adding a per-SoC
set_trips_regs callback and handling the split HI_GATE registers;
Patch (4/7):
- New patch;
- cleanup: use GENMASK/FIELD_* helpers, add named constants, and factor
common trip point setup;
Patch (5/7):
- New patch;
- refactor: move thermal_zone_device_ops into chip_data and replace the
Loongson-2K2000 flag special case with an optional init_extend_resource
callback;
Patch (7/7):
- Updated the 10-bit output to 11-bit in commit message;
- Temporarily remove the implementation of `set_trips`;
- Remove unnecessary header files;
- Rewrite `get_temp`, separating `read_calib` and `detect_old_fuse` into
new functions to be called during the probe;
- Use macros to define the relevant numbers.
Link to V5:
https://lore.kernel.org/all/cover.1789546118.git.zhoubinbin@loongson.cn/#t
V5:
- Rebase on linux-pm/thermal;
- Drop patch-3 for it was applied.
Link to V4:
https://lore.kernel.org/all/cover.1785829933.git.zhoubinbin@loongson.cn/
V4:
- Rebase on linux-mfd/for-mfd-next;
Patch (3/5):
- Remove the operation that adds `compatible` to the `select` node.
Link to V3:
https://lore.kernel.org/all/cover.1785480242.git.zhoubinbin@loongson.cn/
V3:
Patch (2/5):
- New patch for moving thermal_ops to chip_data;
Patch (3/5):
- Correct spelling errors;
Patch (4/5):
- Add Acked-by from Conor, thanks;
Patch (5/5):
- Keep loongson2_thermal_data->chip_data as const, and use
data->flags as the private data.
- Renmae LOONGSON2_THSENS_OUT_10B_MASK ->
LOONGSON2_THSENS_OUT_11B_MASK;
Link to V2:
https://lore.kernel.org/all/cover.1784619512.git.zhoubinbin@loongson.cn/
V2:
Patch (1/4):
- New patch form Sashiko;
Patch (2/4):
- New patch for adding chipid syscon compatible;
Patch (3/4):
- Use `loongson,chipid` phandle replace reg property;
Patch (3/4):
- Refact `calib_offset` calculate routing;
- Add LS2K0300_OLD_FUSE_FLAG flag.
Link to V1:
https://lore.kernel.org/all/cover.1783670011.git.zhoubinbin@loongson.cn/
Binbin Zhou (8):
thermal/drivers/loongson2: Fix negative temperature conversion in
set_trips
thermal/drivers/loongson2: Fix clamp() usage for thermal trip points
thermal/drivers/loongson2: Fix Loongson-2K2000 trip point programming
thermal/drivers/loongson2: Simplify thermal sensor registration
thermal/drivers/loongson2: Use bitfields and per-SoC thermal ops
thermal/drivers/loongson2: Move per-SoC ops into chip data
dt-bindings: thermal: loongson,ls2k-thermal: Add compatible for
Loongson-2K0300
thermal/drivers/loongson2: Add Loongson-2K0300 support
.../thermal/loongson,ls2k-thermal.yaml | 73 +++-
drivers/thermal/loongson2_thermal.c | 359 ++++++++++++++----
2 files changed, 332 insertions(+), 100 deletions(-)
base-commit: ec0d89150a9381d591344a9f6f5428655c227a7f
--
2.52.0
next reply other threads:[~2026-10-09 2:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 2:57 Binbin Zhou [this message]
2026-10-09 2:57 ` [PATCH v7 1/8] thermal/drivers/loongson2: Fix negative temperature conversion in set_trips Binbin Zhou
2026-10-09 2:57 ` [PATCH v7 2/8] thermal/drivers/loongson2: Fix clamp() usage for thermal trip points Binbin Zhou
2026-10-09 2:58 ` [PATCH v7 3/8] thermal/drivers/loongson2: Fix Loongson-2K2000 trip point programming Binbin Zhou
2026-10-09 2:58 ` [PATCH v7 4/8] thermal/drivers/loongson2: Simplify thermal sensor registration Binbin Zhou
2026-10-09 2:58 ` [PATCH v7 5/8] thermal/drivers/loongson2: Use bitfields and per-SoC thermal ops Binbin Zhou
2026-10-09 3:09 ` sashiko-bot
2026-10-09 2:58 ` [PATCH v7 6/8] thermal/drivers/loongson2: Move per-SoC ops into chip data Binbin Zhou
2026-10-09 2:58 ` [PATCH v7 7/8] dt-bindings: thermal: loongson,ls2k-thermal: Add compatible for Loongson-2K0300 Binbin Zhou
2026-10-09 2:58 ` [PATCH v7 8/8] thermal/drivers/loongson2: Add Loongson-2K0300 support Binbin Zhou
2026-10-09 3:07 ` sashiko-bot
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=cover.1791512067.git.zhoubinbin@loongson.cn \
--to=zhoubinbin@loongson.cn \
--cc=chenhuacai@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kernel@xen0n.name \
--cc=krzk+dt@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=zhanghongchen@loongson.cn \
--cc=zhoubb.aaron@gmail.com \
--cc=zhuyinbo@loongson.cn \
/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