Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Aug 2012 12:15:33 +0000
From:      aleek@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r240466 - in soc2012/aleek/beaglexm-armv6/sys: arm/ti/omap3 boot/fdt/dts
Message-ID:  <20120817121533.5CA84106564A@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: aleek
Date: Fri Aug 17 12:15:32 2012
New Revision: 240466
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240466

Log:
  GPTimer refactored. Device ID of the timer is saved on DTS file, so the driver became independent of the selected clocks.

Modified:
  soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.c
  soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.h
  soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts

Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.c	Fri Aug 17 11:43:36 2012	(r240465)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.c	Fri Aug 17 12:15:32 2012	(r240466)
@@ -738,10 +738,20 @@
 {
 	struct omap3_gptimer_softc *sc = device_get_softc(dev);
 	int rid=0; // resource id for device, unique
+	phandle_t node;
+	pcell_t did;
 
 	//device_printf( dev, "Generic attaching the device...\n" );
 	sc->sc_dev = dev;
 
+	/* Get the i2c device id from FDT */
+	node = ofw_bus_get_node(dev);
+	if ((OF_getprop(node, "device-id", &did, sizeof(did))) <= 0) {
+		device_printf(dev, "missing device-id attribute in FDT\n");
+		return (ENXIO);
+	}
+	sc->device_id = fdt32_to_cpu(did);
+
 	/* First try and get the register addresses, if this fails we assume
 	 * there are no more timers.
 	 */
@@ -753,9 +763,14 @@
 	}
 
 	/* Next try and get the interrupt resource, this is not fatal */
-	sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | RF_SHAREABLE); //@TODO XXX Why shareable?
-			sc->profile = OMAP_GPTIMER_PROFILE_OMAP3;
+	//@TODO XXX Why shareable?
+	sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | RF_SHAREABLE); 
+	sc->profile = OMAP_GPTIMER_PROFILE_OMAP3;
 
+	/* 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 = GPTIMER1_CLK + sc->device_id - 1;
 	return 0;
 }
 
@@ -780,12 +795,8 @@
 	struct omap3_gptimer_softc *sc = device_get_softc(dev);
 
 	omap3_gptimer_attach_common(dev);
+	device_printf( dev, "Timecounter on GPTimer%d starting...\n", sc->device_id );
 	mtx_init(&sc->mtx, device_get_nameunit(dev), "omap3_gptimer_tc", MTX_SPIN );
-	/* 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 = 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;
 
@@ -857,11 +868,9 @@
 	struct omap3_gptimer_softc *sc = device_get_softc(dev);
 
 	omap3_gptimer_attach_common(dev);
+
+	device_printf( dev, "EventTimer on GPTimer%d starting...\n", sc->device_id );
 	mtx_init(&sc->mtx, device_get_nameunit(dev), "omap3_gptimer_et", MTX_SPIN );
-	/* 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;

Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.h
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.h	Fri Aug 17 11:43:36 2012	(r240465)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/omap3/omap3_gptimer.h	Fri Aug 17 12:15:32 2012	(r240466)
@@ -108,7 +108,11 @@
 
 	/* The source clock to use */
 	unsigned int        source;
-	
+
+	/* Device ID of the timer. There is 11 GPTimers, so we have to know.
+	 * which one we use. Counting from 1.
+	 */
+	unsigned int		device_id;
 };
 
 void

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts	Fri Aug 17 11:43:36 2012	(r240465)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts	Fri Aug 17 12:15:32 2012	(r240466)
@@ -130,6 +130,7 @@
 			#size-cells = <1>;
 			reg =	< 0x48086000 0x1000 >;
 			interrupts = < 46 >;
+			device-id = <10>;
 			interrupt-parent = <&AINTC>;
 		};
 
@@ -139,6 +140,7 @@
 			#size-cells = <1>;
 			reg =	< 0x48088000 0x1000 >;
 			interrupts = < 47 >;
+			device-id = <11>;
 			interrupt-parent = <&AINTC>;
 		};
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120817121533.5CA84106564A>