www.smartbusinesschoices.com

Leading Business and Technology,
News and information


Part of the Identityscape.com network...

getxfactor.com jmoodmusic.com smartbusinesschoices.com mintdepot.com lowfaresalways.com evangelicalview.com shoppingpodder.com soproudlywehail.com webnews.ws currenthumor.com

 

 

ARM Linux driver : how to write to a physical address?
   Smart Linux Business Choices! - the Best of UseNet Postings! Forum Index -> Linux Embedded  
View previous topic :: View next topic  
Author Message
fred
Guest






PostPosted: Fri Sep 19, 2008 11:24 pm    Post subject: ARM Linux driver : how to write to a physical address? Reply with quote

Hi All,

I'm writing a device driver for an ARM based board (Cirrus EP9302).
One of the functions of the driver is to be able to write values to
the address 0x23800000. How do you actually write to a physical
address
from within the kernel?
Back to top
Juergen Beisert
Guest






PostPosted: Sat Sep 20, 2008 4:26 pm    Post subject: Re: ARM Linux driver : how to write to a physical address? Reply with quote

fred wrote:

Quote:
Hi All,

I'm writing a device driver for an ARM based board (Cirrus EP9302).
One of the functions of the driver is to be able to write values to
the address 0x23800000. How do you actually write to a physical
address
from within the kernel?

Did you check how the other device drivers do it? (BTW: The kernel is full
of examples).

jbe
Back to top
subhasish
Guest






PostPosted: Sun Oct 05, 2008 11:02 am    Post subject: Re: ARM Linux driver : how to write to a physical address? Reply with quote

On Sep 20, 4:26 pm, Juergen Beisert <jbeis...@netscape.net> wrote:
Quote:
fred wrote:
Hi All,

I'm writing a device driver for an ARM based board (Cirrus EP9302).
One of the functions of the driver is to be able to write values to
the address 0x23800000.  How do you actually write to a physical
address
from within the kernel?

Did you check how the other device drivers do it? (BTW: The kernel is full
of examples).

jbe

H!,

Just type cast the address to a variable and use it. Any thing that is
directly mapped to the processors address space can be accssed like
that. Also try __raw_read Api, should be available on ARM.
Back to top
ramkey
Guest






PostPosted: Tue Oct 07, 2008 11:39 pm    Post subject: Re: ARM Linux driver : how to write to a physical address? Reply with quote

On Oct 5, 4:02 am, subhasish <ghosh.subhas...@gmail.com> wrote:
Quote:
On Sep 20, 4:26 pm, Juergen Beisert <jbeis...@netscape.net> wrote:

fred wrote:
Hi All,

I'm writing a device driver for an ARM based board (Cirrus EP9302).
One of the functions of the driver is to be able to write values to
the address 0x23800000.  How do you actually write to a physical
address
from within the kernel?

Did you check how the other device drivers do it? (BTW: The kernel is full
of examples).

jbe

H!,

Just type cast the address to a variable and use it. Any thing that is
directly mapped to the processors address space can be accssed like
that. Also try __raw_read Api, should be available on ARM.

unsigned long *ptr = 0xphysicaladdr
*ptr = yourdata.
Back to top
John McCallum
Guest






PostPosted: Wed Oct 08, 2008 3:18 pm    Post subject: Re: ARM Linux driver : how to write to a physical address? Reply with quote

Hi,

ramkey wrote:
Quote:
Just type cast the address to a variable and use it. Any thing that is
directly mapped to the processors address space can be accssed like
that. Also try __raw_read Api, should be available on ARM.

unsigned long *ptr = 0xphysicaladdr
*ptr = yourdata.

This would be wrong on other architectures (I am unfamiliar with ARM but I
believe most of them have an MMU and therefore it is wrong there too).
Normally you would need a phys_to_virt() to convert the physical address to
the virtual address used in the kernel process.

ie

unsigned long *ptr = phys_to_virt( 0xphysicaladdr );
*ptr = yourdata;

See

http://kerneltrap.org/man/linux/man9/phys_to_virt.9

Cheers,
John McCallum
Edinburgh
Back to top
Grzegorz Kania
Guest






PostPosted: Sun Oct 12, 2008 2:52 am    Post subject: Re: ARM Linux driver : how to write to a physical address? Reply with quote

Uzytkownik "John McCallum" <john.mccallum@skipthisemerson.com> napisal w
wiadomosci news:gci1ej$k03$1$8302bc10@news.demon.co.uk...
Quote:
Hi,

ramkey wrote:
Just type cast the address to a variable and use it. Any thing that is
directly mapped to the processors address space can be accssed like
that. Also try __raw_read Api, should be available on ARM.

unsigned long *ptr = 0xphysicaladdr
*ptr = yourdata.

This would be wrong on other architectures (I am unfamiliar with ARM but I
believe most of them have an MMU and therefore it is wrong there too).
Normally you would need a phys_to_virt() to convert the physical address
to
the virtual address used in the kernel process.

ie

unsigned long *ptr = phys_to_virt( 0xphysicaladdr );
*ptr = yourdata;

See

http://kerneltrap.org/man/linux/man9/phys_to_virt.9


Please dont't forget about: volatile. Lot of time I spent, when I was trying
to understad WHY :)

volatile unsigned long *ptr = phys_to_virt( 0xphysicaladdr );
*ptr = yourdata;

Grzegorz Kania
Czerwionka, Poland
Back to top
Marco Wang
Guest






PostPosted: Thu Nov 06, 2008 9:29 am    Post subject: Re: ARM Linux driver : how to write to a physical address? Reply with quote

On Oct 12, 5:52 am, "Grzegorz Kania" <gka...@poczta.onet.pl> wrote:
Quote:
Uzytkownik "John McCallum" <john.mccal...@skipthisemerson.com> napisal w
wiadomoscinews:gci1ej$k03$1$8302bc10@news.demon.co.uk...



Hi,

ramkey wrote:
Just type cast the address to a variable and use it. Any thing that is
directly mapped to the processors address space can be accssed like
that. Also try __raw_read Api, should be available on ARM.

unsigned long *ptr = 0xphysicaladdr
*ptr = yourdata.

This would be wrong on other architectures (I am unfamiliar with ARM but I
believe most of them have an MMU and therefore it is wrong there too).
Normally you would need a phys_to_virt() to convert the physical address
to
the virtual address used in the kernel process.

ie

unsigned long *ptr = phys_to_virt( 0xphysicaladdr );
*ptr = yourdata;

See

http://kerneltrap.org/man/linux/man9/phys_to_virt.9

Please dont't forget about: volatile. Lot of time I spent, when I was trying
to understad WHY :)

volatile unsigned long *ptr = phys_to_virt( 0xphysicaladdr );
*ptr = yourdata;

Grzegorz Kania
Czerwionka, Poland

phys_to_virt() only works with directly mapped physical address. I
don't think using phys_to_virt() is the best idea, anyway. Usually you
do this in several steps in a device driver:

1. Call request_mem_region() to request virtual memory region;
2. Call ioremap() to map physical address to virtual address;
3. Read/write mapped virtual address by using iowriteXX() /
ioreadXX(), etc. Here XX can be 8, 16, or 32 for example, represents
bit width.
4. Call iounmap() and release_mem_region() to release memory mapping;

Thanks,
Marco Wang
Back to top
Display posts from previous:   
   Smart Linux Business Choices! - the Best of UseNet Postings! Forum Index -> Linux Embedded  
Page 1 of 1
All times are GMT

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum