Export dut_flaga/b GPIO devices on different platforms.
New udev rules for (a) assigning the dut_flaga/b identifiers
corresponding to different platforms as properties of the GPIO chip
device; and (b) exporting the dut_flaga/b GPIOs.
Note 1: we currently do not export the GPIOs for Stumpy, since it's
board implementation did not include pull-up wiring and therefore
dut_flaga/b readings may return arbitrary values when the debug header
is not connected to Servo. This should be resolved and/or worked around
on both client/server end before we can support Stumpy.
Note 2: in the future, we will migrate all GPIO functionality outside of
update engine, into its own dedicated package.
BUG=chromium-os:25397
TEST=GPIOs were properly exported on x86-alex
Change-Id: I11e73625c29329311416a88584e4c58291c450de
Reviewed-on: https://gerrit.chromium.org/gerrit/16745
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Scott James Remnant <keybuk@chromium.org>
diff --git a/99-gpio-dutflag.rules b/99-gpio-dutflag.rules
new file mode 100644
index 0000000..542b02d
--- /dev/null
+++ b/99-gpio-dutflag.rules
@@ -0,0 +1,31 @@
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# These rules are in charge of exporting the dut_flaga and dut_flagb GPIOs on
+# different platforms. The GPIO IDs are registered as attributes, which can be
+# detected by client processes. This was motivated by update engine
+# auto-testing framework.
+
+# Identify the GPIO chip and set dut_flaga identifier on different platforms.
+# Unfortunately, Mario does not have a debug header, hence no GPIOs exposed.
+#
+# - Alex:
+ATTR{[dmi/id]product_name}=="Alex", SUBSYSTEM=="gpio", KERNEL=="gpiochip192", \
+ ENV{ID_GPIO_DUTFLAGA}="205", ENV{ID_GPIO_DUTFLAGB}="202"
+# - ZGB:
+ATTR{[dmi/id]product_name}=="ZGB", SUBSYSTEM=="gpio", KERNEL=="gpiochip192", \
+ ENV{ID_GPIO_DUTFLAGA}="216", ENV{ID_GPIO_DUTFLAGB}="195"
+# - Lumpy, Stumpy:
+# TODO(garnold) Stumpy is current disabled, as its dutflag GPIOs are
+# non-pull-up wired, which means that they can read arbitrary values when not
+# connected to Servo. Once fixed or properly handled by the application, this
+# should read "Lumpy|Stumpty".
+ATTR{[dmi/id]product_name}=="Lumpy", SUBSYSTEM=="gpio", KERNEL=="gpiochip160", \
+ ENV{ID_GPIO_DUTFLAGA}="173", ENV{ID_GPIO_DUTFLAGB}="170"
+
+# Export dut_flaga/b and register their identifier as an attribute.
+ACTION=="add|change", SUBSYSTEM=="gpio", \
+ ENV{ID_GPIO_DUTFLAGA}=="?*", ENV{ID_GPIO_DUTFLAGB}=="?*", \
+ ATTR{subsystem/export}="%E{ID_GPIO_DUTFLAGA}", \
+ ATTR{subsystem/export}="%E{ID_GPIO_DUTFLAGB}"