1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-10-18 01:32:25 +00:00
serenity/Kernel/Arch/aarch64/RPi/Timer.h
Timon Kruiper dab6dbe893 Kernel: Add interrupt support to aarch64 RPi Timer driver
Since we can now build and use the IRQHandler class, we can implement
interrupt support for the Timer in the aarch64 build.
2022-06-02 13:14:12 +01:00

63 lines
1.2 KiB
C++

/*
* Copyright (c) 2021, Nico Weber <thakis@chromium.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <Kernel/Interrupts/IRQHandler.h>
namespace Kernel::RPi {
struct TimerRegisters;
class Timer : public IRQHandler {
public:
Timer();
static Timer& the();
u64 microseconds_since_boot();
void set_interrupt_interval_usec(u32);
void enable_interrupt_mode();
enum class ClockID {
Reserved = 0,
EMMC = 1,
UART = 2,
ARM = 3,
CORE = 4,
V3D = 5,
H264 = 6,
ISP = 7,
SDRAM = 8,
PIXEL = 9,
PWM = 10,
HEVC = 11,
EMMC2 = 12,
M2MC = 13,
PIXEL_BVB = 14,
};
static u32 set_clock_rate(ClockID, u32 rate_hz, bool skip_setting_turbo = true);
private:
enum class TimerID : u32 {
Timer0 = 0,
Timer1 = 1,
Timer2 = 2,
Timer3 = 3,
};
void set_compare(TimerID, u32 compare);
void clear_interrupt(TimerID);
//^ IRQHandler
virtual bool handle_irq(RegisterState const&) override;
TimerRegisters volatile* m_registers;
u32 m_interrupt_interval { 0 };
u32 m_current_timer_value { 0 };
};
}