Deleted Added
full compact
bcm2835_systimer.c (244758) bcm2835_systimer.c (247463)
1/*
2 * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * Copyright (c) 2012 Damjan Marion <dmarion@freebsd.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * Copyright (c) 2012 Damjan Marion <dmarion@freebsd.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c 244758 2012-12-28 01:38:43Z gonzo $");
29__FBSDID("$FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c 247463 2013-02-28 13:46:03Z mav $");
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/malloc.h>
37#include <sys/rman.h>

--- 75 unchanged lines hidden (view full) ---

113
114static unsigned
115bcm_systimer_tc_get_timecount(struct timecounter *tc)
116{
117 return bcm_systimer_tc_read_4(SYSTIMER_CLO);
118}
119
120static int
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/malloc.h>
37#include <sys/rman.h>

--- 75 unchanged lines hidden (view full) ---

113
114static unsigned
115bcm_systimer_tc_get_timecount(struct timecounter *tc)
116{
117 return bcm_systimer_tc_read_4(SYSTIMER_CLO);
118}
119
120static int
121bcm_systimer_start(struct eventtimer *et, struct bintime *first,
122 struct bintime *period)
121bcm_systimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
123{
124 struct systimer *st = et->et_priv;
125 uint32_t clo;
126 uint32_t count;
127 register_t s;
128
122{
123 struct systimer *st = et->et_priv;
124 uint32_t clo;
125 uint32_t count;
126 register_t s;
127
129 if (first != NULL) {
128 if (first != 0) {
130
129
131 count = (st->et.et_frequency * (first->frac >> 32)) >> 32;
132 if (first->sec != 0)
133 count += st->et.et_frequency * first->sec;
130 count = ((uint32_t)et->et_frequency * first) >> 32;
134
135 s = intr_disable();
136 clo = bcm_systimer_tc_read_4(SYSTIMER_CLO);
137 clo += count;
138 /*
139 * Clear pending interrupts
140 */
141 bcm_systimer_tc_write_4(SYSTIMER_CS, (1 << st->index));

--- 91 unchanged lines hidden (view full) ---

233
234 sc->st[DEFAULT_TIMER].index = DEFAULT_TIMER;
235 sc->st[DEFAULT_TIMER].enabled = 0;
236 sc->st[DEFAULT_TIMER].et.et_name = malloc(64, M_DEVBUF, M_NOWAIT | M_ZERO);
237 sprintf(sc->st[DEFAULT_TIMER].et.et_name, "BCM2835 Event Timer %d", DEFAULT_TIMER);
238 sc->st[DEFAULT_TIMER].et.et_flags = ET_FLAGS_ONESHOT;
239 sc->st[DEFAULT_TIMER].et.et_quality = 1000;
240 sc->st[DEFAULT_TIMER].et.et_frequency = sc->sysclk_freq;
131
132 s = intr_disable();
133 clo = bcm_systimer_tc_read_4(SYSTIMER_CLO);
134 clo += count;
135 /*
136 * Clear pending interrupts
137 */
138 bcm_systimer_tc_write_4(SYSTIMER_CS, (1 << st->index));

--- 91 unchanged lines hidden (view full) ---

230
231 sc->st[DEFAULT_TIMER].index = DEFAULT_TIMER;
232 sc->st[DEFAULT_TIMER].enabled = 0;
233 sc->st[DEFAULT_TIMER].et.et_name = malloc(64, M_DEVBUF, M_NOWAIT | M_ZERO);
234 sprintf(sc->st[DEFAULT_TIMER].et.et_name, "BCM2835 Event Timer %d", DEFAULT_TIMER);
235 sc->st[DEFAULT_TIMER].et.et_flags = ET_FLAGS_ONESHOT;
236 sc->st[DEFAULT_TIMER].et.et_quality = 1000;
237 sc->st[DEFAULT_TIMER].et.et_frequency = sc->sysclk_freq;
241 sc->st[DEFAULT_TIMER].et.et_min_period.sec = 0;
242 sc->st[DEFAULT_TIMER].et.et_min_period.frac =
243 ((MIN_PERIOD << 32) / sc->st[DEFAULT_TIMER].et.et_frequency) << 32;
244 sc->st[DEFAULT_TIMER].et.et_max_period.sec = 0xfffffff0U / sc->st[DEFAULT_TIMER].et.et_frequency;
245 sc->st[DEFAULT_TIMER].et.et_max_period.frac =
246 ((0xfffffffeLLU << 32) / sc->st[DEFAULT_TIMER].et.et_frequency) << 32;
238 sc->st[DEFAULT_TIMER].et.et_min_period =
239 (MIN_PERIOD << 32) / sc->st[DEFAULT_TIMER].et.et_frequency;
240 sc->st[DEFAULT_TIMER].et.et_max_period =
241 (0xfffffffeLLU << 32) / sc->st[DEFAULT_TIMER].et.et_frequency;
247 sc->st[DEFAULT_TIMER].et.et_start = bcm_systimer_start;
248 sc->st[DEFAULT_TIMER].et.et_stop = bcm_systimer_stop;
249 sc->st[DEFAULT_TIMER].et.et_priv = &sc->st[DEFAULT_TIMER];
250 et_register(&sc->st[DEFAULT_TIMER].et);
251
252 bcm_systimer_sc = sc;
253
254 bcm_systimer_tc.tc_frequency = DEFAULT_FREQUENCY;

--- 58 unchanged lines hidden ---
242 sc->st[DEFAULT_TIMER].et.et_start = bcm_systimer_start;
243 sc->st[DEFAULT_TIMER].et.et_stop = bcm_systimer_stop;
244 sc->st[DEFAULT_TIMER].et.et_priv = &sc->st[DEFAULT_TIMER];
245 et_register(&sc->st[DEFAULT_TIMER].et);
246
247 bcm_systimer_sc = sc;
248
249 bcm_systimer_tc.tc_frequency = DEFAULT_FREQUENCY;

--- 58 unchanged lines hidden ---