| Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 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.rohar@gmail.com> |
| 8 | * |
| 9 | * Based on documentation in the libsmbios package: |
| 10 | * Copyright (C) 2005-2014 Dell Inc. |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #ifndef _DELL_SMBIOS_H_ |
| 14 | #define _DELL_SMBIOS_H_ |
| 15 | |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 16 | #include <linux/device.h> |
| Mario Limonciello | f2645fa | 2017-11-01 14:25:36 -0500 | [diff] [blame] | 17 | #include <uapi/linux/wmi.h> |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 18 | |
| Mario Limonciello | f2645fa | 2017-11-01 14:25:36 -0500 | [diff] [blame] | 19 | /* Classes and selects used only in kernel drivers */ |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 20 | #define CLASS_KBD_BACKLIGHT 4 |
| 21 | #define SELECT_KBD_BACKLIGHT 11 |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 22 | |
| 23 | /* Tokens used in kernel drivers, any of these |
| 24 | * should be filtered from userspace access |
| 25 | */ |
| 26 | #define BRIGHTNESS_TOKEN 0x007d |
| 27 | #define KBD_LED_AC_TOKEN 0x0451 |
| 28 | #define KBD_LED_OFF_TOKEN 0x01E1 |
| 29 | #define KBD_LED_ON_TOKEN 0x01E2 |
| 30 | #define KBD_LED_AUTO_TOKEN 0x01E3 |
| 31 | #define KBD_LED_AUTO_25_TOKEN 0x02EA |
| 32 | #define KBD_LED_AUTO_50_TOKEN 0x02EB |
| 33 | #define KBD_LED_AUTO_75_TOKEN 0x02EC |
| 34 | #define KBD_LED_AUTO_100_TOKEN 0x02F6 |
| 35 | #define GLOBAL_MIC_MUTE_ENABLE 0x0364 |
| 36 | #define GLOBAL_MIC_MUTE_DISABLE 0x0365 |
| Mario Limonciello | 1f8543a | 2017-11-01 14:25:34 -0500 | [diff] [blame] | 37 | |
| Hans de Goede | 504b025 | 2017-03-16 11:55:32 +0100 | [diff] [blame] | 38 | struct notifier_block; |
| 39 | |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 40 | struct calling_interface_token { |
| 41 | u16 tokenID; |
| 42 | u16 location; |
| 43 | union { |
| 44 | u16 value; |
| 45 | u16 stringlength; |
| 46 | }; |
| 47 | }; |
| 48 | |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 49 | struct calling_interface_structure { |
| 50 | struct dmi_header header; |
| 51 | u16 cmdIOAddress; |
| 52 | u8 cmdIOCode; |
| 53 | u32 supportedCmds; |
| 54 | struct calling_interface_token tokens[]; |
| 55 | } __packed; |
| Michał Kępień | e8edf53 | 2016-03-04 14:09:06 +0100 | [diff] [blame] | 56 | |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 57 | int dell_smbios_register_device(struct device *d, void *call_fn); |
| 58 | void dell_smbios_unregister_device(struct device *d); |
| 59 | |
| 60 | int dell_smbios_error(int value); |
| Mario Limonciello | 1f8543a | 2017-11-01 14:25:34 -0500 | [diff] [blame] | 61 | int dell_smbios_call_filter(struct device *d, |
| 62 | struct calling_interface_buffer *buffer); |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 63 | int dell_smbios_call(struct calling_interface_buffer *buffer); |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 64 | |
| Michał Kępień | 96f7ef9 | 2016-01-22 15:27:22 +0100 | [diff] [blame] | 65 | struct calling_interface_token *dell_smbios_find_token(int tokenid); |
| Hans de Goede | 504b025 | 2017-03-16 11:55:32 +0100 | [diff] [blame] | 66 | |
| 67 | enum dell_laptop_notifier_actions { |
| 68 | DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED, |
| 69 | }; |
| 70 | |
| 71 | int dell_laptop_register_notifier(struct notifier_block *nb); |
| 72 | int dell_laptop_unregister_notifier(struct notifier_block *nb); |
| 73 | void dell_laptop_call_notifier(unsigned long action, void *data); |
| 74 | |
| Mario Limonciello | 25d4702 | 2018-02-27 12:23:04 -0600 | [diff] [blame] | 75 | /* for the supported backends */ |
| 76 | #ifdef CONFIG_DELL_SMBIOS_WMI |
| 77 | int init_dell_smbios_wmi(void); |
| 78 | void exit_dell_smbios_wmi(void); |
| 79 | #else /* CONFIG_DELL_SMBIOS_WMI */ |
| 80 | static inline int init_dell_smbios_wmi(void) |
| 81 | { |
| 82 | return -ENODEV; |
| 83 | } |
| 84 | static inline void exit_dell_smbios_wmi(void) |
| 85 | {} |
| 86 | #endif /* CONFIG_DELL_SMBIOS_WMI */ |
| 87 | |
| 88 | #ifdef CONFIG_DELL_SMBIOS_SMM |
| 89 | int init_dell_smbios_smm(void); |
| 90 | void exit_dell_smbios_smm(void); |
| 91 | #else /* CONFIG_DELL_SMBIOS_SMM */ |
| 92 | static inline int init_dell_smbios_smm(void) |
| 93 | { |
| 94 | return -ENODEV; |
| 95 | } |
| 96 | static inline void exit_dell_smbios_smm(void) |
| 97 | {} |
| 98 | #endif /* CONFIG_DELL_SMBIOS_SMM */ |
| 99 | |
| 100 | #endif /* _DELL_SMBIOS_H_ */ |