From 66096378b33d5796746e16d405c0a47c49f61ebf Mon Sep 17 00:00:00 2001 From: Jin Park Date: Fri, 17 Jun 2011 15:17:19 +0900 Subject: arm: tegra: pinmux: Handling unfitted RSVD pinmux option. When call tegra_pinmux_set_func with unfitted RSVD pinmux option, to prevent unexpected potential problem, handle to finding more preferred value. Bug 839423 Signed-off-by: Jin Park Original-Change-Id: Idf8a1ece4317d14e94a69df0d1c8d450d7762c14 Reviewed-on: http://git-master/r/37185 Reviewed-by: Laxman Dewangan Reviewed-by: Mallikarjun Kasoju Rebase-Id: Rfb625aa025048c88c44fd96da1e8b0a3db8d013d --- arch/arm/mach-tegra/pinmux.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-tegra/pinmux.c b/arch/arm/mach-tegra/pinmux.c index e16797d3b420..71b5af6be4aa 100644 --- a/arch/arm/mach-tegra/pinmux.c +++ b/arch/arm/mach-tegra/pinmux.c @@ -295,6 +295,7 @@ static int tegra_pinmux_set_func(const struct tegra_pingroup_config *config) { int mux = -1; int i; + int find = 0; unsigned long reg; unsigned long flags; enum tegra_pingroup pg = config->pingroup; @@ -320,18 +321,37 @@ static int tegra_pinmux_set_func(const struct tegra_pingroup_config *config) func = pingroups[pg].func_safe; if (func & TEGRA_MUX_RSVD) { - mux = func & 0x3; + for (i = 0; i < 4; i++) { + if (pingroups[pg].funcs[i] & func) + mux = i; + + if (pingroups[pg].funcs[i] == func) { + mux = i; + find = 1; + break; + } + } } else { for (i = 0; i < 4; i++) { if (pingroups[pg].funcs[i] == func) { mux = i; + find = 1; break; } } } - if (mux < 0) + if (mux < 0) { + pr_err("The pingroup %s is not supported option %s\n", + pingroup_name(pg), func_name(func)); + WARN_ON(1); return -EINVAL; + } + + if (!find) + pr_warn("The pingroup %s was configured to %s instead of %s\n", + pingroup_name(pg), func_name(pingroups[pg].funcs[mux]), + func_name(func)); spin_lock_irqsave(&mux_lock, flags); -- cgit v1.2.3