Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/macppc/dev if we get garbage from the RTC try again...
details: https://anonhg.NetBSD.org/src/rev/6740fe59afa0
branches: trunk
changeset: 331512:6740fe59afa0
user: macallan <macallan%NetBSD.org@localhost>
date: Wed Aug 13 10:56:35 2014 +0000
description:
if we get garbage from the RTC try again a couple times
this seems to happen more frequently when the PRAM battery goes bad
diffstat:
sys/arch/macppc/dev/cuda.c | 43 ++++++++++++++++++++++++++++++-------------
1 files changed, 30 insertions(+), 13 deletions(-)
diffs (109 lines):
diff -r 1d5ac4c0fea3 -r 6740fe59afa0 sys/arch/macppc/dev/cuda.c
--- a/sys/arch/macppc/dev/cuda.c Wed Aug 13 09:41:50 2014 +0000
+++ b/sys/arch/macppc/dev/cuda.c Wed Aug 13 10:56:35 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cuda.c,v 1.19 2014/03/14 21:59:41 mrg Exp $ */
+/* $NetBSD: cuda.c,v 1.20 2014/08/13 10:56:35 macallan Exp $ */
/*-
* Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.19 2014/03/14 21:59:41 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.20 2014/08/13 10:56:35 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -559,8 +559,8 @@
if (sc->sc_received > 255) {
/* bitch only once */
if (sc->sc_received == 256) {
- printf("%s: input overflow\n",
- device_xname(sc->sc_dev));
+ aprint_error_dev(sc->sc_dev,
+ "input overflow\n");
ending = 1;
}
} else
@@ -596,7 +596,8 @@
me->handler(me->cookie,
sc->sc_received - 1, &sc->sc_in[1]);
} else {
- printf("no handler for type %02x\n", type);
+ aprint_error_dev(sc->sc_dev,
+ "no handler for type %02x\n", type);
panic("barf");
}
}
@@ -678,6 +679,7 @@
} else {
/* send next byte */
cuda_write_reg(sc, vSR, sc->sc_out[sc->sc_sent]);
+ DPRINTF("%02x", sc->sc_out[sc->sc_sent]);
cuda_toggle_ack(sc); /* signal byte ready to
* shift */
}
@@ -755,16 +757,28 @@
uint8_t cmd[] = { CUDA_PSEUDO, CMD_READ_RTC};
sc->sc_tod = 0;
- cuda_send(sc, 0, 2, cmd);
+ while (sc->sc_tod == 0) {
+ cuda_send(sc, 0, 2, cmd);
+
+ while ((sc->sc_tod == 0) && (cnt < 10)) {
+ tsleep(&sc->sc_todev, 0, "todr", 10);
+ cnt++;
+ }
- while ((sc->sc_tod == 0) && (cnt < 10)) {
- tsleep(&sc->sc_todev, 0, "todr", 10);
- cnt++;
+ if (sc->sc_tod == 0) {
+ aprint_error_dev(sc->sc_dev,
+ "unable to read a sane RTC value\n");
+ return EIO;
+ }
+ if ((sc->sc_tod > 0xf0000000UL) ||
+ (sc->sc_tod < DIFF19041970)) {
+ /* huh? try again */
+ sc->sc_tod = 0;
+ aprint_verbose_dev(sc->sc_dev,
+ "got garbage reading RTC, trying again\n");
+ }
}
- if (sc->sc_tod == 0)
- return EIO;
-
tvp->tv_sec = sc->sc_tod - DIFF19041970;
DPRINTF("tod: %" PRIo64 "\n", tvp->tv_sec);
tvp->tv_usec = 0;
@@ -787,6 +801,7 @@
}
return 0;
}
+ aprint_error_dev(sc->sc_dev, "%s failed\n", __func__);
return -1;
}
@@ -950,6 +965,7 @@
if (sc->sc_error) {
sc->sc_error = 0;
+ aprint_error_dev(sc->sc_dev, "error doing I2C\n");
return -1;
}
@@ -974,7 +990,8 @@
}
if (sc->sc_error) {
- printf("error trying to read\n");
+ aprint_error_dev(sc->sc_dev,
+ "error trying to read from I2C\n");
sc->sc_error = 0;
return -1;
}
Home |
Main Index |
Thread Index |
Old Index