1#
2# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3# Copyright (C) 2021, Hensoldt Cyber GmbH
4#
5# SPDX-License-Identifier: GPL-2.0-only
6#
7
8cmake_minimum_required(VERSION 3.7.2)
9
10declare_platform(bcm2711 KernelPlatformRpi4 PLAT_BCM2711 KernelArchARM)
11
12if(KernelPlatformRpi4)
13    if("${KernelSel4Arch}" STREQUAL aarch32)
14        declare_seL4_arch(aarch32)
15    elseif("${KernelSel4Arch}" STREQUAL aarch64)
16        declare_seL4_arch(aarch64)
17    else()
18        # set aarch64 as default for RPi4
19        fallback_declare_seL4_arch_default(aarch64)
20    endif()
21    set(KernelArmCortexA72 ON)
22    set(KernelArchArmV8a ON)
23    config_set(KernelARMPlatform ARM_PLAT rpi4)
24    set(KernelArmMachFeatureModifiers "+crc" CACHE INTERNAL "")
25    list(APPEND KernelDTSList "tools/dts/rpi4.dts")
26    list(APPEND KernelDTSList "src/plat/bcm2711/overlay-rpi4.dts")
27
28    # - The clock frequency is 54 MHz as can be seen in bcm2711.dtsi in the
29    # Linux Kernel under clk_osc, thus TIMER_FREQUENCY = 54000000.
30    # - The GIC-400 offers 216 SPI IRQs (MAX_IRQ = 216) as can be seen in the
31    # BCM2711 TRM under chapter 6.3. The GIC-400 implements the GICv2
32    # architecture.
33    # https://www.raspberrypi.org/forums/viewtopic.php?t=244479&start=25#p1499052
34    # - CLK_MAGIC and CLK_SHIFT can be calculated with:
35    #       tools/reciprocal.py --divisor 54000000
36    declare_default_headers(
37        TIMER_FREQUENCY 54000000
38        MAX_IRQ 216
39        NUM_PPI 32
40        TIMER drivers/timer/arm_generic.h
41        INTERRUPT_CONTROLLER arch/machine/gic_v2.h
42        KERNEL_WCET 10u
43        CLK_MAGIC 5337599559llu
44        CLK_SHIFT 58u
45    )
46endif()
47
48add_sources(
49    DEP "KernelPlatformRpi4"
50    CFILES src/arch/arm/machine/gic_v2.c src/arch/arm/machine/l2c_nop.c
51)
52