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.

AM4376: Enable I2C2 in SPL

Part Number: AM4376

As customer board also mount a EEPROM on board, but it is connected on I2C2. so need to modify SPL to enable it.

I add I2C2 pinmux in board/ti/am437x/board.c

void gpi2c_init(void)
{
/* When needed to be invoked prior to BSS initialization */
static bool first_time = true;

if (first_time) {
enable_i2c0_pin_mux();
enable_i2c2_pin_mux();
#ifndef CONFIG_DM_I2C
i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED,
CONFIG_SYS_OMAP24_I2C_SLAVE);
#endif
first_time = false;
}
}

and add I2C clock in arch/arm/mach-omap2/am33xx/clock_am43xx.c

u32 *const clk_modules_explicit_en[] = {
&cmper->l3clkctrl,
&cmper->l4lsclkctrl,
&cmper->l4fwclkctrl,
&cmwkup->wkl4wkclkctrl,
&cmper->l3instrclkctrl,
&cmper->l4hsclkctrl,
&cmwkup->wkgpio0clkctrl,
&cmwkup->wkctrlclkctrl,
&cmper->timer2clkctrl,
&cmper->gpmcclkctrl,
&cmper->elmclkctrl,
&cmper->mmc0clkctrl,
&cmper->mmc1clkctrl,
&cmwkup->wkup_i2c0ctrl,
&cmper->gpio1clkctrl,
&cmper->gpio2clkctrl,
&cmper->gpio3clkctrl,
&cmper->gpio4clkctrl,
&cmper->gpio5clkctrl,
&cmper->i2c1clkctrl,
&cmper->i2c2clkctrl, /* add to support I2C2*/
&cmper->cpgmac0clkctrl,
&cmper->emiffwclkctrl,
&cmper->emifclkctrl,
&cmper->otfaemifclkctrl,
&cmper->qspiclkctrl,
&cmper->spi0clkctrl,
0
};

but in board/ti/am43xx/board.c, need to change CONFIG_EEPROM_BUS_ADDRESS definition in Autoconf.h which is autogenerated. 

#ifdef CONFIG_TI_I2C_BOARD_DETECT
void do_board_detect(void)
{
/* Ensure I2C is initialized for EEPROM access*/
gpi2c_init();
 if (ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
CONFIG_EEPROM_CHIP_ADDRESS))

printf("ti_i2c_eeprom_init failed\n");
}

Where to change the auto defined macro? I don't know where it is pre-defined.

And any other modification to enable I2C2 in SPL?

  • Hi Tony,
    1. CONFIG_EEPROM_BUS_ADDRESS, and CONFIG_EEPROM_CHIP_ADDRESS are configured via "/board/ti/common/Kconfig" as listed below:

    config EEPROM_BUS_ADDRESS
    	int "Board EEPROM's I2C bus address"
    	range 0 8
    	default 0
    
    config EEPROM_CHIP_ADDRESS
    	hex "Board EEPROM's I2C chip address"
    	range 0 0xff
    	default 0x50

    2. Additionally, in newer SDK releases, Driver Model (DM) is used for i2c ports in SPL/u-boot.
    When i2c port is connected to EEPORM for board detection, the i2c node needs to be in SPL FDT blob.
    One quick check is running "dtc -I dtb spl/u-boot-spl.dtb"

    Note that <u-boot-spl.dtb> is generated from <u-boot.dtb> with specific spl node property like <u-boot,dm-spl>, <u-boot,dm-pre-reloc>...
    For example, &i2c0 node is defined in <am437x-gp-evm-u-boot.dtsi> which is, along with <am437x-gp-evm.dts>, implicitly compiled
    into <am437x-gp-evm.dtb> file.

    &i2c0 {
    	u-boot,dm-spl;
    };

    Best,

    -Hong