I'm using PCI-e port on Freescale MPC8308 processor (which is based on PowerPC architecture) and I have some problems when trying to use it. The endpoint PCI-e device has memory space equal to 256 MB. I can easily read and write configuration space of the endpoint device by using "pciutils" package.
After writing correct values in configuration registers and getting the permission to access the memory space; I tried to access memory space by using "mmap()" function in C and used the file descriptor located at :
"/sys/devices/pci0000:00/0000:00:00.0/resource0"
which was exactly 256 MB (equal to memory space of endpoint device) so it seems that I am using correct path for file descriptor. here you can find my code using "mmap()" as mentioned in https://github.com/billfarrow/pcimem:
https://github.com/billfarrow/pcimem/blob/master/pcimem.c
But unfortunately when I try to use memory space by using returned address of "mmap()" function; I cannot read the read-only registers of endpoint device correctly. Also, when I read addresses bigger than "0x7FFFFFC", the MPC8308 reboots. Considering above situation, do I miss any steps to initialize the PCI-e interface? Should I change anything in the Linux kernel image or U-Boot codes? Is there anything different for using PowerPC PCI-e with mmap()? Do you have any example code that can help me read PCI-e memory space?
Thanks