Page MenuHomeFreeBSD

bcm2835_pwm - add sysctl vars and supporting code for channel 2
ClosedPublic

Authored by bobf_mrp3.com on Jun 12 2018, 5:23 AM.

Details

Summary

currently the bcm2835_pwm driver only allows you to control PWM channel 1. The modifications create additional sysctl variables and the supporting code to independently control PWM channel 2 as well.

Both PWM output channels share the same clock. Each channel's mode, period, and ratio can be modified and controlled independently using the sysctl variables, as before, except that the new variables 'mode2' 'ratio2' and 'period2' were added to control channel 2. The existing variable names were left as-is.

Additional information regarding the CTL register bits was added as a comment, basically copied from the bcm2835 peripheral documentation with an appropriate reference to that document. This can be removed if there's some reason not to put it here. However, it helps to explain the 'magic bit numbers' that were being assigned, and may allow someone to support additional features (like the FIFO) in the future.

It is worth pointing out that the default DTB for the Raspberry Pi model 2 has GPIO pins 40 and 45 set to 'ALT0', which enables the PWM output on them. These pins are connected to the audio output jacks, since (as it appears) the PWM device is also used by the video core to generate audio output.

At some point an overlay may need to be created that disables the audio device so that it will not interfere with the PWM device. As it stands now, if you use the audio output jacks for PWM output, it should work without an overlay, if you do not use any audio output. Otherwise, it's extremely likely that the bcm2835_audio and bcm2835_pwm devices will interfere with one another.

Test Plan

This has been tested on an RPi model 2B and works as expected. At the time there was no audio output enabled.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bobf_mrp3.com created this revision.Jun 12 2018, 5:23 AM

gonzo - I added you as a reviewer since you apparently did the last commit to the driver, and because it's related to the RPi audio.

gonzo accepted this revision.Jul 2 2018, 12:32 AM
This revision is now accepted and ready to land.Jul 2 2018, 12:32 AM
This revision was automatically updated to reflect the committed changes.