aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2011-06-25 12:34:17 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2011-07-06 17:44:42 -0400
commitcfee95977bea090ae5ec4fd442ebd381792d46c4 (patch)
tree2c82666a095236524def83031ce47f4dd3387237
parente1040ac693bac19eaeafbd6c5fd24d9429b5eeb8 (diff)
x86, olpc: Add XO-1 RTC driver
Add a driver to configure the XO-1 RTC via CS5536 MSRs, to be used as a system wakeup source via olpc-xo1-pm. Device detection is based on finding the relevant device tree node. Signed-off-by: Daniel Drake <dsd@laptop.org> Link: http://lkml.kernel.org/r/1309019658-1712-11-git-send-email-dsd@laptop.org Acked-by: Andres Salomon <dilinger@queued.net> Acked-by: Grant Likely <grant.likely@secretlab.ca> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: devicetree-discuss@lists.ozlabs.org Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--Documentation/devicetree/bindings/rtc/olpc-xo1-rtc.txt5
-rw-r--r--arch/x86/Kconfig7
-rw-r--r--arch/x86/platform/olpc/Makefile1
-rw-r--r--arch/x86/platform/olpc/olpc-xo1-rtc.c81
-rw-r--r--include/linux/cs5535.h5
5 files changed, 99 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/rtc/olpc-xo1-rtc.txt b/Documentation/devicetree/bindings/rtc/olpc-xo1-rtc.txt
new file mode 100644
index 000000000000..a2891ceb6344
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/olpc-xo1-rtc.txt
@@ -0,0 +1,5 @@
1OLPC XO-1 RTC
2~~~~~~~~~~~~~
3
4Required properties:
5 - compatible : "olpc,xo1-rtc"
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index a6aefbbc5cbf..0a9d573a2f9d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2080,6 +2080,13 @@ config OLPC_XO1_PM
2080 ---help--- 2080 ---help---
2081 Add support for poweroff and suspend of the OLPC XO-1 laptop. 2081 Add support for poweroff and suspend of the OLPC XO-1 laptop.
2082 2082
2083config OLPC_XO1_RTC
2084 bool "OLPC XO-1 Real Time Clock"
2085 depends on OLPC_XO1_PM && RTC_DRV_CMOS
2086 ---help---
2087 Add support for the XO-1 real time clock, which can be used as a
2088 programmable wakeup source.
2089
2083config OLPC_XO1_SCI 2090config OLPC_XO1_SCI
2084 bool "OLPC XO-1 SCI extras" 2091 bool "OLPC XO-1 SCI extras"
2085 depends on OLPC && OLPC_XO1_PM && POWER_SUPPLY 2092 depends on OLPC && OLPC_XO1_PM && POWER_SUPPLY
diff --git a/arch/x86/platform/olpc/Makefile b/arch/x86/platform/olpc/Makefile
index 1ec5ade97f44..8922b9b3cd7a 100644
--- a/arch/x86/platform/olpc/Makefile
+++ b/arch/x86/platform/olpc/Makefile
@@ -1,3 +1,4 @@
1obj-$(CONFIG_OLPC) += olpc.o olpc_ofw.o olpc_dt.o 1obj-$(CONFIG_OLPC) += olpc.o olpc_ofw.o olpc_dt.o
2obj-$(CONFIG_OLPC_XO1_PM) += olpc-xo1-pm.o xo1-wakeup.o 2obj-$(CONFIG_OLPC_XO1_PM) += olpc-xo1-pm.o xo1-wakeup.o
3obj-$(CONFIG_OLPC_XO1_RTC) += olpc-xo1-rtc.o
3obj-$(CONFIG_OLPC_XO1_SCI) += olpc-xo1-sci.o 4obj-$(CONFIG_OLPC_XO1_SCI) += olpc-xo1-sci.o
diff --git a/arch/x86/platform/olpc/olpc-xo1-rtc.c b/arch/x86/platform/olpc/olpc-xo1-rtc.c
new file mode 100644
index 000000000000..a2b4efddd61a
--- /dev/null
+++ b/arch/x86/platform/olpc/olpc-xo1-rtc.c
@@ -0,0 +1,81 @@
1/*
2 * Support for OLPC XO-1 Real Time Clock (RTC)
3 *
4 * Copyright (C) 2011 One Laptop per Child
5 *
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.
10 */
11
12#include <linux/mc146818rtc.h>
13#include <linux/platform_device.h>
14#include <linux/rtc.h>
15#include <linux/of.h>
16
17#include <asm/msr.h>
18#include <asm/olpc.h>
19
20static void rtc_wake_on(struct device *dev)
21{
22 olpc_xo1_pm_wakeup_set(CS5536_PM_RTC);
23}
24
25static void rtc_wake_off(struct device *dev)
26{
27 olpc_xo1_pm_wakeup_clear(CS5536_PM_RTC);
28}
29
30static struct resource rtc_platform_resource[] = {
31 [0] = {
32 .start = RTC_PORT(0),
33 .end = RTC_PORT(1),
34 .flags = IORESOURCE_IO,
35 },
36 [1] = {
37 .start = RTC_IRQ,
38 .end = RTC_IRQ,
39 .flags = IORESOURCE_IRQ,
40 }
41};
42
43static struct cmos_rtc_board_info rtc_info = {
44 .rtc_day_alarm = 0,
45 .rtc_mon_alarm = 0,
46 .rtc_century = 0,
47 .wake_on = rtc_wake_on,
48 .wake_off = rtc_wake_off,
49};
50
51static struct platform_device xo1_rtc_device = {
52 .name = "rtc_cmos",
53 .id = -1,
54 .num_resources = ARRAY_SIZE(rtc_platform_resource),
55 .dev.platform_data = &rtc_info,
56 .resource = rtc_platform_resource,
57};
58
59static int __init xo1_rtc_init(void)
60{
61 int r;
62 struct device_node *node;
63
64 node = of_find_compatible_node(NULL, NULL, "olpc,xo1-rtc");
65 if (!node)
66 return 0;
67 of_node_put(node);
68
69 pr_info("olpc-xo1-rtc: Initializing OLPC XO-1 RTC\n");
70 rdmsrl(MSR_RTC_DOMA_OFFSET, rtc_info.rtc_day_alarm);
71 rdmsrl(MSR_RTC_MONA_OFFSET, rtc_info.rtc_mon_alarm);
72 rdmsrl(MSR_RTC_CEN_OFFSET, rtc_info.rtc_century);
73
74 r = platform_device_register(&xo1_rtc_device);
75 if (r)
76 return r;
77
78 device_init_wakeup(&xo1_rtc_device.dev, 1);
79 return 0;
80}
81arch_initcall(xo1_rtc_init);
diff --git a/include/linux/cs5535.h b/include/linux/cs5535.h
index 72954c6bf5d6..c077aec3a6ff 100644
--- a/include/linux/cs5535.h
+++ b/include/linux/cs5535.h
@@ -40,6 +40,10 @@
40#define MSR_MFGPT_NR 0x51400029 40#define MSR_MFGPT_NR 0x51400029
41#define MSR_MFGPT_SETUP 0x5140002B 41#define MSR_MFGPT_SETUP 0x5140002B
42 42
43#define MSR_RTC_DOMA_OFFSET 0x51400055
44#define MSR_RTC_MONA_OFFSET 0x51400056
45#define MSR_RTC_CEN_OFFSET 0x51400057
46
43#define MSR_LX_SPARE_MSR 0x80000011 /* DC-specific */ 47#define MSR_LX_SPARE_MSR 0x80000011 /* DC-specific */
44 48
45#define MSR_GX_GLD_MSR_CONFIG 0xC0002001 49#define MSR_GX_GLD_MSR_CONFIG 0xC0002001
@@ -95,6 +99,7 @@ static inline int cs5535_pic_unreqz_select_high(unsigned int group,
95 99
96/* CS5536_PM1_EN bits */ 100/* CS5536_PM1_EN bits */
97#define CS5536_PM_PWRBTN (1 << 8) 101#define CS5536_PM_PWRBTN (1 << 8)
102#define CS5536_PM_RTC (1 << 10)
98 103
99/* CS5536_PM_GPE0_STS bits */ 104/* CS5536_PM_GPE0_STS bits */
100#define CS5536_GPIOM7_PME_FLAG (1 << 31) 105#define CS5536_GPIOM7_PME_FLAG (1 << 31)