All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] tegra: implement pinmux_avoid_func()
@ 2013-01-22 16:21 Stephen Warren
  2013-01-22 21:13 ` Simon Glass
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Warren @ 2013-01-22 16:21 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

This selects the "safe" (non-conflicting) mux function for a pin group
if the current setting matches the specified function.

Many signals can be routed to or from multiple different groups. Each
signal must be routed to or from only a single group at a given time.
Hence, if we program a particular group for a function, we must ensure
no other group is programmed to that same function first. This API
makes this easy.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
This patch will need updating due to the recently added Tegra30 support.
However, I'm posting it for Lucas, since his NAND patches can probably
benefit from this.

 arch/arm/cpu/tegra20-common/pinmux.c       |   23 +++++++++++++++++++++++
 arch/arm/include/asm/arch-tegra20/pinmux.h |    6 ++++++
 2 files changed, 29 insertions(+)

diff --git a/arch/arm/cpu/tegra20-common/pinmux.c b/arch/arm/cpu/tegra20-common/pinmux.c
index 5ad2121..47179f3 100644
--- a/arch/arm/cpu/tegra20-common/pinmux.c
+++ b/arch/arm/cpu/tegra20-common/pinmux.c
@@ -554,6 +554,29 @@ void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
 	writel(reg, muxctl);
 }
 
+static enum pmux_func pinmux_get_func(enum pmux_pingrp pin)
+{
+	struct pmux_tri_ctlr *pmt =
+			(struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
+	enum pmux_ctlid mux_id = tegra_soc_pingroups[pin].ctl_id;
+	u32 *muxctl = &pmt->pmt_ctl[MUXCTL_REG(mux_id)];
+	u32 reg;
+
+	reg = readl(muxctl);
+	reg >>= MUXCTL_SHIFT(mux_id);
+	reg &= 3;
+
+	return tegra_soc_pingroups[pin].funcs[reg];
+}
+
+void pinmux_avoid_func(enum pmux_pingrp pin, enum pmux_func avoid)
+{
+	if (pinmux_get_func(pin) != avoid)
+		return;
+
+	pinmux_set_func(pin, tegra_soc_pingroups[pin].func_safe);
+}
+
 void pinmux_config_pingroup(const struct pingroup_config *config)
 {
 	enum pmux_pingrp pin = config->pingroup;
diff --git a/arch/arm/include/asm/arch-tegra20/pinmux.h b/arch/arm/include/asm/arch-tegra20/pinmux.h
index a9b4eda..d36e18e 100644
--- a/arch/arm/include/asm/arch-tegra20/pinmux.h
+++ b/arch/arm/include/asm/arch-tegra20/pinmux.h
@@ -337,6 +337,12 @@ void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
 /* Set the mux function for a pin group */
 void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
 
+/*
+ * Select the "safe" (non-conflicting) mux function for a pin group if the
+ * current setting matches the specified function.
+ */
+void pinmux_avoid_func(enum pmux_pingrp pin, enum pmux_func func);
+
 /* Set the complete configuration for a pin group */
 void pinmux_config_pingroup(const struct pingroup_config *config);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-01-23  0:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22 16:21 [U-Boot] [PATCH] tegra: implement pinmux_avoid_func() Stephen Warren
2013-01-22 21:13 ` Simon Glass
2013-01-22 21:26   ` Stephen Warren
2013-01-22 21:42     ` Simon Glass
2013-01-22 22:14       ` Stephen Warren
2013-01-23  0:03         ` Simon Glass
2013-01-23  0:21           ` Stephen Warren
2013-01-23  0:26             ` Simon Glass

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.