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_LICENSE("GPL");
12 static ssize_t
irst_show_wakeup_events(struct device
*dev
,
13 struct device_attribute
*attr
,
16 struct acpi_device
*acpi
;
17 unsigned long long value
;
20 acpi
= to_acpi_device(dev
);
22 status
= acpi_evaluate_integer(acpi
->handle
, "GFFS", NULL
, &value
);
23 if (ACPI_FAILURE(status
))
26 return sprintf(buf
, "%lld\n", value
);
29 static ssize_t
irst_store_wakeup_events(struct device
*dev
,
30 struct device_attribute
*attr
,
31 const char *buf
, size_t count
)
33 struct acpi_device
*acpi
;
38 acpi
= to_acpi_device(dev
);
40 error
= kstrtoul(buf
, 0, &value
);
44 status
= acpi_execute_simple_method(acpi
->handle
, "SFFS", value
);
45 if (ACPI_FAILURE(status
))
51 static struct device_attribute irst_wakeup_attr
= {
52 .attr
= { .name
= "wakeup_events", .mode
= 0600 },
53 .show
= irst_show_wakeup_events
,
54 .store
= irst_store_wakeup_events
57 static ssize_t
irst_show_wakeup_time(struct device
*dev
,
58 struct device_attribute
*attr
, char *buf
)
60 struct acpi_device
*acpi
;
61 unsigned long long value
;
64 acpi
= to_acpi_device(dev
);
66 status
= acpi_evaluate_integer(acpi
->handle
, "GFTV", NULL
, &value
);
67 if (ACPI_FAILURE(status
))
70 return sprintf(buf
, "%lld\n", value
);
73 static ssize_t
irst_store_wakeup_time(struct device
*dev
,
74 struct device_attribute
*attr
,
75 const char *buf
, size_t count
)
77 struct acpi_device
*acpi
;
82 acpi
= to_acpi_device(dev
);
84 error
= kstrtoul(buf
, 0, &value
);
88 status
= acpi_execute_simple_method(acpi
->handle
, "SFTV", value
);
89 if (ACPI_FAILURE(status
))
95 static struct device_attribute irst_timeout_attr
= {
96 .attr
= { .name
= "wakeup_time", .mode
= 0600 },
97 .show
= irst_show_wakeup_time
,
98 .store
= irst_store_wakeup_time
101 static int irst_add(struct acpi_device
*acpi
)
105 error
= device_create_file(&acpi
->dev
, &irst_timeout_attr
);
109 error
= device_create_file(&acpi
->dev
, &irst_wakeup_attr
);
111 device_remove_file(&acpi
->dev
, &irst_timeout_attr
);
116 static int irst_remove(struct acpi_device
*acpi
)
118 device_remove_file(&acpi
->dev
, &irst_wakeup_attr
);
119 device_remove_file(&acpi
->dev
, &irst_timeout_attr
);
124 static const struct acpi_device_id irst_ids
[] = {
129 static struct acpi_driver irst_driver
= {
130 .owner
= THIS_MODULE
,
131 .name
= "intel_rapid_start",
132 .class = "intel_rapid_start",
136 .remove
= irst_remove
,
140 module_acpi_driver(irst_driver
);
142 MODULE_DEVICE_TABLE(acpi
, irst_ids
);