Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


Search this Thread
Old 06-10-2010, 07:13 AM   #1
LQ Newbie
Registered: May 2010
Posts: 24

Rep: Reputation: 0
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.....
Old 06-10-2010, 02:40 PM   #2
Senior Member
Registered: Apr 2009
Posts: 1,118

Rep: Reputation: 89
What space do you want to access those registers, in kernel or user space?
Old 06-17-2010, 12:52 PM   #3
Registered: Nov 2007
Location: Kerala
Posts: 42

Rep: Reputation: 15
In kernel space, how it is possible?
Old 06-17-2010, 02:50 PM   #4
Senior Member
Registered: Apr 2009
Posts: 1,118

Rep: Reputation: 89
You can access those register in kernel space like regular memory after calling ioremap.
Old 06-19-2010, 03:30 AM   #5
Suresh Maniyath
Registered: Feb 2009
Location: India
Distribution: Fedora, Ubuntu
Posts: 37

Rep: Reputation: 19
Lightbulb 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
Old 06-23-2010, 05:09 AM   #6
Registered: Nov 2007
Location: Kerala
Posts: 42

Rep: Reputation: 15
Thank You Very Much


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access kernel register from user application navvu_mom Linux - Software 0 05-27-2008 01:32 AM
Virtualization using Physcial Partition joshfoulk Linux - Software 4 12-17-2007 02:12 PM
Direct I/O Port Access illiadum Programming 2 08-07-2007 05:39 AM
Howto access internet usig dhcp with MAC register badall Linux - Networking 2 05-24-2007 01:53 AM
Direct memory access through C/C++ NCC-1701&NCC-1701-D Programming 3 09-14-2005 03:20 PM

All times are GMT -5. The time now is 09:24 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration