summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2014-03-07 12:45:50 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2014-03-07 12:45:50 +0000
commitae4bb49da0f6c09e6d7ec32256dc891080b933a0 (patch)
treeff2c8e638d60e706d4217262130a032f194be809 /sys
parent55845650d9eb4c82a1e393b9ebf08cd9840f39a4 (diff)
Provide the appropriate default values for the SCSI initiaror ID on sgi and
sparc64.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/qlw.c8
-rw-r--r--sys/dev/ic/qlwvar.h3
-rw-r--r--sys/dev/pci/qlw_pci.c33
3 files changed, 39 insertions, 5 deletions
diff --git a/sys/dev/ic/qlw.c b/sys/dev/ic/qlw.c
index f8a3048e34c..e270e78770b 100644
--- a/sys/dev/ic/qlw.c
+++ b/sys/dev/ic/qlw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qlw.c,v 1.1 2014/03/05 23:10:41 kettenis Exp $ */
+/* $OpenBSD: qlw.c,v 1.2 2014/03/07 12:45:49 kettenis Exp $ */
/*
* Copyright (c) 2011 David Gwynne <dlg@openbsd.org>
@@ -373,7 +373,7 @@ qlw_attach(struct qlw_softc *sc)
for (bus = 0; bus < sc->sc_numbusses; bus++) {
sc->sc_link[bus].adapter = &qlw_switch;
sc->sc_link[bus].adapter_softc = sc;
- sc->sc_link[bus].adapter_target = 7;
+ sc->sc_link[bus].adapter_target = sc->sc_initiator[bus];
sc->sc_link[bus].adapter_buswidth = QLW_MAX_TARGETS;
sc->sc_link[bus].openings = sc->sc_max_queue_depth[bus];
sc->sc_link[bus].pool = &sc->sc_iopool;
@@ -408,7 +408,7 @@ qlw_config_bus(struct qlw_softc *sc, int bus)
int target, err;
sc->sc_mbox[0] = QLW_MBOX_SET_INITIATOR_ID;
- sc->sc_mbox[1] = (bus << 7) | 7;
+ sc->sc_mbox[1] = (bus << 7) | sc->sc_initiator[bus];
if (qlw_mbox(sc, 0x0003, 0x0001)) {
printf("couldn't set initiator id: %x\n", sc->sc_mbox[0]);
@@ -1429,6 +1429,7 @@ qlw_parse_nvram_1040(struct qlw_softc *sc, int bus)
KASSERT(bus == 0);
+ sc->sc_initiator[0] = (nv->config1 >> 4);
sc->sc_retry_count[0] = nv->retry_count;
sc->sc_retry_delay[0] = nv->retry_delay;
sc->sc_reset_delay[0] = nv->reset_delay;
@@ -1455,6 +1456,7 @@ qlw_parse_nvram_1080(struct qlw_softc *sc, int bus)
struct qlw_nvram_bus *nv = &nvram->bus[bus];
int target;
+ sc->sc_initiator[bus] = (nv->config1 & 0x0f);
sc->sc_retry_count[bus] = nv->retry_count;
sc->sc_retry_delay[bus] = nv->retry_delay;
sc->sc_reset_delay[bus] = nv->reset_delay;
diff --git a/sys/dev/ic/qlwvar.h b/sys/dev/ic/qlwvar.h
index 1ba992f26f1..64eacaf3cf8 100644
--- a/sys/dev/ic/qlwvar.h
+++ b/sys/dev/ic/qlwvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: qlwvar.h,v 1.2 2014/03/07 00:20:55 kettenis Exp $ */
+/* $OpenBSD: qlwvar.h,v 1.3 2014/03/07 12:45:49 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014 Jonathan Matthew <jmatthew@openbsd.org>
@@ -111,6 +111,7 @@ struct qlw_softc {
int sc_nvram_size;
int sc_nvram_minversion;
+ u_int8_t sc_initiator[2];
u_int8_t sc_retry_count[2];
u_int8_t sc_retry_delay[2];
u_int8_t sc_reset_delay[2];
diff --git a/sys/dev/pci/qlw_pci.c b/sys/dev/pci/qlw_pci.c
index bfd1aabed56..a3afc83eca8 100644
--- a/sys/dev/pci/qlw_pci.c
+++ b/sys/dev/pci/qlw_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qlw_pci.c,v 1.4 2014/03/06 18:09:17 kettenis Exp $ */
+/* $OpenBSD: qlw_pci.c,v 1.5 2014/03/07 12:45:49 kettenis Exp $ */
/*
* Copyright (c) 2011 David Gwynne <dlg@openbsd.org>
@@ -106,6 +106,9 @@ qlw_pci_attach(struct device *parent, struct device *self, void *aux)
struct pci_attach_args *pa = aux;
pci_intr_handle_t ih;
u_int32_t pcictl;
+#ifdef __sparc64__
+ int node, initiator;
+#endif
pcireg_t bars[] = { QLW_PCI_MEM_BAR, QLW_PCI_IO_BAR };
pcireg_t memtype;
@@ -227,6 +230,34 @@ qlw_pci_attach(struct device *parent, struct device *self, void *aux)
}
#endif
+ /*
+ * The standard SCSI initiator ID is 7, but various SGI
+ * machines use 0 as the initiator ID for their onboard SCSI.
+ * Add-on cards should have a valid nvram, which will override
+ * these defaults.
+ */
+#ifdef __sgi__
+ sc->sc_initiator[0] = sc->sc_initiator[1] = 0;
+#else
+ sc->sc_initiator[0] = sc->sc_initiator[1] = 7;
+#endif
+
+#ifdef __sparc64__
+ /*
+ * Walk up the Open Firmware device tree until we find a
+ * "scsi-initiator-id" property.
+ */
+ node = PCITAG_NODE(pa->pa_tag);
+ while (node) {
+ if (OF_getprop(node, "scsi-initiator-id",
+ &initiator, sizeof(initiator)) == sizeof(initiator)) {
+ sc->sc_initiator[0] = sc->sc_initiator[1] = initiator;
+ break;
+ }
+ node = OF_parent(node);
+ }
+#endif
+
if (qlw_attach(sc) != 0) {
/* error printed by qlw_attach */
goto deintr;