[U-Boot] [PATCH v2 2/7] tegra: Add enum to select from available funcmux configs

Simon Glass sjg at chromium.org
Wed Jan 11 23:42:23 CET 2012


We want to give a name to each available funcmux config. For now we just
use the pin group names (even through it is verbose) since there seems
to be nothing better.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Add enum to select from available funcmux configs

 arch/arm/cpu/armv7/tegra2/board.c          |    2 +-
 arch/arm/cpu/armv7/tegra2/funcmux.c        |    9 +++++----
 arch/arm/include/asm/arch-tegra2/funcmux.h |   12 +++++++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra2/board.c b/arch/arm/cpu/armv7/tegra2/board.c
index ea06570..5f296ab 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, FUNCMUX_DEFAULT);
 			clock_ll_start_uart(id);
 		}
 	}
diff --git a/arch/arm/cpu/armv7/tegra2/funcmux.c b/arch/arm/cpu/armv7/tegra2/funcmux.c
index 0f03b9f..4706788 100644
--- a/arch/arm/cpu/armv7/tegra2/funcmux.c
+++ b/arch/arm/cpu/armv7/tegra2/funcmux.c
@@ -22,15 +22,16 @@
 /* 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 bad_config = config != 0;
+	int bad_config = config != FUNCMUX_DEFAULT;
 
 	switch (id) {
 	case PERIPH_ID_UART1:
-		if (config == 0) {
+		if (config == FUNCMUX_UART1_IRRX_IRTX) {
 			pinmux_set_func(PINGRP_IRRX, PMUX_FUNC_UARTA);
 			pinmux_set_func(PINGRP_IRTX, PMUX_FUNC_UARTA);
 			pinmux_tristate_disable(PINGRP_IRRX);
@@ -39,14 +40,14 @@ int funcmux_select(enum periph_id id, int config)
 		break;
 
 	case PERIPH_ID_UART2:
-		if (config == 0) {
+		if (config == FUNCMUX_UART2_IRDA) {
 			pinmux_set_func(PINGRP_UAD, PMUX_FUNC_IRDA);
 			pinmux_tristate_disable(PINGRP_UAD);
 		}
 		break;
 
 	case PERIPH_ID_UART4:
-		if (config == 0) {
+		if (config == FUNCMUX_UART4_GMC) {
 			pinmux_set_func(PINGRP_GMC, PMUX_FUNC_UARTD);
 			pinmux_tristate_disable(PINGRP_GMC);
 		}
diff --git a/arch/arm/include/asm/arch-tegra2/funcmux.h b/arch/arm/include/asm/arch-tegra2/funcmux.h
index d4f9cfb..791f301 100644
--- a/arch/arm/include/asm/arch-tegra2/funcmux.h
+++ b/arch/arm/include/asm/arch-tegra2/funcmux.h
@@ -24,6 +24,16 @@
 #ifndef __FUNCMUX_H
 #define __FUNCMUX_H
 
+/* Configs supported by the func mux */
+enum {
+	FUNCMUX_DEFAULT = 0,	/* default config */
+
+	/* UART configs */
+	FUNCMUX_UART1_IRRX_IRTX = 0,
+	FUNCMUX_UART2_IRDA = 0,
+	FUNCMUX_UART4_GMC = 0,
+};
+
 /**
  * Select a config for a particular peripheral.
  *
@@ -36,7 +46,7 @@
  * so that they operate in normal mode.
  *
  * @param id		Peripheral id
- * @param config	Configuration to use (generally 0)
+ * @param config	Configuration to use (FUNCMUX_...), 0 for default
  * @return 0 if ok, -1 on error (e.g. incorrect id or config)
  */
 int funcmux_select(enum periph_id id, int config);
-- 
1.7.3.1



More information about the U-Boot mailing list