kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* GPIO Driver Design
@ 2021-05-08 22:52 Robert Joslyn
  0 siblings, 0 replies; only message in thread
From: Robert Joslyn @ 2021-05-08 22:52 UTC (permalink / raw)
  To: kernelnewbies

I'm working on writing a driver for custom hardware, but I'm not sure
the best way to expose the features of the hardware to userspace. The
hardware in question is basically a configurable industrial GPIO board,
but it has additional features that don't seem to map well to the
libgpio subsystem.

The board has a set of output pins that can be treated like normal GPIO
pins. The input pins, however, have additional configuration that can
be set by a user. For example, the inputs can be configured for
different input voltage levels, such as 24 Vdc, 110 Vac at 60 Hz, 220
Vac at 50 Hz, etc. Debounce times can also be configured. The hardware
also has a FIFO buffer that records the state of all input pins, as
well as a free running counter (FRC), when any input value changes.

What is a reasonable way to expose the voltage and debounce
configuration to userspace? Or the FIFO? 

Presently, I have an initial driver that creates a character device in
/dev and uses ioctls so a user can provide configuration, read
input/output state, and read the FIFO. There is also a custom sysfs
interface to access the same configuration values and data.The sysfs
interface is manily to provide something easier to use from shell, all
the functionality is also duplicated in the ioctl interface. I plan on
adding access to the input/output states through libgpio, but have not
finished this yet. I'd like to get this driver in a state where it
could be merged upstream, but I'm not sure that a custom sysfs class or
ioctls are the right way to go. Is there a better way for userspace to
provide this configuration, or access to the FIFO?

This is the first kernel driver I've worked on, so it's possible there
is an obvious way to implement this that I just haven't seen yet. Or
maybe this hardware is just too specific and doesn't make a good
candidate for pushing upstream. I'd appreciate any suggestions or
ideas!

Thanks,
Robert


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-08 22:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08 22:52 GPIO Driver Design Robert Joslyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).