diff options
author | Jordan Hargrave <jordan@cvs.openbsd.org> | 2010-06-29 23:44:35 +0000 |
---|---|---|
committer | Jordan Hargrave <jordan@cvs.openbsd.org> | 2010-06-29 23:44:35 +0000 |
commit | 2964132324c636e01cdf6e269d23f78656a2b6ef (patch) | |
tree | bcc3c6a62c44f158d1dcfac24c37195e509f472a /sys/dev/acpi | |
parent | 6d13124cf127abfab2fa25160b42afb4b76f8a7e (diff) |
Use new ACPI PCI mapping to get _PRT bus
Delete old unused code
ok kettenis
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r-- | sys/dev/acpi/acpiprt.c | 85 |
1 files changed, 5 insertions, 80 deletions
diff --git a/sys/dev/acpi/acpiprt.c b/sys/dev/acpi/acpiprt.c index 94abf7319de..92c643003ab 100644 --- a/sys/dev/acpi/acpiprt.c +++ b/sys/dev/acpi/acpiprt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiprt.c,v 1.35 2009/03/31 20:59:00 kettenis Exp $ */ +/* $OpenBSD: acpiprt.c,v 1.36 2010/06/29 23:44:34 jordan Exp $ */ /* * Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org> * @@ -56,7 +56,6 @@ SIMPLEQ_HEAD(, acpiprt_map) acpiprt_map_list = int acpiprt_match(struct device *, void *, void *); void acpiprt_attach(struct device *, struct device *, void *); int acpiprt_getirq(union acpi_resource *crs, void *arg); -int acpiprt_getminbus(union acpi_resource *, void *); int acpiprt_chooseirq(union acpi_resource *, void *); struct acpiprt_softc { @@ -297,7 +296,7 @@ acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v) if ((p = malloc(sizeof(*p), M_ACPI, M_NOWAIT)) == NULL) return; p->bus = sc->sc_bus; - p->dev = ACPI_PCI_DEV(addr << 16); + p->dev = ACPI_ADR_PCIDEV(addr); p->pin = pin; p->irq = irq; p->sc = sc; @@ -365,85 +364,11 @@ acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v) } int -acpiprt_getminbus(union acpi_resource *crs, void *arg) -{ - int *bbn = arg; - int typ = AML_CRSTYPE(crs); - - /* Check for embedded bus number */ - if (typ == LR_WORD && crs->lr_word.type == 2) - *bbn = crs->lr_word._min; - return 0; -} - -int acpiprt_getpcibus(struct acpiprt_softc *sc, struct aml_node *node) { - struct aml_node *parent = node->parent; - struct aml_value res; - pci_chipset_tag_t pc = NULL; - pcitag_t tag; - pcireg_t reg; - int bus, dev, func, rv; - int64_t ires; - - if (parent == NULL) - return 0; - - /* - * If our parent is a a bridge, it might have an address descriptor - * that tells us our bus number. - */ - if (aml_evalname(sc->sc_acpi, parent, "_CRS.", 0, NULL, &res) == 0) { - rv = -1; - if (res.type == AML_OBJTYPE_BUFFER) - aml_parse_resource(res.length, res.v_buffer, - acpiprt_getminbus, &rv); - aml_freevalue(&res); - if (rv != -1) - return rv; - } - - /* - * If our parent is the root of the bus, it should specify the - * base bus number. - */ - if (aml_evalinteger(sc->sc_acpi, parent, "_BBN.", 0, NULL, &ires) == 0) { - return (ires); - } - - /* - * If our parent is a PCI-PCI bridge, get our bus number from its - * PCI config space. - */ - if (aml_evalinteger(sc->sc_acpi, parent, "_ADR.", 0, NULL, &ires) == 0) { - bus = acpiprt_getpcibus(sc, parent); - dev = ACPI_PCI_DEV(ires << 16); - func = ACPI_PCI_FN(ires << 16); - - /* - * Some systems return 255 as the device number for - * devices that are not really there. - */ - if (dev >= pci_bus_maxdevs(pc, bus)) - return (-1); - - tag = pci_make_tag(pc, bus, dev, func); - - /* Check whether the device is really there. */ - reg = pci_conf_read(pc, tag, PCI_ID_REG); - if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID) - return (-1); - - /* Fetch bus number from PCI config space. */ - reg = pci_conf_read(pc, tag, PCI_CLASS_REG); - if (PCI_CLASS(reg) == PCI_CLASS_BRIDGE && - PCI_SUBCLASS(reg) == PCI_SUBCLASS_BRIDGE_PCI) { - reg = pci_conf_read(pc, tag, PPB_REG_BUSINFO); - return (PPB_BUSINFO_SECONDARY(reg)); - } - } - return (0); + /* Check if parent device has PCI mapping */ + return (node->parent && node->parent->pci) ? + node->parent->pci->sub : -1; } void |