blob: 91e8004d48babcca8dbe62219c6a765e826125ce [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
Mario Limonciello1f8543a2017-11-01 14:25:34 -050029#define CLASS_FLASH_INTERFACE 7
30#define SELECT_FLASH_INTERFACE 3
31#define CLASS_ADMIN_PROP 10
32#define SELECT_ADMIN_PROP 3
Mario Limonciello549b4932017-11-01 14:25:31 -050033#define CLASS_INFO 17
34#define SELECT_RFKILL 11
35#define SELECT_APP_REGISTRATION 3
Mario Limonciello1f8543a2017-11-01 14:25:34 -050036#define SELECT_DOCK 22
Mario Limonciello549b4932017-11-01 14:25:31 -050037
38/* Tokens used in kernel drivers, any of these
39 * should be filtered from userspace access
40 */
41#define BRIGHTNESS_TOKEN 0x007d
42#define KBD_LED_AC_TOKEN 0x0451
43#define KBD_LED_OFF_TOKEN 0x01E1
44#define KBD_LED_ON_TOKEN 0x01E2
45#define KBD_LED_AUTO_TOKEN 0x01E3
46#define KBD_LED_AUTO_25_TOKEN 0x02EA
47#define KBD_LED_AUTO_50_TOKEN 0x02EB
48#define KBD_LED_AUTO_75_TOKEN 0x02EC
49#define KBD_LED_AUTO_100_TOKEN 0x02F6
50#define GLOBAL_MIC_MUTE_ENABLE 0x0364
51#define GLOBAL_MIC_MUTE_DISABLE 0x0365
Mario Limonciello1f8543a2017-11-01 14:25:34 -050052
53/* tokens whitelisted to userspace use */
54#define CAPSULE_EN_TOKEN 0x0461
55#define CAPSULE_DIS_TOKEN 0x0462
Mario Limoncielloda1f6072017-11-01 14:25:33 -050056#define WSMT_EN_TOKEN 0x04EC
57#define WSMT_DIS_TOKEN 0x04ED
Mario Limonciello549b4932017-11-01 14:25:31 -050058
Hans de Goede504b0252017-03-16 11:55:32 +010059struct notifier_block;
60
Michał Kępień2f9f26b2016-01-22 15:27:13 +010061/* This structure will be modified by the firmware when we enter
62 * system management mode, hence the volatiles */
63
64struct calling_interface_buffer {
Mario Limonciellof35a8ef2017-11-01 14:25:22 -050065 u16 cmd_class;
66 u16 cmd_select;
Michał Kępień2f9f26b2016-01-22 15:27:13 +010067 volatile u32 input[4];
68 volatile u32 output[4];
69} __packed;
70
71struct calling_interface_token {
72 u16 tokenID;
73 u16 location;
74 union {
75 u16 value;
76 u16 stringlength;
77 };
78};
79
Mario Limonciello549b4932017-11-01 14:25:31 -050080struct calling_interface_structure {
81 struct dmi_header header;
82 u16 cmdIOAddress;
83 u8 cmdIOCode;
84 u32 supportedCmds;
85 struct calling_interface_token tokens[];
86} __packed;
Michał Kępieńe8edf532016-03-04 14:09:06 +010087
Mario Limonciello549b4932017-11-01 14:25:31 -050088int dell_smbios_register_device(struct device *d, void *call_fn);
89void dell_smbios_unregister_device(struct device *d);
90
91int dell_smbios_error(int value);
Mario Limonciello1f8543a2017-11-01 14:25:34 -050092int dell_smbios_call_filter(struct device *d,
93 struct calling_interface_buffer *buffer);
Mario Limonciello549b4932017-11-01 14:25:31 -050094int dell_smbios_call(struct calling_interface_buffer *buffer);
Michał Kępień2f9f26b2016-01-22 15:27:13 +010095
Michał Kępień96f7ef92016-01-22 15:27:22 +010096struct calling_interface_token *dell_smbios_find_token(int tokenid);
Hans de Goede504b0252017-03-16 11:55:32 +010097
98enum dell_laptop_notifier_actions {
99 DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED,
100};
101
102int dell_laptop_register_notifier(struct notifier_block *nb);
103int dell_laptop_unregister_notifier(struct notifier_block *nb);
104void dell_laptop_call_notifier(unsigned long action, void *data);
105
Michał Kępień2f9f26b2016-01-22 15:27:13 +0100106#endif