Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Feb 2016 17:49:09 +0200
From:      Jukka Ukkonen <jau789@gmail.com>
To:        Ian Lepore <ian@freebsd.org>, freebsd-arm <freebsd-arm@FreeBSD.org>
Subject:   Re: ds3231 suddenly failing
Message-ID:  <56B372F5.3090506@gmail.com>
In-Reply-To: <1454511243.1736.3.camel@freebsd.org>
References:  <56B21158.80401@gmail.com> <1454511243.1736.3.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 02/03/16 16:54, Ian Lepore wrote:
> On Wed, 2016-02-03 at 16:40 +0200, Jukka Ukkonen wrote:
>> Hello all,
>>
>> Previously my RPI2 had no problems with ds3231 RTC.
>> Now 11.0-CURRENT r295206 shows these during boot...
>>
>> ds32310: <Maxim DS3231 RTC> at addr 0x1a0 on iicbus1
>> ds32310: cannot read from RTC.
>>
>> Trying sysctl dev.ds3231 gives me this...
>>
>> dev.ds3231.0.%parent: iicbus1
>> dev.ds3231.0.%pnpinfo: name=rtc compat=maxim,ds3231
>> dev.ds3231.0.%location: addr=0x1a0
>> dev.ds3231.0.%driver: ds3231
>> dev.ds3231.0.%desc: Maxim DS3231 RTC
>> dev.ds3231.%parent:
>>
>> Trying "i2c -s" does not show anything on either
>> /dev/iic0 or /dev/iic1.
>>
>> AFAIK I have not changed anything in the build.
>>
>> Checking the contents of rpi2.dtb says this about
>> the clock chip...
>>
>>                         rtc {
>>                                 compatible = "maxim,ds3231";
>>                                 reg = <0xd0>;
>>                         };
>>
>> I guess that the alert "cannot read from RTC." is
>> due to the fact that "addr 0x1a0" does not match
>> "reg = <0xd0>;" in the DTB. It just does not dawn
>> to me where the kernel found the alternate value.
>> Any ideas?
>>
>> --jau
> 
> You didn't say what version you were running previously that had no
> problems, but there was an update a while back that changed the i2c
> device addressing in dts files to match the published standard, which
> requires 7-bit addresses.  Freebsd has always used 8-bit addresses in
> i2c drivers.  (0x1a0 is 0xd0 left-shifted by 1).
> 
> So, just adjust the address in your dts to 0x68 and it should start
> working again.
> 
> -- Ian
> 

Quite right. I did not say what was the previous version for
the simple reason that I installed the new OS version on the
same SD card without checking the old version first.

Anyhow your hint was spot on. When I shifted the 0xd0 value
down one bit in the DTS file the lost ds3231 returned to service
again. Thanks.

It seems that the ds3231 manual page still says only this...

-----
On a FDT(4) based system the following properties must be set:

compatible  Must always be set to "maxim,ds3231".

reg         The i2c address of ds3231. The default address for ds3231 is
0xd0.
-----

Obviously if left as is this tends to be misleading. The
proper value "reg = <0x68>" and the automatic shift by one
bit position should be explained in the manual page.

--jau




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56B372F5.3090506>