blob: 07effdc7ae8b64d87b536c6ab4572166b2c4b1dc [file] [log] [blame]
Michał Kępień2f9f26b2016-01-22 15:27:13 +01001/*
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 Limonciello549b4932017-11-01 14:25:31 -050019#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 Limoncielloda1f6072017-11-01 14:25:33 -050047#define WSMT_EN_TOKEN 0x04EC
48#define WSMT_DIS_TOKEN 0x04ED
Mario Limonciello549b4932017-11-01 14:25:31 -050049
Hans de Goede504b0252017-03-16 11:55:32 +010050struct notifier_block;
51
Michał Kępień2f9f26b2016-01-22 15:27:13 +010052/* This structure will be modified by the firmware when we enter
53 * system management mode, hence the volatiles */
54
55struct calling_interface_buffer {
Mario Limonciellof35a8ef2017-11-01 14:25:22 -050056 u16 cmd_class;
57 u16 cmd_select;
Michał Kępień2f9f26b2016-01-22 15:27:13 +010058 volatile u32 input[4];
59 volatile u32 output[4];
60} __packed;
61
62struct calling_interface_token {
63 u16 tokenID;
64 u16 location;
65 union {
66 u16 value;
67 u16 stringlength;
68 };
69};
70
Mario Limonciello549b4932017-11-01 14:25:31 -050071struct 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ńe8edf532016-03-04 14:09:06 +010078
Mario Limonciello549b4932017-11-01 14:25:31 -050079int dell_smbios_register_device(struct device *d, void *call_fn);
80void dell_smbios_unregister_device(struct device *d);
81
82int dell_smbios_error(int value);
83int dell_smbios_call(struct calling_interface_buffer *buffer);
Michał Kępień2f9f26b2016-01-22 15:27:13 +010084
Michał Kępień96f7ef92016-01-22 15:27:22 +010085struct calling_interface_token *dell_smbios_find_token(int tokenid);
Hans de Goede504b0252017-03-16 11:55:32 +010086
87enum dell_laptop_notifier_actions {
88 DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED,
89};
90
91int dell_laptop_register_notifier(struct notifier_block *nb);
92int dell_laptop_unregister_notifier(struct notifier_block *nb);
93void dell_laptop_call_notifier(unsigned long action, void *data);
94
Michał Kępień2f9f26b2016-01-22 15:27:13 +010095#endif