diff options
author | imp <imp@FreeBSD.org> | 2012-07-11 17:11:07 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2012-07-11 17:11:07 +0000 |
commit | 1d3ba5c3ca11b6e10f08cad2b2fd551ac74cd969 (patch) | |
tree | 8b265584227d1d3211a4a93b16aa1a18c9c93e51 /sys/arm/at91/at91_rst.c | |
parent | 786ac825530572ff02b9440ed00f28096197f9b9 (diff) | |
download | FreeBSD-src-1d3ba5c3ca11b6e10f08cad2b2fd551ac74cd969.zip FreeBSD-src-1d3ba5c3ca11b6e10f08cad2b2fd551ac74cd969.tar.gz |
at91$DEV->at91_$DEV to match other Atmel drivers. Also, export
at91_rst_cpu_reset.
Diffstat (limited to 'sys/arm/at91/at91_rst.c')
-rw-r--r-- | sys/arm/at91/at91_rst.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/sys/arm/at91/at91_rst.c b/sys/arm/at91/at91_rst.c index dbd041b..0879072 100644 --- a/sys/arm/at91/at91_rst.c +++ b/sys/arm/at91/at91_rst.c @@ -42,26 +42,26 @@ __FBSDID("$FreeBSD$"); #define RST_TIMEOUT (5) /* Seconds to hold NRST for hard reset */ #define RST_TICK (20) /* sample NRST at hz/RST_TICK intervals */ -static int at91rst_intr(void *arg); +static int at91_rst_intr(void *arg); -static struct at91rst_softc { +static struct at91_rst_softc { struct resource *mem_res; /* Memory resource */ struct resource *irq_res; /* IRQ resource */ void *intrhand; /* Interrupt handle */ struct callout tick_ch; /* Tick callout */ device_t sc_dev; u_int shutdown; /* Shutdown in progress */ -} *at91rst_sc; +} *at91_rst_sc; static inline uint32_t -RD4(struct at91rst_softc *sc, bus_size_t off) +RD4(struct at91_rst_softc *sc, bus_size_t off) { return (bus_read_4(sc->mem_res, off)); } static inline void -WR4(struct at91rst_softc *sc, bus_size_t off, uint32_t val) +WR4(struct at91_rst_softc *sc, bus_size_t off, uint32_t val) { bus_write_4(sc->mem_res, off, val); @@ -70,17 +70,17 @@ WR4(struct at91rst_softc *sc, bus_size_t off, uint32_t val) void cpu_reset_sam9g20(void) __attribute__((weak)); void cpu_reset_sam9g20(void) {} -static void -at91rst_cpu_reset(void) +void +at91_rst_cpu_reset(void) { - if (at91rst_sc) { + if (at91_rst_sc) { cpu_reset_sam9g20(); /* May be null */ - WR4(at91rst_sc, RST_MR, + WR4(at91_rst_sc, RST_MR, RST_MR_ERSTL(0xd) | RST_MR_URSTEN | RST_MR_KEY); - WR4(at91rst_sc, RST_CR, + WR4(at91_rst_sc, RST_CR, RST_CR_PROCRST | RST_CR_PERRST | RST_CR_EXTRST | @@ -91,7 +91,7 @@ at91rst_cpu_reset(void) } static int -at91rst_probe(device_t dev) +at91_rst_probe(device_t dev) { device_set_desc(dev, "AT91SAM9 Reset Controller"); @@ -99,13 +99,13 @@ at91rst_probe(device_t dev) } static int -at91rst_attach(device_t dev) +at91_rst_attach(device_t dev) { - struct at91rst_softc *sc; + struct at91_rst_softc *sc; const char *cause; int rid, err; - at91rst_sc = sc = device_get_softc(dev); + at91_rst_sc = sc = device_get_softc(dev); sc->sc_dev = dev; callout_init(&sc->tick_ch, 0); @@ -129,11 +129,11 @@ at91rst_attach(device_t dev) /* Activate the interrupt. */ err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, - at91rst_intr, NULL, sc, &sc->intrhand); + at91_rst_intr, NULL, sc, &sc->intrhand); if (err) device_printf(dev, "could not establish interrupt handler.\n"); - WR4(at91rst_sc, RST_MR, RST_MR_ERSTL(0xd) | RST_MR_URSIEN | RST_MR_KEY); + WR4(at91_rst_sc, RST_MR, RST_MR_ERSTL(0xd) | RST_MR_URSIEN | RST_MR_KEY); switch (RD4(sc, RST_SR) & RST_SR_RST_MASK) { case RST_SR_RST_POW: @@ -157,15 +157,14 @@ at91rst_attach(device_t dev) } device_printf(dev, "Reset cause: %s.\n", cause); - soc_data.reset = at91rst_cpu_reset; out: return (err); } static void -at91rst_tick(void *argp) +at91_rst_tick(void *argp) { - struct at91rst_softc *sc = argp; + struct at91_rst_softc *sc = argp; if (sc->shutdown++ >= RST_TIMEOUT * RST_TICK) { /* User released the button in morre than RST_TIMEOUT */ @@ -176,36 +175,36 @@ at91rst_tick(void *argp) device_printf(sc->sc_dev, "shutting down...\n"); shutdown_nice(0); } else { - callout_reset(&sc->tick_ch, hz/RST_TICK, at91rst_tick, sc); + callout_reset(&sc->tick_ch, hz/RST_TICK, at91_rst_tick, sc); } } static int -at91rst_intr(void *argp) +at91_rst_intr(void *argp) { - struct at91rst_softc *sc = argp; + struct at91_rst_softc *sc = argp; if (RD4(sc, RST_SR) & RST_SR_URSTS) { if (sc->shutdown == 0) - callout_reset(&sc->tick_ch, hz/RST_TICK, at91rst_tick, sc); + callout_reset(&sc->tick_ch, hz/RST_TICK, at91_rst_tick, sc); return (FILTER_HANDLED); } return (FILTER_STRAY); } -static device_method_t at91rst_methods[] = { - DEVMETHOD(device_probe, at91rst_probe), - DEVMETHOD(device_attach, at91rst_attach), +static device_method_t at91_rst_methods[] = { + DEVMETHOD(device_probe, at91_rst_probe), + DEVMETHOD(device_attach, at91_rst_attach), DEVMETHOD_END }; -static driver_t at91rst_driver = { +static driver_t at91_rst_driver = { "at91_rst", - at91rst_methods, - sizeof(struct at91rst_softc), + at91_rst_methods, + sizeof(struct at91_rst_softc), }; -static devclass_t at91rst_devclass; +static devclass_t at91_rst_devclass; -DRIVER_MODULE(at91_rst, atmelarm, at91rst_driver, at91rst_devclass, NULL, +DRIVER_MODULE(at91_rst, atmelarm, at91_rst_driver, at91_rst_devclass, NULL, NULL); |