RTEMS RPi4B BSP 添加system timer驱动支持

RPi4 有两种timer,ARM timer 和 system timer。

The ARM Timer is based on a ARM SP804, but it has a number of differences with the standard SP804.

The clock from the ARM timer is derived from the system clock. This clock can
change dynamically e.g. if the system goes into reduced power or in low power
mode. Thus the clock speed adapts to the overall system performance
capabilities. For accurate timing it is recommended to use the system timers.

RPI4 BSP目前使用的是ARM timer 提供 clock。驱动为 bsps/shared/dev/clock/arm-generic-timer.c。

计划添加system timer驱动,以提供准确计时。

  1. 查阅数据手册可知,RPi4(BCM2811)的 system timer 与 RPi1-3(BCM2835)相互兼容。将位于 bsps/arm/raspberrypi/clock/clockdrv.c 的 system timer 驱动移植到共享目录 bsps/shared/dev/clock/bcm2835-system-timer.c。 需要修改 rpi1-3 BSP的spec文件。spec/build/bsps/arm/raspberrypi/obj.yml。
  2. 为 RPi4 BSP 添加 system timer 支持。
    • 修改 bsps/aarch64/raspberrypi/include/bsp/irq.h 文件。加入system timer中断号。
    #define BCM2711_IRQ_VC_PERIPHERAL_BASE 96
    
    /* Interrupt Vectors: System Timer */
    #define BCM2835_IRQ_ID_GPU_TIMER_M0    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 0)
    #define BCM2835_IRQ_ID_GPU_TIMER_M1    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 1)
    #define BCM2835_IRQ_ID_GPU_TIMER_M2    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 2)
    #define BCM2835_IRQ_ID_GPU_TIMER_M3    (BCM2711_IRQ_VC_PERIPHERAL_BASE + 3)
    
    • 修改 bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h文件。在变量命名方面与BCM2835 system timer兼容。
    • 新建 spec/build/bsps/aarch64/raspberrypi/objsystemtimer.yml 文件,将system timer引入。
    • 在 spec/build/bsps/aarch64/raspberrypi/objclock.yml 中使用 enabled-by: not: 字段实现ARM timer 和 system timer 的选择。
    enabled-by:
      not: BSP_CLOCK_USE_SYSTEMTIMER
    
    • 新建文件 spec/build/bsps/aarch64/raspberrypi/optsystemtimer.yml ,配置为true则使用system timer,为false则使用 ARM timer。
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值