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
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,6 @@ This driver exports a few files in its own platform device, msi-ec, and is avail
- sport: full clock frequency and voltage for the CPU & GPU, aka default desktop mode
- turbo: over-voltage and over-clock for the CPU & GPU, aka overclocking mode

- `/sys/devices/platform/msi-ec/super_battery`
- Description: This entry allows switching the super battery function.
- Access: Read, Write
- Valid values:
- on: super battery function is enabled
- off: super battery function is disabled

- `/sys/devices/platform/msi-ec/available_fan_modes`
- Description: This entry reports all supported fan modes.
- Access: Read
Expand Down
5 changes: 0 additions & 5 deletions docs/sysfs-platform-msi-ec
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ Description:
Valid values: the values present in the available_shift_modes
list.

What: /sys/devices/platform/<platform>/super_battery
Description:
Allows to enable the super battery saving mode.
Valid values: "on", "off"

What: /sys/devices/platform/<platform>/available_fan_modes
Description:
Read-only, shows the list of available fan modes for
Expand Down
6 changes: 0 additions & 6 deletions ec_memory_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ struct msi_ec_shift_mode_conf {
struct msi_ec_mode modes[5]; // fixed size for easier hard coding
};

struct msi_ec_super_battery_conf {
int address;
int mask;
};

struct msi_ec_fan_mode_conf {
int address;
struct msi_ec_mode modes[5]; // fixed size for easier hard coding
Expand Down Expand Up @@ -90,7 +85,6 @@ struct msi_ec_conf {
struct msi_ec_fn_win_swap_conf fn_win_swap;
struct msi_ec_cooler_boost_conf cooler_boost;
struct msi_ec_shift_mode_conf shift_mode;
struct msi_ec_super_battery_conf super_battery;
struct msi_ec_fan_mode_conf fan_mode;
struct msi_ec_cpu_conf cpu;
struct msi_ec_gpu_conf gpu;
Expand Down
130 changes: 4 additions & 126 deletions msi-ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/version.h>
#include <linux/rtc.h>
#include <linux/string_choices.h>

static DEFINE_MUTEX(ec_set_by_mask_mutex);
static DEFINE_MUTEX(ec_unset_by_mask_mutex);
//static DEFINE_MUTEX(ec_set_by_mask_mutex);
//static DEFINE_MUTEX(ec_unset_by_mask_mutex);
static DEFINE_MUTEX(ec_set_bit_mutex);

#define SM_ECO_NAME "eco"
Expand Down Expand Up @@ -92,9 +91,6 @@ static struct msi_ec_conf CONF_G1_0 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN, // 0xd5 needs testing
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -178,9 +174,6 @@ static struct msi_ec_conf CONF_G1_1 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -248,10 +241,6 @@ static struct msi_ec_conf CONF_G1_2 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN, // known. 0xd5.
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -334,10 +323,6 @@ static struct msi_ec_conf CONF_G1_3 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -405,10 +390,6 @@ static struct msi_ec_conf CONF_G1_4 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN, // 0xd5 but has its own set of modes
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -479,10 +460,6 @@ static struct msi_ec_conf CONF_G1_5 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -557,10 +534,6 @@ static struct msi_ec_conf CONF_G1_6 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN, // 0xed
.mask = 0x0f, // a5, a4, a2
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -639,10 +612,6 @@ static struct msi_ec_conf CONF_G1_7 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -709,9 +678,6 @@ static struct msi_ec_conf CONF_G1_8 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP, // enabled by "Super Battery" shift mode
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -783,9 +749,6 @@ static struct msi_ec_conf CONF_G1_9 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -851,9 +814,6 @@ static struct msi_ec_conf CONF_G1_10 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -925,10 +885,6 @@ static struct msi_ec_conf CONF_G1_11 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN, // 0xd5 (automatic switching with shift mode)
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -994,10 +950,6 @@ static struct msi_ec_conf CONF_G1_13 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xd5,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
Expand Down Expand Up @@ -1080,10 +1032,6 @@ static struct msi_ec_conf CONF_G2_0 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1204,10 +1152,6 @@ static struct msi_ec_conf CONF_G2_1 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1296,10 +1240,6 @@ static struct msi_ec_conf CONF_G2_2 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1395,10 +1335,6 @@ static struct msi_ec_conf CONF_G2_3 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1465,10 +1401,6 @@ static struct msi_ec_conf CONF_G2_4 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1541,10 +1473,6 @@ static struct msi_ec_conf CONF_G2_5 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1625,10 +1553,6 @@ static struct msi_ec_conf CONF_G2_6 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1783,10 +1707,6 @@ static struct msi_ec_conf CONF_G2_10 __initdata = {
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
Expand Down Expand Up @@ -1877,6 +1797,7 @@ static int ec_read_seq(u8 addr, u8 *buf, u8 len)
return 0;
}

/*
static int ec_set_by_mask(u8 addr, u8 mask)
{
int result;
Expand Down Expand Up @@ -1926,6 +1847,7 @@ static int ec_check_by_mask(u8 addr, u8 mask, bool *output)

return 0;
}
*/

static int ec_set_bit(u8 addr, u8 bit, bool value)
{
Expand Down Expand Up @@ -2377,45 +2299,6 @@ static ssize_t shift_mode_store(struct device *dev,
return -EINVAL;
}

static ssize_t super_battery_show(struct device *device,
struct device_attribute *attr, char *buf)
{
int result;
bool enabled;

result = ec_check_by_mask(conf.super_battery.address,
conf.super_battery.mask,
&enabled);
if (result < 0)
return result;

return sysfs_emit(buf, "%s\n", str_on_off(enabled));
}

static ssize_t super_battery_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int result;
bool value;

result = kstrtobool(buf, &value);
if (result)
return result;

if (value)
result = ec_set_by_mask(conf.super_battery.address,
conf.super_battery.mask);
else
result = ec_unset_by_mask(conf.super_battery.address,
conf.super_battery.mask);

if (result < 0)
return result;

return count;
}

static ssize_t available_fan_modes_show(struct device *device,
struct device_attribute *attr,
char *buf)
Expand Down Expand Up @@ -2532,7 +2415,6 @@ static DEVICE_ATTR_RW(win_key);
static DEVICE_ATTR_RW(cooler_boost);
static DEVICE_ATTR_RO(available_shift_modes);
static DEVICE_ATTR_RW(shift_mode);
static DEVICE_ATTR_RW(super_battery);
static DEVICE_ATTR_RO(available_fan_modes);
static DEVICE_ATTR_RW(fan_mode);
static DEVICE_ATTR_RO(fw_version);
Expand All @@ -2546,7 +2428,6 @@ static struct attribute *msi_root_attrs[] = {
&dev_attr_cooler_boost.attr,
&dev_attr_available_shift_modes.attr,
&dev_attr_shift_mode.attr,
&dev_attr_super_battery.attr,
&dev_attr_available_fan_modes.attr,
&dev_attr_fan_mode.attr,
&dev_attr_fw_version.attr,
Expand Down Expand Up @@ -2895,9 +2776,6 @@ static umode_t msi_ec_is_visible(struct kobject *kobj,
attr == &dev_attr_shift_mode.attr)
address = conf.shift_mode.address;

else if (attr == &dev_attr_super_battery.attr)
address = conf.super_battery.address;

else if (attr == &dev_attr_available_fan_modes.attr ||
attr == &dev_attr_fan_mode.attr)
address = conf.fan_mode.address;
Expand Down