xref: /openbmc/linux/drivers/platform/x86/think-lmi.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1a40cd7efSMark Pearson /* SPDX-License-Identifier: GPL-2.0-or-later */
2a40cd7efSMark Pearson 
3a40cd7efSMark Pearson #ifndef _THINK_LMI_H_
4a40cd7efSMark Pearson #define _THINK_LMI_H_
5a40cd7efSMark Pearson 
6a40cd7efSMark Pearson #include <linux/types.h>
7a40cd7efSMark Pearson 
8a40cd7efSMark Pearson #define TLMI_SETTINGS_COUNT  256
9a40cd7efSMark Pearson #define TLMI_SETTINGS_MAXLEN 512
10a40cd7efSMark Pearson #define TLMI_PWD_BUFSIZE     129
11a40cd7efSMark Pearson #define TLMI_LANG_MAXLEN       4
12640a5fa5SMark Pearson #define TLMI_INDEX_MAX        32
13a40cd7efSMark Pearson 
14a40cd7efSMark Pearson /* Possible error values */
15a40cd7efSMark Pearson struct tlmi_err_codes {
16a40cd7efSMark Pearson 	const char *err_str;
17a40cd7efSMark Pearson 	int err_code;
18a40cd7efSMark Pearson };
19a40cd7efSMark Pearson 
20a40cd7efSMark Pearson enum encoding_option {
21a40cd7efSMark Pearson 	TLMI_ENCODING_ASCII,
22a40cd7efSMark Pearson 	TLMI_ENCODING_SCANCODE,
23a40cd7efSMark Pearson };
24a40cd7efSMark Pearson 
25640a5fa5SMark Pearson enum level_option {
26640a5fa5SMark Pearson 	TLMI_LEVEL_USER,
27640a5fa5SMark Pearson 	TLMI_LEVEL_MASTER,
28640a5fa5SMark Pearson };
29640a5fa5SMark Pearson 
30a40cd7efSMark Pearson /* password configuration details */
31640a5fa5SMark Pearson struct tlmi_pwdcfg_core {
32a40cd7efSMark Pearson 	uint32_t password_mode;
33a40cd7efSMark Pearson 	uint32_t password_state;
34a40cd7efSMark Pearson 	uint32_t min_length;
35a40cd7efSMark Pearson 	uint32_t max_length;
36a40cd7efSMark Pearson 	uint32_t supported_encodings;
37a40cd7efSMark Pearson 	uint32_t supported_keyboard;
38a40cd7efSMark Pearson };
39a40cd7efSMark Pearson 
40640a5fa5SMark Pearson struct tlmi_pwdcfg_ext {
41640a5fa5SMark Pearson 	uint32_t hdd_user_password;
42640a5fa5SMark Pearson 	uint32_t hdd_master_password;
43640a5fa5SMark Pearson 	uint32_t nvme_user_password;
44640a5fa5SMark Pearson 	uint32_t nvme_master_password;
45640a5fa5SMark Pearson };
46640a5fa5SMark Pearson 
47640a5fa5SMark Pearson struct tlmi_pwdcfg {
48640a5fa5SMark Pearson 	struct tlmi_pwdcfg_core core;
49640a5fa5SMark Pearson 	struct tlmi_pwdcfg_ext ext;
50640a5fa5SMark Pearson };
51640a5fa5SMark Pearson 
52a40cd7efSMark Pearson /* password setting details */
53a40cd7efSMark Pearson struct tlmi_pwd_setting {
54a40cd7efSMark Pearson 	struct kobject kobj;
55a40cd7efSMark Pearson 	bool valid;
56a40cd7efSMark Pearson 	char password[TLMI_PWD_BUFSIZE];
57a40cd7efSMark Pearson 	const char *pwd_type;
58a40cd7efSMark Pearson 	const char *role;
59a40cd7efSMark Pearson 	int minlen;
60a40cd7efSMark Pearson 	int maxlen;
61a40cd7efSMark Pearson 	enum encoding_option encoding;
62a40cd7efSMark Pearson 	char kbdlang[TLMI_LANG_MAXLEN];
63640a5fa5SMark Pearson 	int index; /*Used for HDD and NVME auth */
64640a5fa5SMark Pearson 	enum level_option level;
65*b49f72e7SMark Pearson 	bool cert_installed;
66*b49f72e7SMark Pearson 	char *signature;
67*b49f72e7SMark Pearson 	char *save_signature;
68a40cd7efSMark Pearson };
69a40cd7efSMark Pearson 
70a40cd7efSMark Pearson /* Attribute setting details */
71a40cd7efSMark Pearson struct tlmi_attr_setting {
72a40cd7efSMark Pearson 	struct kobject kobj;
73a40cd7efSMark Pearson 	int index;
74a40cd7efSMark Pearson 	char display_name[TLMI_SETTINGS_MAXLEN];
75a40cd7efSMark Pearson 	char *possible_values;
76a40cd7efSMark Pearson };
77a40cd7efSMark Pearson 
78a40cd7efSMark Pearson struct think_lmi {
79a40cd7efSMark Pearson 	struct wmi_device *wmi_device;
80a40cd7efSMark Pearson 
81a40cd7efSMark Pearson 	bool can_set_bios_settings;
82a40cd7efSMark Pearson 	bool can_get_bios_selections;
83a40cd7efSMark Pearson 	bool can_set_bios_password;
84a40cd7efSMark Pearson 	bool can_get_password_settings;
8595d42920SMark Pearson 	bool pending_changes;
86f5bc0157SMark Pearson 	bool can_debug_cmd;
87640a5fa5SMark Pearson 	bool opcode_support;
88*b49f72e7SMark Pearson 	bool certificate_support;
89a40cd7efSMark Pearson 
90a40cd7efSMark Pearson 	struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
91a40cd7efSMark Pearson 	struct device *class_dev;
92a40cd7efSMark Pearson 	struct kset *attribute_kset;
93a40cd7efSMark Pearson 	struct kset *authentication_kset;
94640a5fa5SMark Pearson 
95640a5fa5SMark Pearson 	struct tlmi_pwdcfg pwdcfg;
96a40cd7efSMark Pearson 	struct tlmi_pwd_setting *pwd_admin;
97a40cd7efSMark Pearson 	struct tlmi_pwd_setting *pwd_power;
98640a5fa5SMark Pearson 	struct tlmi_pwd_setting *pwd_system;
99640a5fa5SMark Pearson 	struct tlmi_pwd_setting *pwd_hdd;
100640a5fa5SMark Pearson 	struct tlmi_pwd_setting *pwd_nvme;
101a40cd7efSMark Pearson };
102a40cd7efSMark Pearson 
103a40cd7efSMark Pearson #endif /* !_THINK_LMI_H_ */
104