Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1770880iob; Sat, 14 May 2022 20:39:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDysTdDRl73ngbt8/n3HYKr+YTM619+YuWwCnDCsAdw6eWQlC1FYEyuzV7+YKLy3Eys4oX X-Received: by 2002:a05:6000:2cc:b0:20c:5c31:1120 with SMTP id o12-20020a05600002cc00b0020c5c311120mr9651862wry.105.1652585972195; Sat, 14 May 2022 20:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652585972; cv=none; d=google.com; s=arc-20160816; b=S25rhMsrqOse3rXjO8jTg8y9lUIWaJWlDwQzcd8QGglKxp7nYj5Qzs1qBSS0JfLUWz Q8+Ub0rvjrAYeEU207oZz1hvJcHh11/9ar71wY3ay/ya13KFaWvvmbIjmfaGuFiLt4A6 MsuXGqHON3BZD/bQK1yFlsQc9jeYtFbPV+6ubv5JyhvGJdT1dL+sfQ7Ccn6q+XV+fSoy 7UoTum5X9lEhrFty7lzqlxbWG3vArSYrrnBHocxIXTBQxlgW1qW+tJMJsBEi/Ql+RkBF lNZWj8N3gnbqMqxfd+uKHaLd29VKL+lmzhBrMhbpecBPQC79Sd54aGatPuGH96HErARS 0Ppw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6WfQCozPKRIS1eb+8FwlePRl53vVrdYwrk9axraCIxo=; b=BDmE/9quiWNRSUq8VhGesK79E62BKQ7c+VFVDAXGiaZlDV+za5n4RH4SPl9AeGzLtt mZ2rRjRTr83g6UR9jcLtMryrx96ZHUqgIITokqprHPXzeHrH4z940C55+S+GKrr0MHs9 WD7Q76TmZkAhBXEonn4gVr1routu+noG6FF6Hw6mgZk1B7Ep8X1FZ+yGOLgSUV+7wMGO w3rypafuPoIw0+6QtGzniybFr1kFb7qkA7hGDntoqtrKIIBsNVNUy2/k6Q9Q+UOR5dST XkFlvbfGRi6CKNn8gh6LFIgNUzqP4ww4pW0cQFKw61wJZgiceIA9ixWzlPWv5fkmijC3 gqGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=clNGH9JT; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i18-20020a05600c355200b00394497dad60si8208672wmq.115.2022.05.14.20.39.06; Sat, 14 May 2022 20:39:32 -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=@bootlin.com header.s=gm1 header.b=clNGH9JT; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234070AbiENQAn (ORCPT + 99 others); Sat, 14 May 2022 12:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232414AbiENQAl (ORCPT ); Sat, 14 May 2022 12:00:41 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E53D20BC2; Sat, 14 May 2022 09:00:38 -0700 (PDT) Received: (Authenticated sender: alexandre.belloni@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 10168100004; Sat, 14 May 2022 16:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1652544037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6WfQCozPKRIS1eb+8FwlePRl53vVrdYwrk9axraCIxo=; b=clNGH9JTtIRzD2/SfSPVoov0gdu5f4sFNNETGJRfTv6e1IcJqsUtjcLg83+lAjgBff5wrt J5OL+J8daN8O+zmvnRr7RoRvbjxKzdOpGdgqpab92qaRYblgdAux83+Fj+sfztm4Qq2flL K3oDgdl5zW2yhfkkYNqPpaLlGZ7/+8w9Y7KaCJ4dxXgqqTataagF3UJqhMH9Yeoy/yiinW OtC+zN10Y4c+znygsnmHPj7caAGMV1MaPBUj7ddkNt9leA+6og2HXF9OQQkcyMMN8GTXtz 8GS652moGqCMQDgrCkrTYKRi8ou1VK+SSZ9N+ZhP9UVVtzSkj9wsZB2uh4W2Xw== Date: Sat, 14 May 2022 18:00:33 +0200 From: Alexandre Belloni To: Huacai Chen 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 Subject: Re: [PATCH V10 16/22] LoongArch: Add misc common routines Message-ID: References: <20220514080402.2650181-1-chenhuacai@loongson.cn> <20220514080402.2650181-17-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 On 14/05/2022 22:12:37+0800, Huacai Chen wrote: > 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? > 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