]> Pileus Git - ~andy/linux/blob - drivers/platform/x86/mxm-wmi.c
7503d2b9b0730d287966d8716ca57a717db7b3db
[~andy/linux] / drivers / platform / x86 / mxm-wmi.c
1 /*
2  * MXM WMI driver
3  *
4  * Copyright(C) 2010 Red Hat.
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/mxm-wmi.h>
24 #include <acpi/acpi_bus.h>
25 #include <acpi/acpi_drivers.h>
26
27 MODULE_AUTHOR("Dave Airlie");
28 MODULE_DESCRIPTION("MXM WMI Driver");
29 MODULE_LICENSE("GPL");
30
31 #define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
32
33 MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
34
35 #define MXM_WMMX_FUNC_MXDS 0x5344584D /* "MXDS" */
36 #define MXM_WMMX_FUNC_MXMX 0x53445344 /* "MXMX" */
37
38 struct mxds_args {
39         u32 func;
40         u32 args;
41         u32 xarg;
42 };
43
44 int mxm_wmi_call_mxds(int adapter)
45 {
46         struct mxds_args args = {
47                 .func = MXM_WMMX_FUNC_MXDS,
48                 .args = 0,
49                 .xarg = 1,
50         };
51         struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
52         struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
53         acpi_status status;
54
55         printk("calling mux switch %d\n", adapter);
56
57         status = wmi_evaluate_method(MXM_WMMX_GUID, 0x1, adapter, &input,
58                                      &output);
59
60         if (ACPI_FAILURE(status))
61                 return status;
62
63         printk("mux switched %d\n", status);
64         return 0;
65                             
66 }
67 EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
68
69 int mxm_wmi_call_mxmx(int adapter)
70 {
71         struct mxds_args args = {
72                 .func = MXM_WMMX_FUNC_MXMX,
73                 .args = 0,
74                 .xarg = 1,
75         };
76         struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
77         struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
78         acpi_status status;
79
80         printk("calling mux switch %d\n", adapter);
81
82         status = wmi_evaluate_method(MXM_WMMX_GUID, 0x1, adapter, &input,
83                                      &output);
84
85         if (ACPI_FAILURE(status))
86                 return status;
87
88         printk("mux mutex set switched %d\n", status);
89         return 0;
90                             
91 }
92 EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
93
94 bool mxm_wmi_supported(void)
95 {
96         bool guid_valid;
97         guid_valid = wmi_has_guid(MXM_WMMX_GUID);
98         return guid_valid;
99 }
100 EXPORT_SYMBOL_GPL(mxm_wmi_supported);
101
102 static int __init mxm_wmi_init(void)
103 {
104         return 0;
105 }
106
107 static void __exit mxm_wmi_exit(void)
108 {
109 }
110
111 module_init(mxm_wmi_init);
112 module_exit(mxm_wmi_exit);