Module Name: src Committed By: msaitoh Date: Wed Nov 10 14:36:28 UTC 2021
Modified Files: src/sys/dev/pci: sdhc_pci.c Log Message: Support 64bit BAR. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/sdhc_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/sdhc_pci.c diff -u src/sys/dev/pci/sdhc_pci.c:1.17 src/sys/dev/pci/sdhc_pci.c:1.18 --- src/sys/dev/pci/sdhc_pci.c:1.17 Wed Jan 1 23:28:31 2020 +++ src/sys/dev/pci/sdhc_pci.c Wed Nov 10 14:36:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc_pci.c,v 1.17 2020/01/01 23:28:31 mlelstv Exp $ */ +/* $NetBSD: sdhc_pci.c,v 1.18 2021/11/10 14:36:28 msaitoh Exp $ */ /* $OpenBSD: sdhc_pci.c,v 1.7 2007/10/30 18:13:45 chl Exp $ */ /* @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.17 2020/01/01 23:28:31 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.18 2021/11/10 14:36:28 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -252,6 +252,7 @@ sdhc_pci_attach(device_t parent, device_ bus_space_handle_t ioh; bus_size_t size; uint32_t flags; + int width; char intrbuf[PCI_INTRSTR_LEN]; sc->sc.sc_dev = self; @@ -313,13 +314,23 @@ sdhc_pci_attach(device_t parent, device_ if ((PCI_INTERFACE(pa->pa_class) == SDHC_PCI_INTERFACE_DMA)) SET(sc->sc.sc_flags, SDHC_FLAG_USE_DMA); - /* XXX: handle 64-bit BARs */ cnt = 0; for (reg = SDHC_PCI_BAR_START + SDHC_PCI_FIRST_BAR(slotinfo) * sizeof(uint32_t); reg < SDHC_PCI_BAR_END && nslots > 0; - reg += sizeof(uint32_t), nslots--) { - if (pci_mapreg_map(pa, reg, PCI_MAPREG_TYPE_MEM, 0, + reg += width, nslots--) { + pcireg_t type; + + type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, reg); + if (type == PCI_MAPREG_TYPE_IO) + break; + else if (PCI_MAPREG_MEM_TYPE(type) + == PCI_MAPREG_MEM_TYPE_64BIT) + width = 8; + else + width = 4; + + if (pci_mapreg_map(pa, reg, type, 0, &iot, &ioh, NULL, &size)) { continue; }