3 #include <linux/export.h>
6 #include <asm/uaccess.h>
17 #define _COMPONENT ACPI_SYSTEM_COMPONENT
27 #if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || !defined(CONFIG_X86)
30 #define HAVE_ACPI_LEGACY_ALARM
33 #ifdef HAVE_ACPI_LEGACY_ALARM
37 static int acpi_system_alarm_seq_show(
struct seq_file *seq,
void *
offset)
63 mo = cmos_bcd_read(
RTC_MONTH, rtc_control);
69 yr = cmos_bcd_read(
RTC_YEAR, rtc_control);
71 spin_unlock_irqrestore(&rtc_lock, flags);
123 return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->
data);
126 static int get_date_field(
char **
p,
u32 *
value)
129 char *string_end =
NULL;
146 if (string_end != *p)
158 static u32 cmos_bcd_read(
int offset,
int rtc_control)
167 static void cmos_bcd_write(
u32 val,
int offset,
int rtc_control)
175 acpi_system_write_alarm(
struct file *file,
176 const char __user *
buffer,
size_t count, loff_t * ppos)
179 char alarm_string[30] = {
'\0' };
180 char *p = alarm_string;
183 unsigned char rtc_control = 0;
185 if (count >
sizeof(alarm_string) - 1)
191 alarm_string[
count] =
'\0';
194 if (alarm_string[0] ==
'+') {
199 if ((result = get_date_field(&p, &yr)))
201 if ((result = get_date_field(&p, &mo)))
203 if ((result = get_date_field(&p, &day)))
205 if ((result = get_date_field(&p, &hr)))
207 if ((result = get_date_field(&p, &min)))
209 if ((result = get_date_field(&p, &sec)))
212 spin_lock_irq(&rtc_lock);
217 yr += cmos_bcd_read(
RTC_YEAR, rtc_control);
218 mo += cmos_bcd_read(
RTC_MONTH, rtc_control);
220 hr += cmos_bcd_read(
RTC_HOURS, rtc_control);
225 spin_unlock_irq(&rtc_lock);
248 spin_lock_irq(&rtc_lock);
273 yr += cmos_bcd_read(
acpi_gbl_FADT.century, rtc_control) * 100;
274 cmos_bcd_write(yr / 100,
acpi_gbl_FADT.century, rtc_control);
281 spin_unlock_irq(&rtc_lock);
290 return result ? result :
count;
295 acpi_system_wakeup_device_seq_show(
struct seq_file *seq,
void *offset)
299 seq_printf(seq,
"Device\tS-state\t Status Sysfs node\n");
303 struct acpi_device *
dev =
305 struct acpi_device_physical_node *
entry;
307 if (!dev->wakeup.flags.valid)
312 (
u32) dev->wakeup.sleep_state);
314 if (!dev->physical_node_count)
316 dev->wakeup.flags.run_wake ?
317 '*' :
' ',
"disabled");
327 dev->physical_node_list.next)
331 dev->wakeup.flags.run_wake ?
'*' :
' ',
332 (device_may_wakeup(&dev->dev) ||
333 (ldev && device_may_wakeup(ldev))) ?
334 "enabled" :
"disabled",
335 ldev->
bus ? ldev->
bus->name :
336 "no-bus", dev_name(ldev));
345 static void physical_device_enable_wakeup(
struct acpi_device *adev)
347 struct acpi_device_physical_node *
entry;
350 &adev->physical_node_list, node)
351 if (entry->dev && device_can_wakeup(entry->dev)) {
352 bool enable = !device_may_wakeup(entry->dev);
358 acpi_system_write_wakeup_device(
struct file *file,
359 const char __user * buffer,
360 size_t count, loff_t * ppos)
375 sscanf(strbuf,
"%s", str);
379 struct acpi_device *dev =
381 if (!dev->wakeup.flags.valid)
384 if (!
strncmp(dev->pnp.bus_id, str, 4)) {
385 if (device_can_wakeup(&dev->dev)) {
386 bool enable = !device_may_wakeup(&dev->dev);
389 physical_device_enable_wakeup(dev);
399 acpi_system_wakeup_device_open_fs(
struct inode *inode,
struct file *file)
401 return single_open(file, acpi_system_wakeup_device_seq_show,
407 .open = acpi_system_wakeup_device_open_fs,
409 .write = acpi_system_write_wakeup_device,
414 #ifdef HAVE_ACPI_LEGACY_ALARM
417 .open = acpi_system_alarm_open_fs,
419 .write = acpi_system_write_alarm,
435 #ifdef HAVE_ACPI_LEGACY_ALARM