From nobody Thu Nov 28 08:37:49 2024 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBAEC38DE0; Thu, 3 Oct 2024 03:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727926071; cv=none; b=sT809dyu6QZSGjF75CHRVdsq/AOzz81SwxbtBWRgkHoLx+xdWjnBpq3+y6p3NL7DM6/scGIyNO1h4jroXs1radOm1l0mAnOQMdnr7Y954Q8YA3FgKhhuYhAZHE2CDIqBpi1ZCS/Gz0xfkDp9WAAhszHFloWAkdjuNTzM8DVNUpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727926071; c=relaxed/simple; bh=VxZlrtAqFv9j/uHtY1BhROEG/+3JnklZMvpNVUxPEJw=; h=To:Cc:Message-Id:In-Reply-To:References:From:Subject:Date; b=H75j1RwDGRtla48EKlcWrp+KIJpWPlbLX5uaXcm+SXuDe/99wHxD1D61eaqx0WL9Q1LNoUwnkk31YYj7tmcofyCcde2HcmPhJ3xtXgFf+awBILlScA9uAfP40E/HOAwNpKoL2x065jb7twZEt35gnnQpzuEYBOKVY3lbXlWpFAA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=eYqEwAeT; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eYqEwAeT" Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 0488F13804B7; Wed, 2 Oct 2024 23:27:49 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Wed, 02 Oct 2024 23:27:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1727926069; x= 1728012469; bh=RXdzWn7PA5l/DmEXkF+W4h++S2gHqll77LPZsh02hLA=; b=e YqEwAeTaGrXdaqqquahNRMZAa5y8ckbKD62mg3Zrf3x+1NcEQ8spevrZAehPY4Gx IdXKRqfbglKj/LSCncMdXewKIlHkQ1nBAMGATM2WtNTtFaSXxeH6QPr9M3JiTGZQ jnakK0i43ij0yQgvwLDik1t3PIk5R+21xhr9DCATntBv2Yri/rCPwTfSXxT9ANl7 lEZZ/PdcubIMk7mJxNgS2Cx8PnYe05R8hvup4RK536NZRiAJsELd2jwBYP4pbSas m+09sagZ56ukZUGx14qvkyPP3rcIge1WFPcfmC1AdlifLOFb8DirRPdMG2vtwHqk vhzUzZUCUqDZ+Np058AjA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvtddgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepvfevkfgjfhfhufffsedttdertddttddtnecuhfhr ohhmpefhihhnnhcuvfhhrghinhcuoehfthhhrghinheslhhinhhugidqmheikehkrdhorh hgqeenucggtffrrghtthgvrhhnpeevgffgtdfhhfefveeuudfgtdeugfeftedtveekieeg gfduleetgeegueehgeffffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehfthhhrghinheslhhinhhugidqmheikehkrdhorhhgpdhnsggprhgt phhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrlhgvgigrnhgurh gvrdgsvghllhhonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepghgvvghrthes lhhinhhugidqmheikehkrdhorhhgpdhrtghpthhtohepuggrnhhivghlsedtgidtfhdrtg homhdprhgtphhtthhopehprghvohhnvgesrhgvthhrohguvghvrdgtohhmpdhrtghpthht oheplhhinhhugidqmheikehksehlihhsthhsrdhlihhnuhigqdhmieekkhdrohhrghdprh gtphhtthhopehlihhnuhigqdhrthgtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghp thhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Oct 2024 23:27:46 -0400 (EDT) To: Alexandre Belloni , Geert Uytterhoeven Cc: Daniel Palmer , Michael Pavone , linux-m68k@lists.linux-m68k.org, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: In-Reply-To: References: From: Finn Thain Subject: [PATCH 1/2] rtc: m48t59: Accommodate chips that lack a century bit Date: Thu, 03 Oct 2024 13:23:22 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The m48t59 driver is needed by both SPARC and MVME systems. Linux on MVME uses 1970 as "year zero" rather than 1968 that's used on SPARC. Add support for the MVME convention. Otherwise, the RTC on non-SPARC systems can only read and write dates between 1900 and 1999. Tested-by: Daniel Palmer Signed-off-by: Finn Thain --- drivers/rtc/rtc-m48t59.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index f0f6b9b6daec..e2d882ea5c2f 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c @@ -57,6 +57,17 @@ m48t59_mem_readb(struct device *dev, u32 ofs) return readb(m48t59->ioaddr+ofs); } =20 +/* + * Sun SPARC machines count years since 1968. MVME machines running Linux + * count years since 1970. + */ + +#ifdef CONFIG_SPARC +#define YEAR0 68 +#else +#define YEAR0 70 +#endif + /* * NOTE: M48T59 only uses BCD mode */ @@ -82,10 +93,7 @@ static int m48t59_rtc_read_time(struct device *dev, stru= ct rtc_time *tm) dev_dbg(dev, "Century bit is enabled\n"); tm->tm_year +=3D 100; /* one century */ } -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - tm->tm_year +=3D 68; -#endif + tm->tm_year +=3D YEAR0; =20 tm->tm_wday =3D bcd2bin(val & 0x07); tm->tm_hour =3D bcd2bin(M48T59_READ(M48T59_HOUR) & 0x3F); @@ -108,10 +116,7 @@ static int m48t59_rtc_set_time(struct device *dev, str= uct rtc_time *tm) u8 val =3D 0; int year =3D tm->tm_year; =20 -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - year -=3D 68; -#endif + year -=3D YEAR0; =20 dev_dbg(dev, "RTC set time %04d-%02d-%02d %02d/%02d/%02d\n", year + 1900, tm->tm_mon, tm->tm_mday, @@ -163,10 +168,7 @@ static int m48t59_rtc_readalarm(struct device *dev, st= ruct rtc_wkalrm *alrm) M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); =20 tm->tm_year =3D bcd2bin(M48T59_READ(M48T59_YEAR)); -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - tm->tm_year +=3D 68; -#endif + tm->tm_year +=3D YEAR0; /* tm_mon is 0-11 */ tm->tm_mon =3D bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; =20 @@ -199,10 +201,7 @@ static int m48t59_rtc_setalarm(struct device *dev, str= uct rtc_wkalrm *alrm) unsigned long flags; int year =3D tm->tm_year; =20 -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - year -=3D 68; -#endif + year -=3D YEAR0; =20 /* If no irq, we don't support ALARM */ if (m48t59->irq =3D=3D NO_IRQ) --=20 2.39.5