How to get a device_t

John Baldwin jhb at FreeBSD.org
Fri Aug 8 13:32:36 PDT 2003


On 08-Aug-2003 Bernd Walter wrote:
> On Fri, Aug 08, 2003 at 03:48:22PM -0400, John Baldwin wrote:
>> 
>> On 08-Aug-2003 Bernd Walter wrote:
>> > On Fri, Aug 08, 2003 at 02:27:30PM -0400, John Baldwin wrote:
>> >> Well, that would be a major pain on current since nexus is already
>> >> finished attaching many of its drivers by the time it gets to here.
>> >> Also, if you use ACPI and if ACPI exists, then this function _won't_
>> >> _ever_ _be_ _called_.  If you use a hostb PCI driver, then it will
>> >> work both for ACPI and legacy.
>> > 
>> > I agree with this point and if I understood correct this is what
>> > John Birrel already had done.
>> 
>> No, he is still working in the nexus/pcib driver's identify routine,
>> not in a separate 'hostb' PCI driver.
>> 
>> > However - I would still like to know why
>> > device_add_child(nexus, "elanbb", -1);
>> > results in an elanbb instance numer 1 connected to pci0.
>> > And why I don't get any iicbb childs.
>> 
>> I would have to see your code changes in order to try to tell you that.
> 
> http://www.cosmo-project.de/~bernd/elanbb.diff

First off, the iicbb driver does not know have an elanbb attachment.
You need a set of driver methods and corresponding

DRIVER_MODULE(iicbb, elanbb, ...)

For the iicbb child of elanbb to get a driver that probes it and attaches
to it.

Hmm, what you want to do is not hijack the legacy/pcib identify
routine I think, but add an identify routine to your elanbb driver
and have elanbb live off the nexus (so DRIVER_MODULE(elan, nexus))
and have its identify routine use pci_cfgreg() to get the devid for
device 0 and if it is the right one call init_AMD_Elan_sc520() and
add it's probe routine.  Or rather.  I've fixed all this and you can
get the changes (whcih should fix bogus elanbb0 and make iicbb0 show
up) at http://www.freebsd.org/~jhb/patches/elan.patch  It includes
your patch above but fixes a few things.  One other bug I fixed is
that since yout elan was hung off of pci and had an empty probe
routine, any unclaimed PCI device got "claimed" by your elanbb driver,
hence your bogus elanbb0.  Note that the version of elanbb in
elan.patch uses a private identify routine that calls
init_AMD_Elan_sc250(), so it will work both with and without ACPI.
However, the warning printf about CPU_ELAN won't show up with ACPI.
I left the printf in pci_bus.c for now.  A better place to put it would
be in the hostb driver itself.  Well, I went ahead and did that too,
so now the warning will show up both for ACPI and non-ACPI systems.

-- 

John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


More information about the freebsd-hackers mailing list