LTC1760 (smbus) connected to i2c on i.mx8mm not found (kernel 6.1, custom board)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LTC1760 (smbus) connected to i2c on i.mx8mm not found (kernel 6.1, custom board)

Jump to solution
930 Views
DaxTailor
Contributor II

Hello,

I'm trying to connect a LTC1760 battery manager chip via the i2c3 to an imx8mm. The i2c3 is configured like the i2c2 and devices on them working fine.

The difference is, the LTC1760 has an SMBus. The question is, do I have to add additional configuration to the i2c3? There is no other device on the i2c3.

We checked the signals (SCL and SLA) with an oscilloscope and there are clock and data signals from time to time. The signals are in the range of the smbus specification.

i2cdetect -r 2 0x0a 0x0a

Shows that there is a device on 0x0a but that is not stable. When I repeat that command then the 0x0a cell shows 0x0a or -- in an random order.

Using i2cdetect without the range gives a lot if found devices but there are all random. Doing that also results in a message: "i2c i2c-2: SCL is stuck low, exit recovery".

Could be that i2cdetect confuses the bus.

Disconnecting the LTC1760 from the i2c bus, i2cdetect shows an empty bus without errors.

In the device tree I added this to the i2c3:

...
batman: battery-manager@0a {
        compatible = "lltc,ltc1760", "sbs,sbs-manager";
        reg = <0x0a>;
...

But the module is not loaded automatic like the modules for other i2c devices do.

Hope someone can help or point me to something I can check.

Thanks

Labels (2)
0 Kudos
Reply
1 Solution
856 Views
DaxTailor
Contributor II

It looks like we found a solution by using the i2c-gpio bit bang driver. Here the dts part:

&i2c3 {
    status = "disabled";
};

&{/}{
    i2c@3 {
        compatible = "i2c-gpio";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c3_gpio_x>;
        sda-gpios = <&gpio5 19 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
        scl-gpios = <&gpio5 18 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
	    i2c-gpio,delay-us = <50>;	/* ~10 kHz */
	    #address-cells = <1>;
	    #size-cells = <0>;
        status = "okay";

        batman: battery-manager@0a {
            compatible = "lltc,ltc1760", "sbs,sbs-manager";
            reg = <0x0a>;
            #address-cells = <1>;
            #size-cells = <0>;
            gpio-controller;
            #gpio-cells = <2>;
            status = "okay";

            i2c@1 {
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <1>;
                battery@b {
                    compatible = "ti,bq20z65", "sbs,sbs-battery";
                    reg = <0x0b>;
                    sbs,battery-detect-gpios = <&batman 1 1>;
                };
            };
            
            i2c@2 {
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <2>;
                battery@b {
                    compatible = "ti,bq20z65", "sbs,sbs-battery";
                    reg = <0x0b>;
                    sbs,battery-detect-gpios = <&batman 2 1>;
                };
            };
        };
    };
};

The iomuc was not changed. To get the driver running, the linux kernel got this configuration:

CONFIG_POWER_SUPPLY=y
CONFIG_POWER_SUPPLY_DEBUG=y
CONFIG_MANAGER_SBS=m
CONFIG_CHARGER_MANAGER=m
CONFIG_CHARGER_SBS=m
CONFIG_CHARGER_BQ2415X=m
CONFIG_BATTERY_SBS=m
CONFIG_BATTERY_BQ27XXX=m
CONFIG_BATTERY_MAX17040=m
CONFIG_BATTERY_MAX17042=m
CONFIG_PMBUS=n
CONFIG_I2C=y
CONFIG_I2C_MUX=m
CONFIG_I2C_SMBUS=m

Now i2cdetect will find this:

i2cdetect -l
i2c-0   i2c             30a20000.i2c                            I2C adapter
i2c-1   i2c             30a30000.i2c                            I2C adapter
i2c-4   i2c             i2c@3                                   I2C adapter
i2c-5   i2c             i2c-4-mux (chan_id 1)                   I2C adapter
i2c-6   i2c             i2c-4-mux (chan_id 2)                   I2C adapter

I think we can work with that. The i2c clock frequency is low with 10kHz but that should be a problem to as a battery for its status.

But still, the question is why does the nxp i2c driver does not work. And why is there no documentation about that?

View solution in original post

0 Kudos
Reply
3 Replies
906 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

Did you build the dtb and kernel?

Regards

0 Kudos
Reply
870 Views
DaxTailor
Contributor II

Hello,

> Did you build the dtb and kernel?

I'm not sure what do you mean. After every change I'm calling bitbake <image-name> and copy the dtb files to the boot partition. That has worked well for over a month now.

But I have some news.

We disconnected the LTC1760 from the i2c3 and connected an other i2c device. This one can be found by i2cdetect with no problems. I think the problem is not the i2c bus of the i.mx8mm but the i2c bus in combination with the LTC1760 which is an smbus device.
Measurements shows the the LTC1760 try to send some data over the i2c bus by it self, without a request from the CPU.

So the question is still open, how do I configure the i2c3 bus of the i.mx8mm so it can be used as an smbus master?

Thanks.

0 Kudos
Reply
857 Views
DaxTailor
Contributor II

It looks like we found a solution by using the i2c-gpio bit bang driver. Here the dts part:

&i2c3 {
    status = "disabled";
};

&{/}{
    i2c@3 {
        compatible = "i2c-gpio";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c3_gpio_x>;
        sda-gpios = <&gpio5 19 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
        scl-gpios = <&gpio5 18 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
	    i2c-gpio,delay-us = <50>;	/* ~10 kHz */
	    #address-cells = <1>;
	    #size-cells = <0>;
        status = "okay";

        batman: battery-manager@0a {
            compatible = "lltc,ltc1760", "sbs,sbs-manager";
            reg = <0x0a>;
            #address-cells = <1>;
            #size-cells = <0>;
            gpio-controller;
            #gpio-cells = <2>;
            status = "okay";

            i2c@1 {
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <1>;
                battery@b {
                    compatible = "ti,bq20z65", "sbs,sbs-battery";
                    reg = <0x0b>;
                    sbs,battery-detect-gpios = <&batman 1 1>;
                };
            };
            
            i2c@2 {
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <2>;
                battery@b {
                    compatible = "ti,bq20z65", "sbs,sbs-battery";
                    reg = <0x0b>;
                    sbs,battery-detect-gpios = <&batman 2 1>;
                };
            };
        };
    };
};

The iomuc was not changed. To get the driver running, the linux kernel got this configuration:

CONFIG_POWER_SUPPLY=y
CONFIG_POWER_SUPPLY_DEBUG=y
CONFIG_MANAGER_SBS=m
CONFIG_CHARGER_MANAGER=m
CONFIG_CHARGER_SBS=m
CONFIG_CHARGER_BQ2415X=m
CONFIG_BATTERY_SBS=m
CONFIG_BATTERY_BQ27XXX=m
CONFIG_BATTERY_MAX17040=m
CONFIG_BATTERY_MAX17042=m
CONFIG_PMBUS=n
CONFIG_I2C=y
CONFIG_I2C_MUX=m
CONFIG_I2C_SMBUS=m

Now i2cdetect will find this:

i2cdetect -l
i2c-0   i2c             30a20000.i2c                            I2C adapter
i2c-1   i2c             30a30000.i2c                            I2C adapter
i2c-4   i2c             i2c@3                                   I2C adapter
i2c-5   i2c             i2c-4-mux (chan_id 1)                   I2C adapter
i2c-6   i2c             i2c-4-mux (chan_id 2)                   I2C adapter

I think we can work with that. The i2c clock frequency is low with 10kHz but that should be a problem to as a battery for its status.

But still, the question is why does the nxp i2c driver does not work. And why is there no documentation about that?

0 Kudos
Reply