Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Common functions for kernel modules using Dell SMBIOS |
| 3 | * |
| 4 | * Copyright (c) Red Hat <mjg@redhat.com> |
| 5 | * Copyright (c) 2014 Gabriele Mazzotta <gabriele.mzt@gmail.com> |
| 6 | * Copyright (c) 2014 Pali Rohár <pali.rohar@gmail.com> |
| 7 | * |
| 8 | * Based on documentation in the libsmbios package: |
| 9 | * Copyright (C) 2005-2014 Dell Inc. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | */ |
| 15 | |
| 16 | #ifndef _DELL_SMBIOS_H_ |
| 17 | #define _DELL_SMBIOS_H_ |
| 18 | |
Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 19 | #include <linux/device.h> |
Mario Limonciello | f2645fa | 2017-11-01 14:25:36 -0500 | [diff] [blame] | 20 | #include <uapi/linux/wmi.h> |
Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 21 | |
Mario Limonciello | f2645fa | 2017-11-01 14:25:36 -0500 | [diff] [blame] | 22 | /* Classes and selects used only in kernel drivers */ |
Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 23 | #define CLASS_KBD_BACKLIGHT 4 |
| 24 | #define SELECT_KBD_BACKLIGHT 11 |
Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 25 | |
| 26 | /* Tokens used in kernel drivers, any of these |
| 27 | * should be filtered from userspace access |
| 28 | */ |
| 29 | #define BRIGHTNESS_TOKEN 0x007d |
| 30 | #define KBD_LED_AC_TOKEN 0x0451 |
| 31 | #define KBD_LED_OFF_TOKEN 0x01E1 |
| 32 | #define KBD_LED_ON_TOKEN 0x01E2 |
| 33 | #define KBD_LED_AUTO_TOKEN 0x01E3 |
| 34 | #define KBD_LED_AUTO_25_TOKEN 0x02EA |
| 35 | #define KBD_LED_AUTO_50_TOKEN 0x02EB |
| 36 | #define KBD_LED_AUTO_75_TOKEN 0x02EC |
| 37 | #define KBD_LED_AUTO_100_TOKEN 0x02F6 |
| 38 | #define GLOBAL_MIC_MUTE_ENABLE 0x0364 |
| 39 | #define GLOBAL_MIC_MUTE_DISABLE 0x0365 |
Mario Limonciello | 1f8543a | 2017-11-01 14:25:34 -0500 | [diff] [blame] | 40 | |
Hans de Goede | 504b025 | 2017-03-16 11:55:32 +0100 | [diff] [blame] | 41 | struct notifier_block; |
| 42 | |
Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 43 | struct calling_interface_token { |
| 44 | u16 tokenID; |
| 45 | u16 location; |
| 46 | union { |
| 47 | u16 value; |
| 48 | u16 stringlength; |
| 49 | }; |
| 50 | }; |
| 51 | |
Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 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; |
Michał Kępień | e8edf53 | 2016-03-04 14:09:06 +0100 | [diff] [blame] | 59 | |
Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 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); |
Mario Limonciello | 1f8543a | 2017-11-01 14:25:34 -0500 | [diff] [blame] | 64 | int dell_smbios_call_filter(struct device *d, |
| 65 | struct calling_interface_buffer *buffer); |
Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 66 | int dell_smbios_call(struct calling_interface_buffer *buffer); |
Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 67 | |
Michał Kępień | 96f7ef9 | 2016-01-22 15:27:22 +0100 | [diff] [blame] | 68 | struct calling_interface_token *dell_smbios_find_token(int tokenid); |
Hans de Goede | 504b025 | 2017-03-16 11:55:32 +0100 | [diff] [blame] | 69 | |
| 70 | enum dell_laptop_notifier_actions { |
| 71 | DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED, |
| 72 | }; |
| 73 | |
| 74 | int dell_laptop_register_notifier(struct notifier_block *nb); |
| 75 | int dell_laptop_unregister_notifier(struct notifier_block *nb); |
| 76 | void dell_laptop_call_notifier(unsigned long action, void *data); |
| 77 | |
Mario Limonciello | 25d4702 | 2018-02-27 12:23:04 -0600 | [diff] [blame] | 78 | /* for the supported backends */ |
| 79 | #ifdef CONFIG_DELL_SMBIOS_WMI |
| 80 | int init_dell_smbios_wmi(void); |
| 81 | void exit_dell_smbios_wmi(void); |
| 82 | #else /* CONFIG_DELL_SMBIOS_WMI */ |
| 83 | static inline int init_dell_smbios_wmi(void) |
| 84 | { |
| 85 | return -ENODEV; |
| 86 | } |
| 87 | static inline void exit_dell_smbios_wmi(void) |
| 88 | {} |
| 89 | #endif /* CONFIG_DELL_SMBIOS_WMI */ |
| 90 | |
| 91 | #ifdef CONFIG_DELL_SMBIOS_SMM |
| 92 | int init_dell_smbios_smm(void); |
| 93 | void exit_dell_smbios_smm(void); |
| 94 | #else /* CONFIG_DELL_SMBIOS_SMM */ |
| 95 | static inline int init_dell_smbios_smm(void) |
| 96 | { |
| 97 | return -ENODEV; |
| 98 | } |
| 99 | static inline void exit_dell_smbios_smm(void) |
| 100 | {} |
| 101 | #endif /* CONFIG_DELL_SMBIOS_SMM */ |
| 102 | |
| 103 | #endif /* _DELL_SMBIOS_H_ */ |