linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Accessing BCSR's
@ 2002-03-03 23:32 Jeremy Rosen
  2002-03-03 23:57 ` Magnus Damm
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Rosen @ 2002-03-03 23:32 UTC (permalink / raw)
  To: linuxppc-embedded


Hello everybody,

I have 860T FADS board, and I am trying to access the (board specific)
registers BCSRs.

I have no problem accessing them in PPCBOOT, since they are accessed
through CS1, at address FF01xxxx, but I can't access them in linux for
the moment.
My first attempt was by using the /dev/mem device, but it doesn't seem
to work, the result read are not correct.
so I have to question
1) why doesn't it work, I probably don't understand how /dev/mem works
: does it map only memory and not the address space ? do I have to
register the address range or the BCSR in the kernel ?
2) what is the proper way of doing this ? writing a driver ? or using
/dev/mem properly ?

thx for your help...

Jeremy

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Accessing BCSR's
  2002-03-03 23:32 Jeremy Rosen
@ 2002-03-03 23:57 ` Magnus Damm
  0 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2002-03-03 23:57 UTC (permalink / raw)
  To: Jeremy Rosen; +Cc: linuxppc-embedded


Hi,

If you have memory-mapped io (The (F)ADS8xx BCSR registers is a
good example) which is mapped to a certain physical address, it
is very simple to access it if the MMU is turned off.

The Linux kernel runs with the MMU on, and it needs a
virtual-to-physical
address mapping to be able to access memory-mapped io.

So, my 2.2-kernel has a file called arch/ppc/mm/init.c.

Inside that file there's a function called "ioremap()" - that is what
you are looking for.

Make sure that your Linux kernel has a virtual page for your io-area,
and access the virtual address that is returned by "ioremap()".

If you use "ioremap()" before a certain moment when the Linux kernel
starts up, you will get a 1:1 mapping between virtual and physical
addresses.
(This is true for 2.2 anyhow)

Look how the internal io block is ioremap():ped for a good example how
it is done.

Cheers /

magnus

Jeremy Rosen wrote:
>
> Hello everybody,
>
> I have 860T FADS board, and I am trying to access the (board specific)
> registers BCSRs.
>
> I have no problem accessing them in PPCBOOT, since they are accessed
> through CS1, at address FF01xxxx, but I can't access them in linux for
> the moment.
> My first attempt was by using the /dev/mem device, but it doesn't seem
> to work, the result read are not correct.
> so I have to question
> 1) why doesn't it work, I probably don't understand how /dev/mem works
> : does it map only memory and not the address space ? do I have to
> register the address range or the BCSR in the kernel ?
> 2) what is the proper way of doing this ? writing a driver ? or using
> /dev/mem properly ?
>
> thx for your help...
>
> Jeremy
>

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Accessing BCSR's
@ 2002-03-04  0:42 Jeremy Rosen
  2002-03-04  5:22 ` caokai
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Rosen @ 2002-03-04  0:42 UTC (permalink / raw)
  To: linuxppc-embedded, Magnus Damm


I have investigated a little further, and in arch/ppc/mm/init.c, it
calls ppc_md.setup_io_mapping(), which remaps 1:1 the BCSRs
(in arch/ppc/kernel/m8xx_map_io), so (if I understand your explanation
and the code properly) the BCSR should be at the same address in PPCBOOT
and in the kernel space... so accessing offset ff010000 in /dev/mem or
/dev/kmem should give me access to it... is that it ? Because if it is,
I can't make it work...

I'll try to access some of the internal maps in the IMMR to see if they
work...

thx anyway
Jeremy

>>> Magnus Damm <damm@opensource.se> 03/04/02 10:57am >>>
Hi,

If you have memory-mapped io (The (F)ADS8xx BCSR registers is a
good example) which is mapped to a certain physical address, it
is very simple to access it if the MMU is turned off.

The Linux kernel runs with the MMU on, and it needs a
virtual-to-physical
address mapping to be able to access memory-mapped io.

So, my 2.2-kernel has a file called arch/ppc/mm/init.c.

Inside that file there's a function called "ioremap()" - that is what
you are looking for.

Make sure that your Linux kernel has a virtual page for your io-area,
and access the virtual address that is returned by "ioremap()".

If you use "ioremap()" before a certain moment when the Linux kernel
starts up, you will get a 1:1 mapping between virtual and physical
addresses.
(This is true for 2.2 anyhow)

Look how the internal io block is ioremap():ped for a good example how
it is done.

Cheers /

magnus

Jeremy Rosen wrote:
>
> Hello everybody,
>
> I have 860T FADS board, and I am trying to access the (board
specific)
> registers BCSRs.
>
> I have no problem accessing them in PPCBOOT, since they are accessed
> through CS1, at address FF01xxxx, but I can't access them in linux
for
> the moment.
> My first attempt was by using the /dev/mem device, but it doesn't
seem
> to work, the result read are not correct.
> so I have to question
> 1) why doesn't it work, I probably don't understand how /dev/mem
works
> : does it map only memory and not the address space ? do I have to
> register the address range or the BCSR in the kernel ?
> 2) what is the proper way of doing this ? writing a driver ? or
using
> /dev/mem properly ?
>
> thx for your help...
>
> Jeremy
>

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Accessing BCSR's
  2002-03-04  0:42 Accessing BCSR's Jeremy Rosen
@ 2002-03-04  5:22 ` caokai
  0 siblings, 0 replies; 5+ messages in thread
From: caokai @ 2002-03-04  5:22 UTC (permalink / raw)
  To: Jeremy Rosen, linuxppc-embedded@lists.linuxppc.org


Hi,Jeremy Rosen:
   I have met the same problem with u.The kernel will crash if I access the
BCSR when mmu is on.
I add the following line in function MMU_init (arch/ppc/mm/init.c).it is OK
now.
#ifdef CONFIG_XXXXXX
        /*I defined the BCSR_ADDR,BCSR_SIZE in my include/asm/xxxx.h*/
        ioremap(BCSR_ADDR, BCSR_SIZE);
#endif
Wish it helps u.
caokai
Jeremy Rosen wrote:

> I have investigated a little further, and in arch/ppc/mm/init.c, it
> calls ppc_md.setup_io_mapping(), which remaps 1:1 the BCSRs
> (in arch/ppc/kernel/m8xx_map_io), so (if I understand your explanation
> and the code properly) the BCSR should be at the same address in PPCBOOT
> and in the kernel space... so accessing offset ff010000 in /dev/mem or
> /dev/kmem should give me access to it... is that it ? Because if it is,
> I can't make it work...
>
> I'll try to access some of the internal maps in the IMMR to see if they
> work...
>
> thx anyway
> Jeremy
>
> >>> Magnus Damm <damm@opensource.se> 03/04/02 10:57am >>>
> Hi,
>
> If you have memory-mapped io (The (F)ADS8xx BCSR registers is a
> good example) which is mapped to a certain physical address, it
> is very simple to access it if the MMU is turned off.
>
> The Linux kernel runs with the MMU on, and it needs a
> virtual-to-physical
> address mapping to be able to access memory-mapped io.
>
> So, my 2.2-kernel has a file called arch/ppc/mm/init.c.
>
> Inside that file there's a function called "ioremap()" - that is what
> you are looking for.
>
> Make sure that your Linux kernel has a virtual page for your io-area,
> and access the virtual address that is returned by "ioremap()".
>
> If you use "ioremap()" before a certain moment when the Linux kernel
> starts up, you will get a 1:1 mapping between virtual and physical
> addresses.
> (This is true for 2.2 anyhow)
>
> Look how the internal io block is ioremap():ped for a good example how
> it is done.
>
> Cheers /
>
> magnus
>
> Jeremy Rosen wrote:
> >
> > Hello everybody,
> >
> > I have 860T FADS board, and I am trying to access the (board
> specific)
> > registers BCSRs.
> >
> > I have no problem accessing them in PPCBOOT, since they are accessed
> > through CS1, at address FF01xxxx, but I can't access them in linux
> for
> > the moment.
> > My first attempt was by using the /dev/mem device, but it doesn't
> seem
> > to work, the result read are not correct.
> > so I have to question
> > 1) why doesn't it work, I probably don't understand how /dev/mem
> works
> > : does it map only memory and not the address space ? do I have to
> > register the address range or the BCSR in the kernel ?
> > 2) what is the proper way of doing this ? writing a driver ? or
> using
> > /dev/mem properly ?
> >
> > thx for your help...
> >
> > Jeremy
> >
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Accessing BCSR's
@ 2002-03-04  6:41 Jeremy Rosen
  0 siblings, 0 replies; 5+ messages in thread
From: Jeremy Rosen @ 2002-03-04  6:41 UTC (permalink / raw)
  To: linuxppc-embedded, tk19


thanks all, I got it working, I had wrongly configured the BCSR, my
mistake.

thx for all the help...

B.T.W is their a way to use the request_mem_region mechanism to have
all the memory map documented in /proc/iomem ??
it seems quite straightforward  to do, or did I miss something ???
thx
jeremy

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-03-04  6:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-04  0:42 Accessing BCSR's Jeremy Rosen
2002-03-04  5:22 ` caokai
  -- strict thread matches above, loose matches on Subject: below --
2002-03-04  6:41 Jeremy Rosen
2002-03-03 23:32 Jeremy Rosen
2002-03-03 23:57 ` Magnus Damm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).