summaryrefslogtreecommitdiff
path: root/board/davinci/common/misc.c
diff options
context:
space:
mode:
authorNick Thompson <nick.thompson@gefanuc.com>2009-12-12 12:10:51 -0500
committerTom Rix <Tom.Rix@windriver.com>2010-01-04 08:48:16 -0600
commit90110e0eab5ac6ab714109ce1fd8873c858dd552 (patch)
tree18fa0a14b05b3cdb793459e64ef00f10d3d96131 /board/davinci/common/misc.c
parent1270ec13d4fbae48a537dc76d418a6efa72f5725 (diff)
Davinci: Table driven pinmux configuration
Davinci: Table driven pinmux configuration Add code to allow pinmux_config tables to be grouped and configured as a single resource. This removes multiple calls to the pinmux configuration code from board_init and allows pinmuxes to be individually configured and added by data manipulation only. All related #ifdefs can the be removed from board_init code and since the compiler optimises away statics, #ifdefs can be reduced in the data definitions as well. Signed-off-by: Nick Thompson <nick.thompson@gefanuc.com>
Diffstat (limited to 'board/davinci/common/misc.c')
-rw-r--r--board/davinci/common/misc.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c
index 9fab76fa5d8..25ca3265007 100644
--- a/board/davinci/common/misc.c
+++ b/board/davinci/common/misc.c
@@ -155,3 +155,34 @@ int davinci_configure_pin_mux(const struct pinmux_config *pins,
return 0;
}
+
+/*
+ * Configure multiple pinmux resources.
+ *
+ * Takes an pinmux_resource array of pinmux_config and pin counts:
+ *
+ * const struct pinmux_resource pinmuxes[] = {
+ * PINMUX_ITEM(uart_pins),
+ * PINMUX_ITEM(i2c_pins),
+ * };
+ *
+ * The number of items in the array must be passed (ARRAY_SIZE can provide
+ * this value conveniently).
+ *
+ * Each item entry is configured in the defined order. If configuration
+ * of any item fails, -1 is returned and none of the following items are
+ * configured. On success, 0 is returned.
+ */
+int davinci_configure_pin_mux_items(const struct pinmux_resource *item,
+ const int n_items)
+{
+ int i;
+
+ for (i = 0; i < n_items; i++) {
+ if (davinci_configure_pin_mux(item[i].pins,
+ item[i].n_pins) != 0)
+ return -1;
+ }
+
+ return 0;
+}