Closed butonic closed 1 month ago
The live devicetree knows about i2c_ao:
$ sudo ldto current | grep i2c_
i2c_ao_sck_pins {
groups = "i2c_ao_sck";
function = "i2c_ao";
i2c_ao_sda {
groups = "i2c_ao_sda";
function = "i2c_ao";
i2c_ao_sck_e {
groups = "i2c_ao_sck_e";
function = "i2c_ao";
i2c_ao_sda_e {
groups = "i2c_ao_sda_e";
function = "i2c_ao";
i2c_ao_sck_pins = "/soc/bus@ff800000/sys-ctrl@0/pinctrl/i2c_ao_sck_pins";
i2c_ao_sda_pins = "/soc/bus@ff800000/sys-ctrl@0/pinctrl/i2c_ao_sda";
i2c_ao_sck_e_pins = "/soc/bus@ff800000/sys-ctrl@0/pinctrl/i2c_ao_sck_e";
i2c_ao_sda_e_pins = "/soc/bus@ff800000/sys-ctrl@0/pinctrl/i2c_ao_sda_e";
i2c_AO = "/soc/bus@ff800000/i2c@5000";
Just nothing about i2c_b 🤔
Ok, I found these disabled i2c in the live device tree:
bus@ffd00000 {
...
i2c@1c000 {
compatible = "amlogic,meson-axg-i2c";
status = "disabled";
reg = <0x00 0x1c000 0x00 0x20>;
interrupts = <0x00 0x27 0x01>;
#address-cells = <0x01>;
#size-cells = <0x00>;
clocks = <0x02 0x18>;
phandle = <0x132>;
};
i2c@1d000 {
compatible = "amlogic,meson-axg-i2c";
status = "disabled";
reg = <0x00 0x1d000 0x00 0x20>;
interrupts = <0x00 0xd7 0x01>;
#address-cells = <0x01>;
#size-cells = <0x00>;
clocks = <0x02 0x18>;
phandle = <0x133>;
};
i2c@1e000 {
compatible = "amlogic,meson-axg-i2c";
status = "disabled";
reg = <0x00 0x1e000 0x00 0x20>;
interrupts = <0x00 0xd6 0x01>;
#address-cells = <0x01>;
#size-cells = <0x00>;
clocks = <0x02 0x18>;
phandle = <0x134>;
};
i2c@1f000 {
compatible = "amlogic,meson-axg-i2c";
status = "disabled";
reg = <0x00 0x1f000 0x00 0x20>;
interrupts = <0x00 0x15 0x01>;
#address-cells = <0x01>;
#size-cells = <0x00>;
clocks = <0x02 0x18>;
phandle = <0x135>;
};
Ok, just enabling the i2cx with sth like (using &i2c[0-3]
):
/dts-v1/;
/plugin/;
/ {
compatible = "amlogic,aml-a311d-cc";
fragment@0 {
target = <&i2c0>;
__overlay__ {
status = "okay";
};
};
};
will enable it, but dmesg says:
[373535.609370] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/bus@ffd00000/i2c@1f000/status
[373535.609391] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/bus@ffd00000/i2c@1e000/status
[373723.586206] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/bus@ffd00000/i2c@1d000/status
[373725.826336] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/bus@ffd00000/i2c@1c000/status
I now get 5 i2c devices:
$ i2cdetect -l
i2c-3 i2c Meson I2C adapter I2C adapter
i2c-1 i2c Meson I2C adapter I2C adapter
i2c-4 i2c Meson I2C adapter I2C adapter
i2c-2 i2c Meson I2C adapter I2C adapter
i2c-0 i2c DesignWare HDMI I2C adapter
But none of them show the device pitop[3] hub I expect to see.
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: -- -- -- -- -- -- -- --
🤔 digging further
IT seems i2c_AO is disabled by default as well ... enabling it will create another Meson I2C adapter
in the i2cdetect -l
. But it does not find any i2c devices. merging and rebooting does create the /dev/i2c-x devices ... but still no pitop[3] hub ...
I tried faking an i2c by trying to create an item with target-path
:
/dts-v1/;
/plugin/;
/ {
compatible = "amlogic,aml-a311d-cc";
fragment@0 {
target-path = "/aliases";
__overlay__ {
i2c0 = "/soc/bus@ff800000/i2c@5100";
};
};
fragment@1 {
target-path = "/soc/bus@ff800000/i2c@5100";
__overlay__ {
pinctrl-0 = <0x96 0x97>;
pinctrl-names = "default";
status = "okay";
};
};
};
but it cannot find "/soc/bus@ff800000/i2c@5100"
.
🤔 Is it even possible to create a new entry on /soc/bus@ff800000
?
from the A311D datasheet, Section 8.1 Memory Map I can see that the memory range FFD1D000 is mapped to EE_I2C_M2, which matches the schematics.
Furthermore Table 3-7. GPIOX_x Multi-Function Pi also shows that GPIOX_17 and GPIOX_18 are mapped to I2C_EE_M2_SDA and I2C_EE_M2_SCL.
The live device tree shows
So in theory enabling i2c2 should just work
/dts-v1/;
/plugin/;
/ {
compatible = "amlogic,aml-a311d-cc";
fragment@0 {
target = <&i2c2>;
__overlay__ {
status = "okay";
};
};
};
Hm, aligning it more with the i2s_b.dts from the other board I still see no i2c client:
/dts-v1/;
/plugin/;
#include <dt-bindings/gpio/gpio.h>
/ {
compatible = "amlogic,aml-a311d-cc";
fragment@0 {
target = <&i2c2>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&i2c2_pins>;
__overlay__ {
cfg {
pins = "GPIOX_17", "GPIOX_18";
bias-pull-up;
};
};
};
fragment@2 {
target = <&i2c2>;
__overlay__ {
status = "okay";
pinctrl-0 = <&i2c2_pins>;
pinctrl-names = "default";
};
};
};
That i2c2_pins
exists was just a guess, but I still doubt this is the correct way to enable the I2C bus.
Hello @butonic , I'm also interested in enabling i2c to connect a PWM Servo board. I am not experienced with device-tree development or electronics, but will be happy to help testing on my end, if you tell me how
How do I enable the i2c on the Alta board?
IT seems i2c_AO is disabled by default as well ... enabling it will create another
Meson I2C adapter
in thei2cdetect -l
. But it does not find any i2c devices. merging and rebooting does create the /dev/i2c-x devices ... but still no pitop[3] hub ...
Ho did you enable i2c_AO?
it's i2c2 for "Pin 27 (SDA), 28 (SCL)", so, take a look at this to see if it works for you? https://github.com/libre-computer-project/libretech-wiring-tool/commit/771185a26d81feb870d3cd04daa4402ba93efc74
For future reference, the device tree in text format can be found here: https://boot.libre.computer/ci/aml-a311d-cc.dts
You have to match the I2C node from the GPIO map or schematic to the I2C node in the device tree and enable it. By default, the GPIOs are in GPIO mode and not I2C mode.
I'm new to dts and overlays. I tried an uneducated guess to enable i2c on the aml-a311d-cc. But I get this dmesg, when trying to enable it with
sudo ldto enable i2c-b
:so ... I'll keep dabbling, but any pointers are welcome. I guess I need to read up more on how to write dts. I only got them to compile. But the Makefile does all the necessary things, so kudos to libre.computer for that!
Links