brintos

brintos / linux-shallow public Read only

0
0
Text · 3.2 KiB · 77baa15 Raw
117 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 *  Common functions for kernel modules using Dell SMBIOS4 *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@kernel.org>8 *9 *  Based on documentation in the libsmbios package:10 *  Copyright (C) 2005-2014 Dell Inc.11 */12 13#ifndef _DELL_SMBIOS_H_14#define _DELL_SMBIOS_H_15 16#include <linux/device.h>17#include <uapi/linux/wmi.h>18 19/* Classes and selects used only in kernel drivers */20#define CLASS_KBD_BACKLIGHT 421#define SELECT_KBD_BACKLIGHT 1122#define SELECT_THERMAL_MANAGEMENT 1923 24/* Tokens used in kernel drivers, any of these25 * should be filtered from userspace access26 */27#define BRIGHTNESS_TOKEN	0x007d28#define KBD_LED_AC_TOKEN	0x045129#define KBD_LED_OFF_TOKEN	0x01E130#define KBD_LED_ON_TOKEN	0x01E231#define KBD_LED_AUTO_TOKEN	0x01E332#define KBD_LED_AUTO_25_TOKEN	0x02EA33#define KBD_LED_AUTO_50_TOKEN	0x02EB34#define KBD_LED_AUTO_75_TOKEN	0x02EC35#define KBD_LED_AUTO_100_TOKEN	0x02F636#define BAT_PRI_AC_MODE_TOKEN	0x034137#define BAT_ADAPTIVE_MODE_TOKEN	0x034238#define BAT_CUSTOM_MODE_TOKEN	0x034339#define BAT_STANDARD_MODE_TOKEN	0x034640#define BAT_EXPRESS_MODE_TOKEN	0x034741#define BAT_CUSTOM_CHARGE_START	0x034942#define BAT_CUSTOM_CHARGE_END	0x034A43#define GLOBAL_MIC_MUTE_ENABLE	0x036444#define GLOBAL_MIC_MUTE_DISABLE	0x036545#define GLOBAL_MUTE_ENABLE	0x058C46#define GLOBAL_MUTE_DISABLE	0x058D47 48struct notifier_block;49 50struct calling_interface_token {51	u16 tokenID;52	u16 location;53	union {54		u16 value;55		u16 stringlength;56	};57};58 59struct calling_interface_structure {60	struct dmi_header header;61	u16 cmdIOAddress;62	u8 cmdIOCode;63	u32 supportedCmds;64	struct calling_interface_token tokens[];65} __packed;66 67int dell_smbios_register_device(struct device *d, void *call_fn);68void dell_smbios_unregister_device(struct device *d);69 70int dell_smbios_error(int value);71int dell_smbios_call_filter(struct device *d,72	struct calling_interface_buffer *buffer);73int dell_smbios_call(struct calling_interface_buffer *buffer);74 75void dell_fill_request(struct calling_interface_buffer *buffer,76			       u32 arg0, u32 arg1, u32 arg2, u32 arg3);77int dell_send_request(struct calling_interface_buffer *buffer,78			     u16 class, u16 select);79 80struct calling_interface_token *dell_smbios_find_token(int tokenid);81 82enum dell_laptop_notifier_actions {83	DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED,84};85 86int dell_laptop_register_notifier(struct notifier_block *nb);87int dell_laptop_unregister_notifier(struct notifier_block *nb);88void dell_laptop_call_notifier(unsigned long action, void *data);89bool dell_smbios_class_is_supported(u16 class);90 91/* for the supported backends */92#ifdef CONFIG_DELL_SMBIOS_WMI93int init_dell_smbios_wmi(void);94void exit_dell_smbios_wmi(void);95#else /* CONFIG_DELL_SMBIOS_WMI */96static inline int init_dell_smbios_wmi(void)97{98	return -ENODEV;99}100static inline void exit_dell_smbios_wmi(void)101{}102#endif /* CONFIG_DELL_SMBIOS_WMI */103 104#ifdef CONFIG_DELL_SMBIOS_SMM105int init_dell_smbios_smm(void);106void exit_dell_smbios_smm(void);107#else /* CONFIG_DELL_SMBIOS_SMM */108static inline int init_dell_smbios_smm(void)109{110	return -ENODEV;111}112static inline void exit_dell_smbios_smm(void)113{}114#endif /* CONFIG_DELL_SMBIOS_SMM */115 116#endif /* _DELL_SMBIOS_H_ */117