LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Direct physcial register access (I/O) (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/direct-physcial-register-access-i-o-813322/)

chxooi 06-10-2010 07:13 AM

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.....

nini09 06-10-2010 02:40 PM

What space do you want to access those registers, in kernel or user space?

atmurali 06-17-2010 12:52 PM

In kernel space, how it is possible?

nini09 06-17-2010 02:50 PM

You can access those register in kernel space like regular memory after calling ioremap.

Suresh Maniyath 06-19-2010 03:30 AM

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

atmurali 06-23-2010 05:09 AM

Thank You Very Much


All times are GMT -5. The time now is 05:43 PM.