Date: Thu, 21 Jun 2012 18:59:39 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r238102 - soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x Message-ID: <20120621185939.7799A1065670@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: aleek Date: Thu Jun 21 18:59:38 2012 New Revision: 238102 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238102 Log: timer is working. FreeBSD boots to mounting rootfs Modified: 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/ti/am37x/am37x_gptimer.h ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer.h Thu Jun 21 17:48:28 2012 (r238101) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer.h Thu Jun 21 18:59:38 2012 (r238102) @@ -126,10 +126,10 @@ void (*callback)(void *data), void *data); int -omap3_gptimer_start(struct omap3_gptimer_softc *sc); +omap3_gptimer_start(struct eventtimer *et, struct bintime *first, struct bintime *period); int -omap3_gptimer_stop(struct omap3_gptimer_softc *sc); +omap3_gptimer_stop(struct eventtimer *et); int omap3_gptimer_get_freq(struct omap3_gptimer_softc *sc, uint32_t *freq); 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 17:48:28 2012 (r238101) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c Thu Jun 21 18:59:38 2012 (r238102) @@ -44,6 +44,8 @@ #include <sys/lock.h> #include <sys/gpio.h> #include <sys/mutex.h> +#include <sys/timeet.h> +#include <sys/timetc.h> #include <machine/bus.h> #include <machine/cpu.h> @@ -100,6 +102,8 @@ .tc_quality = 1000, }; +static struct eventtimer omap3_gptimer_et; + #define __omap3_delay(i) \ do { \ unsigned int cnt = (i); \ @@ -435,7 +439,7 @@ /* Calculate the start value */ startcount = 0xFFFFFFFFUL - (uint32_t)(tickcount & 0xFFFFFFFFUL); - printf("[BRG] %s, %d : freq64=%llu : tickcount=%llu : startcount=%u : time_us=%u\n", + printf("%s, %d : freq64=%llu : tickcount=%llu : startcount=%u : time_us=%u\n", __func__, __LINE__, freq64, tickcount, startcount, time_us); } @@ -482,9 +486,6 @@ sc->flags |= OMAP3_GPTIMER_ACTIVATED_FLAG; //OMAP3_GPTIMER_UNLOCK(sc); - - printf("[BRG] %s, %d\n", __func__, __LINE__); - return (0); } @@ -497,8 +498,9 @@ * Returns 0 on success, otherwise an error code */ int -omap3_gptimer_start(struct omap3_gptimer_softc *sc) +omap3_gptimer_start(struct eventtimer *et, struct bintime *first, struct bintime *period) { + struct omap3_gptimer_softc *sc = (struct omap3_gptimer_softc *)et->et_priv; uint32_t val; /* Sanity checks */ @@ -527,8 +529,9 @@ * Returns 0 on success, otherwise an error code */ int -omap3_gptimer_stop(struct omap3_gptimer_softc *sc) +omap3_gptimer_stop(struct eventtimer *et) { + struct omap3_gptimer_softc *sc = (struct omap3_gptimer_softc *)et->et_priv; uint32_t val; /* Sanity checks */ @@ -748,16 +751,10 @@ omap3_gptimer_attach_common(device_t dev) { struct omap3_gptimer_softc *sc = device_get_softc(dev); - //char name[32]; int rid=0; // resource id for device, unique - uint32_t rev; - - device_printf( dev, "Generic attaching the device...\n" ); - - // Setup the basics - //sc->sc_dev = dev; - //sc->sc_tick_timer = NULL; + //device_printf( dev, "Generic attaching the device...\n" ); + sc->sc_dev = dev; /* First try and get the register addresses, if this fails we assume * there are no more timers. @@ -771,32 +768,9 @@ /* 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? - - /* Mutex to protect the shared data structures */ - //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); - switch (rev) { - case 0x00000013: /* OMAP3 without 1ms generation */ - case 0x00000015: - case 0x00000021: /* OMAP3 with 1ms generation */ sc->profile = OMAP_GPTIMER_PROFILE_OMAP3; - break; - break; - default: - sc->profile = OMAP_GPTIMER_PROFILE_UNKNOWN; - break; - } - - if (sc->profile == OMAP_GPTIMER_PROFILE_UNKNOWN) { - device_printf(dev, "Error: failed to determine the type of " - "GPTIMER_tc, ignoring timer (rev: 0x%08x)\n", - rev); - return (ENXIO); - } - device_printf( dev, "done!\n" ); + + //device_printf( dev, "done!\n" ); return 0; } @@ -836,9 +810,9 @@ /* Setup another timer to be the timecounter */ if (omap3_gptimer_activate(sc, OMAP3_GPTIMER_PERIODIC_FLAG, 0, NULL, NULL)) { device_printf(dev, "Error: failed to activate system tick timer\n"); - } else if (omap3_gptimer_start(sc)) { + }/* else if (omap3_gptimer_start(sc)) { device_printf(dev, "Error: failed to start system tick timer\n"); - } + }*/ /* Save the system clock speed */ omap3_gptimer_get_freq(sc, &timer_freq); @@ -896,7 +870,7 @@ struct omap3_gptimer_softc *sc = device_get_softc(dev); omap3_gptimer_attach_common(dev); - device_printf( dev, "Timer specyfic attaching...\n" ); + //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. */ @@ -921,14 +895,26 @@ 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"); + /*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); + omap3_gptimer_et.et_name = "AM37x EventTimer0", + omap3_gptimer_et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT; + omap3_gptimer_et.et_quality = 1000; + omap3_gptimer_et.et_frequency = tick; //@todo XXX naprawic to !! + omap3_gptimer_et.et_min_period.sec = 0; + omap3_gptimer_et.et_min_period.frac = ((0x00000002LLU << 32) / omap3_gptimer_et.et_frequency) << 32; + omap3_gptimer_et.et_max_period.sec = 0xfffffff0U / omap3_gptimer_et.et_frequency; + omap3_gptimer_et.et_max_period.frac = ((0xfffffffeLLU << 32) / omap3_gptimer_et.et_frequency) << 32; + omap3_gptimer_et.et_start = omap3_gptimer_start; + omap3_gptimer_et.et_stop = omap3_gptimer_stop; + omap3_gptimer_et.et_priv = &omap3_gptimer_et; + et_register( &omap3_gptimer_et ); g_omap3_gptimer_sc_et = sc;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120621185939.7799A1065670>