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