I am trying to get memory resource but for any reason, I cannot. My code is the following:
mmio_base0 = pci_resource_start (dev,0);
mmio_length0 =pci_resource_len(dev,0);
if(!mmio_base0 || ((pci_resource_flags (dev,0) & IORESOURCE_MEM)== 0))
{
dev_err(&(dev->dev), "no mem resource at PCI #0\n");
}
else
{
printk(KERN_ALERT "There is memory at BAR0\n");
if(request_mem_region(mmio_base0,mmio_length0,"driver")==0){
printk(KERN_ALERT "Impossible to get memory\n");
}
}
I always get "Impossible to get memory". So, there are memory but I cannot request it.
cat /proc/iomem
c20000000-c2fffffff : /pcie@ffe250000
c20000000-c2fffffff : PCI Bus 0001:01
c20000000-c200fffff : 0001:01:00.0 //these two memories I want to request
c20100000-c201fffff : 0001:01:00.0
c40000000-c4fffffff : /pcie@ffe270000
c40000000-c4fffffff : PCI Bus 0002:01
There are memories there, but I cannot request them. It always fail! But my uboot detect my device.
PCIe2: Root Complex, x2 gen2, regs @ 0xfe250000
02:00.0 - 1957:0808 - Processor
And there is not driver loaded which take these memories:
0001:01:00.0 Power PC: Freescale Semiconductor Inc Device 0808 (rev 10) (prog-if 01)
Flags: bus master, fast devsel, latency 0, IRQ 41
Memory at c20000000 (32-bit, non-prefetchable) [size=1M]
Memory at c20100000 (32-bit, prefetchable) [size=1M]
Capabilities: [44] Power Management version 3
Capabilities: [4c] Express Endpoint, MSI 00
Capabilities: [88] MSI: Enable- Count=1/16 Maskable- 64bit+
Capabilities: [100] Advanced Error Reporting
Any idea what is going on?
BR