From owner-freebsd-mips@FreeBSD.ORG Fri Jan 4 19:37:36 2013 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 52F61CDC; Fri, 4 Jan 2013 19:37:36 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by mx1.freebsd.org (Postfix) with ESMTP id BA54C37D; Fri, 4 Jan 2013 19:37:35 +0000 (UTC) Received: by mail-wg0-f48.google.com with SMTP id dt10so7591755wgb.3 for ; Fri, 04 Jan 2013 11:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=j9ODyJdry7YXRY/vCN45mgZAv3xHyl5XqongJXMutKw=; b=HBO0ggmnAk5HTqaNluNFujXUnyF/DaPXpCb5CL8k88yyr2fpmwBg29xMWeMTHs1R+4 U5yTOqGm1aRvtRynLkQ6ljdfDPLqZJGdYLlSYnZNx0PQQvHWBjrq4ulvzBJBBXI/ckNn pbLZHPZPwIkw2zPegESSk/RmFz9D0MAJuJz6dxCMcLaBF4ko/F5ZNoFYxqS7spskmyLY lGVSne/0SudSgiwbWpWcamQdI6E40vDRlXm5PZG4e3ZRQyWZYiSwaHd9CxDjCh1n337W HLb6Uxdm9EB6e0lDmmHtDv115JvnCQb1YfeK0rlYJOtCiUGuhSA6TTTL49buYhI7dkNP d2jw== MIME-Version: 1.0 Received: by 10.180.72.146 with SMTP id d18mr74616982wiv.33.1357328254384; Fri, 04 Jan 2013 11:37:34 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.217.57.9 with HTTP; Fri, 4 Jan 2013 11:37:34 -0800 (PST) In-Reply-To: References: Date: Fri, 4 Jan 2013 11:37:34 -0800 X-Google-Sender-Auth: b93C68o-OlAXluKjG3HDKCe50Vs Message-ID: Subject: Re: ath0: could not map interrupt From: Adrian Chadd To: Monthadar Al Jaberi Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-wireless@freebsd.org, freebsd-mips@freebsd.org X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2013 19:37:36 -0000 On 4 January 2013 11:24, Monthadar Al Jaberi wrote: > On Fri, Jan 4, 2013 at 8:13 PM, Adrian Chadd wrote: >> Ok. The magic you need to try hacking is in ar71xx_pci.c. There's the >> 7 PCI windows and the 3 interrupt lines that are configured. >> >> The IRQ only gets unmasked when a slot claims it as a resource. So >> you'll have to fiddle with that mapping a little. >> >> Look at ar71xx_pci_route_interrupt(). Maybe set it up so >> AR71XX_PCI_BASE_SLOT is 18 instead of 17? > > Works!!! :D Hah! Nice! > The slot is not the issue I think. The code seems to iterate through a > couple, and when one fails it just checks the other. What it seems is > wrong is that the interrupts are mapped wrong. > Linux assigned IRQ 0 to slot 18, while FreeBSD assignes IRQ 1. We need > a mapping just like openwrt. Code re-write? :D > > We need this: Slot 18 IRQ 0, Slot 19 IRQ 1, Slot 20 IRQ 2 > > I don't know really what "slots" are physcially. Does the PCI bridge > have many slots (ports)? It's .. slightly more screwed up than that. Well, kind of. You need to read up on a PCI bus primer to understand how it works. Remember, the hardware design tries to minimise the amount of custom hardware logic that you need - so the whole notion of PCI "slots" here is really just a set of bits in the upper part of the 32 bit physical address space. The interrupt lines are fixed - there's what, three of them that come off the AR71XX CPU (AR71XX_PCI_INTR_STATUS and AR71XX_PCI_INTR_MASK) and get wired to individual physical slots. I think we only get one wired to INTA on each physical slot. So yes, it depends upon how they've wired up the board. It sounds like mikroik wired "slot 18" (which is just a specific combination of high address pins) to INT0, "slot 19" to INT1, "slot 20" to INT2. Whereas the PB42 and Ubiquiti hardware wires it starting at "slot 17". Look at ar71xx_pci_make_addr() to see what the slot/func/bus/etc mapping to physical 32 bit address is. Note there's also a PCI window register set that maps the 32 bit physical addresses for each PCI slot to a KSEG space address that MIPS code can get at. So now that we've figured that out, please create a PR with the description of the problem and the solution, and we'll have to figure out the "right" way to teach the PCI glue code about this. Chances are we can just create a PCI bus hint that defaults to "17" that says where the slots start at. Then for the Mikrotik board we can start it at 18. Adrian