All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Erickson <marathon96@gmail.com>
To: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Subject: Re: ARM Architecture and GENERIC_CMOS_UPDATE
Date: Wed, 02 Feb 2011 08:57:46 -0800	[thread overview]
Message-ID: <C96ECD0A.239F7%marathon96@gmail.com> (raw)
In-Reply-To: <20110201223252.GG3358@atomide.com>

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



  reply	other threads:[~2011-02-02 16:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-29  0:35 ARM Architecture and GENERIC_CMOS_UPDATE Grant Erickson
2011-02-01 22:32 ` Tony Lindgren
2011-02-02 16:57   ` Grant Erickson [this message]
2011-02-09 18:27     ` Tony Lindgren

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=C96ECD0A.239F7%marathon96@gmail.com \
    --to=marathon96@gmail.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.