Part of the weekly Friday blast of Raspberry Pi posts on the Adafruit blog, they highlighted a series of posts by Sean Cross who developed a PWM kernel module for the Pi:
How Sean gets ready for RPi k-deving, Poking at /dev/mem – hacking without a net & more…
How Sean gets ready for RPi k-deving & How Sean started the skeleton of the hardware PWM kernel module. But wait, there’s more! Poking at /dev/mem – hacking without a net! Before writing up the PWM kernel module, Sean wanted to spend some user-space time prodding the registers for PWM. The fastest way to do this is to simply open up /dev/mem and index to the PWM control registers. This isn’t for the faint-of-heart, as a little incorrect math and you can possibly bork your Pi installation but it is as fast & furious as it gets with embedded Linux.
Here's a brief snippet from each of his posts:
Getting new hardware is always an exciting time. When dealing with old, familiar hardware, it's possible to become complacent. When a problem arises, the solution is simple, obvious, and requires no intake of new knowledge. At worst you know exactly where to find the answer in the manual or source file. But new hardware is great. It's a trip back to ignorance.
Pwm Driver Part 1: Housekeeping
The Raspberry Pi has a single PWM port, but in order to drive it you need to directly map register memory and talk directly to several different subsystems, each of which has a confusing chapter in the manual (if it's documented at all) in order to get it to work. Let's see if we can create a kernel driver to make life simpler
Now that we have the basis for working in the kernel, we need to figure out what it is we want to do exactly. Fortunately it's possible to prototype this code in userspace and really get a feel for how the PWM block behaves before moving it into the kernel
Cheers,
Drew