lkml.org 
[lkml]   [2022]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH V10 16/22] LoongArch: Add misc common routines
    Hi, Alexandre,

    On Sat, May 14, 2022 at 8:56 PM Alexandre Belloni
    <alexandre.belloni@bootlin.com> 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?

    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

    \
     
     \ /
      Last update: 2022-05-14 16:13    [W:2.399 / U:0.116 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site