summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2006-12-12 02:39:26 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2006-12-12 02:39:26 +0000
commitd5f9726a1b1d99b7c23019d128c3f00a18af9e46 (patch)
tree52603907e573b4960904984e3143133cb92ed764 /sys/dev/pci
parent550367658793b45ccd9c9597ddcc06ecd509c647 (diff)
for each port the controller says is hooked up, go and allocate our
ahci_port structs for it.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/ahci.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c
index 97836eb5f3b..17ab0484ddf 100644
--- a/sys/dev/pci/ahci.c
+++ b/sys/dev/pci/ahci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahci.c,v 1.27 2006/12/12 02:37:09 dlg Exp $ */
+/* $OpenBSD: ahci.c,v 1.28 2006/12/12 02:39:25 dlg Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -254,6 +254,8 @@ ahci_attach(struct device *parent, struct device *self, void *aux)
{
struct ahci_softc *sc = (struct ahci_softc *)self;
struct pci_attach_args *pa = aux;
+ u_int32_t reg;
+ int i;
sc->sc_dmat = pa->pa_dmat;
@@ -276,9 +278,9 @@ ahci_attach(struct device *parent, struct device *self, void *aux)
#ifdef AHCI_DEBUG
if (ahcidebug & AHCI_D_VERBOSE) {
- u_int32_t reg = ahci_read(sc, AHCI_REG_CAP);
const char *gen;
+ reg = ahci_read(sc, AHCI_REG_CAP);
switch (reg & AHCI_REG_CAP_ISS) {
case AHCI_REG_CAP_ISS_G1:
gen = "1 (1.5Gbps)";
@@ -297,8 +299,26 @@ ahci_attach(struct device *parent, struct device *self, void *aux)
}
#endif
- return;
+ reg = ahci_read(sc, AHCI_REG_PI);
+ DPRINTF(AHCI_D_VERBOSE, "%s: ports implemented: 0x%08x\n",
+ DEVNAME(sc), reg);
+ for (i = 0; i < AHCI_MAX_PORTS; i++) {
+ if (((1 << i) & reg) == 0) {
+ /* dont allocate stuff if the port isnt implemented */
+ continue;
+ }
+ if (ahci_port_alloc(sc, i) != 0)
+ goto freeports;
+ }
+
+ return;
+
+freeports:
+ for (i = 0; i < AHCI_MAX_PORTS; i++) {
+ if (sc->sc_ports[i] != NULL)
+ ahci_port_free(sc, i);
+ }
unmap:
ahci_unmap_regs(sc, pa);
}