[U-Boot] [PATCH 55/60] i2c: tegra: move pinmux setup to board files

Stephen Warren swarren at wwwdotorg.org
Tue Apr 19 22:59:35 CEST 2016


From: Stephen Warren <swarren at nvidia.com>

Remove funcmux calls from the Tegra I2C driver. Knowledge of pinmux
setup must come from either board files or DT; it should not be embedded
into board-agnostic driver code. The DT pinmux bindings do not allow
drivers to derive funcmux-style information, since the DT bindings are
pin-based whereas funcmux is controller-based, so there's no good way to
call the existing funcmux APIs from drivers. Converting drivers to use a
new (as yet non-existent in U-Boot) API that pulls pinmux information from
DT isn't useful for Tegra, since Tegra's DT files don't contain any
per-device pinmux tables, so this would simply be extra code that has no
effect; doesn't actually set up the pinmux. We are left with moving the
pinmux setup functionality into board files. In theory the board files
could be converted later to use DT, but that would be a separate change.

Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
 board/avionic-design/common/tamonten.c  |  5 +++++
 board/nvidia/seaboard/seaboard.c        |  3 +++
 board/nvidia/whistler/whistler.c        |  1 +
 board/toradex/colibri_t20/colibri_t20.c |  3 +++
 drivers/i2c/tegra_i2c.c                 | 19 -------------------
 5 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/board/avionic-design/common/tamonten.c b/board/avionic-design/common/tamonten.c
index e5748b01722a..c43a93de1fc6 100644
--- a/board/avionic-design/common/tamonten.c
+++ b/board/avionic-design/common/tamonten.c
@@ -37,5 +37,10 @@ void tegra_board_early_init_f(void)
 	pinmux_tristate_disable(PMUX_PINGRP_ATA);
 	/* for CD GPIO PH2 */
 	pinmux_tristate_disable(PMUX_PINGRP_ATD);
+#ifdef CONFIG_TARGET_MEDCOM_WIDE
+	funcmux_select(PERIPH_ID_DVC_I2C, FUNCMUX_DEFAULT);
+	funcmux_select(PERIPH_ID_I2C1, FUNCMUX_DEFAULT);
+	funcmux_select(PERIPH_ID_I2C3, FUNCMUX_DEFAULT);
+#endif
 	funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
 }
diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
index 8958de2bdcd8..a2d6ba557b7b 100644
--- a/board/nvidia/seaboard/seaboard.c
+++ b/board/nvidia/seaboard/seaboard.c
@@ -40,6 +40,9 @@ void tegra_board_early_init_f(void)
 	pinmux_tristate_disable(PMUX_PINGRP_ATA);
 	/* For CD GPIO PI5 */
 	pinmux_tristate_disable(PMUX_PINGRP_ATC);
+	funcmux_select(PERIPH_ID_DVC_I2C, FUNCMUX_DEFAULT);
+	funcmux_select(PERIPH_ID_I2C1, FUNCMUX_DEFAULT);
+	funcmux_select(PERIPH_ID_I2C3, FUNCMUX_DEFAULT);
 	funcmux_select(PERIPH_ID_KBC, FUNCMUX_DEFAULT);
 	funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
 }
diff --git a/board/nvidia/whistler/whistler.c b/board/nvidia/whistler/whistler.c
index d66742880487..549b67d5616f 100644
--- a/board/nvidia/whistler/whistler.c
+++ b/board/nvidia/whistler/whistler.c
@@ -27,6 +27,7 @@ void tegra_board_early_init_f(void)
 {
 	funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_SLXA_8BIT);
 	funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATC_ATD_8BIT);
+	funcmux_select(PERIPH_ID_DVC_I2C, FUNCMUX_DEFAULT);
 }
 
 int tegra_board_init(void)
diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c
index aff036ab243c..d6348f794f5e 100644
--- a/board/toradex/colibri_t20/colibri_t20.c
+++ b/board/toradex/colibri_t20/colibri_t20.c
@@ -62,6 +62,9 @@ void tegra_board_early_init_f(void)
 	pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
 	funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
 	pinmux_tristate_disable(PMUX_PINGRP_GMB);
+	funcmux_select(PERIPH_ID_DVC_I2C, FUNCMUX_DEFAULT);
+	funcmux_select(PERIPH_ID_I2C1, FUNCMUX_DEFAULT);
+	funcmux_select(PERIPH_ID_I2C3, FUNCMUX_DEFAULT);
 	funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
 }
 
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 4eb68b6e11b5..b462f2264b33 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -13,7 +13,6 @@
 #include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/funcmux.h>
 #include <asm/arch-tegra/clk_rst.h>
 #include <mach/tegra_i2c.h>
 #include "tegra_i2c_priv.h"
@@ -31,7 +30,6 @@ struct i2c_bus {
 	int			id;
 	enum periph_id		periph_id;
 	int			speed;
-	int			pinmux_config;
 	struct i2c_control	*control;
 	struct i2c_ctlr		*regs;
 	enum i2c_type		type;
@@ -110,8 +108,6 @@ static void i2c_init_controller(struct i2c_bus *i2c_bus)
 
 		setbits_le32(&dvc->ctrl3, DVC_CTRL_REG3_I2C_HW_SW_PROG_MASK);
 	}
-
-	funcmux_select(i2c_bus->periph_id, i2c_bus->pinmux_config);
 }
 
 static void send_packet_headers(
@@ -338,22 +334,7 @@ static int tegra_i2c_probe(struct udevice *dev)
 	i2c_bus->type = dev_get_driver_data(dev);
 	i2c_bus->regs = (struct i2c_ctlr *)dev_get_addr(dev);
 
-	/*
-	 * We don't have a binding for pinmux yet. Leave it out for now. So
-	 * far no one needs anything other than the default.
-	 */
-	i2c_bus->pinmux_config = FUNCMUX_DEFAULT;
 	i2c_bus->periph_id = clock_decode_periph_id(blob, node);
-
-	/*
-	 * We can't specify the pinmux config in the fdt, so I2C2 will not
-	 * work on Seaboard. It normally has no devices on it anyway.
-	 * You could add in this little hack if you need to use it.
-	 * The correct solution is a pinmux binding in the fdt.
-	 *
-	 *	if (i2c_bus->periph_id == PERIPH_ID_I2C2)
-	 *		i2c_bus->pinmux_config = FUNCMUX_I2C2_PTA;
-	 */
 	if (i2c_bus->periph_id == -1)
 		return -EINVAL;
 
-- 
2.8.1



More information about the U-Boot mailing list