diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-05-22 10:16:38 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-05-22 10:16:38 +0000 |
commit | 50fc807852de50221ac1d5eabdb4a17f6c104f84 (patch) | |
tree | ca7eb4a97e4d15c2083850d0301f31195b8d7f9f /sys/dev/acpi | |
parent | 197dec868ec7c331c691e22cc38ee29d1517262f (diff) |
Use the parsed address and interrupt information from
struct acpi_attach_args.
tpm(4) tested by kn@
ok jmatthew@
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r-- | sys/dev/acpi/amdgpio.c | 84 | ||||
-rw-r--r-- | sys/dev/acpi/aplgpio.c | 87 | ||||
-rw-r--r-- | sys/dev/acpi/bytgpio.c | 87 | ||||
-rw-r--r-- | sys/dev/acpi/chvgpio.c | 78 | ||||
-rw-r--r-- | sys/dev/acpi/glkgpio.c | 86 | ||||
-rw-r--r-- | sys/dev/acpi/tpm.c | 96 |
6 files changed, 140 insertions, 378 deletions
diff --git a/sys/dev/acpi/amdgpio.c b/sys/dev/acpi/amdgpio.c index 5971fd44508..f82a982076c 100644 --- a/sys/dev/acpi/amdgpio.c +++ b/sys/dev/acpi/amdgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amdgpio.c,v 1.2 2020/01/26 00:11:42 jsg Exp $ */ +/* $OpenBSD: amdgpio.c,v 1.3 2020/05/22 10:16:37 kettenis Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * Copyright (c) 2019 James Hastings @@ -55,10 +55,6 @@ struct amdgpio_softc { bus_space_tag_t sc_memt; bus_space_handle_t sc_memh; - bus_addr_t sc_addr; - bus_size_t sc_size; - - int sc_irq; int sc_irq_flags; void *sc_ih; @@ -85,7 +81,6 @@ const char *amdgpio_hids[] = { NULL }; -int amdgpio_parse_resources(int, union acpi_resource *, void *); int amdgpio_read_pin(void *, int); void amdgpio_write_pin(void *, int, int); void amdgpio_intr_establish(void *, int, int, int (*)(), void *); @@ -106,15 +101,24 @@ amdgpio_attach(struct device *parent, struct device *self, void *aux) { struct acpi_attach_args *aaa = aux; struct amdgpio_softc *sc = (struct amdgpio_softc *)self; - struct aml_value res; int64_t uid; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_node = aaa->aaa_node; - printf(": %s", sc->sc_node->name); + printf(" %s", sc->sc_node->name); + + if (aaa->aaa_naddr < 1) { + printf(": no registers\n"); + return; + } + + if (aaa->aaa_nirq < 1) { + printf(": no interrupt\n"); + return; + } if (aml_evalinteger(sc->sc_acpi, sc->sc_node, "_UID", 0, NULL, &uid)) { - printf(", can't find uid\n"); + printf(": can't find uid\n"); return; } @@ -129,39 +133,23 @@ amdgpio_attach(struct device *parent, struct device *self, void *aux) return; } - if (aml_evalname(sc->sc_acpi, sc->sc_node, "_CRS", 0, NULL, &res)) { - printf(", can't find registers\n"); - return; - } + printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]); + printf(" irq %d", aaa->aaa_irq[0]); - aml_parse_resource(&res, amdgpio_parse_resources, sc); - aml_freevalue(&res); - printf(" addr 0x%lx/0x%lx", sc->sc_addr, sc->sc_size); - if (sc->sc_addr == 0 || sc->sc_size == 0) { - printf("\n"); + sc->sc_memt = aaa->aaa_bst[0]; + if (bus_space_map(sc->sc_memt, aaa->aaa_addr[0], aaa->aaa_size[0], + 0, &sc->sc_memh)) { + printf(": can't map registers\n"); return; } sc->sc_pin_ih = mallocarray(sc->sc_npins, sizeof(*sc->sc_pin_ih), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->sc_pin_ih == NULL) { - printf("\n"); - return; - } - - printf(" irq %d", sc->sc_irq); + M_DEVBUF, M_WAITOK | M_ZERO); - sc->sc_memt = aaa->aaa_memt; - if (bus_space_map(sc->sc_memt, sc->sc_addr, sc->sc_size, 0, - &sc->sc_memh)) { - printf(", can't map registers\n"); - goto free; - } - - sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO, - amdgpio_intr, sc, sc->sc_dev.dv_xname); + sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0], + IPL_BIO, amdgpio_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { - printf(", can't establish interrupt\n"); + printf(": can't establish interrupt\n"); goto unmap; } @@ -177,32 +165,8 @@ amdgpio_attach(struct device *parent, struct device *self, void *aux) return; unmap: - bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size); -free: free(sc->sc_pin_ih, M_DEVBUF, sc->sc_npins * sizeof(*sc->sc_pin_ih)); -} - -int -amdgpio_parse_resources(int crsidx, union acpi_resource *crs, void *arg) -{ - struct amdgpio_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; - default: - printf(" type 0x%x\n", type); - break; - } - - return 0; + bus_space_unmap(sc->sc_memt, sc->sc_memh, aaa->aaa_size[0]); } int diff --git a/sys/dev/acpi/aplgpio.c b/sys/dev/acpi/aplgpio.c index 280e94b401c..2cbe27b43cd 100644 --- a/sys/dev/acpi/aplgpio.c +++ b/sys/dev/acpi/aplgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplgpio.c,v 1.1 2019/06/17 18:28:18 patrick Exp $ */ +/* $OpenBSD: aplgpio.c,v 1.2 2020/05/22 10:16:37 kettenis Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * Copyright (c) 2019 James Hastings @@ -49,11 +49,6 @@ struct aplgpio_softc { bus_space_tag_t sc_memt; bus_space_handle_t sc_memh; - bus_addr_t sc_addr; - bus_size_t sc_size; - - int sc_irq; - int sc_irq_flags; void *sc_ih; int sc_npins; @@ -78,7 +73,6 @@ const char *aplgpio_hids[] = { NULL }; -int aplgpio_parse_resources(int, union acpi_resource *, void *); int aplgpio_read_pin(void *, int); void aplgpio_write_pin(void *, int, int); void aplgpio_intr_establish(void *, int, int, int (*)(), void *); @@ -96,18 +90,27 @@ aplgpio_match(struct device *parent, void *match, void *aux) void aplgpio_attach(struct device *parent, struct device *self, void *aux) { - struct acpi_attach_args *aaa = aux; struct aplgpio_softc *sc = (struct aplgpio_softc *)self; - struct aml_value res; + struct acpi_attach_args *aaa = aux; int64_t uid; int i; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_node = aaa->aaa_node; - printf(": %s", sc->sc_node->name); + printf(" %s", sc->sc_node->name); + + if (aaa->aaa_naddr < 1) { + printf(": no registers\n"); + return; + } + + if (aaa->aaa_nirq < 1) { + printf(": no interrupt\n"); + return; + } if (aml_evalinteger(sc->sc_acpi, sc->sc_node, "_UID", 0, NULL, &uid)) { - printf(", can't find uid\n"); + printf(": can't find uid\n"); return; } @@ -131,39 +134,23 @@ aplgpio_attach(struct device *parent, struct device *self, void *aux) return; } - if (aml_evalname(sc->sc_acpi, sc->sc_node, "_CRS", 0, NULL, &res)) { - printf(", can't find registers\n"); - return; - } + printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]); + printf(" irq %d", aaa->aaa_irq[0]); - aml_parse_resource(&res, aplgpio_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"); + sc->sc_memt = aaa->aaa_bst[0]; + if (bus_space_map(sc->sc_memt, aaa->aaa_addr[0], aaa->aaa_size[0], + 0, &sc->sc_memh)) { + printf(": can't map registers\n"); return; } - aml_freevalue(&res); sc->sc_pin_ih = mallocarray(sc->sc_npins, sizeof(*sc->sc_pin_ih), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->sc_pin_ih == NULL) { - printf("\n"); - return; - } + M_DEVBUF, M_WAITOK | M_ZERO); - printf(" irq %d", sc->sc_irq); - - sc->sc_memt = aaa->aaa_memt; - if (bus_space_map(sc->sc_memt, sc->sc_addr, sc->sc_size, 0, - &sc->sc_memh)) { - printf(", can't map registers\n"); - goto free; - } - - sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO, - aplgpio_intr, sc, sc->sc_dev.dv_xname); + sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0], + IPL_BIO, aplgpio_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { - printf(", can't establish interrupt\n"); + printf(": can't establish interrupt\n"); goto unmap; } @@ -189,32 +176,8 @@ aplgpio_attach(struct device *parent, struct device *self, void *aux) return; unmap: - bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size); -free: free(sc->sc_pin_ih, M_DEVBUF, sc->sc_npins * sizeof(*sc->sc_pin_ih)); -} - -int -aplgpio_parse_resources(int crsidx, union acpi_resource *crs, void *arg) -{ - struct aplgpio_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; - default: - printf(" type 0x%x\n", type); - break; - } - - return 0; + bus_space_unmap(sc->sc_memt, sc->sc_memh, aaa->aaa_size[0]); } int diff --git a/sys/dev/acpi/bytgpio.c b/sys/dev/acpi/bytgpio.c index a761afc76a2..ed14457b680 100644 --- a/sys/dev/acpi/bytgpio.c +++ b/sys/dev/acpi/bytgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bytgpio.c,v 1.13 2018/04/30 18:47:48 kettenis Exp $ */ +/* $OpenBSD: bytgpio.c,v 1.14 2020/05/22 10:16:37 kettenis Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * @@ -49,11 +49,6 @@ struct bytgpio_softc { bus_space_tag_t sc_memt; bus_space_handle_t sc_memh; - bus_addr_t sc_addr; - bus_size_t sc_size; - - int sc_irq; - int sc_irq_flags; void *sc_ih; const int *sc_pins; @@ -104,7 +99,6 @@ const int byt_sus_pins[] = { 56, 54, 49, 55, 48, 57, 50, 58, 52, 53, 59, 40 }; -int bytgpio_parse_resources(int, union acpi_resource *, void *); int bytgpio_read_pin(void *, int); void bytgpio_write_pin(void *, int, int); void bytgpio_intr_establish(void *, int, int, int (*)(), void *); @@ -122,19 +116,28 @@ bytgpio_match(struct device *parent, void *match, void *aux) void bytgpio_attach(struct device *parent, struct device *self, void *aux) { - struct acpi_attach_args *aaa = aux; struct bytgpio_softc *sc = (struct bytgpio_softc *)self; - struct aml_value res; + struct acpi_attach_args *aaa = aux; int64_t uid; uint32_t reg; int i; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_node = aaa->aaa_node; - printf(": %s", sc->sc_node->name); + printf(" %s", sc->sc_node->name); + + if (aaa->aaa_naddr < 1) { + printf(": no registers\n"); + return; + } + + if (aaa->aaa_nirq < 1) { + printf(": no interrupt\n"); + return; + } if (aml_evalinteger(sc->sc_acpi, sc->sc_node, "_UID", 0, NULL, &uid)) { - printf(", can't find uid\n"); + printf(": can't find uid\n"); return; } @@ -158,39 +161,23 @@ bytgpio_attach(struct device *parent, struct device *self, void *aux) return; } - if (aml_evalname(sc->sc_acpi, sc->sc_node, "_CRS", 0, NULL, &res)) { - printf(", can't find registers\n"); - return; - } + printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]); + printf(" irq %d", aaa->aaa_irq[0]); - aml_parse_resource(&res, bytgpio_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"); + sc->sc_memt = aaa->aaa_bst[0]; + if (bus_space_map(sc->sc_memt, aaa->aaa_addr[0], aaa->aaa_size[0], + 0, &sc->sc_memh)) { + printf(": can't map registers\n"); return; } - aml_freevalue(&res); sc->sc_pin_ih = mallocarray(sc->sc_npins, sizeof(*sc->sc_pin_ih), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->sc_pin_ih == NULL) { - printf("\n"); - return; - } + M_DEVBUF, M_WAITOK | M_ZERO); - printf(" irq %d", sc->sc_irq); - - sc->sc_memt = aaa->aaa_memt; - if (bus_space_map(sc->sc_memt, sc->sc_addr, sc->sc_size, 0, - &sc->sc_memh)) { - printf(", can't map registers\n"); - goto free; - } - - sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO, - bytgpio_intr, sc, sc->sc_dev.dv_xname); + sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0], + IPL_BIO, bytgpio_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { - printf(", can't establish interrupt\n"); + printf(": can't establish interrupt\n"); goto unmap; } @@ -221,32 +208,8 @@ bytgpio_attach(struct device *parent, struct device *self, void *aux) return; unmap: - bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size); -free: free(sc->sc_pin_ih, M_DEVBUF, sc->sc_npins * sizeof(*sc->sc_pin_ih)); -} - -int -bytgpio_parse_resources(int crsidx, union acpi_resource *crs, void *arg) -{ - struct bytgpio_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; - default: - printf(" type 0x%x\n", type); - break; - } - - return 0; + bus_space_unmap(sc->sc_memt, sc->sc_memh, aaa->aaa_size[0]); } int diff --git a/sys/dev/acpi/chvgpio.c b/sys/dev/acpi/chvgpio.c index 4dddf4e76ee..a0e75bcb60b 100644 --- a/sys/dev/acpi/chvgpio.c +++ b/sys/dev/acpi/chvgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chvgpio.c,v 1.8 2017/11/29 22:51:01 kettenis Exp $ */ +/* $OpenBSD: chvgpio.c,v 1.9 2020/05/22 10:16:37 kettenis Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * @@ -58,11 +58,7 @@ struct chvgpio_softc { bus_space_tag_t sc_memt; bus_space_handle_t sc_memh; - bus_addr_t sc_addr; bus_size_t sc_size; - - int sc_irq; - int sc_irq_flags; void *sc_ih; const int *sc_pins; @@ -146,7 +142,6 @@ const int chv_southeast_pins[] = { 8, 12, 6, 8, 10, 11, -1 }; -int chvgpio_parse_resources(int, union acpi_resource *, void *); int chvgpio_check_pin(struct chvgpio_softc *, int); int chvgpio_read_pin(void *, int); void chvgpio_write_pin(void *, int, int); @@ -166,18 +161,27 @@ chvgpio_match(struct device *parent, void *match, void *aux) void chvgpio_attach(struct device *parent, struct device *self, void *aux) { - struct acpi_attach_args *aaa = aux; struct chvgpio_softc *sc = (struct chvgpio_softc *)self; - struct aml_value res; + struct acpi_attach_args *aaa = aux; int64_t uid; int i; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_node = aaa->aaa_node; - printf(": %s", sc->sc_node->name); + printf(" %s", sc->sc_node->name); + + if (aaa->aaa_naddr < 1) { + printf(": no registers\n"); + return; + } + + if (aaa->aaa_nirq < 1) { + printf(": no interrupt\n"); + return; + } if (aml_evalinteger(sc->sc_acpi, sc->sc_node, "_UID", 0, NULL, &uid)) { - printf(", can't find uid\n"); + printf(": can't find uid\n"); return; } @@ -206,32 +210,21 @@ chvgpio_attach(struct device *parent, struct device *self, void *aux) sc->sc_ngroups++; } - if (aml_evalname(sc->sc_acpi, sc->sc_node, "_CRS", 0, NULL, &res)) { - printf(", can't find registers\n"); - return; - } + printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]); + printf(" irq %d", aaa->aaa_irq[0]); - aml_parse_resource(&res, chvgpio_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"); + sc->sc_memt = aaa->aaa_bst[0]; + sc->sc_size = aaa->aaa_size[0]; + if (bus_space_map(sc->sc_memt, aaa->aaa_addr[0], aaa->aaa_size[0], + 0, &sc->sc_memh)) { + printf(": can't map registers\n"); return; } - aml_freevalue(&res); - printf(" irq %d", sc->sc_irq); - - sc->sc_memt = aaa->aaa_memt; - if (bus_space_map(sc->sc_memt, sc->sc_addr, sc->sc_size, 0, - &sc->sc_memh)) { - printf(", can't map registers\n"); - return; - } - - sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO, - chvgpio_intr, sc, sc->sc_dev.dv_xname); + sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0], + IPL_BIO, chvgpio_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { - printf(", can't establish interrupt\n"); + printf(": can't establish interrupt\n"); goto unmap; } @@ -261,29 +254,6 @@ unmap: } int -chvgpio_parse_resources(int crsidx, union acpi_resource *crs, void *arg) -{ - struct chvgpio_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; - default: - printf(" type 0x%x\n", type); - break; - } - - return 0; -} - -int chvgpio_check_pin(struct chvgpio_softc *sc, int pin) { if (pin < 0) diff --git a/sys/dev/acpi/glkgpio.c b/sys/dev/acpi/glkgpio.c index 6d8d1495404..2646c3e0777 100644 --- a/sys/dev/acpi/glkgpio.c +++ b/sys/dev/acpi/glkgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glkgpio.c,v 1.1 2019/06/24 21:33:27 kettenis Exp $ */ +/* $OpenBSD: glkgpio.c,v 1.2 2020/05/22 10:16:37 kettenis Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * Copyright (c) 2019 James Hastings @@ -49,11 +49,6 @@ struct glkgpio_softc { bus_space_tag_t sc_memt; bus_space_handle_t sc_memh; - bus_addr_t sc_addr; - bus_size_t sc_size; - - int sc_irq; - int sc_irq_flags; void *sc_ih; int sc_npins; @@ -96,18 +91,27 @@ glkgpio_match(struct device *parent, void *match, void *aux) void glkgpio_attach(struct device *parent, struct device *self, void *aux) { - struct acpi_attach_args *aaa = aux; struct glkgpio_softc *sc = (struct glkgpio_softc *)self; - struct aml_value res; + struct acpi_attach_args *aaa = aux; int64_t uid; int i; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_node = aaa->aaa_node; - printf(": %s", sc->sc_node->name); + printf(" %s", sc->sc_node->name); + + if (aaa->aaa_naddr < 1) { + printf(": no registers\n"); + return; + } + + if (aaa->aaa_nirq < 1) { + printf(": no interrupt\n"); + return; + } if (aml_evalinteger(sc->sc_acpi, sc->sc_node, "_UID", 0, NULL, &uid)) { - printf(", can't find uid\n"); + printf(": can't find uid\n"); return; } @@ -131,39 +135,23 @@ glkgpio_attach(struct device *parent, struct device *self, void *aux) return; } - if (aml_evalname(sc->sc_acpi, sc->sc_node, "_CRS", 0, NULL, &res)) { - printf(", can't find registers\n"); - return; - } + printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]); + printf(" irq %d", aaa->aaa_irq[0]); - aml_parse_resource(&res, glkgpio_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"); + sc->sc_memt = aaa->aaa_bst[0]; + if (bus_space_map(sc->sc_memt, aaa->aaa_addr[0], aaa->aaa_size[0], + 0, &sc->sc_memh)) { + printf(": can't map registers\n"); return; } - aml_freevalue(&res); sc->sc_pin_ih = mallocarray(sc->sc_npins, sizeof(*sc->sc_pin_ih), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->sc_pin_ih == NULL) { - printf("\n"); - return; - } + M_DEVBUF, M_WAITOK | M_ZERO); - printf(" irq %d", sc->sc_irq); - - sc->sc_memt = aaa->aaa_memt; - if (bus_space_map(sc->sc_memt, sc->sc_addr, sc->sc_size, 0, - &sc->sc_memh)) { - printf(", can't map registers\n"); - goto free; - } - - sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO, - glkgpio_intr, sc, sc->sc_dev.dv_xname); + sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0], + IPL_BIO, glkgpio_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { - printf(", can't establish interrupt\n"); + printf(": can't establish interrupt\n"); goto unmap; } @@ -189,32 +177,8 @@ glkgpio_attach(struct device *parent, struct device *self, void *aux) return; unmap: - bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size); -free: free(sc->sc_pin_ih, M_DEVBUF, sc->sc_npins * sizeof(*sc->sc_pin_ih)); -} - -int -glkgpio_parse_resources(int crsidx, union acpi_resource *crs, void *arg) -{ - struct glkgpio_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; - default: - printf(" type 0x%x\n", type); - break; - } - - return 0; + bus_space_unmap(sc->sc_memt, sc->sc_memh, aaa->aaa_size[0]); } int diff --git a/sys/dev/acpi/tpm.c b/sys/dev/acpi/tpm.c index 2cda107a116..cf575b1ad5b 100644 --- a/sys/dev/acpi/tpm.c +++ b/sys/dev/acpi/tpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tpm.c,v 1.9 2019/05/15 21:28:21 tedu Exp $ */ +/* $OpenBSD: tpm.c,v 1.10 2020/05/22 10:16:37 kettenis Exp $ */ /* * Minimal interface to Trusted Platform Module chips implementing the @@ -127,19 +127,6 @@ struct tpm_softc { int sc_enabled; }; -struct tpm_crs { - int irq_int; - uint8_t irq_flags; - uint32_t addr_min; - uint32_t addr_bas; - uint32_t addr_len; - uint16_t i2c_addr; - struct aml_node *devnode; - struct aml_node *gpio_int_node; - uint16_t gpio_int_pin; - uint16_t gpio_int_flags; -}; - const struct { uint32_t devid; char name[32]; @@ -158,7 +145,6 @@ const struct { int tpm_match(struct device *, void *, void *); void tpm_attach(struct device *, struct device *, void *); int tpm_activate(struct device *, int); -int tpm_parse_crs(int, union acpi_resource *, void *); int tpm_probe(bus_space_tag_t, bus_space_handle_t); int tpm_init(struct tpm_softc *); @@ -210,61 +196,43 @@ void tpm_attach(struct device *parent, struct device *self, void *aux) { struct tpm_softc *sc = (struct tpm_softc *)self; - struct acpi_attach_args *aa = aux; - struct tpm_crs crs; - struct aml_value res; - int64_t st; + struct acpi_attach_args *aaa = aux; + int64_t sta; sc->sc_acpi = (struct acpi_softc *)parent; - sc->sc_devnode = aa->aaa_node; + sc->sc_devnode = aaa->aaa_node; sc->sc_enabled = 0; - printf(": %s", sc->sc_devnode->name); + printf(" %s", sc->sc_devnode->name); - if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, &st)) - st = STA_PRESENT | STA_ENABLED | STA_DEV_OK; - if ((st & (STA_PRESENT | STA_ENABLED | STA_DEV_OK)) != + sta = acpi_getsta(sc->sc_acpi, sc->sc_devnode); + if ((sta & (STA_PRESENT | STA_ENABLED | STA_DEV_OK)) != (STA_PRESENT | STA_ENABLED | STA_DEV_OK)) { - printf(", not enabled\n"); + printf(": not enabled\n"); return; } - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_CRS", 0, NULL, &res)) { - printf(", no _CRS method\n"); - return; - } - if (res.type != AML_OBJTYPE_BUFFER || res.length < 5) { - printf(", invalid _CRS object (type %d len %d)\n", - res.type, res.length); - aml_freevalue(&res); + if (aaa->aaa_naddr < 1) { + printf(": no registers\n"); return; } - memset(&crs, 0, sizeof(crs)); - crs.devnode = sc->sc_devnode; - aml_parse_resource(&res, tpm_parse_crs, &crs); - aml_freevalue(&res); - if (crs.addr_bas == 0) { - printf(", can't find address\n"); - return; - } + printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]); - printf(" addr 0x%x/0x%x", crs.addr_bas, crs.addr_len); - - sc->sc_bt = aa->aaa_memt; - if (bus_space_map(sc->sc_bt, crs.addr_bas, crs.addr_len, 0, - &sc->sc_bh)) { - printf(", failed mapping at 0x%x\n", crs.addr_bas); + sc->sc_bt = aaa->aaa_bst[0]; + if (bus_space_map(sc->sc_bt, aaa->aaa_addr[0], aaa->aaa_size[0], + 0, &sc->sc_bh)) { + printf(": can't map registers\n"); return; } if (!tpm_probe(sc->sc_bt, sc->sc_bh)) { - printf(", probe failed\n"); + printf(": probe failed\n"); return; } if (tpm_init(sc) != 0) { - printf(", init failed\n"); + printf(": init failed\n"); return; } @@ -273,36 +241,6 @@ tpm_attach(struct device *parent, struct device *self, void *aux) } int -tpm_parse_crs(int crsidx, union acpi_resource *crs, void *arg) -{ - struct tpm_crs *sc_crs = arg; - - switch (AML_CRSTYPE(crs)) { - case LR_MEM32: - sc_crs->addr_min = letoh32(crs->lr_m32._min); - sc_crs->addr_len = letoh32(crs->lr_m32._len); - break; - - case LR_MEM32FIXED: - sc_crs->addr_bas = letoh32(crs->lr_m32fixed._bas); - sc_crs->addr_len = letoh32(crs->lr_m32fixed._len); - break; - - case SR_IOPORT: - case SR_IRQ: - case LR_EXTIRQ: - case LR_GPIO: - break; - - default: - DPRINTF(("%s: unknown resource type %d\n", __func__, - AML_CRSTYPE(crs))); - } - - return 0; -} - -int tpm_activate(struct device *self, int act) { struct tpm_softc *sc = (struct tpm_softc *)self; |