Allow non-root access to GPIO & PWM sysfs nodes

Mechanism borrowed from Pi to ensure full compatibility with libs
like python-periphery.
https://github.com/RPi-Distro/raspberrypi-sys-mods/blob/master/etc.armhf/udev/rules.d/99-com.rules

Note that a separate group 'gpio' is not used, instead the existing
group 'input' is. This is to allow updating an already flashed board
with this package to get the feature without re-flashing. Pi adds
the gpio group at image build time, requiring re-flash or manual
groupadd after update.

BUG: 144068132
Change-Id: I27ad8f826536ad6461496a6891c486311e8104d7
diff --git a/debian/mendel-minimal.udev b/debian/mendel-minimal.udev
index 0bcdc36..56b41ee 100644
--- a/debian/mendel-minimal.udev
+++ b/debian/mendel-minimal.udev
@@ -1,3 +1,13 @@
 SUBSYSTEM=="apex", MODE="0660", GROUP="apex"
 DEVPATH=="/module/ov5645_camera_mipi_v2", ACTION=="add", RUN+="/bin/chgrp video /sys%p/parameters/ov5645_af", RUN+="/bin/chmod ug+rw /sys%p/parameters/ov5645_af"
 DEVPATH=="/module/ov5645_camera_mipi_v2", ACTION=="change", ENV{TRIGGER}!="none", RUN+="/bin/chgrp video /sys%p/parameters/ov5645_af", RUN+="/bin/chmod ug+rw /sys%p/parameters/ov5645_af"
+SUBSYSTEM=="gpio", GROUP="input", MODE="0660"
+SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
+	chown -R root:input /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
+	chown -R root:input /sys$devpath && chmod -R 770 /sys$devpath\
+'"
+SUBSYSTEM=="pwm", GROUP="input", MODE="0660"
+SUBSYSTEM=="pwm*", PROGRAM="/bin/sh -c '\
+	chown -R root:input /sys/class/pwm && chmod -R 770 /sys/class/pwm;\
+	chown -R root:input /sys$devpath && chmod -R 770 /sys$devpath\
+'"