linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <marcelo@kvack.org>
To: David Brownell <david-b@pacbell.net>
Cc: linux-pm@lists.linux-foundation.org, devel@laptop.org,
	linux-acpi@vger.kernel.org
Subject: [PATCH] OLPC rtc-cmos support
Date: Sat, 7 Jul 2007 23:55:04 -0400	[thread overview]
Message-ID: <20070708035504.GC19633@dmt> (raw)
In-Reply-To: <20070402165511.GD5024@cosmic.amd.com>


Hi,

The following patch implements the hooks necessary for OLPC to use the
rtc-cmos driver. This is necessary since we do not want CONFIG_PNP.

This makes it possible to control rtc wakeup via
/sys/devices/platform/rtc_cmos/power/wakeup.

Comments?


diff --git a/arch/i386/kernel/olpc-pm.c b/arch/i386/kernel/olpc-pm.c
index 9599dbe..d92c54a 100644
--- a/arch/i386/kernel/olpc-pm.c
+++ b/arch/i386/kernel/olpc-pm.c
@@ -11,6 +11,9 @@ #include <linux/delay.h>
 #include <linux/input.h>
 #include <linux/suspend.h>
 #include <linux/bootmem.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+#include <linux/mc146818rtc.h>
 #include <asm/io.h>
 
 #include <asm/olpc.h>
@@ -272,6 +275,8 @@ static int olpc_pm_enter(suspend_state_t
 	return 0;
 }
 
+static u16 olpc_wakeup_mask = CS5536_PM_PWRBTN;
+
 int asmlinkage olpc_do_sleep(u8 sleep_state)
 {
 	void *pgd_addr = __va(read_cr3());
@@ -282,7 +287,7 @@ int asmlinkage olpc_do_sleep(u8 sleep_st
 
 	/* FIXME:  Set any other SCI events that we might want here */
 
-	outl((CS5536_PM_PWRBTN << 16) | 0xFFFF, acpi_base + PM1_STS);
+	outl((olpc_wakeup_mask << 16) | 0xFFFF, acpi_base + PM1_STS);
 
 	/* If we are in test mode, then just return (simulate a successful
 	   suspend/resume).  Otherwise, if we are doing the real thing,
@@ -549,6 +554,92 @@ static int __init olpc_pm_init(void)
 	return 0;
 }
 
+
+#if defined (CONFIG_RTC_DRV_CMOS) || defined (CONFIG_RTC_DRV_CMOS_MODULE)
+struct resource rtc_platform_resource[2] = {
+	{
+		.flags		= IORESOURCE_IO,
+		.start		= RTC_PORT(0),
+		.end		= RTC_PORT(0) + RTC_IO_EXTENT
+	},
+	{
+		.flags = IORESOURCE_IRQ,
+		.start = 8,
+		.end = 8,
+	},
+};
+
+struct resource rtc_platform_irq = {
+	.flags = IORESOURCE_IRQ,
+	.start = 8,
+	.end = 8,
+};
+
+static int olpc_add_rtc(void)
+{
+	struct platform_device *pd;
+
+	pd = platform_device_register_simple("rtc_cmos", -1,
+					     rtc_platform_resource, 2);
+	if (IS_ERR(pd)) 
+		return PTR_ERR(pd);
+
+	/* rtc-cmos only supports 24-hr mode */
+	CMOS_WRITE(CMOS_READ(RTC_CONTROL) | RTC_24H, RTC_CONTROL);
+
+	return 0;
+}
+arch_initcall(olpc_add_rtc);
+
+static struct cmos_rtc_board_info rtc_info;
+
+static void rtc_wake_on(struct device *dev)
+{
+	olpc_wakeup_mask |= CS5536_PM_RTC;
+}
+
+static void rtc_wake_off(struct device *dev)
+{
+	olpc_wakeup_mask &= ~(CS5536_PM_RTC);
+}
+
+static int rtc_match(struct device *dev, void *data)
+{
+	static const char *devname = { "rtc_cmos" };
+	struct rtc_device *rtcdev = to_rtc_device(dev);
+
+	if (!strcmp(devname, rtcdev->name))
+		return 1;
+
+	return 0;
+}
+
+static struct device * get_rtc_dev(void)
+{
+        return bus_find_device(&platform_bus_type, NULL, NULL, rtc_match);
+}
+
+static int olpc_rtc_init(void)
+{
+	struct device *dev = get_rtc_dev();
+
+	if (dev) {
+		rtc_info.rtc_day_alarm = 0;
+		rtc_info.rtc_mon_alarm = 0;
+		rtc_info.rtc_century = 0;
+		rtc_info.wake_on = rtc_wake_on;
+		rtc_info.wake_off = rtc_wake_off;
+
+		dev->platform_data = &rtc_info;
+
+		device_init_wakeup(dev, 1);
+	} else 
+		printk(KERN_ERR "no rtc\n");
+	return 0;
+}
+fs_initcall(olpc_rtc_init);
+#endif /* CONFIG_RTC_DRV_CMOS */
+
 static void olpc_pm_exit(void)
 {
 	/* Clear any pending events, and disable them */

  parent reply	other threads:[~2007-07-08  3:55 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-30 23:57 Power Mangement Interfaces Jordan Crouse
2007-03-31  0:18 ` Johannes Berg
2007-03-31  0:21   ` Johannes Berg
2007-03-31  4:33     ` [linux-pm] " Gopi P.M.
2007-03-31 15:20     ` Jordan Crouse
2007-03-31 16:12     ` David Brownell
2007-03-31 15:16   ` Jordan Crouse
2007-04-02  7:38     ` [linux-pm] " Pavel Machek
2007-03-31 16:57   ` David Brownell
2007-03-31 16:52 ` David Brownell
2007-03-31 18:16   ` Jordan Crouse
2007-03-31 18:57     ` David Brownell
2007-04-01  1:01       ` Jordan Crouse
2007-04-01  3:01         ` David Brownell
2007-04-01 16:56           ` Jordan Crouse
2007-04-02  0:28             ` David Brownell
2007-04-02 16:55               ` Jordan Crouse
2007-04-02 17:53                 ` David Brownell
2007-07-08  3:46                 ` rtc-cmos not supporting RTC_AIE? Marcelo Tosatti
2007-07-08  5:26                   ` David Brownell
2007-07-08 19:03                     ` Marcelo Tosatti
2007-07-08 19:17                       ` David Brownell
2007-07-08 19:31                         ` Richard Hughes
2007-07-08 20:15                           ` Hibernate after alarm wakes from STR David Brownell
2007-07-08 22:31                             ` Marcelo Tosatti
2007-07-09  2:44                               ` David Brownell
2007-07-09  8:34                                 ` Richard Hughes
2007-07-09 15:40                                 ` Marcelo Tosatti
2007-07-09 16:26                                   ` David Brownell
2007-07-10  2:45                                     ` [linux-pm] " Nigel Cunningham
2007-07-10 16:51                                       ` David Brownell
2007-07-10 22:16                                         ` Nigel Cunningham
2007-07-11  0:45                                           ` Matthew Garrett
2007-07-11  0:53                                             ` Nigel Cunningham
2007-07-11  1:23                                               ` Matthew Garrett
2007-07-11  1:39                                                 ` Nigel Cunningham
2007-07-11  1:59                                                   ` Matthew Garrett
2007-07-11  3:14                                                     ` Nigel Cunningham
2007-07-11 10:09                                                       ` Rafael J. Wysocki
2007-07-11 10:14                                                         ` Nigel Cunningham
2007-07-11 10:31                                                           ` Rafael J. Wysocki
2007-07-11 16:04                                           ` David Brownell
2007-07-11 22:48                                             ` Nigel Cunningham
2007-07-08  3:49                 ` [PATCH] rtc-cmos: use cmos_rtc_board_info to determine wake_on callback Marcelo Tosatti
2007-07-08  5:06                   ` David Brownell
2007-07-08  3:55                 ` Marcelo Tosatti [this message]
2007-07-08  5:13                   ` [PATCH] OLPC rtc-cmos support David Brownell
2007-07-08 18:40                     ` Marcelo Tosatti
2007-07-08 19:10                       ` David Brownell
2007-07-08 20:17                         ` Marcelo Tosatti
2007-07-08 20:47                           ` David Brownell
2007-06-19 17:00               ` Power Mangement Interfaces Marcelo Tosatti
2007-06-19 19:17                 ` Jens Axboe
2007-06-19 19:41                 ` Woodruff, Richard
2007-06-21  1:30                 ` David Brownell
2007-07-08 22:10                   ` [PATCH] add powerbutton and lid platform devices Marcelo Tosatti
2007-07-09 15:05                     ` Jordan Crouse
2007-07-09 16:30                       ` David Brownell
2007-07-09 16:36                         ` Jordan Crouse
2007-07-16  8:51                         ` Richard Hughes
2007-07-16 17:11                       ` C. Scott Ananian
2007-04-02 10:23           ` Power Mangement Interfaces Zhang Rui
2007-04-02 18:24             ` David Brownell
2007-04-02 19:40               ` Matthew Garrett
2007-04-02 21:31                 ` David Brownell
2007-04-05  8:20               ` Zhang Rui
2007-04-02 10:07       ` Zhang Rui
2007-03-31 19:14     ` Jim Gettys
2007-04-02  9:36 ` Zhang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070708035504.GC19633@dmt \
    --to=marcelo@kvack.org \
    --cc=david-b@pacbell.net \
    --cc=devel@laptop.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).