socsvn commit: r238093 - in soc2012/aleek/beaglexm-armv6/sys/arm: conf ti/am37x

aleek at FreeBSD.org aleek at FreeBSD.org
Thu Jun 21 15:37:39 UTC 2012


Author: aleek
Date: Thu Jun 21 15:37:36 2012
New Revision: 238093
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238093

Log:
  modified Event Timer Clock. Still not working

Modified:
  soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM
  soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer.h
  soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c

Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM	Thu Jun 21 14:55:35 2012	(r238092)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM	Thu Jun 21 15:37:36 2012	(r238093)
@@ -49,6 +49,8 @@
 
 # Debugging
 makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+#makeoptions	WERROR="-Werror"
+#makeoptions WERROR=""
 options		BREAK_TO_DEBUGGER
 #options		VERBOSE_SYSINIT		#Enable verbose sysinit messages
 options		KDB

Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer.h
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer.h	Thu Jun 21 14:55:35 2012	(r238092)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer.h	Thu Jun 21 15:37:36 2012	(r238093)
@@ -144,10 +144,16 @@
 omap3_timer_tick_intr(void *arg);
 
 static int
-omap3_gptimer_probe(device_t dev);
+omap3_gptimer_probe_tc(device_t dev);
 
 static int
-omap3_gptimer_attach(device_t dev);
+omap3_gptimer_attach_tc(device_t dev);
+
+static int
+omap3_gptimer_probe_et(device_t dev);
+
+static int
+omap3_gptimer_attach_et(device_t dev);
 
 int
 omap3_gptimer_write_count(struct omap3_gptimer_softc *sc, uint32_t cnt);

Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c	Thu Jun 21 14:55:35 2012	(r238092)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c	Thu Jun 21 15:37:36 2012	(r238093)
@@ -64,7 +64,8 @@
 #include <arm/ti/ti_prcm.h>
 #include <arm/ti/am37x/am37x_gptimer.h>
 
-static struct omap3_gptimer_softc *g_omap3_gptimer_sc = NULL;
+static struct omap3_gptimer_softc *g_omap3_gptimer_sc_tc = NULL;
+static struct omap3_gptimer_softc *g_omap3_gptimer_sc_et = NULL;
 
 static unsigned int delay_loops_per_us = 100;
 
@@ -150,7 +151,7 @@
 omap3_gptimer_tc_get_timecount(struct timecounter *tc)
 {
 	uint32_t count;
-	omap3_gptimer_read_count(g_omap3_gptimer_sc, &count);
+	omap3_gptimer_read_count(g_omap3_gptimer_sc_tc, &count);
 	return(count);
 
 }
@@ -175,7 +176,7 @@
 		
 	/* Get a pointer to the individual sc struct */
 	
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 	
 	if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG)) {
 		ret = EINVAL;
@@ -184,7 +185,7 @@
 		ret = 0;
 	}
 
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 	
 	return (ret);
 }
@@ -210,11 +211,11 @@
 	if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG))
 		return (EINVAL);
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 	
 	omap3_gptimer_writel(sc, OMAP3_GPT_TCRR, cnt);
 
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 	
 	return (0);
 }
@@ -285,7 +286,7 @@
 		return (rc);
 
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 	
 	/* Determine if the pre-scalar is enabled and if so the prescaler value */
 	tclr = omap3_gptimer_readl(sc, OMAP3_GPT_TCLR);
@@ -297,7 +298,7 @@
 	/* Get the reload count */
 	tldr = omap3_gptimer_readl(sc, OMAP3_GPT_TLDR);
 	
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 	
 	
 	/* Calculate the tick freq */
@@ -363,7 +364,7 @@
 		return (EINVAL);
 	}
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 
 	/* Enable the functional and interface clock */
 	if (flags & OMAP3_GPTIMER_32KCLK_FLAG)
@@ -462,6 +463,7 @@
 		sc->callback_data = data;
 		
 		/* Activate the interrupt */
+		printf( "bus_setup_intr(): %s:%d\n", __func__, __LINE__ );
 		if (bus_setup_intr(sc->sc_dev, sc->irq_res, 
 		                   INTR_TYPE_MISC | INTR_MPSAFE, NULL, omap3_gptimer_intr,
 						   (void*)sc, &sc->irq_h)) {
@@ -479,7 +481,7 @@
 	/* Finally set the activated flag */
 	sc->flags |= OMAP3_GPTIMER_ACTIVATED_FLAG;
 
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 	
 	printf("[BRG] %s, %d\n", __func__, __LINE__);
 
@@ -505,13 +507,13 @@
 	if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG))
 		return (EINVAL);
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 
 	val = omap3_gptimer_readl(sc, OMAP3_GPT_TCLR);
 	val |= TCLR_ST;
 	omap3_gptimer_writel(sc, OMAP3_GPT_TCLR, val);
 
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 
 	return 0;
 }
@@ -535,13 +537,13 @@
 	if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG))
 		return (EINVAL);
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 	
 	val = omap3_gptimer_readl(sc, OMAP3_GPT_TCLR);
 	val &= ~TCLR_ST;
 	omap3_gptimer_writel(sc, OMAP3_GPT_TCLR, val);
 
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 
 	return 0;
 }
@@ -563,27 +565,28 @@
 	if (sc == NULL)
 		return (ENOMEM);
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 
 	/* If a callback is already installed this won't work */
 	if (sc->callback != NULL) {
-		OMAP3_GPTIMER_UNLOCK(sc);
+		//OMAP3_GPTIMER_UNLOCK(sc);
 		return(EINVAL);
 	}
 	
 	/* Sanity check the timer is already activated and periodic type */
 	if ((sc->flags & (OMAP3_GPTIMER_ACTIVATED_FLAG | OMAP3_GPTIMER_PERIODIC_FLAG))
 	    != (OMAP3_GPTIMER_ACTIVATED_FLAG | OMAP3_GPTIMER_PERIODIC_FLAG)) {
-		OMAP3_GPTIMER_UNLOCK(sc);
+		//OMAP3_GPTIMER_UNLOCK(sc);
 		return(EINVAL);
 	}
 	
 	
 	/* Attempt to activate the interrupt for the tick */
+		printf( "bus_setup_intr(): %s:%d\n", __func__, __LINE__ );
 	if (bus_setup_intr(sc->sc_dev, sc->irq_res, INTR_TYPE_CLK,
 	                   filter, NULL, NULL, &sc->irq_h)) {
 		device_printf(sc->sc_dev, "Error: failed to activate interrupt\n");
-		OMAP3_GPTIMER_UNLOCK(sc);
+		//OMAP3_GPTIMER_UNLOCK(sc);
 		return(EINVAL);
 	}
 	
@@ -595,7 +598,7 @@
 		omap3_gptimer_writel(sc, OMAP3_GPT_TIER, val);
 	}
 	
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 	
 	return(0);
 }
@@ -615,7 +618,7 @@
 {
 	uint32_t stat;
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 	
 	/* Read the interrupt status flag and clear it */
 	/* Read the status and it with the enable flag */
@@ -624,7 +627,7 @@
 		
 	/* Clear the status flag */
 	omap3_gptimer_writel(sc, OMAP3_GPT_TISR, stat);
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 }
 
 
@@ -659,7 +662,7 @@
 	int32_t counts;
 	//uint32_t first, last;
 
-	if (g_omap3_gptimer_sc == NULL) {
+	if (g_omap3_gptimer_sc_tc == NULL) {
 		for (; usec > 0; usec--)
 			for (counts = 200; counts > 0; counts--)
 				/* Prevent gcc from optimizing  out the loop */
@@ -676,7 +679,7 @@
 	void*    callback_data;
 	uint32_t stat = 0x0000;
 
-	OMAP3_GPTIMER_LOCK(sc);
+	//OMAP3_GPTIMER_LOCK(sc);
 
 	/* Read the interrupt status flag and clear it */
 	if (sc->profile == OMAP_GPTIMER_PROFILE_OMAP3) {
@@ -693,7 +696,7 @@
 	callback = sc->callback;
 	callback_data = sc->callback_data;
 	
-	OMAP3_GPTIMER_UNLOCK(sc);
+	//OMAP3_GPTIMER_UNLOCK(sc);
 
 	/* Check if an actual overflow interrupt */
 	if ((stat & OVF) && (callback != NULL))
@@ -712,7 +715,6 @@
  *	RETURNS:
  *	Always returns FILTER_HANDLED. 
  */
-#if 0
 static int
 omap3_timer_tick_intr(void *arg)
 {
@@ -722,7 +724,7 @@
 #endif
 
 	/* Acknowledge the interrupt */
-	omap3_gptimer_intr_filter_ack(TICKTIMER_GPTIMER);
+	omap3_gptimer_intr_filter_ack(g_omap3_gptimer_sc_et);
 
 	/* Heartbeat */
 #if defined(OMAP3_HEARTBEAT_GPIO)
@@ -739,33 +741,18 @@
 	/* Indicate we've handed the interrupt */
 	return (FILTER_HANDLED);
 }
-#endif
-
 
-static int
-omap3_gptimer_probe(device_t dev)
-{
-	//struct	omap3_gptimer_softc *sc = (struct omap3_gptimer_softc *)device_get_softc(dev);
 
-	if (ofw_bus_is_compatible(dev, "ti,omap3_gptimer_tc")) {
-		device_set_desc(dev, "OMAP3 General Purpose Timer - Tick Counter");
-		return(BUS_PROBE_DEFAULT);
-	}
-
-	return (ENXIO);
-}
 
 static int
-omap3_gptimer_attach(device_t dev)
+omap3_gptimer_attach_common(device_t dev)
 {
 	struct omap3_gptimer_softc *sc = device_get_softc(dev);
-	char name[32];
+	//char name[32];
 	int rid=0; // resource id for device, unique
 	uint32_t rev;
-	u_int oldirqstate;
-	unsigned int timer_freq;
 
-	device_printf( dev, "Attaching the device..." );
+	device_printf( dev, "Generic attaching the device...\n" );
 
 
 	// Setup the basics
@@ -786,8 +773,8 @@
 	sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | RF_SHAREABLE); //@TODO XXX Why shareable?
 
 	/* Mutex to protect the shared data structures */
-	snprintf(name, 32, "omap_gptimer_tc");
-	mtx_init(&sc->mtx, device_get_nameunit(dev), name, MTX_SPIN);
+	//snprintf(name, 32, "omap_gptimer_tc");
+	//mtx_init(&sc->mtx, device_get_nameunit(dev), name, MTX_SPIN);
 
 	// I decided to delete support for OMAP4 timers from the original code - aleek
 	rev = omap3_gptimer_readl(sc, OMAP3_GPT_TIDR);
@@ -809,10 +796,36 @@
 		              rev);
 		return (ENXIO);
 	}
+	device_printf( dev, "done!\n" );
+
+	return 0;
+}
+
+static int
+omap3_gptimer_probe_tc(device_t dev)
+{
+	//struct	omap3_gptimer_softc *sc = (struct omap3_gptimer_softc *)device_get_softc(dev);
+
+	if (ofw_bus_is_compatible(dev, "ti,omap3_gptimer_tc")) {
+		device_set_desc(dev, "OMAP3 General Purpose Timer - Tick Counter");
+		return(BUS_PROBE_DEFAULT);
+	}
+
+	return (ENXIO);
+}
+
+static int
+omap3_gptimer_attach_tc(device_t dev)
+{
+	u_int oldirqstate;
+	unsigned int timer_freq;
+	struct omap3_gptimer_softc *sc = device_get_softc(dev);
+
+	omap3_gptimer_attach_common(dev);
 	/* Set the clock source for the timer, this is just a one to one
 	 * mapping of the clock id to timer, i.e. n=0 => GPTIMER1_CLK.
 	 */
-	sc->source = GPTIMER10_CLK; // @TODO XXX fix this - the timer number shouldn't be hardcoded
+	sc->source = GPTIMER11_CLK; // @TODO XXX fix this - the timer number shouldn't be hardcoded
 
 	/* Finally mark the timer as available */
 	sc->flags = OMAP3_GPTIMER_AVAILABLE_FLAG;
@@ -832,7 +845,7 @@
 	omap3_gptimer_tc.tc_frequency = timer_freq;
 	
 	/* Setup the time counter */
-	tc_init(&omap3_gptimer_tc);
+	//tc_init(&omap3_gptimer_tc);
 
 	/* Calibrate the delay loop */
 	omap3_calibrate_delay_loop(&omap3_gptimer_tc);
@@ -840,24 +853,100 @@
 	/* Restore interrupt state */
 	restore_interrupts(oldirqstate);
 
-	g_omap3_gptimer_sc = sc;
+	g_omap3_gptimer_sc_tc = sc;
 
 	return 0;
 }
 
-static device_method_t g_omap3_gptimer_methods[] = {
-	DEVMETHOD(device_probe, omap3_gptimer_probe),
-	DEVMETHOD(device_attach, omap3_gptimer_attach),
+static device_method_t g_omap3_gptimer_methods_tc[] = {
+	DEVMETHOD(device_probe, omap3_gptimer_probe_tc),
+	DEVMETHOD(device_attach, omap3_gptimer_attach_tc),
 	{0, 0},
 };
 
-static driver_t g_omap3_gptimer_driver = {
+static driver_t g_omap3_gptimer_driver_tc = {
 	"omap3_gptimer_tc",
-	g_omap3_gptimer_methods,
+	g_omap3_gptimer_methods_tc,
 	sizeof(struct omap3_gptimer_softc),
 };
-static devclass_t g_omap3_gptimer_devclass;
+static devclass_t g_omap3_gptimer_devclass_tc;
+
+DRIVER_MODULE(omap3_gptimer_tc, simplebus, g_omap3_gptimer_driver_tc, g_omap3_gptimer_devclass_tc, 0, 0);
+MODULE_DEPEND(omap3_gptimer_tc, ti_prcm, 1, 1, 1);
+
+
+static int
+omap3_gptimer_probe_et(device_t dev)
+{
+	//struct	omap3_gptimer_softc *sc = (struct omap3_gptimer_softc *)device_get_softc(dev);
 
-DRIVER_MODULE(omap3_gptimer, simplebus, g_omap3_gptimer_driver, g_omap3_gptimer_devclass, 0, 0);
-///MODULE_DEPEND(omap3_gptimer, ti_prcm, 1, 1, 1);
+	if (ofw_bus_is_compatible(dev, "ti,omap3_gptimer_et")) {
+		device_set_desc(dev, "OMAP3 General Purpose Timer - Event Timer");
+		return(BUS_PROBE_DEFAULT);
+	}
+
+	return (ENXIO);
+}
+
+static int
+omap3_gptimer_attach_et(device_t dev)
+{
+	u_int oldirqstate;
+	unsigned int timer_freq;
+	struct omap3_gptimer_softc *sc = device_get_softc(dev);
+
+	omap3_gptimer_attach_common(dev);
+	device_printf( dev, "Timer specyfic attaching...\n" );
+	/* Set the clock source for the timer, this is just a one to one
+	 * mapping of the clock id to timer, i.e. n=0 => GPTIMER1_CLK.
+	 */
+	sc->source = GPTIMER10_CLK; // @TODO XXX fix this - the timer number shouldn't be hardcoded
+
+	/* Finally mark the timer as available */
+	sc->flags = OMAP3_GPTIMER_AVAILABLE_FLAG;
+
+	/* setup GPTIMER10 for system ticks, and GPTIMER11 for general purpose counter */
+	oldirqstate = disable_interrupts(I32_bit);
+
+	/* Number of microseconds between interrupts */
+	unsigned int tick = 1000000 / hz;
+
+	/* Next setup one of the timers to be the system tick timer */
+	if (omap3_gptimer_activate(sc, OMAP3_GPTIMER_PERIODIC_FLAG, tick, NULL, NULL)) {
+		panic("Error: failed to activate system tick timer\n");
+	}
+	
+	/* Setup an interrupt filter for the timer */
+	if (omap3_gptimer_set_intr_filter(sc, omap3_timer_tick_intr))
+		panic("Error: failed to start system tick timer\n");
+	
+	/* Lastly start the tick timer */
+	if (omap3_gptimer_start(sc))
+		panic("Error: failed to start system tick timer\n");
+
+	omap3_gptimer_get_freq(sc, &timer_freq);
+	device_printf(dev, "tick: timer_freq = %u\n", timer_freq);
+
+	/* Restore interrupt state */
+	restore_interrupts(oldirqstate);
+
+	g_omap3_gptimer_sc_et = sc;
+
+	return 0;
+}
+
+static device_method_t g_omap3_gptimer_methods_et[] = {
+	DEVMETHOD(device_probe, omap3_gptimer_probe_et),
+	DEVMETHOD(device_attach, omap3_gptimer_attach_et),
+	{0, 0},
+};
+
+static driver_t g_omap3_gptimer_driver_et = {
+	"omap3_gptimer_et",
+	g_omap3_gptimer_methods_et,
+	sizeof(struct omap3_gptimer_softc),
+};
+static devclass_t g_omap3_gptimer_devclass_et;
 
+DRIVER_MODULE(omap3_gptimer_et, simplebus, g_omap3_gptimer_driver_et, g_omap3_gptimer_devclass_et, 0, 0);
+MODULE_DEPEND(omap3_gptimer_et, ti_prcm, 1, 1, 1);


More information about the svn-soc-all mailing list