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 GLOBAL_MIC_MUTE_ENABLE 0x0364 37 #define GLOBAL_MIC_MUTE_DISABLE 0x0365 38 #define GLOBAL_MUTE_ENABLE 0x058C 39 #define GLOBAL_MUTE_DISABLE 0x058D 40 41 struct notifier_block; 42 43 struct calling_interface_token { 44 u16 tokenID; 45 u16 location; 46 union { 47 u16 value; 48 u16 stringlength; 49 }; 50 }; 51 52 struct calling_interface_structure { 53 struct dmi_header header; 54 u16 cmdIOAddress; 55 u8 cmdIOCode; 56 u32 supportedCmds; 57 struct calling_interface_token tokens[]; 58 } __packed; 59 60 int dell_smbios_register_device(struct device *d, void *call_fn); 61 void dell_smbios_unregister_device(struct device *d); 62 63 int dell_smbios_error(int value); 64 int dell_smbios_call_filter(struct device *d, 65 struct calling_interface_buffer *buffer); 66 int dell_smbios_call(struct calling_interface_buffer *buffer); 67 68 void dell_fill_request(struct calling_interface_buffer *buffer, 69 u32 arg0, u32 arg1, u32 arg2, u32 arg3); 70 int dell_send_request(struct calling_interface_buffer *buffer, 71 u16 class, u16 select); 72 73 struct calling_interface_token *dell_smbios_find_token(int tokenid); 74 75 enum dell_laptop_notifier_actions { 76 DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED, 77 }; 78 79 int dell_laptop_register_notifier(struct notifier_block *nb); 80 int dell_laptop_unregister_notifier(struct notifier_block *nb); 81 void dell_laptop_call_notifier(unsigned long action, void *data); 82 bool dell_smbios_class_is_supported(u16 class); 83 84 /* for the supported backends */ 85 #ifdef CONFIG_DELL_SMBIOS_WMI 86 int init_dell_smbios_wmi(void); 87 void exit_dell_smbios_wmi(void); 88 #else /* CONFIG_DELL_SMBIOS_WMI */ 89 static inline int init_dell_smbios_wmi(void) 90 { 91 return -ENODEV; 92 } 93 static inline void exit_dell_smbios_wmi(void) 94 {} 95 #endif /* CONFIG_DELL_SMBIOS_WMI */ 96 97 #ifdef CONFIG_DELL_SMBIOS_SMM 98 int init_dell_smbios_smm(void); 99 void exit_dell_smbios_smm(void); 100 #else /* CONFIG_DELL_SMBIOS_SMM */ 101 static inline int init_dell_smbios_smm(void) 102 { 103 return -ENODEV; 104 } 105 static inline void exit_dell_smbios_smm(void) 106 {} 107 #endif /* CONFIG_DELL_SMBIOS_SMM */ 108 109 #endif /* _DELL_SMBIOS_H_ */ 110