[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yn+nAFCA/+Wm+rC/@mail.local>
Date: Sat, 14 May 2022 14:56:32 +0200
From: Alexandre Belloni <alexandre.belloni@...tlin.com>
To: Huacai Chen <chenhuacai@...ngson.cn>
Cc: Arnd Bergmann <arnd@...db.de>, Andy Lutomirski <luto@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
David Airlie <airlied@...ux.ie>,
Jonathan Corbet <corbet@....net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
linux-arch@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, Xuefeng Li <lixuefeng@...ngson.cn>,
Yanteng Si <siyanteng@...ngson.cn>,
Huacai Chen <chenhuacai@...il.com>,
Guo Ren <guoren@...nel.org>, Xuerui Wang <kernel@...0n.name>,
Jiaxun Yang <jiaxun.yang@...goat.com>,
Stephen Rothwell <sfr@...b.auug.org.au>
Subject: Re: [PATCH V10 16/22] LoongArch: Add misc common routines
Hi,
On 14/05/2022 16:03:56+0800, Huacai Chen wrote:
> diff --git a/arch/loongarch/kernel/rtc.c b/arch/loongarch/kernel/rtc.c
> new file mode 100644
> index 000000000000..d7568385219f
> --- /dev/null
> +++ b/arch/loongarch/kernel/rtc.c
> @@ -0,0 +1,36 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
> + */
> +
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/platform_device.h>
> +#include <asm/loongson.h>
> +
> +#define RTC_TOYREAD0 0x2C
> +#define RTC_YEAR 0x30
> +
> +unsigned long loongson_get_rtc_time(void)
> +{
> + unsigned int year, mon, day, hour, min, sec;
> + unsigned int value;
> +
> + value = ls7a_readl(LS7A_RTC_REG_BASE + RTC_TOYREAD0);
> + sec = (value >> 4) & 0x3f;
> + min = (value >> 10) & 0x3f;
> + hour = (value >> 16) & 0x1f;
> + day = (value >> 21) & 0x1f;
> + mon = (value >> 26) & 0x3f;
> + year = ls7a_readl(LS7A_RTC_REG_BASE + RTC_YEAR);
> +
> + year = 1900 + year;
> +
> + return mktime64(year, mon, day, hour, min, sec);
> +}
> +
> +void read_persistent_clock64(struct timespec64 *ts)
> +{
This should rather be implemented in a proper rtc driver and then have
userspace set the system time or use hctosys.
> + ts->tv_sec = loongson_get_rtc_time();
> + ts->tv_nsec = 0;
> +}
> --
> 2.27.0
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists