Deleted Added
full compact
sp804.c (244197) sp804.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/versatile/sp804.c 244197 2012-12-13 23:19:13Z gonzo $");
29__FBSDID("$FreeBSD: head/sys/arm/versatile/sp804.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>

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

115static unsigned
116sp804_timer_tc_get_timecount(struct timecounter *tc)
117{
118 struct sp804_timer_softc *sc = tc->tc_priv;
119 return 0xffffffff - sp804_timer_tc_read_4(SP804_TIMER1_VALUE);
120}
121
122static 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>

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

115static unsigned
116sp804_timer_tc_get_timecount(struct timecounter *tc)
117{
118 struct sp804_timer_softc *sc = tc->tc_priv;
119 return 0xffffffff - sp804_timer_tc_read_4(SP804_TIMER1_VALUE);
120}
121
122static int
123sp804_timer_start(struct eventtimer *et, struct bintime *first,
124 struct bintime *period)
123sp804_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
125{
126 struct sp804_timer_softc *sc = et->et_priv;
127 uint32_t count, reg;
128
124{
125 struct sp804_timer_softc *sc = et->et_priv;
126 uint32_t count, reg;
127
129 if (first != NULL) {
128 if (first != 0) {
130 sc->et_enabled = 1;
131
129 sc->et_enabled = 1;
130
132 count = (sc->et.et_frequency * (first->frac >> 32)) >> 32;
133 if (first->sec != 0)
134 count += sc->et.et_frequency * first->sec;
131 count = ((uint32_t)et->et_frequency * first) >> 32;
135
136 sp804_timer_tc_write_4(SP804_TIMER2_LOAD, count);
137 reg = TIMER_CONTROL_32BIT | TIMER_CONTROL_INTREN |
138 TIMER_CONTROL_PERIODIC | DEFAULT_CONTROL_DIV |
139 TIMER_CONTROL_EN;
140 sp804_timer_tc_write_4(SP804_TIMER2_CONTROL, reg);
141
142 return (0);
143 }
144
132
133 sp804_timer_tc_write_4(SP804_TIMER2_LOAD, count);
134 reg = TIMER_CONTROL_32BIT | TIMER_CONTROL_INTREN |
135 TIMER_CONTROL_PERIODIC | DEFAULT_CONTROL_DIV |
136 TIMER_CONTROL_EN;
137 sp804_timer_tc_write_4(SP804_TIMER2_CONTROL, reg);
138
139 return (0);
140 }
141
145 if (period != NULL) {
142 if (period != 0) {
146 panic("period");
147 }
148
149 return (EINVAL);
150}
151
152static int
153sp804_timer_stop(struct eventtimer *et)

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

259 */
260 sc->et_enabled = 0;
261 sc->et.et_name = malloc(64, M_DEVBUF, M_NOWAIT | M_ZERO);
262 sprintf(sc->et.et_name, "SP804 Event Timer %d",
263 device_get_unit(dev));
264 sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
265 sc->et.et_quality = 1000;
266 sc->et.et_frequency = sc->sysclk_freq / DEFAULT_DIVISOR;
143 panic("period");
144 }
145
146 return (EINVAL);
147}
148
149static int
150sp804_timer_stop(struct eventtimer *et)

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

256 */
257 sc->et_enabled = 0;
258 sc->et.et_name = malloc(64, M_DEVBUF, M_NOWAIT | M_ZERO);
259 sprintf(sc->et.et_name, "SP804 Event Timer %d",
260 device_get_unit(dev));
261 sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
262 sc->et.et_quality = 1000;
263 sc->et.et_frequency = sc->sysclk_freq / DEFAULT_DIVISOR;
267 sc->et.et_min_period.sec = 0;
268 sc->et.et_min_period.frac =
269 ((0x00000002LLU << 32) / sc->et.et_frequency) << 32;
270 sc->et.et_max_period.sec = 0xfffffff0U / sc->et.et_frequency;
271 sc->et.et_max_period.frac =
272 ((0xfffffffeLLU << 32) / sc->et.et_frequency) << 32;
264 sc->et.et_min_period = (0x00000002LLU << 32) / sc->et.et_frequency;
265 sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency;
273 sc->et.et_start = sp804_timer_start;
274 sc->et.et_stop = sp804_timer_stop;
275 sc->et.et_priv = sc;
276 et_register(&sc->et);
277
278 id = 0;
279 for (i = 3; i >= 0; i--) {
280 id = (id << 8) |

--- 72 unchanged lines hidden ---
266 sc->et.et_start = sp804_timer_start;
267 sc->et.et_stop = sp804_timer_stop;
268 sc->et.et_priv = sc;
269 et_register(&sc->et);
270
271 id = 0;
272 for (i = 3; i >= 0; i--) {
273 id = (id << 8) |

--- 72 unchanged lines hidden ---