[U-Boot] [PATCH] tegra: implement pinmux_avoid_func()

Simon Glass sjg at chromium.org
Tue Jan 22 22:13:00 CET 2013


Hi Stephen,

On Tue, Jan 22, 2013 at 8:21 AM, Stephen Warren <swarren at wwwdotorg.org> wrote:
> From: Stephen Warren <swarren at 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.

What is the intended use of this function? (sorry, yes, I am confused :-)

>
> Signed-off-by: Stephen Warren <swarren at 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;

Is this an error - does the caller need to know?

> +
> +       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.
> + */

What does it do when it doesn't match, and perhaps comment when you
might find this function useful?

> +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
>

Regards,
Simon


More information about the U-Boot mailing list