svn commit: r238369 - head/sys/arm/at91

Warner Losh imp at FreeBSD.org
Wed Jul 11 17:11:08 UTC 2012


Author: imp
Date: Wed Jul 11 17:11:07 2012
New Revision: 238369
URL: http://svn.freebsd.org/changeset/base/238369

Log:
  at91$DEV->at91_$DEV to match other Atmel drivers.  Also, export
  at91_rst_cpu_reset.

Modified:
  head/sys/arm/at91/at91_rst.c
  head/sys/arm/at91/at91_rstreg.h

Modified: head/sys/arm/at91/at91_rst.c
==============================================================================
--- head/sys/arm/at91/at91_rst.c	Wed Jul 11 16:52:25 2012	(r238368)
+++ head/sys/arm/at91/at91_rst.c	Wed Jul 11 17:11:07 2012	(r238369)
@@ -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
 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);

Modified: head/sys/arm/at91/at91_rstreg.h
==============================================================================
--- head/sys/arm/at91/at91_rstreg.h	Wed Jul 11 16:52:25 2012	(r238368)
+++ head/sys/arm/at91/at91_rstreg.h	Wed Jul 11 17:11:07 2012	(r238369)
@@ -25,8 +25,8 @@
 
 /* $FreeBSD$ */
 
-#ifndef ARM_AT91_AT91RSTREG_H
-#define ARM_AT91_AT91RSTREG_H
+#ifndef ARM_AT91_AT91_RSTREG_H
+#define ARM_AT91_AT91_RSTREG_H
 
 #define	RST_CR		0x0	/* Control Register */
 #define	RST_SR		0x4	/* Status Register */
@@ -56,4 +56,8 @@
 #define	RST_MR_ERSTL(x)		((x)<<8) /* External reset length */	
 #define	RST_MR_KEY		(0xa5<<24)
 
-#endif /* ARM_AT91_AT91RSTREG_H */
+#ifndef __ASSEMBLER__
+void at91_rst_cpu_reset(void);
+#endif
+
+#endif /* ARM_AT91_AT91_RSTREG_H */


More information about the svn-src-all mailing list