* Re: ARM Architecture and GENERIC_CMOS_UPDATE
2011-02-01 22:32 ` Tony Lindgren
@ 2011-02-02 16:57 ` Grant Erickson
2011-02-09 18:27 ` Tony Lindgren
0 siblings, 1 reply; 4+ messages in thread
From: Grant Erickson @ 2011-02-02 16:57 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux-omap
On 2/1/11 2:32 PM, Tony Lindgren wrote:
> * Grant Erickson <marathon96@gmail.com> [110128 16:34]:
>> Is there any reason, to date, that the ARM architecture has not had the
>> following kernel configuration option?
>>
>> config GENERIC_CMOS_UPDATE
>> def_bool y
>
> Looks like it would just require implementing update_persitent_clock.
> No idea why it's not done for ARM , maybe send some patches for that?
Tony:
Thanks for the confirmation. For the time being, for my 2.6.32 kernel, I
added the following to my board-specific file:
#if defined(CONFIG_GENERIC_CMOS_UPDATE) && defined(CONFIG_RTC_LIB)
/**
* update_persistent_clock - set the hardware clock time to system time
* @now: the current system wall clock time.
*
* This routine attempts to access the primary hardware real-time
* clock and, if successful, sets it to the current system wall clock
* time.
*
* This generation (2.6.32) of ARM kernel has an alternative function
* do_set_rtc in linux/arch/arm/kernel/time.c that does something
* similar; however, in a more awkward and non-standard way. So much
* so, that in 2.6.36 kernels, it's gone away entirely.
*
* This more or less matches what is in linux/arch/sparc/kernel/time_64.c
*
* Returns 0 if the real-time clock was successfully set to the system
* wall clock time; otherwise, < 0 on error.
*/
int update_persistent_clock(struct timespec now)
{
const char * name = "rtc0";
struct rtc_device *rtc;
int err = -ENODEV;
rtc = rtc_class_open(name);
if (rtc) {
err = rtc_set_mmss(rtc, now.tv_sec);
rtc_class_close(rtc);
}
return err;
}
#endif /* defined(CONFIG_GENERIC_CMOS_UPDATE) && defined(CONFIG_RTC_LIB) */
and changed arch/arm/kernel/time.c as follows:
--- a/linux/arch/arm/kernel/time.c
+++ b/linux/arch/arm/kernel/time.c
@@ -89,6 +89,9 @@ static unsigned long dummy_gettimeoffset(void)
}
#endif
+#if defined(CONFIG_GENERIC_CMOS_UPDATE)
+static inline void do_set_rtc(void) { return; }
+#else /* !defined(CONFIG_GENERIC_CMOS_UPDATE) */
static unsigned long next_rtc_update;
/*
@@ -118,6 +121,7 @@ static inline void do_set_rtc(void)
else
next_rtc_update = xtime.tv_sec + 660;
}
+#endif /* defined(CONFIG_GENERIC_CMOS_UPDATE) */
#ifdef CONFIG_LEDS
The long-term solution probably involves adding a function pointer member
field for each machine description with a generic, default function that
does something akin to the above board-specific approach.
Comments welcomed.
-Grant
^ permalink raw reply [flat|nested] 4+ messages in thread