xref: /linux/drivers/platform/x86/dell/dell-smbios.h (revision 5b05bb3f6c5716fab6911e12d60dd1f43ad9806a)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  Common functions for kernel modules using Dell SMBIOS
4  *
5  *  Copyright (c) Red Hat <mjg@redhat.com>
6  *  Copyright (c) 2014 Gabriele Mazzotta <gabriele.mzt@gmail.com>
7  *  Copyright (c) 2014 Pali Rohár <pali@kernel.org>
8  *
9  *  Based on documentation in the libsmbios package:
10  *  Copyright (C) 2005-2014 Dell Inc.
11  */
12 
13 #ifndef _DELL_SMBIOS_H_
14 #define _DELL_SMBIOS_H_
15 
16 #include <linux/device.h>
17 #include <uapi/linux/wmi.h>
18 
19 /* Classes and selects used only in kernel drivers */
20 #define CLASS_KBD_BACKLIGHT 4
21 #define SELECT_KBD_BACKLIGHT 11
22 #define SELECT_THERMAL_MANAGEMENT 19
23 
24 /* Tokens used in kernel drivers, any of these
25  * should be filtered from userspace access
26  */
27 #define BRIGHTNESS_TOKEN	0x007d
28 #define KBD_LED_AC_TOKEN	0x0451
29 #define KBD_LED_OFF_TOKEN	0x01E1
30 #define KBD_LED_ON_TOKEN	0x01E2
31 #define KBD_LED_AUTO_TOKEN	0x01E3
32 #define KBD_LED_AUTO_25_TOKEN	0x02EA
33 #define KBD_LED_AUTO_50_TOKEN	0x02EB
34 #define KBD_LED_AUTO_75_TOKEN	0x02EC
35 #define KBD_LED_AUTO_100_TOKEN	0x02F6
36 #define BAT_PRI_AC_MODE_TOKEN	0x0341
37 #define BAT_ADAPTIVE_MODE_TOKEN	0x0342
38 #define BAT_CUSTOM_MODE_TOKEN	0x0343
39 #define BAT_STANDARD_MODE_TOKEN	0x0346
40 #define BAT_EXPRESS_MODE_TOKEN	0x0347
41 #define BAT_CUSTOM_CHARGE_START	0x0349
42 #define BAT_CUSTOM_CHARGE_END	0x034A
43 #define GLOBAL_MIC_MUTE_ENABLE	0x0364
44 #define GLOBAL_MIC_MUTE_DISABLE	0x0365
45 #define GLOBAL_MUTE_ENABLE	0x058C
46 #define GLOBAL_MUTE_DISABLE	0x058D
47 
48 struct notifier_block;
49 
50 typedef int (*smbios_callback_fn_t)(struct device *dev, struct calling_interface_buffer *buffer);
51 
52 struct calling_interface_token {
53 	u16 tokenID;
54 	u16 location;
55 	union {
56 		u16 value;
57 		u16 stringlength;
58 	};
59 };
60 
61 struct calling_interface_structure {
62 	struct dmi_header header;
63 	u16 cmdIOAddress;
64 	u8 cmdIOCode;
65 	u32 supportedCmds;
66 	struct calling_interface_token tokens[];
67 } __packed;
68 
69 int dell_smbios_register_device(struct device *d, int priority, smbios_callback_fn_t call_fn);
70 void dell_smbios_unregister_device(struct device *d);
71 
72 int dell_smbios_error(int value);
73 int dell_smbios_call_filter(struct device *d,
74 	struct calling_interface_buffer *buffer);
75 int dell_smbios_call(struct calling_interface_buffer *buffer);
76 
77 void dell_fill_request(struct calling_interface_buffer *buffer,
78 			       u32 arg0, u32 arg1, u32 arg2, u32 arg3);
79 int dell_send_request(struct calling_interface_buffer *buffer,
80 			     u16 class, u16 select);
81 
82 struct calling_interface_token *dell_smbios_find_token(int tokenid);
83 
84 enum dell_laptop_notifier_actions {
85 	DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED,
86 };
87 
88 int dell_laptop_register_notifier(struct notifier_block *nb);
89 int dell_laptop_unregister_notifier(struct notifier_block *nb);
90 void dell_laptop_call_notifier(unsigned long action, void *data);
91 bool dell_smbios_class_is_supported(u16 class);
92 
93 /* for the supported backends */
94 #ifdef CONFIG_DELL_SMBIOS_WMI
95 int init_dell_smbios_wmi(void);
96 void exit_dell_smbios_wmi(void);
97 #else /* CONFIG_DELL_SMBIOS_WMI */
init_dell_smbios_wmi(void)98 static inline int init_dell_smbios_wmi(void)
99 {
100 	return -ENODEV;
101 }
exit_dell_smbios_wmi(void)102 static inline void exit_dell_smbios_wmi(void)
103 {}
104 #endif /* CONFIG_DELL_SMBIOS_WMI */
105 
106 #ifdef CONFIG_DELL_SMBIOS_SMM
107 int init_dell_smbios_smm(void);
108 void exit_dell_smbios_smm(void);
109 #else /* CONFIG_DELL_SMBIOS_SMM */
init_dell_smbios_smm(void)110 static inline int init_dell_smbios_smm(void)
111 {
112 	return -ENODEV;
113 }
exit_dell_smbios_smm(void)114 static inline void exit_dell_smbios_smm(void)
115 {}
116 #endif /* CONFIG_DELL_SMBIOS_SMM */
117 
118 #endif /* _DELL_SMBIOS_H_ */
119