From 3fbbb3be4f7c68be03cac0e0ea9d05575225bbcd Mon Sep 17 00:00:00 2001 From: Monthadar Al Jaberi Date: Sun, 6 Jan 2013 20:50:31 +0000 Subject: [PATCH] Mips Atheros AR71XX: make PCI base slot configurable through hints. * Mikrotik RouterBoard 433AH have PCI slot 18 wired to INT0 on the PCI Bus. This is different from e.g. Atheros PB42 and Ubiquiti boards. * Check for hint hint.pcib.0.baseslot=X, where X is number of base slot; * If hint not supplied print a warning and use default AR71XX_PCI_BASE_SLOT; PR: kern/174978 Approved by: adrian (mentor) --- sys/mips/atheros/ar71xx_pci.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/mips/atheros/ar71xx_pci.c b/sys/mips/atheros/ar71xx_pci.c index 126537c3f4da..9b88f608873a 100644 --- a/sys/mips/atheros/ar71xx_pci.c +++ b/sys/mips/atheros/ar71xx_pci.c @@ -81,6 +81,7 @@ struct ar71xx_pci_softc { device_t sc_dev; int sc_busno; + int sc_baseslot; struct rman sc_mem_rman; struct rman sc_irq_rman; @@ -395,6 +396,16 @@ ar71xx_pci_attach(device_t dev) AR71XX_PCI_IRQ_END) != 0) panic("ar71xx_pci_attach: failed to set up IRQ rman"); + /* + * Check if there is a base slot hint. Otherwise use default value. + */ + if (resource_int_value(device_get_name(dev), + device_get_unit(dev), "baseslot", &sc->sc_baseslot) != 0) { + device_printf(dev, + "%s: missing hint '%s', default to AR71XX_PCI_BASE_SLOT\n", + __func__, "baseslot"); + sc->sc_baseslot = AR71XX_PCI_BASE_SLOT; + } ATH_WRITE_REG(AR71XX_PCI_INTR_STATUS, 0); ATH_WRITE_REG(AR71XX_PCI_INTR_MASK, 0); @@ -648,11 +659,13 @@ ar71xx_pci_maxslots(device_t dev) static int ar71xx_pci_route_interrupt(device_t pcib, device_t device, int pin) { - if (pci_get_slot(device) < AR71XX_PCI_BASE_SLOT) + struct ar71xx_pci_softc *sc = device_get_softc(pcib); + + if (pci_get_slot(device) < sc->sc_baseslot) panic("%s: PCI slot %d is less then AR71XX_PCI_BASE_SLOT", __func__, pci_get_slot(device)); - return (pci_get_slot(device) - AR71XX_PCI_BASE_SLOT); + return (pci_get_slot(device) - sc->sc_baseslot); } static device_method_t ar71xx_pci_methods[] = {