blob: 9a19fbd2f73412d064101b9a21e419768ba8ea84 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Dave Airlie99b38b42010-12-06 12:43:33 +10002/*
3 * MXM WMI driver
4 *
5 * Copyright(C) 2010 Red Hat.
Dave Airlie99b38b42010-12-06 12:43:33 +10006 */
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/init.h>
Rashika Kheria475879d2013-12-13 12:59:52 +053010#include <linux/mxm-wmi.h>
Lv Zheng8b484632013-12-03 08:49:16 +080011#include <linux/acpi.h>
Dave Airlie99b38b42010-12-06 12:43:33 +100012
13MODULE_AUTHOR("Dave Airlie");
14MODULE_DESCRIPTION("MXM WMI Driver");
15MODULE_LICENSE("GPL");
16
17#define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
18
19MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
20
21#define MXM_WMMX_FUNC_MXDS 0x5344584D /* "MXDS" */
Dave Airlie000703f2011-05-09 11:40:25 +100022#define MXM_WMMX_FUNC_MXMX 0x53445344 /* "MXMX" */
Dave Airlie99b38b42010-12-06 12:43:33 +100023
24struct mxds_args {
25 u32 func;
26 u32 args;
27 u32 xarg;
28};
29
30int mxm_wmi_call_mxds(int adapter)
31{
32 struct mxds_args args = {
33 .func = MXM_WMMX_FUNC_MXDS,
34 .args = 0,
35 .xarg = 1,
36 };
37 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
38 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
39 acpi_status status;
40
41 printk("calling mux switch %d\n", adapter);
Dave Airlie000703f2011-05-09 11:40:25 +100042
Pali Rohárf85a43b92017-08-12 09:44:15 +020043 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
Dave Airlie99b38b42010-12-06 12:43:33 +100044 &output);
45
46 if (ACPI_FAILURE(status))
47 return status;
48
49 printk("mux switched %d\n", status);
50 return 0;
51
52}
53EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
54
Dave Airlie000703f2011-05-09 11:40:25 +100055int mxm_wmi_call_mxmx(int adapter)
56{
57 struct mxds_args args = {
58 .func = MXM_WMMX_FUNC_MXMX,
59 .args = 0,
60 .xarg = 1,
61 };
62 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
63 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
64 acpi_status status;
65
66 printk("calling mux switch %d\n", adapter);
67
Pali Rohárf85a43b92017-08-12 09:44:15 +020068 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
Dave Airlie000703f2011-05-09 11:40:25 +100069 &output);
70
71 if (ACPI_FAILURE(status))
72 return status;
73
74 printk("mux mutex set switched %d\n", status);
75 return 0;
76
77}
78EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
79
Dave Airlie99b38b42010-12-06 12:43:33 +100080bool mxm_wmi_supported(void)
81{
82 bool guid_valid;
83 guid_valid = wmi_has_guid(MXM_WMMX_GUID);
84 return guid_valid;
85}
86EXPORT_SYMBOL_GPL(mxm_wmi_supported);
87
88static int __init mxm_wmi_init(void)
89{
90 return 0;
91}
92
93static void __exit mxm_wmi_exit(void)
94{
95}
96
97module_init(mxm_wmi_init);
98module_exit(mxm_wmi_exit);