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