Bug 226787 - [new port] misc/raspberrypi-gpioshutdown: kernel module that 'shuts down' I/O pins at the point where the operating system is halted
Summary: [new port] misc/raspberrypi-gpioshutdown: kernel module that 'shuts down' I/O...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-19 20:28 UTC by Bob Frazier
Modified: 2018-03-20 08:01 UTC (History)
0 users

See Also:


Attachments
'shar' archive for port (8.43 KB, text/plain)
2018-03-19 20:28 UTC, Bob Frazier
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bob Frazier 2018-03-19 20:28:09 UTC
Created attachment 191641 [details]
'shar' archive for port

New port 'misc/raspberrypi-gpioshutdown' provides a kernel module 'gpioshutdown' that effectively 'shuts down' I/O pins at the point where the operating system is halted, by re-configuring them as input pins with no pullup/pulldown.  This is similar to the "powerup" state, and somewhat duplicates what Linux does already.

Additionally, it provides 2 'sysctl' variables "kern.gpioshutdown.led_gpio" and "kern.gpioshutdown.led_gpio_set" by which you can optionally define the GPIO pin of an LED that you want kept as an output (instead of changing it to an input), and its 'on' polarity (0 or 1), which will be set to an 'on' state before sync'ing the disks, and then to an 'off' when it's safe to power off.  (This is a workaround due to some odd behavior from the led driver, that seems to be easier to implement than any other idea I had)

It also includes an rc.d script "gpioshutdown" to generically configure a Raspberry Pi to use the power LED [or in the case of Model 1, the "ok" LED] as a shutdown indicator.

By loading this kernel module, all output GPIO pins (other than the one identified by the sysctl variable) are effectively placed into a high impedance state once it is safe to turn off the device.  An external hardware 'power control' device (or an indicator LED) could then be used to determine that it is safe to power off after shutdown, specifically for a headless system.  Many such external devices (such as the ATXRaspi) exist already.  This kernel driver, or one like it, would be necessary for these external power control boards to be compatible with FreeBSD.

Additionally this port attempts to correct the issues brought up in problem report 211979.  Additionally, it is marked for armv6 architecture only, and is specifically targeted for the Raspberry Pi (and named a such).
Comment 1 Mark Linimon freebsd_committer 2018-03-20 06:43:33 UTC
IMHO this should be ONLY_FOR_ARCHS= armv6 armv7
Comment 2 Bob Frazier 2018-03-20 08:01:36 UTC
thanks, but I don't have an armv7 device to test it with.  I understand that you can build for armv7 in '-CURRENT' but it's not released yet.  However, by the time 12 has an RC I'll probably be testing this port with an appropriate device.

again, thanks for that info.