Re: midi problem, an isa device on a pci card

From: Mathew Kanner <mat_at_cnd.mcgill.ca>
Date: Sun, 6 Apr 2003 12:41:34 -0400
	Hello,
	I've recived no responses.  Anyway, the following includes my
own solution to the question, lots of trial and error.  I've found that
isahints was the closest exsting code to what I wanted. 
	As always, I would love to hear any comments.

> 	How do I create isa devices from a pci device.  Do I search up the
> soundcard tree for the pci bus then search down for the isa bus, then
> create_child(..."mpushim")?

	In pci device_attach:
isa=devclass_find("isa");
if( !isa ) {
	device_printf(sc->dev,"cmi midi error no devclass for isa\n");
	goto err;
}
if (devclass_get_devices(isa, &isalistp, &isacountp) != 0 ) {
	device_printf(sc->dev,"cmi midi error fetching isa devices\n");
	goto err;
}
if ( isacountp < 1 ) {
	device_printf(sc->dev,"cmi midi no isa busses found\n");
	goto err;
}
/*
 *      Be stupid and just pick the first isa bus
 */
sc->isadev = isalistp[0];
mpuisa=devclass_find("mpuisa");
if( !mpuisa ) {
	device_printf(sc->dev,"cmi: midi driver not found\n");
	goto err;
}
i = devclass_find_free_unit(mpuisa,0);
sc->mpudev = BUS_ADD_CHILD(sc->isadev, 1, "mpuisa", i);

	[Needs to be done with BUS_ADD_CHILD, I tried with others, m' yo
	they just don't work]

> 	How do I tell the shim before the probe/attach what io region to look
> at, do I fiddle with ivars (or some internal structure),  do I mess with hints
> via kenv(9) [Is there a kenv(9)? ]

	[ Say, p->port=0x300, then following would set it to 0x300-0x302 
	  and the same IRQ as the pci device ]

bus_set_resource(sc->mpudev, SYS_RES_IOPORT, 0, p->port, 2);
bus_set_resource(sc->mpudev, SYS_RES_IRQ, 0, rman_get_start(sc->irq), 1);
if( device_probe_and_attach(sc->mpudev) == 0 ) {
	device_printf(sc->dev,"added %s/%s\n", 
		device_get_nameunit(sc->isadev), 
		device_get_nameunit(sc->mpudev) );
   return ;
}


	Cheers,
	--Mat
-- 
Brain: Are you pondering what I'm pondering?
Pinky: I think so Brain, but the Rockettes, it's mostly girls, isn't it?
Received on Sun Apr 06 2003 - 07:39:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:02 UTC