'Right' way to implement a PWM driver?

Gordon Hollingworth gordon at holliweb.co.uk
Sat Apr 26 07:09:47 PDT 2014

I'm trying to implement the extensions to the PWM driver so that I can
use the serial mode of the PWM driver to talk to an external device.

The external device is a serial device so I want to create a linux
driver that I can open from user space, setup some parameters and send
some data (relatively small quantities of data)

The last time I did this was back in linux 2.4 days and what I would
have done then is:

  function for my device driver to register and grab one of the PWM
channels bcm2835_pwm_unregister()
  to cleanup
  function to set the PWM modes / polarity / dma fifo setup
  function to actually write data into the dma fifo


Create a character device with an open() ioctl() write() interface

open() to open the device, would register with the PWM

ioctl() used to set up the device, setting some device specific
information.  This would configure the pwm channel correctly and allow
device reset commands to be sent

write() used to actually format the data correctly and write it to the PWM

Can someone help me with understanding whether this is still the way
to do this?  Or should I use the sysfs interface or procfs interface
to provide the interfacing mechanism?  Any idea of an example device
that does a similar thing?

Thanks everyone sorry to be slightly off-topic although it is going to
be RPI specific!

More information about the linux-rpi-kernel mailing list