[U-Boot] [PATCH 3/7] tegra: Enhance funcmux to support options

Simon Glass sjg at chromium.org
Mon Jan 9 23:53:29 CET 2012


Add support for an options parameter to funcmux_select() which allows
different pinmux options to be selected. An example of where this might
be used is a UART which supports 2-wire and 4-wire operation. The option
parameter in this case would specify which is required.

Invalid options cause failure with debug messages if enabled. Some
peripheral configs will only support certain options, and if these
required options are not provided, an error is also flagged.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
 arch/arm/cpu/armv7/tegra2/board.c          |    2 +-
 arch/arm/cpu/armv7/tegra2/funcmux.c        |   14 +++++++++++++-
 arch/arm/include/asm/arch-tegra2/funcmux.h |    3 ++-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra2/board.c b/arch/arm/cpu/armv7/tegra2/board.c
index ea06570..8b9e895 100644
--- a/arch/arm/cpu/armv7/tegra2/board.c
+++ b/arch/arm/cpu/armv7/tegra2/board.c
@@ -120,7 +120,7 @@ static void setup_uarts(int uart_ids)
 		if (uart_ids & (1 << i)) {
 			enum periph_id id = id_for_uart[i];
 
-			funcmux_select(id, 0);
+			funcmux_select(id, 0, 0);
 			clock_ll_start_uart(id);
 		}
 	}
diff --git a/arch/arm/cpu/armv7/tegra2/funcmux.c b/arch/arm/cpu/armv7/tegra2/funcmux.c
index 82d994a..ea40f1a 100644
--- a/arch/arm/cpu/armv7/tegra2/funcmux.c
+++ b/arch/arm/cpu/armv7/tegra2/funcmux.c
@@ -22,11 +22,13 @@
 /* Tegra2 high-level function multiplexing */
 #include <common.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/funcmux.h>
 #include <asm/arch/pinmux.h>
 
-int funcmux_select(enum periph_id id, int config)
+int funcmux_select(enum periph_id id, int config, int options)
 {
 	int bad_config = config != 0;
+	int required_options = 0;  /* options that should have been given */
 
 	switch (id) {
 	case PERIPH_ID_UART1:
@@ -97,6 +99,16 @@ int funcmux_select(enum periph_id id, int config)
 		return -1;
 	}
 
+	if (options) {
+		debug("%s: invalid options %#x for periph_id %d", __func__,
+		      options, id);
+		return -1;
+	}
+	if (required_options) {
+		debug("%s: mising required options %#x for periph_id %d",
+		      __func__, required_options, id);
+		return -1;
+	}
 	if (bad_config) {
 		debug("%s: invalid config %d for periph_id %d", __func__,
 		      config, id);
diff --git a/arch/arm/include/asm/arch-tegra2/funcmux.h b/arch/arm/include/asm/arch-tegra2/funcmux.h
index d4f9cfb..a3b315b 100644
--- a/arch/arm/include/asm/arch-tegra2/funcmux.h
+++ b/arch/arm/include/asm/arch-tegra2/funcmux.h
@@ -37,8 +37,9 @@
  *
  * @param id		Peripheral id
  * @param config	Configuration to use (generally 0)
+ * @param options	Options to enable (device-specific)
  * @return 0 if ok, -1 on error (e.g. incorrect id or config)
  */
-int funcmux_select(enum periph_id id, int config);
+int funcmux_select(enum periph_id id, int config, int options);
 
 #endif
-- 
1.7.3.1



More information about the U-Boot mailing list