Module Name: src
Committed By: matt
Date: Sat Jun 15 21:58:20 UTC 2013
Modified Files:
src/sys/arch/arm/omap: omap2_mputmr.c omap2_obio.c omap_dmtimer.c
omap_var.h
Log Message:
Don't rely on hardcoded clocks now that we determine the actual ref clk
in the startup code.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/omap/omap2_mputmr.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/omap/omap2_obio.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/omap/omap_dmtimer.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/omap/omap_var.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/omap/omap2_mputmr.c
diff -u src/sys/arch/arm/omap/omap2_mputmr.c:1.5 src/sys/arch/arm/omap/omap2_mputmr.c:1.6
--- src/sys/arch/arm/omap/omap2_mputmr.c:1.5 Wed Jan 16 23:27:05 2013
+++ src/sys/arch/arm/omap/omap2_mputmr.c Sat Jun 15 21:58:20 2013
@@ -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 uint32_t mpu_get_timecount(struct
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 @@ cpu_initclocks(void)
_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 @@ calc_timer_factors(int ints_per_sec, tim
*/
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 @@ calc_timer_factors(int ints_per_sec, tim
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--;
Index: src/sys/arch/arm/omap/omap2_obio.c
diff -u src/sys/arch/arm/omap/omap2_obio.c:1.20 src/sys/arch/arm/omap/omap2_obio.c:1.21
--- src/sys/arch/arm/omap/omap2_obio.c:1.20 Wed Apr 17 14:35:34 2013
+++ src/sys/arch/arm/omap/omap2_obio.c Sat Jun 15 21:58:20 2013
@@ -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 @@ typedef struct {
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 @@ static const struct {
#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
Index: src/sys/arch/arm/omap/omap_dmtimer.c
diff -u src/sys/arch/arm/omap/omap_dmtimer.c:1.1 src/sys/arch/arm/omap/omap_dmtimer.c:1.2
--- src/sys/arch/arm/omap/omap_dmtimer.c:1.1 Tue Dec 11 19:01:18 2012
+++ src/sys/arch/arm/omap/omap_dmtimer.c Sat Jun 15 21:58:20 2013
@@ -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 @@ omap_dmtimer_attach_timecounter(struct o
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 @@ cpu_initclocks(void)
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 @@ dmt_start(struct omap_dmtimer_softc *sc,
* 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);
Index: src/sys/arch/arm/omap/omap_var.h
diff -u src/sys/arch/arm/omap/omap_var.h:1.3 src/sys/arch/arm/omap/omap_var.h:1.4
--- src/sys/arch/arm/omap/omap_var.h:1.3 Fri Jul 1 20:30:21 2011
+++ src/sys/arch/arm/omap/omap_var.h Sat Jun 15 21:58:20 2013
@@ -16,4 +16,7 @@ extern struct bus_space nobyteacc_bs_tag
/* 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_ */