Clarifications for platform_get_resource and devm_request_mem_region
Amit Uttamchandani
auttamchandani at canoga.com
Tue Nov 3 10:18:01 PST 2009
Hi,
I have been working on modifying drivers/net/ethoc.c to support
communication over an SPI bus. So far, I have successful in the basic
read/write ops and driver init. However, I am confused regarding
requesting system memory for the ethernet buffer descriptors. Here are
some of my questions regarding the following code snippet located in
ethoc_probe:
/* obtain buffer memory space */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) {
mem = devm_request_mem_region(&pdev->dev, res->start,
res->end - res->start + 1, res->name);
if (!mem) {
dev_err(&pdev->dev, "cannot request memory space\n");
ret = -ENXIO;
goto free;
}
netdev->mem_start = mem->start;
netdev->mem_end = mem->end;
}
Note: The actual device is an FPGA device that connected to the CPU via
an SPI bus.
1. I understand I can't use the platform_get_resource function for an
SPI device but I can use the devm_request_mem_region by passing in hard
coded values for the start and length of the mem region. The above code
goes on to setup devm_ioremap_nocache and dma_alloc_coherent.
However, I don't think I can use this for the SPI device since the
above code assumes that the CPU has direct memory access to the FPGA
correct?
2. According to the free-electrons driver dev guide, platform_devices
are only used for devices that are directly connected to the CPU and
not over any bus. But it seems to me there are a lot of net drivers
implemented in this fashion. Why is that so?
Thanks for any help.
Amit
More information about the devel
mailing list