more rtc framework/driver updates
Subsystems (5)
cover more rtc framework/driver updates
Here are more RTC framework updates, basically for the 2.6.20 queue:
- /proc/driver/rtc update ... display the 'struct rtc_wkalrm' status bits more sensibly (though the EFI "irq pending" flag is nonsense with an OS running)
- rtc-sa1100 update ... wasn't reporting "alarm enabled", and its extra procfs info duplicated information already found there
- X86_PC updates ... create an rtc_cmos platform device when PNPACPI isn't available do make one through PNP. (Non-PC platforms can do similar things if they have a "cmos" RTC.)
- Export ACPI RTC extensions through platform_data to the PNP device or the platform device, as appropriate.
- New "rtc-cmos" driver, for the RTC on most PCs. For most folk this seems like it should be able to replace drivers/char/rtc.c ...
- Newish "rtc-omap" driver, for the RTC on OMAP1 processors. No point in having this just live in the OMAP tree.
Folk wanting to try "rtc-cmos" will likely be wanting to tweak their /dev/rtc node to become a symlink to /dev/rtc0, at least until the new version of util-linux comes out (with updated "hwclock" knowing about the new RTC class devices).
- Dave
PATCH 1/6 rtc class /proc/driver/rtc update
Fix two minor botches in the procfs dumping of RTC alarm status:
- Stop confusing "alarm enabled" with "wakeup enabled".
- Don't display bogus "irq pending/un-acked" status; those are the rather pointless semantics EFI assigned to this (for a no-IRQs environment).
The main RTC that seems confused about this is the sa1100 one, which doesn't actually report whether it enabled the alarm.
drivers/rtc/rtc-proc.c +4 -2
@@ -66,9 +66,11 @@ static int rtc_proc_show(struct seq_fileelse seq_printf (seq,"**\n" );seq_printf (seq,"alrm_wakeup\t: %s\n" , +device_may_wakeup (class_dev->dev) + ?"yes" :"no" ); +seq_printf (seq,"alrm_enabled\t: %s\n" , alrm.enabled ?"yes" :"no" ); -seq_printf (seq,"alrm_pending\t: %s\n" , - alrm.pending ?"yes" :"no" ); +/* alrm.pending ("irq un-acked") is useless ... */ }seq_printf (seq,"24hr\t\t: yes\n" );
Re: [patch 2.6.19-rc6 1/6] rtc class /proc/driver/rtc update
Quoted 6 lines · On Mon, 20 Nov 2006 10:17:19 -0800 David Brownell <[email protected]> wrote:
Fix two minor botches in the procfs dumping of RTC alarm status:
- Stop confusing "alarm enabled" with "wakeup enabled".
- Don't display bogus "irq pending/un-acked" status; those are the rather pointless semantics EFI assigned to this (for a no-IRQs environment).
I wouldn't change that, the /proc interface to rtc is old and should not be used anyhow. Here I'm trying to mimic the behaviour of the original one.
sysfs provides a much better interface
(once we'll have all the attributes exported, of course :) )
I don't know if there's any user space tool relying on this. If yes, then it should be fixed.
Any thoughts?
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it
Re: [Bulk] Re: [patch 2.6.19-rc6 1/6] rtc class /proc/driver/rtc update
Quoted 5 lines · Alessandro Zummo
Quoted 2 lines · On Mon, 20 Nov 2006 10:17:19 -0800 David Brownell <[email protected]> wrote:
Fix two minor botches in the procfs dumping of RTC alarm status:
Quoted 8 lines
Quoted 4 lines
- Stop confusing "alarm enabled" with "wakeup enabled".
- Don't display bogus "irq pending/un-acked" status; those are the rather pointless semantics EFI assigned to this (for a no-IRQs environment).
I wouldn't change that, the /proc interface to rtc is old and should not be used anyhow. Here I'm trying to mimic the behaviour of the original one.
The "original" one never had such fields. Even the efirtc.c code (which originated those flags) didn't call them that; it used "Enabled" not "alrm_enabled", so at least this patch moves closer to that "original" behavior.
Quoted 2 lines
sysfs provides a much better interface
(once we'll have all the attributes exported, of course :) )
That's an orthgonal issue. (Though one can argue that the procfs file should be /proc/driver/rtc0 etc, one per RTC, rather than /proc/driver/rtc...)
Quoted 1 line
I don't know if there's any user space tool relying on this.
There shouldn't be any code parsing /proc/driver/rtc ... if there is such stuff, it's already got so many variants to cope with that adding one that actually matches the rest of the system would be a net simplification.
Quoted 3 lines
If yes, then it should be fixed.
Any thoughts?
The whole RTC framework is still labeled "experimental", and AFAIK I'm the first person to audit the use of those flags.
Until it's no longer experimental, I have a hard time thinking that backwards compatibility should prevent fixing such interface bugs ... interface bugs are normally in the "fix ASAP" category, since if you delay fixing them the costs grow exponentially.
- Dave
Re: [Bulk] Re: [patch 2.6.19-rc6 1/6] rtc class /proc/driver/rtc update
Quoted 8 lines · On Mon, 20 Nov 2006 18:47:57 -0800 David Brownell <[email protected]> wrote:
Quoted 3 lines
I wouldn't change that, the /proc interface to rtc is old and should not be used anyhow. Here I'm trying to mimic the behaviour of the original one.
The "original" one never had such fields. Even the
efirtc.ccode (which originated those flags) didn't call them that; it used "Enabled" not "alrm_enabled", so at least this patch moves closer to that "original" behavior.
[..]
Quoted 7 lines
Quoted 1 line
I don't know if there's any user space tool relying on this.
There shouldn't be any code parsing
/proc/driver/rtc... if there is such stuff, it's already got so many variants to cope with that adding one that actually matches the rest of the system would be a net simplification.
Quoted 7 lines
The whole RTC framework is still labeled "experimental", and AFAIK I'm the first person to audit the use of those flags.
Until it's no longer experimental, I have a hard time thinking that backwards compatibility should prevent fixing such interface bugs ... interface bugs are normally in the "fix ASAP" category, since if you delay fixing them the costs grow exponentially.
given the experimental status, I'm inclined to remove the /proc driver right now.
Any objection?
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it
Re: [patch 2.6.19-rc6 1/6] rtc class /proc/driver/rtc update
Quoted 3 lines · Alessandro Zummo
given the experimental status, I'm inclined to remove the /proc driver right now.
I actually prefer the /proc/driver/rtc* file to the sysfs stuff. Even though some people would call that "politically incorrect".
- Dave
PATCH 2/6 rtc-sa1100 tweaks
In reply to David BrownellMinor updates to rtc-sa1100: report whether the alarm is enabled, remove duplicate procfs reporting of that factoid, and stick a FIXME at a place where alarms should be enabled (but aren't).
drivers/rtc/rtc-sa1100.c +6 -3
@@ -263,8 +263,12 @@ static int sa1100_rtc_set_time(struct destatic int sa1100_rtc_read_alarm (struct device *dev,struct rtc_wkalrm *alrm) { +u32 rtsr; +memcpy (&alrm->time, &rtc_alarm,sizeof (struct rtc_time )); - alrm->pending =RTSR &RTSR_AL ?1 :0 ; + rtsr =RTSR ; + alrm->pending = (rtsr &RTSR_AL ) ?1 :0 ; + alrm->enabled = (rtsr &RTSR_ALE ) ?1 :0 ;return 0 ; }
@@ -277,6 +281,7 @@ static int sa1100_rtc_set_alarm(struct dif (ret ==0 ) {memcpy (&rtc_alarm, &alrm->time,sizeof (struct rtc_time )); +/* FIXME 'enabled' should update RTSR_ALE instead */ if (alrm->enabled)enable_irq_wake (IRQ_RTCAlrm);else
@@ -290,8 +295,6 @@ static int sa1100_rtc_set_alarm(struct dstatic int sa1100_rtc_proc (struct device *dev,struct seq_file *seq) {seq_printf (seq,"trim/divider\t: 0x%08lx\n" ,RTTR ); -seq_printf (seq,"alarm_IRQ\t: %s\n" , - (RTSR &RTSR_ALE ) ?"yes" :"no" );seq_printf (seq,"update_IRQ\t: %s\n" , (RTSR &RTSR_HZE ) ?"yes" :"no" ); seq_printf(seq, "periodic_IRQ\t: %s\n",
Re: [patch 2.6.19-rc6 2/6] rtc-sa1100 tweaks
Quoted 3 lines · David Brownell
Minor updates to rtc-sa1100: report whether the alarm is enabled, remove duplicate procfs reporting of that factoid, and stick a FIXME at a place where alarms should be enabled (but aren't).
I think you're rather confused about alarms, but you're going to tell me that it's me who is no doubt, so I'm not sure why I'm bothering to write this mail.
The pre-rtc-lib user API was as follows:
- ALM_SET - sets the time of the alarm, does not enable or disable current alarm settings
- AIE_ON - enables alarm interrupts
- AIE_OFF - disables alarm interrupts
- WKALM_SET - sets the wake up alarm, enables wake up alarm, indicates whether wake up alarm is pending
So, alrm->enabled indicates _independently_ of the alarm interrupt whether this should cause a wakeup, as per the SA1100 driver. Whether a wakeup can occur with or without AIE_ON is implementation defined.
Now, if the new RTC library treats this differently, then /it's/ changing the userspace API and is therefore buggy.
Note also that _lots_ of drivers don't support these new weird device_set_wakeup_enable() and device_may_wakeup() calls - it seems that there's an exercise for someone to go through and add a load of device_set_wakeup_enable() before we go trying to use device_may_wakeup() on those devices. I'm not presently sure what they're supposed to do or achieve.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [patch 2.6.19-rc6 2/6] rtc-sa1100 tweaks
Quoted 8 lines · Russell King
Quoted 3 lines · David Brownell
Minor updates to rtc-sa1100: report whether the alarm is enabled, remove duplicate procfs reporting of that factoid, and stick a FIXME at a place where alarms should be enabled (but aren't).
I think you're rather confused about alarms, but you're going to tell me that it's me who is no doubt, so I'm not sure why I'm bothering to write this mail.
Because you think it likely that more than one person is confused, and you're 100% certain that will continue unless someone like you asks a question to help sort it out? :)
Quoted 1 line
The pre-rtc-lib user API was as follows:
There were actually several such APIs. Most tried to act like the drivers/char/rtc.c driver (/dev/rtc on a PC), but of course not all RTCs are at heart MC146818 clones.
ARM is as usual a rich source of counter-examples, with varying capabilities; and it has its own RTC API, now being more or less replaced by the generic framework. (I only see Integrator left in terms of in-tree callers.)
Quoted 4 lines
-
ALM_SET- sets the time of the alarm, does not enable or disable current alarm settings
-AIE_ON- enables alarm interrupts
-AIE_OFF- disables alarm interrupts
Agreed; that's what the PC "rtc.c" did, and most drivers did a good job of emulating those parts.
One thing that seemed to vary between drivers though: just what an "alarm setting" is. A MC146818 supports only HH:MM:SS alarms, but any of those fields can be wildcards. Lots of drivers implemented that without the wildcard functionality. Some also handled DD-MON, or DD-MON-YEAR specifiers.
I believe that for Linux today, that wildcard functionality is in the "nonportable behavior" category.
Quoted 2 lines
-
WKALM_SET- sets the wake up alarm, enables wake up alarm, indicates whether wake up alarm is pending
Sort of. Semantics varied a lot.
Near as I can tell, WKALM_SET joined us with IA64 and the "efirtc.c" driver (/dev/efirtc on IA64) which **DOES NOT** implement the other calls above ... and implemented WKALM_SET by punting directly to EFI firmware. Ditto its sibling WKALM_GET.
(The arch/arm/common/rtctime.c code seems to have come about four years after the efirtc.c driver, and defined *different* semantics for those calls ...)
Now, I happened to look up what EFI said about the semantics of those firmware requests. Summarizing its manual, the two RTC calls are:
SET ... takes a YYYY-MON-DD HH:MM:SS date and an enable flag,
which affects "wakeup" (including power on)
GET ... returns the above, plus a "irq pending" flag, which is
cleared by calling SET with enable=false (and date=ignored)
The original definition of the WKLAM_* ioctls on Linux was operationally, with respect to EFI firmware.
Quoted 2 lines
So,
alrm->enabledindicates _independently_ of the alarm interrupt whether this should cause a wakeup, as per the SA1100 driver.
Not according to the EFI docs. There is no other way to enable an alarm, and there is no way to enable an alarm that doesn't do system wakeup. They're joined at the hip, and there's no such notion as AIE_ON.
Quoted 2 lines
Whether a wakeup
can occur with or withoutAIE_ONis implementation defined.
See above ... a program expecting /dev/rtc0 and /dev/efirtc to act the same would justifiably say it's a bug if WKALM_SET wasn't a one-stop-shopping solution for setting and activating the alarm.
Quoted 2 lines
Now, if the new RTC library treats this differently, then /it's/ changing the userspace API and is therefore buggy.
As shown above, it's not changing WKALM_SET ... at least in the way you described, since AIE_ON has always been implicit there. It's quite possible that folk implementing that call in the ARM framework were not implementing those original semantics ("therefore buggy").
So it's arguable just how that call should be implemented. The original definition seems clear, and that's what I've tried to use; although that whole "pending" thing does not make sense to me if there are real IRQs.
It seemed to me that the consensus about how to implement WKLALM_SET (judging just by votes in drivers/rtc/*.c drivers) is: (a) it's a combination of ALM_SET plus either AIE_ON or AIE_OFF, as with EFI;
(b) unlike ALM_SET, it supports alarms more than 24 hours in the future; and (c) system wakeup, or lack thereof, is orthogonal to the basic alarm functionality.
Quoted 4 lines
Note also that _lots_ of drivers don't support these new weird
device_set_wakeup_enable()anddevice_may_wakeup()calls - it seems that there's an exercise for someone to go through and add a load ofdevice_set_wakeup_enable()
Wakeup is only relevant for PM-enabled platforms, and there aren't all that many PM-enabled platforms in the first place. And among those, there are darn few that support wakeup events sanely ... with PCs solidly in the "does not support wakeup" category.
Initialization of wakeup-capable devices should device_init_wakeup().
Probably the best example of how to do that is in the at91rm9200 code, where many drivers -- CF, MMC, USB host, USB peripheral, RTC, and more -- are all wakeup-enabled.
Quoted 3 lines
before we go trying to use
device_may_wakeup()
on those devices. I'm not presently sure what they're supposed to do or achieve.
Drivers should use device_may_wakeup() to decide whether they should enable their wakeup capabilities. By default the answer is "yes" if the hardware allows it. Userspace can change that, and would do so for two basic reasons:
(1) It might not work correctly on a given system, even when it looks to the kernel as if it should. Maybe some switch wore out; I have a USB mouse that lies about being wakeup-capable.
(2) Drivers can usually save more power if they don't have to be wakeup-capable. If disabling a few wakeup event sources were to save 20 mA battery power, that could be very critical in the effort to get another few hours out of a charge.
Plus of course just not wanting a particular thing to be a wakeup event ... maybe inserting an MMC or CF card isn't such a big deal on one system as it is on another.
- Dave
PATCH 3/6 X86_PC optionally creates rtc_cmos platform device
In reply to David BrownellUpdate X86_PC platforms (i386, x86_64) to create an "rtc_cmos" platform device when PNPACPI won't be creating a corresponding PNP node for us. There may be other platform devices that should get corresponding treatment; it might help get rid of more legacy ISA probing logic.
arch/x86_64/kernel/setup.c +51 -15
@@ -1212,22 +1212,58 @@ struct seq_operations cpuinfo_op = { .show = show_cpuinfo, }; -#if defined(CONFIG_INPUT_PCSPKR ) || defined(CONFIG_INPUT_PCSPKR_MODULE ) + +#ifdef CONFIG_X86_PC +#include <linux/platform_device.h> -static __init int add_pcspkr (void ) -{ -struct platform_device *pd; -int ret; +#include <asm/mc146818rtc.h> + +#if defined(CONFIG_INPUT_PCSPKR ) || defined(CONFIG_INPUT_PCSPKR_MODULE ) +static struct platform_device pcspkr_dev = { + .name ="pcspkr" , + .id =-1 , +}; +#endif /* PCSPKR */ - pd =platform_device_alloc ("pcspkr" ,-1 ); -if (!pd) -return -ENOMEM ; - - ret =platform_device_add (pd); -if (ret) -platform_device_put (pd); +#ifndef CONFIG_PNPACPI +struct resource rtc_platform_resources[] = { { + .flags =IORESOURCE_IO , + .start =RTC_PORT (0 ), + .end =RTC_PORT (1 ), +}, { + .flags =IORESOURCE_IRQ , + .start =RTC_IRQ +} }; -return ret; -} -device_initcall (add_pcspkr); +struct platform_device rtc_dev = { + .name ="rtc_cmos" , + .id =-1 , + .resource = rtc_platform_resources, + .num_resources =ARRAY_SIZE (rtc_platform_resources), +}; +#endif /* !PNPACPI */ + +static struct platform_device *x86_pc_devs[] __initdata = { +#if defined(CONFIG_INPUT_PCSPKR ) || defined(CONFIG_INPUT_PCSPKR_MODULE ) + &pcspkr_dev, +#endif +#ifndef CONFIG_PNPACPI + &rtc_dev, +#endif +}; + +static __init int add_devices (void ) +{ +#ifndef CONFIG_PNPACPI +/* On most motherboards starting with ATX (1995+), +* RTC alarms can wake the system +*/ +device_init_wakeup (&rtc_dev.dev,1 );#endif + +return platform_add_devices (x86_pc_devs,ARRAY_SIZE (x86_pc_devs)); +} +arch_initcall (add_devices); + +#endif /* X86_PC */ +
arch/i386/kernel/setup.c +47 -13
69 lines not on this page · raw message
PATCH 4/6 ACPI exports RTC extensions through platform_data
In reply to David BrownellDefine platform_data for the MC146818 based RTCs, currently just holding extensions standardized by ACPI (but available on some ACPI-neutral clones).
Update ACPI to export that RTC extension information through platform_data to the PNP or platform bus device node.
include/linux/mc146818rtc.h +12 -0
@@ -18,6 +18,18 @@#ifdef __KERNEL__#include <linux/spinlock.h> /* spinlock_t */ extern spinlock_t rtc_lock;/* serialize CMOS RAM access */ + +/* Some RTCs extend the mc146818 register set to support alarms of more +* than 24 hours in the future; or dates that include a century code. +* And sometimes the RTC alarm can wake the system from suspend-to-disk. +* This platform_data structure can pass this information to the driver. +*/ +struct cmos_rtc_board_info { +u8 rtc_day_alarm;/* zero, or register index */ +u8 rtc_mon_alarm;/* zero, or register index */ +u8 rtc_century;/* zero, or register index */ +u8 wake_from_std;/* true iff alarm wakes from STD */ +};#endif /**********************************************************************
drivers/acpi/glue.c +104 -0
107 lines not on this page · raw message
PATCH 5/6 rtc-cmos driver
In reply to David BrownellThis is a "new RTC framework" driver for the "CMOS" RTCs which are standard on PCs and some other platforms. That's an MC146818, or compatibles like the ones in most south bridges, the M48T86 and DS12887, etc. Advantages of this vs. drivers/char/rtc.c (use one _or_ the other) include:
- This leverages both the new RTC framework and the driver model; both PNPACPI and platform device modes are supported.
- It supports ACPI extensions like longer alarms.
- Likewise, system wakeup events use "real driver model support", with policy control via sysfs "wakeup" attributes and and using normal rtc ioctls to manage wakeup.
- Obsoletes and removes the acpi-only /proc/acpi/alarm interface.
Disadvantages include no testing on non-x86 systems, or with HPET; and issues associated with newness of this code and the relatively limited use of the RTC framework (i.e. primarily on embedded Linuxes, not PCs).
Significant changes since last version: handles periodic irqs, given the rtc core patch for RTC_IRQP_{GET,SET}; renamed as rtc-cmos; better platform device support; cares less about ACPI; passes "rtctest".
Issues of note:
- Some tools like "hwclock" expect /dev/rtc not /dev/rtc0; upcoming util-linux and busybox versions should resolve this.
- ACPI wakeup doesn't always work ... this is not specific to RTC, but it's worth remembering. (Or fixing, please!, if you can.)
- The ALSA sound/core/rtctimer.c doesn't understand the new RTC API, or the fact that not every RTC can generate 1K/sec IRQs.
This version seems generally usable, though it may need tweaks yet.
drivers/rtc/Kconfig +19 -0
@@ -95,6 +95,25 @@ config RTC_INTF_DEV_UIE_EMUL comment "RTC drivers" depends on RTC_CLASS +config RTC_DRV_CMOS + tristate "CMOS real time clock" + depends on RTC_CLASS && (X86_PC || ACPI) + help + Say "yes" here to get direct support for the real time clock + found in every PC or ACPI-based system, and some others. + Specifically the original MC146818, or compatibles like those + in PC south bridges, the DS12887 or M48T86, and so on. + + This RTC can be used to wake most systems from suspend-to-RAM or + standby sleep modes, and on some systems from suspend-to-disk. + (Any PC predating the 1995 introduction of ATX power supplies + probably can't be woken up by its RTC.) + + This obsoletes the old /proc/acpi/alarm interface. + + This driver can also be built as a module. If so, the module + will be called rtc-cmos. + config RTC_DRV_X1205 tristate "Xicor/Intersil X1205" depends on RTC_CLASS && I2C
drivers/rtc/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysf obj-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o obj-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o +obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
drivers/rtc/rtc-cmos.c new file +738 -0
738 lines not on this page · raw message
drivers/acpi/sleep/proc.c +17 -2
@@ -70,6 +70,14 @@ acpi_system_write_sleep(struct file *fil }#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ +#if defined(CONFIG_RTC_DRV_CMOS ) || defined(CONFIG_RTC_DRV_CMOS_MODULE ) +/* use code that fits into standard Linux driver frameworks */ +#else +#define HAVE_ACPI_LEGACY_ALARM +#endif + +#ifdef HAVE_ACPI_LEGACY_ALARM +static int acpi_system_alarm_seq_show (struct seq_file *seq,void *offset) {u32 sec, min, hr;
@@ -339,6 +347,8 @@ acpi_system_write_alarm(struct file *fil end: return_VALUE(result ? result : count); } +#endif /* HAVE_ACPI_LEGACY_ALARM */ +extern struct list_head acpi_wakeup_device_list;extern spinlock_t acpi_device_lock;
@@ -452,6 +462,7 @@ static const struct file_operations acpi };#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ +#ifdef HAVE_ACPI_LEGACY_ALARM static const struct file_operations acpi_system_alarm_fops = { .open = acpi_system_alarm_open_fs, .read = seq_read,
@@ -467,8 +478,9 @@ static u32 rtc_handler(void *context) return ACPI_INTERRUPT_HANDLED; } +#endif /* HAVE_ACPI_LEGACY_ALARM */ -static int acpi_sleep_proc_init (void ) +static int __init acpi_sleep_proc_init (void ) {struct proc_dir_entry *entry =NULL ;
@@ -484,6 +496,7 @@ static int acpi_sleep_proc_init(void) entry->proc_fops = &acpi_system_sleep_fops;#endif +#ifdef HAVE_ACPI_LEGACY_ALARM /* 'alarm' [R/W] */ entry = create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
@@ -491,6 +504,9 @@ static int acpi_sleep_proc_init(void)if (entry) entry->proc_fops = &acpi_system_alarm_fops; +acpi_install_fixed_event_handler (ACPI_EVENT_RTC , rtc_handler,NULL ); +#endif /* HAVE_ACPI_LEGACY_ALARM */ +/* 'wakeup device' [R/W] */ entry = create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
@@ -498,7 +514,6 @@ static int acpi_sleep_proc_init(void)if (entry) entry->proc_fops = &acpi_system_wakeup_device_fops; -acpi_install_fixed_event_handler (ACPI_EVENT_RTC , rtc_handler,NULL );return 0 ; }
PATCH 6/6 rtc-omap driver
In reply to David BrownellThis creates a new RTC-framework driver for the RTC/calendar module found in various OMAP1 chips. (OMAP2 and OMAP3 use external RTCs, like those in TI's multifunction PM companion chips.) It's been in the Linux-OMAP tree for several months now, and other trees before that, so it's quite stable. The most notable issue is that the OMAP IRQ code doesn't yet support the RTC IRQ as a wakeup event. Once that's fixed, a patch will be needed.
drivers/rtc/Kconfig +8 -0
@@ -182,6 +182,14 @@ config RTC_DRV_DS1742 This driver can also be built as a module. If so, the module will be called rtc-ds1742. +config RTC_DRV_OMAP + tristate "TI OMAP1" + depends on RTC_CLASS && ( \ + ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 ) + help + Say "yes" here to support the real time clock on TI OMAP1 chips. + This driver can also be built as a module called rtc-omap. + config RTC_DRV_PCF8563 tristate "Philips PCF8563/Epson RTC8564" depends on RTC_CLASS && I2C
arch/arm/mach-omap1/devices.c +1 -1
@@ -55,7 +55,7 @@ static inline void omap_init_irda(void)/*-------------------------------------------------------------------------*/ -#if defined(CONFIG_OMAP_RTC ) || defined(CONFIG_OMAP_RTC ) +#if defined(CONFIG_RTC_DRV_OMAP ) || defined(CONFIG_RTC_DRV_OMAP_MODULE )#define OMAP_RTC_BASE 0xfffb4800
drivers/rtc/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o +obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
drivers/rtc/rtc-omap.c new file +572 -0
572 lines not on this page · raw message
Re: [patch 2.6.19-rc6 6/6] rtc-omap driver
Quoted 8 lines · On Mon, 20 Nov 2006 10:28:48 -0800 David Brownell <[email protected]> wrote:
This creates a new RTC-framework driver for the RTC/calendar module found in various OMAP1 chips. (OMAP2 and OMAP3 use external RTCs, like those in TI's multifunction PM companion chips.) It's been in the Linux-OMAP tree for several months now, and other trees before that, so it's quite stable. The most notable issue is that the OMAP IRQ code doesn't yet support the RTC IRQ as a wakeup event. Once that's fixed, a patch will be needed.
Signed-off-by David Brownell <[email protected]>
Thanks David!
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it
Re: [patch 2.6.19-rc6 6/6] rtc-omap driver
In reply to David BrownellQuoted 24 lines · On Mon, 20 Nov 2006 10:28:48 -0800 David Brownell <[email protected]> wrote:
This creates a new RTC-framework driver for the RTC/calendar module found in various OMAP1 chips. (OMAP2 and OMAP3 use external RTCs, like those in TI's multifunction PM companion chips.) It's been in the Linux-OMAP tree for several months now, and other trees before that, so it's quite stable. The most notable issue is that the OMAP IRQ code doesn't yet support the RTC IRQ as a wakeup event. Once that's fixed, a patch will be needed.
...
drivers/rtc/rtc-omap.c new file +15
-0+static int omap_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alm) +{ +u8 reg; + +/* Much userspace code uses RTC_ALM_SET, thus "don't care" for +* day/month/year specifies alarms up to 24 hours in the future. +* So we need to handle that ... but let's ignore the "don't care" +* values for hours/minutes/seconds. +*/ +if (alm->time.tm_mday <=0 + && alm->time.tm_mon <0 + && alm->time.tm_year <0 ) { +struct rtc_time tm; +unsigned long now, then; +
drivers/rtc/rtc-omap.c line 313
Quoted 10 lines
drivers/rtc/rtc-omap.c new file +10
-0+omap_rtc_read_time (dev, &tm); +rtc_tm_to_time (&tm, &now); + + alm->time.tm_mday = tm.tm_mday; + alm->time.tm_mon = tm.tm_mon; + alm->time.tm_year = tm.tm_year; +rtc_tm_to_time (&alm->time, &then); + +/* sometimes the alarm wraps into tomorrow */ +if (then < now) {
This isn't wraparound-safe. If you have then=0xffffffff and now=0x00000001.
Perhaps that can't happen.
Quoted 1 line
+MODULE_AUTHOR("George G. Davis (and others)");
Maybe some additional signoffs would be appropirate?
Re: [patch 2.6.19-rc6 6/6] rtc-omap driver
Quoted 8 lines · Andrew Morton
On Mon, 20 Nov 2006 10:28:48 -0800
drivers/rtc/rtc-omap.c line 313
Quoted 2 lines
drivers/rtc/rtc-omap.c new file +2
-0+/* sometimes the alarm wraps into tomorrow */ +if (then < now) {This isn't wraparound-safe. If you have then=0xffffffff and now=0x00000001.
Perhaps that can't happen.
Starting in 2037 or whenever, various things will be breaking...
Probably the RTC lib routines should use a time_t, and when that gets changed to 64 bits then things like this will be fixed automagically. Right now they use "unsigned long".
I suggest Alessandro handle those issues.
Quoted 3 lines
Quoted 1 line
+MODULE_AUTHOR("George G. Davis (and others)");
Maybe some additional signoffs would be appropirate?
I pinged the MontaVista emails from the original driver; maybe they'll send signoffs.
- Dave
Re: [patch 2.6.19-rc6 6/6] rtc-omap driver
Quoted 10 lines · On Tue, 21 Nov 2006 18:15:42 -0800 David Brownell <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
On Mon, 20 Nov 2006 10:28:48 -0800
drivers/rtc/rtc-omap.c line 313
Quoted 2 lines
drivers/rtc/rtc-omap.c new file +2
-0+/* sometimes the alarm wraps into tomorrow */ +if (then < now) {This isn't wraparound-safe. If you have then=0xffffffff and now=0x00000001.
Perhaps that can't happen.
Quoted 8 lines
Starting in 2037 or whenever, various things will be breaking...
Probably the RTC lib routines should use a
time_t, and when that gets changed to 64 bits then things like this will be fixed automagically. Right now they use "unsigned long".I suggest Alessandro handle those issues.
We could simply (ab)use timer_after() here.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
+MODULE_AUTHOR("George G. Davis (and others)");
Maybe some additional signoffs would be appropirate?
I pinged the MontaVista emails from the original driver; maybe they'll send signoffs.
OK. Such signoffs are certainly not a DCO _requirement_. If the MV guys are asleep, no big deal - we trust david-b's assertion.
Re: [patch 2.6.19-rc6 6/6] rtc-omap driver
Quoted 9 lines · Andrew Morton
Quoted 7 lines
Starting in 2037 or whenever, various things will be breaking...
Probably the RTC lib routines should use a
time_t, and when that gets changed to 64 bits then things like this will be fixed automagically. Right now they use "unsigned long".I suggest Alessandro handle those issues.
We could simply (ab)use
timer_after()here.
We could indeed. But things will still break badly in 2037, and the timer_after() thing is clearly an incomplete fix.
- Dave
Re: [patch 2.6.19-rc6 6/6] rtc-omap driver
In reply to David BrownellQuoted 10 lines · On Tue, 21 Nov 2006 18:15:42 -0800 David Brownell <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
On Mon, 20 Nov 2006 10:28:48 -0800
drivers/rtc/rtc-omap.c line 313
Quoted 2 lines
drivers/rtc/rtc-omap.c new file +2
-0+/* sometimes the alarm wraps into tomorrow */ +if (then < now) {This isn't wraparound-safe. If you have then=0xffffffff and now=0x00000001.
Perhaps that can't happen.
Quoted 7 lines
Starting in 2037 or whenever, various things will be breaking...
Probably the RTC lib routines should use a
time_t, and when that gets changed to 64 bits then things like this will be fixed automagically. Right now they use "unsigned long".I suggest Alessandro handle those issues.
I'll make a note for switching to time_t before
2037 :)
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it