Subject: finding the address of a chip
To: None <port-sparc@NetBSD.ORG>
From: Iain Hibbert <plunky@skate.demon.co.uk>
List: port-sparc
Date: 10/13/1997 18:31:31
hi!

after a long time farting about, I seem to have started writing a device
driver..   I'm having a bit of difficulty finding the chip though, can 
anybody advise?  here is the story so far.

I have the hardware (its a Magma LC2+1Sp card) and it is basically as far as
I could see a CL-CD1400 chip that runs the show.  I have the data book for
the CD1400, and I have a couple of drivers for other CD1400 boards on other
platforms etc that will help me greatly in writing the driver, if only I can
find where the chip registers are to twiddle their bits. 

I gather from looking at the source of other drivers, and header files etc
that in the attach function, like so: 

void
magmaattach(parent, dev, args) 
struct device *parent;
struct device *dev;
void *args;
{
register struct magma_softc *ms = (struct magma_softc *)dev;
register struct confargs *ca = args;
	
	ms->cd1400 = mapiodev(ca->ca_ra.ra_reg, 0, 0xff, ca->ca_bustype);

...I need to use mapiodev to mark the chip registers (if I only knew 
where they were) as part of the device/kernel memory map..?

in the romaux structure in the confargs structure, there is an array of
registers, which I have printed out some informationn (in the match function)
and present here.. 

magma: matched `MAGMA_Sp', node 0xffec0acc, nvaddrs 0, nreg 1, nintr 1
magma: reg  0; ra_iospace = 1, ra_paddr = 0xfc000000, ra_len = 65536
magma: intr 0; pri = 7, vec = 0

my guess is that the this means that there was 1 register set and 1
interrupt, the register set was at 0xfc0000000 and this is what would
be being passed to mapiodev (along with the lenght of it? I used 0xff as 
there were only 7 address lines on the chip)

when I have mapped it, the return from mapiodev is 0xfe024000 so I recompiled
my kernel with DDB on and went around again - dropped into ddb and started
poking around to see if I can verify that the chip registers are there.

they aren't as far as I can tell, so I'm stuck - can anybody advise me where
I might have gone wrong?

iain

PS I haven't really been paying much attention to the port-sparc list
recently, but I recall somebody was asking about parallel ports not long ago
- the Magma card is a high speed serial/parallel card so if I get it going,
then there will be a parallel port available.