From nobody Thu Nov 28 06:45:25 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 From nobody Thu Nov 28 06:45:25 2024 Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (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 B24C6433A0; Thu, 3 Oct 2024 03:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727926082; cv=none; b=r9Gpg8TqUEKmxOqFkxHaO7DUjgFQ3LWwmaNWwdV7++uBufhjf0aC13APOxYL6PDu5jito+Ipi6SpSPDRti/tHdxXZyvcqqtgZlWZ0VeksijcUSZVDJTn79eyCOpZYhy4VV7ylRkj3MeZt1moPoAcVUOMua+aw6+vC9TKIrtEavE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727926082; c=relaxed/simple; bh=czarx6UH1A45CYuxIfSlJVkhLNLHETn+68QDlpaQz/U=; h=To:Cc:Message-Id:In-Reply-To:References:From:Subject:Date; b=ttCJ/3IxlAnCi+TrrtPgahPPn7ODHj/NqnSOHkRXzHBp9jhjYrqOIMVCReS0o0YonCiKvjmYCXIKgPf0LuqvSA5aTE2wyFZlg5U5D7e7go4blvSy/peno/mlVODr33olqy+iYgUdz7E8w/cabai+5blwOUHdofme6Ph+7OuVK/w= 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=EILxwcW4; arc=none smtp.client-ip=103.168.172.152 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="EILxwcW4" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id D278B1140226; Wed, 2 Oct 2024 23:27:58 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Wed, 02 Oct 2024 23:27:58 -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=1727926078; x= 1728012478; bh=w7qM2DDRQfQ8tCnmGl9Vw2JjIbzdVjsXvGRYulWXyfk=; b=E ILxwcW4fc3oaiwBStGiF21OxXLZ2tfdP+KzA1m8zWes+jc+zpalMhwelLfpHJL// x0Cq4N75iYd0m4GHxTrQZ0OdtJnfbkPQIW06ldK8PVweiJTaEoUa6YLTp+ligWaD lWeU+6pNG03V/ItdOXfHtsUG8tT/JDsJr1LFCM8AZVUkoL+opxgbIsoRJtfThATM PNga5DKf97xWuHj9VeAg3hj7dEmuvl8VbsAodhJsGwWjO2okaDvGmovHVfOvicKN 6YeA7Zbkdvirl5MizMRSdzh4UecJRAAbzL2WUK7iwIw4sKy3C0VmpezUUqP9Aw95 Vx2WZ45R4K2/T7vtPtIXQ== 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:55 -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 2/2] m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver 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" Both mvme147 and mvme16x platforms have their own RTC driver implementations that duplicate functionality provided by the rtc-m48t59 driver. Adopt the rtc-m48t59 driver and remove the other ones. Tested-by: Daniel Palmer Signed-off-by: Finn Thain --- arch/m68k/configs/multi_defconfig | 1 + arch/m68k/configs/mvme147_defconfig | 1 + arch/m68k/configs/mvme16x_defconfig | 1 + arch/m68k/include/asm/mvme147hw.h | 19 +--- arch/m68k/include/asm/mvme16xhw.h | 18 +-- arch/m68k/mvme147/config.c | 54 ++++----- arch/m68k/mvme16x/Makefile | 2 +- arch/m68k/mvme16x/config.c | 56 ++++------ arch/m68k/mvme16x/rtc.c | 165 ---------------------------- 9 files changed, 52 insertions(+), 265 deletions(-) delete mode 100644 arch/m68k/mvme16x/rtc.c diff --git a/arch/m68k/configs/multi_defconfig b/arch/m68k/configs/multi_de= fconfig index 638df8442c98..617ac93298f3 100644 --- a/arch/m68k/configs/multi_defconfig +++ b/arch/m68k/configs/multi_defconfig @@ -506,6 +506,7 @@ CONFIG_RTC_CLASS=3Dy CONFIG_RTC_DRV_MSM6242=3Dm CONFIG_RTC_DRV_RP5C01=3Dm CONFIG_RTC_DRV_GENERIC=3Dm +CONFIG_RTC_DRV_M48T59=3Dm # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not set diff --git a/arch/m68k/configs/mvme147_defconfig b/arch/m68k/configs/mvme14= 7_defconfig index 2248db426081..4a0928b3b842 100644 --- a/arch/m68k/configs/mvme147_defconfig +++ b/arch/m68k/configs/mvme147_defconfig @@ -392,6 +392,7 @@ CONFIG_UHID=3Dm CONFIG_RTC_CLASS=3Dy # CONFIG_RTC_NVMEM is not set CONFIG_RTC_DRV_GENERIC=3Dm +CONFIG_RTC_DRV_M48T59=3Dy # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not set diff --git a/arch/m68k/configs/mvme16x_defconfig b/arch/m68k/configs/mvme16= x_defconfig index 2975b66521f6..481fb2810f1e 100644 --- a/arch/m68k/configs/mvme16x_defconfig +++ b/arch/m68k/configs/mvme16x_defconfig @@ -393,6 +393,7 @@ CONFIG_UHID=3Dm CONFIG_RTC_CLASS=3Dy # CONFIG_RTC_NVMEM is not set CONFIG_RTC_DRV_GENERIC=3Dm +CONFIG_RTC_DRV_M48T59=3Dy # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not set diff --git a/arch/m68k/include/asm/mvme147hw.h b/arch/m68k/include/asm/mvme= 147hw.h index e28eb1c0e0bf..2b147ab1d189 100644 --- a/arch/m68k/include/asm/mvme147hw.h +++ b/arch/m68k/include/asm/mvme147hw.h @@ -4,24 +4,7 @@ =20 #include =20 -typedef struct { - unsigned char - ctrl, - bcd_sec, - bcd_min, - bcd_hr, - bcd_dow, - bcd_dom, - bcd_mth, - bcd_year; -} MK48T02; - -#define RTC_WRITE 0x80 -#define RTC_READ 0x40 -#define RTC_STOP 0x20 - -#define m147_rtc ((MK48T02 * volatile)0xfffe07f8) - +#define MVME147_RTC_BASE 0xfffe0000 =20 struct pcc_regs { volatile u_long dma_tadr; diff --git a/arch/m68k/include/asm/mvme16xhw.h b/arch/m68k/include/asm/mvme= 16xhw.h index cc7f5ae1220f..ff1126a51fbe 100644 --- a/arch/m68k/include/asm/mvme16xhw.h +++ b/arch/m68k/include/asm/mvme16xhw.h @@ -24,23 +24,7 @@ typedef struct { =20 #define mvmelp ((*(volatile MVMElpPtr)(MVME_LPR_BASE))) =20 -typedef struct { - unsigned char - ctrl, - bcd_sec, - bcd_min, - bcd_hr, - bcd_dow, - bcd_dom, - bcd_mth, - bcd_year; -} MK48T08_t, *MK48T08ptr_t; - -#define RTC_WRITE 0x80 -#define RTC_READ 0x40 -#define RTC_STOP 0x20 - -#define MVME_RTC_BASE 0xfffc1ff8 +#define MVME_RTC_BASE 0xfffc0000 =20 #define MVME_I596_BASE 0xfff46000 =20 diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c index 8b5dc07f0811..e2560c6d10b4 100644 --- a/arch/m68k/mvme147/config.c +++ b/arch/m68k/mvme147/config.c @@ -19,8 +19,9 @@ #include #include #include -#include #include +#include +#include =20 #include #include @@ -35,13 +36,9 @@ =20 static void mvme147_get_model(char *model); extern void mvme147_sched_init(void); -extern int mvme147_hwclk (int, struct rtc_time *); extern void mvme147_reset (void); =20 =20 -static int bcd2int (unsigned char b); - - int __init mvme147_parse_bootinfo(const struct bi_record *bi) { uint16_t tag =3D be16_to_cpu(bi->tag); @@ -79,7 +76,6 @@ void __init config_mvme147(void) { mach_sched_init =3D mvme147_sched_init; mach_init_IRQ =3D mvme147_init_IRQ; - mach_hwclk =3D mvme147_hwclk; mach_reset =3D mvme147_reset; mach_get_model =3D mvme147_get_model; =20 @@ -88,6 +84,27 @@ void __init config_mvme147(void) vme_brdtype =3D VME_TYPE_MVME147; } =20 +static struct resource m48t59_rsrc[] =3D { + DEFINE_RES_MEM(MVME147_RTC_BASE, 0x800), +}; + +static struct m48t59_plat_data m48t59_data =3D { + .type =3D M48T59RTC_TYPE_M48T02, +}; + +static int __init mvme147_platform_init(void) +{ + if (!MACH_IS_MVME147) + return 0; + + platform_device_register_resndata(NULL, "rtc-m48t59", -1, + m48t59_rsrc, ARRAY_SIZE(m48t59_rsrc), + &m48t59_data, sizeof(m48t59_data)); + return 0; +} + +arch_initcall(mvme147_platform_init); + static u64 mvme147_read_clk(struct clocksource *cs); =20 static struct clocksource mvme147_clk =3D { @@ -160,28 +177,3 @@ static u64 mvme147_read_clk(struct clocksource *cs) =20 return ticks; } - -static int bcd2int (unsigned char b) -{ - return ((b>>4)*10 + (b&15)); -} - -int mvme147_hwclk(int op, struct rtc_time *t) -{ - if (!op) { - m147_rtc->ctrl =3D RTC_READ; - t->tm_year =3D bcd2int (m147_rtc->bcd_year); - t->tm_mon =3D bcd2int(m147_rtc->bcd_mth) - 1; - t->tm_mday =3D bcd2int (m147_rtc->bcd_dom); - t->tm_hour =3D bcd2int (m147_rtc->bcd_hr); - t->tm_min =3D bcd2int (m147_rtc->bcd_min); - t->tm_sec =3D bcd2int (m147_rtc->bcd_sec); - m147_rtc->ctrl =3D 0; - if (t->tm_year < 70) - t->tm_year +=3D 100; - } else { - /* FIXME Setting the time is not yet supported */ - return -EOPNOTSUPP; - } - return 0; -} diff --git a/arch/m68k/mvme16x/Makefile b/arch/m68k/mvme16x/Makefile index a8a368c2cbea..02f9e4ad8209 100644 --- a/arch/m68k/mvme16x/Makefile +++ b/arch/m68k/mvme16x/Makefile @@ -3,4 +3,4 @@ # Makefile for Linux arch/m68k/mvme16x source directory # =20 -obj-y :=3D config.o rtc.o +obj-y :=3D config.o diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c index d1fbd1704d65..cca06f75b873 100644 --- a/arch/m68k/mvme16x/config.c +++ b/arch/m68k/mvme16x/config.c @@ -21,9 +21,10 @@ #include #include #include -#include #include #include +#include +#include =20 #include #include @@ -39,16 +40,10 @@ =20 extern t_bdid mvme_bdid; =20 -static MK48T08ptr_t volatile rtc =3D (MK48T08ptr_t)MVME_RTC_BASE; - static void mvme16x_get_model(char *model); extern void mvme16x_sched_init(void); -extern int mvme16x_hwclk (int, struct rtc_time *); extern void mvme16x_reset (void); =20 -int bcd2int (unsigned char b); - - unsigned short mvme16x_config; EXPORT_SYMBOL(mvme16x_config); =20 @@ -268,7 +263,6 @@ void __init config_mvme16x(void) =20 mach_sched_init =3D mvme16x_sched_init; mach_init_IRQ =3D mvme16x_init_IRQ; - mach_hwclk =3D mvme16x_hwclk; mach_reset =3D mvme16x_reset; mach_get_model =3D mvme16x_get_model; mach_get_hardware_list =3D mvme16x_get_hardware_list; @@ -312,6 +306,27 @@ void __init config_mvme16x(void) } } =20 +static struct resource m48t59_rsrc[] =3D { + DEFINE_RES_MEM(MVME_RTC_BASE, 0x2000), +}; + +static struct m48t59_plat_data m48t59_data =3D { + .type =3D M48T59RTC_TYPE_M48T08, +}; + +static int __init mvme16x_platform_init(void) +{ + if (!MACH_IS_MVME16x) + return 0; + + platform_device_register_resndata(NULL, "rtc-m48t59", -1, + m48t59_rsrc, ARRAY_SIZE(m48t59_rsrc), + &m48t59_data, sizeof(m48t59_data)); + return 0; +} + +arch_initcall(mvme16x_platform_init); + static irqreturn_t mvme16x_abort_int (int irq, void *dev_id) { unsigned long *new =3D (unsigned long *)vectors; @@ -426,28 +441,3 @@ static u64 mvme16x_read_clk(struct clocksource *cs) =20 return ticks; } - -int bcd2int (unsigned char b) -{ - return ((b>>4)*10 + (b&15)); -} - -int mvme16x_hwclk(int op, struct rtc_time *t) -{ - if (!op) { - rtc->ctrl =3D RTC_READ; - t->tm_year =3D bcd2int (rtc->bcd_year); - t->tm_mon =3D bcd2int(rtc->bcd_mth) - 1; - t->tm_mday =3D bcd2int (rtc->bcd_dom); - t->tm_hour =3D bcd2int (rtc->bcd_hr); - t->tm_min =3D bcd2int (rtc->bcd_min); - t->tm_sec =3D bcd2int (rtc->bcd_sec); - rtc->ctrl =3D 0; - if (t->tm_year < 70) - t->tm_year +=3D 100; - } else { - /* FIXME Setting the time is not yet supported */ - return -EOPNOTSUPP; - } - return 0; -} diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c deleted file mode 100644 index ccbaae1125e6..000000000000 --- a/arch/m68k/mvme16x/rtc.c +++ /dev/null @@ -1,165 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Real Time Clock interface for Linux on the MVME16x - * - * Based on the PC driver by Paul Gortmaker. - */ - -#define RTC_VERSION "1.00" - -#include -#include -#include -#include -#include -#include -#include -#include -#include /* For struct rtc_time and ioctls, etc */ -#include -#include - -#include -#include -#include - -/* - * We sponge a minor off of the misc major. No need slurping - * up another valuable major dev number for this. If you add - * an ioctl, make sure you don't conflict with SPARC's RTC - * ioctls. - */ - -static const unsigned char days_in_mo[] =3D -{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - -static atomic_t rtc_ready =3D ATOMIC_INIT(1); - -static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long a= rg) -{ - volatile MK48T08ptr_t rtc =3D (MK48T08ptr_t)MVME_RTC_BASE; - unsigned long flags; - struct rtc_time wtime; - void __user *argp =3D (void __user *)arg; - - switch (cmd) { - case RTC_RD_TIME: /* Read the time/date from RTC */ - { - local_irq_save(flags); - /* Ensure clock and real-time-mode-register are accessible */ - rtc->ctrl =3D RTC_READ; - memset(&wtime, 0, sizeof(struct rtc_time)); - wtime.tm_sec =3D bcd2bin(rtc->bcd_sec); - wtime.tm_min =3D bcd2bin(rtc->bcd_min); - wtime.tm_hour =3D bcd2bin(rtc->bcd_hr); - wtime.tm_mday =3D bcd2bin(rtc->bcd_dom); - wtime.tm_mon =3D bcd2bin(rtc->bcd_mth)-1; - wtime.tm_year =3D bcd2bin(rtc->bcd_year); - if (wtime.tm_year < 70) - wtime.tm_year +=3D 100; - wtime.tm_wday =3D bcd2bin(rtc->bcd_dow)-1; - rtc->ctrl =3D 0; - local_irq_restore(flags); - return copy_to_user(argp, &wtime, sizeof wtime) ? - -EFAULT : 0; - } - case RTC_SET_TIME: /* Set the RTC */ - { - struct rtc_time rtc_tm; - unsigned char mon, day, hrs, min, sec, leap_yr; - unsigned int yrs; - - if (!capable(CAP_SYS_ADMIN)) - return -EACCES; - - if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time))) - return -EFAULT; - - yrs =3D rtc_tm.tm_year; - if (yrs < 1900) - yrs +=3D 1900; - mon =3D rtc_tm.tm_mon + 1; /* tm_mon starts at zero */ - day =3D rtc_tm.tm_mday; - hrs =3D rtc_tm.tm_hour; - min =3D rtc_tm.tm_min; - sec =3D rtc_tm.tm_sec; - - leap_yr =3D ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400)); - - if ((mon > 12) || (day =3D=3D 0)) - return -EINVAL; - - if (day > (days_in_mo[mon] + ((mon =3D=3D 2) && leap_yr))) - return -EINVAL; - - if ((hrs >=3D 24) || (min >=3D 60) || (sec >=3D 60)) - return -EINVAL; - - if (yrs >=3D 2070) - return -EINVAL; - - local_irq_save(flags); - rtc->ctrl =3D RTC_WRITE; - - rtc->bcd_sec =3D bin2bcd(sec); - rtc->bcd_min =3D bin2bcd(min); - rtc->bcd_hr =3D bin2bcd(hrs); - rtc->bcd_dom =3D bin2bcd(day); - rtc->bcd_mth =3D bin2bcd(mon); - rtc->bcd_year =3D bin2bcd(yrs%100); - - rtc->ctrl =3D 0; - local_irq_restore(flags); - return 0; - } - default: - return -EINVAL; - } -} - -/* - * We enforce only one user at a time here with the open/close. - */ -static int rtc_open(struct inode *inode, struct file *file) -{ - if( !atomic_dec_and_test(&rtc_ready) ) - { - atomic_inc( &rtc_ready ); - return -EBUSY; - } - return 0; -} - -static int rtc_release(struct inode *inode, struct file *file) -{ - atomic_inc( &rtc_ready ); - return 0; -} - -/* - * The various file operations we support. - */ - -static const struct file_operations rtc_fops =3D { - .unlocked_ioctl =3D rtc_ioctl, - .open =3D rtc_open, - .release =3D rtc_release, - .llseek =3D noop_llseek, -}; - -static struct miscdevice rtc_dev=3D -{ - .minor =3D RTC_MINOR, - .name =3D "rtc", - .fops =3D &rtc_fops -}; - -static int __init rtc_MK48T08_init(void) -{ - if (!MACH_IS_MVME16x) - return -ENODEV; - - pr_info("MK48T08 Real Time Clock Driver v%s\n", RTC_VERSION); - return misc_register(&rtc_dev); -} -device_initcall(rtc_MK48T08_init); --=20 2.39.5