Direct physcial register access (I/O)
I would like make some "UART" like I/O device driver read/write/interrupt
path is just I/O(like UART) (not dma, pci,i2c) my device base address is 0xdff00000 and some of register offset are 0x04,0x08 etc..... if I want to access this register , how can I do that? #define dev_base 0xdff00000 #define dev_reg1 dev_base+0x04 #define dev_reg2 dev_base+0x08 regwrite example *(unsigned char*)dev_reg1 = 0xFF *(unsigned char*)dev_reg1 = 0xFF read example int read_val=0 read_val= *(unsigned char*)dev_reg1; printk("===>reg value is %x\n",read_val); I think it has very critical problems. How can I access this registers on linux.... after search some file, but I couldn't understand..... |
What space do you want to access those registers, in kernel or user space?
|
In kernel space, how it is possible?
|
You can access those register in kernel space like regular memory after calling ioremap.
|
ioremap
Since your device is memory mapped IO, it is better to use "ioremap_nocache". Always check for the return status of the function "request_mem_region" before remapping the memory. If both the functions passed, then your mapped memory will be visible in /proc/iomem.
In summary, understanding some kernel functions like below will be helpful 1. request_mem_region 2. ioremap_nocache 3. iounmap 4. release_mem_region Best regards, Suresh Maniyath |
Thank You Very Much
|
All times are GMT -5. The time now is 05:43 PM. |