Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ieee1394 Do not require GUID ROM, which is optional ...
details: https://anonhg.NetBSD.org/src/rev/7586fe70c595
branches: trunk
changeset: 504454:7586fe70c595
user: onoe <onoe%NetBSD.org@localhost>
date: Sat Mar 03 02:04:54 2001 +0000
description:
Do not require GUID ROM, which is optional according to the OHCI spec.
Use Global UID register as is, it should be initialized by firmware.
If it is not initialized (i.e. 0), try to read GUID ROM if exists.
On my VAIO PCG-N505AS, the version register says it implement GUID ROM,
but reading GUID ROM returns all zero bytes. I'm not sure where the bug is.
diffstat:
sys/dev/ieee1394/fwohci.c | 82 +++++++++++++++++++++++++++++++++----------
sys/dev/ieee1394/fwohcireg.h | 11 +++++-
2 files changed, 72 insertions(+), 21 deletions(-)
diffs (136 lines):
diff -r 2e9c756bbc77 -r 7586fe70c595 sys/dev/ieee1394/fwohci.c
--- a/sys/dev/ieee1394/fwohci.c Sat Mar 03 01:46:04 2001 +0000
+++ b/sys/dev/ieee1394/fwohci.c Sat Mar 03 02:04:54 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fwohci.c,v 1.15 2001/03/03 00:52:58 onoe Exp $ */
+/* $NetBSD: fwohci.c,v 1.16 2001/03/03 02:04:54 onoe Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -118,6 +118,7 @@
static void fwohci_atrs_output(struct fwohci_softc *, int, struct fwohci_pkt *,
struct fwohci_pkt *);
+static int fwohci_guidrom_init(struct fwohci_softc *);
static void fwohci_configrom_init(struct fwohci_softc *);
static void fwohci_selfid_init(struct fwohci_softc *);
@@ -170,26 +171,10 @@
printf("%s: OHCI %u.%u", sc->sc_sc1394.sc1394_dev.dv_xname,
OHCI_Version_GET_Version(val), OHCI_Version_GET_Revision(val));
- /* Is the Global UID ROM present?
- */
- if ((val & OHCI_Version_GUID_ROM) == 0) {
- printf("\n%s: fatal: no global UID ROM\n", sc->sc_sc1394.sc1394_dev.dv_xname);
+ if (fwohci_guidrom_init(sc) != 0) {
+ printf("\n%s: fatal: no global UID ROM\n",
+ sc->sc_sc1394.sc1394_dev.dv_xname);
return -1;
- } else {
-
- /* Extract the Global UID
- */
- val = OHCI_CSR_READ(sc, OHCI_REG_GUIDHi);
- sc->sc_sc1394.sc1394_guid[0] = (val >> 24) & 0xff;
- sc->sc_sc1394.sc1394_guid[1] = (val >> 16) & 0xff;
- sc->sc_sc1394.sc1394_guid[2] = (val >> 8) & 0xff;
- sc->sc_sc1394.sc1394_guid[3] = (val >> 0) & 0xff;
-
- val = OHCI_CSR_READ(sc, OHCI_REG_GUIDLo);
- sc->sc_sc1394.sc1394_guid[4] = (val >> 24) & 0xff;
- sc->sc_sc1394.sc1394_guid[5] = (val >> 16) & 0xff;
- sc->sc_sc1394.sc1394_guid[6] = (val >> 8) & 0xff;
- sc->sc_sc1394.sc1394_guid[7] = (val >> 0) & 0xff;
}
printf(", %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
@@ -1802,6 +1787,63 @@
*/
/*
+ * Retrieve Global UID from GUID ROM
+ */
+static int
+fwohci_guidrom_init(struct fwohci_softc *sc)
+{
+ int i, n, off;
+ u_int32_t val1, val2;
+
+ /* Extract the Global UID
+ */
+ val1 = OHCI_CSR_READ(sc, OHCI_REG_GUIDHi);
+ val2 = OHCI_CSR_READ(sc, OHCI_REG_GUIDLo);
+
+ if (val1 != 0 || val2 != 0) {
+ sc->sc_sc1394.sc1394_guid[0] = (val1 >> 24) & 0xff;
+ sc->sc_sc1394.sc1394_guid[1] = (val1 >> 16) & 0xff;
+ sc->sc_sc1394.sc1394_guid[2] = (val1 >> 8) & 0xff;
+ sc->sc_sc1394.sc1394_guid[3] = (val1 >> 0) & 0xff;
+ sc->sc_sc1394.sc1394_guid[4] = (val2 >> 24) & 0xff;
+ sc->sc_sc1394.sc1394_guid[5] = (val2 >> 16) & 0xff;
+ sc->sc_sc1394.sc1394_guid[6] = (val2 >> 8) & 0xff;
+ sc->sc_sc1394.sc1394_guid[7] = (val2 >> 0) & 0xff;
+ } else {
+ val1 = OHCI_CSR_READ(sc, OHCI_REG_Version);
+ if ((val1 & OHCI_Version_GUID_ROM) == 0)
+ return -1;
+ OHCI_CSR_WRITE(sc, OHCI_REG_Guid_Rom, OHCI_Guid_AddrReset);
+ for (i = 0; i < OHCI_LOOP; i++) {
+ val1 = OHCI_CSR_READ(sc, OHCI_REG_Guid_Rom);
+ if (!(val1 & OHCI_Guid_AddrReset))
+ break;
+ }
+ off = ((val1 & OHCI_Guid_MiniROM_MASK)
+ >> OHCI_Guid_MiniROM_BITPOS) + 4;
+ val2 = 0;
+ for (n = 0; n < off + sizeof(sc->sc_sc1394.sc1394_guid); n++) {
+ OHCI_CSR_WRITE(sc, OHCI_REG_Guid_Rom,
+ OHCI_Guid_RdStart);
+ for (i = 0; i < OHCI_LOOP; i++) {
+ val1 = OHCI_CSR_READ(sc, OHCI_REG_Guid_Rom);
+ if (!(val1 & OHCI_Guid_RdStart))
+ break;
+ }
+ if (n < off)
+ continue;
+ val1 = (val1 & OHCI_Guid_RdData_MASK)
+ >> OHCI_Guid_RdData_BITPOS;
+ sc->sc_sc1394.sc1394_guid[n - off] = val1;
+ val2 |= val1;
+ }
+ if (val2 == 0)
+ return -1;
+ }
+ return 0;
+}
+
+/*
* Initialization for Configuration ROM (no DMA context)
*/
diff -r 2e9c756bbc77 -r 7586fe70c595 sys/dev/ieee1394/fwohcireg.h
--- a/sys/dev/ieee1394/fwohcireg.h Sat Mar 03 01:46:04 2001 +0000
+++ b/sys/dev/ieee1394/fwohcireg.h Sat Mar 03 02:04:54 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fwohcireg.h,v 1.5 2000/12/13 11:30:15 enami Exp $ */
+/* $NetBSD: fwohcireg.h,v 1.6 2001/03/03 02:04:55 onoe Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -208,6 +208,15 @@
#define OHCI_Version_GET_Version(x) ((((x) >> 16) & 0xf) + (((x) >> 20) & 0xf) * 10)
#define OHCI_Version_GET_Revision(x) ((((x) >> 4) & 0xf) + ((x) & 0xf) * 10)
+/* OHCI_REG_Guid_Rom
+ */
+#define OHCI_Guid_AddrReset 0x80000000
+#define OHCI_Guid_RdStart 0x02000000
+#define OHCI_Guid_RdData_MASK 0x00ff0000
+#define OHCI_Guid_RdData_BITPOS 16
+#define OHCI_Guid_MiniROM_MASK 0x000000ff
+#define OHCI_Guid_MiniROM_BITPOS 0
+
/* OHCI_REG_GUIDxx
*/
Home |
Main Index |
Thread Index |
Old Index