Using I2C api in uboot with 7ulp

cancel
Showing results for 
Search instead for 
Did you mean: 

Using I2C api in uboot with 7ulp

210 Views
arthur_rythm
Contributor II

Hi,

 I am using uboot from official repository Aurora : uboot-imx - i.MX U-Boot 

Tag : rel_imx_4.14.98_2.3.0

I am using the mx7ulp_10x10_arm2 defconfig. 

I would like to use i2c api in my board init code to drive a peripheral. 

I used to pilot i2c device with i2c_setup, i2c_write, etc...

Problem is that I have plenty of problem to used i2c api with 7ulp in uboot.

There is plenty of missing stuff in code. Is there a new I2C api in recent uboot ? LPI2C ?

Some example of my modification :

First to used I2C api from  i2c-mxv7.c, there is no define for 7ulp SOC, I have to add it :

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 1d13812b8a..2376fff7ab 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -54,6 +54,7 @@ ifeq ($(SOC),$(filter $(SOC),mx7ulp))
obj-y += cache.o
obj-$(CONFIG_IMX_VIDEO_SKIP) += video.o
obj-$(CONFIG_SECURE_BOOT) += hab.o
+obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
endif
ifeq ($(SOC),$(filter $(SOC),vf610))
obj-y += ddrmc-vf610.o

Then after including <asm/mach-imx/mxc_i2c.h> in my code, I have plenty of multiple define

from arch/arm/include/asm/mach-imx/iomux-v3.h. So I have to comment plenty of stuff

from iomux-v3.

In file included from ./arch/arm/include/asm/mach-imx/mxc_i2c.h:9:0,
from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:14:
./arch/arm/include/asm/mach-imx/iomux-v3.h:51:0: warning: "MUX_CTRL_OFS_MASK" redefined
#define MUX_CTRL_OFS_MASK ((iomux_v3_cfg_t)0xfff << MUX_CTRL_OFS_SHIFT)

In file included from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:12:0:
./arch/arm/include/asm/arch/iomux.h:48:0: note: this is the location of the previous definition
#define MUX_CTRL_OFS_MASK ((iomux_cfg_t)0xffff << MUX_CTRL_OFS_SHIFT)

In file included from ./arch/arm/include/asm/mach-imx/mxc_i2c.h:9:0,
from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:14:
./arch/arm/include/asm/mach-imx/iomux-v3.h:55:0: warning: "MUX_SEL_INPUT_OFS_SHIFT" redefined
#define MUX_SEL_INPUT_OFS_SHIFT 24

In file included from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:12:0:
./arch/arm/include/asm/arch/iomux.h:49:0: note: this is the location of the previous definition
#define MUX_SEL_INPUT_OFS_SHIFT 16

In file included from ./arch/arm/include/asm/mach-imx/mxc_i2c.h:9:0,
from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:14:
./arch/arm/include/asm/mach-imx/iomux-v3.h:56:0: warning: "MUX_SEL_INPUT_OFS_MASK" redefined
#define MUX_SEL_INPUT_OFS_MASK ((iomux_v3_cfg_t)0xfff << \

In file included from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:12:0:
./arch/arm/include/asm/arch/iomux.h:50:0: note: this is the location of the previous definition
#define MUX_SEL_INPUT_OFS_MASK ((iomux_cfg_t)0xffff << \

In file included from ./arch/arm/include/asm/mach-imx/mxc_i2c.h:9:0,
from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:14:
./arch/arm/include/asm/mach-imx/iomux-v3.h:59:0: warning: "MUX_MODE_SHIFT" redefined
#define MUX_MODE_SHIFT 36

In file included from board/freescale/mx7ulp_arm2/mx7ulp_arm2.c:12:0:
./arch/arm/include/asm/arch/iomux.h:53:0: note: this is the location of the previous definition
#define MUX_MODE_SHIFT 32

There is also no I2CX_BASE_ADDR available in include. Only LPI2CX_BASE_ADDR ?

Thanks,

Tags (3)
0 Kudos
3 Replies

116 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Arthur

i.MX7ULP (along with i.MX8QM/QXP) uses LPI2C module different

from I2C module used in i.MX7D procesor (and i.MX8MQ).

Its driver

imx_lpi2c.c\i2c\drivers - uboot-imx - i.MX U-Boot 

"CONFIG_SYS_I2C_IMX_LPI2C=y"

mx7ulp_evk_defconfig\configs - uboot-imx - i.MX U-Boot 

Also examples can be found in MX7ULP MCUXpresso SDK for i.MX Cortex-M

Welcome | MCUXpresso SDK Builder 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

116 Views
arthur_rythm
Contributor II

Hello igorpadykov‌,

Thanks for your reply.

I was trying to start to work on this topic. I was looking at your link.

This API seems to be cool but all functions are static!

Do I have to include .c file in an ugly way?

It is quite weird to have a source file with only static function.

Moreover, there is not one example in all uboot source using this lpi2c api.

No more luck in official uboot tree.

0 Kudos

116 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Arthur

I think you are right, there are no examples in uboot sources

using lpi2c api, so you will have to write it yourself.

Please note that nxp has special service for helping

with software customizations: Commercial Support and Engineering Services | NXP 

Best regards
igor

0 Kudos