imx6 i2c controller setup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx6 i2c controller setup

648 Views
elliott1609
Contributor I

What must be initialized to access the three I2C controllers built into an imx6?

They are accessed through memory addresses beginning at 0x21a0000.
Despite initializing the IOMUX, clocks, AIPSTZ. and virtual memory pages, (but possibly with errors) all reads from the these memory locations return 0x50085008.

What more than this (in pairs for clock and data)?
1: MUX: 2 assignments like this
*(unsigned long*)(0x20E03B8) = 0x4001b8b1; // (IOMUXC_SW_PAD_CTL_PAD_EIM_DATA21)

2: clock: this looks ok but is it? (runtime output) CCM_CSCMR1: 0x20C401C = 0x900000

3: imx6 "AHB to IP Bridge (AIPSTZ): (runtime output) AIPSTZ2_MPR: 0x217C000 = 0x77777777

4: page tables for virtual to physical addressing, virtual=physical

 

Tags (1)
0 Kudos
Reply
3 Replies

503 Views
pengyong_zhang
NXP Employee
NXP Employee

Hi @elliott1609 

What is your BSP version? You can use the ./memtool tool read and write the I2C controller.

B.R

0 Kudos
Reply

583 Views
pengyong_zhang
NXP Employee
NXP Employee

Hi @elliott1609 

Sorry to reply late, But could you explain more details about your question?

How did you access the three I2C controllers now? And what is your result?

B.R

0 Kudos
Reply

578 Views
elliott1609
Contributor I

Linux on the Phytec Mira board correctly accesses a tri-color LED connected to I2C1 and NXP PCA9533 with these commands:


 

Linux on the Phytec Mira board correctly accesses a tri-color LED connected to I2C1 and NXP PCA9533 with these commands:
root@phyboard-mira-imx6-3:mira-red# pwd
/sys/devices/platform/dimleds/leds/mira-red
root@phyboard-mira-imx6-3:mira-red# ls -l
total 0
lrwxrwxrwx 1 root root    0 Jun 15 17:58 device -> ../../../dimleds/
drwxr-xr-x 2 root root    0 Jun 15 17:58 power/
lrwxrwxrwx 1 root root    0 Apr 28  2022 subsystem -> ../../../../../class/leds/
-rw-r--r-- 1 root root 4096 Jun 15 17:58 brightness
-r--r--r-- 1 root root 4096 Jun 15 17:58 max_brightness
-rw-r--r-- 1 root root    0 Jun 15 17:58 trigger
-rw-r--r-- 1 root root 4096 Apr 28  2022 uevent
root@phyboard-mira-imx6-3:mira-red# echo 1 > brightness 

 

This works too...

 

i2cdetect -l
i2c-0	i2c       	21a0000.i2c                     	I2C adapter
i2c-1	i2c       	21a4000.i2c                     	I2C adapter
i2c-2	i2c       	21a8000.i2c                     	I2C adapter

 

This works too...

 

root@phyboard-mira-imx6-3:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- UU -- -- -- -- -- UU -- -- -- -- -- -- -- 

 

 But if I try to display I/O memory for the first I2C controller - segmentation fault!

 

root@phyboard-mira-imx6-3:~# devmem2 0x21a0000
/dev/mem opened.
[  133.730598] 8<--- cut here ---
Memory mapped at address 0xb6f750[  133.734931] Unhandled fault: page domain fault (0x01b) at 0x0046087e
00.
[  133.744145] pgd = 372d4450
[  133.747281] [0046087e] *pgd=4c289831
[  133.750871] Internal error: : 1b [#1] SMP ARM
[  133.755233] Modules linked in: cfg80211 coda_vpu v4l2_jpeg imx_vdoa etnaviv dw_hdmi_ahb_audio
[  133.763795] CPU: 2 PID: 375 Comm: devmem2 Not tainted 5.15.102-bsp-yocto-ampliphy-i.mx6-pd22.1.1 #1
[  133.772850] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[  133.779380] PC is at imx6q_pcie_abort_handler+0x4/0x6c
[  133.784545] LR is at do_DataAbort+0x38/0xbc
[  133.788739] pc : [<c059f2b8>]    lr : [<c0113fd0>]    psr: 600f0193
[  133.795011] sp : c2c4ff88  ip : c130a66c  fp : 00000002
[  133.800240] r10: 00000077  r9 : 00000000  r8 : c059f2b4
[  133.805468] r7 : c2c4ffb0  r6 : b6f75000  r5 : c130a6ec  r4 : 00001018
[  133.812000] r3 : 0046087e  r2 : c2c4ffb0  r1 : 00001018  r0 : b6f75000
[  133.818532] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
[  133.825763] Control: 10c5387d  Table: 1297804a  DAC: 00000051
[  133.831512] Register r0 information: non-paged memory
[  133.836573] Register r1 information: non-paged memory
[  133.841630] Register r2 information: non-slab/vmalloc memory
[  133.847301] Register r3 information: non-paged memory
[  133.852358] Register r4 information: non-paged memory
[  133.857415] Register r5 information: non-slab/vmalloc memory
[  133.863079] Register r6 information: non-paged memory
[  133.868136] Register r7 information: non-slab/vmalloc memory
[  133.873801] Register r8 information: non-slab/vmalloc memory
[  133.879465] Register r9 information: NULL pointer
[  133.884174] Register r10 information: non-paged memory
[  133.889318] Register r11 information: non-paged memory
[  133.894461] Register r12 information: non-slab/vmalloc memory
[  133.900212] Process devmem2 (pid: 375, stack limit = 0x45ccccb7)
[  133.906225] Stack: (0xc2c4ff88 to 0xc2c50000)
[  133.910592] ff80:                   01366000 00000025 01366190 b6f77200 0046087e 200f0030
[  133.918778] ffa0: ffffffff 10c5387d 10c5387d c0100e64 00000000 00000000 00000001 00000008
[  133.926963] ffc0: b6f75000 00001000 021a0000 00000003 b6f75000 00000000 00000077 00000002
[  133.935147] ffe0: 00471f98 be96fba8 b6e6f96b 0046087e 200f0030 ffffffff 00000000 00000000
[  133.943332] [<c059f2b8>] (imx6q_pcie_abort_handler) from [<c0113fd0>] (do_DataAbort+0x38/0xbc)
[  133.951965] [<c0113fd0>] (do_DataAbort) from [<c0100e64>] (__dabt_usr+0x44/0x60)
[  133.959376] Exception stack(0xc2c4ffb0 to 0xc2c4fff8)
[  133.964434] ffa0:                                     00000000 00000000 00000001 00000008
[  133.972619] ffc0: b6f75000 00001000 021a0000 00000003 b6f75000 00000000 00000077 00000002
[  133.980804] ffe0: 00471f98 be96fba8 b6e6f96b 0046087e 200f0030 ffffffff
[  133.987426] Code: c10428d0 c10428b4 c1042898 e592303c (e5933000) 
[  133.993527] ---[ end trace 79bea8ac688e94bd ]---
Segmentation fault

 

Here are two other attempts to access the I2C controller I/O address space, this time with barebox...

 

Hit m for menu or any to stop autoboot: 2
barebox@PHYTEC phyCORE-i.MX6 Quad with NAND:/ mmuinfo 0x21a0000
PAR result for 0x021a0000:
privileged read: 0x021a0090
Physical Address [31:12]: 0x021a0000
Reserved [11]: 0x0
Not Outer Shareable [10]: 0x0
Non-Secure [9]: 0x0
Impl. def. [8]: 0x0
Shareable [7]: 0x1
Inner mem. attr. [6:4]: 0x1 (0b001 Strongly-ordered)
Outer mem. attr. [3:2]: 0x0 (0b00 Non-cacheable)
SuperSection [1]: 0x0
Failure [0]: 0x0
privileged write: 0x021a0090
Physical Address [31:12]: 0x021a0000
Reserved [11]: 0x0
Not Outer Shareable [10]: 0x0
Non-Secure [9]: 0x0
Impl. def. [8]: 0x0
Shareable [7]: 0x1
Inner mem. attr. [6:4]: 0x1 (0b001 Strongly-ordered)
Outer mem. attr. [3:2]: 0x0 (0b00 Non-cacheable)
SuperSection [1]: 0x0
Failure [0]: 0x0

 

Barebox again showing (I believe) that something is blocking access to the I/O address space for all three I2C controllers ...

 

barebox@PHYTEC phyCORE-i.MX6 Quad with NAND:/ md -l 0x219FFF0+0x20
0219fff0: 00000000 00000000 00000000 00000000 ................
021a0000: xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx ................
barebox@PHYTEC phyCORE-i.MX6 Quad with NAND:/ md -l 0x21abff0+0x20
021abff0: xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx ................
021ac000: 00000000 00000000 00000000 00000000 ................

 

My (short) BARE METAL program correctly accesses UART2, the green SOM LED, and the three LEDS on the Mira "expansion board"

I believe my program fails to control the tri-color LED attached to the PCA9533 because something is blocking memory access to I2C controller registers beginning at 21a_0000. Why do I conclude that? Because ALL reads from ANY I2C register (frequency, status. etc) return 0x50085008

My program's output (via UART2)...

 

 IOMUXC_SW_MUX_CTL_PAD_GPIO04 0x20E0238 = 0x5
 IOMUXC_SW_PAD_CTL_PAD_GPIO04 0x20E0608 = 0x1B0B0
 GPIO05 direction extension green: 0x20AC004 = 0x20000000
R0: 0xC5187F (SCTRL)
R1: 0x0
R2: 0x918048 (translation table base 0)
 CCM_CCGR2: 0x20C4070 = 0xFFFFFFFF
 CCM_CBCMR:   0x20C4018 = 0x11204
 CCM_CBCDR:   0x20C4014 = 0x18D00
 CCM_CSCMR1:  0x20C401C = 0x900000
 AIPSTZ1_MPR:  0x207C000 = 0x77777777
 AIPSTZ2_MPR:  0x217C000 = 0x77777777
 AIPSTZ2_OPACR1:  0x217C044 = 0x0
 IOMUXC_SW_PAD_CTL_PAD_EIM_DATA21:  0x20E03B8 = 0x1B8B1
 I2C1 frequency:  0x21A0004 = 0x50085008
 I2C1_I2SR at start:  0x21A000C = 0x50085008I2C RXAK timeout!  0x21A000C = 0x50085008I2C RXAK timeout!  0x21A000C = 0x50085008I2C RXAK timeout!  0x21A000C = 0x50085008
RV-4162-C7 real-time clock...I2C RXAK timeout!  0x21A000C = 0x50085008I2C RXAK timeout!  0x21A000C = 0x50085008

 

0 Kudos
Reply