* 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