summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2006-12-12 02:19:38 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2006-12-12 02:19:38 +0000
commit3c6472bf20be2716a4a755244da69aabed7be192 (patch)
treeaafb8f8ae1835d46d0a9abc75b56d7d8c3bb62c4 /sys/dev/pci
parente89c45a8be43f1ee0187f9b6d8ab0d4aa31cf818 (diff)
add wrappers for reading and writing a ports registers called ahci_pread,
and ahci_pwrite. these will use an io handle into a window of the controllers register space that can be created with bus_space_subregion, and which is stored in the ahci_port struct.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/ahci.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c
index 752a41ffa0c..8f33c2e1f4a 100644
--- a/sys/dev/pci/ahci.c
+++ b/sys/dev/pci/ahci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahci.c,v 1.23 2006/12/12 02:13:32 dlg Exp $ */
+/* $OpenBSD: ahci.c,v 1.24 2006/12/12 02:19:37 dlg Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -180,6 +180,9 @@ struct ahci_ccb {
};
struct ahci_port {
+ struct ahci_softc *ap_sc;
+ bus_space_handle_t ap_ioh;
+
struct ahci_ccb *ap_ccbs;
TAILQ_HEAD(, ahci_ccb) ap_ccb_free;
@@ -227,6 +230,8 @@ void ahci_dmamem_free(struct ahci_softc *,
u_int32_t ahci_read(struct ahci_softc *, bus_size_t);
void ahci_write(struct ahci_softc *, bus_size_t, u_int32_t);
+u_int32_t ahci_pread(struct ahci_port *, bus_size_t);
+void ahci_pwrite(struct ahci_port *, bus_size_t, u_int32_t);
int ahci_wait_eq(struct ahci_softc *, bus_size_t,
u_int32_t, u_int32_t);
int ahci_wait_ne(struct ahci_softc *, bus_size_t,
@@ -467,6 +472,22 @@ ahci_write(struct ahci_softc *sc, bus_size_t r, u_int32_t v)
BUS_SPACE_BARRIER_WRITE);
}
+u_int32_t
+ahci_pread(struct ahci_port *ap, bus_size_t r)
+{
+ bus_space_barrier(ap->ap_sc->sc_iot, ap->ap_ioh, r, 4,
+ BUS_SPACE_BARRIER_READ);
+ return (bus_space_read_4(ap->ap_sc->sc_iot, ap->ap_ioh, r));
+}
+
+void
+ahci_pwrite(struct ahci_port *ap, bus_size_t r, u_int32_t v)
+{
+ bus_space_write_4(ap->ap_sc->sc_iot, ap->ap_ioh, r, v);
+ bus_space_barrier(ap->ap_sc->sc_iot, ap->ap_ioh, r, 4,
+ BUS_SPACE_BARRIER_WRITE);
+}
+
int
ahci_wait_eq(struct ahci_softc *sc, bus_size_t r, u_int32_t mask,
u_int32_t target)