Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/omap Don't rely on hardcoded clocks now that we...



details:   https://anonhg.NetBSD.org/src/rev/622fd44f2786
branches:  trunk
changeset: 787395:622fd44f2786
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Jun 15 21:58:20 2013 +0000

description:
Don't rely on hardcoded clocks now that we determine the actual ref clk
in the startup code.

diffstat:

 sys/arch/arm/omap/omap2_mputmr.c |  22 ++++++++++++++++------
 sys/arch/arm/omap/omap2_obio.c   |  19 ++++++++++++++++---
 sys/arch/arm/omap/omap_dmtimer.c |  17 ++++++++++++-----
 sys/arch/arm/omap/omap_var.h     |   3 +++
 4 files changed, 47 insertions(+), 14 deletions(-)

diffs (197 lines):

diff -r a1d8d939aa4a -r 622fd44f2786 sys/arch/arm/omap/omap2_mputmr.c
--- a/sys/arch/arm/omap/omap2_mputmr.c  Sat Jun 15 21:55:09 2013 +0000
+++ b/sys/arch/arm/omap/omap2_mputmr.c  Sat Jun 15 21:58:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: omap2_mputmr.c,v 1.5 2013/01/16 23:27:05 jmcneill Exp $        */
+/*     $NetBSD: omap2_mputmr.c,v 1.6 2013/06/15 21:58:20 matt Exp $    */
 
 /*
  * OMAP 2430 GP timers
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap2_mputmr.c,v 1.5 2013/01/16 23:27:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2_mputmr.c,v 1.6 2013/06/15 21:58:20 matt Exp $");
 
 #include "opt_omap.h"
 #include "opt_cpuoptions.h"
@@ -109,7 +109,9 @@
 static struct timecounter mpu_timecounter = {
        .tc_get_timecount = mpu_get_timecount,
        .tc_counter_mask = 0xffffffff,
+#ifdef OMAP_MPU_TIMER_CLOCK_FREQ
        .tc_frequency = OMAP_MPU_TIMER_CLOCK_FREQ,
+#endif
        .tc_name = "gpt",
        .tc_quality = 100,
        .tc_priv = NULL
@@ -251,6 +253,14 @@
        _timer_intr_enb(clock_sc);
        _timer_intr_enb(stat_sc);
 
+#ifndef OMAP_MPU_TIMER_CLOCK_FREQ
+       /*
+        * Make sure to copy the system clock frequency over.
+        */
+       if (omap_sys_clk)
+               mpu_timecounter.tc_frequency = omap_sys_clk;
+#endif
+
        tc_init(&mpu_timecounter);
 }
 
@@ -308,7 +318,7 @@
                 */
                tf->ptv = 0;
                tf->reload = 0;
-               tf->counts_per_usec = OMAP_MPU_TIMER_CLOCK_FREQ / us_per_sec;
+               tf->counts_per_usec = omap_sys_clk / us_per_sec;
                return;
        }
 
@@ -316,15 +326,15 @@
        tf->ptv = 8;
        for (;;) {
                ptv_power = 1 << tf->ptv;
-               count_freq = OMAP_MPU_TIMER_CLOCK_FREQ;
+               count_freq = omap_sys_clk;
                count_freq /= ints_per_sec;
                count_freq /= ptv_power;
                tf->reload = -count_freq;
                tf->counts_per_usec = count_freq / us_per_sec;
                if ((tf->reload * ptv_power * ints_per_sec
-                    == OMAP_MPU_TIMER_CLOCK_FREQ)
+                    == omap_sys_clk)
                    && (tf->counts_per_usec * ptv_power * us_per_sec
-                       == OMAP_MPU_TIMER_CLOCK_FREQ))
+                       == omap_sys_clk))
                {       /* Exact match.  Life is good. */
                        /* Currently reload is MPU_LOAD_TIMER+1.  Fix it. */
                        tf->reload--;
diff -r a1d8d939aa4a -r 622fd44f2786 sys/arch/arm/omap/omap2_obio.c
--- a/sys/arch/arm/omap/omap2_obio.c    Sat Jun 15 21:55:09 2013 +0000
+++ b/sys/arch/arm/omap/omap2_obio.c    Sat Jun 15 21:58:20 2013 +0000
@@ -1,7 +1,7 @@
-/*     $Id: omap2_obio.c,v 1.20 2013/04/17 14:35:34 bouyer Exp $       */
+/*     $Id: omap2_obio.c,v 1.21 2013/06/15 21:58:20 matt Exp $ */
 
 /* adapted from: */
-/*     $NetBSD: omap2_obio.c,v 1.20 2013/04/17 14:35:34 bouyer Exp $ */
+/*     $NetBSD: omap2_obio.c,v 1.21 2013/06/15 21:58:20 matt Exp $ */
 
 
 /*
@@ -103,7 +103,7 @@
 
 #include "opt_omap.h"
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap2_obio.c,v 1.20 2013/04/17 14:35:34 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2_obio.c,v 1.21 2013/06/15 21:58:20 matt Exp $");
 
 #include "locators.h"
 #include "obio.h"
@@ -130,6 +130,13 @@
        ulong           cs_size;
 } obio_csconfig_t;
 
+/* global containing the base system frequency */
+#ifdef OMAP_MPU_TIMER_CLOCK_FREQ
+u_int omap_sys_clk = OMAP_MPU_TIMER_CLOCK_FREQ;
+#else
+u_int omap_sys_clk;
+#endif
+
 /* prototypes */
 static int     obio_match(device_t, cfdata_t, void *);
 static void    obio_attach(device_t, device_t, void *);
@@ -378,6 +385,12 @@
 #if defined(GPIO6_BASE)
        { .name = "gpio6", .addr = GPIO6_BASE, .required = false },
 #endif
+#if defined(GPIO7_BASE)
+       { .name = "gpio7", .addr = GPIO7_BASE, .required = false },
+#endif
+#if defined(GPIO8_BASE)
+       { .name = "gpio8", .addr = GPIO8_BASE, .required = false },
+#endif
 #if 0
        { .name = "dmac", .addr = DMAC_BASE, .required = true },
 #endif
diff -r a1d8d939aa4a -r 622fd44f2786 sys/arch/arm/omap/omap_dmtimer.c
--- a/sys/arch/arm/omap/omap_dmtimer.c  Sat Jun 15 21:55:09 2013 +0000
+++ b/sys/arch/arm/omap/omap_dmtimer.c  Sat Jun 15 21:58:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: omap_dmtimer.c,v 1.1 2012/12/11 19:01:18 riastradh Exp $       */
+/*     $NetBSD: omap_dmtimer.c,v 1.2 2013/06/15 21:58:20 matt Exp $    */
 
 /*
  * TI OMAP Dual-mode timers
@@ -34,22 +34,23 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap_dmtimer.c,v 1.1 2012/12/11 19:01:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap_dmtimer.c,v 1.2 2013/06/15 21:58:20 matt Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/atomic.h>
 #include <sys/bus.h>
 #include <sys/device.h>
+#include <sys/intr.h>
 #include <sys/kernel.h>
 #include <sys/timetc.h>
 
-#include <machine/intr.h>
-
 #include <arm/omap/omap2_prcm.h>
 #include <arm/omap/omap_dmtimerreg.h>
 #include <arm/omap/omap_dmtimervar.h>
 
+#include <arm/omap/omap_var.h>
+
 typedef uint8_t dmt_reg_t;
 typedef uint16_t dmt_timer_reg_t;
 
@@ -94,7 +95,9 @@
 static struct timecounter dmt_timecounter = {
        .tc_get_timecount       = dmt_tc_get_timecount,
        .tc_counter_mask        = 0xffffffff, /* XXXMAGIC Make sense?  */
+#ifdef OMAP_SYSTEM_CLOCK_FREQ
        .tc_frequency           = OMAP_SYSTEM_CLOCK_FREQ, /* XXXPOWER */
+#endif
        .tc_name                = "dmtimer", /* XXX Which one?  */
        .tc_quality             = 100, /* XXXMAGIC?  */
        .tc_priv                = NULL,
@@ -151,6 +154,10 @@
                panic("omap dmtimer statclock not initialized");
        dmt_enable(timecounter_sc);
        dmt_start_timecounter(timecounter_sc);
+
+#ifndef OMAP_SYSTEM_CLOCK_FREQ
+       dmt_timecounter.tc_frequency = omap_sys_clk;
+#endif
        tc_init(&dmt_timecounter);
 }
 
@@ -259,7 +266,7 @@
         * clock frequency by default.  On the AM335x, the system clock
         * frequency is 24 MHz, but dmtimer0 runs at 32 kHz.
         */
-       value = (0xffffffff - ((OMAP_SYSTEM_CLOCK_FREQ / frequency) - 1));
+       value = (0xffffffff - ((omap_sys_clk / frequency) - 1));
 
        dmt_timer_write_4(sc, OMAP_DMTIMER_TIMER_LOAD, value);
        dmt_timer_write_4(sc, OMAP_DMTIMER_TIMER_COUNTER, value);
diff -r a1d8d939aa4a -r 622fd44f2786 sys/arch/arm/omap/omap_var.h
--- a/sys/arch/arm/omap/omap_var.h      Sat Jun 15 21:55:09 2013 +0000
+++ b/sys/arch/arm/omap/omap_var.h      Sat Jun 15 21:58:20 2013 +0000
@@ -16,4 +16,7 @@
 /* platform needs to provide this */
 bus_dma_tag_t omap_bus_dma_init(struct arm32_bus_dma_tag *);
 
+/* platform needs to provide this */
+extern u_int omap_sys_clk;
+
 #endif /* _ARM_OMAP_OMAP_VAR_H_ */



Home | Main Index | Thread Index | Old Index