am335x_dmtimer.c (243523) | am335x_dmtimer.c (247463) |
---|---|
1/*- 2 * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/arm/ti/am335x/am335x_dmtimer.c 243523 2012-11-25 16:19:12Z kientzle $"); | 28__FBSDID("$FreeBSD: head/sys/arm/ti/am335x/am335x_dmtimer.c 247463 2013-02-28 13:46:03Z mav $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/kernel.h> 34#include <sys/module.h> 35#include <sys/malloc.h> 36#include <sys/rman.h> --- 101 unchanged lines hidden (view full) --- 138 139static unsigned 140am335x_dmtimer_tc_get_timecount(struct timecounter *tc) 141{ 142 return am335x_dmtimer_tc_read_4(DMTIMER_TCRR); 143} 144 145static int | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/kernel.h> 34#include <sys/module.h> 35#include <sys/malloc.h> 36#include <sys/rman.h> --- 101 unchanged lines hidden (view full) --- 138 139static unsigned 140am335x_dmtimer_tc_get_timecount(struct timecounter *tc) 141{ 142 return am335x_dmtimer_tc_read_4(DMTIMER_TCRR); 143} 144 145static int |
146am335x_dmtimer_start(struct eventtimer *et, struct bintime *first, 147 struct bintime *period) | 146am335x_dmtimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period) |
148{ 149 struct am335x_dmtimer *tmr = (struct am335x_dmtimer *)et->et_priv; 150 uint32_t load, count; 151 uint32_t tclr = 0; 152 | 147{ 148 struct am335x_dmtimer *tmr = (struct am335x_dmtimer *)et->et_priv; 149 uint32_t load, count; 150 uint32_t tclr = 0; 151 |
153 if (period != NULL) { 154 load = (et->et_frequency * (period->frac >> 32)) >> 32; 155 if (period->sec > 0) 156 load += et->et_frequency * period->sec; | 152 if (period != 0) { 153 load = ((uint32_t)et->et_frequency * period) >> 32; |
157 tclr |= 2; /* autoreload bit */ 158 panic("periodic timer not implemented\n"); 159 } else { 160 load = 0; 161 } 162 | 154 tclr |= 2; /* autoreload bit */ 155 panic("periodic timer not implemented\n"); 156 } else { 157 load = 0; 158 } 159 |
163 if (first != NULL) { 164 count = (tmr->et.et_frequency * (first->frac >> 32)) >> 32; 165 if (first->sec != 0) 166 count += tmr->et.et_frequency * first->sec; 167 } else { | 160 if (first != 0) 161 count = ((uint32_t)et->et_frequency * first) >> 32; 162 else |
168 count = load; | 163 count = load; |
169 } | |
170 171 /* Reset Timer */ 172 am335x_dmtimer_et_write_4(DMTIMER_TSICR, 2); 173 174 /* Wait for reset to complete */ 175 while (am335x_dmtimer_et_read_4(DMTIMER_TIOCP_CFG) & 1); 176 177 /* set load value */ --- 133 unchanged lines hidden (view full) --- 311 device_printf(dev, "Unable to setup the clock irq handler.\n"); 312 return (ENXIO); 313 } 314 315 sc->t[3].et.et_name = "AM335x Eventtimer0"; 316 sc->t[3].et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT; 317 sc->t[3].et.et_quality = 1000; 318 sc->t[3].et.et_frequency = sc->sysclk_freq; | 164 165 /* Reset Timer */ 166 am335x_dmtimer_et_write_4(DMTIMER_TSICR, 2); 167 168 /* Wait for reset to complete */ 169 while (am335x_dmtimer_et_read_4(DMTIMER_TIOCP_CFG) & 1); 170 171 /* set load value */ --- 133 unchanged lines hidden (view full) --- 305 device_printf(dev, "Unable to setup the clock irq handler.\n"); 306 return (ENXIO); 307 } 308 309 sc->t[3].et.et_name = "AM335x Eventtimer0"; 310 sc->t[3].et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT; 311 sc->t[3].et.et_quality = 1000; 312 sc->t[3].et.et_frequency = sc->sysclk_freq; |
319 sc->t[3].et.et_min_period.sec = 0; 320 sc->t[3].et.et_min_period.frac = 321 ((0x00000002LLU << 32) / sc->t[3].et.et_frequency) << 32; 322 sc->t[3].et.et_max_period.sec = 0xfffffff0U / sc->t[3].et.et_frequency; 323 sc->t[3].et.et_max_period.frac = 324 ((0xfffffffeLLU << 32) / sc->t[3].et.et_frequency) << 32; | 313 sc->t[3].et.et_min_period = 314 (0x00000002LLU << 32) / sc->t[3].et.et_frequency; 315 sc->t[3].et.et_max_period = 316 (0xfffffffeLLU << 32) / sc->t[3].et.et_frequency; |
325 sc->t[3].et.et_start = am335x_dmtimer_start; 326 sc->t[3].et.et_stop = am335x_dmtimer_stop; 327 sc->t[3].et.et_priv = &sc->t[3]; 328 et_register(&sc->t[3].et); 329 330 return (0); 331} 332 --- 53 unchanged lines hidden --- | 317 sc->t[3].et.et_start = am335x_dmtimer_start; 318 sc->t[3].et.et_stop = am335x_dmtimer_stop; 319 sc->t[3].et.et_priv = &sc->t[3]; 320 et_register(&sc->t[3].et); 321 322 return (0); 323} 324 --- 53 unchanged lines hidden --- |