* userspace testing an ati fb driver
@ 2003-12-03 9:44 random
2003-12-04 0:06 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: random @ 2003-12-03 9:44 UTC (permalink / raw)
To: linuxppc-dev
On my Powerbook, /proc/iomem lists 0xb0000000-0xb000ffff as the location
of the programming registers for my ATI Radeon R250 Lf.
This seems to be the same spot XFree86 finds in its log:
(II) RADEON(0): MMIO registers at 0xb0000000
I've been trying to mimic the XFree86 fb accel code to make a Linux 2.6 fb
port, but i've had little luck. To try to pare down the new code, I've
written a userspace program which will open "/dev/mem" and then mmap in
this file starting at '0xb0000000' going for 0x10000 bytes. Poking at the
"registers" there seems to have no effect; reading from these "registers"
(for example, to verify the engine idling) indicates that I'm perhaps
reading from the wrong place in memory, i.e. the engine never indicates
that it's idle. Any ideas?
-eger david
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: userspace testing an ati fb driver
2003-12-03 9:44 random
@ 2003-12-04 0:06 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2003-12-04 0:06 UTC (permalink / raw)
To: random; +Cc: linuxppc-dev list
[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]
On Wed, 2003-12-03 at 20:44, random wrote:
> On my Powerbook, /proc/iomem lists 0xb0000000-0xb000ffff as the location
> of the programming registers for my ATI Radeon R250 Lf.
>
> This seems to be the same spot XFree86 finds in its log:
> (II) RADEON(0): MMIO registers at 0xb0000000
>
> I've been trying to mimic the XFree86 fb accel code to make a Linux 2.6 fb
> port, but i've had little luck. To try to pare down the new code, I've
> written a userspace program which will open "/dev/mem" and then mmap in
> this file starting at '0xb0000000' going for 0x10000 bytes. Poking at the
> "registers" there seems to have no effect; reading from these "registers"
> (for example, to verify the engine idling) indicates that I'm perhaps
> reading from the wrong place in memory, i.e. the engine never indicates
> that it's idle. Any ideas?
That should work, make sure you are using proper memory barriers for
your IO accesses though (eieio instructions)
Enclosed is an example of a little program I use to dump the radeon
registers
Ben.
[-- Attachment #2: radeondump.c --]
[-- Type: text/x-c, Size: 2339 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <byteswap.h>
void * mmio;
//#define RADEON_RBASE 0xe3000000
//#define RADEON_RBASE 0xb0000000
#define RADEON_RBASE 0x90000000
//#define RADEON_RBASE 0x90080000
static unsigned char regr8(volatile void *base, const unsigned long offset)
{
unsigned char val;
__asm__ __volatile__(
"lbzx %0,%1,%2\n\t"
"eieio"
: "=r" (val)
: "b" (base), "r" (offset),
"m" (*((volatile unsigned char *)base+offset)));
return(val);
}
static void regw8(volatile void *base, const unsigned long offset,
const unsigned char val)
{
__asm__ __volatile__ ("stbx %1,%2,%3\n\t"
"eieio"
: "=m" (*((volatile unsigned char *)base+offset))
: "r" (val), "b" (base), "r" (offset));
}
static unsigned int regr(volatile void *base, const unsigned long offset)
{
unsigned int val;
__asm__ __volatile__ ("lwbrx %0,%1,%2\n\t"
"eieio"
: "=r" (val)
: "b" (base), "r"(offset),
"m" (*((volatile unsigned char *)base+offset)));
return val;
}
static void regw(volatile void *base, const unsigned long offset,
const unsigned int val)
{
__asm__ __volatile__ ("stwbrx %1,%2,%3\n\t"
"eieio"
: "=m" (*((volatile unsigned char *)base+offset))
: "r"(val), "b"(base), "r"(offset));
}
static unsigned int pllr(volatile void *base, const unsigned long index)
{
unsigned int val;
regw8(base, 0x8, index & 0x3f);
return regr(base, 0xc);
}
unsigned long regs[0x800];
unsigned long pllregs[0x40];
int main() {
int fd, i;
fd = open("/dev/mem", O_RDWR);
mmio = (void *)mmap(0, 0x80000, PROT_READ|PROT_WRITE,
MAP_SHARED, fd, RADEON_RBASE);
for (i=0; i<0x800; i++)
regs[i] = regr(mmio, i*4);
for (i=0; i<0x40; i++)
pllregs[i] = pllr(mmio, i);
printf("Radeon MMIO registers:\n");
for (i=0; i<0x800; i++) {
if (regs[i] != 0)
printf("%04x : %08x\n", i*4, regs[i]);
}
printf("\nRadeon PLL registers:\n");
for (i=0; i<0x40; i++) {
if (pllregs[i] != 0)
printf(" %02x : %08x\n", i, pllregs[i]);
}
printf("\n");
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: userspace testing an ati fb driver
@ 2003-12-05 12:07 David Eger
2003-12-07 1:21 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: David Eger @ 2003-12-05 12:07 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list
I think this explains my problem; output from my reg dump:
Radeon MMIO registers:
0000 : 0000c081
0004 : 00313131
0008 : 3f000000
...
output from your reg dump:
Radeon MMIO registers:
0000 : 81c00000
0004 : 31313100
0008 : 0000003f
...
thanks a bunch.
-david
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: userspace testing an ati fb driver
2003-12-05 12:07 userspace testing an ati fb driver David Eger
@ 2003-12-07 1:21 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2003-12-07 1:21 UTC (permalink / raw)
To: David Eger; +Cc: linuxppc-dev list
On Fri, 2003-12-05 at 23:07, David Eger wrote:
> I think this explains my problem; output from my reg dump:
Are you properly endian-flipping register accesses ? My access
macro use the lwbrx/stwbrx instructions that to the endian flipping
automatically.
> Radeon MMIO registers:
> 0000 : 0000c081
> 0004 : 00313131
> 0008 : 3f000000
> ...
>
> output from your reg dump:
>
> Radeon MMIO registers:
> 0000 : 81c00000
> 0004 : 31313100
> 0008 : 0000003f
> ...
--
Benjamin Herrenschmidt <benh@kernel.crashing.org>
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-12-07 1:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-05 12:07 userspace testing an ati fb driver David Eger
2003-12-07 1:21 ` Benjamin Herrenschmidt
-- strict thread matches above, loose matches on Subject: below --
2003-12-03 9:44 random
2003-12-04 0:06 ` Benjamin Herrenschmidt
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).