1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
6 #include <linux/acpi.h>
7 #include <linux/module.h>
8 #include <linux/slab.h>
10 MODULE_DESCRIPTION("Intel Rapid Start Technology Driver");
11 MODULE_LICENSE("GPL");
13 static ssize_t
irst_show_wakeup_events(struct device
*dev
,
14 struct device_attribute
*attr
,
17 struct acpi_device
*acpi
;
18 unsigned long long value
;
21 acpi
= to_acpi_device(dev
);
23 status
= acpi_evaluate_integer(acpi
->handle
, "GFFS", NULL
, &value
);
24 if (ACPI_FAILURE(status
))
27 return sprintf(buf
, "%lld\n", value
);
30 static ssize_t
irst_store_wakeup_events(struct device
*dev
,
31 struct device_attribute
*attr
,
32 const char *buf
, size_t count
)
34 struct acpi_device
*acpi
;
39 acpi
= to_acpi_device(dev
);
41 error
= kstrtoul(buf
, 0, &value
);
45 status
= acpi_execute_simple_method(acpi
->handle
, "SFFS", value
);
46 if (ACPI_FAILURE(status
))
52 static struct device_attribute irst_wakeup_attr
= {
53 .attr
= { .name
= "wakeup_events", .mode
= 0600 },
54 .show
= irst_show_wakeup_events
,
55 .store
= irst_store_wakeup_events
58 static ssize_t
irst_show_wakeup_time(struct device
*dev
,
59 struct device_attribute
*attr
, char *buf
)
61 struct acpi_device
*acpi
;
62 unsigned long long value
;
65 acpi
= to_acpi_device(dev
);
67 status
= acpi_evaluate_integer(acpi
->handle
, "GFTV", NULL
, &value
);
68 if (ACPI_FAILURE(status
))
71 return sprintf(buf
, "%lld\n", value
);
74 static ssize_t
irst_store_wakeup_time(struct device
*dev
,
75 struct device_attribute
*attr
,
76 const char *buf
, size_t count
)
78 struct acpi_device
*acpi
;
83 acpi
= to_acpi_device(dev
);
85 error
= kstrtoul(buf
, 0, &value
);
89 status
= acpi_execute_simple_method(acpi
->handle
, "SFTV", value
);
90 if (ACPI_FAILURE(status
))
96 static struct device_attribute irst_timeout_attr
= {
97 .attr
= { .name
= "wakeup_time", .mode
= 0600 },
98 .show
= irst_show_wakeup_time
,
99 .store
= irst_store_wakeup_time
102 static int irst_add(struct acpi_device
*acpi
)
106 error
= device_create_file(&acpi
->dev
, &irst_timeout_attr
);
110 error
= device_create_file(&acpi
->dev
, &irst_wakeup_attr
);
112 device_remove_file(&acpi
->dev
, &irst_timeout_attr
);
117 static void irst_remove(struct acpi_device
*acpi
)
119 device_remove_file(&acpi
->dev
, &irst_wakeup_attr
);
120 device_remove_file(&acpi
->dev
, &irst_timeout_attr
);
123 static const struct acpi_device_id irst_ids
[] = {
128 static struct acpi_driver irst_driver
= {
129 .name
= "intel_rapid_start",
130 .class = "intel_rapid_start",
134 .remove
= irst_remove
,
138 module_acpi_driver(irst_driver
);
140 MODULE_DEVICE_TABLE(acpi
, irst_ids
);