Re: [PATCH V10 16/22] LoongArch: Add misc common routines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14/05/2022 22:12:37+0800, Huacai Chen wrote:
> Hi, Alexandre,
> 
> On Sat, May 14, 2022 at 8:56 PM Alexandre Belloni
> <alexandre.belloni@xxxxxxxxxxx> wrote:
> >
> > 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.
> I found that some archs don't implement read_persistent_clock64(), so
> I can safely remove the whole file if there is available rtc drivers?
> 

Yes, you can remove the whole file.

> Huacai
> >
> > > +     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

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux