mirror of
https://github.com/torvalds/linux.git
synced 2025-11-30 23:16:01 +07:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user