Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1397028iob; Sat, 14 May 2022 07:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1Z3EmUlbmb+de1Q/j6ohZywYyXdDrqMwaTw8Dj85us16DAL6YD3RIq3TxQTSDZDJNv0XM X-Received: by 2002:a05:6000:1815:b0:20a:deee:3cf0 with SMTP id m21-20020a056000181500b0020adeee3cf0mr7778670wrh.210.1652540330072; Sat, 14 May 2022 07:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652540330; cv=none; d=google.com; s=arc-20160816; b=cc3Rf+GO8jOMJeDXLzkb96v75Z0JwTcnG3sX4QD+vTUFnamU0LK3twA7583CDLANKH EH3h2tBMv9svjeHwy7gSF14gXIjoIHnwO8MTKarXClLehwyynh1YKB4As+P+e0u+0ZBB Po3c2lYCU5yWZiuZSrlrDMc8IWV0sCpUx9takYSNiHCgcoYEJXj+Uu2VZYkTOl+w3g4d uL1hHFncygJALyWQqereT88FvXO2weTjy6LxhmG2+ctwDoMY+fA8nkL/t2dKDBxJCOk8 QXkOCLa7T9DrK9pv08hFPEO6WEOAOGuF9Uq57ANG2x0SPoT7n7DCi/jXlXvTZJljppnX rwLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1i1F8HA8SXw91VCcJkd0PDhnz+7pwWJ7etAarJLpsYc=; b=NYB81/Bpesyzv8b5yZ18i20cvJ8AtCRp3UvOz5Vj99FYTjSpwJ8LUGTINAIRAQDy1W MYHqWZuPr6+ilMDilji0+/LrkVTmPaFHId6eCg6qF7xWbr2YHfSZ9TBHsDg6UOED7Wem W7x9/fHIlV2TY2V1kcZWPv/puebFa9yROgzU4Qu/JP7Vwc2nXYiatM+JRnQpvePA8Kqb HzEFDSmyNr8NEO2L3QAKig/0lX4IcMfj0fub8uYtOvA9sgQQRLm985KtIslaAEwx9QlK XOFA4qvECZDqo9mcRSB8oNVzgnUst1G/uJh8cworBDs43W5uSQfH7AazxZycVOPKyzaj aVGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UhhF5+Er; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t15-20020adfdc0f000000b0020aa743efd9si4829698wri.153.2022.05.14.07.58.11; Sat, 14 May 2022 07:58:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UhhF5+Er; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232985AbiENONM (ORCPT + 99 others); Sat, 14 May 2022 10:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232817AbiENONE (ORCPT ); Sat, 14 May 2022 10:13:04 -0400 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053FA140F3; Sat, 14 May 2022 07:13:02 -0700 (PDT) Received: by mail-vs1-xe30.google.com with SMTP id y74so11169852vsy.7; Sat, 14 May 2022 07:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1i1F8HA8SXw91VCcJkd0PDhnz+7pwWJ7etAarJLpsYc=; b=UhhF5+ErMt0QBRHo3cb0CIi7PPt6V1b0Kl8TkcsbidISlait2xK3HZnrykYh8MPAKN pJVobsLGBXBz3IoRT42AETIIwJUfoKic28GhUYSshM/yOaH1TexpPCfmy1Nrc919sbKn MRpHSDEImOLuIWvlSMs4MsNpcRglUvPhgh0KDKHbushmpMekGaPNLWMGNkVNmJx2G9q6 +q6uDU/6WuyxS70uKQYRgs6XDV4EiMlA+JUdKX0hhgf6ecvIEx12JRDQSGDShnPVjTwK vn2hOZRte/SHLCarmLqDkUbf5A+35Ii+W0LTVIKrOQqc2Cize+zKsnQYeUwv55JoN31N dk6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1i1F8HA8SXw91VCcJkd0PDhnz+7pwWJ7etAarJLpsYc=; b=ZCW+XHF8HpnHUdG+Yooo8axwYTs2A8F5EmmgmPJ/FkYcg25DsVSeDSIBjvYdmcbr3r bzdcbRKePTOnzYnSdtQQjfHTZIFJ/sr2v8vr8OwGGA8T+YAXk/glo++ZqwZprJugvIGC 5jL2wK1C5EVIA3c/DAjBAm9clUTBRCLSoj4PI3RJ/aVdBD8X45dvJZmiYz7E483VWv5I lGYcBDJsryDzIFzrWDnBfwWKwbBF7wlfIG3yLzUTVf+Hfk1v6U1wEVi+uHXZxgreHLAR n72VgaL4c5Ojxafao3XF0Oyk1Ci5VCT9aaDyDQgYn/0Vc4FN6uJonIYWjWb4i3rjayk3 zBBQ== X-Gm-Message-State: AOAM532/mIHq7IHPMEzI7PiFGE4/RpoxV1seyhiYMMs9IXUs8Ln2c9+q +C7pvAujvehvvyqYOWDWEcfsPHjGiNOQD3Al4pU= X-Received: by 2002:a67:be0b:0:b0:32c:d82f:6723 with SMTP id x11-20020a67be0b000000b0032cd82f6723mr4212504vsq.67.1652537581096; Sat, 14 May 2022 07:13:01 -0700 (PDT) MIME-Version: 1.0 References: <20220514080402.2650181-1-chenhuacai@loongson.cn> <20220514080402.2650181-17-chenhuacai@loongson.cn> In-Reply-To: From: Huacai Chen Date: Sat, 14 May 2022 22:12:37 +0800 Message-ID: Subject: Re: [PATCH V10 16/22] LoongArch: Add misc common routines To: Alexandre Belloni Cc: Huacai Chen , Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , linux-arch , "open list:DOCUMENTATION" , LKML , Xuefeng Li , Yanteng Si , Guo Ren , Xuerui Wang , Jiaxun Yang , Stephen Rothwell Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Alexandre, On Sat, May 14, 2022 at 8:56 PM Alexandre Belloni 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 > > +#include > > +#include > > +#include > > + > > +#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