| 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> |
| 20 | |
| 21 | /* Classes and selects used in kernel drivers */ |
| 22 | #define CLASS_TOKEN_READ 0 |
| 23 | #define CLASS_TOKEN_WRITE 1 |
| 24 | #define SELECT_TOKEN_STD 0 |
| 25 | #define SELECT_TOKEN_BAT 1 |
| 26 | #define SELECT_TOKEN_AC 2 |
| 27 | #define CLASS_KBD_BACKLIGHT 4 |
| 28 | #define SELECT_KBD_BACKLIGHT 11 |
| 29 | #define CLASS_INFO 17 |
| 30 | #define SELECT_RFKILL 11 |
| 31 | #define SELECT_APP_REGISTRATION 3 |
| 32 | |
| 33 | /* Tokens used in kernel drivers, any of these |
| 34 | * should be filtered from userspace access |
| 35 | */ |
| 36 | #define BRIGHTNESS_TOKEN 0x007d |
| 37 | #define KBD_LED_AC_TOKEN 0x0451 |
| 38 | #define KBD_LED_OFF_TOKEN 0x01E1 |
| 39 | #define KBD_LED_ON_TOKEN 0x01E2 |
| 40 | #define KBD_LED_AUTO_TOKEN 0x01E3 |
| 41 | #define KBD_LED_AUTO_25_TOKEN 0x02EA |
| 42 | #define KBD_LED_AUTO_50_TOKEN 0x02EB |
| 43 | #define KBD_LED_AUTO_75_TOKEN 0x02EC |
| 44 | #define KBD_LED_AUTO_100_TOKEN 0x02F6 |
| 45 | #define GLOBAL_MIC_MUTE_ENABLE 0x0364 |
| 46 | #define GLOBAL_MIC_MUTE_DISABLE 0x0365 |
| Mario Limonciello | da1f607 | 2017-11-01 14:25:33 -0500 | [diff] [blame^] | 47 | #define WSMT_EN_TOKEN 0x04EC |
| 48 | #define WSMT_DIS_TOKEN 0x04ED |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 49 | |
| Hans de Goede | 504b025 | 2017-03-16 11:55:32 +0100 | [diff] [blame] | 50 | struct notifier_block; |
| 51 | |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 52 | /* This structure will be modified by the firmware when we enter |
| 53 | * system management mode, hence the volatiles */ |
| 54 | |
| 55 | struct calling_interface_buffer { |
| Mario Limonciello | f35a8ef | 2017-11-01 14:25:22 -0500 | [diff] [blame] | 56 | u16 cmd_class; |
| 57 | u16 cmd_select; |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 58 | volatile u32 input[4]; |
| 59 | volatile u32 output[4]; |
| 60 | } __packed; |
| 61 | |
| 62 | struct calling_interface_token { |
| 63 | u16 tokenID; |
| 64 | u16 location; |
| 65 | union { |
| 66 | u16 value; |
| 67 | u16 stringlength; |
| 68 | }; |
| 69 | }; |
| 70 | |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 71 | struct calling_interface_structure { |
| 72 | struct dmi_header header; |
| 73 | u16 cmdIOAddress; |
| 74 | u8 cmdIOCode; |
| 75 | u32 supportedCmds; |
| 76 | struct calling_interface_token tokens[]; |
| 77 | } __packed; |
| Michał Kępień | e8edf53 | 2016-03-04 14:09:06 +0100 | [diff] [blame] | 78 | |
| Mario Limonciello | 549b493 | 2017-11-01 14:25:31 -0500 | [diff] [blame] | 79 | int dell_smbios_register_device(struct device *d, void *call_fn); |
| 80 | void dell_smbios_unregister_device(struct device *d); |
| 81 | |
| 82 | int dell_smbios_error(int value); |
| 83 | int dell_smbios_call(struct calling_interface_buffer *buffer); |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 84 | |
| Michał Kępień | 96f7ef9 | 2016-01-22 15:27:22 +0100 | [diff] [blame] | 85 | struct calling_interface_token *dell_smbios_find_token(int tokenid); |
| Hans de Goede | 504b025 | 2017-03-16 11:55:32 +0100 | [diff] [blame] | 86 | |
| 87 | enum dell_laptop_notifier_actions { |
| 88 | DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED, |
| 89 | }; |
| 90 | |
| 91 | int dell_laptop_register_notifier(struct notifier_block *nb); |
| 92 | int dell_laptop_unregister_notifier(struct notifier_block *nb); |
| 93 | void dell_laptop_call_notifier(unsigned long action, void *data); |
| 94 | |
| Michał Kępień | 2f9f26b | 2016-01-22 15:27:13 +0100 | [diff] [blame] | 95 | #endif |