summaryrefslogtreecommitdiff
path: root/include/gpio.wrap
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2014-06-24 07:52:49 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-06-26 02:43:01 +0000
commit9ccfd4553e708a5df4be3aa18b97c75da3f6c1b9 (patch)
treebd10678c7ee25901de97260967b8bee4a849baa5 /include/gpio.wrap
parent88c0ffd692b4e6d5fadc75bb15255e0684d6a1c9 (diff)
downloadchrome-ec-9ccfd4553e708a5df4be3aa18b97c75da3f6c1b9.tar.gz
gpio: Replace duplication in gpio declarations with X-macro file
Previously each board.h and board.c contained an enum and an array for gpio definitons that had to be manually kept in sync, with no compiler assistance other than that their lengths matched. This change adds a single gpio.inc file that declares all gpio's that a board uses and is used as an X-macro include file to generate both the gpio_signal enum and the gpio_list array. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=make buildall -j Change-Id: If9c9feca968619a59ff9f20701359bcb9374e4da Reviewed-on: https://chromium-review.googlesource.com/205354 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'include/gpio.wrap')
-rw-r--r--include/gpio.wrap47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/gpio.wrap b/include/gpio.wrap
new file mode 100644
index 0000000000..941d97ac67
--- /dev/null
+++ b/include/gpio.wrap
@@ -0,0 +1,47 @@
+/* -*- mode:c -*-
+ *
+ * Copyright (c) 2014 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.
+ */
+
+/*
+ * The GPIO macro is used to define a new GPIO pin name and function.
+ *
+ * The name is used to populate the gpio_signal enum by first prepending GPIO_
+ * to the name. It is also used to construct the string name that is presented
+ * in the shell interface. Similarly, the port parameter has GPIO_ prepended to
+ * it before it is used to initialize the port base address of a gpio_info
+ * struct. The pin number is used to create a bitmask. The flags and signal
+ * parameters are passed on to the gpio_info directly.
+ */
+#ifndef GPIO
+#define GPIO(name, port, pin, function, signal)
+#endif
+
+/*
+ * The UNIMPLEMENTED macro is used to define a GPIO that doesn't actually exist.
+ *
+ * Some GPIO names are well known and used by generic code, ENTERING_RW and WP_L
+ * are examples. If a particular board doesn't have a GPIO assigned to such a
+ * function/name then it should specify that that GPIO is not implemented using
+ * the UNIMPLEMENTED macro below in the board gpio.inc file. This macro creates
+ * an entry in the gpio_signal enum and the gpio_list array that is initialized
+ * to use the DUMMY_GPIO_BANK and a bitmask of zero. The chip GPIO layer is
+ * implemented such that writes to and reads from DUMMY_GPIO_BANK with a bitmask
+ * of zero are harmless.
+ *
+ * This allows common code that expects these GPIOs to exist to compile and have
+ * some reduced functionality.
+ */
+#ifndef UNIMPLEMENTED
+#define UNIMPLEMENTED(name)
+#endif
+
+#include "gpio.inc"
+
+/*
+ * Once the gpio.inc file has been included these macros are no longer needed.
+ */
+#undef GPIO
+#undef UNIMPLEMENTED