From owner-freebsd-drivers@FreeBSD.ORG Sun Mar 13 20:13:49 2011 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96F5E1065670; Sun, 13 Mar 2011 20:13:49 +0000 (UTC) (envelope-from philip.s.schulz@googlemail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 3AA408FC15; Sun, 13 Mar 2011 20:13:48 +0000 (UTC) Received: by qyk27 with SMTP id 27so3612800qyk.13 for ; Sun, 13 Mar 2011 13:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=QdInNExF+MSQhbARAJ/ZemEoKLXTyOBEbJ4IlvQU0zk=; b=SCYdlTH7npCTRO1+Owmd9KILQjuj45LEPQs+gPpaJXQ5g7cCXFF12j/ZB+h4TiZ+81 Qlg8eNcrchVdAur++KUl8YVJ7sQ8ZkF82FwBwyOd5xe/JkEOYZ1kFpyOFSWXINU+4slU Cn8SCljmg4LAlYL1PKk2MGS1nD0AFuBcyxaRM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=INaPj0seNPKWONOseGAe3LaLZmFA8nT+POlxI3MR4D1uD8xmXZH8fLc2z9wllIXSZy orL2LPOkwS9N7vc/0rTX9rHEJsdCisjmDaIoMF57oGxuJEncq1SptLkZsDYV24zIAnbZ ZC1pd5aRHJO6GHuX38MrOI2cyoi31xXaZCDXA= MIME-Version: 1.0 Received: by 10.229.29.9 with SMTP id o9mr9455799qcc.58.1300045526209; Sun, 13 Mar 2011 12:45:26 -0700 (PDT) Received: by 10.229.185.146 with HTTP; Sun, 13 Mar 2011 12:45:26 -0700 (PDT) In-Reply-To: References: <3550EA55-ADDE-40AC-9C22-1FAC441A0BC8@freebsd.org> <0A707516-C7D1-4441-B17B-1273B6C256B0@FreeBSD.org> Date: Sun, 13 Mar 2011 20:45:26 +0100 Message-ID: From: Philip Schulz To: Henrik Brix Andersen Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-drivers@freebsd.org Subject: Re: Allocating resources to isab children X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Mar 2011 20:13:49 -0000 Hi Brix, 2011/3/13 Henrik Brix Andersen : [...] > Comments are more than welcome. I am still trying to figure out how to al= low children to allocate and setup interrupts through isab; any pointers to= what needs to be done in that regard are also very welcome since I'm not h= aving much luck with it so far... > I'm currently working on a driver for the exact same device, except I'm going for the I2C engine. Naturally, I'm facing some similar issues ;-) I created a new isab driver that attaches specifically to the relevant function in the CS5536 chip, mainly because I didn't want to modify the existing generic PCI-ISA bridge driver. In the attach routine of my isab driver, I used BUS_GET_RESOURCE_LIST() to obtain the list of resources that the parent PCI bus allocated for the device. On my system (Alix 1.C), that list contains the I/O ranges the device announces in the BARs. The bus_alloc_resource (and the bus_release_resource) method then checks whether said list contains the requested resource. If so, my isab driver requests the resource from the PCI bus and returns the requested resource to the requestor. If not, the request is passed through so it eventually ends up at the nexus device driver on x86. On my system, the resource list obtained from the PCI bus does not contain any interrupts. If I read the PCI bus code correctly, that's because the "Interrupt Pin" and "Interrupt Line" fields in the device's PCI config space are not set up. I didn't find any code that sets up those fields which leads me to believe that the fields should have been set up by the BIOS. As a result, my isab driver cannot request any interrupts from the PCI bus driver. However, that's not a problem because my I2C device driver ("glxiic") is a child of isa, not isab. So the tree is something like glxiix - isa - isab - pci - ... - nexus - root. If the glxiic driver request an interrupt resource, the request passes the isab driver at one point. Because the interrupt resource is not in the list mentioned above, the request is passed onto the parent, which is the PCI bus. The PCI bus will only handle those requests that come from direct children, so the request is again passed up. Eventually, the nexus device handles the request and the interrupt is allocated. As with other ISA device drivers, the interrupt number used by glxiic is set up via device.hints. However, the driver still needs to route the interrupt in the "Extended PIC" that is part of the CS5536 chip. I'm not sure if this is the right concept, but I found it to work out for my needs. Hope that helps, Phil.