Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1522626pxb; Sat, 30 Oct 2021 16:00:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnxBRRoY3whR5XhY0kpNgG7qSxOsmHLWqGH3yom0/UHb+8sxIn1A/ZVO/tPfJ5kZGo8jOm X-Received: by 2002:a05:6402:280b:: with SMTP id h11mr7599964ede.378.1635634806932; Sat, 30 Oct 2021 16:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635634806; cv=none; d=google.com; s=arc-20160816; b=JO2RkCSG5xTK/pRlz4vESJ17c68VF0jYO7NqttGfZDoGYa9DkEH5YnP1MeHXSBaIS8 XAONIVHr3sW4ZP126wT2CzNAjdAa82hQIHhslquzsJD5+cGc8w8NKOvikp9H6JZIdtlV fJk+S62qDy204My5P5ZpFBbxkdsVWCYe5v9M/j0u0I7duwbisXXa+rsgmWfCUS1YNSqK vWdxs0YDGLZzDwTeG39Zg8nOllzPU93AOYmLy4luJ4dKeoqbCQs0bPOEqkMRynpOnz5D SfuY31vLgSxk+CcIXbEL/C5YxTfic7gIsRCA4V3BCC8Fb0UQVZNjRK5Cy5CC/Yb7VyCZ PYjg== 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; bh=LFFuS6nPzfbi5UC1vA89NaELz1vWvpb4Zuuk22l8ne0=; b=bNt4rrVK6pP5dYo+rmyxC3INnBi9MmhbuEwCL7k6FQjdmOIn4eMWrkYscTZ9WFt3b3 T65Nr9d5lFVpaLtiSjHOYMoktImK4E+JO5hRZip3nB4w+1RXeokI0ZDzAuhad/CHL+SM 6OleGiRPNFZYL3Fo8b+Gb/jGEj8DZvlzJGl/hc2IeMjOYnyU0KmIj0Sm71xTGjtSXpO1 sIyUdDKLgdZUQx8yiWYIqeQZulqu1i3trT9B8929GeCi347pcStbI7Tr1ndavFTXqxKq SCRonPk2RG+mXOM0Hi33cJgvoBdWWGyEwR+K17b9qBjS8BYWxw85odxYG7cuAVZEkED4 UbzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si12973711ejm.446.2021.10.30.15.59.43; Sat, 30 Oct 2021 16:00:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232020AbhJ3XAd (ORCPT + 99 others); Sat, 30 Oct 2021 19:00:33 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:33697 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbhJ3XAd (ORCPT ); Sat, 30 Oct 2021 19:00:33 -0400 Received: (Authenticated sender: alexandre.belloni@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 43347100005; Sat, 30 Oct 2021 22:57:58 +0000 (UTC) Date: Sun, 31 Oct 2021 00:57:57 +0200 From: Alexandre Belloni To: Pavel Modilaynen Cc: a.zummo@towertech.it, robh+dt@kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lkml@axis.com, kernel@axis.com, Pavel Modilaynen Subject: Re: [PATCH 1/2] rtc: rs5c372: Add support for trim configuration Message-ID: References: <20211030225054.32114-1-pavel.modilaynen@axis.com> <20211030225054.32114-2-pavel.modilaynen@axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211030225054.32114-2-pavel.modilaynen@axis.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Please use the proper RTC interface by implementing .set_offset and .read_offset. On 31/10/2021 00:50:53+0200, Pavel Modilaynen wrote: > From: Pavel Modilaynen > > Add support for oscillation adjustment register RS5C372_REG_TRIM > setting that is needed to accommodate for effective crystal > capacitance. > > Use optional property ricoh,trim that should contain > raw value to setup this register. According to > datasheets for RS5C372, R2025S/D, RV5C38[67] and R222[13] > the value will be converted to a number of ticks that > is to be subtracted or added when the second digits read > 00, 20 or 40 seconds. > > Signed-off-by: Pavel Modilaynen > --- > drivers/rtc/rtc-rs5c372.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c > index 80980414890c..3a2db0326669 100644 > --- a/drivers/rtc/rtc-rs5c372.c > +++ b/drivers/rtc/rtc-rs5c372.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > /* > * Ricoh has a family of I2C based RTCs, which differ only slightly from > @@ -560,6 +561,8 @@ static int rs5c_oscillator_setup(struct rs5c372 *rs5c372) > { > unsigned char buf[2]; > int addr, i, ret = 0; > + struct i2c_client *client = rs5c372->client; > + u8 trim = 0; > > addr = RS5C_ADDR(RS5C_REG_CTRL1); > buf[0] = rs5c372->regs[RS5C_REG_CTRL1]; > @@ -599,9 +602,22 @@ static int rs5c_oscillator_setup(struct rs5c372 *rs5c372) > break; > } > > + /* optional setup of xtal trimming */ > + if (!of_property_read_u8(client->dev.of_node, "ricoh,trim", &trim)) { > + if (rs5c372->type != rtc_r2221tl && (trim & ~RS5C372_TRIM_MASK)) { > + dev_warn(&client->dev, "Erroneous setting for ricoh,trim in devicetree\n"); > + } else { > + int addr = RS5C_ADDR(RS5C372_REG_TRIM); > + int ret = i2c_smbus_write_byte_data(client, addr, trim); > + > + if (unlikely(ret < 0)) > + return ret; > + } > + } > + > for (i = 0; i < sizeof(buf); i++) { > addr = RS5C_ADDR(RS5C_REG_CTRL1 + i); > - ret = i2c_smbus_write_byte_data(rs5c372->client, addr, buf[i]); > + ret = i2c_smbus_write_byte_data(client, addr, buf[i]); > if (unlikely(ret < 0)) > return ret; > } > -- > 2.20.1 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com