mirror of
https://github.com/torvalds/linux.git
synced 2026-07-29 10:41:49 +02:00
hwmon fixes for v6.18-rc6
* gpd-fan: Fix compilation error for non-ACPI builds, and initialize EC when loading the driver -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmkWPEsACgkQyx8mb86f mYE1CQ/+NtX8LrqP4mzEKoYt8Ppx8xTqE31CxLOZH0NeBo0oLp0Oct8zkIHLfLss ZKdfLPL9yeXYKA6De/FRMzFKtfYGqA9lLrpizxXtp+K4PL9LLJsf4XYbx23tQkPS IJqnnhVsLGFWLM1b9Lkyi6nxsGkLR9sqMD6M5OpzArgUXACEn9Lrq+4LTUrD+sMr 6iTU3Jbd/J34dghZdU/wcGQbU0sh3ysnOGZHVZuNJdKFJHxhS3iAxSMReTi5iBOR 9EepPWxI7sRTA5lSaTCFhrNXsFpkVE92S3IQpG5xEfYKqIKFZyfibHTUkidghMSR oyIRUT+BNxcZJQcdLqVEXSGuVeJKv6NnL8+b3FfwBsQ5Hlb1/kkqLRdvWg+yBYFu BDGjFOosAlKHot7LU2Gjd8ylJvzC5Et/BYAvjmYxBTbn8peWCHWvyZp95V/6pXzl FmNx913mq2y2uNlLD8Ox7mkSLpoyPH6QKMzXpRe9Ftgwa0N7A0SbclMjiabjTts6 k3gVfcNZ+bM6dA5IY7hktLMSFQvPv+qYWUpd2DuUxAtYBWDQR0LA+RBjjI3sA8cU qDnt86d3W3blnV+Lvy/dANXOrrApiiz7YYG6rGc+ZOsoCKIG8rVLKy2jBwInHVY8 Z8AVr5C0bswa0zcmcCIJMBb13aZNMJtYMio9hGWQqqTfCeQ8gpU= =YXus -----END PGP SIGNATURE----- Merge tag 'hwmon-for-v6.18-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon fixes from Guenter Roeck: - gpd-fan: Fix compilation error for non-ACPI builds, and initialize EC when loading the driver * tag 'hwmon-for-v6.18-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (gpd-fan) initialize EC on driver load for Win 4 hwmon: (gpd-fan) Fix compilation error in non-ACPI builds
This commit is contained in:
commit
01814e11e5
|
|
@ -12,9 +12,9 @@
|
|||
* Copyright (c) 2024 Cryolitia PukNgae
|
||||
*/
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -276,31 +276,6 @@ static int gpd_generic_read_rpm(void)
|
|||
return (u16)high << 8 | low;
|
||||
}
|
||||
|
||||
static void gpd_win4_init_ec(void)
|
||||
{
|
||||
u8 chip_id, chip_ver;
|
||||
|
||||
gpd_ecram_read(0x2000, &chip_id);
|
||||
|
||||
if (chip_id == 0x55) {
|
||||
gpd_ecram_read(0x1060, &chip_ver);
|
||||
gpd_ecram_write(0x1060, chip_ver | 0x80);
|
||||
}
|
||||
}
|
||||
|
||||
static int gpd_win4_read_rpm(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = gpd_generic_read_rpm();
|
||||
|
||||
if (ret == 0)
|
||||
// Re-init EC when speed is 0
|
||||
gpd_win4_init_ec();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gpd_wm2_read_rpm(void)
|
||||
{
|
||||
for (u16 pwm_ctr_offset = GPD_PWM_CTR_OFFSET;
|
||||
|
|
@ -320,11 +295,10 @@ static int gpd_wm2_read_rpm(void)
|
|||
static int gpd_read_rpm(void)
|
||||
{
|
||||
switch (gpd_driver_priv.drvdata->board) {
|
||||
case win4_6800u:
|
||||
case win_mini:
|
||||
case duo:
|
||||
return gpd_generic_read_rpm();
|
||||
case win4_6800u:
|
||||
return gpd_win4_read_rpm();
|
||||
case win_max_2:
|
||||
return gpd_wm2_read_rpm();
|
||||
}
|
||||
|
|
@ -607,6 +581,28 @@ static struct hwmon_chip_info gpd_fan_chip_info = {
|
|||
.info = gpd_fan_hwmon_channel_info
|
||||
};
|
||||
|
||||
static void gpd_win4_init_ec(void)
|
||||
{
|
||||
u8 chip_id, chip_ver;
|
||||
|
||||
gpd_ecram_read(0x2000, &chip_id);
|
||||
|
||||
if (chip_id == 0x55) {
|
||||
gpd_ecram_read(0x1060, &chip_ver);
|
||||
gpd_ecram_write(0x1060, chip_ver | 0x80);
|
||||
}
|
||||
}
|
||||
|
||||
static void gpd_init_ec(void)
|
||||
{
|
||||
// The buggy firmware won't initialize EC properly on boot.
|
||||
// Before its initialization, reading RPM will always return 0,
|
||||
// and writing PWM will have no effect.
|
||||
// Initialize it manually on driver load.
|
||||
if (gpd_driver_priv.drvdata->board == win4_6800u)
|
||||
gpd_win4_init_ec();
|
||||
}
|
||||
|
||||
static int gpd_fan_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
|
|
@ -634,6 +630,8 @@ static int gpd_fan_probe(struct platform_device *pdev)
|
|||
return dev_err_probe(dev, PTR_ERR(hwdev),
|
||||
"Failed to register hwmon device\n");
|
||||
|
||||
gpd_init_ec();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user