Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jan 2013 11:37:34 -0800
From:      Adrian Chadd <adrian@freebsd.org>
To:        Monthadar Al Jaberi <monthadar@gmail.com>
Cc:        freebsd-wireless@freebsd.org, freebsd-mips@freebsd.org
Subject:   Re: ath0: could not map interrupt
Message-ID:  <CAJ-VmokD99h78ys3regxH4QoVMM8aYE_uqC6DV7TNRnEdexyyg@mail.gmail.com>
In-Reply-To: <CA%2BsBSoKSqODze7VxsP-vN1D93K=4YYy7mc3PUHvnuuO1zy32Sw@mail.gmail.com>
References:  <CA%2BsBSoKs9s0SxAOyf91pcPv0MZMx3LCHh%2B_dTN-2mEQdYdH45g@mail.gmail.com> <CA%2BsBSo%2BpxqvWkrMjd8pmJSYUBdr0HuMW4eARJFcaFrG5tEYqBg@mail.gmail.com> <CAJ-Vmon%2BGzpXYkfE%2Bu7CDoXqmpH=zeJPcQdrukxAa9QH-2GazQ@mail.gmail.com> <CA%2BsBSoJg%2B%2BNo1ApSfUVnh1dDVgqEUPLpFJZPv3Ac%2BvaMno01sQ@mail.gmail.com> <CA%2BsBSoJY7AHjN=cMv6sfXHF4R0_z60c4q9BXEo20jCq6BJGEPg@mail.gmail.com> <CA%2BsBSoJgO6VWwc_43_SkThxG1ZcRh6iEJZdZ3yandNfEd8LNZw@mail.gmail.com> <CAJ-Vmon5pe4-7wN_0b46hyK-jiojaKC=7BWeCLH6L_viTsochg@mail.gmail.com> <CA%2BsBSoK519AFeHRXNPFozzmiToDW-dK%2B4NL-M-JDvpzrdEQkLw@mail.gmail.com> <CAJ-Vmo=_rakJQu5o1E63BcC34t%2Bd36a75qBmaFYz1R4vveZ0EQ@mail.gmail.com> <CA%2BsBSoKSqODze7VxsP-vN1D93K=4YYy7mc3PUHvnuuO1zy32Sw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4 January 2013 11:24, Monthadar Al Jaberi <monthadar@gmail.com> wrote:
> On Fri, Jan 4, 2013 at 8:13 PM, Adrian Chadd <adrian@freebsd.org> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-VmokD99h78ys3regxH4QoVMM8aYE_uqC6DV7TNRnEdexyyg>