Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / platform / x86 / mxm-wmi.c
blob9a457956025a5be9526a38f6989eb246f137c456
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * MXM WMI driver
5 * Copyright(C) 2010 Red Hat.
6 */
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/init.h>
10 #include <linux/mxm-wmi.h>
11 #include <linux/acpi.h>
13 MODULE_AUTHOR("Dave Airlie");
14 MODULE_DESCRIPTION("MXM WMI Driver");
15 MODULE_LICENSE("GPL");
17 #define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
19 MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
21 #define MXM_WMMX_FUNC_MXDS 0x5344584D /* "MXDS" */
22 #define MXM_WMMX_FUNC_MXMX 0x53445344 /* "MXMX" */
24 struct mxds_args {
25 u32 func;
26 u32 args;
27 u32 xarg;
30 int mxm_wmi_call_mxds(int adapter)
32 struct mxds_args args = {
33 .func = MXM_WMMX_FUNC_MXDS,
34 .args = 0,
35 .xarg = 1,
37 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
38 acpi_status status;
40 printk("calling mux switch %d\n", adapter);
42 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL);
44 if (ACPI_FAILURE(status))
45 return status;
47 printk("mux switched %d\n", status);
48 return 0;
51 EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
53 int mxm_wmi_call_mxmx(int adapter)
55 struct mxds_args args = {
56 .func = MXM_WMMX_FUNC_MXMX,
57 .args = 0,
58 .xarg = 1,
60 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
61 acpi_status status;
63 printk("calling mux switch %d\n", adapter);
65 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL);
67 if (ACPI_FAILURE(status))
68 return status;
70 printk("mux mutex set switched %d\n", status);
71 return 0;
74 EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
76 bool mxm_wmi_supported(void)
78 bool guid_valid;
79 guid_valid = wmi_has_guid(MXM_WMMX_GUID);
80 return guid_valid;
82 EXPORT_SYMBOL_GPL(mxm_wmi_supported);
84 static int __init mxm_wmi_init(void)
86 return 0;
89 static void __exit mxm_wmi_exit(void)
93 module_init(mxm_wmi_init);
94 module_exit(mxm_wmi_exit);