2000-10-28 06:59:48 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2000 Michael Smith
|
|
|
|
* Copyright (c) 2000 BSDi
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2003-08-24 17:55:58 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-10-28 06:59:48 +00:00
|
|
|
#include "opt_acpi.h"
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/bus.h>
|
2001-07-05 07:20:51 +00:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2009-06-05 18:44:36 +00:00
|
|
|
#include <contrib/dev/acpica/include/acpi.h>
|
|
|
|
#include <contrib/dev/acpica/include/accommon.h>
|
|
|
|
|
2000-10-28 06:59:48 +00:00
|
|
|
#include <dev/acpica/acpivar.h>
|
2002-08-26 18:30:27 +00:00
|
|
|
#include <dev/acpica/acpi_pcibvar.h>
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2003-08-22 06:06:16 +00:00
|
|
|
#include <dev/pci/pcivar.h>
|
2000-10-28 06:59:48 +00:00
|
|
|
#include "pcib_if.h"
|
|
|
|
|
2004-03-22 20:32:27 +00:00
|
|
|
/* Hooks for the ACPI CA debugging infrastructure. */
|
2001-06-29 20:32:29 +00:00
|
|
|
#define _COMPONENT ACPI_BUS
|
2002-02-23 05:27:49 +00:00
|
|
|
ACPI_MODULE_NAME("PCI")
|
2000-12-08 09:16:20 +00:00
|
|
|
|
2004-08-13 06:22:07 +00:00
|
|
|
ACPI_SERIAL_DECL(pcib, "ACPI PCI bus methods");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For locking, we assume the caller is not concurrent since this is
|
|
|
|
* triggered by newbus methods.
|
|
|
|
*/
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
|
|
|
|
struct prt_lookup_request {
|
|
|
|
ACPI_PCI_ROUTING_TABLE *pr_entry;
|
|
|
|
u_int pr_pin;
|
|
|
|
u_int pr_slot;
|
|
|
|
};
|
2004-12-27 05:36:47 +00:00
|
|
|
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
typedef void prt_entry_handler(ACPI_PCI_ROUTING_TABLE *entry, void *arg);
|
|
|
|
|
|
|
|
static void prt_attach_devices(ACPI_PCI_ROUTING_TABLE *entry, void *arg);
|
|
|
|
static void prt_lookup_device(ACPI_PCI_ROUTING_TABLE *entry, void *arg);
|
|
|
|
static void prt_walk_table(ACPI_BUFFER *prt, prt_entry_handler *handler,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
static void
|
|
|
|
prt_walk_table(ACPI_BUFFER *prt, prt_entry_handler *handler, void *arg)
|
|
|
|
{
|
|
|
|
ACPI_PCI_ROUTING_TABLE *entry;
|
|
|
|
char *prtptr;
|
|
|
|
|
|
|
|
/* First check to see if there is a table to walk. */
|
|
|
|
if (prt == NULL || prt->Pointer == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Walk the table executing the handler function for each entry. */
|
|
|
|
prtptr = prt->Pointer;
|
|
|
|
entry = (ACPI_PCI_ROUTING_TABLE *)prtptr;
|
|
|
|
while (entry->Length != 0) {
|
|
|
|
handler(entry, arg);
|
|
|
|
prtptr += entry->Length;
|
|
|
|
entry = (ACPI_PCI_ROUTING_TABLE *)prtptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
prt_attach_devices(ACPI_PCI_ROUTING_TABLE *entry, void *arg)
|
|
|
|
{
|
|
|
|
ACPI_HANDLE handle;
|
|
|
|
device_t child, pcib;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* We only care about entries that reference a link device. */
|
|
|
|
if (entry->Source == NULL || entry->Source[0] == '\0')
|
|
|
|
return;
|
|
|
|
|
2005-11-07 21:48:45 +00:00
|
|
|
/*
|
|
|
|
* In practice, we only see SourceIndex's of 0 out in the wild.
|
|
|
|
* When indices != 0 have been found, they've been bugs in the ASL.
|
|
|
|
*/
|
|
|
|
if (entry->SourceIndex != 0)
|
|
|
|
return;
|
|
|
|
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
/* Lookup the associated handle and device. */
|
|
|
|
pcib = (device_t)arg;
|
2005-01-18 20:20:32 +00:00
|
|
|
if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, entry->Source, &handle)))
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
return;
|
|
|
|
child = acpi_get_device(handle);
|
|
|
|
if (child == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If the device hasn't been probed yet, force it to do so. */
|
|
|
|
error = device_probe_and_attach(child);
|
|
|
|
if (error != 0) {
|
2005-01-27 20:49:59 +00:00
|
|
|
device_printf(pcib, "failed to force attach of %s\n",
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
acpi_name(handle));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a reference for a specific bus/device/pin tuple. */
|
|
|
|
acpi_pci_link_add_reference(child, entry->SourceIndex, pcib,
|
|
|
|
ACPI_ADR_PCI_SLOT(entry->Address), entry->Pin);
|
|
|
|
}
|
|
|
|
|
2002-08-26 18:30:27 +00:00
|
|
|
int
|
|
|
|
acpi_pcib_attach(device_t dev, ACPI_BUFFER *prt, int busno)
|
2000-10-28 06:59:48 +00:00
|
|
|
{
|
|
|
|
ACPI_STATUS status;
|
2000-12-08 09:16:20 +00:00
|
|
|
|
2002-05-19 06:16:47 +00:00
|
|
|
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't attach if we're not really there.
|
|
|
|
*
|
2002-08-26 18:30:27 +00:00
|
|
|
* XXX: This isn't entirely correct since we may be a PCI bus
|
2000-10-28 06:59:48 +00:00
|
|
|
* on a hot-plug docking station, etc.
|
|
|
|
*/
|
|
|
|
if (!acpi_DeviceIsPresent(dev))
|
2000-12-08 09:16:20 +00:00
|
|
|
return_VALUE(ENXIO);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2001-07-05 07:20:51 +00:00
|
|
|
/*
|
2004-03-22 20:32:27 +00:00
|
|
|
* Get the PCI interrupt routing table for this bus. If we can't
|
2004-11-11 22:33:08 +00:00
|
|
|
* get it, this is not an error but may reduce functionality. There
|
|
|
|
* are several valid bridges in the field that do not have a _PRT, so
|
|
|
|
* only warn about missing tables if bootverbose is set.
|
2001-07-05 07:20:51 +00:00
|
|
|
*/
|
2002-08-26 18:30:27 +00:00
|
|
|
prt->Length = ACPI_ALLOCATE_BUFFER;
|
|
|
|
status = AcpiGetIrqRoutingTable(acpi_get_handle(dev), prt);
|
2004-11-11 22:33:08 +00:00
|
|
|
if (ACPI_FAILURE(status) && (bootverbose || status != AE_NOT_FOUND))
|
2002-10-04 00:32:09 +00:00
|
|
|
device_printf(dev,
|
|
|
|
"could not get PCI interrupt routing table for %s - %s\n",
|
|
|
|
acpi_name(acpi_get_handle(dev)), AcpiFormatException(status));
|
2001-07-05 07:20:51 +00:00
|
|
|
|
2000-12-01 10:18:57 +00:00
|
|
|
/*
|
|
|
|
* Attach the PCI bus proper.
|
2000-10-28 06:59:48 +00:00
|
|
|
*/
|
2008-11-25 19:06:20 +00:00
|
|
|
if (device_add_child(dev, "pci", busno) == NULL) {
|
2002-10-29 19:08:55 +00:00
|
|
|
device_printf(device_get_parent(dev), "couldn't attach pci bus\n");
|
2000-12-08 09:16:20 +00:00
|
|
|
return_VALUE(ENXIO);
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-12-02 01:14:14 +00:00
|
|
|
* Now go scan the bus.
|
2000-10-28 06:59:48 +00:00
|
|
|
*/
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
prt_walk_table(prt, prt_attach_devices, dev);
|
2004-03-22 20:32:27 +00:00
|
|
|
|
|
|
|
return_VALUE (bus_generic_attach(dev));
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
|
|
|
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
static void
|
|
|
|
prt_lookup_device(ACPI_PCI_ROUTING_TABLE *entry, void *arg)
|
|
|
|
{
|
|
|
|
struct prt_lookup_request *pr;
|
|
|
|
|
|
|
|
pr = (struct prt_lookup_request *)arg;
|
|
|
|
if (pr->pr_entry != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare the slot number (high word of Address) and pin number
|
|
|
|
* (note that ACPI uses 0 for INTA) to check for a match.
|
|
|
|
*
|
|
|
|
* Note that the low word of the Address field (function number)
|
|
|
|
* is required by the specification to be 0xffff. We don't risk
|
|
|
|
* checking it here.
|
|
|
|
*/
|
|
|
|
if (ACPI_ADR_PCI_SLOT(entry->Address) == pr->pr_slot &&
|
|
|
|
entry->Pin == pr->pr_pin)
|
|
|
|
pr->pr_entry = entry;
|
|
|
|
}
|
|
|
|
|
2001-07-05 07:20:51 +00:00
|
|
|
/*
|
|
|
|
* Route an interrupt for a child of the bridge.
|
|
|
|
*/
|
2002-08-26 18:30:27 +00:00
|
|
|
int
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin,
|
|
|
|
ACPI_BUFFER *prtbuf)
|
2000-10-28 06:59:48 +00:00
|
|
|
{
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
ACPI_PCI_ROUTING_TABLE *prt;
|
|
|
|
struct prt_lookup_request pr;
|
|
|
|
ACPI_HANDLE lnkdev;
|
|
|
|
int interrupt;
|
2001-08-26 22:50:15 +00:00
|
|
|
|
2002-05-19 06:16:47 +00:00
|
|
|
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
2004-08-11 14:52:50 +00:00
|
|
|
|
2004-06-07 17:36:22 +00:00
|
|
|
interrupt = PCI_INVALID_IRQ;
|
2001-07-05 07:20:51 +00:00
|
|
|
|
2004-03-22 20:32:27 +00:00
|
|
|
/* ACPI numbers pins 0-3, not 1-4 like the BIOS. */
|
2001-07-05 07:20:51 +00:00
|
|
|
pin--;
|
|
|
|
|
2004-08-13 06:22:07 +00:00
|
|
|
ACPI_SERIAL_BEGIN(pcib);
|
|
|
|
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
/* Search for a matching entry in the routing table. */
|
|
|
|
pr.pr_entry = NULL;
|
|
|
|
pr.pr_pin = pin;
|
|
|
|
pr.pr_slot = pci_get_slot(dev);
|
|
|
|
prt_walk_table(prtbuf, prt_lookup_device, &pr);
|
2005-03-08 17:22:11 +00:00
|
|
|
if (pr.pr_entry == NULL) {
|
2005-12-02 13:35:14 +00:00
|
|
|
device_printf(pcib, "no PRT entry for %d.%d.INT%c\n", pci_get_bus(dev),
|
2005-03-08 17:22:11 +00:00
|
|
|
pci_get_slot(dev), 'A' + pin);
|
|
|
|
goto out;
|
|
|
|
}
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
prt = pr.pr_entry;
|
2005-03-08 17:22:11 +00:00
|
|
|
|
2004-08-12 17:04:19 +00:00
|
|
|
if (bootverbose) {
|
|
|
|
device_printf(pcib, "matched entry for %d.%d.INT%c",
|
|
|
|
pci_get_bus(dev), pci_get_slot(dev), 'A' + pin);
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
if (prt->Source != NULL && prt->Source[0] != '\0')
|
|
|
|
printf(" (src %s:%u)", prt->Source, prt->SourceIndex);
|
2004-08-12 17:04:19 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
2001-07-05 07:20:51 +00:00
|
|
|
|
|
|
|
/*
|
2004-08-11 14:52:50 +00:00
|
|
|
* If source is empty/NULL, the source index is a global IRQ number
|
|
|
|
* and it's hard-wired so we're done.
|
2005-11-07 21:48:45 +00:00
|
|
|
*
|
|
|
|
* XXX: If the source index is non-zero, ignore the source device and
|
|
|
|
* assume that this is a hard-wired entry.
|
2001-07-05 07:20:51 +00:00
|
|
|
*/
|
2005-11-07 21:48:45 +00:00
|
|
|
if (prt->Source == NULL || prt->Source[0] == '\0' ||
|
|
|
|
prt->SourceIndex != 0) {
|
2001-10-07 18:25:43 +00:00
|
|
|
if (bootverbose)
|
2004-08-11 14:52:50 +00:00
|
|
|
device_printf(pcib, "slot %d INT%c hardwired to IRQ %d\n",
|
|
|
|
pci_get_slot(dev), 'A' + pin, prt->SourceIndex);
|
2005-12-03 21:17:17 +00:00
|
|
|
if (prt->SourceIndex) {
|
2004-08-11 14:52:50 +00:00
|
|
|
interrupt = prt->SourceIndex;
|
2005-12-03 21:17:17 +00:00
|
|
|
BUS_CONFIG_INTR(dev, interrupt, INTR_TRIGGER_LEVEL,
|
|
|
|
INTR_POLARITY_LOW);
|
|
|
|
} else
|
2004-08-11 14:52:50 +00:00
|
|
|
device_printf(pcib, "error: invalid hard-wired IRQ of 0\n");
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
/*
|
|
|
|
* We have to find the source device (PCI interrupt link device).
|
2001-07-05 07:20:51 +00:00
|
|
|
*/
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, prt->Source, &lnkdev))) {
|
|
|
|
device_printf(pcib, "couldn't find PCI interrupt link device %s\n",
|
|
|
|
prt->Source);
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
interrupt = acpi_pci_link_route_interrupt(acpi_get_device(lnkdev),
|
|
|
|
prt->SourceIndex);
|
2004-03-22 20:32:27 +00:00
|
|
|
|
2004-08-11 14:52:50 +00:00
|
|
|
if (bootverbose && PCI_INTERRUPT_VALID(interrupt))
|
2004-07-01 07:46:29 +00:00
|
|
|
device_printf(pcib, "slot %d INT%c routed to irq %d via %s\n",
|
Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices. The devices
are called pci_linkX. The driver includes suspend/resume support so that
the ACPI bridge drivers no longer have to poke the links to get them
to handle suspend/resume. Also, the code to handle which IRQs a link is
routed to and choosing an IRQ when a link is not already routed is all
contained in the link driver. The PCI bridge drivers now ask the link
driver which IRQ to use once they determine that a _PRT entry does not
use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
link device as well as preserving any non-IRQ resources when adjusting
the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
link-centric rather than pci bus/device/pin specific. Thus, when
using a tunable to override the default IRQ settings, one now uses
a single tunable to route an entire link rather than routing a single
device that uses the link (which has great foot-shooting potential if
the user tries to route the same link to two different IRQs using two
different pci bus/device/pin hints). For example, to adjust the IRQ
that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
loader.
- As a side effect of having the link driver, unused link devices will now
be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
IRQ assigned is now much closer to the one used in $PIR routing. When a
link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
already used are used for routing instead of using probabilities to
guess at which IRQs are probably not used by an ISA device. One change
from $PIR is that the SCI is always considered a viable ISA IRQ, so that
if the BIOS does not setup any IRQs the kernel will degenerate to routing
all interrupts over the SCI. For non ISA IRQs, interrupts are picked
from the possible pool using a simplistic weighting algorithm.
Tested by: ru, scottl, others on acpi@
Reviewed by: njl
2004-11-23 22:26:44 +00:00
|
|
|
pci_get_slot(dev), 'A' + pin, interrupt, acpi_name(lnkdev));
|
2001-07-05 07:20:51 +00:00
|
|
|
|
2004-03-22 20:32:27 +00:00
|
|
|
out:
|
2004-08-13 06:22:07 +00:00
|
|
|
ACPI_SERIAL_END(pcib);
|
2001-07-05 07:20:51 +00:00
|
|
|
|
2004-03-22 20:32:27 +00:00
|
|
|
return_VALUE (interrupt);
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
2010-08-17 15:44:52 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
acpi_pcib_power_for_sleep(device_t pcib, device_t dev, int *pstate)
|
|
|
|
{
|
|
|
|
device_t acpi_dev;
|
|
|
|
|
|
|
|
acpi_dev = devclass_get_device(devclass_find("acpi"), 0);
|
|
|
|
acpi_device_pwr_for_sleep(acpi_dev, dev, pstate);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|