summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpi/sdhc_acpi.c
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-05-08 11:18:01 +0000
committerkettenis <kettenis@openbsd.org>2020-05-08 11:18:01 +0000
commitf09f3dbfab507baeedb875f13dfb88090e7c70d5 (patch)
tree65c232c06b96eca0c99a91b5eb8b024564153102 /sys/dev/acpi/sdhc_acpi.c
parentMake sure cmsgbufs are properly aligned by using the idiom from the (diff)
downloadwireguard-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/sdhc_acpi.c')
-rw-r--r--sys/dev/acpi/sdhc_acpi.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/sys/dev/acpi/sdhc_acpi.c b/sys/dev/acpi/sdhc_acpi.c
index 8e21b1d7538..3b4c827b9bd 100644
--- a/sys/dev/acpi/sdhc_acpi.c
+++ b/sys/dev/acpi/sdhc_acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhc_acpi.c,v 1.14 2019/04/02 07:08:39 stsp Exp $ */
+/* $OpenBSD: sdhc_acpi.c,v 1.15 2020/05/08 11:18:01 kettenis Exp $ */
/*
* Copyright (c) 2016 Mark Kettenis
*
@@ -36,11 +36,6 @@ struct sdhc_acpi_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;
struct aml_node *sc_gpio_int_node;
@@ -86,39 +81,45 @@ sdhc_acpi_match(struct device *parent, void *match, void *aux)
void
sdhc_acpi_attach(struct device *parent, struct device *self, void *aux)
{
- struct acpi_attach_args *aaa = aux;
struct sdhc_acpi_softc *sc = (struct sdhc_acpi_softc *)self;
+ struct acpi_attach_args *aaa = aux;
struct aml_value res;
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, sdhc_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);
+ if (aml_evalname(sc->sc_acpi, sc->sc_node, "_CRS", 0, NULL, &res)) {
+ printf(": can't find registers\n");
+ return;
+ }
+
+ aml_parse_resource(&res, sdhc_acpi_parse_resources, sc);
- 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");
+ printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]);
+ printf(" irq %d", aaa->aaa_irq[0]);
+
+ 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_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO,
- sdhc_intr, sc, sc->sc.sc_dev.dv_xname);
+ sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0],
+ IPL_BIO, sdhc_intr, sc, sc->sc.sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
- printf(", can't establish interrupt\n");
+ printf(": can't establish interrupt\n");
return;
}
@@ -141,7 +142,8 @@ sdhc_acpi_attach(struct device *parent, struct device *self, void *aux)
sc->sc.sc_host = &sc->sc_host;
sc->sc.sc_dmat = aaa->aaa_dmat;
- sdhc_host_found(&sc->sc, sc->sc_memt, sc->sc_memh, sc->sc_size, 1, 0);
+ sdhc_host_found(&sc->sc, sc->sc_memt, sc->sc_memh,
+ aaa->aaa_size[0], 1, 0);
}
int
@@ -153,14 +155,6 @@ sdhc_acpi_parse_resources(int crsidx, union acpi_resource *crs, void *arg)
uint16_t pin;
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;
case LR_GPIO:
node = aml_searchname(sc->sc_node, (char *)&crs->pad[crs->lr_gpio.res_off]);
pin = *(uint16_t *)&crs->pad[crs->lr_gpio.pin_off];