lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6cc22970-fa11-ccb4-c155-62396a7e3890@axis.com>
Date:   Sun, 31 Oct 2021 11:29:12 +0100
From:   Pavel Modilaynen <pavelmn@...s.com>
To:     Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Pavel Modilaynen <Pavel.Modilaynen@...s.com>
CC:     "a.zummo@...ertech.it" <a.zummo@...ertech.it>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "linux-rtc@...r.kernel.org" <linux-rtc@...r.kernel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "lkml@...s.com" <lkml@...s.com>, kernel <kernel@...s.com>
Subject: Re: [PATCH 1/2] rtc: rs5c372: Add support for trim configuration

Hi Alexandre,


On 10/31/21 12:57 AM, Alexandre Belloni wrote:
> Hello,
> 
> Please use the proper RTC interface by implementing .set_offset and
> .read_offset.

I am not sure about .set/read_offset. It looks as runtime adjustment 
interface,
however this Xtal trimming parameter is based on schematics and Xtal 
capacitance (datasheet parameter).
It is found by calibration procedure based on RTC clock output (the 
procedure and calculation of trimming parameter is described in datasheets).
So, I would like to say that this parameter is functionally close to
"quartz-load-femtofarads" for rtc-pcf8523/pcf85063.

> 
> On 31/10/2021 00:50:53+0200, Pavel Modilaynen wrote:
>> From: Pavel Modilaynen <pavelmn@...s.com>
>> 
>> 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 <pavelmn@...s.com>
>> ---
>>  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 <linux/slab.h>
>>  #include <linux/module.h>
>>  #include <linux/of_device.h>
>> +#include <linux/of.h>
>>  
>>  /*
>>   * 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 <https://bootlin.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ