xref: /openbmc/linux/drivers/platform/x86/msi-ec.h (revision f4356947)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /*
4  * msi-ec: MSI laptops' embedded controller driver.
5  *
6  * Copyright (C) 2023 Jose Angel Pastrana <japp0005@red.ujaen.es>
7  * Copyright (C) 2023 Aakash Singh <mail@singhaakash.dev>
8  * Copyright (C) 2023 Nikita Kravets <teackot@gmail.com>
9  */
10 
11 #ifndef _MSI_EC_H_
12 #define _MSI_EC_H_
13 
14 #include <linux/types.h>
15 
16 #define MSI_EC_DRIVER_NAME "msi-ec"
17 
18 #define MSI_EC_ADDR_UNKNOWN 0xff01 // unknown address
19 #define MSI_EC_ADDR_UNSUPP  0xff01 // unsupported parameter
20 
21 // Firmware info addresses are universal
22 #define MSI_EC_FW_VERSION_ADDRESS 0xa0
23 #define MSI_EC_FW_DATE_ADDRESS    0xac
24 #define MSI_EC_FW_TIME_ADDRESS    0xb4
25 #define MSI_EC_FW_VERSION_LENGTH  12
26 #define MSI_EC_FW_DATE_LENGTH     8
27 #define MSI_EC_FW_TIME_LENGTH     8
28 
29 struct msi_ec_charge_control_conf {
30 	int address;
31 	int offset_start;
32 	int offset_end;
33 	int range_min;
34 	int range_max;
35 };
36 
37 struct msi_ec_webcam_conf {
38 	int address;
39 	int block_address;
40 	int bit;
41 };
42 
43 struct msi_ec_fn_super_swap_conf {
44 	int address;
45 	int bit;
46 };
47 
48 struct msi_ec_cooler_boost_conf {
49 	int address;
50 	int bit;
51 };
52 
53 #define MSI_EC_MODE_NULL { NULL, 0 }
54 struct msi_ec_mode {
55 	const char *name;
56 	int value;
57 };
58 
59 struct msi_ec_shift_mode_conf {
60 	int address;
61 	struct msi_ec_mode modes[5]; // fixed size for easier hard coding
62 };
63 
64 struct msi_ec_super_battery_conf {
65 	int address;
66 	int mask;
67 };
68 
69 struct msi_ec_fan_mode_conf {
70 	int address;
71 	struct msi_ec_mode modes[5]; // fixed size for easier hard coding
72 };
73 
74 struct msi_ec_cpu_conf {
75 	int rt_temp_address;
76 	int rt_fan_speed_address; // realtime
77 	int rt_fan_speed_base_min;
78 	int rt_fan_speed_base_max;
79 	int bs_fan_speed_address; // basic
80 	int bs_fan_speed_base_min;
81 	int bs_fan_speed_base_max;
82 };
83 
84 struct msi_ec_gpu_conf {
85 	int rt_temp_address;
86 	int rt_fan_speed_address; // realtime
87 };
88 
89 struct msi_ec_led_conf {
90 	int micmute_led_address;
91 	int mute_led_address;
92 	int bit;
93 };
94 
95 #define MSI_EC_KBD_BL_STATE_MASK 0x3
96 struct msi_ec_kbd_bl_conf {
97 	int bl_mode_address;
98 	int bl_modes[2];
99 	int max_mode;
100 
101 	int bl_state_address;
102 	int state_base_value;
103 	int max_state;
104 };
105 
106 struct msi_ec_conf {
107 	const char * const *allowed_fw;
108 
109 	struct msi_ec_charge_control_conf charge_control;
110 	struct msi_ec_webcam_conf         webcam;
111 	struct msi_ec_fn_super_swap_conf  fn_super_swap;
112 	struct msi_ec_cooler_boost_conf   cooler_boost;
113 	struct msi_ec_shift_mode_conf     shift_mode;
114 	struct msi_ec_super_battery_conf  super_battery;
115 	struct msi_ec_fan_mode_conf       fan_mode;
116 	struct msi_ec_cpu_conf            cpu;
117 	struct msi_ec_gpu_conf            gpu;
118 	struct msi_ec_led_conf            leds;
119 	struct msi_ec_kbd_bl_conf         kbd_bl;
120 };
121 
122 #endif // _MSI_EC_H_
123