2 * Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
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.
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.
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.
20 #include <linux/init.h>
21 #include <linux/module.h>
22 #include <linux/slab.h>
23 #include <acpi/acpi_drivers.h>
25 MODULE_LICENSE("GPL");
27 static ssize_t irst_show_wakeup_events(struct device *dev,
28 struct device_attribute *attr,
31 struct acpi_device *acpi;
32 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
33 union acpi_object *result;
36 acpi = to_acpi_device(dev);
38 status = acpi_evaluate_object(acpi->handle, "GFFS", NULL, &output);
39 if (!ACPI_SUCCESS(status))
42 result = output.pointer;
44 if (result->type != ACPI_TYPE_INTEGER) {
49 return sprintf(buf, "%lld\n", result->integer.value);
52 static ssize_t irst_store_wakeup_events(struct device *dev,
53 struct device_attribute *attr,
54 const char *buf, size_t count)
56 struct acpi_device *acpi;
61 acpi = to_acpi_device(dev);
63 error = kstrtoul(buf, 0, &value);
68 status = acpi_execute_simple_method(acpi->handle, "SFFS", value);
70 if (!ACPI_SUCCESS(status))
76 static struct device_attribute irst_wakeup_attr = {
77 .attr = { .name = "wakeup_events", .mode = 0600 },
78 .show = irst_show_wakeup_events,
79 .store = irst_store_wakeup_events
82 static ssize_t irst_show_wakeup_time(struct device *dev,
83 struct device_attribute *attr, char *buf)
85 struct acpi_device *acpi;
86 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
87 union acpi_object *result;
90 acpi = to_acpi_device(dev);
92 status = acpi_evaluate_object(acpi->handle, "GFTV", NULL, &output);
93 if (!ACPI_SUCCESS(status))
96 result = output.pointer;
98 if (result->type != ACPI_TYPE_INTEGER) {
103 return sprintf(buf, "%lld\n", result->integer.value);
106 static ssize_t irst_store_wakeup_time(struct device *dev,
107 struct device_attribute *attr,
108 const char *buf, size_t count)
110 struct acpi_device *acpi;
115 acpi = to_acpi_device(dev);
117 error = kstrtoul(buf, 0, &value);
122 status = acpi_execute_simple_method(acpi->handle, "SFTV", value);
124 if (!ACPI_SUCCESS(status))
130 static struct device_attribute irst_timeout_attr = {
131 .attr = { .name = "wakeup_time", .mode = 0600 },
132 .show = irst_show_wakeup_time,
133 .store = irst_store_wakeup_time
136 static int irst_add(struct acpi_device *acpi)
140 error = device_create_file(&acpi->dev, &irst_timeout_attr);
144 error = device_create_file(&acpi->dev, &irst_wakeup_attr);
151 device_remove_file(&acpi->dev, &irst_timeout_attr);
156 static int irst_remove(struct acpi_device *acpi)
158 device_remove_file(&acpi->dev, &irst_wakeup_attr);
159 device_remove_file(&acpi->dev, &irst_timeout_attr);
164 static const struct acpi_device_id irst_ids[] = {
169 static struct acpi_driver irst_driver = {
170 .owner = THIS_MODULE,
171 .name = "intel_rapid_start",
172 .class = "intel_rapid_start",
176 .remove = irst_remove,
180 module_acpi_driver(irst_driver);
182 MODULE_DEVICE_TABLE(acpi, irst_ids);