18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Common functions for kernel modules using Dell SMBIOS 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) Red Hat <mjg@redhat.com> 68c2ecf20Sopenharmony_ci * Copyright (c) 2014 Gabriele Mazzotta <gabriele.mzt@gmail.com> 78c2ecf20Sopenharmony_ci * Copyright (c) 2014 Pali Rohár <pali@kernel.org> 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Based on documentation in the libsmbios package: 108c2ecf20Sopenharmony_ci * Copyright (C) 2005-2014 Dell Inc. 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef _DELL_SMBIOS_H_ 148c2ecf20Sopenharmony_ci#define _DELL_SMBIOS_H_ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/device.h> 178c2ecf20Sopenharmony_ci#include <uapi/linux/wmi.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* Classes and selects used only in kernel drivers */ 208c2ecf20Sopenharmony_ci#define CLASS_KBD_BACKLIGHT 4 218c2ecf20Sopenharmony_ci#define SELECT_KBD_BACKLIGHT 11 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* Tokens used in kernel drivers, any of these 248c2ecf20Sopenharmony_ci * should be filtered from userspace access 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci#define BRIGHTNESS_TOKEN 0x007d 278c2ecf20Sopenharmony_ci#define KBD_LED_AC_TOKEN 0x0451 288c2ecf20Sopenharmony_ci#define KBD_LED_OFF_TOKEN 0x01E1 298c2ecf20Sopenharmony_ci#define KBD_LED_ON_TOKEN 0x01E2 308c2ecf20Sopenharmony_ci#define KBD_LED_AUTO_TOKEN 0x01E3 318c2ecf20Sopenharmony_ci#define KBD_LED_AUTO_25_TOKEN 0x02EA 328c2ecf20Sopenharmony_ci#define KBD_LED_AUTO_50_TOKEN 0x02EB 338c2ecf20Sopenharmony_ci#define KBD_LED_AUTO_75_TOKEN 0x02EC 348c2ecf20Sopenharmony_ci#define KBD_LED_AUTO_100_TOKEN 0x02F6 358c2ecf20Sopenharmony_ci#define GLOBAL_MIC_MUTE_ENABLE 0x0364 368c2ecf20Sopenharmony_ci#define GLOBAL_MIC_MUTE_DISABLE 0x0365 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistruct notifier_block; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct calling_interface_token { 418c2ecf20Sopenharmony_ci u16 tokenID; 428c2ecf20Sopenharmony_ci u16 location; 438c2ecf20Sopenharmony_ci union { 448c2ecf20Sopenharmony_ci u16 value; 458c2ecf20Sopenharmony_ci u16 stringlength; 468c2ecf20Sopenharmony_ci }; 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistruct calling_interface_structure { 508c2ecf20Sopenharmony_ci struct dmi_header header; 518c2ecf20Sopenharmony_ci u16 cmdIOAddress; 528c2ecf20Sopenharmony_ci u8 cmdIOCode; 538c2ecf20Sopenharmony_ci u32 supportedCmds; 548c2ecf20Sopenharmony_ci struct calling_interface_token tokens[]; 558c2ecf20Sopenharmony_ci} __packed; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciint dell_smbios_register_device(struct device *d, void *call_fn); 588c2ecf20Sopenharmony_civoid dell_smbios_unregister_device(struct device *d); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ciint dell_smbios_error(int value); 618c2ecf20Sopenharmony_ciint dell_smbios_call_filter(struct device *d, 628c2ecf20Sopenharmony_ci struct calling_interface_buffer *buffer); 638c2ecf20Sopenharmony_ciint dell_smbios_call(struct calling_interface_buffer *buffer); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct calling_interface_token *dell_smbios_find_token(int tokenid); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cienum dell_laptop_notifier_actions { 688c2ecf20Sopenharmony_ci DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED, 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciint dell_laptop_register_notifier(struct notifier_block *nb); 728c2ecf20Sopenharmony_ciint dell_laptop_unregister_notifier(struct notifier_block *nb); 738c2ecf20Sopenharmony_civoid dell_laptop_call_notifier(unsigned long action, void *data); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* for the supported backends */ 768c2ecf20Sopenharmony_ci#ifdef CONFIG_DELL_SMBIOS_WMI 778c2ecf20Sopenharmony_ciint init_dell_smbios_wmi(void); 788c2ecf20Sopenharmony_civoid exit_dell_smbios_wmi(void); 798c2ecf20Sopenharmony_ci#else /* CONFIG_DELL_SMBIOS_WMI */ 808c2ecf20Sopenharmony_cistatic inline int init_dell_smbios_wmi(void) 818c2ecf20Sopenharmony_ci{ 828c2ecf20Sopenharmony_ci return -ENODEV; 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_cistatic inline void exit_dell_smbios_wmi(void) 858c2ecf20Sopenharmony_ci{} 868c2ecf20Sopenharmony_ci#endif /* CONFIG_DELL_SMBIOS_WMI */ 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#ifdef CONFIG_DELL_SMBIOS_SMM 898c2ecf20Sopenharmony_ciint init_dell_smbios_smm(void); 908c2ecf20Sopenharmony_civoid exit_dell_smbios_smm(void); 918c2ecf20Sopenharmony_ci#else /* CONFIG_DELL_SMBIOS_SMM */ 928c2ecf20Sopenharmony_cistatic inline int init_dell_smbios_smm(void) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci return -ENODEV; 958c2ecf20Sopenharmony_ci} 968c2ecf20Sopenharmony_cistatic inline void exit_dell_smbios_smm(void) 978c2ecf20Sopenharmony_ci{} 988c2ecf20Sopenharmony_ci#endif /* CONFIG_DELL_SMBIOS_SMM */ 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#endif /* _DELL_SMBIOS_H_ */ 101