All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Thompson <nick.thompson@gefanuc.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Davinci: Table driven pinmux configuration
Date: Mon, 16 Nov 2009 12:15:35 +0000	[thread overview]
Message-ID: <4B014267.5030904@gefanuc.com> (raw)

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>
---
Applies to u-boot-ti:

 board/davinci/common/misc.c |   31 +++++++++++++++++++++++++++++++
 board/davinci/common/misc.h |   13 +++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c
index 9fab76f..25ca326 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;
+}
diff --git a/board/davinci/common/misc.h b/board/davinci/common/misc.h
index f6d8b1b..329c369 100644
--- a/board/davinci/common/misc.h
+++ b/board/davinci/common/misc.h
@@ -34,8 +34,21 @@ struct pinmux_config {
 	unsigned char	field;		/* field number */
 };
 
+/* pin table definition */
+struct pinmux_resource {
+	const struct pinmux_config	*pins;
+	const int 			n_pins;
+};
+
+#define PINMUX_ITEM(item) { \
+				.pins = item, \
+				.n_pins = ARRAY_SIZE(item) \
+			  }
+
 int dvevm_read_mac_address(uint8_t *buf);
 void dv_configure_mac_address(uint8_t *rom_enetaddr);
 int davinci_configure_pin_mux(const struct pinmux_config *pins, int n_pins);
+int davinci_configure_pin_mux_items(const struct pinmux_resource *item,
+				    int n_items);
 
 #endif /* __MISC_H */

             reply	other threads:[~2009-11-16 12:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-16 12:15 Nick Thompson [this message]
2009-12-03 10:25 ` [U-Boot] [PATCH] Davinci: Table driven pinmux configuration Nick Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B014267.5030904@gefanuc.com \
    --to=nick.thompson@gefanuc.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.