2 * Support for OLPC XO-1 Real Time Clock (RTC)
4 * Copyright (C) 2011 One Laptop per Child
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/mc146818rtc.h>
13 #include <linux/platform_device.h>
14 #include <linux/rtc.h>
19 #include <asm/x86_init.h>
21 static void rtc_wake_on(struct device
*dev
)
23 olpc_xo1_pm_wakeup_set(CS5536_PM_RTC
);
26 static void rtc_wake_off(struct device
*dev
)
28 olpc_xo1_pm_wakeup_clear(CS5536_PM_RTC
);
31 static struct resource rtc_platform_resource
[] = {
35 .flags
= IORESOURCE_IO
,
40 .flags
= IORESOURCE_IRQ
,
44 static struct cmos_rtc_board_info rtc_info
= {
48 .wake_on
= rtc_wake_on
,
49 .wake_off
= rtc_wake_off
,
52 static struct platform_device xo1_rtc_device
= {
55 .num_resources
= ARRAY_SIZE(rtc_platform_resource
),
56 .dev
.platform_data
= &rtc_info
,
57 .resource
= rtc_platform_resource
,
60 static int __init
xo1_rtc_init(void)
63 struct device_node
*node
;
65 node
= of_find_compatible_node(NULL
, NULL
, "olpc,xo1-rtc");
70 pr_info("olpc-xo1-rtc: Initializing OLPC XO-1 RTC\n");
71 rdmsrl(MSR_RTC_DOMA_OFFSET
, rtc_info
.rtc_day_alarm
);
72 rdmsrl(MSR_RTC_MONA_OFFSET
, rtc_info
.rtc_mon_alarm
);
73 rdmsrl(MSR_RTC_CEN_OFFSET
, rtc_info
.rtc_century
);
75 r
= platform_device_register(&xo1_rtc_device
);
79 x86_platform
.legacy
.rtc
= 0;
81 device_init_wakeup(&xo1_rtc_device
.dev
, 1);
84 arch_initcall(xo1_rtc_init
);