Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/samsung Implement heartbeat LED using the new g...
details: https://anonhg.NetBSD.org/src/rev/6ab058d37819
branches: trunk
changeset: 329129:6ab058d37819
user: reinoud <reinoud%NetBSD.org@localhost>
date: Fri May 09 22:21:46 2014 +0000
description:
Implement heartbeat LED using the new gpio subsystem
diffstat:
sys/arch/arm/samsung/mct.c | 32 +++++++++++++++++++++++++++++---
sys/arch/arm/samsung/mct_var.h | 6 ++++++
2 files changed, 35 insertions(+), 3 deletions(-)
diffs (93 lines):
diff -r 4d65f6cdf86c -r 6ab058d37819 sys/arch/arm/samsung/mct.c
--- a/sys/arch/arm/samsung/mct.c Fri May 09 22:20:41 2014 +0000
+++ b/sys/arch/arm/samsung/mct.c Fri May 09 22:21:46 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mct.c,v 1.1 2014/04/13 02:26:26 matt Exp $ */
+/* $NetBSD: mct.c,v 1.2 2014/05/09 22:21:46 reinoud Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: mct.c,v 1.1 2014/04/13 02:26:26 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: mct.c,v 1.2 2014/05/09 22:21:46 reinoud Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -155,6 +155,7 @@
struct mct_softc * const sc = &mct_sc;
prop_dictionary_t dict = device_properties(self);
char freqbuf[sizeof("XXX SHz")];
+ const char *pin_name;
self->dv_private = sc;
sc->sc_dev = self;
@@ -186,6 +187,19 @@
if (sc->sc_global_ih == NULL)
panic("%s: unable to register timer interrupt", __func__);
aprint_normal_dev(sc->sc_dev, "interrupting on irq %d\n", sc->sc_irq);
+
+ /* blink led */
+ if (prop_dictionary_get_cstring_nocopy(dict, "heartbeat", &pin_name)) {
+ if (!exynos_gpio_pin_reserve(pin_name, &sc->sc_gpio_led)) {
+ aprint_error_dev(self,
+ "failed to reserve GPIO \"%s\" "
+ "for heartbeat led\n", pin_name);
+ } else {
+ sc->sc_has_blink_led = true;
+ sc->sc_led_state = false;
+ sc->sc_led_timer = hz;
+ }
+ }
}
@@ -217,17 +231,29 @@
struct mct_softc * const sc = &mct_sc;
const uint64_t now = mct_gettime(sc);
uint64_t delta = now - sc->sc_lastintr;
+ uint64_t missed = delta / sc->sc_autoinc;
/* ack the interrupt */
mct_write_global(sc, MCT_G_INT_CSTAT, G_INT_CSTAT_CLEAR);
/* check if we missed clock interrupts */
if (delta > sc->sc_autoinc)
- sc->sc_ev_missing_ticks.ev_count += delta / sc->sc_autoinc;
+ sc->sc_ev_missing_ticks.ev_count += missed;
sc->sc_lastintr = now;
hardclock(cf);
+ if (sc->sc_has_blink_led) {
+ sc->sc_led_timer = sc->sc_led_timer - 1 - missed;
+ if (sc->sc_led_timer <= 0) {
+ sc->sc_led_state = !sc->sc_led_state;
+ exynos_gpio_pindata_write(&sc->sc_gpio_led,
+ sc->sc_led_state);
+ while (sc->sc_led_timer <= 0)
+ sc->sc_led_timer += hz;
+ }
+ }
+
/* handled */
return 1;
}
diff -r 4d65f6cdf86c -r 6ab058d37819 sys/arch/arm/samsung/mct_var.h
--- a/sys/arch/arm/samsung/mct_var.h Fri May 09 22:20:41 2014 +0000
+++ b/sys/arch/arm/samsung/mct_var.h Fri May 09 22:21:46 2014 +0000
@@ -47,6 +47,12 @@
uint64_t sc_lastintr;
uint32_t sc_autoinc;
struct evcnt sc_ev_missing_ticks;
+
+ /* blinking led */
+ bool sc_has_blink_led;
+ struct exynos_gpio_pindata sc_gpio_led;
+ bool sc_led_state;
+ int sc_led_timer;
} mct_sc;
void mct_init_cpu_clock(struct cpu_info *ci);
Home |
Main Index |
Thread Index |
Old Index