diff options
author | 2020-05-08 11:18:01 +0000 | |
---|---|---|
committer | 2020-05-08 11:18:01 +0000 | |
commit | f09f3dbfab507baeedb875f13dfb88090e7c70d5 (patch) | |
tree | 65c232c06b96eca0c99a91b5eb8b024564153102 /sys/dev/acpi/pluart_acpi.c | |
parent | Make sure cmsgbufs are properly aligned by using the idiom from the (diff) | |
download | wireguard-openbsd-f09f3dbfab507baeedb875f13dfb88090e7c70d5.tar.xz wireguard-openbsd-f09f3dbfab507baeedb875f13dfb88090e7c70d5.zip |
Move parsing of _CRS into acpi(4) and pass the parsed address and interrupt
information in struct acpi_attach_args.
ok mpi@
Diffstat (limited to 'sys/dev/acpi/pluart_acpi.c')
-rw-r--r-- | sys/dev/acpi/pluart_acpi.c | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/sys/dev/acpi/pluart_acpi.c b/sys/dev/acpi/pluart_acpi.c index 7b622668284..4c531187407 100644 --- a/sys/dev/acpi/pluart_acpi.c +++ b/sys/dev/acpi/pluart_acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pluart_acpi.c,v 1.3 2018/08/25 09:39:20 kettenis Exp $ */ +/* $OpenBSD: pluart_acpi.c,v 1.4 2020/05/08 11:18:01 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -34,13 +34,8 @@ struct pluart_acpi_softc { struct pluart_softc sc; struct acpi_softc *sc_acpi; struct aml_node *sc_node; - - bus_addr_t sc_addr; - bus_size_t sc_size; - - int sc_irq; - int sc_irq_flags; - void *sc_ih; + bus_addr_t sc_addr; + void *sc_ih; }; int pluart_acpi_match(struct device *, void *, void *); @@ -55,7 +50,6 @@ const char *pluart_hids[] = { NULL }; -int pluart_acpi_parse_resources(int, union acpi_resource *, void *); int pluart_acpi_is_console(struct pluart_acpi_softc *); int @@ -70,37 +64,36 @@ pluart_acpi_match(struct device *parent, void *match, void *aux) void pluart_acpi_attach(struct device *parent, struct device *self, void *aux) { - struct acpi_attach_args *aaa = aux; struct pluart_acpi_softc *sc = (struct pluart_acpi_softc *)self; - struct aml_value res; + struct acpi_attach_args *aaa = aux; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_node = aaa->aaa_node; printf(" %s", sc->sc_node->name); - if (aml_evalname(sc->sc_acpi, sc->sc_node, "_CRS", 0, NULL, &res)) { - printf(": can't find registers\n"); + if (aaa->aaa_naddr < 1) { + printf(": no registers\n"); return; } - aml_parse_resource(&res, pluart_acpi_parse_resources, sc); - printf(" addr 0x%lx/0x%lx", sc->sc_addr, sc->sc_size); - if (sc->sc_addr == 0 || sc->sc_size == 0) { - printf("\n"); + if (aaa->aaa_nirq < 1) { + printf(": no interrupt\n"); return; } - printf(" irq %d", sc->sc_irq); + printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]); + printf(" irq %d", aaa->aaa_irq[0]); - sc->sc.sc_iot = aaa->aaa_memt; - if (bus_space_map(sc->sc.sc_iot, sc->sc_addr, sc->sc_size, 0, - &sc->sc.sc_ioh)) { + sc->sc.sc_iot = aaa->aaa_bst[0]; + sc->sc_addr = aaa->aaa_addr[0]; + if (bus_space_map(sc->sc.sc_iot, aaa->aaa_addr[0], aaa->aaa_size[0], + 0, &sc->sc.sc_ioh)) { printf(": can't map registers\n"); return; } - sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_TTY, - pluart_intr, sc, sc->sc.sc_dev.dv_xname); + sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0], + IPL_TTY, pluart_intr, sc, sc->sc.sc_dev.dv_xname); if (sc->sc_ih == NULL) { printf(": can't establish interrupt\n"); return; @@ -110,26 +103,6 @@ pluart_acpi_attach(struct device *parent, struct device *self, void *aux) } int -pluart_acpi_parse_resources(int crsidx, union acpi_resource *crs, void *arg) -{ - struct pluart_acpi_softc *sc = arg; - int type = AML_CRSTYPE(crs); - - switch (type) { - case LR_MEM32FIXED: - sc->sc_addr = crs->lr_m32fixed._bas; - sc->sc_size = crs->lr_m32fixed._len; - break; - case LR_EXTIRQ: - sc->sc_irq = crs->lr_extirq.irq[0]; - sc->sc_irq_flags = crs->lr_extirq.flags; - break; - } - - return 0; -} - -int pluart_acpi_is_console(struct pluart_acpi_softc *sc) { struct acpi_table_header *hdr; |