All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/7] tegra: Add I2C support to funcmux
Date: Mon, 26 Dec 2011 10:11:47 -0800	[thread overview]
Message-ID: <1324923111-340-4-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1324923111-340-1-git-send-email-sjg@chromium.org>

Add support to funcmux for selecting I2C functions and programming
the pinmux appropriately.

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

diff --git a/arch/arm/cpu/armv7/tegra2/funcmux.c b/arch/arm/cpu/armv7/tegra2/funcmux.c
index 0878f51..82d994a 100644
--- a/arch/arm/cpu/armv7/tegra2/funcmux.c
+++ b/arch/arm/cpu/armv7/tegra2/funcmux.c
@@ -26,27 +26,70 @@
 
 int funcmux_select(enum periph_id id, int config)
 {
-	if (config != 0) {
-		debug("%s: invalid config %d for periph_id %d", __func__,
-		      config, id);
-		return -1;
-	}
+	int bad_config = config != 0;
+
 	switch (id) {
 	case PERIPH_ID_UART1:
-		pinmux_set_func(PINGRP_IRRX, PMUX_FUNC_UARTA);
-		pinmux_set_func(PINGRP_IRTX, PMUX_FUNC_UARTA);
-		pinmux_tristate_disable(PINGRP_IRRX);
-		pinmux_tristate_disable(PINGRP_IRTX);
+		if (config == 0) {
+			pinmux_set_func(PINGRP_IRRX, PMUX_FUNC_UARTA);
+			pinmux_set_func(PINGRP_IRTX, PMUX_FUNC_UARTA);
+			pinmux_tristate_disable(PINGRP_IRRX);
+			pinmux_tristate_disable(PINGRP_IRTX);
+		}
 		break;
 
 	case PERIPH_ID_UART2:
-		pinmux_set_func(PINGRP_UAD, PMUX_FUNC_IRDA);
-		pinmux_tristate_disable(PINGRP_UAD);
+		if (config == 0) {
+			pinmux_set_func(PINGRP_UAD, PMUX_FUNC_IRDA);
+			pinmux_tristate_disable(PINGRP_UAD);
+		}
 		break;
 
 	case PERIPH_ID_UART4:
-		pinmux_set_func(PINGRP_GMC, PMUX_FUNC_UARTD);
-		pinmux_tristate_disable(PINGRP_GMC);
+		if (config == 0) {
+			pinmux_set_func(PINGRP_GMC, PMUX_FUNC_UARTD);
+			pinmux_tristate_disable(PINGRP_GMC);
+		}
+		break;
+
+	case PERIPH_ID_DVC_I2C:
+		/* there is only one selection, pinmux_config is ignored */
+		if (config == 0) {
+			pinmux_set_func(PINGRP_I2CP, PMUX_FUNC_I2C);
+			pinmux_tristate_disable(PINGRP_I2CP);
+		}
+		break;
+
+	case PERIPH_ID_I2C1:
+		/* support pinmux_config of 0 for now, */
+		if (config == 0) {
+			pinmux_set_func(PINGRP_RM, PMUX_FUNC_I2C);
+			pinmux_tristate_disable(PINGRP_RM);
+		}
+		break;
+	case PERIPH_ID_I2C2: /* I2C2 */
+		switch (config) {
+		case 0:	/* DDC pin group, select I2C2 */
+			pinmux_set_func(PINGRP_DDC, PMUX_FUNC_I2C2);
+			/* PTA to HDMI */
+			pinmux_set_func(PINGRP_PTA, PMUX_FUNC_HDMI);
+			pinmux_tristate_disable(PINGRP_DDC);
+			break;
+		case 1:	/* PTA pin group, select I2C2 */
+			pinmux_set_func(PINGRP_PTA, PMUX_FUNC_I2C2);
+			/* set DDC_SEL to RSVDx (RSVD2 works for now) */
+			pinmux_set_func(PINGRP_DDC, PMUX_FUNC_RSVD2);
+			pinmux_tristate_disable(PINGRP_PTA);
+			bad_config = 0;
+			break;
+		}
+		break;
+	case PERIPH_ID_I2C3: /* I2C3 */
+		/* support pinmux_config of 0 for now */
+		if (config == 0) {
+			pinmux_set_func(PINGRP_DTF, PMUX_FUNC_I2C3);
+			pinmux_tristate_disable(PINGRP_DTF);
+		}
 		break;
 
 	default:
@@ -54,5 +97,11 @@ int funcmux_select(enum periph_id id, int config)
 		return -1;
 	}
 
+	if (bad_config) {
+		debug("%s: invalid config %d for periph_id %d", __func__,
+		      config, id);
+		return -1;
+	}
+
 	return 0;
 }
diff --git a/arch/arm/include/asm/arch-tegra2/funcmux.h b/arch/arm/include/asm/arch-tegra2/funcmux.h
index 2d724a2..d4f9cfb 100644
--- a/arch/arm/include/asm/arch-tegra2/funcmux.h
+++ b/arch/arm/include/asm/arch-tegra2/funcmux.h
@@ -32,6 +32,9 @@
  * The basic config is 0, and higher numbers indicate different
  * pinmux settings to bring the peripheral out on other pins,
  *
+ * This function also disables tristate for the function's pins,
+ * so that they operate in normal mode.
+ *
  * @param id		Peripheral id
  * @param config	Configuration to use (generally 0)
  * @return 0 if ok, -1 on error (e.g. incorrect id or config)
-- 
1.7.3.1

  parent reply	other threads:[~2011-12-26 18:11 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-26 18:11 [U-Boot] [PATCH 0/7] tegra: Add I2C driver and associated parts Simon Glass
2011-12-26 18:11 ` [U-Boot] [PATCH 1/7] tegra: Rename NV_PA_PMC_BASE to TEGRA2_PMC_BASE Simon Glass
2011-12-26 19:12   ` Marek Vasut
2012-01-09 21:34   ` Stephen Warren
2011-12-26 18:11 ` [U-Boot] [PATCH 2/7] tegra: fdt: Add extra I2C definitions for U-Boot Simon Glass
2011-12-26 19:12   ` Marek Vasut
2011-12-27  4:35   ` Stephen Warren
2011-12-27  5:15     ` Simon Glass
2011-12-29  6:40       ` Stephen Warren
2011-12-29  7:11         ` Simon Glass
2011-12-26 18:11 ` Simon Glass [this message]
2012-01-09 21:36   ` [U-Boot] [PATCH 3/7] tegra: Add I2C support to funcmux Stephen Warren
2012-01-09 21:40     ` Simon Glass
2012-01-09 22:56       ` Simon Glass
2011-12-26 18:11 ` [U-Boot] [PATCH 4/7] tegra: Add I2C driver Simon Glass
2011-12-26 19:15   ` Marek Vasut
2012-01-08 16:57     ` Simon Glass
2012-01-08 17:06       ` Marek Vasut
2012-01-08 18:16         ` Simon Glass
2012-01-08  5:57   ` Mike Frysinger
2012-01-08 16:46     ` Simon Glass
2012-01-09 22:07   ` Stephen Warren
2012-01-12  4:17     ` Simon Glass
2012-01-12 19:14       ` Stephen Warren
2012-01-13  7:12         ` Heiko Schocher
2012-01-13 14:49           ` Simon Glass
2012-01-13 15:27             ` Heiko Schocher
2012-02-03 23:18         ` Simon Glass
2011-12-26 18:11 ` [U-Boot] [PATCH 5/7] tegra: Initialise I2C on Nvidia boards Simon Glass
2011-12-26 18:11 ` [U-Boot] [PATCH 6/7] tegra: Select I2C ordering for Seaboard Simon Glass
2012-01-09 21:42   ` Stephen Warren
2011-12-26 18:11 ` [U-Boot] [PATCH 7/7] tegra: Enable I2C on Seaboard Simon Glass
2012-01-09 21:45   ` Stephen Warren
     [not found]     ` <CAPnjgZ3jTm6j-fK_Kn==W3uGr=8pREEWXawP39kojLzzSH07wQ@mail.gmail.com>
     [not found]       ` <74CDBE0F657A3D45AFBB94109FB122FF17801D1D4A@HQMAIL01.nvidia.com>
2012-01-12 19:10         ` Simon Glass
2012-01-12 19:21           ` Stephen Warren
2012-01-12 19:28             ` Simon Glass
2012-01-13  7:34           ` Heiko Schocher

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=1324923111-340-4-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --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.