From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.free-electrons.com ([62.4.15.54]:39836 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751584AbdLKQIh (ORCPT ); Mon, 11 Dec 2017 11:08:37 -0500 Date: Mon, 11 Dec 2017 17:08:35 +0100 From: Alexandre Belloni To: Rabeeh Khoury Cc: Gregory CLEMENT , Baruch Siach , Thomas Petazzoni , linux-rtc@vger.kernel.org, "nadavh@marvell.com" Subject: Re: Armada RTC power up reset Message-ID: <20171211160835.GC32306@piout.net> References: <20171130094049.fg3zoxgvhlb7jqw3@tarshish> <871skewf05.fsf@free-electrons.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: Sender: linux-rtc-owner@vger.kernel.org List-ID: On 11/12/2017 at 14:46:41 +0200, Rabeeh Khoury wrote: > On Fri, Dec 1, 2017 at 7:10 PM, Gregory CLEMENT < > gregory.clement@free-electrons.com> wrote: > > > Hi Baruch, > > > > On jeu., nov. 30 2017, Baruch Siach wrote: > > > > > Hi Thomas, > > > > > > As you know, the Armada 38x/8k RTC needs a reset sequence to be > > operational > > > when first powered up. This reset code is currently in the vendor > > provided > > > U-Boot RTC driver. But having to run 'date reset' from the U-Boot prompt > > every > > > first boot (happens quite a lot when dealing with SOMs) is not nice. An > > > automatic reset in the kernel driver would be much better. > > > > > > Rabeeh has mentioned to me that you had an idea how to detect at run > > time that > > > the RTC is in first power up state. Do you recall the details? > > > > Actually it was me who worked on the RTC but I didn't remember having a > > way to detect that the RTC is in first power up state. I dig in the > > datasheet, errata sheet and alos on varisou branches of the vendor tree > > and didn't find anything. > > > > Maybe a solution could be to reset the RTC when we set the time. > > > > > This is one way to do it; but then on first boot you might get real awkward > time; like year 2035 which can seriously confuse the boot process. > Detecting an uninitialized RTC and forcing it to tick with time = 0 (i.e. > 1970) is better way since boot failures can be reproduced in an orderly > manner (and the developer would know what was really wrong). Certainly not. If you know the time is invalid, then just return an error. Else, userspace has no way to know whether it can rely on the time from the RTC and act accordingly. -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com