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.

AM4372: access i2c2 from u-boot

Part Number: AM4372
Other Parts Discussed in Thread: TPS65218

Hi,

I am trying to access the third I2C bus of an AM4372-based design within u-boot. The issue however is not specific to our custom-board, I am having the same problem with the EVM.

The bus is working fine from Linux. The pinmux settings are the same for for both, Linux and u-boot:

i2c2_pins: i2c2_pins {
		pinctrl-single,pins = <
			0x9e8 (PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE3)
			0x9ec (PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE3)
		>;
	};
	
	
&i2c2 {
	u-boot,dm-spl;
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2c2_pins>;
	clock-frequency = <100000>;

	tps65218: tps65218@24 {
		reg = <0x24>;
		compatible = "ti,tps65218";
		interrupts = <GIC_SPI 7 IRQ_TYPE_NONE>;
		interrupt-controller;
		#interrupt-cells = <2>;

		dcdc1: regulator-dcdc1 {
			compatible = "ti,tps65218-dcdc1";
			regulator-name = "vdd_core";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <1144000>;
			regulator-boot-on;
			regulator-always-on;
		};

		dcdc2: regulator-dcdc2 {
			compatible = "ti,tps65218-dcdc2";
			regulator-name = "vdd_mpu";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <1378000>;
			regulator-boot-on;
			regulator-always-on;
		};

		dcdc3: regulator-dcdc3 {
			compatible = "ti,tps65218-dcdc3";
			regulator-name = "vdcdc3";
			regulator-min-microvolt = <1350000>;
			regulator-max-microvolt = <1350000>;
			regulator-boot-on;
			regulator-always-on;
		};

		dcdc4: regulator-dcdc4 {
			compatible = "ti,tps65218-dcdc4";
			regulator-name = "vdcdc4";
			regulator-min-microvolt = <3300000>;                  
			regulator-max-microvolt = <3300000>;                  
			regulator-boot-on;
			regulator-always-on;
		};
		
		dcdc5: regulator-dcdc5 {
			compatible = "ti,tps65218-dcdc5";
			regulator-name = "v1_0bat";
			regulator-min-microvolt = <1000000>;
			regulator-max-microvolt = <1000000>;
			regulator-boot-on;
			regulator-always-on;
		};

		dcdc6: regulator-dcdc6 {
			compatible = "ti,tps65218-dcdc6";
			regulator-name = "v1_8bat";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-boot-on;
			regulator-always-on;
		};

		ldo1: regulator-ldo1 {
			compatible = "ti,tps65218-ldo1";
			regulator-min-microvolt = <2100000>;
			regulator-max-microvolt = <2100000>;
			regulator-boot-on;
			regulator-always-on;
		};
	};
};

And in mux.c:

static struct module_pin_mux i2c2_pin_mux[] = {
	{OFFSET(cam1_data0), (MODE(3) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
	{OFFSET(cam1_data1), (MODE(3) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
	{-1},
};

I have been trying with both, I2C_DM and plain access using the respective init functions, however the problem is always the same: trying to access the bus - for example using "i2c dev 2" in the u-boot prompt, will cause a reboot:

=> i2c bus
Bus 2:  i2c@4819c000
=> i2c dev
No I2C bus selected
Current bus is -1
=> i2c dev 2
Setting bus to 2
data abort
pc : [<9ff70682>]          lr : [<9ff70657>]
reloc pc : [<80820682>]    lr : [<80820657>]
sp : 9df32c08  ip : 9df32bdc     fp : 000003e8
r10: 9df41500  r9 : 9df3feb8     r8 : 9df415a8
r7 : 00000002  r6 : 00000001     r5 : 9ffab869  r4 : 4819c000
r3 : 000000a4  r2 : 0000b2b0     r1 : 00005578  r0 : 9df40468
Flags: nzCv  IRQs off  FIQs off  Mode SVC_32
Code: 2e002702 461dbf18 7b7af44f 6004f8c8 (5ae37a6b)
Resetting CPU ...

I have followed the various tweaks from the E2E articles like checking if I2C_BASE3 is defined. changing default base as define, (in case of no DM) put the right bus number in the init command, ... Nothing works.

Did anyone ever succeed in accessing I2C2 of AM437x via u-boot and if yes, how? I am really running out of ideas. As it is working perfectly fine in Linux, we can exclude any hardware or pinmux issues.

This is the output of u-boot (with driver debug enabled):

<debug_uart> spl_early_init
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'root_driver'
   - not found
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
board_early_init_f
prcm_init
i2c2_pin_mux
power_tps65218_init
i2c_get_chip_for_busnum startuclass_find_device_by_seq: 0 0
   - 2 -1 'i2c@4819c000'
   - not found
uclass_find_device_by_seq: 1 0
   - 2 -1 'i2c@4819c000'
   - not found
Cannot find I2C bus 0
power_tps65218_init: -19
set_mux_conf_regs
TPS reg: 1A  value: 0 err: -19
TPS reg: 16  value: 0 err: -19
TPS reg: 17  value: 0 err: -19
TPS reg: 18  value: 0 err: -19
TPS reg: 19  value: 0 err: -19
TPS reg: 13  value: 0 err: -19
TPS reg: 1B  value: 0 err: -19
TPS reg: 22  value: 0 err: -19
TPS reg: 13  value: 0 err: -19
TPS reg: 24  value: 0 err: -19
TPS reg: 25  value: 0 err: -19
TPS reg: 26  value: 0 err: -19
mmc0_pin_mux
mmc1_pin_mux
enable_board_pin_mux end
sdram_init
reg: 61a05332
get_ram_size
ram size: 536870912
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'ocp'
   - -1 -1 'l4_wkup@44c00000'
   - -1 -1 'scm@210000'
   - -1 -1 'ocp2scp@483a8000'
   - not found
uclass_find_device_by_seq: 0 4
   - 4 -1 'serial@481a8000'
   - not found
ofnode_read_u32: reg-offset: (not found)
ofnode_read_u32: clock-frequency: (not found)

U-Boot SPL 2019.01-g11ba6979b2-dirty (Jan 04 2022 - 19:43:07 +0100)
Trying to boot from MMC1
uclass_find_device_by_seq: 0 0
   - -1 -1 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
uclass_find_device_by_seq: 1 0
   - -1 -1 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
ofnode_read_u32: bus-width: 0x4 (4)
ofnode_read_u32: max-frequency: (not found)
ofnode_read_bool: cap-sd-highspeed: false
ofnode_read_bool: cap-mmc-highspeed: false
ofnode_read_bool: sd-uhs-sdr12: false
ofnode_read_bool: sd-uhs-sdr25: false
ofnode_read_bool: sd-uhs-sdr50: false
ofnode_read_bool: sd-uhs-sdr104: false
ofnode_read_bool: sd-uhs-ddr50: false
ofnode_read_bool: mmc-ddr-1_8v: false
ofnode_read_bool: mmc-ddr-1_2v: false
ofnode_read_bool: mmc-hs200-1_8v: false
ofnode_read_bool: mmc-hs200-1_2v: false
ofnode_read_bool: mmc-hs400-1_8v: false
ofnode_read_bool: mmc-hs400-1_2v: false
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 0 'mmc@48060000'
   - found
uclass_find_device_by_seq: 0 1
   - -1 0 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
ofnode_read_u32: bus-width: 0x8 (8)
ofnode_read_u32: max-frequency: (not found)
ofnode_read_bool: cap-sd-highspeed: false
ofnode_read_bool: cap-mmc-highspeed: false
ofnode_read_bool: sd-uhs-sdr12: false
ofnode_read_bool: sd-uhs-sdr25: false
ofnode_read_bool: sd-uhs-sdr50: false
ofnode_read_bool: sd-uhs-sdr104: false
ofnode_read_bool: sd-uhs-ddr50: false
ofnode_read_bool: mmc-ddr-1_8v: false
ofnode_read_bool: mmc-ddr-1_2v: false
ofnode_read_bool: mmc-hs200-1_8v: false
ofnode_read_bool: mmc-hs200-1_2v: false
ofnode_read_bool: mmc-hs400-1_8v: false
ofnode_read_bool: mmc-hs400-1_2v: false
SPL: Please implement spl_start_uboot() for your board
SPL: Direct Linux boot not active!
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'root_driver'
   - not found
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_u32_array: ranges: ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: true
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
ofnode_read_bool: u-boot,dm-pre-reloc: false
ofnode_read_bool: u-boot,dm-spl: false
ofnode_read_bool: u-boot,dm-tpl: false
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'ocp'
   - -1 -1 'l4_wkup@44c00000'
   - -1 -1 'scm@210000'
   - -1 -1 'ocp2scp@483a8000'
   - not found
uclass_find_device_by_seq: 0 4
   - 4 -1 'serial@481a8000'
   - not found
ofnode_read_u32: reg-offset: (not found)
ofnode_read_u32: clock-frequency: (not found)


U-Boot 2019.01-g11ba6979b2-dirty (Jan 04 2022 - 19:43:07 +0100)

CPU  : AM437X-GP rev 1.2
Model: SMaBiT SMaWay
DRAM:  512 MiB
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'root_driver'
   - not found
ofnode_read_u32_array: ranges: ofnode_read_u32_array: ranges: ofnode_read_u32_array: ranges: ofnode_read_u32_array: ranges: ofnode_read_u32_array: ranges: uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'ocp'
   - -1 -1 'l4_wkup@44c00000'
   - -1 -1 'scm@210000'
   - -1 -1 'ocp2scp@483a8000'
   - -1 -1 'ocp2scp@483e8000'
   - not found
uclass_find_device_by_seq: 0 4
   - 4 -1 'serial@481a8000'
   - not found
ofnode_read_u32: reg-offset: (not found)
ofnode_read_u32: clock-frequency: (not found)
i2c_get_chip_for_busnum startuclass_find_device_by_seq: 0 0
   - 1 -1 'i2c@4802a000'
   - 2 -1 'i2c@4819c000'
   - not found
uclass_find_device_by_seq: 1 0
   - 1 -1 'i2c@4802a000'
   - 2 -1 'i2c@4819c000'
   - not found
Cannot find I2C bus 0
power_tps65218_init: -19
NAND:  ofnode_read_string: tick-timer: /ocp/timer@48040000
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'timer@48040000'
   - not found
ofnode_read_u32: clock-frequency: (not found)
0 MiB
MMC:   uclass_find_device_by_seq: 0 0
   - -1 -1 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
uclass_find_device_by_seq: 1 0
   - -1 -1 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
ofnode_read_u32: bus-width: 0x4 (4)
ofnode_read_u32: max-frequency: (not found)
ofnode_read_bool: cap-sd-highspeed: false
ofnode_read_bool: cap-mmc-highspeed: false
ofnode_read_bool: sd-uhs-sdr12: false
ofnode_read_bool: sd-uhs-sdr25: false
ofnode_read_bool: sd-uhs-sdr50: false
ofnode_read_bool: sd-uhs-sdr104: false
ofnode_read_bool: sd-uhs-ddr50: false
ofnode_read_bool: mmc-ddr-1_8v: false
ofnode_read_bool: mmc-ddr-1_2v: false
ofnode_read_bool: mmc-hs200-1_8v: false
ofnode_read_bool: mmc-hs200-1_2v: false
ofnode_read_bool: mmc-hs400-1_8v: false
ofnode_read_bool: mmc-hs400-1_2v: false
uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 0 'mmc@48060000'
   - found
uclass_find_device_by_seq: 0 1
   - -1 0 'mmc@48060000'
   - -1 -1 'mmc@481d8000'
   - not found
ofnode_read_u32: bus-width: 0x8 (8)
ofnode_read_u32: max-frequency: (not found)
ofnode_read_bool: cap-sd-highspeed: false
ofnode_read_bool: cap-mmc-highspeed: false
ofnode_read_bool: sd-uhs-sdr12: false
ofnode_read_bool: sd-uhs-sdr25: false
ofnode_read_bool: sd-uhs-sdr50: false
ofnode_read_bool: sd-uhs-sdr104: false
ofnode_read_bool: sd-uhs-ddr50: false
ofnode_read_bool: mmc-ddr-1_8v: false
ofnode_read_bool: mmc-ddr-1_2v: false
ofnode_read_bool: mmc-hs200-1_8v: false
ofnode_read_bool: mmc-hs200-1_2v: false
ofnode_read_bool: mmc-hs400-1_8v: false
ofnode_read_bool: mmc-hs400-1_2v: false
OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'mmc@48060000.blk'
   - -1 -1 'mmc@481d8000.blk'
   - not found
*** Warning - bad CRC, using default environment

uclass_find_device_by_seq: 0 -1
uclass_find_device_by_seq: 0 0
   - -1 -1 'oscillator'
   - not found
ofnode_read_u32: clock-frequency: 0xb71b00 (12000000)
Net:   No ethernet found.

Thank you in advance for your ideas, regards
Peter

  • Hi Peter,
    Sorry for delayed response as I'm still catching up after the new year time-off.
    First can we run a quick test @u-boot prompt as listed below:

    #1 => md.l 0x44DF8CB0 1
    44df8cb0: 00030000                               
    #2 => mw.l 0x44DF8CB0 0x2 1
    #3 => md.l 0x44DF8CB0 1
    44df8cb0: 00000002  

    What is the return value from cmd #1 on your board?
    If cmd #1 returns "0x00030000" as shown above, then continue running cmds #2 and #3.
    Afterwards, run "i2c dev 2" to see any difference?
    If it works, you may add one line in "u-boot/arch/arm/mach-omap2/am33xx/clock_am43xx.c"

    		&cmper->i2c1clkctrl,
    +		&cmper->i2c2clkctrl,

    Best,

    -Hong

  • Absolutely great, it works. Thank you Hong!