summaryrefslogtreecommitdiff
path: root/src/sys/io/ic
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/io/ic')
-rw-r--r--src/sys/io/ic/ahci.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/sys/io/ic/ahci.c b/src/sys/io/ic/ahci.c
index 825306d..9f96a00 100644
--- a/src/sys/io/ic/ahci.c
+++ b/src/sys/io/ic/ahci.c
@@ -144,6 +144,27 @@ ahci_hba_reset(struct ahci_hba *hba)
}
/*
+ * Initialize the ports of an HBA
+ */
+static int
+ahci_init_ports(struct ahci_hba *hba)
+{
+ volatile struct hba_memspace *io = hba->io;
+ uint32_t pi, nbits;
+
+ pi = hba->pi;
+ for (int i = 0; i < hba->nport; ++i) {
+ if (!ISSET(pi, BIT(i))) {
+ continue;
+ }
+
+ dtrace("port %d implemented\n", i);
+ }
+
+ return 0;
+}
+
+/*
* Put the HBA as well as its devices in an initialized
* state so that they may be used for operation.
*/
@@ -151,9 +172,14 @@ static int
ahci_hba_init(struct ahci_hba *hba)
{
volatile struct hba_memspace *io = hba->io;
- uint32_t ghc;
+ uint32_t ghc, cap;
int error;
+ /* Yoink from firmware before reset */
+ cap = mmio_read32(&io->cap);
+ hba->pi = mmio_read32(&io->pi);
+ hba->nport = AHCI_CAP_NP(cap) + 1;
+
/*
* We cannot be so certain what state the BIOS or whatever
* firmware left the host controller in, therefore the HBA
@@ -173,7 +199,7 @@ ahci_hba_init(struct ahci_hba *hba)
ghc = mmio_read32(&io->ghc);
ghc |= AHCI_GHC_AE;
mmio_write32(&io->ghc, ghc);
- return 0;
+ return ahci_init_ports(hba);
}
/*