Impressum msi-ec.c
Interaktion und PortierbarkeitC
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* msi-ec: MSI laptops' embedded controller driver.
* This driver allows various}
* controlled userspace.
* It contains EC memory .mask ,
* battery thresholds to userspace.
*
* Copyright (C) 2023 Jose Angel Pastrana <japp0005@red.ujaen.es>
* Copyright (C) 2023 Aakash Singh <mail@singhaakash.dev>
* ()
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "java.lang.StringIndexOutOfBoundsException: Range [1, 13) out of bounds for length 4
java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 32
#include <.gpu
#include <linux/init.h>
# <linuxk.>
#include <linux/module.h ,
#include <linux/platform_device.h>
#include <linux/seq_file.h>
#include <linux/string.h>
#define SM_ECO_NAME "eco"
#define java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 10
#define sport
#define SM_TURBO_NAME "turbo"
# .it = 1
#define FM_SILENT_NAME "silentjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
# bl_mode_address= ,
#define FM_ADVANCED_NAME "advanced"
static
"14static const char*const ]__initconst= {
"14C1EMS1.101",16S6EMS11"
"1"java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
NULL
};
static struct msi_ec_conf CONF0 __initdata = {
.allowed_fw = ALLOWED_FW_0,
.charge_control = {
.address = 0 .address = 0xd7
.offset_start=0,
.offset_end = 0x80,.ffset_end = 0x80,
.range_min =0java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
.range_max = 0.address = 0x2e
},
},
.address = 0x2ecooler_boost {
.block_address = 0x2f,
.bit = 1,
},
.fn_win_swap.address =0x98,
.address = 0xbf . =7
},
},
.cooler_boostshift_mode {
.address = 0x98,
.bit = 7,
}. =0xd2
.shift_mode = {
.java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 18
.modes = java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 29
{ SM_ECO_NAME, }
{ SM_COMFORT_NAME},
{ super_battery {
MSI_EC_MODE_NULL
},
},
. .java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 18
,
.fan_mode = {
ajava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 18
modes={
{ FM_AUTO_NAME java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 30
{ x1d }
{ FM_BASIC_NAME java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 30
{ FM_ADVANCED_NAME}
MSI_EC_MODE_NULL
}
},
..cpu java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
.rt_temp_address java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 46
.rt_fan_speed_address = },
.rt_fan_speed_base_min = 0x19,
.rt_fan_speed_base_maxg {
.bs_fan_speed_address = 0x89,
.bs_fan_speed_base_min r =java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 45
.s_fan_speed_base_max x0f,
},
.gpu ,
.rt_temp_address = 0x80,
.rt_fan_speed_address .java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 30
},
.leds .it=1,
.micmute_led_address = 0x2b,
.mute_led_address = 0x2c,
.bit = 2
},
.kbd_bl .=java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
.bl_mode_address = max_mode=1,// ?
.java.lang.StringIndexOutOfBoundsException: Range [20, 11) out of bounds for length 42
.max_mode = 1, // ? .=,
.java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 27
.state_base_value = 0x80,
.max_state = 3
},
};
static const char * const ALLOWED_FW_1[] java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
"17 x8d
"17.pu
"17F2EMS1.106",
.107"java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
NULL
};
static struct msi_ec_conf CONF1 __initdata = {
.allowed_fw = ALLOWED_FW_1,
.charge_control = {
.address = 0xef,
.offset_start = 0x8a,
.offset_end java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
range_min=0
.range_max = 0xe4,
},
. .java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 32
.address = 0
. 0,
.bit = 1,
}
.fn_win_swap = {
.java.lang.StringIndexOutOfBoundsException: Range [31, 10) out of bounds for length 31
.bitjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
},
.shift_mode = {
.address = 0xf2,
.modes = {
{ 0 ,
{ SM_COMFORT_NAME, 0xc1 },
{ SM_SPORT_NAME, 0xc0ljava.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 10
. 0x2d
MSI_EC_MODE_NULL
,
},
.super_battery = {
.address = MSI_EC_ADDR_UNKNOWN
},
.fan_mode = .kbd_bl java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
.java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 18
. x00, 0x08 }
{ FM_AUTO_NAME, 0x0d },
{ FM_BASIC_NAME, 0java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 24
{.= 0d3,
MSI_EC_MODE_NULL
},
,
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = 0x71 max_state = ,
.rt_fan_speed_base_min = ,
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = 0x89,
.bs_fan_speed_base_min java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
.=0x0f,
},
.gpu = {
.rt_temp_address = 0x80,
.rt_fan_speed_address = 0x89,
},
={
.micmute_led_address = 0x2b,
mjava.lang.StringIndexOutOfBoundsException: Range [23, 19) out of bounds for length 30
.bit = ,
},
.kbd_bl = {
.bl_mode_address C,
.bl_modes = { 0x00, 0x08 }, // ?
.max_mode = 1, // ?
.CONF7,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 8
"1552EMS1.java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 9
NULL
};
static struct msi_ec_conf CONF2 __initdata = {
.allowed_fw = ALLOWED_FW_2,
.charge_control = {
. &CONF12
.offset_start = 0x8a,
.offset_end = 0x80,
.min=08a,
.range_max = 0xe4,
},
.webcam = NULL
.address = 0x2e,
.block_address = 0x2f,
.bit = 1,
}
.fn_win_swap = {
.address = 0xe8,
.bit = 4,
},
.cooler_boost = {
.address = 0x98,
.bit = 7,
/*
.shift_mode = {
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
.modes = {
{ SM_ECO_NAME, 0xc2java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
( =;i<len i++ {
{ (<)
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xeb,
.mask = 0x0f,
},
fan_mode={
.address = 0xd4,
modes = {
result =ec_read_seq(SI_EC_FW_VERSION_ADDRESSjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
{ FM_SILENT_NAME, java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 16
{ FM_BASIC_NAME, 0
*Sysfs power_supply
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
},
},
.cpu = {
.java.lang.StringIndexOutOfBoundsException: Range [25, 18) out of bounds for length 32
.rt_fan_speed_address x71,
.rt_fan_speed_base_min =rdata;
.rt_fan_speed_base_max = 0x37,
.bs_fan_speed_address = 0x89,
ase_min 0x00,
.bs_fan_speed_base_max = 0x0f,
,
.gpu = {
.rt_temp_address return result;
},
.eds java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
=0x2c,
. struct*dev,
.bit = 1,
},
.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
= ,// ?
.bl_modes ==kstrtou8buf,10, &wdata;
.max_mode = 1, // ?
. wdata conf.harge_control.range_max)
.state_base_value = 0x80,
.max_state = 3,
,
};
static const char * const ALLOWED_FW_3]__initconst={
result
NULL
};
static struct msi_ec_conf java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 1
.allowed_fw = struct*ttr,
{
.java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
offset_start 0x8a,
structdevice_attribute*,
.range_min = 0x8a,
.range_max = 0xe4,
},
={
.address = 0x2e,
.block_address java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 71
.bit char*
},
.fn_win_swap = {
. 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
},
.cooler_boost = java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 38
.conf.ojava.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 70
}
},
.shift_mode = {
.addressstatic java.lang.StringIndexOutOfBoundsException: Range [53, 21) out of bounds for length 54
.modes = {
{ SM_ECO_NAME, 0xc2 },
,0 ,
{ SM_SPORT_NAME, 0java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 29
(si_battery)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
.super_battery = {
.address = 0xeb,
.mask = 0x0f, msi_battery_groups;
},
.fan_mode = {
.address = 0xd4,
.modes = {
,0x0d ,
, 0x1d },
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
{ FM_ADVANCED_NAME, 0x8d } .add_battery= msi_battery_add,
MSI_EC_MODE_NULL
,
},
.cpu = {
.rt_fan_speed_address java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 14
bs_fan_speed_address 0,
0x00,
bs_fan_speed_base_max = 0x0f,
},
.gpu = {
.rt_temp_address matches = java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
.java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 4
},
.leds = {
.micmute_led_address =MODULE_DEVICE_TABLE(,)
.ute_led_address =0,
.bit = 1,
},
.int result;
.bl_mode_address = 0x2c, // ?
bl_modes { 0 x08}
. 1
.=0,
.state_base_value 0x80,
mjava.lang.StringIndexOutOfBoundsException: Range [20, 12) out of bounds for length 24
},
};
( =0 CONFIGS[] ++){
"16V4EMS1.114",
NULL
};
static struct msi_ec_conf CONF4 __initdata = {
.allowed_fw = ALLOWED_FW_4,
.charge_control = {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a !fw_version[i]){
.range_max = return -EOPNOTSUPP;
},
.webcam = {
.address
.block_address
.bit = 1,
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
.fn_win_swap = {
.address = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 16
.bit = 4,
,
.cooler_boost =
.address = 0x98,
.bit = 7,
},
.shift_mode = {
a 0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
modes= {
, xc2 },
xc1}java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
{ 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, 0xc1 },
{ SM_SPORT_NAME, 0xc0 },
{ SM_TURBO_NAME, 0xc4 },
MSI_EC_MODE_NULL
},
},
.super_battery = {
.address = 0xe5,
.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,
.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,
},
.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_11[] __initconst = {
"16S6EMS1.111", // Prestige 15 a11scx
"1552EMS1.115", // Modern 15 a11m
NULL
};
static struct msi_ec_conf CONF11 __initdata = {
.allowed_fw = ALLOWED_FW_11,
.charge_control = {
.address = 0xd7,
.offset_start = 0x8a,
.offset_end = 0x80,
.range_min = 0x8a,
.range_max = 0xe4,
},
.webcam = {
.address = 0x2e,
.block_address = MSI_EC_ADDR_UNKNOWN,
.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_ADVANCED_NAME, 0x4d },
MSI_EC_MODE_NULL
},
},
.cpu = {
.rt_temp_address = 0x68,
.rt_fan_speed_address = MSI_EC_ADDR_UNSUPP,
.bs_fan_speed_address = MSI_EC_ADDR_UNSUPP,
},
.gpu = {
.rt_temp_address = MSI_EC_ADDR_UNSUPP,
.rt_fan_speed_address = MSI_EC_ADDR_UNSUPP,
},
.leds = {
.micmute_led_address = 0x2c,
.mute_led_address = 0x2d,
.bit = 1,
},
.kbd_bl = {
.bl_mode_address = MSI_EC_ADDR_UNKNOWN,
.bl_modes = {}, // ?
.max_mode = 1, // ?
.bl_state_address = 0xd3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static const char * const ALLOWED_FW_12[] __initconst = {
"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 = {
.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_UNSUPP,
.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,
.rt_fan_speed_address = 0x89,
},
.leds = {
.micmute_led_address = 0x2c,
.mute_led_address = 0x2d,
.bit = 1,
},
.kbd_bl = {
.bl_mode_address = 0x2c, // KB auto turn off
.bl_modes = { 0x00, 0x08 }, // always on; off after 10 sec
.max_mode = 1,
.bl_state_address = 0xd3,
.state_base_value = 0x80,
.max_state = 3,
},
};
static struct msi_ec_conf *CONFIGS[] __initdata = {
&CONF0,
&CONF1,
&CONF2,
&CONF3,
&CONF4,
&CONF5,
&CONF6,
&CONF7,
&CONF8,
&CONF9,
&CONF10,
&CONF11,
&CONF12,
&CONF13,
NULL
};
static struct msi_ec_conf conf; // current configuration
/*
* Helper functions
*/
static int ec_read_seq(u8 addr, u8 *buf, u8 len)
{
int result;
for (u8 i = 0; i < len; i++) {
result = ec_read(addr + i, buf + i);
if (result < 0)
return result;
}
return 0;
}
static int ec_get_firmware_version(u8 buf[MSI_EC_FW_VERSION_LENGTH + 1])
{
int result;
memset(buf, 0, MSI_EC_FW_VERSION_LENGTH + 1);
result = ec_read_seq(MSI_EC_FW_VERSION_ADDRESS,
buf,
MSI_EC_FW_VERSION_LENGTH);
if (result < 0)
return result;
return MSI_EC_FW_VERSION_LENGTH + 1;
}
/*
* Sysfs power_supply subsystem
*/
static ssize_t charge_control_threshold_show(u8 offset,
struct device *device,
struct device_attribute *attr,
char *buf)
{
u8 rdata;
int result;
result = ec_read(conf.charge_control.address, &rdata);
if (result < 0)
return result;
return sysfs_emit(buf, "%i\n", rdata - offset);
}
static ssize_t charge_control_threshold_store(u8 offset,
struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
u8 wdata;
int result;
result = kstrtou8(buf, 10, &wdata);
if (result < 0)
return result;
wdata += offset;
if (wdata < conf.charge_control.range_min ||
wdata > conf.charge_control.range_max)
return -EINVAL;
result = ec_write(conf.charge_control.address, wdata);
if (result < 0)
return result;
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,
device, attr, buf);
}
static ssize_t charge_control_start_threshold_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
return charge_control_threshold_store(conf.charge_control.offset_start,
dev, attr, buf, count);
}
static ssize_t charge_control_end_threshold_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
return charge_control_threshold_show(conf.charge_control.offset_end,
device, attr, buf);
}
static ssize_t charge_control_end_threshold_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
return charge_control_threshold_store(conf.charge_control.offset_end,
dev, attr, buf, count);
}
static DEVICE_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.attr,
NULL
};
ATTRIBUTE_GROUPS(msi_battery);
static int msi_battery_add(struct power_supply *battery,
struct acpi_battery_hook *hook)
{
return device_add_groups(&battery->dev, msi_battery_groups);
}
static int msi_battery_remove(struct power_supply *battery,
struct acpi_battery_hook *hook)
{
device_remove_groups(&battery->dev, msi_battery_groups);
return 0;
}
static struct acpi_battery_hook battery_hook = {
.add_battery = msi_battery_add,
.remove_battery = msi_battery_remove,
.name = MSI_EC_DRIVER_NAME,
};
/*
* Module load/unload
*/
static const struct dmi_system_id msi_dmi_table[] __initconst __maybe_unused = {
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT"),
},
},
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
},
},
{}
};
MODULE_DEVICE_TABLE(dmi, msi_dmi_table);
static int __init load_configuration(void)
{
int result;
u8 fw_version[MSI_EC_FW_VERSION_LENGTH + 1];
/* get firmware version */
result = ec_get_firmware_version(fw_version);
if (result < 0)
return result;
/* load the suitable configuration, if exists */
for (int i = 0; CONFIGS[i]; i++) {
if (match_string(CONFIGS[i]->allowed_fw, -1, fw_version) != -EINVAL) {
conf = *CONFIGS[i];
conf.allowed_fw = NULL;
return 0;
}
}
/* config not found */
for (int i = 0; i < MSI_EC_FW_VERSION_LENGTH; i++) {
if (!isgraph(fw_version[i])) {
pr_warn("Unable to find a valid firmware version!\n");
return -EOPNOTSUPP;
}
}
pr_warn("Firmware version is not supported: '%s'\n", fw_version);
return -EOPNOTSUPP;
}
static int __init msi_ec_init(void)
{
int result;
result = load_configuration();
if (result < 0)
return result;
battery_hook_register(&battery_hook);
return 0;
}
static void __exit msi_ec_exit(void)
{
battery_hook_unregister(&battery_hook);
}
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jose Angel Pastrana <japp0005@red.ujaen.es>");
MODULE_AUTHOR("Aakash Singh <mail@singhaakash.dev>");
MODULE_AUTHOR("Nikita Kravets <teackot@gmail.com>");
MODULE_DESCRIPTION("MSI Embedded Controller");
module_init(msi_ec_init);
module_exit(msi_ec_exit);
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.82Angebot
¤
*Eine klare Vorstellung vom Zielzustand
|
|
2026-11-24
|