Re: DS3231 v. MAX77620

From: Brian Scott <bscott_at_bunyatech.com.au>
Date: Mon, 08 Nov 2021 09:27:57 UTC
On 8/11/21 7:55 pm, Mark Murray wrote:
> On 7 Nov 2021, at 13:42, Bernd Walter <ticso@cicely7.cicely.de 
> <mailto:ticso@cicely7.cicely.de>> wrote:
>>
>> However, I also couldn't get the same DS3231 module running on my Pi4.
>
> The GPIO drivers for BCM2711 are subtly different from the others, and 
> thus
> don't quite work. I have some config.txt hacks to turn on I2C, but 
> ideally we
> should fix the drivers.
>
> I keep on failing to get time to do this, and getting my head around 
> FDT is
> an obstacle.
>
> Some looking around has shown a couple of problems:
> 1) Register differences in BCM2711 - should be easy to fix with a bit 
> of time
> 2) We don't use the in-tree FDT files on the RPi's. Needs fixing if we 
> are to
>    be able to tweek them without manual recompilation.
>
I got some help from Hrant Dadivanyan privately about the general I2C 
problem (setting alt0 mode on GPIO 2 and 3) that was covered in a 
discussion starting in 
https://lists.freebsd.org/pipermail/freebsd-arm/2021-April/023685.html. 
I had expected that the standard config.txt line 
'dtparam=audio=on,i2c_arm=on,spi=on' should have taken care of this 
(i2c_arm=on). Good luck digging deeper into this. This stuff is 
seriously weird and its very easy to just go with the boilerplate fix.

With the choice of module issue, Hrant reported that what appears to be 
an identical set up to mine but with a different outcome:

Mine is 13.0-RELEASE without anything special to hide MAX77620:
# dmesg | egrep -i 'iic|rtc|ds3231|max'
iichb0: <BCM2708/2835 BSC controller> mem 0x7e804000-0x7e804fff irq 26 
on simplebus0
iicbus0: <OFW I2C bus> on iichb0
iic0: <I2C generic I/O> on iicbus0
ds32310: <Maxim DS3231 RTC> at addr 0xd0 on iicbus0
ds32310: registered as a time-of-day clock, resolution 1.000000s

Mine (with the I2C fix) gives:

iicbus0: <OFW I2C bus> on iichb0
iic0: <I2C generic I/O> on iicbus0
rtc0: <MAX77620 RTC> at addr 0xd0 on iicbus0
rtc0: registered as a time-of-day clock, resolution 1.000000s

But seems to be working.

As a positive from this, learning about the gpio= statement in 
config.txt has allowed me to set the pull-up attribute on a few pins 
(unrelated to this topic). This seems to be something the GPIO driver 
for the BCM2711 (?) is incapable of doing. 'gpio=22,23=ip,pu' . Lovely.

Thanks for the work and the help,

Brian