Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ec_memory_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ struct msi_ec_fan_mode_conf {
struct msi_ec_cpu_conf {
int rt_temp_address;
int rt_fan_speed_address; // realtime % RPM
int fan_speed_rpm_address_0; // 480000/n RPM
};

struct msi_ec_gpu_conf {
int rt_temp_address;
int rt_fan_speed_address; // realtime % RPM
int fan_speed_rpm_address_0; // 480000/n RPM
};

struct msi_ec_led_conf {
Expand Down
60 changes: 60 additions & 0 deletions msi-ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,12 @@ static struct msi_ec_conf CONF_G1_8 __initdata = {
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71,
.fan_speed_rpm_address_0 = 0xcc,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = 0x89,
.fan_speed_rpm_address_0 = 0xca,
},
.leds = {
.micmute_led_address = MSI_EC_ADDR_UNSUPP,
Expand Down Expand Up @@ -2206,6 +2208,23 @@ static ssize_t cpu_realtime_fan_speed_show(struct device *device,
return sysfs_emit(buf, "%i\n", rdata);
}

static ssize_t cpu_fan_speed_rpm_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
u8 rdata[2];
int result;

result = ec_read_seq(conf.cpu.fan_speed_rpm_address_0, rdata, 2);
if (result < 0)
return result;

int value = (rdata[0] << 8) | rdata[1];
int rpm = value != 0 ? 480000 / value : 0;

return sysfs_emit(buf, "%i\n", rpm);
}

static struct device_attribute dev_attr_cpu_realtime_temperature = {
.attr = {
.name = "realtime_temperature",
Expand All @@ -2222,9 +2241,18 @@ static struct device_attribute dev_attr_cpu_realtime_fan_speed = {
.show = cpu_realtime_fan_speed_show,
};

static struct device_attribute dev_attr_cpu_fan_speed_rpm = {
.attr = {
.name = "fan_speed_rpm",
.mode = 0444,
},
.show = cpu_fan_speed_rpm_show,
};

static struct attribute *msi_cpu_attrs[] = {
&dev_attr_cpu_realtime_temperature.attr,
&dev_attr_cpu_realtime_fan_speed.attr,
&dev_attr_cpu_fan_speed_rpm.attr,
NULL
};

Expand Down Expand Up @@ -2260,6 +2288,23 @@ static ssize_t gpu_realtime_fan_speed_show(struct device *device,
return sysfs_emit(buf, "%i\n", rdata);
}

static ssize_t gpu_fan_speed_rpm_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
u8 rdata[2];
int result;

result = ec_read_seq(conf.gpu.fan_speed_rpm_address_0, rdata, 2);
if (result < 0)
return result;

int value = (rdata[0] << 8) | rdata[1];
int rpm = value != 0 ? 480000 / value : 0;

return sysfs_emit(buf, "%i\n", rpm);
}

static struct device_attribute dev_attr_gpu_realtime_temperature = {
.attr = {
.name = "realtime_temperature",
Expand All @@ -2276,9 +2321,18 @@ static struct device_attribute dev_attr_gpu_realtime_fan_speed = {
.show = gpu_realtime_fan_speed_show,
};

static struct device_attribute dev_attr_gpu_fan_speed_rpm = {
.attr = {
.name = "fan_speed_rpm",
.mode = 0444,
},
.show = gpu_fan_speed_rpm_show,
};

static struct attribute *msi_gpu_attrs[] = {
&dev_attr_gpu_realtime_temperature.attr,
&dev_attr_gpu_realtime_fan_speed.attr,
&dev_attr_gpu_fan_speed_rpm.attr,
NULL
};

Expand Down Expand Up @@ -2529,13 +2583,19 @@ static umode_t msi_ec_is_visible(struct kobject *kobj,
else if (attr == &dev_attr_cpu_realtime_fan_speed.attr)
address = conf.cpu.rt_fan_speed_address;

else if (attr == &dev_attr_cpu_fan_speed_rpm.attr)
address = conf.cpu.fan_speed_rpm_address_0;

/* gpu group */
else if (attr == &dev_attr_gpu_realtime_temperature.attr)
address = conf.gpu.rt_temp_address;

else if (attr == &dev_attr_gpu_realtime_fan_speed.attr)
address = conf.gpu.rt_fan_speed_address;

else if (attr == &dev_attr_gpu_fan_speed_rpm.attr)
address = conf.gpu.fan_speed_rpm_address_0;

/* default */
else
return attr->mode;
Expand Down