Issue with PCA9685, ADS1115

Hey,
I have modified BONE-I2C2.dts file to add support for PCA9685, MCP23017 and ADS1115. MCP23017 works, I’m able to toggle GPIOs with libgpiod. So no issues with this.

PCA9685 is getting detected as pwmchip0 but I’m not getting any output when I run the following commands:

echo 0 > /sys/class/pwm/pwmchip0/export
echo 1000000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 500000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

Something strange I observed is npwm is 17. Shouldn’t it be 16?

ADS1115 is also getting detected by the iio drivers but in_voltageX_raw is -1. I’m getting -1 for all channels on all ICs.

This is my overlay:

/dts-v1/;
/plugin/;

/ {
    compatible = "beagle,j721e-beagleboneai64", "ti,j721e";

    fragment@0 {
        target = <&bone_i2c_2>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;
            status = "okay";
            clock-frequency = <100000>;
            symlink = "bone/i2c/2";

            /* ADS1115 - 0x48 */
            adc@48 {
                compatible = "ti,ads1115";
                reg = <0x48>;
                #address-cells = <1>;
                #size-cells = <0>;

                channel@4 {
                    reg = <4>; /* AIN0-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@5 {
                    reg = <5>; /* AIN1-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@6 {
                    reg = <6>; /* AIN2-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@7 {
                    reg = <7>; /* AIN3-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };
            };

            /* ADS1115 - 0x49 */
            adc@49 {
                compatible = "ti,ads1115";
                reg = <0x49>;
                #address-cells = <1>;
                #size-cells = <0>;

                channel@4 {
                    reg = <4>; /* AIN0-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@5 {
                    reg = <5>; /* AIN1-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@6 {
                    reg = <6>; /* AIN2-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@7 {
                    reg = <7>; /* AIN3-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };
            };

            /* ADS1115 - 0x4A */
            adc@4A {
                compatible = "ti,ads1115";
                reg = <0x4A>;
                #address-cells = <1>;
                #size-cells = <0>;

                channel@4 {
                    reg = <4>; /* AIN0-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@5 {
                    reg = <5>; /* AIN1-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@6 {
                    reg = <6>; /* AIN2-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@7 {
                    reg = <7>; /* AIN3-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };
            };

            /* ADS1115 - 0x4B */
            adc@4B {
                compatible = "ti,ads1115";
                reg = <0x4B>;
                #address-cells = <1>;
                #size-cells = <0>;

                channel@4 {
                    reg = <4>; /* AIN0-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@5 {
                    reg = <5>; /* AIN1-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@6 {
                    reg = <6>; /* AIN2-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };

                channel@7 {
                    reg = <7>; /* AIN3-GND */
                    ti,gain = <2>;
                    ti,datarate = <4>;
                };
            };

            /* MCP23017 - 0x20 */
            gpio@20 {
                compatible = "microchip,mcp23017";
                reg = <0x20>;
                gpio-controller;
                #gpio-cells = <2>;
            };

            /* MCP23017 - 0x21 */
            gpio@21 {
                compatible = "microchip,mcp23017";
                reg = <0x21>;
                gpio-controller;
                #gpio-cells = <2>;
            };

            /* PCA9685 - 0x40 */
            pca@40 {
                compatible = "nxp,pca9685-pwm";
                #pwm-cells = <2>;
                reg = <0x40>;
                open-drain;
            };
        };
    };
};

All these worked when I used python and smbus2 but pwm and adc are not working when kernel drivers are used. dmesg isn’t throwing any errors. Can’t figure out what else can be done as there are no errors thrown anywhere.

I’m using 6.12.17-ti-arm64-r30 kernel and Debian 12.

Thanks

Okay, so ADS1115 is working. So it returns -1 if the pin is floating. When the pin is connected to analog source it’ll return a value.
Still trying to figure out how to get PCA9685 working. The overlay loads fine, the folders are created, I can write to file to set freq and duty cycle without errors but no output.
lsmod does not return anything related to pwm or pca9685 for some reason even tho the driver is present in the /sys/bus/i2c/drivers directory.

1 Like

PCA9685 is also working, turns out the issue was in the devicetree. I shouldn’t have added invert in the overlay. Could have solved this a lot faster if I had just connected the outputs to a scope
For some reason PCA9685’s driver module doesn’t show up on lsmod, so I thought something else was wrong

1 Like