The SDHC on this machine comes with a 64-bit BAR, so we need to fix
that XXX. I did change the error handling a bit such that we give up
after the first unmappable BAR. It seems multi-slot controllers are
rare and it is questionable whether higher numbered slots work if we
can't properly configure a lower numbered slot.
ok?
Index: sdhc_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/sdhc_pci.c,v
retrieving revision 1.17
diff -u -p -r1.17 sdhc_pci.c
--- sdhc_pci.c 30 Sep 2014 18:09:23 -0000 1.17
+++ sdhc_pci.c 10 Nov 2015 16:10:32 -0000
@@ -106,6 +106,7 @@ sdhc_pci_attach(struct device *parent, s
int nslots;
int usedma;
int reg;
+ pcireg_t type;
bus_space_tag_t iot;
bus_space_handle_t ioh;
bus_size_t size;
@@ -160,27 +161,25 @@ sdhc_pci_attach(struct device *parent, s
sc->sc.sc_host = mallocarray(nslots, sizeof(struct sdhc_host *),
M_DEVBUF, M_WAITOK);
- /* XXX: handle 64-bit BARs */
- for (reg = SDHC_PCI_BAR_START + SDHC_PCI_FIRST_BAR(slotinfo) *
- sizeof(u_int32_t);
+ for (reg = SDHC_PCI_BAR_START + SDHC_PCI_FIRST_BAR(slotinfo) * 4;
reg < SDHC_PCI_BAR_END && nslots > 0;
- reg += sizeof(u_int32_t), nslots--) {
+ reg += 4, nslots--) {
+ if (pci_mapreg_probe(pa->pa_pc, pa->pa_tag, reg, &type) != 0)
+ break;
- if (pci_mem_find(pa->pa_pc, pa->pa_tag, reg,
- NULL, NULL, NULL) != 0)
- continue;
-
- if (pci_mapreg_map(pa, reg, PCI_MAPREG_TYPE_MEM, 0,
- &iot, &ioh, NULL, &size, 0)) {
+ if (type == PCI_MAPREG_TYPE_IO || pci_mapreg_map(pa, reg,
+ type, 0, &iot, &ioh, NULL, &size, 0)) {
printf("%s at 0x%x: can't map registers\n",
sc->sc.sc_dev.dv_xname, reg);
- continue;
+ break;
}
if (sdhc_host_found(&sc->sc, iot, ioh, size, usedma, caps) != 0)
- /* XXX: sc->sc_host leak */
printf("%s at 0x%x: can't initialize host\n",
sc->sc.sc_dev.dv_xname, reg);
+
+ if (type & PCI_MAPREG_MEM_TYPE_64BIT)
+ reg += 4;
}
}