Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: ALL THE I2C BUSSES
> On Apr 9, 2018, at 7:48 PM, Jason Thorpe <thorpej%me.com@localhost> wrote:
>
> Forgive me, folks, I’m a little new to the Raspberry Pi (a little slow on the uptake, I guess :-)…
>
> I’m a little confused about how to map the prevailing documentation on the RPI and it’s Broadcom SoC to NetBSD’s treatment of the device tree. NetBSD shows 3 i2c controllers (iic0, iic1, iic2). I also know the 40-pin Pi models with newer firmware have a dedicated ID EERPOM i2c bus brought out to pins 27 and 28. All of the pinout diagrams I’ve seen show the i2c that’s on pins 3 and 5 as SDA1 / SCL1. I always assumed that the first i2c bus wasn’t brought out to the 40-pin header, but rather used on-board only.
>
> So, I figured that the i2c on the header would be “iic1”, reinforced by the RPI kernel config file’s dsrtc* entry.
>
> Well, much to my chagrin, dsrtc0 was not, in fact, found on iic1. i2cscan found them on iic2. I can fix the kernel config file, no big deal. But I’d like to understand the device unit mapping at play.
There’s also a bug. The “iic” driver supports both direct configuration of devices (for board configs with a known set of devices on the i2c), as well as indirect config, which searches for devices specified in the kernel config file.
It looks like this code has changed a bit since I wrote it 15 years ago. If the parent driver (bsciic, in this case) provides a prop_array_t as iba->iba_child_devices, then indirect configuration is bypassed. If it does not, then there’s a dance to check for i2c-indirect-config == false or if the parent has i2c-child-devices as a property on itself, in which case, again, indirect config is skipped.
The problem in the bsciic driver is that if there is not i2c-child-devices property, then an empty array is assigned to iba->iba_child_devices. This makes the check against NULL fail, and thus no indirect config devices will be found.
The following patch makes the dsrtc driver work correctly on my RPI:
Index: bcm2835_bsc.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/broadcom/bcm2835_bsc.c,v
retrieving revision 1.10
diff -u -p -r1.10 bcm2835_bsc.c
--- bcm2835_bsc.c 3 Mar 2018 16:03:38 -0000 1.10
+++ bcm2835_bsc.c 10 Apr 2018 04:22:17 -0000
@@ -184,7 +184,7 @@ bsciic_attach(device_t parent, device_t
if (iba.iba_child_devices)
prop_object_retain(iba.iba_child_devices);
else
- iba.iba_child_devices = prop_array_create();
+ iba.iba_child_devices = NULL;
prop_object_release(devs);
config_found_ia(self, "i2cbus", &iba, iicbus_print);
A quick perusal indicates that other board packages have the same bug.
.
.
.
bsciic2 at fdt1: Broadcom Serial Controller
iic2 at bsciic2: I2C bus
dsrtc0 at iic2 addr 0x68: DS3231 Real-time Clock
.
.
.
(and I’ve confirmed that the correct date/time are stored in the RTC at reboot, and read correctly at boot time.)
-- thorpej
Home |
Main Index |
Thread Index |
Old Index