aklimaj
Posts: 4
Joined: Thu Sep 12, 2019 5:19 pm

CM4 BQ25890 dtoverlay help

Thu Jul 22, 2021 12:15 am

I have a custom CM4 board with a BQ25890 TI charger connected to I2C0 on pins 44 and 45. I can see the chip on i2cdetect on bus 0. I am trying to use a dtoverlay to load the BQ25890 module without success.

Here is my overlay.

Code: Select all

// Overlay for bq25890

/dts-v1/;
/plugin/;

/ {
        compatible = "brcm,bcm2835";

        fragment@0 {
                target = <&i2c0>;
                __overlay__ {
                #address-cells = <1>;
                #size-cells = <0>;

                bq25890: bq25890@6a {
                        compatible = "ti,bq25890";
                        reg = <0x6a>;
                        //interrupt-parent = <23>;
                        //interrupts = <1>;
                        ti,battery-regulation-voltage = <4200000>;
                        ti,charge-current = <6000000>;
                        ti,termination-current = <50000>;
                        ti,precharge-current = <128000>;
                        ti,minimum-sys-voltage = <3600000>;
                        ti,boost-voltage = <5000000>;
                        ti,boost-max-current = <1000000>;
                        ti,use-ilim-pin;
                        ti,thermal-regulation-threshold = <120>;
                        status = "okay";
                        };
                };
        };
};
I can compile it with no errors.

Code: Select all

sudo dtc -@ -I dts -O dtb -o /boot/overlays/bq25890.dtbo /boot/bq25890-overlay.dts
And it looks like it loads.

Code: Select all

005644.167: brfs: File read: 1462 bytes
005648.637: brfs: File read: /mfs/sd/overlays/i2c0.dtbo
005661.891: Loaded overlay 'i2c0'
005661.904: dtparam: pins_44_45=on
005686.575: brfs: File read: 1785 bytes
005696.154: brfs: File read: /mfs/sd/overlays/bq25890.dtbo
005701.696: Loaded overlay 'bq25890'
005726.069: brfs: File read: 826 bytes
But it does not appear to be running. Any suggestions?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4064
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 BQ25890 dtoverlay help

Thu Jul 22, 2021 7:36 am

Does the device appear in the output of "i2cdetect -y 0"?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4064
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 BQ25890 dtoverlay help

Thu Jul 22, 2021 8:26 am

I think your problem is that there is an I2C multiplexer enabled by default which the i2c0 partially (but not completely) disables.

Out of the box, the "i2c0" DT label and /dev/i2c-0 both select the I2C0 hardware interface enabled on GPIOs 0 & 1. I2C0 on GPIOs 44 & 45 is available at label "i2c_csi_dsi" and /dev/i2c-10.

1. Try removing your use of the i2c0 dtoverlay and then run "sudo i2cdetect -y 10" - the device should appear at address 0x6a.
2. Edit the overlay and change the target of fragment0 to be "&i2c_csi_dsi".
3. Profit!

aklimaj
Posts: 4
Joined: Thu Sep 12, 2019 5:19 pm

Re: CM4 BQ25890 dtoverlay help

Thu Jul 22, 2021 7:45 pm

Thanks. I turned dtparam=i2c_vc=on back on and I can see it on i2c 10 and 11.

Code: Select all

pi@raspberrypi:~ $ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi:~ $ sudo i2cdetect -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- 6a -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi:~ $ sudo i2cdetect -y 11
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- 6a -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi:~ $
I changed the overlay to &i2c_csi_dsi and it still does not appear to work.

Code: Select all

005630.955: brfs: File read: /mfs/sd/overlays/bq25890.dtbo
005636.481: Loaded overlay 'bq25890'
005651.205: brfs: File read: 778 bytes
Maybe the kernel driver isn't compiled and present?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4064
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 BQ25890 dtoverlay help

Thu Jul 22, 2021 9:03 pm

If you include:

Code: Select all

status = "okay";
in the overlay then you won't need the "dtparam=i2c_vc=on".

Can you modprobe the module? Are there any relevant errors in the output of "dmesg"?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11637
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CM4 BQ25890 dtoverlay help

Fri Jul 23, 2021 6:50 am

Code: Select all

status = "okay"
needs to be on the i2c0if and i2c0mux nodes, not i2c_csi_dsi or i2c0.

The fact that i2cdetect shows the address and not UU means the kernel driver hasn't been loaded to claim that device.

Code: Select all

grep bq25890 /lib/modules/`uname -r`/*
will tell you if the compatible string is found for your kernel build, and which module is associated. modinfo on that module name will map back the other way.

And ignore i2c-11 - it's a quirk of the way the muxes work that it leaves the parent bus exposed. This makes sense for devices such as PCA9548A where the parent bus is physically accessible, but less sense with i2c-mux-pinctrl where it isn't.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

aklimaj
Posts: 4
Joined: Thu Sep 12, 2019 5:19 pm

Re: CM4 BQ25890 dtoverlay help

Sat Jul 24, 2021 12:36 am

dmesg shows nothing about the BQ25890.

Code: Select all

pi@raspberrypi:~ $ grep bq25890 /lib/modules/`uname -r`/*
grep: /lib/modules/5.10.52-v7l+/kernel: Is a directory

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11637
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CM4 BQ25890 dtoverlay help

Sat Jul 24, 2021 10:18 am

Follow https://www.raspberrypi.org/documentati ... uilding.md to build your own kernel.
After doing the "make bcmXXX_defconfig" step you'll want to run "make menuconfig" (text based) or "make xconfig" (X GUI option) to allow adding CHARGER_BQ25890 (with menuconfig, press "/" to allow searching, otherwise it should be under Device Drivers/Power Supply Class Support). Then resume the build steps.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Device Tree”