iMX6 PCIe: How to mmap() a PCIe device?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

iMX6 PCIe: How to mmap() a PCIe device?

跳至解决方案
8,365 次查看
KroMignon
Contributor I

On my system, I have connected to iMX6 (DualLite) via the PCIe Link an external MAC/Phy from Intel (i211).

To be able to use this Gigabit interface, I must program into internal PROM a MAC address.

The MAC address programming has to be done through the PCIe link, there is no other way to do this.

To do this, I need to mmap() the i211 registers, but the mmap() call fails with an error:

Unhandled fault: external abort on non-linefetch (0x1018) at 0x40248010

This is the code I try to execute:

Mapped1Address = mmap(NULL, 4096*32, PROT_WRITE | PROT_READ, MAP_SHARED, FileDescriptor, (off_t)WordLocation );

Where :

  • FileDescriptor : is the result of  fopen("/dev/mem", O_RDWR |O_SYNC)
  • WordLocation : is the physical address of the l’i211, which is 0x01100000

With lspci, I can see that my device is detected:

# lspci

00:00.0 Class 0604: 16c3:abcd

01:00.0 Class 0200: 8086:1532

And in /proc/iomem, the address space I try to mmap() is affected to PCIe:

# cat /proc/iomem

00000000-00000000 : iobase_vg

  00000000-00000000 : phys_baseaddr

00110000-00111fff : mxs-dma-apbh

00130000-00133fff : iobase_3d

  00130000-00133fff : galcore register region

00134000-00137fff : iobase_2d

  00134000-00137fff : galcore register region

01000000-01dfffff : PCIe 0 MEM

  01000000-010fffff : 0000:00:00.0

01100000-011fffff : PCI Bus 0000:01

01100000-0111ffff : 0000:01:00.0

01120000-01123fff : 0000:01:00.0

01200000-0120ffff : 0000:00:00.

So what I am doing wrong?

Any advice or suggestion?

My Linux system is build using Linux Kernel 3.0.35 (based on Freescale BSP 4.1.0).

Best regards

Fabrice

标签 (3)
标记 (3)
1 解答
3,686 次查看
richard_zhu
NXP Employee
NXP Employee

Had the "the i211 registers," been mapped during the pcie bus enumeration procedure(such as the kinds of  mem spaces defined by bars of ep device)?

If yes, you can mmap "the i211 registers," by one regions of imx6 pcie address space(some part of 0x0100_0000 ~ 0x01ef_ffff) directly.

If not, I'm afraid that the outbound mem region should be defined to map "the EP's i211 registers," at RC side, and used to access "the i211 registers,".

The details, you can make a reference to the imx6 pcie ep/rc validation.

在原帖中查看解决方案

0 项奖励
回复
7 回复数
3,687 次查看
richard_zhu
NXP Employee
NXP Employee

Had the "the i211 registers," been mapped during the pcie bus enumeration procedure(such as the kinds of  mem spaces defined by bars of ep device)?

If yes, you can mmap "the i211 registers," by one regions of imx6 pcie address space(some part of 0x0100_0000 ~ 0x01ef_ffff) directly.

If not, I'm afraid that the outbound mem region should be defined to map "the EP's i211 registers," at RC side, and used to access "the i211 registers,".

The details, you can make a reference to the imx6 pcie ep/rc validation.

0 项奖励
回复
3,687 次查看
aurelienbouin
Contributor IV

Hongxing Zhu is right ! i211 need to be enumerate at boot up

Since I get back in the bus error problem I will propose you a really simple solution to solve it.

What have to be done is to make the i211 detected by the probe function of igb driver. If you don't use an i210 component you can simply fake the igb driver telling him that i210 id is the i211 unprogrammed id

What you can do before compilation of you linux is a simple :

sed -i -e "s/0x1533/0x1532/g" ${S}/drivers/net/ethernet/intel/igb/e1000_hw.h

Then the i211 unprogrammed is detected as an i210, the driver will fail but you will be able to use eepromarmtool

Hope it will help

Regards,

Aurelien BOUIN

0 项奖励
回复
3,687 次查看
MarekVasut
Senior Contributor I

Honestly, we had a lot of fun with i210 :-) You will likely be unable to program your card on the FSL BSP, sorry.

What we did was we used mainline Linux as it contains a truly working PCIe driver. I'd suggest to use linux-next for this purpose (or linux-pci), since they contain a few fixes for some corner-case problems. Once you have at least a basic linux-next with PCIe and UART support running, use the eepromARMtool and program your i210 . While ultra-ugly and non-recommended, it is possible to do a static build of the eepromARMtool and run it from initramfs .

0 项奖励
回复
3,687 次查看
samuelbrucksch
Contributor I

Can you please tell me where i can download that arm eeprom tool for i210?

0 项奖励
回复
3,687 次查看
karina_valencia
NXP Apps Support
NXP Apps Support

Zhi LiEmployee

Can you try add offset 0x0110 0000

0 项奖励
回复
3,687 次查看
MarekVasut
Senior Contributor I

Can you please elaborate how would that fix anything ?

0 项奖励
回复
3,687 次查看
karina_valencia
NXP Apps Support
NXP Apps Support

FrankLi1z can you comment please?

0 项奖励
回复