Now, as we saw in the Understanding the issue with direct access section, attempting to perform I/O directly on these physical or bus addresses simply won't work. The way we should do this is by telling Linux to map these bus addresses into the kernel's VAS so that we can access it through kernel virtual addresses (KVAs)! How do we do this? The kernel provides APIs for this express purpose; a very common one that driver authors use is the ioremap() API. Its signature is as follows:
#include <asm/io.h>
void __iomem *ioremap(phys_addr_t offset, size_t size)
The asm/io.h header becomes an arch-specific header file as required. Notice how the first parameter to ioremap() is a physical (or bus) address (it's data type is phys_addr_t). This is one of the rare cases in Linux where you, as a driver author, have to supply a physical – not a virtual – address (the other typical case...