9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] Patch for BCM2711 GPIO
@ 2023-09-13 20:19 Kyle Nusbaum
  0 siblings, 0 replies; only message in thread
From: Kyle Nusbaum @ 2023-09-13 20:19 UTC (permalink / raw)
  To: 9front


I've recently started working on 9 again, with some RasPis.
I wasn't very happy with the GPIO device, and so decided to rewrite it.

I think what I ended up with is an improvement. It's feature-complete with the
old version, at least for BCM2711. I have not tested support for the older
boards, but I think it will not be completely functional. The old driver had
some code specifically for the different chips. I would want to add that before
calling it "done".

The structure under '#G/gpio' is one directory per GPIO pin, named after the
GPIO number (GPIO27 -> '#G/gpio/27'). Within each of these directories, there
is a value file, a status file, an event file, and a ctl file.

The status file prints out a human-readable description of the pin's
configuration. This is currently missing support for listing the registered

The value file prints the current value, and when in "out" function mode,
writing a "0" or "1" to the file will change the pin's value to high or low.

The event file will return a "1" any time an enabled event occurs.

The ctl file allows changing the configuration of the pin.
      function [in | out | 0 | 1 | 2 | 3 | 4 | 5] - Change the pin's function
            to input, output, or one of the 6 available pin-specific alternate
      pull [off | up | down] - Change the pull resistor on a pin, keeping a
            disconnected pin floating (off), high (up), or low (down).
      event [rising | falling] [on | off] - Enable or disable event reporting
            for rising or falling edges on the pin. When any enabled events
            occur, a "1"  will be written to the event file.

Things I want to do immediately:
      - Support listing registered events in the status file
      - Support PWM
      - Support the older BCM chips for older Raspberry Pis.

I'm looking for feedback on the code, the dev structure, etc. I've tried to
follow the style(6) guide. Let me know if I missed anything or misinterpreted

This is basically a rewrite of /sys/src/9/bcm/gpio.c and
/sys/src/9/bcm/devgpio.c Because of this, the diff is big, and probably hard  
to read without applying it as a patch. As such, I've included, along with the
full diff, copies of gpio.c and devgpio.c

Full diff: http://okturing.com/src/16918/body
gpio.c: http://okturing.com/src/16920/body
devgpio.c: http://okturing.com/src/16921/body

-- Kyle

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

only message in thread, other threads:[~2023-09-13 20:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13 20:19 [9front] Patch for BCM2711 GPIO Kyle Nusbaum

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).