For a device driver, the hardware registers access usually involves following kernel API.
- request_mem_region: Tell kernel that the specific range of physical memory are to be used.
- ioremap: Maps the physical memory to kernel virtual memory that can be accessed by kernel.
- ioreadX, iowriteX: X could be 8, 16, 32, parameter is the kernel virtual memory.
- release_mem_region: tell kernel the range of physical memory is not to be used anymore
ioread & iowirte
There are some drivers for ARM device are using "writel" and "iowrite32" function to access IO mapped memory.
writeX read X are deprecated functions, should use ioreadX iowriteX functions.
There is some interesting story about memory barriers of io mapped memory access.
Seems in 2006, writel and iowrite32 is no-barrier. It is nowadays.
http://lwn.net/Articles/198988/
request_mem_region
About why some code, there is no calling of request_mem_region.
http://stackoverflow.com/questions/7682422/what-does-request-mem-region-actually-do-and-when-it-is-needed
Examples
Some source examples shows how to use io read/write related functions.
No comments:
Post a Comment