This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: Use alternate pins for I2C

Part Number: AM5728

Tool/software: Linux

HI, I'm trying to swap which pins are used for I2C4, starting from the config of the AM5728-EVM.  I want to make I2C4 appear on pins R6 and T9.  I have changed mux_data.h, hopefully correctly, and rebuilt u-boot.  Unfortunately, when I hook up the scope to the relevant pins and try an I2C transfer, nothing happens, i.e. there are no transitions on the pins.

Reading through some of the other threads, I get the idea that setting the pins in u-boot isn't enough, and that I need to do something in the device tree as well - maybe some form of construct involving DRA7XX_CORE_IOPAD?

Please could you let me know firstly if I need to adjust the mux mode in the DTS as well as u-boot, and give me some help on what I need to do?

Best regards,

Bob.

  • Hi Bob,

    Pins R6/T9 pinmux is done only in u-boot-spl at below file and structure:

    u-boot-2018.01/board/ti/am57xx/mux_data.h, core_padconf_array_essential_x15[]

    When you make the relevant changes in this mux_data.h file, you can check if your update is successful:

    1. interrupt the boot process in u-boot prompt and check what value you have in the pinmux registers at Control Module. You can do that with the u-boot md command. Check registers CTRL_CORE_PAD_GPMC_A0/0x4A003440 and CTRL_CORE_PAD_GPMC_A1/0x4A003444

    2. in user space, you can check these two registers with devmem2 tool or omapconf tool

    You need also enable I2C4 module in DTS file.

    Regards,
    Pavel
  • Hi Pavel,

    Thanks for your response.  In particular thanks for the tips on how to check the pinmux registers, which I was wondering how to do.

    I now have it running, but I needed to add something in to the relevant device tree file, i.e.

    &dra7_pmx_core {
        i2c4_alt_pins: i2c4_alt_pins {
            pinctrl-single,pins = <
                DRA7XX_CORE_IOPAD(0x3440, PIN_INPUT_PULLUP | MUX_MODE7) /* gpmc_a0.i2c4_scl */
                DRA7XX_CORE_IOPAD(0x3444, PIN_INPUT_PULLUP | MUX_MODE7) /* gpmc_a1.i2c4_sda */
            >;
        };
    };

    &i2c4 {
        clock-frequency = <400000>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&i2c4_alt_pins>;
    };

    Note that the device tree file needs to #include "dra74x.dtsi", to pick up the DRA7XX_CORE_IOPAD macro.  As a minor note, I got the addresses from the Sitara TRM.

    I must admit that I don't understand why this addition to the device tree is needed, in addition to setting the pinmuxes in u-boot.  So it may be that I'm not doing all of this correctly, and I'm interested in views on whether this is the correct approach or not. However it seems to work!

    Best regards,

    Bob.

  • Bob,

    You need to remove pinctrl-x/i2c4_alt_pins pinmux from your DTS. Pinmux of I2C should be done only in mux_data.h file and should be enough. This is due to AM57x errata i869: IO Glitches Can Occur When Changing IO Settings. See below e2e thread:

    e2e.ti.com/.../661048

    Regarding I2C4 module, your u-boot and kernel DTS files should look like:

    &i2c4 {
    clock-frequency = <400000>;
    status = "okay";
    }

    You can refer to below u-boot and kernel DTS files for examples of I2C module usage. Note that we have no I2C pinmux done in these DTS files.

    u-boot/arch/arm/dts/am57xx-beagle-x15-common.dtsi
    u-boot/arch/arm/dts/am57xx-idk-common.dtsi

    linux-kernel/arch/arm/boot/dts/ti/am57xx-evm-common.dtso
    linux-kernel/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi
    linux-kernel/arch/arm/boot/dts/am57xx-idk-common.dtsi

    Regards,
    Pavel
  • Hi Pavel,

    Firstly, thanks again for your support on this issue.

    I've used MD from u-boot to look at CTRL_CORE_PAD_GPMC_A0 and _A1 - see below:

    4a003440: 00040102 00040102 00040102 00040102    ................

    I interpret this as the pinmux being set to 2 rather than 7, so the problem is in my u-boot.  I have built the u-boot by changing mux_data.h to include the following in core_padconf_array_essential_x15[]:

    {GPMC_A0, (M7 | PIN_INPUT_PULLUP)}, /* gpmc_a0.i2c4_scl */
    {GPMC_A1, (M7 | PIN_INPUT_PULLUP)}, /* gpmc_a1.i2c4_sda */

    I have removed the original GPMC_A0 and GPMC_M1 entries.

    Any thoughts on what I'm doing wrong?

    Best regards,

    Bob

  • Hi Pavel,

    Do I have to update MLO as well as u-boot.img?

    Best regards,
    Bob.
  • Bob,

    Yes, MLO update is needed. mux_data.h belongs to MLO/u-boot-spl.

    Regards,
    Pavel
  • If you have no more questions related to the subject of this e2e thread, please close/verify/resolve this thread.

    Regards,
    Pavel
  • Hi Pavel,

    Yes, this has fixed my issue for me.  Thanks again for your help.

    Cheers Bob.