// SPDX-License-Identifier: GPL-2.0-or-later /* * OpenRISC time.c * * Linux architectural port borrowing liberally from similar works of * others. All original copyrights apply as per the original source * declaration. * * Modifications for the OpenRISC architecture: * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
*/
/* Test the timer ticks to count, used in sync routine */ inlinevoid openrisc_timer_set(unsignedlong count)
{
mtspr(SPR_TTCR, count);
}
/* Set the timer to trigger in delta cycles */ inlinevoid openrisc_timer_set_next(unsignedlong delta)
{
u32 c;
/* Read 32-bit counter value, add delta, mask off the low 28 bits. * We're guaranteed delta won't be bigger than 28 bits because the * generic timekeeping code ensures that for us.
*/
c = mfspr(SPR_TTCR);
c += delta;
c &= SPR_TTMR_TP;
/* Set counter and enable interrupt. * Keep timer in continuous mode always.
*/
mtspr(SPR_TTMR, SPR_TTMR_CR | SPR_TTMR_IE | c);
}
/* This is the clock event device based on the OR1K tick timer. * As the timer is being used as a continuous clock-source (required for HR * timers) we cannot enable the PERIODIC feature. The tick timer can run using * one-shot events, so no problem.
*/ static DEFINE_PER_CPU(struct clock_event_device, clockevent_openrisc_timer);
/* We only have 28 bits */
clockevents_config_and_register(evt, cpuinfo->clock_frequency,
100, 0x0fffffff);
}
staticinlinevoid timer_ack(void)
{ /* Clear the IP bit and disable further interrupts */ /* This can be done very simply... we just need to keep the timer running, so just maintain the CR bits while clearing the rest of the register
*/
mtspr(SPR_TTMR, SPR_TTMR_CR);
}
/* * The timer interrupt is mostly handled in generic code nowadays... this * function just acknowledges the interrupt and fires the event handler that * has been set on the clockevent device by the generic time management code. * * This function needs to be called by the timer exception handler and that's * all the exception handler needs to do.
*/
/* * update_process_times() expects us to have called irq_enter().
*/
irq_enter();
evt->event_handler(evt);
irq_exit();
set_irq_regs(old_regs);
return IRQ_HANDLED;
}
/* * Clocksource: Based on OpenRISC timer/counter * * This sets up the OpenRISC Tick Timer as a clock source. The tick timer * is 32 bits wide and runs at the CPU clock frequency.
*/ static u64 openrisc_timer_read(struct clocksource *cs)
{ return (u64) mfspr(SPR_TTCR);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.