From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 8 13:32:35 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C036137B404 for ; Fri, 8 Aug 2003 13:32:35 -0700 (PDT) Received: from mail.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0550343FE9 for ; Fri, 8 Aug 2003 13:32:35 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 28750 invoked from network); 8 Aug 2003 20:32:25 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender )encrypted SMTP for ; 8 Aug 2003 20:32:25 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.9/8.12.9) with ESMTP id h78KWN9s037907; Fri, 8 Aug 2003 16:32:23 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20030808195511.GD46866@cicely12.cicely.de> Date: Fri, 08 Aug 2003 16:32:43 -0400 (EDT) From: John Baldwin To: ticso@cicely.de cc: ticso@cicely12.cicely.de cc: freebsd-hackers@FreeBSD.org cc: Poul-Henning Kamp Subject: Re: How to get a device_t X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Aug 2003 20:32:36 -0000 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 <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/