RTEMS | bsp/aarch64/raspberrypi4: Add PWM peripheral support (!509)
Kinsey Moore (@opticron)
gitlab at rtems.org
Thu Jun 19 14:04:27 UTC 2025
Kinsey Moore commented on a discussion on bsps/aarch64/raspberrypi/pwm/raspberrypi-pwm.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/509#note_124926
> +#define BCM2711_CM_PWM(x) BCM2835_REG(BCM2711_CM_PWM_BASE + (x))
> +#define CM_PWM_CTL_ENABLE_OSC (CM_PWM_PASSWD | CM_PWM_CTL_ENAB | CM_PWM_CTL_SRC_OSC)
> +#define CM_PWM_CTL_DISABLE (CM_PWM_PASSWD | CM_PWM_CTL_SRC_OSC)
> +
> +static inline bool rpi_pwm_validate(raspberrypi_pwm_master master,
> + raspberrypi_pwm_channel channel)
> +{
> + return ((master == raspberrypi_pwm_master0) || (master == raspberrypi_pwm_master1)) &&
> + ((channel == raspberrypi_pwm0) || (channel == raspberrypi_pwm1));
> +}
> +
> +rtems_status_code rpi_pwm_set_clock(uint32_t divisor)
> +{
> + if (divisor == 0) {
> + return RTEMS_INVALID_NUMBER;
> + }
As per the header:
```
/**
* @brief Set PWM clock divider.
* @param divisor 1 – 4095; PWMCLK = 19.2 MHz / @p divisor.
* @retval RTEMS_SUCCESSFUL OK
* @retval RTEMS_INVALID_NUMBER 0 or >4095
*/
rtems_status_code rpi_pwm_set_clock( uint32_t divisor );
```
Please validate according to the comments you provided in the header. Currently, you are checking whether divisor is less than 0 which is not possible with a uint32_t. That check can never be true. This is also still missing the upper bound check.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/509#note_124926
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250619/8ce23210/attachment-0001.htm>
More information about the bugs
mailing list