Libre Computer Raspbian Portability Feedback

I have good news. I was able to create a DTS file for the PCA9548 and when I compiled, installed and enabled the module, I got the following message in the dmesg feedback:

[ 3711.951406] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/bus@c8100000/i2c@500/status
[ 3711.960088] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/pca9548
[ 3711.971380] i2c i2c-0: Added multiplexed i2c bus 1
[ 3711.973785] i2c i2c-0: Added multiplexed i2c bus 2
[ 3711.984706] i2c i2c-0: Added multiplexed i2c bus 3
[ 3711.991326] i2c i2c-0: Added multiplexed i2c bus 4
[ 3712.002107] i2c i2c-0: Added multiplexed i2c bus 5
[ 3712.012163] i2c i2c-0: Added multiplexed i2c bus 6
[ 3712.019968] i2c i2c-0: Added multiplexed i2c bus 7
[ 3712.027143] i2c i2c-0: Added multiplexed i2c bus 8
[ 3712.028492] pca954x 0-0070: registered 8 multiplexed busses for I2C switch pca9548

Don’t know exactly where the memory leak message is coming from, but it’s definitely not related to my DTS only since I see this a lot of times when enabling a DTO.

When I run the command ls -als /dev/i2c* I have the following feedback:

pi@librecomputer:~ $ ls -als /dev/i2c*
0 crw-rw---- 1 root i2c 89, 0 Dec  1 16:03 /dev/i2c-0
0 crw-rw---- 1 root i2c 89, 1 Dec  1 17:02 /dev/i2c-1
0 crw-rw---- 1 root i2c 89, 2 Dec  1 17:02 /dev/i2c-2
0 crw-rw---- 1 root i2c 89, 3 Dec  1 17:02 /dev/i2c-3
0 crw-rw---- 1 root i2c 89, 4 Dec  1 17:02 /dev/i2c-4
0 crw-rw---- 1 root i2c 89, 5 Dec  1 17:02 /dev/i2c-5
0 crw-rw---- 1 root i2c 89, 6 Dec  1 17:02 /dev/i2c-6
0 crw-rw---- 1 root i2c 89, 7 Dec  1 17:02 /dev/i2c-7
0 crw-rw---- 1 root i2c 89, 8 Dec  1 17:02 /dev/i2c-8

which is perfect!

Next, I connected an MCP23017 IO expander to the second output of the PCA9548 (so, connected to the virtual bus /dev/i2c-2) and saw the following feedback when running the command i2cdetect -y x, where x in the below output is 0, 1 and 2:

pi@librecomputer:~ $ 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: UU -- -- -- -- -- -- --
pi@librecomputer:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: UU -- -- -- -- -- -- --
pi@librecomputer:~ $ i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- 21 -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: UU -- -- -- -- -- -- --

As you can see, bus 0 only detects the PCA9548 (defaulted to address 0x70) and indicates it as UU, meaning it’s not really directly accessible but used as a “proxy” I2C device to forward incoming I2C commands to the correct output.

Bus 1 (that is the first virtual bus created by the PCA9548 DTO) has the same output as bus 0 since nothing is connected to that I2c output of the PCA9548.

However, bus 2 detects, next to the “proxy” I2C device, also my MCP23017 IO expander, which is perfect!

I can now access my I2C IO expander through the I2C mux, which was my first goal to achieve. Mission accomplished!

And for those interested in the PCA9548 DT source file, here it is:

/*
 * Author: Geert Vancompernolle
 *
 */

/*
 * Overlay to add the PCA9548 I2C mux (or equivalent) to the system giving the user an extra
 * 8 I2C buses /dev/i2c-1 .. /dev/i2c-8.
 * Default address of the I2C mux = 0x70 (all 3 address pins grounded).
 */

/dts-v1/;
/plugin/;

/{
	compatible = "libretech,cc", "amlogic,s905x", "amlogic,meson-gxl";

	fragment@1 {
		target = <&i2c_AO>;

		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			pca9548: mux@70 {
				compatible = "nxp,pca9548";
				reg = <0x70>;
				#address-cells = <1>;
				#size-cells = <0>;

				i2c@0 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <0>;
				};
				i2c@1 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <1>;
				};
				i2c@2 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <2>;
				};
				i2c@3 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <3>;
				};
				i2c@4 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <4>;
				};
				i2c@5 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <5>;
				};
				i2c@6 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <6>;
				};
				i2c@7 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <7>;
				};
			};
		};
	};

	__overrides__ {
		addr = <&pca9548>,"reg:0";
                bus = <&i2c_AO>,"reg:0";
	};
};

If someone from LibreComputer (or anyone else) has any remarks, then I’m happy to hear some feedback.

1 Like