generic_timer.c (302408) | generic_timer.c (305866) |
---|---|
1/*- 2 * Copyright (c) 2011 The FreeBSD Foundation 3 * Copyright (c) 2013 Ruslan Bukin <br@bsdpad.com> 4 * All rights reserved. 5 * 6 * Based on mpcore_timer.c developed by Ben Gray <ben.r.gray@gmail.com> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 24 unchanged lines hidden (view full) --- 33/** 34 * Cortex-A7, Cortex-A15, ARMv8 and later Generic Timer 35 */ 36 37#include "opt_acpi.h" 38#include "opt_platform.h" 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2011 The FreeBSD Foundation 3 * Copyright (c) 2013 Ruslan Bukin <br@bsdpad.com> 4 * All rights reserved. 5 * 6 * Based on mpcore_timer.c developed by Ben Gray <ben.r.gray@gmail.com> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 24 unchanged lines hidden (view full) --- 33/** 34 * Cortex-A7, Cortex-A15, ARMv8 and later Generic Timer 35 */ 36 37#include "opt_acpi.h" 38#include "opt_platform.h" 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: stable/11/sys/arm/arm/generic_timer.c 299851 2016-05-15 13:20:59Z manu $"); | 41__FBSDID("$FreeBSD: stable/11/sys/arm/arm/generic_timer.c 305866 2016-09-16 10:04:28Z kib $"); |
42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/bus.h> 46#include <sys/kernel.h> 47#include <sys/module.h> 48#include <sys/malloc.h> 49#include <sys/rman.h> --- 50 unchanged lines hidden (view full) --- 100static struct resource_spec timer_spec[] = { 101 { SYS_RES_IRQ, 0, RF_ACTIVE }, /* Secure */ 102 { SYS_RES_IRQ, 1, RF_ACTIVE }, /* Non-secure */ 103 { SYS_RES_IRQ, 2, RF_ACTIVE | RF_OPTIONAL }, /* Virt */ 104 { SYS_RES_IRQ, 3, RF_ACTIVE | RF_OPTIONAL }, /* Hyp */ 105 { -1, 0 } 106}; 107 | 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/bus.h> 46#include <sys/kernel.h> 47#include <sys/module.h> 48#include <sys/malloc.h> 49#include <sys/rman.h> --- 50 unchanged lines hidden (view full) --- 100static struct resource_spec timer_spec[] = { 101 { SYS_RES_IRQ, 0, RF_ACTIVE }, /* Secure */ 102 { SYS_RES_IRQ, 1, RF_ACTIVE }, /* Non-secure */ 103 { SYS_RES_IRQ, 2, RF_ACTIVE | RF_OPTIONAL }, /* Virt */ 104 { SYS_RES_IRQ, 3, RF_ACTIVE | RF_OPTIONAL }, /* Hyp */ 105 { -1, 0 } 106}; 107 |
108static uint32_t arm_tmr_fill_vdso_timehands(struct vdso_timehands *vdso_th, 109 struct timecounter *tc); 110static void arm_tmr_do_delay(int usec, void *); 111 |
|
108static timecounter_get_t arm_tmr_get_timecount; 109 110static struct timecounter arm_tmr_timecount = { 111 .tc_name = "ARM MPCore Timecounter", 112 .tc_get_timecount = arm_tmr_get_timecount, 113 .tc_poll_pps = NULL, 114 .tc_counter_mask = ~0u, 115 .tc_frequency = 0, 116 .tc_quality = 1000, | 112static timecounter_get_t arm_tmr_get_timecount; 113 114static struct timecounter arm_tmr_timecount = { 115 .tc_name = "ARM MPCore Timecounter", 116 .tc_get_timecount = arm_tmr_get_timecount, 117 .tc_poll_pps = NULL, 118 .tc_counter_mask = ~0u, 119 .tc_frequency = 0, 120 .tc_quality = 1000, |
121 .tc_fill_vdso_timehands = arm_tmr_fill_vdso_timehands, |
|
117}; 118 119#ifdef __arm__ 120#define get_el0(x) cp15_## x ##_get() 121#define get_el1(x) cp15_## x ##_get() 122#define set_el0(x, val) cp15_## x ##_set(val) 123#define set_el1(x, val) cp15_## x ##_set(val) 124#else /* __aarch64__ */ 125#define get_el0(x) READ_SPECIALREG(x ##_el0) 126#define get_el1(x) READ_SPECIALREG(x ##_el1) 127#define set_el0(x, val) WRITE_SPECIALREG(x ##_el0, val) 128#define set_el1(x, val) WRITE_SPECIALREG(x ##_el1, val) 129#endif 130 | 122}; 123 124#ifdef __arm__ 125#define get_el0(x) cp15_## x ##_get() 126#define get_el1(x) cp15_## x ##_get() 127#define set_el0(x, val) cp15_## x ##_set(val) 128#define set_el1(x, val) cp15_## x ##_set(val) 129#else /* __aarch64__ */ 130#define get_el0(x) READ_SPECIALREG(x ##_el0) 131#define get_el1(x) READ_SPECIALREG(x ##_el1) 132#define set_el0(x, val) WRITE_SPECIALREG(x ##_el0, val) 133#define set_el1(x, val) WRITE_SPECIALREG(x ##_el1, val) 134#endif 135 |
131static uint32_t arm_tmr_fill_vdso_timehands(struct vdso_timehands *vdso_th, 132 struct timecounter *tc); 133static void arm_tmr_do_delay(int usec, void *); 134 | |
135static int 136get_freq(void) 137{ 138 return (get_el0(cntfrq)); 139} 140 141static long 142get_cntxct(bool physical) --- 264 unchanged lines hidden (view full) --- 407 error = bus_setup_intr(dev, sc->res[i], INTR_TYPE_CLK, 408 arm_tmr_intr, NULL, sc, &sc->ihl[i]); 409 if (error) { 410 device_printf(dev, "Unable to alloc int resource.\n"); 411 return (ENXIO); 412 } 413 } 414 | 136static int 137get_freq(void) 138{ 139 return (get_el0(cntfrq)); 140} 141 142static long 143get_cntxct(bool physical) --- 264 unchanged lines hidden (view full) --- 408 error = bus_setup_intr(dev, sc->res[i], INTR_TYPE_CLK, 409 arm_tmr_intr, NULL, sc, &sc->ihl[i]); 410 if (error) { 411 device_printf(dev, "Unable to alloc int resource.\n"); 412 return (ENXIO); 413 } 414 } 415 |
415 arm_cpu_fill_vdso_timehands = arm_tmr_fill_vdso_timehands; 416 | |
417 arm_tmr_timecount.tc_frequency = sc->clkfreq; 418 tc_init(&arm_tmr_timecount); 419 420 sc->et.et_name = "ARM MPCore Eventtimer"; 421 sc->et.et_flags = ET_FLAGS_ONESHOT | ET_FLAGS_PERCPU; 422 sc->et.et_quality = 1000; 423 424 sc->et.et_frequency = sc->clkfreq; --- 105 unchanged lines hidden (view full) --- 530} 531#endif 532 533static uint32_t 534arm_tmr_fill_vdso_timehands(struct vdso_timehands *vdso_th, 535 struct timecounter *tc) 536{ 537 | 416 arm_tmr_timecount.tc_frequency = sc->clkfreq; 417 tc_init(&arm_tmr_timecount); 418 419 sc->et.et_name = "ARM MPCore Eventtimer"; 420 sc->et.et_flags = ET_FLAGS_ONESHOT | ET_FLAGS_PERCPU; 421 sc->et.et_quality = 1000; 422 423 sc->et.et_frequency = sc->clkfreq; --- 105 unchanged lines hidden (view full) --- 529} 530#endif 531 532static uint32_t 533arm_tmr_fill_vdso_timehands(struct vdso_timehands *vdso_th, 534 struct timecounter *tc) 535{ 536 |
537 vdso_th->th_algo = VDSO_TH_ALGO_ARM_GENTIM; |
|
538 vdso_th->th_physical = arm_tmr_sc->physical; 539 bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); | 538 vdso_th->th_physical = arm_tmr_sc->physical; 539 bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); |
540 return (tc == &arm_tmr_timecount); | 540 return (1); |
541} | 541} |