blob: f5f986991b52f8a5a5faae4f3446105e1d2fe2bf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/proc_fs.h>
2#include <linux/seq_file.h>
3#include <linux/suspend.h>
4#include <linux/bcd.h>
5#include <asm/uaccess.h>
6
7#include <acpi/acpi_bus.h>
8#include <acpi/acpi_drivers.h>
9
10#ifdef CONFIG_X86
11#include <linux/mc146818rtc.h>
12#endif
13
14#include "sleep.h"
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#define _COMPONENT ACPI_SYSTEM_COMPONENT
Len Brown43532c82007-07-24 02:16:50 -040017
18/*
19 * this file provides support for:
Len Brown43532c82007-07-24 02:16:50 -040020 * /proc/acpi/alarm
21 * /proc/acpi/wakeup
22 */
23
Len Brown4be44fc2005-08-05 00:44:28 -040024ACPI_MODULE_NAME("sleep")
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Len Brown673d5b42007-07-28 03:33:16 -040026#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || !defined(CONFIG_X86)
David Brownellf5f72b42007-05-08 00:34:02 -070027/* use /sys/class/rtc/rtcX/wakealarm instead; it's not ACPI-specific */
28#else
29#define HAVE_ACPI_LEGACY_ALARM
30#endif
31
32#ifdef HAVE_ACPI_LEGACY_ALARM
33
Len Brown2602a672009-01-09 02:10:16 -050034static u32 cmos_bcd_read(int offset, int rtc_control);
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
37{
Len Brown4be44fc2005-08-05 00:44:28 -040038 u32 sec, min, hr;
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030039 u32 day, mo, yr, cent = 0;
Mark Lord48452e52008-12-09 10:46:30 -050040 u32 today = 0;
Len Brown4be44fc2005-08-05 00:44:28 -040041 unsigned char rtc_control = 0;
42 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 spin_lock_irqsave(&rtc_lock, flags);
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 rtc_control = CMOS_READ(RTC_CONTROL);
Mark Lord48452e52008-12-09 10:46:30 -050047 sec = cmos_bcd_read(RTC_SECONDS_ALARM, rtc_control);
48 min = cmos_bcd_read(RTC_MINUTES_ALARM, rtc_control);
49 hr = cmos_bcd_read(RTC_HOURS_ALARM, rtc_control);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51 /* If we ever get an FACP with proper values... */
Mark Lord48452e52008-12-09 10:46:30 -050052 if (acpi_gbl_FADT.day_alarm) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 /* ACPI spec: only low 6 its should be cared */
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030054 day = CMOS_READ(acpi_gbl_FADT.day_alarm) & 0x3F;
Mark Lord48452e52008-12-09 10:46:30 -050055 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
56 day = bcd2bin(day);
57 } else
58 day = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030059 if (acpi_gbl_FADT.month_alarm)
Mark Lord48452e52008-12-09 10:46:30 -050060 mo = cmos_bcd_read(acpi_gbl_FADT.month_alarm, rtc_control);
61 else {
62 mo = cmos_bcd_read(RTC_MONTH, rtc_control);
63 today = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
64 }
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030065 if (acpi_gbl_FADT.century)
Mark Lord48452e52008-12-09 10:46:30 -050066 cent = cmos_bcd_read(acpi_gbl_FADT.century, rtc_control);
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030067
Mark Lord48452e52008-12-09 10:46:30 -050068 yr = cmos_bcd_read(RTC_YEAR, rtc_control);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70 spin_unlock_irqrestore(&rtc_lock, flags);
71
Len Brown4be44fc2005-08-05 00:44:28 -040072 /* we're trusting the FADT (see above) */
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030073 if (!acpi_gbl_FADT.century)
Len Brown4be44fc2005-08-05 00:44:28 -040074 /* If we're not trusting the FADT, we should at least make it
75 * right for _this_ century... ehm, what is _this_ century?
76 *
77 * TBD:
78 * ASAP: find piece of code in the kernel, e.g. star tracker driver,
79 * which we can trust to determine the century correctly. Atom
80 * watch driver would be nice, too...
81 *
82 * if that has not happened, change for first release in 2050:
83 * if (yr<50)
84 * yr += 2100;
85 * else
86 * yr += 2000; // current line of code
87 *
88 * if that has not happened either, please do on 2099/12/31:23:59:59
89 * s/2000/2100
90 *
91 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 yr += 2000;
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030093 else
94 yr += cent * 100;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Mark Lord48452e52008-12-09 10:46:30 -050096 /*
97 * Show correct dates for alarms up to a month into the future.
98 * This solves issues for nearly all situations with the common
99 * 30-day alarm clocks in PC hardware.
100 */
101 if (day < today) {
102 if (mo < 12) {
103 mo += 1;
104 } else {
105 mo = 1;
106 yr += 1;
107 }
108 }
109
Len Brown4be44fc2005-08-05 00:44:28 -0400110 seq_printf(seq, "%4.4u-", yr);
111 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
112 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
113 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
114 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec);
116
117 return 0;
118}
119
120static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
121{
122 return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data);
123}
124
Len Brown4be44fc2005-08-05 00:44:28 -0400125static int get_date_field(char **p, u32 * value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126{
Len Brown4be44fc2005-08-05 00:44:28 -0400127 char *next = NULL;
128 char *string_end = NULL;
129 int result = -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
131 /*
132 * Try to find delimeter, only to insert null. The end of the
133 * string won't have one, but is still valid.
134 */
Signed-off by Yi Yang975c3022007-12-27 21:50:42 -0500135 if (*p == NULL)
136 return result;
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 next = strpbrk(*p, "- :");
139 if (next)
140 *next++ = '\0';
141
142 *value = simple_strtoul(*p, &string_end, 10);
143
144 /* Signal success if we got a good digit */
145 if (string_end != *p)
146 result = 0;
147
148 if (next)
149 *p = next;
Signed-off by Yi Yang975c3022007-12-27 21:50:42 -0500150 else
151 *p = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
153 return result;
154}
155
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400156/* Read a possibly BCD register, always return binary */
157static u32 cmos_bcd_read(int offset, int rtc_control)
158{
159 u32 val = CMOS_READ(offset);
160 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
Adrian Bunkab527d72008-10-18 20:28:39 -0700161 val = bcd2bin(val);
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400162 return val;
163}
164
165/* Write binary value into possibly BCD register */
166static void cmos_bcd_write(u32 val, int offset, int rtc_control)
167{
168 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
Adrian Bunkab527d72008-10-18 20:28:39 -0700169 val = bin2bcd(val);
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400170 CMOS_WRITE(val, offset);
171}
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173static ssize_t
Len Brown4be44fc2005-08-05 00:44:28 -0400174acpi_system_write_alarm(struct file *file,
175 const char __user * buffer, size_t count, loff_t * ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176{
Len Brown4be44fc2005-08-05 00:44:28 -0400177 int result = 0;
178 char alarm_string[30] = { '\0' };
179 char *p = alarm_string;
180 u32 sec, min, hr, day, mo, yr;
181 int adjust = 0;
182 unsigned char rtc_control = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 if (count > sizeof(alarm_string) - 1)
Lin Ming95d9a7a2008-12-16 16:49:26 +0800185 return -EINVAL;
Len Brown4be44fc2005-08-05 00:44:28 -0400186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 if (copy_from_user(alarm_string, buffer, count))
Lin Ming95d9a7a2008-12-16 16:49:26 +0800188 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
190 alarm_string[count] = '\0';
191
192 /* check for time adjustment */
193 if (alarm_string[0] == '+') {
194 p++;
195 adjust = 1;
196 }
197
198 if ((result = get_date_field(&p, &yr)))
199 goto end;
200 if ((result = get_date_field(&p, &mo)))
201 goto end;
202 if ((result = get_date_field(&p, &day)))
203 goto end;
204 if ((result = get_date_field(&p, &hr)))
205 goto end;
206 if ((result = get_date_field(&p, &min)))
207 goto end;
208 if ((result = get_date_field(&p, &sec)))
209 goto end;
210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 spin_lock_irq(&rtc_lock);
212
213 rtc_control = CMOS_READ(RTC_CONTROL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 if (adjust) {
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400216 yr += cmos_bcd_read(RTC_YEAR, rtc_control);
217 mo += cmos_bcd_read(RTC_MONTH, rtc_control);
218 day += cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
219 hr += cmos_bcd_read(RTC_HOURS, rtc_control);
220 min += cmos_bcd_read(RTC_MINUTES, rtc_control);
221 sec += cmos_bcd_read(RTC_SECONDS, rtc_control);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 }
223
224 spin_unlock_irq(&rtc_lock);
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 if (sec > 59) {
Yi Yang08798022007-12-27 22:04:26 -0500227 min += sec/60;
228 sec = sec%60;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 }
230 if (min > 59) {
Yi Yang08798022007-12-27 22:04:26 -0500231 hr += min/60;
232 min = min%60;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 }
234 if (hr > 23) {
Yi Yang08798022007-12-27 22:04:26 -0500235 day += hr/24;
236 hr = hr%24;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 }
238 if (day > 31) {
Yi Yang08798022007-12-27 22:04:26 -0500239 mo += day/32;
240 day = day%32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 }
242 if (mo > 12) {
Yi Yang08798022007-12-27 22:04:26 -0500243 yr += mo/13;
244 mo = mo%13;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247 spin_lock_irq(&rtc_lock);
248 /*
249 * Disable alarm interrupt before setting alarm timer or else
250 * when ACPI_EVENT_RTC is enabled, a spurious ACPI interrupt occurs
251 */
252 rtc_control &= ~RTC_AIE;
253 CMOS_WRITE(rtc_control, RTC_CONTROL);
254 CMOS_READ(RTC_INTR_FLAGS);
255
256 /* write the fields the rtc knows about */
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400257 cmos_bcd_write(hr, RTC_HOURS_ALARM, rtc_control);
258 cmos_bcd_write(min, RTC_MINUTES_ALARM, rtc_control);
259 cmos_bcd_write(sec, RTC_SECONDS_ALARM, rtc_control);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 /*
262 * If the system supports an enhanced alarm it will have non-zero
263 * offsets into the CMOS RAM here -- which for some reason are pointing
264 * to the RTC area of memory.
265 */
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300266 if (acpi_gbl_FADT.day_alarm)
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400267 cmos_bcd_write(day, acpi_gbl_FADT.day_alarm, rtc_control);
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300268 if (acpi_gbl_FADT.month_alarm)
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400269 cmos_bcd_write(mo, acpi_gbl_FADT.month_alarm, rtc_control);
Huacai Chencce3ce82008-07-04 09:59:31 -0700270 if (acpi_gbl_FADT.century) {
271 if (adjust)
272 yr += cmos_bcd_read(acpi_gbl_FADT.century, rtc_control) * 100;
Linus Torvaldsc67c36e2007-10-17 23:18:32 -0400273 cmos_bcd_write(yr / 100, acpi_gbl_FADT.century, rtc_control);
Huacai Chencce3ce82008-07-04 09:59:31 -0700274 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 /* enable the rtc alarm interrupt */
276 rtc_control |= RTC_AIE;
277 CMOS_WRITE(rtc_control, RTC_CONTROL);
278 CMOS_READ(RTC_INTR_FLAGS);
279
280 spin_unlock_irq(&rtc_lock);
281
282 acpi_clear_event(ACPI_EVENT_RTC);
283 acpi_enable_event(ACPI_EVENT_RTC, 0);
284
285 *ppos += count;
286
287 result = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400288 end:
Lin Ming95d9a7a2008-12-16 16:49:26 +0800289 return result ? result : count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290}
Len Brownfd350942007-05-09 23:34:35 -0400291#endif /* HAVE_ACPI_LEGACY_ALARM */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293static int
294acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
295{
Len Brown4be44fc2005-08-05 00:44:28 -0400296 struct list_head *node, *next;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
David Brownell8aa55592007-04-25 15:20:10 -0400298 seq_printf(seq, "Device\tS-state\t Status Sysfs node\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
Shaohua Li90905892009-04-07 10:24:29 +0800300 mutex_lock(&acpi_device_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
Len Brown4be44fc2005-08-05 00:44:28 -0400302 struct acpi_device *dev =
303 container_of(node, struct acpi_device, wakeup_list);
David Brownell8aa55592007-04-25 15:20:10 -0400304 struct device *ldev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306 if (!dev->wakeup.flags.valid)
307 continue;
David Brownell8aa55592007-04-25 15:20:10 -0400308
309 ldev = acpi_get_physical_device(dev->handle);
310 seq_printf(seq, "%s\t S%d\t%c%-8s ",
Len Brown4be44fc2005-08-05 00:44:28 -0400311 dev->pnp.bus_id,
312 (u32) dev->wakeup.sleep_state,
David Brownell8aa55592007-04-25 15:20:10 -0400313 dev->wakeup.flags.run_wake ? '*' : ' ',
Rafael J. Wysockif2b56bc2011-01-06 23:34:22 +0100314 (device_may_wakeup(&dev->dev)
315 || (ldev && device_may_wakeup(ldev))) ?
316 "enabled" : "disabled");
David Brownell8aa55592007-04-25 15:20:10 -0400317 if (ldev)
318 seq_printf(seq, "%s:%s",
Linus Torvalds77fb61a2008-11-16 10:09:34 -0800319 ldev->bus ? ldev->bus->name : "no-bus",
Kay Sievers07944692008-10-30 01:18:59 +0100320 dev_name(ldev));
David Brownell8aa55592007-04-25 15:20:10 -0400321 seq_printf(seq, "\n");
322 put_device(ldev);
323
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 }
Shaohua Li90905892009-04-07 10:24:29 +0800325 mutex_unlock(&acpi_device_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 return 0;
327}
328
Rafael J. Wysocki76acae02008-10-03 15:23:49 -0700329static void physical_device_enable_wakeup(struct acpi_device *adev)
330{
331 struct device *dev = acpi_get_physical_device(adev->handle);
332
Rafael J. Wysockif2b56bc2011-01-06 23:34:22 +0100333 if (dev && device_can_wakeup(dev)) {
334 bool enable = !device_may_wakeup(dev);
335 device_set_wakeup_enable(dev, enable);
336 }
Rafael J. Wysocki76acae02008-10-03 15:23:49 -0700337}
338
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339static ssize_t
Len Brown4be44fc2005-08-05 00:44:28 -0400340acpi_system_write_wakeup_device(struct file *file,
341 const char __user * buffer,
342 size_t count, loff_t * ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343{
Len Brown4be44fc2005-08-05 00:44:28 -0400344 struct list_head *node, *next;
345 char strbuf[5];
346 char str[5] = "";
Arjan van de Ven52a2b112009-10-01 15:48:40 -0700347 unsigned int len = count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348
Len Brown4be44fc2005-08-05 00:44:28 -0400349 if (len > 4)
350 len = 4;
Arjan van de Vend9f65012009-09-26 20:50:25 +0200351 if (len < 0)
352 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 if (copy_from_user(strbuf, buffer, len))
355 return -EFAULT;
356 strbuf[len] = '\0';
357 sscanf(strbuf, "%s", str);
358
Shaohua Li90905892009-04-07 10:24:29 +0800359 mutex_lock(&acpi_device_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
Len Brown4be44fc2005-08-05 00:44:28 -0400361 struct acpi_device *dev =
362 container_of(node, struct acpi_device, wakeup_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 if (!dev->wakeup.flags.valid)
364 continue;
365
366 if (!strncmp(dev->pnp.bus_id, str, 4)) {
Rafael J. Wysockif2b56bc2011-01-06 23:34:22 +0100367 if (device_can_wakeup(&dev->dev)) {
368 bool enable = !device_may_wakeup(&dev->dev);
369 device_set_wakeup_enable(&dev->dev, enable);
370 } else {
371 physical_device_enable_wakeup(dev);
372 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 break;
374 }
375 }
Shaohua Li90905892009-04-07 10:24:29 +0800376 mutex_unlock(&acpi_device_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 return count;
378}
379
380static int
381acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
382{
Len Brown4be44fc2005-08-05 00:44:28 -0400383 return single_open(file, acpi_system_wakeup_device_seq_show,
384 PDE(inode)->data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
Arjan van de Vend7508032006-07-04 13:06:00 -0400387static const struct file_operations acpi_system_wakeup_device_fops = {
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700388 .owner = THIS_MODULE,
Len Brown4be44fc2005-08-05 00:44:28 -0400389 .open = acpi_system_wakeup_device_open_fs,
390 .read = seq_read,
391 .write = acpi_system_write_wakeup_device,
392 .llseek = seq_lseek,
393 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394};
395
David Brownellf5f72b42007-05-08 00:34:02 -0700396#ifdef HAVE_ACPI_LEGACY_ALARM
Arjan van de Vend7508032006-07-04 13:06:00 -0400397static const struct file_operations acpi_system_alarm_fops = {
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700398 .owner = THIS_MODULE,
Len Brown4be44fc2005-08-05 00:44:28 -0400399 .open = acpi_system_alarm_open_fs,
400 .read = seq_read,
401 .write = acpi_system_write_alarm,
402 .llseek = seq_lseek,
403 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404};
405
Len Brown4be44fc2005-08-05 00:44:28 -0400406static u32 rtc_handler(void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
408 acpi_clear_event(ACPI_EVENT_RTC);
409 acpi_disable_event(ACPI_EVENT_RTC, 0);
410
411 return ACPI_INTERRUPT_HANDLED;
412}
Len Brownfd350942007-05-09 23:34:35 -0400413#endif /* HAVE_ACPI_LEGACY_ALARM */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
Bjorn Helgaas9cee43e2009-03-24 16:50:14 -0600415int __init acpi_sleep_proc_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416{
David Brownellf5f72b42007-05-08 00:34:02 -0700417#ifdef HAVE_ACPI_LEGACY_ALARM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 /* 'alarm' [R/W] */
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700419 proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR,
420 acpi_root_dir, &acpi_system_alarm_fops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
David Brownellf5f72b42007-05-08 00:34:02 -0700422 acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
Zhao Yakuie1094bf2008-05-14 11:32:59 +0800423 /*
424 * Disable the RTC event after installing RTC handler.
425 * Only when RTC alarm is set will it be enabled.
426 */
427 acpi_clear_event(ACPI_EVENT_RTC);
428 acpi_disable_event(ACPI_EVENT_RTC, 0);
Len Brownfd350942007-05-09 23:34:35 -0400429#endif /* HAVE_ACPI_LEGACY_ALARM */
David Brownellf5f72b42007-05-08 00:34:02 -0700430
Pavel Machekc65ade42005-08-05 00:37:45 -0400431 /* 'wakeup device' [R/W] */
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700432 proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
433 acpi_root_dir, &acpi_system_wakeup_device_fops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 return 0;
436}