Quelle msi-ec.c
Sprache: C
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* msi-ec: MSI laptops' embedded controller driver.
*
* This driver allows various MSI laptops' functionalities to be
* controlled from userspace.
*
* It contains EC memory configurations for different firmware versions
* and exports battery charge thresholds to userspace.
*
* Copyright (C) 2023 Jose Angel Pastrana <japp0005@red.ujaen.es>
* Copyright (C) 2023 Aakash Singh <mail@singhaakash.dev>
* Copyright (C) 2023 Nikita Kravets <teackot@gmail.com>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "msi-ec.h"
#include <acpi/battery.h>
#include <linux/acpi.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/seq_file.h>
#include <linux/string.h>
#define SM_ECO_NAME "eco"
#define SM_COMFORT_NAME "comfort"
#define SM_SPORT_NAME "sport"
#define SM_TURBO_NAME "turbo"
#define FM_AUTO_NAME "auto"
#define FM_SILENT_NAME "silent"
#define FM_BASIC_NAME "basic"
#define FM_ADVANCED_NAME "advanced"
static const char * const ALLOWED_FW_0[] __initconst = {
"14C1EMS1.012",
"14C1EMS1.101",
"14C1EMS1.102",
NULL
};
static struct msi_ec_conf CONF0 __initdata = {
.allowed_fw = ALLOWED_FW_0,
.charge_control = {
.address = 0xef,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = 0xbf,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN, // 0xd5 needs testing
},
.fan_mode = {
.address = 0xf4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_BASIC_NAME, 0x4d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71,
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = 0x89,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = 0x89,
},
.leds = {
.micmute_led_address = 0x2b,
.mute_led_address = 0x2c,
.bit = 2,
},
.kbd_bl = {
.bl_mode_address = 0x2c, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = 0xf3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_1[] __initconst = {
"17F2EMS1.103",
"17F2EMS1.104",
"17F2EMS1.106",
"17F2EMS1.107",
NULL
};
static struct msi_ec_conf CONF1 __initdata = {
.allowed_fw = ALLOWED_FW_1,
.charge_control = {
.address = 0xef,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = 0xbf,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
{ SM_TURBO_NAME, 0xc4 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN,
},
.fan_mode = {
.address = 0xf4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_BASIC_NAME, 0x4d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71,
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = 0x89,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = 0x89,
},
.leds = {
.micmute_led_address = 0x2b,
.mute_led_address = 0x2c,
.bit = 2,
},
.kbd_bl = {
.bl_mode_address = 0x2c, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = 0xf3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_2[] __initconst = {
"1552EMS1.118",
NULL
};
static struct msi_ec_conf CONF2 __initdata = {
.allowed_fw = ALLOWED_FW_2,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = 0xe8,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_BASIC_NAME, 0x4d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71,
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = 0x89,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = 0x89,
},
.leds = {
.micmute_led_address = 0x2c,
.mute_led_address = 0x2d,
.bit = 1,
},
.kbd_bl = {
.bl_mode_address = 0x2c, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = 0xd3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_3[] __initconst = {
"1592EMS1.111",
NULL
};
static struct msi_ec_conf CONF3 __initdata = {
.allowed_fw = ALLOWED_FW_3,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = 0xe8,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xd2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_BASIC_NAME, 0x4d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0xc9,
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = 0x89, // ?
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = 0x89,
},
.leds = {
.micmute_led_address = 0x2b,
.mute_led_address = 0x2c,
.bit = 1,
},
.kbd_bl = {
.bl_mode_address = 0x2c, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = 0xd3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_4[] __initconst = {
"16V4EMS1.114",
NULL
};
static struct msi_ec_conf CONF4 __initdata = {
.allowed_fw = ALLOWED_FW_4,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = MSI_EC_ADDR_UNKNOWN, // supported, but unknown
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xd2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
MSI_EC_MODE_NULL
},
},
.super_battery = { // may be supported, but address is unknown
.address = MSI_EC_ADDR_UNKNOWN,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68, // needs testing
.rt_fan_speed_address = 0x71, // needs testing
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = MSI_EC_ADDR_UNKNOWN,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = MSI_EC_ADDR_UNKNOWN,
},
.leds = {
.micmute_led_address = MSI_EC_ADDR_UNKNOWN,
.mute_led_address = MSI_EC_ADDR_UNKNOWN,
.bit = 1,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNKNOWN, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = MSI_EC_ADDR_UNSUPP, // 0xd3, not functional
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_5[] __initconst = {
"158LEMS1.103",
"158LEMS1.105",
"158LEMS1.106",
NULL
};
static struct msi_ec_conf CONF5 __initdata = {
.allowed_fw = ALLOWED_FW_5,
.charge_control = {
.address = 0xef,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = { // todo: reverse
.address = 0xbf,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_TURBO_NAME, 0xc4 },
MSI_EC_MODE_NULL
},
},
.super_battery = { // unsupported?
.address = MSI_EC_ADDR_UNKNOWN,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68, // needs testing
.rt_fan_speed_address = 0x71, // needs testing
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = MSI_EC_ADDR_UNKNOWN,
.rt_fan_speed_address = MSI_EC_ADDR_UNKNOWN,
},
.leds = {
.micmute_led_address = 0x2b,
.mute_led_address = 0x2c,
.bit = 2,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNKNOWN, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = MSI_EC_ADDR_UNSUPP, // 0xf3, not functional
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_6[] __initconst = {
"1542EMS1.102",
"1542EMS1.104",
NULL
};
static struct msi_ec_conf CONF6 __initdata = {
.allowed_fw = ALLOWED_FW_6,
.charge_control = {
.address = 0xef,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = MSI_EC_ADDR_UNSUPP,
.bit = 1,
},
.fn_win_swap = {
.address = 0xbf, // todo: reverse
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
{ SM_TURBO_NAME, 0xc4 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xd5,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0xc9,
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = MSI_EC_ADDR_UNKNOWN,
},
.leds = {
.micmute_led_address = MSI_EC_ADDR_UNSUPP,
.mute_led_address = MSI_EC_ADDR_UNSUPP,
.bit = 2,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNKNOWN, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = MSI_EC_ADDR_UNSUPP, // 0xf3, not functional
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_7[] __initconst = {
"17FKEMS1.108",
"17FKEMS1.109",
"17FKEMS1.10A",
NULL
};
static struct msi_ec_conf CONF7 __initdata = {
.allowed_fw = ALLOWED_FW_7,
.charge_control = {
.address = 0xef,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = MSI_EC_ADDR_UNSUPP,
.bit = 1,
},
.fn_win_swap = {
.address = 0xbf, // needs testing
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
{ SM_TURBO_NAME, 0xc4 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN, // 0xd5 but has its own wet of modes
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
{ FM_AUTO_NAME, 0x0d }, // d may not be relevant
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0xc9, // needs testing
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = MSI_EC_ADDR_UNKNOWN,
.rt_fan_speed_address = MSI_EC_ADDR_UNKNOWN,
},
.leds = {
.micmute_led_address = MSI_EC_ADDR_UNSUPP,
.mute_led_address = 0x2c,
.bit = 2,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNKNOWN, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = 0xf3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_8[] __initconst = {
"14F1EMS1.115",
NULL
};
static struct msi_ec_conf CONF8 __initdata = {
.allowed_fw = ALLOWED_FW_8,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = MSI_EC_ADDR_UNSUPP,
.bit = 1,
},
.fn_win_swap = {
.address = 0xe8,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xd2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
.fan_mode = {
.address = 0xd4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_BASIC_NAME, 0x4d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71,
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = MSI_EC_ADDR_UNKNOWN,
.rt_fan_speed_address = MSI_EC_ADDR_UNKNOWN,
},
.leds = {
.micmute_led_address = MSI_EC_ADDR_UNSUPP,
.mute_led_address = 0x2d,
.bit = 1,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNKNOWN, // ?
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.bl_state_address = MSI_EC_ADDR_UNSUPP, // not functional
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_9[] __initconst = {
"14JKEMS1.104",
NULL
};
static struct msi_ec_conf CONF9 __initdata = {
.allowed_fw = ALLOWED_FW_9,
.charge_control = {
.address = 0xef,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = 0xbf,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP, // unsupported or enabled by ECO shift
.mask = 0x0f,
},
.fan_mode = {
.address = 0xf4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71,
.rt_fan_speed_base_min = 0x00,
.rt_fan_speed_base_max = 0x96,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = MSI_EC_ADDR_UNSUPP,
.rt_fan_speed_address = MSI_EC_ADDR_UNSUPP,
},
.leds = {
.micmute_led_address = 0x2b,
.mute_led_address = 0x2c,
.bit = 2,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNSUPP, // not presented in MSI app
.bl_modes = { 0x00, 0x08 },
.max_mode = 1,
.bl_state_address = 0xf3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_10[] __initconst = {
"1582EMS1.107", // GF66 11UC
NULL
};
static struct msi_ec_conf CONF10 __initdata = {
.allowed_fw = ALLOWED_FW_10,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = MSI_EC_ADDR_UNSUPP,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xd2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0
{ SM_SPORT_NAME, 0xc0 },
{ SM_TURBO_NAME, 0xc4 },
*
},
},
.super_battery* controlledfrom
.address*
mask = 0x0f
},
.fan_mode = {
. and exportscharge java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 54
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME, 0 Copyright ( 2023 Nikita Kravets <teackot@gmail.com>
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71, // ?
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = MSI_EC_ADDR_UNKNOWN, // ?
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
. = {
.rt_temp_address = 0x80,
.#include/ernelh
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
.leds = {
.micmute_led_address = 0x2c,
.#defineSM_SPORT_NAME "sport"
b =1,
},
.kbd_bl = {
.bl_mode_address =0x2cjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
.bl_modes = { 0x00, 0x08 },
.max_mode = 1,
.bl_state_address = 0xd3,
.state_base_value = 0x80,
.max_state = 3,
},
};
staticconst ALLOWED_FW_11[ __initconst ={
"16S6EMS1.11,// Prestige 15 a11scx
14C1EMS1.02,
NULL
};
static struct msi_ec_conf CONF11 __initdata = {
.allowed_fw = ALLOWED_FW_11,
.java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
,
. x8a
.ffset_end 0x80,
.range_min x8a,
.range_max = 0xe4,
},
.webcam = {
,
.block_address = MSI_EC_ADDR_UNKNOWN,
.bit = 1,
},
.fn_win_swap = {
.address = 0xe8,
.bit = 4,
},
.cooler_boost = java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
.address x98,
bit = ,
},
.shift_mode =java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
address = 0xd2,
.address = 0xf2,
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{SM_SPORT_NAME, 0xc0 },
MSI_EC_MODE_NULL
,
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
. = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
.ddress = 0xeb,
.mask = 0x0f,
},
.,
. .address.ddress = 0xf4,
.modes .modes {
{FM_AUTO_NAME, 0x0d },
{ {FM_SILENT_NAME,0 ,
{FM_ADVANCED_NAME, 0x4d },
MSI_EC_MODE_NULL
,
} ,
.cpu ={
.rt_temp_address = 0x68,
=MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
.pu= java.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 9
.t_temp_address = MSI_EC_ADDR_UNSUPP,
bs_fan_speed_base_max =0,
},
.leds = {
micmute_led_address = 0x2c,
.mute_led_address = 0x2d,
bit 1java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
},
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 12
bl_mode_address = MSI_EC_ADDR_UNKNOWN,
.bl_modes = {}, // ?
.max_mode 1, // ?
bl_modes = { 0x00, 0x08 }, // ?
state_base_value = 0x80
.max_state .bl_state_address = 0xf3,
},
};
static}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
"16R6EMS1.104", // GF63 Thin 11UC
NULL
};
static struct msi_ec_conf CONF12 __initdata = {
.allowed_fw = ALLOWED_FW_12,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = 0xe8,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xd2,
.modes = {
{ SM_ECO_NAME, 0xc2 },
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
{ SM_TURBO_NAME, 0xc4 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP, // 0xeb
.mask = 0x0f, // 00, 0f
},
.fan_mode = {
.address = 0xd4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME,0x8d },
MSI_EC_MODE_NULL
},
},
cpu ={
."17F2EMS1.107,
.rt_fan_speed_address = 0x71,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.=0x80,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP, .range_min =0x8a,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = block_address = x2f
.rt_temp_address = ,
.rt_fan_speed_address = 0x89,
},
.leds = {
.micmute_led_address = MSI_EC_ADDR_UNSUPP,
.mute_led_address = 0x2d,
.bit = 1,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNKNOWN,
.bl_modes = { 0x00, 0x08 },
.max_mode = 1,
.bl_state_address = 0xd3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_13[] __initconst = {
"1594EMS1.109", // MSI Prestige 16 Studio A13VE
NULL
};
static struct msi_ec_conf CONF13 __initdata = {
.allowed_fw = ALLOWED_FW_13,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap = {
.address = 0xe8,
.bit = 4, // 0x00-0x10
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xd2,
.modes = {
{ SM_ECO_NAME, 0xc2 }, // super battery
{ SM_COMFORT_NAME, 0xc1 }, // balanced
{ SM_TURBO_NAME, 0xc4 }, // extreme
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = MSI_EC_ADDR_UNSUPP,
.mask = 0x0f, // 00, 0f
},
.fan_mode = {
.address = 0xd4,
.modes = {
{ FM_AUTO_NAME, 0x0d },
{ FM_SILENT_NAME, 0x1d },
{ FM_ADVANCED_NAME, 0x8d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71, // 0x0-0x96
.rt_fan_speed_base_min = 0x00,
.rt_fan_speed_base_max = 0x96,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_base_min = 0x00,
.bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 18
{ SM_ECO_NAME, 0xc2}java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
.eds = {
.micmute_led_address = 0x2c,
mute_led_address = 0x2d,
}java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
.kbd_bl={
.bl_mode_address = address = 0xf4,
.l_modes ={0x00, 0x08},// always on; off after 10 sec
.max_mode = 1,
.bl_state_address = x,
.state_base_value}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
.max_state =3
}
};
static struct msi_ec_conf * .bs_fan_speed_base_max = 0x0fbs_fan_speed_base_max 0java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
&CONF0=leds = {
.ute_led_address = 0x2c,
.bit =2
&CONF3,
&ONF4
&CONF5,
&CONF6,
&java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
&
&CONF9,
&CONF10,
&CONF11,
,
&range_ x
NULL
};
static struct msi_ec_conf}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/*
* Helper functions
*/
static int ec_read_seq(u8 addr, u8 *buf, java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 12
{
int result;
for (u8i = 0 <; i++)
result = ec_read(addr + i, buf + i);
if (result < 0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
return result;
}
return 0;
}
static int java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 18
{
int .fan_mode = java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
.modes = {
= ec_read_seq(SI_EC_FW_VERSION_ADDRESS,
buf,
MSI_EC_FW_VERSION_LENGTH);
if (result < 0)
return result;
return MSI_EC_FW_VERSION_LENGTH + 1;
}
/*
Sysfssubsystem
*/
static ssize_t charge_control_threshold_show(u8 offset,
java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 3
.rt_temp_address = 0x68,
char=0
{
u8 java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
int result;
result = .bs_fan_speed_b=0x00java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
if }java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return resultjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
return sysfs_emit .={
}
static ssize_t charge_control_threshold_store(u8 .micmute_led_address 0x2c,
device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
u8 wdata;
.bl_mode_address = 0x2c
result kstrtou8(buf 10,&wdata);
if (result < 0)
return result;
wdata += offset;
if (wdata < conf.charge_control.range_min ||
wdata >confcjava.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 43
return -EINVAL;
}
static* const ALLOWED_FW_3[ _initconst java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
return ;
return count;
}
static ssize_t charge_control_start_threshold_show(struct device *device,
struct device_attribute attr,
char *buf)
{
return charge_control_threshold_show(conf.charge_control.offset_start,
.charge_control= {
}
static ssize_t charge_control_start_threshold_store( .= 0x8a,
struct device_attribute *attr
const char *buf, size_t count)
{
return charge_control_threshold_store(conf.java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 23
dev, attr, buf, .webcam = java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}
staticssize_t charge_control_end_threshold_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 3
device, .address =0xe8,
}
static ssize_t
structdevice_attribute *attr,
const char *buf, size_t count)
{
return charge_control_threshold_store(confcharge_control.ffset_end,
dev, attr, buf, count);
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
staticDEVICE_ATTR_RW(charge_control_start_threshold);
static DEVICE_ATTR_RW(charge_control_end_threshold);
static struct attribute *msi_battery_attrs[] = {
&dev_attr_charge_control_start_threshold.attr,
&dev_attr_charge_control_end_threshold {SM_COMFORT_NAME,0xc1}
{SM_SPORT_NAME, 0xc0 },
};
ATTRIBUTE_GROUPSm;
static }
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
{
return device_add_groups(&battery->dev, msi_battery_groups)
}
static int java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 14
struct acpi_battery_hook *hook)
{ {FM_AUTO_NAME x0d }
{ FM_SILENT_NAME0java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 30
return 0;
}
static struct acpi_battery_hook battery_hook = {
.add_battery =java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
.remove_battery = msi_battery_remove,
.}java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
;
/*
* Module load/unload
*/
static const struct dmi_system_id msi_dmi_table[] __initconst __maybe_unused = {
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT.= x89 // ?
} .bs_fan_speed_base_min = x00
}.java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 32
{
.atches {
DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
},
},
{}
};
MODULE_DEVICE_TABLEdmi,msi_dmi_table)
static m= x2cjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
{
intresultjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
u8 fw_version[ .bl_modes= {0x00,0 ,// ?
/* get firmware version */max_mode= 1,// ?
result .bl_state_address =xd3
if .state_base_value = 0x80,
return .ax_state = 3,
/* load the suitable configuration, if exists */
for(nti=; i;i+){
if (match_string(CONFIGS[i]->allowed_fw, -1, fw_version) != -EINVAL) {
conf = *java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 5
conf.allowed_fw = NULL;
return 0;
}
}
/* config not found */
for (int i = 0; i < java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 23
if(isgraph(fw_versioni])
pr_warn("Unable to find a valid firmware version!\n");
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 22
}
}
.block_address = 0x2f,
return -EOPNOTSUPP;
}
static int __init msi_ec_init(void)
{
int result;
result = load_configuration();
if (result < 0)
return result;
}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 10
}
static void __exit msi_ec_exit(void)
{
battery_hook_unregister .ddress= 0xd2,
}
. {
{SM_ECO_NAME 0c2}
MODULE_AUTHOR("Aakash Singh < {SM_COMFORT_NAME,0 ,
MODULE_AUTHOR("Nikita Kravets <teackot@gmail.com>");
MODULE_DESCRIPTION("MSI Embedded Controller");
module_init(msi_ec_init);
module_exit(msi_ec_exit);
¤ Dauer der Verarbeitung: 0.27 Sekunden
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|