From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8DBE3A8C2; Mon, 22 Jan 2024 09:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705914925; cv=none; b=IZ6TIMXf5s/Fd7Dm59s1ONc9PGLvgUx7bX91TZ4zR1dxOwkSXhbcYp7zCxjVuZjMTKYArxsF4u7efuySp98PAInqJVjc2ndmc5ce2aDGYGScla3A5vKGxwxFhWboIpIfaargroxvy0os5ffGxGzCiqVuIB6LzFx1QLxY64s6z9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705914925; c=relaxed/simple; bh=QOMGLQ8Zx+wPiL92sY2/XSGqt6AVHmJbZBY431fESWI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EqOa88ciVXuMQiDUw8DsssDlLT+XVRiJ6aFlmVrgGe5x8dqBJHZQWKqOir1CFtPxqE+zxnbsKG8h9ChOZN7isQlhiSaB5vqBw7Ls5uZoUJ1QAchP9d6PLK5lT9lj1OWmKgA3lGFeCAzmtPWHtrQdmx8YDT5nwceKpsHnvM5lMpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=SFDc5YZj; arc=none smtp.client-ip=217.70.183.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="SFDc5YZj" Received: by mail.gandi.net (Postfix) with ESMTPSA id E828C1C0008; Mon, 22 Jan 2024 09:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1705914914; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrG9+46KuXtBlxIUOx0DyHU7sjn1FkhruzlXHAOP5As=; b=SFDc5YZjAYVRO1aKvOuFt3JAr6qRfWGKwPgTbdbQ/8JLd8rtm9JbE+BvXMa0rqbH5G+TNI iFBNBhJw6VvJBsBwjBLnZJ4eFrzgxCIWgFYFZgM+5rKAjSv7Qv5be3ayicmtSpg99/LiEE ZArtLOhhmbouLIJYFK9bDQuasJJcksq4VSNVFdU7J1TujI7vjCB+tp7dRrO06BVCGmqhYx ygT/I2wQJmN+ud0cuf3cgD3x0J3Uq3qOKFfzH6kHinnuAwmtZ0wzqwnaRphmMWLC32FRoY euogrM+TTpBI1BpgrfHqLzuyN6j6EmGrcMiUg+m7KKfJ9PUVei+uOHtSipZj0Q== Date: Mon, 22 Jan 2024 10:15:11 +0100 From: Alexandre Belloni To: Jingbao Qiu Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, chao.wei@sophgo.com, unicorn_wang@outlook.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, dlan@gentoo.org Subject: Re: [PATCH v7 2/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC Message-ID: <2024012209151130867663@mail.local> References: <20240122080631.2880-1-qiujingbao.dlmu@gmail.com> <20240122081722868bdda5@mail.local> Precedence: bulk X-Mailing-List: linux-rtc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-GND-Sasl: alexandre.belloni@bootlin.com On 22/01/2024 16:34:00+0800, Jingbao Qiu wrote: > On Mon, Jan 22, 2024 at 4:17 PM Alexandre Belloni > wrote: > > > > On 22/01/2024 16:06:30+0800, Jingbao Qiu wrote: > > > Implement the RTC driver for CV1800, which able to provide time alarm > > > and calibrate functionality. > > > > > > Signed-off-by: Jingbao Qiu > > > --- > > > > > > Depends on https://lore.kernel.org/all/IA1PR20MB4953C774D41EDF1EADB6EC18BB6D2@IA1PR20MB4953.namprd20.prod.outlook.com/ > > > > What is the dependency? > > > > Thank you, this driver requires support from the CLK driver. > I will add an explanation in the next version. > > > > > Also, please fix the checkpatch.pl --strict warnings > > I will use the -- strict option for testing. > > > > > > +/** > > > + * cv1800_rtc_32k_coarse_val_calib() - Using an external > > > + * clock to coarse calibrate the crystal oscillator > > > + * @info: the device of calibrated > > > + * > > > + * @return 0 on success, or -1 on fail > > > + * > > > + * This RTC has an independent 32KHz oscillator. However, > > > + * the accuracy of this oscillator is easily affected by > > > + * external environmental interference,resulting in lower > > > + * accuracy than the internal oscillator.Therefore, a 25M > > > + * crystal oscillator is used as a reference source to > > > + * calibrate the RTC and improve its accuracy.Calibration > > > + * is completed through two steps, namely rough calibration > > > + * and fine calibration. > > > + */ > > > +static int cv1800_rtc_32k_coarse_val_calib(struct cv1800_rtc_priv *info) > > > > This is still not working as well as you think it is. You should > > Implement the offset callbacks instead. > > > I'm sorry, I don't quite understand offset callbacks. > Do you mean that this function needs to be executed periodically. I mean implement read_offset and set_offset here: https://elixir.bootlin.com/linux/v6.7/source/include/linux/rtc.h#L67 -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C46C1C47DAF for ; Mon, 22 Jan 2024 09:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zXbLVidYIwuMxjOg+4myhX4E6e00Vetj6gudtb8HT7I=; b=YHRxmn5JkPYDn/ nOPNTp2Pf3XZflVDTUaC149DfopK4XO5bw/qPb68nreG6/St8+DznVzU3uh3uCPH/gwB7eZ3dz/Ih BG4T9ftAN/rTzIyhSsgO7/7BiRgArYdWZjKGupr7EuIalTP1rGzOwR6WEeb1WiHN1MfTdL7i8oTiV 6RPdzNM1KqXm8AVOj8JvNzucg1aPcXzExs4wqwWSLI75ZqThckkea3EMcFUaPxAnIWMtdrDhIQO4a p3rWE7Xujex/Tj+JZsJ3oFuWfkPS7mx9wdtUjEfbUf1sZJP0u/BugRIE80nfCnlpDsUBRaqwd/0RN UeBMrXThyWTGGWcsrGvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rRqOr-00BEzu-05; Mon, 22 Jan 2024 09:15:25 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rRqOl-00BEwa-1I for linux-riscv@lists.infradead.org; Mon, 22 Jan 2024 09:15:23 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id E828C1C0008; Mon, 22 Jan 2024 09:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1705914914; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrG9+46KuXtBlxIUOx0DyHU7sjn1FkhruzlXHAOP5As=; b=SFDc5YZjAYVRO1aKvOuFt3JAr6qRfWGKwPgTbdbQ/8JLd8rtm9JbE+BvXMa0rqbH5G+TNI iFBNBhJw6VvJBsBwjBLnZJ4eFrzgxCIWgFYFZgM+5rKAjSv7Qv5be3ayicmtSpg99/LiEE ZArtLOhhmbouLIJYFK9bDQuasJJcksq4VSNVFdU7J1TujI7vjCB+tp7dRrO06BVCGmqhYx ygT/I2wQJmN+ud0cuf3cgD3x0J3Uq3qOKFfzH6kHinnuAwmtZ0wzqwnaRphmMWLC32FRoY euogrM+TTpBI1BpgrfHqLzuyN6j6EmGrcMiUg+m7KKfJ9PUVei+uOHtSipZj0Q== Date: Mon, 22 Jan 2024 10:15:11 +0100 From: Alexandre Belloni To: Jingbao Qiu Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, chao.wei@sophgo.com, unicorn_wang@outlook.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, dlan@gentoo.org Subject: Re: [PATCH v7 2/3] rtc: sophgo: add rtc support for Sophgo CV1800 SoC Message-ID: <2024012209151130867663@mail.local> References: <20240122080631.2880-1-qiujingbao.dlmu@gmail.com> <20240122081722868bdda5@mail.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-GND-Sasl: alexandre.belloni@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240122_011519_577296_ACADCF05 X-CRM114-Status: GOOD ( 23.50 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org T24gMjIvMDEvMjAyNCAxNjozNDowMCswODAwLCBKaW5nYmFvIFFpdSB3cm90ZToKPiBPbiBNb24s IEphbiAyMiwgMjAyNCBhdCA0OjE34oCvUE0gQWxleGFuZHJlIEJlbGxvbmkKPiA8YWxleGFuZHJl LmJlbGxvbmlAYm9vdGxpbi5jb20+IHdyb3RlOgo+ID4KPiA+IE9uIDIyLzAxLzIwMjQgMTY6MDY6 MzArMDgwMCwgSmluZ2JhbyBRaXUgd3JvdGU6Cj4gPiA+IEltcGxlbWVudCB0aGUgUlRDIGRyaXZl ciBmb3IgQ1YxODAwLCB3aGljaCBhYmxlIHRvIHByb3ZpZGUgdGltZSBhbGFybQo+ID4gPiBhbmQg Y2FsaWJyYXRlIGZ1bmN0aW9uYWxpdHkuCj4gPiA+Cj4gPiA+IFNpZ25lZC1vZmYtYnk6IEppbmdi YW8gUWl1IDxxaXVqaW5nYmFvLmRsbXVAZ21haWwuY29tPgo+ID4gPiAtLS0KPiA+ID4KPiA+ID4g RGVwZW5kcyBvbiBodHRwczovL2xvcmUua2VybmVsLm9yZy9hbGwvSUExUFIyME1CNDk1M0M3NzRE NDFFREYxRUFEQjZFQzE4QkI2RDJASUExUFIyME1CNDk1My5uYW1wcmQyMC5wcm9kLm91dGxvb2su Y29tLwo+ID4KPiA+IFdoYXQgaXMgdGhlIGRlcGVuZGVuY3k/Cj4gPgo+IAo+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