blob: 898400865f40563abe4e044a4626fbb62691565c [file] [log] [blame]
Matthew Garrett5c7f80f2013-07-03 00:50:13 -04001/*
2 * Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19
20#include <linux/init.h>
21#include <linux/module.h>
22#include <acpi/acpi_drivers.h>
23
24MODULE_LICENSE("GPL");
25
26static int smartconnect_acpi_init(struct acpi_device *acpi)
27{
Matthew Garrett5c7f80f2013-07-03 00:50:13 -040028 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
29 union acpi_object *result;
Matthew Garrett5c7f80f2013-07-03 00:50:13 -040030 acpi_status status;
31
32 status = acpi_evaluate_object(acpi->handle, "GAOS", NULL, &output);
33 if (!ACPI_SUCCESS(status))
34 return -EINVAL;
35
36 result = output.pointer;
37
38 if (result->type != ACPI_TYPE_INTEGER) {
39 kfree(result);
40 return -EINVAL;
41 }
42
43 if (result->integer.value & 0x1) {
Matthew Garrett5c7f80f2013-07-03 00:50:13 -040044 dev_info(&acpi->dev, "Disabling Intel Smart Connect\n");
Zhang Rui77c39852013-09-03 08:31:54 +080045 status = acpi_execute_simple_method(acpi->handle, "SAOS", 0);
Matthew Garrett5c7f80f2013-07-03 00:50:13 -040046 }
47
48 kfree(result);
49
50 return 0;
51}
52
53static const struct acpi_device_id smartconnect_ids[] = {
54 {"INT33A0", 0},
55 {"", 0}
56};
57
58static struct acpi_driver smartconnect_driver = {
59 .owner = THIS_MODULE,
60 .name = "intel_smart_connect",
61 .class = "intel_smart_connect",
62 .ids = smartconnect_ids,
63 .ops = {
64 .add = smartconnect_acpi_init,
65 },
66};
67
Wei Yongjun4d263532013-07-17 09:52:28 +080068module_acpi_driver(smartconnect_driver);
Matthew Garrett5c7f80f2013-07-03 00:50:13 -040069
70MODULE_DEVICE_TABLE(acpi, smartconnect_ids);