From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3B2CC4CED1 for ; Thu, 3 Oct 2019 11:48:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBA562086A for ; Thu, 3 Oct 2019 11:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729671AbfJCLse (ORCPT ); Thu, 3 Oct 2019 07:48:34 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:35605 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726523AbfJCLsd (ORCPT ); Thu, 3 Oct 2019 07:48:33 -0400 X-Originating-IP: 86.207.98.53 Received: from localhost (aclermont-ferrand-651-1-259-53.w86-207.abo.wanadoo.fr [86.207.98.53]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id F131824000C; Thu, 3 Oct 2019 11:48:31 +0000 (UTC) Date: Thu, 3 Oct 2019 13:48:31 +0200 From: Alexandre Belloni To: Lukasz Majewski Cc: Alessandro Zummo , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rtc: Add support for century bits to m41t62 (rv4162) RTC devices Message-ID: <20191003114831.GR4106@piout.net> References: <20190911154803.15969-1-lukma@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190911154803.15969-1-lukma@denx.de> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 11/09/2019 17:48:03+0200, Lukasz Majewski wrote: > This change adds support for 'century bits' on 4162 family of RTC devices > (from ST or microcrystal), which allow storing time beyond year 2099. > > For rv4162 century bits - CB1[7]:CB0[6] are stored in reg6 - 0x6 (MONTH): > CB1 CB0 > 0 0 (year 2000 - 2099) > 0 1 (year 2100 - 2199) > 1 0 (year 2200 - 2299) > 1 1 (year 2300 - 2399) > > The driver has been also adjusted to allow setting time up to year 2399 > if the M41T80_FEATURE_CB is set in its DTS/I2C data. > > There shall be no functional changes for devices not supporting this > feature. However, other devices - like m41t80 - have different approaches > to handle century information. > This does not work because the RTC doesn't handle leap years on century properly. This means that if you do that, then there is no guarantee the date will be the correct after 2099. As far as the m41t62 and rv4162 are concerned, there is no way to make the century bits useful. See the datasheet: "During any year which is a multiple of 4, the RV-4162 RTC will automatically insert leap day, February 29. Therefore, the application software must correct for this during the exception years (2100, 2200, etc.) as noted above." -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com