From 3420cd2b8efbbc467d9b228d6568ac7819d3097c Mon Sep 17 00:00:00 2001 From: LeoLiu-oc Date: Tue, 23 Dec 2025 18:59:33 +0800 Subject: [PATCH 1/2] anolis: hwmon/zhaoxin: Modernize cputemp driver code and configuration ANBZ: #28468 This patch modernizes the Zhaoxin CPU temperature driver with several improvements: 1. Set the driver to load as module by default in Kconfig 2. Modernize CPU matching using X86_MATCH_VENDOR_FAM_MODEL macro 3. Improve code readability with consistent naming(zhaoxin_cputemp_cpu_ids) 4. Fix indentation in cpuhp_setup_state function call 5. Maintain support for all existing Zhaoxin and Centaur processor models Signed-off-by: LeoLiu-oc --- drivers/hwmon/Kconfig | 1 + drivers/hwmon/zhaoxin-cputemp.c | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 096dbb1fec26..604f8053fd7f 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1911,6 +1911,7 @@ config SENSORS_VIA_CPUTEMP config SENSORS_ZHAOXIN_CPUTEMP tristate "Zhaoxin CPU temperature sensor" depends on X86 + default m help If you say yes here you get support for the temperature sensor inside your CPU. Supported are all known variants of diff --git a/drivers/hwmon/zhaoxin-cputemp.c b/drivers/hwmon/zhaoxin-cputemp.c index f93b291e61a9..61c8c7493509 100644 --- a/drivers/hwmon/zhaoxin-cputemp.c +++ b/drivers/hwmon/zhaoxin-cputemp.c @@ -262,16 +262,16 @@ static int zhaoxin_cputemp_down_prep(unsigned int cpu) mutex_unlock(&pdev_list_mutex); return 0; } -static const struct x86_cpu_id cputemp_ids[] __initconst = { - {X86_VENDOR_CENTAUR, 7, 0x3b, }, - {X86_VENDOR_ZHAOXIN, 7, 0x3b, }, - {X86_VENDOR_CENTAUR, 7, 0x5b, }, - {X86_VENDOR_ZHAOXIN, 7, 0x5b, }, - {X86_VENDOR_CENTAUR, 7, 0x6b, }, - {X86_VENDOR_ZHAOXIN, 7, 0x6b, }, +static const struct x86_cpu_id zhaoxin_cputemp_cpu_ids[] __initconst = { + X86_MATCH_VENDOR_FAM_MODEL(ZHAOXIN, 7, 0x3b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(CENTAUR, 7, 0x3b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(ZHAOXIN, 7, 0x5b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(CENTAUR, 7, 0x5b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(ZHAOXIN, 7, 0x6b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(CENTAUR, 7, 0x6b, NULL), {} }; -MODULE_DEVICE_TABLE(x86cpu, cputemp_ids); +MODULE_DEVICE_TABLE(x86cpu, zhaoxin_cputemp_cpu_ids); static enum cpuhp_state zhaoxin_temp_online; @@ -279,15 +279,13 @@ static int __init zhaoxin_cputemp_init(void) { int err; - if (!x86_match_cpu(cputemp_ids)) + if (!x86_match_cpu(zhaoxin_cputemp_cpu_ids)) return -ENODEV; err = platform_driver_register(&zhaoxin_cputemp_driver); if (err) goto exit; - err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, - "hwmon/zhaoxin:online", - zhaoxin_cputemp_online, - zhaoxin_cputemp_down_prep); + err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "hwmon/zhaoxin:online", + zhaoxin_cputemp_online, zhaoxin_cputemp_down_prep); if (err < 0) goto exit_driver_unreg; zhaoxin_temp_online = err; -- Gitee From 2af4e4eb3c687a1d98e0eac527c1f8dccf7cabf4 Mon Sep 17 00:00:00 2001 From: LeoLiu-oc Date: Tue, 23 Dec 2025 19:05:25 +0800 Subject: [PATCH 2/2] anolis: hwmon/zhaoxin: add support for KH-50000 ANBZ: #28468 Adds support for KH-50000 CPU with model 0x7b in the zhaoxin-cputemp driver. It extends the existing `x86_cpu_id` array to include this new CPU model. Reviewed-by: Tony W. Wang Tested-by: Lyle Li Signed-off-by: LeoLiu-oc --- drivers/hwmon/zhaoxin-cputemp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/zhaoxin-cputemp.c b/drivers/hwmon/zhaoxin-cputemp.c index 61c8c7493509..9c3b84e1496e 100644 --- a/drivers/hwmon/zhaoxin-cputemp.c +++ b/drivers/hwmon/zhaoxin-cputemp.c @@ -143,9 +143,9 @@ static int zhaoxin_cputemp_probe(struct platform_device *pdev) data->id = pdev->id; data->name = "zhaoxin_cputemp"; data->msr_temp = 0x1423; - if (c->x86_model == 0x6b) { - data->msr_crit = 0x175b; - data->msr_max = 0x175a; + if (c->x86_model == 0x6b || c->x86_model == 0x7b) { + data->msr_crit = 0x175b; + data->msr_max = 0x175a; } else { data->msr_crit = 0x1416; data->msr_max = 0x1415; @@ -269,6 +269,8 @@ static const struct x86_cpu_id zhaoxin_cputemp_cpu_ids[] __initconst = { X86_MATCH_VENDOR_FAM_MODEL(CENTAUR, 7, 0x5b, NULL), X86_MATCH_VENDOR_FAM_MODEL(ZHAOXIN, 7, 0x6b, NULL), X86_MATCH_VENDOR_FAM_MODEL(CENTAUR, 7, 0x6b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(CENTAUR, 7, 0x7b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(ZHAOXIN, 7, 0x7b, NULL), {} }; MODULE_DEVICE_TABLE(x86cpu, zhaoxin_cputemp_cpu_ids); -- Gitee